Changeset 539
- Timestamp:
- 03/05/08 18:00:56 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42make/libx42make.vcproj
r523 r539 529 529 </Filter> 530 530 <Filter 531 Name="batcher" 532 > 533 <File 534 RelativePath=".\adjacency.cpp" 535 > 536 </File> 537 <File 538 RelativePath=".\batcher.h" 539 > 540 </File> 541 <File 542 RelativePath=".\topology-split.cpp" 543 > 544 </File> 545 <File 546 RelativePath=".\topology.cpp" 531 Name="modelbuilder" 532 > 533 <File 534 RelativePath=".\modelbuilder-animation.cpp" 535 > 536 </File> 537 <File 538 RelativePath=".\modelbuilder-batch.cpp" 539 > 540 </File> 541 <File 542 RelativePath=".\modelbuilder-cull.cpp" 543 > 544 </File> 545 <File 546 RelativePath=".\modelbuilder-enumerators.cpp" 547 > 548 </File> 549 <File 550 RelativePath=".\modelbuilder-geometry.cpp" 551 > 552 </File> 553 <File 554 RelativePath=".\modelbuilder-influences.cpp" 555 > 556 </File> 557 <File 558 RelativePath=".\modelbuilder-skeleton.cpp" 559 > 560 </File> 561 <File 562 RelativePath=".\modelbuilder-write.cpp" 563 > 564 </File> 565 <File 566 RelativePath=".\modelbuilder.cpp" 547 567 > 548 568 </File> … … 579 599 > 580 600 </File> 601 <Filter 602 Name="batcher" 603 > 604 <File 605 RelativePath=".\adjacency.cpp" 606 > 607 </File> 608 <File 609 RelativePath=".\batcher.h" 610 > 611 </File> 612 <File 613 RelativePath=".\topology-split.cpp" 614 > 615 </File> 616 <File 617 RelativePath=".\topology.cpp" 618 > 619 </File> 620 </Filter> 581 621 </Filter> 582 622 <File … … 656 696 </FileConfiguration> 657 697 </File> 658 <File659 RelativePath=".\modelbuilder-animation.cpp"660 >661 </File>662 <File663 RelativePath=".\modelbuilder-batch.cpp"664 >665 </File>666 <File667 RelativePath=".\modelbuilder-cull.cpp"668 >669 </File>670 <File671 RelativePath=".\modelbuilder-enumerators.cpp"672 >673 </File>674 <File675 RelativePath=".\modelbuilder-geometry.cpp"676 >677 </File>678 <File679 RelativePath=".\modelbuilder-influences.cpp"680 >681 </File>682 <File683 RelativePath=".\modelbuilder-skeleton.cpp"684 >685 </File>686 <File687 RelativePath=".\modelbuilder-write.cpp"688 >689 </File>690 <File691 RelativePath=".\modelbuilder.cpp"692 >693 </File>694 698 </Files> 695 699 <Globals> branches/morph-targets/libx42make/modelbuilder-batch.cpp
r538 r539 95 95 void split_by_weight_count(); 96 96 void greedy_split( size_t max_verts, size_t max_prims, size_t max_influences ); 97 void topological_split( size_t max_verts, size_t max_prims, size_t max_influences ); 97 void topological_split_from_root( size_t max_verts, size_t max_prims, size_t max_influences ); 98 void topological_split_from_leaves( size_t max_verts, size_t max_prims, size_t max_influences ); 98 99 99 100 void cost_ordered_merge( size_t max_verts, float up_merge_limit_factor ); … … 101 102 private: 102 103 group_split_target_ptr internal_merge_groups( group_split_target_ptr a, group_split_target_ptr b ); 104 }; 105 106 class adjacency 107 { 108 public: 109 adjacency() 110 { 111 } 112 113 void initialize( const std::vector< index > &tris ); 114 115 size_t adj_len( size_t tri_idx ) const { return entries[tri_idx].len; } 116 size_t adj_idx( size_t tri_idx, size_t adj_idx ) const { return values[entries[tri_idx].beg + adj_idx]; } 117 118 private: 119 struct adj_entry 120 { 121 size_t beg; 122 size_t len; 123 }; 124 125 std::vector< adj_entry > entries; 126 std::vector< size_t > values; 103 127 }; 104 128 … … 245 269 246 270 return ret; 271 } 272 273 /* 274 class adjacency 275 */ 276 277 void adjacency::initialize( const std::vector< index > &tris ) 278 { 279 entries.resize( tris.size() / 3 ); 280 281 values.clear(); 282 values.reserve( tris.size() ); 283 284 //for each triangle 285 for( uint t = 0; t < entries.size(); t++ ) 286 { 287 entries[t].beg = (uint)values.size(); 288 289 //skip degenerates 290 if( tris[t * 3 + 0] == tris[t * 3 + 1] || 291 tris[t * 3 + 1] == tris[t * 3 + 2] || 292 tris[t * 3 + 2] == tris[t * 3 + 0] ) 293 continue; 294 295 //for each edge 296 for( uint e = 0; e < 3; e++ ) 297 { 298 uint es = tris[t * 3 + e]; 299 uint ee = tris[t * 3 + ((e + 1) % 3)]; 300 301 //for each other triangle 302 for( uint ot = 0; ot < entries.size(); ot++ ) 303 { 304 if( ot == t ) 305 continue; 306 307 //skip degenerates 308 if( tris[ot * 3 + 0] == tris[ot * 3 + 1] || 309 tris[ot * 3 + 1] == tris[ot * 3 + 2] || 310 tris[ot * 3 + 2] == tris[ot * 3 + 0] ) 311 continue; 312 313 //for each other edge 314 for( uint oe = 0; oe < 3; oe++ ) 315 { 316 uint oes = tris[ot * 3 + oe]; 317 uint oee = tris[ot * 3 + ((oe + 1) % 3)]; 318 319 if( es == oee && ee == oes ) 320 values.push_back( ot ); 321 } 322 } 323 } 324 325 entries[t].len = (uint)values.size() - entries[t].beg; 326 } 247 327 } 248 328 … … 429 509 void group_split_context::split_by_weight_count() 430 510 { 431 if( target_groups.size() ) 432 throw error(); 511 target_groups.clear(); 433 512 434 513 for( size_t i = 0; i < vertex_weights::max_weights; i++ ) … … 461 540 size_t max_prims, size_t max_influences ) 462 541 { 542 target_groups.clear(); 543 463 544 for( size_t i_prim = 0; i_prim < prim_count; i_prim++ ) 464 545 { … … 501 582 } 502 583 503 void group_split_context::topological_split( size_t max_verts, 584 void group_split_context::topological_split_from_leaves( size_t max_verts, 585 size_t max_prims, size_t max_influences ) 586 { 587 if( elems_per_prim != 3 ) 588 throw error( "Topological split only works on triangles." ); 589 590 591 } 592 593 void group_split_context::topological_split_from_root( size_t max_verts, 504 594 size_t max_prims, size_t max_influences ) 505 595 {
