Changeset 523
- Timestamp:
- 02/25/08 15:52:26 (11 months ago)
- Files:
-
- branches/morph-targets/libx42make/include/x42make-modelbuilder.h (modified) (5 diffs)
- branches/morph-targets/libx42make/libx42make.vcproj (modified) (1 diff)
- branches/morph-targets/libx42make/modelbuilder-batch.cpp (added)
- branches/morph-targets/libx42make/modelbuilder-geometry.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42make/include/x42make-modelbuilder.h
r522 r523 61 61 void intrusive_ptr_release( const ref_obj *r ); 62 62 63 class group_split_target; 64 class group_split_context; 65 63 66 class model_data_builder; 64 67 }; … … 442 445 void remap_vertices( const std::vector< index > &remap ); 443 446 447 std::vector< index > get_point_list_indices() const; 448 std::vector< index > get_line_list_indices() const; 444 449 std::vector< index > get_triangle_list_indices() const; 450 451 std::vector< index > get_list_indices() const; 445 452 446 453 X42_DECLARE_ENUM( optimize_type ) … … 454 461 size_t vertex_count() const { return base_shape.size(); } 455 462 size_t index_count() const { return indices.size(); } 463 size_t element_count() const { return indices.size() ? indices.size() : vertex_count(); } 464 size_t primitive_count() const { return prim_type.elems_to_prims( (uint)element_count() ); } 456 465 457 466 size_t count_max_influences_per_vert() const; … … 467 476 468 477 friend class model_builder; 478 479 friend class _impl::group_split_target; 480 friend class _impl::group_split_context; 469 481 }; 470 482 … … 482 494 483 495 friend class lod; 496 497 friend class _impl::group_split_target; 498 friend class _impl::group_split_context; 484 499 }; 485 500 branches/morph-targets/libx42make/libx42make.vcproj
r521 r523 661 661 </File> 662 662 <File 663 RelativePath=".\modelbuilder-batch.cpp" 664 > 665 </File> 666 <File 663 667 RelativePath=".\modelbuilder-cull.cpp" 664 668 > branches/morph-targets/libx42make/modelbuilder-geometry.cpp
r521 r523 239 239 } 240 240 241 std::vector< index > geometry::get_point_list_indices() const 242 { 243 if( prim_type != primitive_type::point_list ) 244 throw error( "Can't get point indices for non-point geometry." ); 245 246 std::vector< index > ret; 247 248 if( indices.size() ) 249 { 250 ret.insert( ret.end(), indices.begin(), indices.end() ); 251 } 252 else 253 { 254 ret.resize( vertex_count() ); 255 for( size_t i = 0; i < ret.size(); i++ ) 256 ret[i] = (index)i; 257 } 258 259 return ret; 260 } 261 262 std::vector< index > geometry::get_line_list_indices() const 263 { 264 switch( prim_type ) 265 { 266 case primitive_type::line_list: 267 case primitive_type::line_strip: 268 break; 269 270 default: 271 throw error( "Can't get triangle indices for non-triangle geometry." ); 272 } 273 274 size_t elem_count = index_count() ? index_count() : vertex_count(); 275 size_t prim_count = (size_t)primitive_type::elems_to_prims( prim_type, (uint)elem_count ); 276 277 std::vector< index > ret( prim_count * 2 ); 278 279 if( prim_type == primitive_type::line_list && index_count() ) 280 { 281 if( indices.size() != ret.size() ) 282 throw error( "Odd index count." ); 283 284 std::copy( indices.begin(), indices.end(), ret.begin() ); 285 } 286 else 287 { 288 size_t i = 0; 289 290 primitive_iterator< index > iter( prim_type, &indices[0], (uint)indices.size() ); 291 while( iter.next() ) 292 { 293 ret[i + 0] = iter.current( 0 ); 294 ret[i + 1] = iter.current( 1 ); 295 296 i += 2; 297 } 298 } 299 300 return ret; 301 } 302 241 303 std::vector< index > geometry::get_triangle_list_indices() const 242 304 { … … 280 342 281 343 return ret; 344 } 345 346 std::vector< index > geometry::get_list_indices() const 347 { 348 switch( prim_type ) 349 { 350 case primitive_type::point_list: 351 return get_point_list_indices(); 352 353 case primitive_type::line_list: 354 case primitive_type::line_strip: 355 return get_line_list_indices(); 356 357 case primitive_type::triangle_list: 358 case primitive_type::triangle_strip: 359 case primitive_type::triangle_fan: 360 return get_triangle_list_indices(); 361 362 default: 363 throw error( "Invalid primitive type." ); 364 } 282 365 } 283 366
