Changeset 510
- Timestamp:
- 02/19/08 23:25:59 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/morph-targets/libx42make/include/x42make-modelbuilder.h
r509 r510 32 32 { 33 33 34 class error : public std::exception 35 { 36 public: 37 error() : exception() { } 38 error( const char *why ) : exception( why ) { } 39 error( const error &other ) : exception( other ) { } 40 }; 41 42 class validation_error : public error 43 { 44 public: 45 validation_error() : error() { } 46 validation_error( const char *why ) : error( why ) { } 47 validation_error( const error &other ) : error( other ) { } 48 }; 49 34 50 class ref_obj; 35 51 typedef ::boost::intrusive_ptr< ref_obj > ref_obj_ptr; branches/morph-targets/libx42make/modelbuilder-skeleton.cpp
r509 r510 87 87 void model_builder::validate_bone_parent( bone *bone, const bone_ptr &new_parent ) const 88 88 { 89 } 89 if( _bone_update_count ) 90 return; 91 92 //check if this would cause a cycle 93 for( bone_ptr p = new_parent; p; p = p->_parent ) 94 { 95 if( p == bone ) 96 throw validation_error( "Bone parent causes a cycle." ); 97 } 98 } 99 90 100 void model_builder::validate_bone_anim_group( bone *bone, uint new_anim_group ) const 91 101 { 92 } 93 94 void model_builder::notify_bone_parent( bone *bone ) 102 if( _bone_update_count ) 103 return; 104 105 if( bone->_parent && bone->_parent->_anim_group > new_anim_group ) 106 throw validation_error( "Animation group number treater than parent's value." ); 107 } 108 109 void model_builder::notify_bone_parent( bone * /* bone */ ) 95 110 { 96 111 sort_bones(); 97 112 } 98 void model_builder::notify_bone_anim_group( bone * bone)113 void model_builder::notify_bone_anim_group( bone * /* bone */ ) 99 114 { 100 115 sort_bones(); … … 105 120 if( _bone_update_count ) 106 121 return; 122 123 for( size_t i = 0; i < bones.size(); i++ ) 124 { 125 bone_ptr b = bones[i]; 126 127 if( b->owner != this ) 128 throw validation_error( "Bones includes a bone that does not belong to this model_builder." ); 129 130 if( b->_parent ) 131 { 132 if( b->_parent->owner != this ) 133 throw validation_error( "Bones includes a bone with a parent that does not belong to this model_builder." ); 134 135 if( b->_parent->_index >= bones.size() || bones[b->_parent->_index] != b->_parent ) 136 throw validation_error( "Bones includes a bone with a parent that does not belong to this model_builder." ); 137 } 138 139 validate_bone_parent( b.get(), b->_parent.get() ); 140 validate_bone_anim_group( b.get(), b->_anim_group ); 141 142 //check for duplicates 143 for( size_t j = i + 1; j < bones.size(); j++ ) 144 { 145 if( bones[j] == b ) 146 throw validation_error( "Duplicate bone." ); 147 } 148 } 107 149 } 108 150
