Changeset 507
- Timestamp:
- 02/19/08 14:24:52 (11 months ago)
- Files:
-
- branches/morph-targets/libx42make/include/x42make-modelbuilder.h (added)
- branches/morph-targets/libx42make/include/x42make-modeldata.h (modified) (3 diffs)
- branches/morph-targets/libx42make/include/x42make.h (modified) (1 diff)
- branches/morph-targets/libx42make/libx42make.vcproj (modified) (3 diffs)
- branches/morph-targets/libx42make/modelbuilder-geometry.cpp (added)
- branches/morph-targets/libx42make/modelbuilder.cpp (added)
- branches/morph-targets/libx42make/modeldata-batch.cpp (modified) (12 diffs)
- branches/morph-targets/libx42make/modeldata-optimize.cpp (modified) (5 diffs)
- branches/morph-targets/libx42make/modeldata.cpp (modified) (3 diffs)
- branches/morph-targets/libx42make/topology-split.cpp (modified) (1 diff)
- branches/morph-targets/libx42pp/include/x42types-imp.hpp (modified) (3 diffs)
- branches/morph-targets/libx42pp/include/x42types.h (modified) (6 diffs)
- branches/morph-targets/x42maya/Export-Gather.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42make/include/x42make-modeldata.h
r506 r507 83 83 }; 84 84 85 class GroupPrimitiveIterator : public PrimitiveIterator< index >85 class GroupPrimitiveIterator : public primitive_iterator< index > 86 86 { 87 87 public: … … 99 99 std::string surfaceName; 100 100 101 PrimTypeprimType;101 primitive_type primType; 102 102 103 103 std::vector< Vertex > verts; … … 114 114 115 115 uint NumElements( void ) const { return indices.size() ? (uint)indices.size() : (uint)verts.size(); } 116 uint NumPrimitives( void ) const { return PrimType::ElemsToPrims( primType, NumElements() ); }116 uint NumPrimitives( void ) const { return primitive_type::elems_to_prims( primType, NumElements() ); } 117 117 118 118 void DoRemapInfluences( const std::vector< uint > &infRemap ); branches/morph-targets/libx42make/include/x42make.h
r440 r507 32 32 33 33 #include "x42make-modeldata.h" 34 #include "x42make-modelbuilder.h" 34 35 35 36 #endif branches/morph-targets/libx42make/libx42make.vcproj
r462 r507 492 492 > 493 493 <File 494 RelativePath=".\include\x42make-modelbuilder.h" 495 > 496 </File> 497 <File 494 498 RelativePath=".\include\x42make-modeldata.h" 495 499 > … … 544 548 </File> 545 549 </Filter> 550 <Filter 551 Name="old" 552 > 553 <File 554 RelativePath=".\modeldata-anim.cpp" 555 > 556 </File> 557 <File 558 RelativePath=".\modeldata-batch.cpp" 559 > 560 </File> 561 <File 562 RelativePath=".\modeldata-cull.cpp" 563 > 564 </File> 565 <File 566 RelativePath=".\modeldata-optimize.cpp" 567 > 568 </File> 569 <File 570 RelativePath=".\modeldata-weights.cpp" 571 > 572 </File> 573 <File 574 RelativePath=".\modeldata-write.cpp" 575 > 576 </File> 577 <File 578 RelativePath=".\modeldata.cpp" 579 > 580 </File> 581 </Filter> 546 582 <File 547 583 RelativePath=".\local.h" … … 617 653 </File> 618 654 <File 619 RelativePath=".\model data-anim.cpp"655 RelativePath=".\modelbuilder-geometry.cpp" 620 656 > 621 657 </File> 622 658 <File 623 RelativePath=".\modeldata-batch.cpp" 624 > 625 </File> 626 <File 627 RelativePath=".\modeldata-cull.cpp" 628 > 629 </File> 630 <File 631 RelativePath=".\modeldata-optimize.cpp" 632 > 633 </File> 634 <File 635 RelativePath=".\modeldata-weights.cpp" 636 > 637 </File> 638 <File 639 RelativePath=".\modeldata-write.cpp" 640 > 641 </File> 642 <File 643 RelativePath=".\modeldata.cpp" 659 RelativePath=".\modelbuilder.cpp" 644 660 > 645 661 </File> branches/morph-targets/libx42make/modeldata-batch.cpp
r506 r507 52 52 53 53 GroupPrimitiveIterator iter( group ); 54 while( iter. Next() )54 while( iter.next() ) 55 55 { 56 56 int maxWt = 0; 57 57 58 for( uint i = 0; i < iter. IndicesPerPrim(); i++ )59 { 60 const Vertex &v = group->verts[iter. Current( i )];58 for( uint i = 0; i < iter.indices_per_prim(); i++ ) 59 { 60 const Vertex &v = group->verts[iter.current( i )]; 61 61 62 62 int numWt = 0; … … 74 74 std::vector< int > &vertMap = vertMaps[maxWt - 1]; 75 75 76 for( uint i = 0; i < iter. IndicesPerPrim(); i++ )77 { 78 index idx = iter. Current( i );76 for( uint i = 0; i < iter.indices_per_prim(); i++ ) 77 { 78 index idx = iter.current( i ); 79 79 80 80 if( vertMap[idx] == -1 ) … … 118 118 GroupPtr ret( new Group( this ) ); 119 119 120 demand( ga->primType. ElemsPerPrim() == gb->primType.ElemsPerPrim(), "mismatched primitive sizes" );120 demand( ga->primType.elems_per_prim() == gb->primType.elems_per_prim(), "mismatched primitive sizes" ); 121 121 122 122 ret->surfaceName = ga->surfaceName; 123 123 ret->material = ga->material; 124 124 125 ret->primType = PrimType::ListTypeFromElemsPerPrim( ga->primType.ElemsPerPrim());125 ret->primType = ga->primType.to_list_type(); 126 126 127 127 ret->verts.insert( ret->verts.begin(), ga->verts.begin(), ga->verts.end() ); 128 128 ret->infMap.insert( ret->infMap.begin(), ga->infMap.begin(), ga->infMap.end() ); 129 129 130 if( ga->primType. IsListType() && ga->indices.size() )130 if( ga->primType.is_list_type() && ga->indices.size() ) 131 131 { 132 132 ret->indices.insert( ret->indices.begin(), ga->indices.begin(), ga->indices.end() ); … … 135 135 { 136 136 GroupPrimitiveIterator ia( ga ); 137 while( ia. Next() )138 { 139 for( uint i = 0; i < ia. IndicesPerPrim(); i++ )140 ret->indices.push_back( ia. Current( i ) );137 while( ia.next() ) 138 { 139 for( uint i = 0; i < ia.indices_per_prim(); i++ ) 140 ret->indices.push_back( ia.current( i ) ); 141 141 } 142 142 } … … 186 186 187 187 GroupPrimitiveIterator ib( gb ); 188 while( ib. Next() )189 { 190 for( uint i = 0; i < ib. IndicesPerPrim(); i++ )191 ret->indices.push_back( util::checked_int_cast< index >( remap[ib. Current( i )] ) );188 while( ib.next() ) 189 { 190 for( uint i = 0; i < ib.indices_per_prim(); i++ ) 191 ret->indices.push_back( util::checked_int_cast< index >( remap[ib.current( i )] ) ); 192 192 } 193 193 … … 277 277 GroupPtr group = groups[iGroup]; 278 278 279 uint numPrims = PrimType::ElemsToPrims( group->primType, (uint)group->indices.size() );279 uint numPrims = primitive_type::elems_to_prims( group->primType, (uint)group->indices.size() ); 280 280 281 281 if( group->verts.size() <= maxVerts && numPrims <= maxPrims && group->infMap.size() <= maxInfluences ) … … 308 308 309 309 GroupPrimitiveIterator iter( group ); 310 while( iter. Next() )310 while( iter.next() ) 311 311 { 312 312 //create the cost estimate for the prim … … 317 317 addVerts[iG] = 0; 318 318 319 for( uint iPv = 0; iPv < iter. IndicesPerPrim(); iPv++ )320 { 321 const index vIdx = iter. Current( iPv );319 for( uint iPv = 0; iPv < iter.indices_per_prim(); iPv++ ) 320 { 321 const index vIdx = iter.current( iPv ); 322 322 //only count the cost if the vert's not already in the group 323 323 … … 341 341 342 342 //make sure we can actually add into this group 343 if( PrimType::ElemsToPrims( sGroup.primType, (uint)sGroup.indices.size() ) + 1 > maxPrims )343 if( primitive_type::elems_to_prims( sGroup.primType, (uint)sGroup.indices.size() ) + 1 > maxPrims ) 344 344 continue; 345 345 if( sGroup.verts.size() + addVerts[i] > maxVerts ) … … 385 385 std::vector< int > &vertMap = vertRemap[iBest]; 386 386 387 for( uint iPv = 0; iPv < iter. IndicesPerPrim(); iPv++ )388 { 389 uint vidx = iter. Current( iPv );387 for( uint iPv = 0; iPv < iter.indices_per_prim(); iPv++ ) 388 { 389 uint vidx = iter.current( iPv ); 390 390 391 391 if( vertMap[vidx] == -1 ) … … 566 566 switch( group.primType ) 567 567 { 568 case PrimType::TriangleFan:569 case PrimType::TriangleStrip:570 case PrimType::TriangleList:568 case primitive_type::triangle_fan: 569 case primitive_type::triangle_strip: 570 case primitive_type::triangle_list: 571 571 if( DoTopologicalSplit( iGroup, maxVerts, maxPrims, maxInfluences ) ) 572 572 iGroup--; … … 692 692 } 693 693 694 if( ga->primType. ElemsPerPrim() != gb->primType.ElemsPerPrim() )694 if( ga->primType.elems_per_prim() != gb->primType.elems_per_prim() ) 695 695 continue; 696 696 branches/morph-targets/libx42make/modeldata-optimize.cpp
r506 r507 40 40 switch( primType ) 41 41 { 42 case PrimType::TriangleList:43 case PrimType::TriangleStrip:44 case PrimType::TriangleFan:45 numPrims = PrimType::ElemsToPrims( primType, numElems );42 case primitive_type::triangle_list: 43 case primitive_type::triangle_strip: 44 case primitive_type::triangle_fan: 45 numPrims = primitive_type::elems_to_prims( primType, numElems ); 46 46 break; 47 47 … … 55 55 if( numPrims ) 56 56 { 57 if( primType == PrimType::TriangleStrip&& indices.size() )57 if( primType == primitive_type::triangle_list && indices.size() ) 58 58 { 59 59 assert( indices.size() == ret.size(), "Odd index count." ); … … 65 65 66 66 GroupPrimitiveIterator iter( this ); 67 while( iter. Next() )67 while( iter.next() ) 68 68 { 69 ret[iOut++] = iter. Current( 0 );70 ret[iOut++] = iter. Current( 1 );71 ret[iOut++] = iter. Current( 2 );69 ret[iOut++] = iter.current( 0 ); 70 ret[iOut++] = iter.current( 1 ); 71 ret[iOut++] = iter.current( 2 ); 72 72 } 73 73 } … … 81 81 switch( primType ) 82 82 { 83 case PrimType::TriangleList:84 case PrimType::TriangleStrip:85 case PrimType::TriangleFan:83 case primitive_type::triangle_list: 84 case primitive_type::triangle_strip: 85 case primitive_type::triangle_fan: 86 86 break; 87 87 … … 128 128 } 129 129 else 130 primType = PrimType::TriangleStrip;130 primType = primitive_type::triangle_strip; 131 131 } 132 132 else 133 primType = PrimType::TriangleList;133 primType = primitive_type::triangle_list; 134 134 135 135 //clear the group branches/morph-targets/libx42make/modeldata.cpp
r506 r507 75 75 */ 76 76 GroupPrimitiveIterator::GroupPrimitiveIterator( const Group *group ) 77 : PrimitiveIterator< ushort >( group->primType,77 : primitive_iterator< ushort >( group->primType, 78 78 group->indices.size() ? &group->indices[0] : NULL, group->NumPrimitives() ) 79 79 { … … 81 81 82 82 GroupPrimitiveIterator::GroupPrimitiveIterator( ConstGroupPtr group ) 83 : PrimitiveIterator< ushort >( group->primType,83 : primitive_iterator< ushort >( group->primType, 84 84 group->indices.size() ? &group->indices[0] : NULL, group->NumPrimitives() ) 85 85 { … … 92 92 Group::Group( Lod *owner ) 93 93 : owner( owner ), 94 primType( PrimType::TriangleList ),94 primType( primitive_type::triangle_list ), 95 95 maxInfsPerVert( X42_WEIGHTS_PER_VERT ) 96 96 { branches/morph-targets/libx42make/topology-split.cpp
r506 r507 57 57 goodGroup->surfaceName = group->surfaceName; 58 58 goodGroup->maxInfsPerVert = group->maxInfsPerVert; 59 goodGroup->primType = PrimType::TriangleList;59 goodGroup->primType = primitive_type::triangle_list; 60 60 61 61 spillGroup->material = group->material; 62 62 spillGroup->surfaceName = group->surfaceName; 63 63 spillGroup->maxInfsPerVert = group->maxInfsPerVert; 64 spillGroup->primType = PrimType::TriangleList;64 spillGroup->primType = primitive_type::triangle_list; 65 65 } 66 66 branches/morph-targets/libx42pp/include/x42types-imp.hpp
r500 r507 33 33 34 34 template< typename T > 35 PrimitiveIterator< T >::PrimitiveIterator( PrimType primType, const T *indices, uint numPrims )36 : prim Type( primType ), indices( indices ), numPrims( numPrims ), currPrim( uint_traits::max_val )37 { 38 } 39 40 template< typename T > 41 uint PrimitiveIterator< T >::IndicesPerPrim( void ) const42 { 43 return prim Type.ElemsPerPrim();44 } 45 46 template< typename T > 47 bool PrimitiveIterator< T >::Next( void)35 primitive_iterator< T >::primitive_iterator( primitive_type prim_type, const T *indices, uint numPrims ) 36 : prim_type( prim_type ), indices( indices ), numPrims( numPrims ), currPrim( uint_traits::max_val ) 37 { 38 } 39 40 template< typename T > 41 uint primitive_iterator< T >::indices_per_prim( void ) const 42 { 43 return prim_type.elems_per_prim(); 44 } 45 46 template< typename T > 47 bool primitive_iterator< T >::next() 48 48 { 49 49 if( currPrim == uint_traits::max_val ) … … 65 65 66 66 template< typename T > 67 T PrimitiveIterator< T >::Current( uint i ) const68 { 69 if( i >= IndicesPerPrim() )67 T primitive_iterator< T >::current( uint i ) const 68 { 69 if( i >= indices_per_prim() ) 70 70 fail( ErrCode::OutOfRange, "invalid element index" ); 71 71 72 72 uint idx; 73 73 74 switch( prim Type )74 switch( prim_type ) 75 75 { 76 case PrimType::PointList:76 case primitive_type::point_list: 77 77 idx = currPrim; 78 78 break; 79 79 80 case PrimType::LineList:80 case primitive_type::line_list: 81 81 idx = currPrim * 2 + i; 82 82 break; 83 83 84 case PrimType::LineStrip:84 case primitive_type::line_strip: 85 85 idx = currPrim + i; 86 86 break; 87 87 88 case PrimType::TriangleList:88 case primitive_type::triangle_list: 89 89 idx = currPrim * 3 + i; 90 90 break; 91 91 92 case PrimType::TriangleStrip:92 case primitive_type::triangle_strip: 93 93 if( currPrim & 1 ) 94 94 { … … 116 116 break; 117 117 118 case PrimType::TriangleFan:118 case primitive_type::triangle_fan: 119 119 idx = i ? currPrim + i : 0; 120 120 break; branches/morph-targets/libx42pp/include/x42types.h
r469 r507 44 44 typedef util::integer_traits< uint > uint_traits; 45 45 46 X42_DECLARE_ENUM( PrimType )47 48 PointList = X42_PT_POINT_LIST,49 50 LineList = X42_PT_LINE_LIST,51 LineStrip = X42_PT_LINE_STRIP,52 53 TriangleList = X42_PT_TRIANGLE_LIST,54 TriangleStrip = X42_PT_TRIANGLE_STRIP,55 TriangleFan= X42_PT_TRIANGLE_FAN,56 57 X42_END_ENUM_WITH_TYPE_OPEN( PrimType, uint )58 59 static uint ElemsToPrims( PrimType primType, uint numElems )60 { 61 switch( (Values)prim Type )46 X42_DECLARE_ENUM( primitive_type ) 47 48 point_list = X42_PT_POINT_LIST, 49 50 line_list = X42_PT_LINE_LIST, 51 line_strip = X42_PT_LINE_STRIP, 52 53 triangle_list = X42_PT_TRIANGLE_LIST, 54 triangle_strip = X42_PT_TRIANGLE_STRIP, 55 triangle_fan = X42_PT_TRIANGLE_FAN, 56 57 X42_END_ENUM_WITH_TYPE_OPEN( primitive_type, uint ) 58 59 static uint elems_to_prims( primitive_type primitive_type, uint num_elems ) 60 { 61 switch( (Values)primitive_type ) 62 62 { 63 case PointList:64 return num Elems;65 66 case LineList:67 return num Elems >= 2 ? numElems / 2 : 0;68 69 case LineStrip:70 return num Elems >= 2 ? numElems - 1 : 0;71 72 case TriangleList:73 return num Elems >= 3 ? numElems / 3 : 0;74 75 case TriangleStrip:76 case TriangleFan:77 return num Elems >= 3 ? numElems - 2 : 0;63 case point_list: 64 return num_elems; 65 66 case line_list: 67 return num_elems >= 2 ? num_elems / 2 : 0; 68 69 case line_strip: 70 return num_elems >= 2 ? num_elems - 1 : 0; 71 72 case triangle_list: 73 return num_elems >= 3 ? num_elems / 3 : 0; 74 75 case triangle_strip: 76 case triangle_fan: 77 return num_elems >= 3 ? num_elems - 2 : 0; 78 78 79 79 default: … … 82 82 } 83 83 84 uint ElemsToPrims( uint numElems ) const85 { 86 return ElemsToPrims( *this, numElems );87 } 88 89 static uint PrimsToElems( PrimType primType, uint numPrims )90 { 91 switch( (Values)prim Type )84 uint elems_to_prims( uint num_elems ) const 85 { 86 return elems_to_prims( *this, num_elems ); 87 } 88 89 static uint prims_to_elems( primitive_type primitive_type, uint num_prims ) 90 { 91 switch( (Values)primitive_type ) 92 92 { 93 case PointList:94 return num Prims;95 96 case LineList:97 return num Prims * 2;98 99 case LineStrip:100 return num Prims + 1;101 102 case TriangleList:103 return num Prims * 3;104 105 case TriangleStrip:106 case TriangleFan:107 return num Prims + 2;93 case point_list: 94 return num_prims; 95 96 case line_list: 97 return num_prims * 2; 98 99 case line_strip: 100 return num_prims + 1; 101 102 case triangle_list: 103 return num_prims * 3; 104 105 case triangle_strip: 106 case triangle_fan: 107 return num_prims + 2; 108 108 109 109 default: … … 112 112 } 113 113 114 uint PrimsToElems( uint numPrims ) const115 { 116 return PrimsToElems( *this, numPrims );117 } 118 119 static uint ElemsPerPrim( PrimType primType )120 { 121 switch( (Values)prim Type )114 uint prims_to_elems( uint num_prims ) const 115 { 116 return prims_to_elems( *this, num_prims ); 117 } 118 119 static uint elems_per_prim( primitive_type primitive_type ) 120 { 121 switch( (Values)primitive_type ) 122 122 { 123 case PointList:123 case point_list: 124 124 return 1; 125 125 126 case LineList:127 case LineStrip:126 case line_list: 127 case line_strip: 128 128 return 2; 129 129 130 case TriangleList:131 case TriangleStrip:132 case TriangleFan:130 case triangle_list: 131 case triangle_strip: 132 case triangle_fan: 133 133 return 3; 134 134 … … 138 138 } 139 139 140 uint ElemsPerPrim( void ) const141 { 142 return ElemsPerPrim( *this );143 } 144 145 static PrimType ListTypeFromElemsPerPrim( uint elemsPerPrim )146 { 147 switch( elems PerPrim )140 uint elems_per_prim( void ) const 141 { 142 return elems_per_prim( *this ); 143 } 144 145 static primitive_type elems_per_prim_to_list_type( uint elems_per_prim ) 146 { 147 switch( elems_per_prim ) 148 148 { 149 149 case 1: 150 return PrimType::PointList;150 return primitive_type::point_list; 151 151 break; 152 152 153 153 case 2: 154 return PrimType::LineList;154 return primitive_type::line_list; 155 155 break; 156 156 157 157 case 3: 158 return PrimType::TriangleList;158 return primitive_type::triangle_list; 159 159 break; 160 160 … … 164 164 } 165 165 166 static bool IsListType( PrimType primType ) 167 { 168 switch( (Values)primType ) 166 primitive_type to_list_type() const 167 { 168 return elems_per_prim_to_list_type( elems_per_prim() ); 169 } 170 171 static bool is_list_type( primitive_type primitive_type ) 172 { 173 switch( (Values)primitive_type ) 169 174 { 170 case PointList:171 case LineList:172 case TriangleList:175 case point_list: 176 case line_list: 177 case triangle_list: 173 178 return true; 174 179 175 case LineStrip:176 case TriangleStrip:177 case TriangleFan:178 return true;179 180 180 default: 181 return 0;181 return false; 182 182 } 183 183 } 184 184 185 bool IsListType( void ) const186 { 187 return IsListType( *this );188 } 189 190 X42_END_OPEN_ENUM( PrimType );185 bool is_list_type( void ) const 186 { 187 return is_list_type( *this ); 188 } 189 190 X42_END_OPEN_ENUM( primitive_type ); 191 191 192 192 template< typename T > 193 class PrimitiveIterator194 { 195 public: 196 PrimitiveIterator( PrimType primType, const T *indices, uint numIndices );193 class primitive_iterator 194 { 195 public: 196 primitive_iterator( primitive_type primitive_type, const T *indices, uint numIndices ); 197 197 198 uint IndicesPerPrim( void ) const;199 200 bool Next( void );201 T Current( uint i ) const;202 203 private: 204 PrimType primType;198 uint indices_per_prim( void ) const; 199 200 bool next( void ); 201 T current( uint i ) const; 202 203 private: 204 primitive_type prim_type; 205 205 const T *indices; 206 206 … … 208 208 uint numPrims; 209 209 210 PrimitiveIterator( const PrimitiveIterator & );211 PrimitiveIterator& operator = ( const PrimitiveIterator & );210 primitive_iterator( const primitive_iterator & ); 211 primitive_iterator& operator = ( const primitive_iterator & ); 212 212 }; 213 213 branches/morph-targets/x42maya/Export-Gather.cpp
r466 r507 334 334 newGroup->material = shaderName; 335 335 newGroup->surfaceName = surfaceName; 336 newGroup->primType = PrimType::TriangleList;336 newGroup->primType = primitive_type::triangle_list; 337 337 newGroup->maxInfsPerVert = 4; //for now, just to keep sanity, adjust later 338 338
