1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 20:11:36 +00:00

Store the RigGeometry's source vertices and normals directly

This commit is contained in:
scrawl 2016-03-22 22:01:56 +01:00
parent 6f31b3d79f
commit 7a347e3483
2 changed files with 9 additions and 5 deletions

View file

@ -82,12 +82,14 @@ RigGeometry::RigGeometry(const RigGeometry &copy, const osg::CopyOp &copyop)
, mLastFrameNumber(0) , mLastFrameNumber(0)
, mBoundsFirstFrame(true) , mBoundsFirstFrame(true)
{ {
setSourceGeometry(copy.mSourceGeometry); mSourceVertices = copy.mSourceVertices;
mSourceNormals = copy.mSourceNormals;
} }
void RigGeometry::setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeometry) void RigGeometry::setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeometry)
{ {
mSourceGeometry = sourceGeometry; mSourceVertices = static_cast<osg::Vec3Array*>(sourceGeometry->getVertexArray());
mSourceNormals = static_cast<osg::Vec3Array*>(sourceGeometry->getNormalArray());
osg::Geometry& from = *sourceGeometry; osg::Geometry& from = *sourceGeometry;
@ -223,8 +225,8 @@ void RigGeometry::update(osg::NodeVisitor* nv)
mSkeleton->updateBoneMatrices(nv); mSkeleton->updateBoneMatrices(nv);
// skinning // skinning
osg::Vec3Array* positionSrc = static_cast<osg::Vec3Array*>(mSourceGeometry->getVertexArray()); osg::Vec3Array* positionSrc = mSourceVertices;
osg::Vec3Array* normalSrc = static_cast<osg::Vec3Array*>(mSourceGeometry->getNormalArray()); osg::Vec3Array* normalSrc = mSourceNormals;
osg::Vec3Array* positionDst = static_cast<osg::Vec3Array*>(getVertexArray()); osg::Vec3Array* positionDst = static_cast<osg::Vec3Array*>(getVertexArray());
osg::Vec3Array* normalDst = static_cast<osg::Vec3Array*>(getNormalArray()); osg::Vec3Array* normalDst = static_cast<osg::Vec3Array*>(getNormalArray());

View file

@ -41,6 +41,7 @@ namespace SceneUtil
/// Initialize this geometry from the source geometry. /// Initialize this geometry from the source geometry.
/// @note The source geometry will not be modified. /// @note The source geometry will not be modified.
/// @note The source geometry's normal and vertex arrays must be an osg::Vec3Array.
void setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeom); void setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeom);
// Called automatically by our CullCallback // Called automatically by our CullCallback
@ -50,7 +51,8 @@ namespace SceneUtil
void updateBounds(osg::NodeVisitor* nv); void updateBounds(osg::NodeVisitor* nv);
private: private:
osg::ref_ptr<osg::Geometry> mSourceGeometry; osg::ref_ptr<osg::Vec3Array> mSourceVertices;
osg::ref_ptr<osg::Vec3Array> mSourceNormals;
Skeleton* mSkeleton; Skeleton* mSkeleton;
osg::NodePath mSkelToGeomPath; osg::NodePath mSkelToGeomPath;