root/OpenSceneGraph/trunk/src/osgUtil/RenderLeaf.cpp @ 7328

Revision 7328, 2.4 kB (checked in by robert, 7 years ago)

Changed RenderLeaf? and StateGraph? so that they use ref_ptr<> by default for Drawable and StateSet?.

  • 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#include <osgUtil/RenderLeaf>
14#include <osgUtil/StateGraph>
15#include <osg/Notify>
16
17using namespace osg;
18using namespace osgUtil;
19
20void RenderLeaf::render(osg::RenderInfo& renderInfo,RenderLeaf* previous)
21{
22    osg::State& state = *renderInfo.getState();
23
24    // don't draw this leaf if the abort rendering flag has been set.
25    if (state.getAbortRendering())
26    {
27        //cout << "early abort"<<endl;
28        return;
29    }
30
31    if (previous)
32    {
33
34        // apply matrices if required.
35        state.applyProjectionMatrix(_projection.get());
36        state.applyModelViewMatrix(_modelview.get());
37
38        // apply state if required.
39        StateGraph* prev_rg = previous->_parent;
40        StateGraph* prev_rg_parent = prev_rg->_parent;
41        StateGraph* rg = _parent;
42        if (prev_rg_parent!=rg->_parent)
43        {
44            StateGraph::moveStateGraph(state,prev_rg_parent,rg->_parent);
45
46            // send state changes and matrix changes to OpenGL.
47            state.apply(rg->getStateSet());
48
49        }
50        else if (rg!=prev_rg)
51        {
52
53            // send state changes and matrix changes to OpenGL.
54            state.apply(rg->getStateSet());
55
56        }
57       
58
59        // draw the drawable
60        _drawable->draw(renderInfo);
61    }
62    else
63    {
64        // apply matrices if required.
65        state.applyProjectionMatrix(_projection.get());
66        state.applyModelViewMatrix(_modelview.get());
67
68        // apply state if required.
69        StateGraph::moveStateGraph(state,NULL,_parent->_parent);
70
71        state.apply(_parent->getStateSet());
72
73        // draw the drawable
74        _drawable->draw(renderInfo);
75    }
76   
77    if (_dynamic)
78    {
79        state.decrementDynamicObjectCount();
80    }
81   
82    // osg::notify(osg::NOTICE)<<"RenderLeaf "<<_drawable->getName()<<" "<<_depth<<std::endl;
83}
Note: See TracBrowser for help on using the browser.