root/OpenSceneGraph/trunk/include/osgUtil/RenderLeaf @ 13041

Revision 13041, 3.5 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGUTIL_RENDERLEAF
15#define OSGUTIL_RENDERLEAF 1
16
17#include <osg/ref_ptr>
18#include <osg/Matrix>
19#include <osg/Drawable>
20#include <osg/State>
21
22#include <osgUtil/Export>
23
24namespace osgUtil {
25
26#define OSGUTIL_RENDERBACKEND_USE_REF_PTR
27
28// Forward declare StateGraph
29class StateGraph;
30
31/** Container class for all data required for rendering of drawables.
32  */
33class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
34{
35    public:
36
37
38        inline RenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalNumber=0):
39            osg::Referenced(false),
40            _parent(0),
41            _drawable(drawable),
42            _projection(projection),
43            _modelview(modelview),
44            _depth(depth),
45            _traversalNumber(traversalNumber)
46        {
47            _dynamic = (drawable->getDataVariance()==osg::Object::DYNAMIC);
48        }
49
50
51        inline void set(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* modelview, float depth=0.0f, unsigned int traversalNumber=0)
52        {
53            _parent = 0;
54            _drawable = drawable;
55            _projection = projection,
56            _modelview = modelview,
57            _depth = depth;
58            _dynamic = (drawable->getDataVariance()==osg::Object::DYNAMIC);
59            _traversalNumber = traversalNumber;
60        }
61
62        inline void reset()
63        {
64            _parent = 0;
65            _drawable = 0;
66            _projection = 0;
67            _modelview = 0;
68            _depth = 0.0f;
69            _dynamic = false;
70            _traversalNumber = 0;
71        }
72
73        virtual void render(osg::RenderInfo& renderInfo,RenderLeaf* previous);
74
75        /// Allow StateGraph to change the RenderLeaf's _parent.
76        friend class osgUtil::StateGraph;
77
78    public:
79
80
81
82        StateGraph*                     _parent;
83
84#ifdef OSGUTIL_RENDERBACKEND_USE_REF_PTR
85        osg::ref_ptr<osg::Drawable>     _drawable;
86        const osg::Drawable* getDrawable() const { return _drawable.get(); }
87#else
88        osg::Drawable*                  _drawable;
89        const osg::Drawable* getDrawable() const { return _drawable; }
90#endif
91        osg::ref_ptr<osg::RefMatrix>    _projection;
92        osg::ref_ptr<osg::RefMatrix>    _modelview;
93        float                           _depth;
94        bool                            _dynamic;
95        unsigned int                    _traversalNumber;
96
97    private:
98
99        /// disallow creation of blank RenderLeaf as this isn't useful.
100        RenderLeaf():
101            osg::Referenced(false),
102            _parent(0),
103            _drawable(0),
104            _projection(0),
105            _modelview(0),
106            _depth(0.0f),
107            _traversalNumber(0) {}
108
109        /// disallow copy construction.
110        RenderLeaf(const RenderLeaf&):osg::Referenced(false) {}
111        /// disallow copy operator.
112        RenderLeaf& operator = (const RenderLeaf&) { return *this; }
113
114};
115
116}
117
118#endif
Note: See TracBrowser for help on using the browser.