source: trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp @ 74

Revision 74, 4.3 KB checked in by mattausch, 19 years ago (diff)

added support for release mode

Line 
1#include "OgreSceneNodeHierarchyInterface.h"
2#include <OgreIteratorWrappers.h>
3#include <OgreCamera.h>
4#include <OgreSceneNode.h>
5
6//#include <windows.h>
7
8namespace Ogre {
9
10//-----------------------------------------------------------------------
11SceneNodeHierarchyInterface::SceneNodeHierarchyInterface(SceneManager *sm, RenderSystem *rsys):
12PlatformHierarchyInterface(sm, rsys)
13{               
14}
15//-----------------------------------------------------------------------
16void SceneNodeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node)
17{
18        mNumTraversedNodes ++;
19       
20        SceneNode *sceneNode = static_cast<SceneNode *>(node);
21
22        if (HasGeometry(node))
23        {
24                RenderNode(node);
25        }
26
27        // internal node: add children to priority queue for further processing
28        Node::ChildNodeIterator it = sceneNode->getChildIterator();
29                               
30        while (it.hasMoreElements())                   
31        {
32                mDistanceQueue->push(it.getNext());
33        }
34}
35//-----------------------------------------------------------------------
36void SceneNodeHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node)
37{
38#ifdef GTP_VISIBILITY_MODIFIED_OGRE
39        SceneNode *sceneNode = static_cast<SceneNode *>(node);
40
41        if (sceneNode->lastRendered() != sceneNode->lastVisited())
42        {
43                sceneNode->setLastRendered(sceneNode->lastVisited());
44                mNumRenderedNodes ++;
45
46                mSceneManager->_renderSceneNode(mCamera, sceneNode);
47        }
48#endif
49}
50//-----------------------------------------------------------------------
51bool SceneNodeHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node) const
52{
53        return (static_cast<SceneNode *>(node)->numChildren() == 0);
54}
55//-----------------------------------------------------------------------
56bool SceneNodeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const
57{
58        SceneNode *sceneNode = static_cast<SceneNode *>(node);
59       
60        return sceneNode->numAttachedObjects() > 0;
61}
62//-----------------------------------------------------------------------
63void SceneNodeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node)
64{
65#ifdef GTP_VISIBILITY_MODIFIED_OGRE
66        SceneNode *sceneNode = static_cast<SceneNode *>(node);
67
68        while(sceneNode && !sceneNode->isNodeVisible())
69        {
70                sceneNode->setNodeVisible(true);
71                sceneNode = sceneNode->getParentSceneNode();
72        }
73#endif
74}
75//-----------------------------------------------------------------------
76bool SceneNodeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1,
77                                                                                                         GtpVisibility::HierarchyNode *node2) const
78{
79        SceneNode *sceneNode1 = static_cast<SceneNode *>(node1);
80        SceneNode *sceneNode2 = static_cast<SceneNode *>(node2);
81
82        return sceneNode1->getSquaredViewDepth(mCamera) > sceneNode2->getSquaredViewDepth(mCamera);
83}
84//-----------------------------------------------------------------------
85void SceneNodeHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node,
86                                                                                                 const bool visible)
87{
88#ifdef GTP_VISIBILITY_MODIFIED_OGRE
89        SceneNode *sceneNode = static_cast<SceneNode *>(node);
90        sceneNode->setNodeVisible(visible);
91#endif
92}
93//-----------------------------------------------------------------------
94void SceneNodeHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node,
95                                                                                                 const unsigned int frameId)
96{
97#ifdef GTP_VISIBILITY_MODIFIED_OGRE
98        SceneNode *sceneNode = static_cast<SceneNode *>(node);
99        sceneNode->setLastVisited(frameId);
100#endif
101}
102//-----------------------------------------------------------------------
103bool SceneNodeHierarchyInterface::IsNodeVisible(GtpVisibility::HierarchyNode *node) const
104{
105#ifdef GTP_VISIBILITY_MODIFIED_OGRE
106        SceneNode *sceneNode = static_cast<SceneNode *>(node);
107        return sceneNode->isNodeVisible();
108#else
109        return true;
110#endif
111}
112//-----------------------------------------------------------------------
113unsigned int SceneNodeHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node) const
114{
115#ifdef GTP_VISIBILITY_MODIFIED_OGRE
116        SceneNode *sceneNode = static_cast<SceneNode *>(node);
117        return sceneNode->lastVisited();
118#else
119        return 0;
120#endif
121}
122//-----------------------------------------------------------------------
123AxisAlignedBox *SceneNodeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node)
124{
125        SceneNode *sceneNode = static_cast<SceneNode *>(node);
126        return &mBox;
127}
128} // namespace Ogre     
Note: See TracBrowser for help on using the repository browser.