root/OpenSceneGraph/trunk/src/osgAnimation/UpdateBone.cpp @ 13041

Revision 13041, 1.9 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/*  -*-c++-*-
2 *  Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
3 *
4 * This library is open source and may be redistributed and/or modified under
5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 * (at your option) any later version.  The full license is in LICENSE file
7 * included with this distribution, and on the openscenegraph.org website.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * OpenSceneGraph Public License for more details.
13 */
14
15#include <osg/NodeVisitor>
16#include <osgAnimation/Bone>
17#include <osgAnimation/UpdateBone>
18
19using namespace osgAnimation;
20
21
22UpdateBone::UpdateBone(const std::string& name) : UpdateMatrixTransform(name)
23{
24}
25
26UpdateBone::UpdateBone(const UpdateBone& apc,const osg::CopyOp& copyop) : osg::Object(apc,copyop), UpdateMatrixTransform(apc, copyop)
27{
28}
29
30/** Callback method called by the NodeVisitor when visiting a node.*/
31void UpdateBone::operator()(osg::Node* node, osg::NodeVisitor* nv)
32{
33    if (nv && nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
34    {
35        Bone* b = dynamic_cast<Bone*>(node);
36        if (!b)
37        {
38            OSG_WARN << "Warning: UpdateBone set on non-Bone object." << std::endl;
39            return;
40        }
41
42        // here we would prefer to have a flag inside transform stack in order to avoid update and a dirty state in matrixTransform if it's not require.
43        _transforms.update();
44        const osg::Matrix& matrix = _transforms.getMatrix();
45        b->setMatrix(matrix);
46
47        Bone* parent = b->getBoneParent();
48        if (parent)
49            b->setMatrixInSkeletonSpace(b->getMatrixInBoneSpace() * parent->getMatrixInSkeletonSpace());
50        else
51            b->setMatrixInSkeletonSpace(b->getMatrixInBoneSpace());
52    }
53    traverse(node,nv);
54}
Note: See TracBrowser for help on using the browser.