Skip to content

Commit

Permalink
Makes point and spot lights be correctly culled with zoning like othe…
Browse files Browse the repository at this point in the history
…r objects.
  • Loading branch information
Areloch committed Jun 17, 2016
1 parent ca4e4fe commit dfb8f4f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Engine/source/T3D/lightBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ LightBase::LightBase()
mFlareScale( 1.0f )
{
mNetFlags.set( Ghostable | ScopeAlways );
mTypeMask = EnvironmentObjectType | LightObjectType;
mTypeMask = LightObjectType;

mLight = LightManager::createLightInfo();

Expand Down
3 changes: 2 additions & 1 deletion Engine/source/T3D/objectTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ enum SceneObjectTypeMasks
StaticShapeObjectType |
DynamicShapeObjectType |
EntityObjectType |
ZoneObjectType ), // This improves the result of zone traversals.
ZoneObjectType |
LightObjectType ), // This improves the result of zone traversals.

/// Mask for objects that should be specifically excluded from zone culling.
CULLING_EXCLUDE_TYPEMASK = ( TerrainObjectType |
Expand Down
9 changes: 9 additions & 0 deletions Engine/source/lighting/lightManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ void LightManager::registerGlobalLights( const Frustum *frustum, bool staticLigh
// Cull the lights using the frustum.
getSceneManager()->getContainer()->findObjectList( *frustum, lightMask, &activeLights );

for (U32 i = 0; i < activeLights.size(); ++i)
{
if (!getSceneManager()->mRenderedObjectsList.contains(activeLights[i]))
{
activeLights.erase(i);
--i;
}
}

// Store the culling position for sun placement
// later... see setSpecialLight.
mCullPos = frustum->getPosition();
Expand Down
7 changes: 7 additions & 0 deletions Engine/source/scene/sceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ void SceneManager::_renderScene( SceneRenderState* state, U32 objectMask, SceneZ

PROFILE_END();

//store our rendered objects into a list we can easily look up against later if required
mRenderedObjectsList.clear();
for (U32 i = 0; i < numRenderObjects; ++i)
{
mRenderedObjectsList.push_back(mBatchQueryList[i]);
}

// Render the remaining objects.

PROFILE_START( Scene_renderObjects );
Expand Down
4 changes: 4 additions & 0 deletions Engine/source/scene/sceneManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ class SceneManager
/// If true, render the AABBs of objects for debugging.
static bool smRenderBoundingBoxes;

//A cache list of objects that made it through culling, so we don't have to attempt to re-test
//visibility of objects later.
Vector< SceneObject* > mRenderedObjectsList;

protected:

/// Whether this is the client-side scene.
Expand Down

0 comments on commit dfb8f4f

Please sign in to comment.