1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 03:39:42 +00:00

RigGeometry optimization: optimize geometry optimization

This commit is contained in:
Andrei Kortunov 2019-01-09 21:01:33 +04:00
parent 254f01b89d
commit 8e6fd348d1
3 changed files with 6 additions and 11 deletions

View file

@ -1092,8 +1092,7 @@ namespace NifOsg
const std::vector<Nif::NiSkinData::VertWeight> &weights = data->bones[i].weights;
for(size_t j = 0;j < weights.size();j++)
{
std::pair<unsigned short, float> indexWeight = std::make_pair(weights[j].vertex, weights[j].weight);
influence.mWeights.insert(indexWeight);
influence.mWeights.emplace_back(weights[j].vertex, weights[j].weight);
}
influence.mInvBindMatrix = data->bones[i].trafo.toMatrix();
influence.mBoundSphere = osg::BoundingSpheref(data->bones[i].boundSphereCenter, data->bones[i].boundSphereRadius);

View file

@ -146,18 +146,14 @@ bool RigGeometry::initFromParentSkeleton(osg::NodeVisitor* nv)
continue;
}
mBoneSphereVector.emplace_back(bone, influencePair.second.mBoundSphere);
const BoneInfluence& bi = influencePair.second;
mBoneSphereVector.emplace_back(bone, bi.mBoundSphere);
const std::map<unsigned short, float>& weights = influencePair.second.mWeights;
for (std::map<unsigned short, float>::const_iterator weightIt = weights.begin(); weightIt != weights.end(); ++weightIt)
for (auto& weightPair: bi.mWeights)
{
std::vector<BoneWeight>& vec = vertex2BoneMap[weightIt->first];
std::vector<BoneWeight>& vec = vertex2BoneMap[weightPair.first];
BoneWeight b = std::make_pair(std::make_pair(bone, bi.mInvBindMatrix), weightIt->second);
vec.push_back(b);
vec.emplace_back(std::make_pair(bone, bi.mInvBindMatrix), weightPair.second);
}
}

View file

@ -31,7 +31,7 @@ namespace SceneUtil
osg::Matrixf mInvBindMatrix;
osg::BoundingSpheref mBoundSphere;
// <vertex index, weight>
std::map<unsigned short, float> mWeights;
std::vector<std::pair<unsigned short, float>> mWeights;
};
struct InfluenceMap : public osg::Referenced