1 | #include "OgreOcclusionCullingTerrainSceneManager.h"
|
---|
2 | #include "OgreMath.h"
|
---|
3 | #include "OgreIteratorWrappers.h"
|
---|
4 | #include "OgreRenderSystem.h"
|
---|
5 | #include "OgreCamera.h"
|
---|
6 | #include "OgreHardwareOcclusionQuery.h"
|
---|
7 | #include "OgreSolidHalfBoundingBox.h"
|
---|
8 |
|
---|
9 | #include <windows.h>
|
---|
10 |
|
---|
11 | namespace Ogre {
|
---|
12 | //-----------------------------------------------------------------------
|
---|
13 | OcclusionCullingTerrainSceneManager::OcclusionCullingTerrainSceneManager()
|
---|
14 | {
|
---|
15 | mOcclusionCullingOctreeSceneTraverser =
|
---|
16 | new OcclusionCullingOctreeSceneTraverser(this, mDestRenderSystem);
|
---|
17 |
|
---|
18 | //mShowBoxes = true;
|
---|
19 | //mDisplayNodes = true;
|
---|
20 | //mShowBoundingBoxes = true;
|
---|
21 | mMaxDepth = 20;
|
---|
22 | }
|
---|
23 | //-----------------------------------------------------------------------
|
---|
24 | OcclusionCullingTerrainSceneManager::~OcclusionCullingTerrainSceneManager()
|
---|
25 | {
|
---|
26 | delete mOcclusionCullingOctreeSceneTraverser;
|
---|
27 | }
|
---|
28 | //-----------------------------------------------------------------------
|
---|
29 | void OcclusionCullingTerrainSceneManager::_renderVisibleObjects(void)
|
---|
30 | {
|
---|
31 | //-- render background
|
---|
32 | clearSpecialCaseRenderQueues();
|
---|
33 | addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
|
---|
34 | addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY);
|
---|
35 |
|
---|
36 | setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
|
---|
37 | SceneManager::_renderVisibleObjects();
|
---|
38 | _deleteRenderedQueueGroups();
|
---|
39 |
|
---|
40 | //-- render visible objects (i.e., all but overlay)
|
---|
41 | clearSpecialCaseRenderQueues();
|
---|
42 | addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY);
|
---|
43 | setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
|
---|
44 |
|
---|
45 | mOcclusionCullingOctreeSceneTraverser->setSceneRoot(mOctree);
|
---|
46 | mOcclusionCullingOctreeSceneTraverser->renderScene(mCameraInProgress);
|
---|
47 |
|
---|
48 | _deleteRenderedQueueGroups();
|
---|
49 |
|
---|
50 | //-- render overlay
|
---|
51 | clearSpecialCaseRenderQueues();
|
---|
52 | SceneManager::_renderVisibleObjects( );
|
---|
53 | }
|
---|
54 | //-----------------------------------------------------------------------
|
---|
55 | void OcclusionCullingTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
|
---|
56 | {
|
---|
57 | // must be empty because objects are found and rendered in an interleaved fashion
|
---|
58 | // in _renderVisibibleObjects
|
---|
59 | }
|
---|
60 | //-----------------------------------------------------------------------
|
---|
61 | void OcclusionCullingTerrainSceneManager::_updateSceneGraph(Camera* cam)
|
---|
62 | {
|
---|
63 | mOcclusionCullingOctreeSceneTraverser->setNumSceneNodes((int)mSceneNodes.size());
|
---|
64 | mOcclusionCullingOctreeSceneTraverser->setRenderSystem(mDestRenderSystem);
|
---|
65 |
|
---|
66 | mOcclusionCullingOctreeSceneTraverser->setNumOctreeNodes(mNumOctreeNodes);
|
---|
67 |
|
---|
68 | TerrainSceneManager::_updateSceneGraph(cam);
|
---|
69 | }
|
---|
70 | //-----------------------------------------------------------------------
|
---|
71 | bool OcclusionCullingTerrainSceneManager::setOption( const String & key, const void * val )
|
---|
72 | {
|
---|
73 | return mOcclusionCullingOctreeSceneTraverser->setOption( key, val) || TerrainSceneManager::setOption( key, val );
|
---|
74 | }
|
---|
75 | //-----------------------------------------------------------------------
|
---|
76 | bool OcclusionCullingTerrainSceneManager::getOption( const String & key, void *val )
|
---|
77 | {
|
---|
78 | return mOcclusionCullingOctreeSceneTraverser->getOption( key, val) || TerrainSceneManager::getOption( key, val ) ;
|
---|
79 | }
|
---|
80 | //-----------------------------------------------------------------------
|
---|
81 | bool OcclusionCullingTerrainSceneManager::getOptionValues( const String & key, StringVector &refValueList )
|
---|
82 | {
|
---|
83 | return TerrainSceneManager::getOptionValues( key, refValueList );
|
---|
84 | }
|
---|
85 | //-----------------------------------------------------------------------
|
---|
86 | bool OcclusionCullingTerrainSceneManager::getOptionKeys( StringVector & refKeys )
|
---|
87 | {
|
---|
88 | return mOcclusionCullingOctreeSceneTraverser->getOptionKeys ( refKeys ) || TerrainSceneManager::getOptionKeys( refKeys );
|
---|
89 | }
|
---|
90 | //-----------------------------------------------------------------------
|
---|
91 | /*unsigned int OcclusionCullingTerrainSceneManager::countNumOctrees(Octree *root)
|
---|
92 | {
|
---|
93 | unsigned int result = 1;
|
---|
94 |
|
---|
95 | for(int i=0; i<8; ++i)
|
---|
96 | {
|
---|
97 | Octree *nextChild = root->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1];
|
---|
98 |
|
---|
99 | if(nextChild != 0)
|
---|
100 | result += countNumOctrees(nextChild);
|
---|
101 | }
|
---|
102 |
|
---|
103 | return result;
|
---|
104 | }*/
|
---|
105 | }
|
---|