readd VertexInfluence whenever it's bad named and kinda useless

This commit is contained in:
Julien Valentin
2017-08-30 15:13:54 +02:00
parent 6d1193ee70
commit 8fad310ce1
7 changed files with 34 additions and 18 deletions

View File

@@ -89,14 +89,16 @@ void VertexInfluenceMap::cullInfluenceCountPerVertex(unsigned int numbonepervert
if(sum>1e-4){
sum=1.0f/sum;
for(BoneWeightOrdered::iterator bwit=bwset.begin(); bwit!=bwset.end(); ++bwit) {
IndexWeightList & inf= (*this)[bwit->getBoneName()];
VertexInfluence & inf= (*this)[bwit->getBoneName()];
inf.push_back(IndexWeight(mapit->first, bwit->getWeight()*sum));
inf.setName(bwit->getBoneName());
}
}
}else{
for(BoneWeightOrdered::iterator bwit=bwset.begin(); bwit!=bwset.end(); ++bwit) {
IndexWeightList & inf= (*this)[bwit->getBoneName()];
VertexInfluence & inf= (*this)[bwit->getBoneName()];
inf.push_back(IndexWeight(mapit->first,bwit->getWeight()));
inf.setName(bwit->getBoneName());
}
}

View File

@@ -51,7 +51,7 @@ void ComputeAABBOnBoneVisitor::computeBoundingBoxOnBones() {
osg::Vec3Array *vertices = dynamic_cast<osg::Vec3Array*>(rigGeometry->getVertexArray());
if(!vertices) continue;
osgAnimation::IndexWeightList vxtInf = (*itMap).second;
osgAnimation::VertexInfluence vxtInf = (*itMap).second;
//Expand the boundingBox with each vertex
for(unsigned int j = 0; j < vxtInf.size(); j++) {

View File

@@ -200,9 +200,9 @@ protected:
BoneNameBoneMap::iterator bone_it = boneMap.find(vertexInfluencePair->first);
if(bone_it == boneMap.end()) continue;
osg::ref_ptr<osgAnimation::Bone> bone = bone_it->second;
const osgAnimation::IndexWeightList& vertexInfluence = (*vertexInfluencePair).second;
const osgAnimation::VertexInfluence& vertexInfluence = (*vertexInfluencePair).second;
for(osgAnimation::IndexWeightList::const_iterator vertexIndexWeight = vertexInfluence.begin(); vertexIndexWeight != vertexInfluence.end(); ++vertexIndexWeight) {
for(osgAnimation::VertexInfluence::const_iterator vertexIndexWeight = vertexInfluence.begin(); vertexIndexWeight != vertexInfluence.end(); ++vertexIndexWeight) {
rigGeometryInfluenceByBoneMap[bone.get()][*rigGeometry].addWeight((*vertexIndexWeight).second);
}
}

View File

@@ -804,16 +804,17 @@ bool RigGeometry_readLocalData(Object& obj, Input& fr)
for (int i = 0; i < nbGroups; i++)
{
int nbVertexes = 0;
std::string bonename;
std::string name;
if (fr.matchSequence("osgAnimation::VertexInfluence %s %i {"))
{
bonename = fr[1].getStr();
name = fr[1].getStr();
fr[2].getInt(nbVertexes);
fr += 4;
iteratorAdvanced = true;
}
osgAnimation::IndexWeightList vi;
osgAnimation::VertexInfluence vi;
vi.setName(name);
vi.reserve(nbVertexes);
for (int j = 0; j < nbVertexes; j++)
{
@@ -832,7 +833,7 @@ bool RigGeometry_readLocalData(Object& obj, Input& fr)
{
fr+=1;
}
(*vmap)[bonename] = vi;
(*vmap)[name] = vi;
}
if (!vmap->empty())
geom.setInfluenceMap(vmap.get());
@@ -862,8 +863,8 @@ bool RigGeometry_writeLocalData(const Object& obj, Output& fw)
name = "Empty";
fw.indent() << "osgAnimation::VertexInfluence \"" << name << "\" " << it->second.size() << " {" << std::endl;
fw.moveIn();
const osgAnimation::IndexWeightList& vi = it->second;
for (osgAnimation::IndexWeightList::const_iterator itv = vi.begin(); itv != vi.end(); itv++)
const osgAnimation::VertexInfluence& vi = it->second;
for (osgAnimation::VertexInfluence::const_iterator itv = vi.begin(); itv != vi.end(); itv++)
{
fw.indent() << itv->first << " " << itv->second << std::endl;
}

View File

@@ -19,8 +19,8 @@ static bool readInfluenceMap( osgDB::InputStream& is, osgAnimation::RigGeometry&
is >> is.PROPERTY("VertexInfluence");
is.readWrappedString(bonename);
viSize = is.readSize(); is >> is.BEGIN_BRACKET;
osgAnimation::IndexWeightList vi;
osgAnimation::VertexInfluence vi;
vi.setName( bonename );
vi.reserve( viSize );
for ( unsigned int j=0; j<viSize; ++j )
{
@@ -46,14 +46,14 @@ static bool writeInfluenceMap( osgDB::OutputStream& os, const osgAnimation::RigG
itr!=map->end(); ++itr )
{
std::string name = itr->first;
const osgAnimation::IndexWeightList& vi = itr->second;
const osgAnimation::VertexInfluence& vi = itr->second;
if ( name.empty() ) name = "Empty";
os << os.PROPERTY("VertexInfluence");
os.writeWrappedString(name);
os.writeSize(vi.size()) ; os << os.BEGIN_BRACKET << std::endl;
for ( osgAnimation::IndexWeightList::const_iterator vitr=vi.begin();
for ( osgAnimation::VertexInfluence::const_iterator vitr=vi.begin();
vitr != vi.end(); ++vitr )
{
os << vitr->first << vitr->second << std::endl;