~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/SceneManagers/EmberPagingSceneManager/src/OgrePagingLandScapeOcclusionElement.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "OgrePagingLandScapePrecompiledHeaders.h"
 
3
 
 
4
#include <stack>
 
5
#include <queue>
 
6
 
 
7
#include "OgrePagingLandScapeOcclusionElement.h"
 
8
 
 
9
#include "OgrePagingLandScapePrerequisites.h"
 
10
#include "OgrePagingLandScapeOctreeCamera.h"
 
11
#include "OgrePagingLandScapeOcclusionVisibilityData.h"
 
12
#include "OgreDebugRectangle2D.h"
 
13
 
 
14
 
 
15
namespace Ogre
 
16
{
 
17
    //---------------------------------------------------------------------
 
18
    OcclusionElement::OcclusionElement() :
 
19
        #ifdef _VISIBILITYDEBUG
 
20
            mDebugRectangle2d(0),
 
21
        #endif //_VISIBILITYDEBUG  
 
22
        mIsRegisteredToCam (false)
 
23
    {
 
24
    } 
 
25
    //---------------------------------------------------------------------
 
26
    OcclusionElement::~OcclusionElement() 
 
27
    {
 
28
        #ifdef _VISIBILITYDEBUG
 
29
            delete mDebugRectangle2d;
 
30
        #endif //_VISIBILITYDEBUG  
 
31
        
 
32
        NodeDataPerCamMapiterator i = nodeDataPerCam.begin ();
 
33
        while (i != nodeDataPerCam.end())
 
34
        {
 
35
            delete i->second;
 
36
            ++i;
 
37
        }
 
38
        nodeDataPerCam.clear();
 
39
    }  
 
40
    //---------------------------------------------------------------------
 
41
    VisibilityData *OcclusionElement::getNodeData(PagingLandScapeOctreeCamera *cam)
 
42
    {
 
43
        if (nodeDataPerCam.find(cam->getId()) == nodeDataPerCam.end())
 
44
            nodeDataPerCam[cam->getId()] = new VisibilityData();
 
45
        //assert (nodeDataPerCam.find(cam->getId()) != nodeDataPerCam.end());
 
46
        return nodeDataPerCam[cam->getId()];
 
47
    }
 
48
    //---------------------------------------------------------------------
 
49
    void OcclusionElement::addCamNodeData (PagingLandScapeOctreeCamera *cam)
 
50
    {
 
51
        if (nodeDataPerCam.find(cam->getId()) == nodeDataPerCam.end())
 
52
            nodeDataPerCam[cam->getId()] = new VisibilityData();
 
53
    }
 
54
    //---------------------------------------------------------------------
 
55
    void OcclusionElement::removeCamNodeData (PagingLandScapeOctreeCamera *cam)
 
56
    {
 
57
        NodeDataPerCamMapiterator i = nodeDataPerCam.find (cam->getId());
 
58
        if (i != nodeDataPerCam.end())
 
59
        {
 
60
            delete i->second;
 
61
                nodeDataPerCam.erase (i);
 
62
        }
 
63
    }
 
64
    #ifdef _VISIBILITYDEBUG
 
65
        //---------------------------------------------------------------------
 
66
        DebugRectangle2D *OcclusionElement::getRectangle2d(SceneManager *scnMgr)
 
67
        {
 
68
            if (!mDebugRectangle2d)
 
69
            {
 
70
                mDebugRectangle2d = new DebugRectangle2D();
 
71
                //scnMgr->getRootSceneNode ()->createChildSceneNode ()->attachObject (mDebugRectangle2d);
 
72
            }
 
73
            return mDebugRectangle2d;
 
74
        }
 
75
    #endif //_VISIBILITYDEBUG   
 
76
}//namespace Ogre