root/OpenSceneGraph/trunk/src/osgAnimation/StackedTransform.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 <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    {
26        const StackedTransformElement* element = it->get();
27        if (element)
28            push_back(osg::clone(element,co));
29    }
30}
31
32
33void StackedTransform::update(float t)
34{
35    int dirty = 0;
36    for (StackedTransform::iterator it = begin(); it != end(); ++it)
37    {
38        StackedTransformElement* element = it->get();
39        if (!element)
40            continue;
41        // update and check if there are changes
42        element->update(t);
43        if (element->isIdentity())
44            continue;
45        dirty++;
46    }
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    {
56        StackedTransformElement* element = it->get();
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.