void CClientLeafSystem::ProjectFlashlight( ClientLeafShadowHandle_t handle, const VMatrix &worldToShadow ) { // Remove the shadow from any leaves it current exists in RemoveShadowFromLeaves( handle ); RemoveShadowFromRenderables( handle ); Assert( ( m_Shadows[handle].m_Flags & SHADOW_FLAGS_PROJECTED_TEXTURE_TYPE_MASK ) == SHADOW_FLAGS_FLASHLIGHT ); // This will help us to avoid adding the shadow multiple times to a renderable ++m_ShadowEnum; // Use an AABB around the frustum to enumerate leaves. Vector mins, maxs; CalculateAABBFromProjectionMatrix( worldToShadow, &mins, &maxs ); CShadowLeafEnum leafEnum; ISpatialQuery* pQuery = engine->GetBSPTreeQuery(); pQuery->EnumerateLeavesInBox( mins, maxs, &leafEnum, handle ); }
void CClientLeafSystem::InsertIntoTree( ClientRenderHandle_t handle ) { // When we insert into the tree, increase the shadow enumerator // to make sure each shadow is added exactly once to each renderable ++m_ShadowEnum; // NOTE: The render bounds here are relative to the renderable's coordinate system IClientRenderable* pRenderable = m_Renderables[handle].m_pRenderable; Vector absMins, absMaxs; CalcRenderableWorldSpaceAABB_Fast( pRenderable, absMins, absMaxs ); Assert( absMins.IsValid() && absMaxs.IsValid() ); ISpatialQuery* pQuery = engine->GetBSPTreeQuery(); pQuery->EnumerateLeavesInBox( absMins, absMaxs, this, handle ); // Cache off the area it's sitting in. m_Renderables[handle].m_Area = GetRenderableArea( handle ); }
bool CBSPTreeData::EnumerateLeavesInBox( Vector const& mins, Vector const& maxs, ISpatialLeafEnumerator* pEnum, int context ) { return m_pBSPTree->EnumerateLeavesInBox( mins, maxs, pEnum, context ); }
void CBSPTreeData::InsertIntoTree( BSPTreeDataHandle_t handle, Vector const& mins, Vector const& maxs ) { m_pBSPTree->EnumerateLeavesInBox( mins, maxs, this, handle ); }