mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
More work on copy constructors
This commit is contained in:
parent
f8422c3ed4
commit
00ab474188
2 changed files with 18 additions and 16 deletions
|
@ -111,6 +111,8 @@ namespace NifOsg
|
|||
class NodeTargetValue : public ControllerValue
|
||||
{
|
||||
protected:
|
||||
// TODO: get rid of target pointers, which are incompatible with a copy constructor we will need later
|
||||
// instead, controllers can be a Node added as child of their target
|
||||
osg::Node *mNode;
|
||||
|
||||
public:
|
||||
|
|
|
@ -168,11 +168,12 @@ namespace
|
|||
class InvertBoneMatrix : public osg::NodeCallback
|
||||
{
|
||||
public:
|
||||
InvertBoneMatrix(osg::Node* skelRootNode)
|
||||
: mSkelRoot(skelRootNode)
|
||||
{
|
||||
}
|
||||
// TODO: add copy constructor
|
||||
InvertBoneMatrix() {}
|
||||
|
||||
InvertBoneMatrix(const InvertBoneMatrix& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
|
||||
: osg::Object(copy, copyop), osg::NodeCallback(copy, copyop) {}
|
||||
|
||||
META_Object(NifOsg, InvertBoneMatrix)
|
||||
|
||||
void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
|
@ -183,21 +184,20 @@ namespace
|
|||
|
||||
osg::MatrixTransform* trans = dynamic_cast<osg::MatrixTransform*>(node);
|
||||
|
||||
osg::NodePath::iterator found = std::find(path.begin(), path.end(), mSkelRoot);
|
||||
if (found != path.end())
|
||||
for (osg::NodePath::iterator it = path.begin(); it != path.end(); ++it)
|
||||
{
|
||||
path.erase(path.begin(),found+1);
|
||||
|
||||
osg::Matrix worldMat = osg::computeLocalToWorld( path );
|
||||
trans->setMatrix(osg::Matrix::inverse(worldMat));
|
||||
if (dynamic_cast<osgAnimation::Skeleton*>(*it))
|
||||
{
|
||||
path.erase(path.begin(), it+1);
|
||||
// the bone's transform in skeleton space
|
||||
osg::Matrix boneMat = osg::computeLocalToWorld( path );
|
||||
trans->setMatrix(osg::Matrix::inverse(boneMat));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
traverse(node,nv);
|
||||
}
|
||||
private:
|
||||
|
||||
// TODO: keeping this pointer will break when copying the scene graph; maybe retrieve it while visiting if it's NULL?
|
||||
osg::Node* mSkelRoot;
|
||||
};
|
||||
|
||||
osg::ref_ptr<osg::Geometry> handleMorphGeometry(const Nif::NiGeomMorpherController* morpher)
|
||||
|
@ -793,7 +793,7 @@ namespace NifOsg
|
|||
rig->setInfluenceMap(map);
|
||||
|
||||
osg::ref_ptr<osg::MatrixTransform> trans(new osg::MatrixTransform);
|
||||
trans->setUpdateCallback(new InvertBoneMatrix(mSkeleton));
|
||||
trans->setUpdateCallback(new InvertBoneMatrix());
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
||||
geode->addDrawable(rig);
|
||||
|
|
Loading…
Reference in a new issue