Changeset 514
- Timestamp:
- 02/21/08 03:01:30 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42make/include/x42make-modelbuilder.h
r513 r514 371 371 372 372 std::vector< index > get_triangle_list_indices() const; 373 void optimize( bool generate_stitched_strips = false ); 373 374 X42_DECLARE_ENUM( optimize_type ) 375 match_current, 376 prefer_lists, 377 prefer_strips, 378 X42_END_ENUM( optimize_type ); 379 380 void optimize( optimize_type opt_type = optimize_type::match_current ); 374 381 375 382 size_t vertex_count() const { return base_shape.size(); } … … 435 442 influence_ptr create_influence( const bone_ptr &bone = bone_ptr(), const ::x42::math::affine &matrix = ::x42::math::affinei() ); 436 443 tag_ptr create_tag( const std::string &name = std::string(), const bone_ptr &bone = bone_ptr(), const ::x42::math::affine &matrix = ::x42::math::affinei() ); 444 445 void optimize_geometry( geometry::optimize_type opt_type = geometry::optimize_type::match_current ); 437 446 438 447 void begin_bone_update(); //suspends bone validation and sorting branches/morph-targets/libx42make/modelbuilder-geometry.cpp
r513 r514 232 232 } 233 233 234 void geometry::optimize( bool generate_stitched_strips)234 void geometry::optimize( optimize_type opt_type ) 235 235 { 236 236 if( !indices.size() ) … … 238 238 return; 239 239 240 bool generate_stitched_strips; 241 240 242 switch( prim_type ) 241 243 { … … 244 246 return; 245 247 248 case primitive_type::triangle_fan: 249 if( opt_type == optimize_type::match_current ) 250 return; 251 252 generate_stitched_strips = false; //silence warning 253 break; 254 246 255 case primitive_type::triangle_list: 256 generate_stitched_strips = false; 257 break; 258 247 259 case primitive_type::triangle_strip: 248 case primitive_type::triangle_fan:260 generate_stitched_strips = true; 249 261 break; 250 262 … … 254 266 } 255 267 268 switch( opt_type ) 269 { 270 case optimize_type::prefer_lists: 271 generate_stitched_strips = false; 272 break; 273 274 case optimize_type::prefer_strips: 275 generate_stitched_strips = true; 276 break; 277 } 278 256 279 if( vertex_count() > index_traits::max_val ) 257 280 //nv's lib can't handle these … … 285 308 { 286 309 if( num_prim_groups != 1 ) 287 { 288 optimize( false ); //failed strips, give it one more shot as lists 289 return; 290 } 291 else 292 prim_type = primitive_type::triangle_strip; 310 throw error( "NVTriStrip reterned unstitched strips." ); 311 312 prim_type = primitive_type::triangle_strip; 293 313 } 294 314 else … … 296 316 297 317 //build the remap table (wheee!) 298 std::vector< index > remap_table( vertex_count() ); 299 300 //TODO 301 318 std::vector< index > remap_table( vertex_count(), index_traits::max_val ); 319 std::vector< index > new_indices; 320 321 new_indices.reserve( index_count() ); 322 323 for( nv::PrimitiveGroup *pg = strip, *rpg = remap; num_prim_groups--; pg++, rpg++ ) 324 { 325 if( generate_stitched_strips ) 326 { 327 if( pg->type != nv::PT_STRIP ) 328 throw error( "NVTriStrip produced non-strip." ); 329 } 330 else 331 { 332 if( pg->type != nv::PT_LIST ) 333 throw error( "NVTriStrip produced non-list." ); 334 } 335 336 for( uint i = 0; i < pg->numIndices; i++ ) 337 { 338 ushort src_idx = pg->indices[i]; 339 ushort dst_idx = rpg->indices[i]; 340 341 remap_table[src_idx] = dst_idx; 342 new_indices.push_back( src_idx ); 343 } 344 } 345 346 std::swap( indices, new_indices ); 302 347 remap_vertices( remap_table ); 303 348 } … … 330 375 */ 331 376 377 void model_builder::optimize_geometry( geometry::optimize_type opt_type ) 378 { 379 for( group_enumerator iter( *this ); iter.next(); ) 380 { 381 iter.current()->group_geometry.optimize( opt_type ); 382 } 383 } 384 332 385 }; 333 386 };
