root/OpenSceneGraph/trunk/src/osgAnimation/StackedTransform.cpp @ 11034

Revision 11034, 1.9 kB (checked in by robert, 5 years ago)

Build fixes for build without ref_ptr<> automatic type conversion

RevLine 
[11009]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 <osgAnimation/StackedTransform>
16
17using namespace osgAnimation;
18
19StackedTransform::StackedTransform() {}
20
21StackedTransform::StackedTransform(const StackedTransform& rhs, const osg::CopyOp& co)
22{
23    reserve(rhs.size());
24    for (StackedTransform::const_iterator it = rhs.begin(); it != rhs.end(); ++it)
25    {
[11034]26        const StackedTransformElement* element = it->get();
[11009]27        if (element)
28            push_back(osg::clone(element,co));
29    }
30}
31
32
33void StackedTransform::update()
34{
35    int dirty = 0;
36    for (StackedTransform::iterator it = begin(); it != end(); ++it)
37    {
38       
[11034]39        StackedTransformElement* element = it->get();
[11009]40        if (!element)
41            continue;
42        // update and check if there are changes
43        element->update();
44        if (element->isIdentity())
45            continue;
46        dirty++;
47    }
48    if (!dirty)
49        return;
50
51
52    // dirty update matrix
53    _matrix.makeIdentity();
54    for (StackedTransform::iterator it = begin(); it != end(); ++it)
55    {
[11034]56        StackedTransformElement* element = it->get();
[11009]57        if (!element || element->isIdentity())
58            continue;
59        element->applyToMatrix(_matrix);
60    }
61}
62
63const osg::Matrix& StackedTransform::getMatrix() const
64{
65    return _matrix;
66}
Note: See TracBrowser for help on using the browser.