diff --git a/CMakeLists.txt b/CMakeLists.txt index 12724740d..badecd43d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ PROJECT(OpenSceneGraph) SET(OPENSCENEGRAPH_MAJOR_VERSION 3) SET(OPENSCENEGRAPH_MINOR_VERSION 3) SET(OPENSCENEGRAPH_PATCH_VERSION 6) -SET(OPENSCENEGRAPH_SOVERSION 118) +SET(OPENSCENEGRAPH_SOVERSION 119) # set to 0 when not a release candidate, non zero means that any generated # svn tags will be treated as release candidates of given number diff --git a/include/osgAnimation/MorphGeometry b/include/osgAnimation/MorphGeometry index 48e384201..634167fb0 100644 --- a/include/osgAnimation/MorphGeometry +++ b/include/osgAnimation/MorphGeometry @@ -48,18 +48,6 @@ namespace osgAnimation typedef std::vector MorphTargetList; - struct UpdateVertex : public osg::Drawable::UpdateCallback - { - virtual void update(osg::NodeVisitor*, osg::Drawable* drw) - { - MorphGeometry* geom = dynamic_cast(drw); - if (!geom) - return; - - geom->transformSoftwareMethod(); - } - }; - MorphGeometry(); MorphGeometry(const osg::Geometry& b); MorphGeometry(const MorphGeometry& b, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); @@ -149,6 +137,25 @@ namespace osgAnimation bool link(osgAnimation::Channel* channel); }; + struct UpdateMorphGeometry : public osg::Drawable::UpdateCallback + { + UpdateMorphGeometry() {} + + UpdateMorphGeometry(const UpdateMorphGeometry&, const osg::CopyOp&) {} + + META_Object(osgAnimation, UpdateMorphGeometry); + + virtual void update(osg::NodeVisitor*, osg::Drawable* drw) + { + MorphGeometry* geom = dynamic_cast(drw); + if (!geom) + return; + + geom->transformSoftwareMethod(); + } + }; + + } #endif diff --git a/include/osgAnimation/RigGeometry b/include/osgAnimation/RigGeometry index 76dd2519e..2fc542ffd 100644 --- a/include/osgAnimation/RigGeometry +++ b/include/osgAnimation/RigGeometry @@ -46,6 +46,7 @@ namespace osgAnimation mutable osg::BoundingBox _boundingBox; }; + class OSGANIMATION_EXPORT RigGeometry : public osg::Geometry { public: @@ -92,41 +93,16 @@ namespace osgAnimation void copyFrom(osg::Geometry& from); - struct UpdateVertex : public osg::Drawable::UpdateCallback + struct FindNearestParentSkeleton : public osg::NodeVisitor { - UpdateVertex() {} - - UpdateVertex(const UpdateCallback&, const osg::CopyOp&) {} - - META_Object(osgAnimation, UpdateVertex); - - virtual void update(osg::NodeVisitor*, osg::Drawable* drw) { - RigGeometry* geom = dynamic_cast(drw); - if(!geom) + osg::ref_ptr _root; + FindNearestParentSkeleton() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_PARENTS) {} + void apply(osg::Transform& node) + { + if (_root.valid()) return; - if(!geom->getSkeleton() && !geom->getParents().empty()) - { - FindNearestParentSkeleton finder; - if(geom->getParents().size() > 1) - osg::notify(osg::WARN) << "A RigGeometry should not have multi parent ( " << geom->getName() << " )" << std::endl; - geom->getParents()[0]->accept(finder); - - if(!finder._root.valid()) - { - osg::notify(osg::WARN) << "A RigGeometry did not find a parent skeleton for RigGeomtry ( " << geom->getName() << " )" << std::endl; - return; - } - geom->buildVertexInfluenceSet(); - geom->setSkeleton(finder._root.get()); - } - - if(!geom->getSkeleton()) - return; - - if(geom->getNeedToComputeMatrix()) - geom->computeMatrixFromRootSkeleton(); - - geom->update(); + _root = dynamic_cast(&node); + traverse(node); } }; @@ -143,21 +119,47 @@ namespace osgAnimation osg::observer_ptr _root; bool _needToComputeMatrix; - struct FindNearestParentSkeleton : public osg::NodeVisitor - { - osg::ref_ptr _root; - FindNearestParentSkeleton() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_PARENTS) {} - void apply(osg::Transform& node) - { - if (_root.valid()) - return; - _root = dynamic_cast(&node); - traverse(node); - } - }; }; + + struct UpdateRigGeometry : public osg::Drawable::UpdateCallback + { + UpdateRigGeometry() {} + + UpdateRigGeometry(const UpdateRigGeometry&, const osg::CopyOp&) {} + + META_Object(osgAnimation, UpdateRigGeometry); + + virtual void update(osg::NodeVisitor*, osg::Drawable* drw) { + RigGeometry* geom = dynamic_cast(drw); + if(!geom) + return; + if(!geom->getSkeleton() && !geom->getParents().empty()) + { + RigGeometry::FindNearestParentSkeleton finder; + if(geom->getParents().size() > 1) + osg::notify(osg::WARN) << "A RigGeometry should not have multi parent ( " << geom->getName() << " )" << std::endl; + geom->getParents()[0]->accept(finder); + + if(!finder._root.valid()) + { + osg::notify(osg::WARN) << "A RigGeometry did not find a parent skeleton for RigGeomtry ( " << geom->getName() << " )" << std::endl; + return; + } + geom->buildVertexInfluenceSet(); + geom->setSkeleton(finder._root.get()); + } + + if(!geom->getSkeleton()) + return; + + if(geom->getNeedToComputeMatrix()) + geom->computeMatrixFromRootSkeleton(); + + geom->update(); + } + }; } #endif diff --git a/src/osgAnimation/MorphGeometry.cpp b/src/osgAnimation/MorphGeometry.cpp index f3c819198..b22879072 100644 --- a/src/osgAnimation/MorphGeometry.cpp +++ b/src/osgAnimation/MorphGeometry.cpp @@ -25,7 +25,7 @@ MorphGeometry::MorphGeometry() : _morphNormals(true) { setUseDisplayList(false); - setUpdateCallback(new UpdateVertex); + setUpdateCallback(new UpdateMorphGeometry); setDataVariance(osg::Object::DYNAMIC); setUseVertexBufferObjects(true); } @@ -37,7 +37,7 @@ MorphGeometry::MorphGeometry(const osg::Geometry& b) : _morphNormals(true) { setUseDisplayList(false); - setUpdateCallback(new UpdateVertex); + setUpdateCallback(new UpdateMorphGeometry); setDataVariance(osg::Object::DYNAMIC); setUseVertexBufferObjects(true); } diff --git a/src/osgAnimation/RigGeometry.cpp b/src/osgAnimation/RigGeometry.cpp index 344d129b8..c34ceb687 100644 --- a/src/osgAnimation/RigGeometry.cpp +++ b/src/osgAnimation/RigGeometry.cpp @@ -53,7 +53,7 @@ RigGeometry::RigGeometry() { _supportsDisplayList = false; setUseVertexBufferObjects(true); - setUpdateCallback(new UpdateVertex); + setUpdateCallback(new UpdateRigGeometry); setDataVariance(osg::Object::DYNAMIC); _needToComputeMatrix = true; _matrixFromSkeletonToGeometry = _invMatrixFromSkeletonToGeometry = osg::Matrix::identity(); diff --git a/src/osgWrappers/serializers/osgAnimation/LibraryWrapper.cpp b/src/osgWrappers/serializers/osgAnimation/LibraryWrapper.cpp index c06f656c8..e36c41f75 100644 --- a/src/osgWrappers/serializers/osgAnimation/LibraryWrapper.cpp +++ b/src/osgWrappers/serializers/osgAnimation/LibraryWrapper.cpp @@ -25,6 +25,8 @@ USE_SERIALIZER_WRAPPER(osgAnimation_UpdateMaterial) USE_SERIALIZER_WRAPPER(osgAnimation_UpdateMatrixTransform) USE_SERIALIZER_WRAPPER(osgAnimation_UpdateMorph) USE_SERIALIZER_WRAPPER(osgAnimation_UpdateSkeleton) +USE_SERIALIZER_WRAPPER(osgAnimation_UpdateMorphGeometry) +USE_SERIALIZER_WRAPPER(osgAnimation_UpdateRigGeometry) extern "C" void wrapper_serializer_library_osgAnimation(void) {} diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp index 5818a75f9..8c1b7247d 100644 --- a/src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp +++ b/src/osgWrappers/serializers/osgAnimation/UpdateBone.cpp @@ -9,7 +9,7 @@ REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateBone, new osgAnimation::UpdateBone, osgAnimation::UpdateBone, - "osg::Object osg::NodeCallback osgAnimation::UpdateMatrixTransform osgAnimation::UpdateBone" ) + "osg::Object osg::Callback osg::NodeCallback osgAnimation::UpdateMatrixTransform osgAnimation::UpdateBone" ) { } diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp index 0fe1ef359..73e7c9d3d 100644 --- a/src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp +++ b/src/osgWrappers/serializers/osgAnimation/UpdateMaterial.cpp @@ -9,7 +9,7 @@ REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMaterial, new osgAnimation::UpdateMaterial, osgAnimation::UpdateMaterial, - "osg::Object osgAnimation::UpdateMaterial" ) + "osg::Object osg::Callback osgAnimation::UpdateMaterial" ) { } diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateMatrixTransform.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateMatrixTransform.cpp index 40ff00f9d..4c78bc52e 100644 --- a/src/osgWrappers/serializers/osgAnimation/UpdateMatrixTransform.cpp +++ b/src/osgWrappers/serializers/osgAnimation/UpdateMatrixTransform.cpp @@ -41,7 +41,7 @@ static bool writeStackedTransforms( osgDB::OutputStream& os, const osgAnimation: REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMatrixTransform, new osgAnimation::UpdateMatrixTransform, osgAnimation::UpdateMatrixTransform, - "osg::Object osg::NodeCallback osgAnimation::UpdateMatrixTransform" ) + "osg::Object osg::Callback osg::NodeCallback osgAnimation::UpdateMatrixTransform" ) { ADD_USER_SERIALIZER( StackedTransforms ); // _transforms } diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp index a450848ae..f3070ba7d 100644 --- a/src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp +++ b/src/osgWrappers/serializers/osgAnimation/UpdateMorph.cpp @@ -9,7 +9,7 @@ REGISTER_OBJECT_WRAPPER( osgAnimation_UpdateMorph, new osgAnimation::UpdateMorph, osgAnimation::UpdateMorph, - "osg::Object osg::NodeCallback osgAnimation::UpdateMorph" ) + "osg::Object osg::Callback osg::NodeCallback osgAnimation::UpdateMorph" ) { } diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateMorphGeometry.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateMorphGeometry.cpp new file mode 100644 index 000000000..b79a2133a --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/UpdateMorphGeometry.cpp @@ -0,0 +1,15 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER(osgAnimation_UpdateMorphGeometry, + new osgAnimation::UpdateMorphGeometry, + osgAnimation::UpdateMorphGeometry, + "osg::Object osg::Callback osg::UpdateCallback osgAnimation::UpdateMorphGeometry") {} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateRigGeometry.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateRigGeometry.cpp new file mode 100644 index 000000000..60ddae553 --- /dev/null +++ b/src/osgWrappers/serializers/osgAnimation/UpdateRigGeometry.cpp @@ -0,0 +1,15 @@ +#undef OBJECT_CAST +#define OBJECT_CAST dynamic_cast + +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER(osgAnimation_UpdateRigGeometry, + new osgAnimation::UpdateRigGeometry, + osgAnimation::UpdateRigGeometry, + "osg::Object osg::Callback osg::UpdateCallback osgAnimation::UpdateRigGeometry") {} + +#undef OBJECT_CAST +#define OBJECT_CAST static_cast diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp index 5b910273a..b458afecb 100644 --- a/src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp +++ b/src/osgWrappers/serializers/osgAnimation/UpdateSkeleton.cpp @@ -10,7 +10,7 @@ REGISTER_OBJECT_WRAPPER2( osgAnimation_UpdateSkeleton, new osgAnimation::Skeleton::UpdateSkeleton, osgAnimation::Skeleton::UpdateSkeleton, "osgAnimation::UpdateSkeleton", - "osg::Object osg::NodeCallback osgAnimation::UpdateSkeleton" ) + "osg::Object osg::Callback osg::NodeCallback osgAnimation::UpdateSkeleton" ) { } diff --git a/src/osgWrappers/serializers/osgAnimation/UpdateVertex.cpp b/src/osgWrappers/serializers/osgAnimation/UpdateVertex.cpp deleted file mode 100644 index 89f4b2e33..000000000 --- a/src/osgWrappers/serializers/osgAnimation/UpdateVertex.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#undef OBJECT_CAST -#define OBJECT_CAST dynamic_cast - -#include -#include -#include -#include - -REGISTER_OBJECT_WRAPPER2(osg_Drawable_UpdateCallback, - new osgAnimation::RigGeometry::UpdateVertex, - osgAnimation::RigGeometry::UpdateVertex, - "osgAnimation::UpdateVertex", - "osg::Object osg::UpdateCallback osgAnimation::UpdateVertex") {} - -#undef OBJECT_CAST -#define OBJECT_CAST static_cast