diff --git a/examples/osganimationskinning/osganimationskinning.cpp b/examples/osganimationskinning/osganimationskinning.cpp index 485276e03..2536353a6 100644 --- a/examples/osganimationskinning/osganimationskinning.cpp +++ b/examples/osganimationskinning/osganimationskinning.cpp @@ -143,11 +143,11 @@ void initVertexMap(osgAnimation::Bone* b0, float val = (*array)[i][0]; std::cout << val << std::endl; if (val >= -1.0f && val <= 0.0f) - (*vim)[b0->getName()].push_back(osgAnimation::IndexWeight(i,1.0f)); + (*vim)[b0->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); else if ( val > 0.0f && val <= 1.0f) - (*vim)[b1->getName()].push_back(osgAnimation::IndexWeight(i,1.0f)); + (*vim)[b1->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); else if ( val > 1.0f) - (*vim)[b2->getName()].push_back(osgAnimation::IndexWeight(i,1.0f)); + (*vim)[b2->getName()].push_back(osgAnimation::VertexIndexWeight(i,1.0f)); } geom->setInfluenceMap(vim); diff --git a/include/osgAnimation/RigTransformHardware b/include/osgAnimation/RigTransformHardware index 9e2cb23f1..eeefa0030 100644 --- a/include/osgAnimation/RigTransformHardware +++ b/include/osgAnimation/RigTransformHardware @@ -81,7 +81,7 @@ namespace osgAnimation unsigned int _minAttribIndex; bool buildPalette(const BoneMap& boneMap ,const RigGeometry& rig); - bool init(RigGeometry& ); + virtual bool init(RigGeometry& ); }; } diff --git a/include/osgAnimation/VertexInfluence b/include/osgAnimation/VertexInfluence index 94c12b0e4..a521f13d7 100644 --- a/include/osgAnimation/VertexInfluence +++ b/include/osgAnimation/VertexInfluence @@ -34,15 +34,15 @@ namespace osgAnimation inline void setWeight(float i){second=i;} }; // first is vertex index, and second the weight - struct IndexWeight: public std::pair + struct VertexIndexWeight: public std::pair { - IndexWeight( unsigned int f = 0xffffffff,float s = 0.0f): std::pair(f,s){} + VertexIndexWeight( unsigned int f = 0xffffffff,float s = 0.0f): std::pair(f,s){} inline const unsigned int& getIndex()const{return first;} inline void setIndex(unsigned int i){first=i;} inline const float &getWeight()const{return second;} inline void setWeight(float i){second=i;} }; - typedef std::vector IndexWeightList; + typedef std::vector IndexWeightList; typedef std::vector BoneWeightList; typedef std::vector IndexList; diff --git a/src/osgAnimation/RigTransformHardware.cpp b/src/osgAnimation/RigTransformHardware.cpp index f2fac8c43..8713b5cef 100644 --- a/src/osgAnimation/RigTransformHardware.cpp +++ b/src/osgAnimation/RigTransformHardware.cpp @@ -65,7 +65,7 @@ void RigTransformHardware::computeMatrixPaletteUniform(const osg::Matrix& transf } -void createVertexAttribList(RigTransformHardware& rig,const std::vector > &perVertexInfluences,RigTransformHardware::BoneWeightAttribList & boneWeightAttribArrays); +void createVertexAttribList(RigTransformHardware& rig,const std::vector > &perVertexInfluences,RigTransformHardware::BoneWeightAttribList & boneWeightAttribArrays); // // create vertex attribute by 2 bones @@ -76,7 +76,7 @@ void createVertexAttribList(RigTransformHardware& rig,const std::vector > PerVertexInfList; +typedef std::vector > PerVertexInfList; void createVertexAttribList(RigTransformHardware& rig, const PerVertexInfList & perVertexInfluences, RigTransformHardware::BoneWeightAttribList& boneWeightAttribArrays) @@ -172,7 +172,7 @@ bool RigTransformHardware::buildPalette(const BoneMap&boneMap ,const RigGeometry BoneNamePaletteIndex::iterator boneName2PaletteIndex; // init temp vertex attribute data - std::vector > perVertexInfluences; + std::vector perVertexInfluences; perVertexInfluences.resize(_nbVertexes); unsigned int paletteindex; @@ -203,14 +203,14 @@ bool RigTransformHardware::buildPalette(const BoneMap&boneMap ,const RigGeometry } for(IndexWeightList::const_iterator infit = boneinflist.begin(); infit!=boneinflist.end(); ++infit) { - const IndexWeight& iw = *infit; + const VertexIndexWeight& iw = *infit; const unsigned int &index = iw.getIndex(); const float &weight = iw.getWeight(); IndexWeightList & iwlist=perVertexInfluences[index]; if(fabs(weight) > 1e-4) // don't use bone with weight too small { - iwlist.push_back(IndexWeight(paletteindex,weight)); + iwlist.push_back(VertexIndexWeight(paletteindex,weight)); } else { diff --git a/src/osgAnimation/RigTransformSoftware.cpp b/src/osgAnimation/RigTransformSoftware.cpp index 35bea4823..3e858647a 100644 --- a/src/osgAnimation/RigTransformSoftware.cpp +++ b/src/osgAnimation/RigTransformSoftware.cpp @@ -67,7 +67,7 @@ void RigTransformSoftware::buildMinimumUpdateSet( const BoneMap&boneMap, const R Bone* bone = bmit->second.get(); for(IndexWeightList::const_iterator infit=inflist.begin(); infit!=inflist.end(); ++infit) { - const IndexWeight &iw = *infit; + const VertexIndexWeight &iw = *infit; const unsigned int &index = iw.getIndex(); float weight = iw.getWeight(); diff --git a/src/osgAnimation/VertexInfluence.cpp b/src/osgAnimation/VertexInfluence.cpp index 2fffc7559..d0bba7599 100644 --- a/src/osgAnimation/VertexInfluence.cpp +++ b/src/osgAnimation/VertexInfluence.cpp @@ -38,7 +38,7 @@ void VertexInfluenceMap::normalize(unsigned int numvert) { for(VertexInfluenceMap::iterator mapit=this->begin(); mapit!=this->end(); ++mapit) { IndexWeightList &curvecinf=mapit->second; for(IndexWeightList::iterator curinf=curvecinf.begin(); curinf!=curvecinf.end(); ++curinf) { - IndexWeight& inf=*curinf; + VertexIndexWeight& inf=*curinf; localstore[inf.first].first+=inf.second; localstore[inf.first].second.push_back(&inf.second); @@ -70,7 +70,7 @@ void VertexInfluenceMap::cullInfluenceCountPerVertex(unsigned int numbonepervert const std::string& bonename=mapit->first; IndexWeightList &curvecinf=mapit->second; for(IndexWeightList::iterator curinf=curvecinf.begin(); curinf!=curvecinf.end(); ++curinf) { - IndexWeight& inf=*curinf; + VertexIndexWeight& inf=*curinf; if( bonename.empty()) { OSG_WARN << "VertexInfluenceSet::buildVertex2BoneList warning vertex " << inf.first << " is not assigned to a bone" << std::endl; } @@ -90,14 +90,14 @@ void VertexInfluenceMap::cullInfluenceCountPerVertex(unsigned int numbonepervert sum=1.0f/sum; for(BoneWeightOrdered::iterator bwit=bwset.begin(); bwit!=bwset.end(); ++bwit) { VertexInfluence & inf= (*this)[bwit->getBoneName()]; - inf.push_back(IndexWeight(mapit->first, bwit->getWeight()*sum)); + inf.push_back(VertexIndexWeight(mapit->first, bwit->getWeight()*sum)); inf.setName(bwit->getBoneName()); } } }else{ for(BoneWeightOrdered::iterator bwit=bwset.begin(); bwit!=bwset.end(); ++bwit) { VertexInfluence & inf= (*this)[bwit->getBoneName()]; - inf.push_back(IndexWeight(mapit->first,bwit->getWeight())); + inf.push_back(VertexIndexWeight(mapit->first,bwit->getWeight())); inf.setName(bwit->getBoneName()); } @@ -114,14 +114,13 @@ void VertexInfluenceMap::computePerVertexInfluenceList(std::vectorsecond; if (it->first.empty()) { - OSG_WARN << "RigTransformSoftware::VertexInfluenceMap contains unamed bone IndexWeightList" << std::endl; + OSG_WARN << "VertexInfluenceMap::computePerVertexInfluenceList contains unamed bone IndexWeightList" << std::endl; } for(IndexWeightList::const_iterator infit=inflist.begin(); infit!=inflist.end(); ++infit) { - const IndexWeight &iw = *infit; + const VertexIndexWeight &iw = *infit; const unsigned int &index = iw.getIndex(); float weight = iw.getWeight(); - vertex2Bones[index].push_back(BoneWeight(it->first, weight));; } } @@ -173,12 +172,9 @@ void VertexInfluenceMap::computeMinimalVertexGroupList(std::vector& unsigned int vertexID=0; for (std::vector::iterator it = vertex2Bones.begin(); it != vertex2Bones.end(); ++it,++vertexID) { - BoneWeightList &boneweightlist = *it;//->second; - //int vertexIndex = it->first; - + BoneWeightList &boneweightlist = *it; // sort the vector to have a consistent key std::sort(boneweightlist.begin(), boneweightlist.end(), SortByNameAndWeight()); - // we use the vector as key to differentiate group UnifyBoneGroup::iterator result = unifyBuffer.find(boneweightlist); if (result == unifyBuffer.end()) diff --git a/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp b/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp index 4dbf949dc..add7f50fd 100644 --- a/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp +++ b/src/osgWrappers/deprecated-dotosg/osgAnimation/ReaderWriter.cpp @@ -827,7 +827,7 @@ bool RigGeometry_readLocalData(Object& obj, Input& fr) fr += 2; iteratorAdvanced = true; } - vi.push_back(osgAnimation::IndexWeight(index, weight)); + vi.push_back(osgAnimation::VertexIndexWeight(index, weight)); } if (fr.matchSequence("}")) { diff --git a/src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp b/src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp index 2ea4b9551..10b14d0f1 100644 --- a/src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp +++ b/src/osgWrappers/serializers/osgAnimation/RigGeometry.cpp @@ -27,7 +27,7 @@ static bool readInfluenceMap( osgDB::InputStream& is, osgAnimation::RigGeometry& int index = 0; float weight = 0.0f; is >> index >> weight; - vi.push_back( osgAnimation::IndexWeight(index, weight) ); + vi.push_back( osgAnimation::VertexIndexWeight(index, weight) ); } (*map)[bonename] = vi; is >> is.END_BRACKET;