Skip to content

Commit 72978c5

Browse files
committed
perf: small OcclusionSystem adjustments from CSGO
1 parent 2abe479 commit 72978c5

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/engine/OcclusionSystem.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ void CWingedEdgeList::ResetActiveEdgeList()
437437

438438
// Don't bother with edges below the screen edge
439439
m_flNextDiscontinuity = WingedEdge( 0 ).m_vecPosition.y;
440-
m_flNextDiscontinuity = max( m_flNextDiscontinuity, -1.0f );
440+
m_flNextDiscontinuity = MAX( m_flNextDiscontinuity, -1.0f );
441441

442442
m_StartTerminal.m_pNextActiveEdge = &m_EndTerminal;
443443
m_EndTerminal.m_pPrevActiveEdge = &m_StartTerminal;
@@ -2571,7 +2571,9 @@ void COcclusionSystem::SetView( const Vector &vecCameraPos, float flFOV, const V
25712571
m_NearClipPlane.type = 3;
25722572
m_bEdgeListDirty = true;
25732573
m_flNearPlaneDist = -( DotProduct( vecCameraPos, m_NearClipPlane.normal ) - m_NearClipPlane.dist );
2574-
Assert( m_flNearPlaneDist > 0.0f );
2574+
// Due to FP precision issues this value can sometimes drop slightly below 0.0f
2575+
Assert( m_flNearPlaneDist > 0.125f );
2576+
m_flNearPlaneDist = MAX(m_flNearPlaneDist, 0.0f);
25752577
m_flFOVFactor = m_flNearPlaneDist * tan( flFOV * 0.5f * M_PI / 180.0f );
25762578
m_flFOVFactor = m_flNearPlaneDist / m_flFOVFactor;
25772579
m_flFOVFactor *= m_flFOVFactor;
@@ -2629,20 +2631,20 @@ struct EdgeInfo_t
26292631
// NOTE: The face indices here have to very carefully ordered for the algorithm
26302632
// to work. They must be ordered so that vert0 -> vert1 is clockwise
26312633
// for the first face listed and vert1 -> vert0 is clockwise for the 2nd face listed
2632-
static EdgeInfo_t s_pEdges[12] =
2633-
{
2634-
{ { 0, 1 }, { 2, 4 }, 0, 0 }, // 0: Edge between -y + -z
2635-
{ { 2, 0 }, { 0, 4 }, 0, 0 }, // 1: Edge between -x + -z
2636-
{ { 1, 3 }, { 1, 4 }, 0, 0 }, // 2: Edge between +x + -z
2637-
{ { 3, 2 }, { 3, 4 }, 0, 0 }, // 3: Edge between +y + -z
2638-
{ { 0, 4 }, { 0, 2 }, 0, 0 }, // 4: Edge between -x + -y
2639-
{ { 5, 1 }, { 1, 2 }, 0, 0 }, // 5: Edge between +x + -y
2640-
{ { 6, 2 }, { 0, 3 }, 0, 0 }, // 6: Edge between -x + +y
2641-
{ { 3, 7 }, { 1, 3 }, 0, 0 }, // 7: Edge between +x + +y
2642-
{ { 5, 4 }, { 2, 5 }, 0, 0 }, // 8: Edge between -y + +z
2643-
{ { 4, 6 }, { 0, 5 }, 0, 0 }, // 9: Edge between -x + +z
2644-
{ { 7, 5 }, { 1, 5 }, 0, 0 }, // 10:Edge between +x + +z
2645-
{ { 6, 7 }, { 3, 5 }, 0, 0 }, // 11:Edge between +y + +z
2634+
static EdgeInfo_t s_pEdges[12] =
2635+
{
2636+
{ 0, 1, 2, 4, 0, 0 }, // 0: Edge between -y + -z
2637+
{ 2, 0, 0, 4, 0, 0 }, // 1: Edge between -x + -z
2638+
{ 1, 3, 1, 4, 0, 0 }, // 2: Edge between +x + -z
2639+
{ 3, 2, 3, 4, 0, 0 }, // 3: Edge between +y + -z
2640+
{ 0, 4, 0, 2, 0, 0 }, // 4: Edge between -x + -y
2641+
{ 5, 1, 1, 2, 0, 0 }, // 5: Edge between +x + -y
2642+
{ 6, 2, 0, 3, 0, 0 }, // 6: Edge between -x + +y
2643+
{ 3, 7, 1, 3, 0, 0 }, // 7: Edge between +x + +y
2644+
{ 5, 4, 2, 5, 0, 0 }, // 8: Edge between -y + +z
2645+
{ 4, 6, 0, 5, 0, 0 }, // 9: Edge between -x + +z
2646+
{ 7, 5, 1, 5, 0, 0 }, // 10:Edge between +x + +z
2647+
{ 6, 7, 3, 5, 0, 0 }, // 11:Edge between +y + +z
26462648
};
26472649

26482650
static int s_pFaceEdges[6][4] =

0 commit comments

Comments
 (0)