forked from mirror/openmw-tes3mp
RigGeometry: do not update the geomToSkelMatrix more than once per frame
This commit is contained in:
parent
75a464f7ec
commit
6d5aa272fc
2 changed files with 9 additions and 9 deletions
|
@ -224,8 +224,6 @@ void RigGeometry::update(osg::NodeVisitor* nv)
|
|||
|
||||
mSkeleton->updateBoneMatrices(nv);
|
||||
|
||||
osg::Matrixf geomToSkel = getGeomToSkelMatrix(nv);
|
||||
|
||||
// skinning
|
||||
osg::Vec3Array* positionSrc = static_cast<osg::Vec3Array*>(mSourceGeometry->getVertexArray());
|
||||
osg::Vec3Array* normalSrc = static_cast<osg::Vec3Array*>(mSourceGeometry->getNormalArray());
|
||||
|
@ -248,7 +246,7 @@ void RigGeometry::update(osg::NodeVisitor* nv)
|
|||
const osg::Matrixf& boneMatrix = bone->mMatrixInSkeletonSpace;
|
||||
accumulateMatrix(invBindMatrix, boneMatrix, weight, resultMat);
|
||||
}
|
||||
resultMat = resultMat * geomToSkel;
|
||||
resultMat = resultMat * mGeomToSkelMatrix;
|
||||
|
||||
for (std::vector<unsigned short>::const_iterator vertexIt = it->second.begin(); vertexIt != it->second.end(); ++vertexIt)
|
||||
{
|
||||
|
@ -276,13 +274,14 @@ void RigGeometry::updateBounds(osg::NodeVisitor *nv)
|
|||
|
||||
mSkeleton->updateBoneMatrices(nv);
|
||||
|
||||
osg::Matrixf geomToSkel = getGeomToSkelMatrix(nv);
|
||||
updateGeomToSkelMatrix(nv);
|
||||
|
||||
osg::BoundingBox box;
|
||||
for (BoneSphereMap::const_iterator it = mBoneSphereMap.begin(); it != mBoneSphereMap.end(); ++it)
|
||||
{
|
||||
Bone* bone = it->first;
|
||||
osg::BoundingSpheref bs = it->second;
|
||||
transformBoundingSphere(bone->mMatrixInSkeletonSpace * geomToSkel, bs);
|
||||
transformBoundingSphere(bone->mMatrixInSkeletonSpace * mGeomToSkelMatrix, bs);
|
||||
box.expandBy(bs);
|
||||
}
|
||||
|
||||
|
@ -297,7 +296,7 @@ void RigGeometry::updateBounds(osg::NodeVisitor *nv)
|
|||
getParent(i)->dirtyBound();
|
||||
}
|
||||
|
||||
osg::Matrixf RigGeometry::getGeomToSkelMatrix(osg::NodeVisitor *nv)
|
||||
void RigGeometry::updateGeomToSkelMatrix(osg::NodeVisitor *nv)
|
||||
{
|
||||
osg::NodePath path;
|
||||
bool foundSkel = false;
|
||||
|
@ -311,8 +310,7 @@ osg::Matrixf RigGeometry::getGeomToSkelMatrix(osg::NodeVisitor *nv)
|
|||
else
|
||||
path.push_back(*it);
|
||||
}
|
||||
return osg::computeWorldToLocal(path);
|
||||
|
||||
mGeomToSkelMatrix = osg::computeWorldToLocal(path);
|
||||
}
|
||||
|
||||
void RigGeometry::setInfluenceMap(osg::ref_ptr<InfluenceMap> influenceMap)
|
||||
|
|
|
@ -48,6 +48,8 @@ namespace SceneUtil
|
|||
osg::ref_ptr<osg::Geometry> mSourceGeometry;
|
||||
Skeleton* mSkeleton;
|
||||
|
||||
osg::Matrixf mGeomToSkelMatrix;
|
||||
|
||||
osg::ref_ptr<InfluenceMap> mInfluenceMap;
|
||||
|
||||
typedef std::pair<Bone*, osg::Matrixf> BoneBindMatrixPair;
|
||||
|
@ -69,7 +71,7 @@ namespace SceneUtil
|
|||
|
||||
bool initFromParentSkeleton(osg::NodeVisitor* nv);
|
||||
|
||||
osg::Matrixf getGeomToSkelMatrix(osg::NodeVisitor* nv);
|
||||
void updateGeomToSkelMatrix(osg::NodeVisitor* nv);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue