Changeset 519
- Timestamp:
- 02/25/08 00:34:47 (11 months ago)
- Files:
-
- branches/morph-targets/libx42make/helpers.h (modified) (1 diff)
- branches/morph-targets/libx42make/include/x42make-modelbuilder.h (modified) (8 diffs)
- branches/morph-targets/libx42make/libx42make.vcproj (modified) (1 diff)
- branches/morph-targets/libx42make/modelbuilder-geometry.cpp (modified) (1 diff)
- branches/morph-targets/libx42make/modelbuilder-write.cpp (added)
- branches/morph-targets/libx42make/modelbuilder.cpp (modified) (3 diffs)
- branches/morph-targets/libx42make/modeldata-write.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42make/helpers.h
r516 r519 156 156 } 157 157 158 template< typename T, typename Cmp > 159 size_t index_of( const std::vector< T > &v, const T &val, Cmp cmp ) 160 { 161 std::vector< T >::const_iterator pos = 162 std::upper_bound( v.begin(), v.end(), val, cmp ); 163 164 if( pos == v.begin() ) 165 throw std::exception(); 166 167 pos--; 168 169 const T &vp = *pos; 170 171 if( !cmp( vp, val ) && !cmp( val, vp ) ) 172 //neither is less, they are "equal" 173 throw std::exception(); 174 175 return pos - v.begin(); 176 } 177 158 178 }; 159 179 }; branches/morph-targets/libx42make/include/x42make-modelbuilder.h
r518 r519 58 58 namespace _impl 59 59 { 60 void intrusive_ptr_add_ref( ref_obj *r ); 61 void intrusive_ptr_release( ref_obj *r ); 60 void intrusive_ptr_add_ref( const ref_obj *r ); 61 void intrusive_ptr_release( const ref_obj *r ); 62 63 class model_data_builder; 62 64 }; 63 65 … … 73 75 74 76 private: 75 size_t _ref_count;77 mutable size_t _ref_count; 76 78 77 friend void _impl::intrusive_ptr_add_ref( ref_obj *r );78 friend void _impl::intrusive_ptr_release( ref_obj *r );79 friend void _impl::intrusive_ptr_add_ref( const ref_obj *r ); 80 friend void _impl::intrusive_ptr_release( const ref_obj *r ); 79 81 }; 80 82 … … 256 258 friend class animation_tracks; 257 259 friend class model_builder; 260 friend class _impl::model_data_builder; 258 261 }; 259 262 … … 434 437 size_t index_count() const { return indices.size(); } 435 438 439 size_t count_max_influences_per_vert() const; 440 436 441 bool is_valid() const; 437 442 … … 465 470 class lod : public ref_obj 466 471 { 467 public: 468 uint lod_number; 472 public: 469 473 std::vector< group_ptr > groups; 474 475 uint lod_number() const { return _lod_number; } 470 476 471 477 group_ptr create_group( const std::string &surface_name = std::string(), … … 473 479 474 480 private: 481 uint _lod_number; 482 475 483 model_builder *owner; 476 lod( model_builder *owner ) : owner( owner ) { } 484 lod( model_builder *owner, uint lod_number ) 485 : owner( owner ), _lod_number( lod_number ) 486 { } 477 487 478 488 friend class model_builder; … … 490 500 std::vector< animation > animations; 491 501 std::vector< uint > pinned_frames; 502 503 ::x42::geom::aabb bounding_box; 504 ::x42::geom::sphere bounding_sphere; 492 505 493 506 animation_tolerances loose_tolerances; … … 558 571 void remove_unused_bones(); 559 572 573 model to_model( void ) const; 574 560 575 private: 561 576 int _base_frame; branches/morph-targets/libx42make/libx42make.vcproj
r515 r519 677 677 </File> 678 678 <File 679 RelativePath=".\modelbuilder-write.cpp" 680 > 681 </File> 682 <File 679 683 RelativePath=".\modelbuilder.cpp" 680 684 > branches/morph-targets/libx42make/modelbuilder-geometry.cpp
r518 r519 381 381 } 382 382 383 size_t geometry::count_max_influences_per_vert() const 384 { 385 size_t ret = 0; 386 387 for( size_t i = 0; i < weights.size(); i++ ) 388 { 389 ret = max( ret, weights[i].count() ); 390 } 391 } 392 383 393 void geometry::bake_vertices( const std::vector< ::x42::math::affine > &inf_mats, const influence_ptr &rebind_inf ) 384 394 { branches/morph-targets/libx42make/modelbuilder.cpp
r512 r519 35 35 { 36 36 37 void intrusive_ptr_add_ref( ref_obj *r )37 void intrusive_ptr_add_ref( const ref_obj *r ) 38 38 { 39 39 r->_ref_count++; 40 40 } 41 41 42 void intrusive_ptr_release( ref_obj *r )42 void intrusive_ptr_release( const ref_obj *r ) 43 43 { 44 44 if( !--r->_ref_count ) … … 73 73 for( size_t i = 0; i < lods.size(); i++ ) 74 74 { 75 if( lods[i]-> lod_number == lod_number )75 if( lods[i]->_lod_number == lod_number ) 76 76 return lods[i]; 77 77 } … … 85 85 for( i = 0; i < lods.size(); i++ ) 86 86 { 87 if( lods[i]-> lod_number == lod_number )87 if( lods[i]->_lod_number == lod_number ) 88 88 return lods[i]; 89 89 90 if( lods[i]-> lod_number > lod_number )90 if( lods[i]->_lod_number > lod_number ) 91 91 break; 92 92 } 93 93 94 lod_ptr ret( new lod( this ) ); 95 96 ret->lod_number = lod_number; 97 94 lod_ptr ret( new lod( this, lod_number ) ); 98 95 lods.insert( lods.begin() + i, ret ); 99 96 branches/morph-targets/libx42make/modeldata-write.cpp
r506 r519 270 270 { 271 271 animGroups[i].name = _sb.intern_string( std::string( "" ) ); 272 animGroups[i].beginBone = (u16)data.numFrames;272 animGroups[i].beginBone = integer_traits< u16 >::max_val; 273 273 animGroups[i].endBone = 0; 274 274 }
