Torque3D Documentation / _generateds / sceneTraversalState.cpp

sceneTraversalState.cpp

Engine/source/scene/zones/sceneTraversalState.cpp

More...

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#include "platform/platform.h"
25#include "scene/zones/sceneTraversalState.h"
26
27#include "scene/sceneManager.h"
28#include "scene/culling/sceneCullingState.h"
29#include "scene/culling/sceneCullingVolume.h"
30#include "scene/zones/sceneZoneSpaceManager.h"
31
32
33//-----------------------------------------------------------------------------
34
35SceneTraversalState::SceneTraversalState( SceneCullingState* cullingState )
36   : mCullingState( cullingState ),
37     mTraversedArea( 0.f )
38{
39   VECTOR_SET_ASSOCIATION( mZoneStack );
40   VECTOR_SET_ASSOCIATION( mCullingVolumeStack );
41
42   // Push the polyhedron of the root frustum onto the traversal
43   // stack as the current culling volume.
44
45   pushCullingVolume( cullingState->getRootVolume() );
46}
47
48//-----------------------------------------------------------------------------
49
50SceneZoneSpace* SceneTraversalState::getZoneFromStack( U32 depth )
51{
52   SceneZoneSpaceManager* zoneManager = getCullingState()->getSceneManager()->getZoneManager();
53   U32 zoneId = getZoneIdFromStack( depth );
54
55   return zoneManager->getZoneOwner( zoneId );
56}
57
58//-----------------------------------------------------------------------------
59
60void SceneTraversalState::pushCullingVolume( const SceneCullingVolume& volume )
61{
62   mCullingVolumeStack.push_back( volume );
63}
64
65//-----------------------------------------------------------------------------
66
67void SceneTraversalState::popCullingVolume()
68{
69   AssertFatal( mCullingVolumeStack.size() > 1, "SceneTraversalState::popCullingVolume - Must not pop root volume" );
70   mCullingVolumeStack.pop_back();
71}
72