diff --git a/include/osgAnimation/MorphGeometry b/include/osgAnimation/MorphGeometry index a1ec3f697..9c87ac681 100644 --- a/include/osgAnimation/MorphGeometry +++ b/include/osgAnimation/MorphGeometry @@ -61,25 +61,25 @@ namespace osgAnimation virtual const char* className() const { return "MorphGeometry"; } // set implementation of rig method - void setMorphTransformImplementation(MorphTransform*); - MorphTransform* getMorphTransformImplementation(); - const MorphTransform* getMorphTransformImplementation() const { return _rigTransformImplementation.get(); } + inline void setMorphTransformImplementation(MorphTransform*mt) { _morphTransformImplementation=mt; } + inline MorphTransform* getMorphTransformImplementation() { return _morphTransformImplementation.get(); } + inline const MorphTransform* getMorphTransformImplementation() const { return _morphTransformImplementation.get(); } /** Set the morphing method. */ - void setMethod(Method method) { _method = method; } + inline void setMethod(Method method) { _method = method; } /** Get the morphing method. */ inline Method getMethod() const { return _method; } /** Set flag for morphing normals. */ - void setMorphNormals(bool morphNormals) { _morphNormals = morphNormals; } + inline void setMorphNormals(bool morphNormals) { _morphNormals = morphNormals; } /** Get the flag for morphing normals. */ inline bool getMorphNormals() const { return _morphNormals; } /** Get the list of MorphTargets.*/ - const MorphTargetList& getMorphTargetList() const { return _morphTargets; } + inline const MorphTargetList& getMorphTargetList() const { return _morphTargets; } /** Get the list of MorphTargets. Warning if you modify this array you will have to call dirty() */ - MorphTargetList& getMorphTargetList() { return _morphTargets; } + inline MorphTargetList& getMorphTargetList() { return _morphTargets; } /** Return the \c MorphTarget at position \c i.*/ inline const MorphTarget& getMorphTarget( unsigned int i ) const { return _morphTargets[i]; } @@ -130,7 +130,7 @@ namespace osgAnimation } /** update a morph target at index setting its current weight to morphWeight */ - void setWeight(unsigned int index, float morphWeight) + inline void setWeight(unsigned int index, float morphWeight) { if (index < _morphTargets.size()) { @@ -144,10 +144,10 @@ namespace osgAnimation inline bool isDirty()const { return _dirty; } /** for retrocompatibility */ - virtual void transformSoftwareMethod(){ if (!_rigTransformImplementation.valid())_rigTransformImplementation = new MorphTransformSoftware();(*_rigTransformImplementation.get())(*this);} + virtual void transformSoftwareMethod(){(*_morphTransformImplementation.get())(*this);} protected: - osg::ref_ptr _rigTransformImplementation; + osg::ref_ptr _morphTransformImplementation; /// Do we need to recalculate the morphed geometry? bool _dirty; diff --git a/include/osgAnimation/MorphTransformHardware b/include/osgAnimation/MorphTransformHardware index e75114a74..9b5e5239b 100644 --- a/include/osgAnimation/MorphTransformHardware +++ b/include/osgAnimation/MorphTransformHardware @@ -1,5 +1,5 @@ /* -*-c++-*- - * Copyright (C) 2009 Cedric Pinson + * Copyright (C) 2017 Julien Valentin * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or diff --git a/include/osgAnimation/RigGeometry b/include/osgAnimation/RigGeometry index a2a096b51..e3b3c4a46 100644 --- a/include/osgAnimation/RigGeometry +++ b/include/osgAnimation/RigGeometry @@ -145,10 +145,6 @@ namespace osgAnimation } geom->setSkeleton(finder._root.get()); - if(!geom->getRigTransformImplementation()) - { - geom->setRigTransformImplementation(new RigTransformSoftware); - } geom->getRigTransformImplementation()->prepareData(*geom); } diff --git a/src/osgAnimation/MorphGeometry.cpp b/src/osgAnimation/MorphGeometry.cpp index f52c04c3a..07a86d1a6 100644 --- a/src/osgAnimation/MorphGeometry.cpp +++ b/src/osgAnimation/MorphGeometry.cpp @@ -29,6 +29,7 @@ MorphGeometry::MorphGeometry() : setUseDisplayList(false); setUpdateCallback(new UpdateMorphGeometry); setUseVertexBufferObjects(true); + _morphTransformImplementation = new MorphTransformSoftware(); } MorphGeometry::MorphGeometry(const osg::Geometry& g) : @@ -41,10 +42,12 @@ MorphGeometry::MorphGeometry(const osg::Geometry& g) : setUseDisplayList(false); setUpdateCallback(new UpdateMorphGeometry); setUseVertexBufferObjects(true); + _morphTransformImplementation = new MorphTransformSoftware(); } MorphGeometry::MorphGeometry(const MorphGeometry& b, const osg::CopyOp& copyop) : osg::Geometry(b,copyop), + _morphTransformImplementation((MorphTransform*)copyop(b._morphTransformImplementation)), _dirty(b._dirty), _method(b._method), _morphTargets(b._morphTargets), @@ -56,9 +59,6 @@ MorphGeometry::MorphGeometry(const MorphGeometry& b, const osg::CopyOp& copyop) setUseVertexBufferObjects(true); } -MorphTransform* MorphGeometry::getMorphTransformImplementation() { return _rigTransformImplementation.get(); } -void MorphGeometry::setMorphTransformImplementation(MorphTransform* rig) { _rigTransformImplementation = rig; } - UpdateMorph::UpdateMorph(const UpdateMorph& apc,const osg::CopyOp& copyop) : osg::Object(apc, copyop), osg::Callback(apc, copyop), diff --git a/src/osgAnimation/MorphTransformHardware.cpp b/src/osgAnimation/MorphTransformHardware.cpp index be37a470a..8b5351cea 100644 --- a/src/osgAnimation/MorphTransformHardware.cpp +++ b/src/osgAnimation/MorphTransformHardware.cpp @@ -1,5 +1,5 @@ /* -*-c++-*- - * Copyleft 2016 Valentin Julien + * Copyright (C) 2017 Julien Valentin * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or diff --git a/src/osgAnimation/RigGeometry.cpp b/src/osgAnimation/RigGeometry.cpp index 057625876..c176cf9df 100644 --- a/src/osgAnimation/RigGeometry.cpp +++ b/src/osgAnimation/RigGeometry.cpp @@ -59,6 +59,7 @@ RigGeometry::RigGeometry() _matrixFromSkeletonToGeometry = _invMatrixFromSkeletonToGeometry = osg::Matrix::identity(); // disable the computation of boundingbox for the rig mesh setComputeBoundingBoxCallback(new RigComputeBoundingBoxCallback()); + _rigTransformImplementation = new osgAnimation::RigTransformSoftware; } @@ -66,6 +67,7 @@ RigGeometry::RigGeometry() RigGeometry::RigGeometry(const RigGeometry& b, const osg::CopyOp& copyop) : osg::Geometry(b,copyop), _geometry(b._geometry), + _rigTransformImplementation((RigTransform*)copyop(b._rigTransformImplementation)), _vertexInfluenceMap(b._vertexInfluenceMap), _needToComputeMatrix(b._needToComputeMatrix) { @@ -100,7 +102,7 @@ void RigGeometry::computeMatrixFromRootSkeleton() void RigGeometry::update() { - RigTransform& implementation = *getRigTransformImplementation(); + RigTransform& implementation = *_rigTransformImplementation; (implementation)(*this); }