Skip to content

Commit

Permalink
optimizations
Browse files Browse the repository at this point in the history
optimized job threads
fixed some studio render call inefficiencies
fixed math bugs
default borderless windowed
optimized world list building
  • Loading branch information
mastercoms committed Aug 29, 2020
1 parent 7c30a1e commit cb0fc6a
Show file tree
Hide file tree
Showing 30 changed files with 4,464 additions and 4,248 deletions.
34 changes: 18 additions & 16 deletions engine/OcclusionSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ void CWingedEdgeList::ResetActiveEdgeList()

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

m_StartTerminal.m_pNextActiveEdge = &m_EndTerminal;
m_EndTerminal.m_pPrevActiveEdge = &m_StartTerminal;
Expand Down Expand Up @@ -2571,7 +2571,9 @@ void COcclusionSystem::SetView( const Vector &vecCameraPos, float flFOV, const V
m_NearClipPlane.type = 3;
m_bEdgeListDirty = true;
m_flNearPlaneDist = -( DotProduct( vecCameraPos, m_NearClipPlane.normal ) - m_NearClipPlane.dist );
Assert( m_flNearPlaneDist > 0.0f );
// Due to FP precision issues this value can sometimes drop slightly below 0.0f
Assert( m_flNearPlaneDist > 0.125f );
m_flNearPlaneDist = MAX(m_flNearPlaneDist, 0.0f);
m_flFOVFactor = m_flNearPlaneDist * tan( flFOV * 0.5f * M_PI / 180.0f );
m_flFOVFactor = m_flNearPlaneDist / m_flFOVFactor;
m_flFOVFactor *= m_flFOVFactor;
Expand Down Expand Up @@ -2629,20 +2631,20 @@ struct EdgeInfo_t
// NOTE: The face indices here have to very carefully ordered for the algorithm
// to work. They must be ordered so that vert0 -> vert1 is clockwise
// for the first face listed and vert1 -> vert0 is clockwise for the 2nd face listed
static EdgeInfo_t s_pEdges[12] =
{
{ { 0, 1 }, { 2, 4 }, 0, 0 }, // 0: Edge between -y + -z
{ { 2, 0 }, { 0, 4 }, 0, 0 }, // 1: Edge between -x + -z
{ { 1, 3 }, { 1, 4 }, 0, 0 }, // 2: Edge between +x + -z
{ { 3, 2 }, { 3, 4 }, 0, 0 }, // 3: Edge between +y + -z
{ { 0, 4 }, { 0, 2 }, 0, 0 }, // 4: Edge between -x + -y
{ { 5, 1 }, { 1, 2 }, 0, 0 }, // 5: Edge between +x + -y
{ { 6, 2 }, { 0, 3 }, 0, 0 }, // 6: Edge between -x + +y
{ { 3, 7 }, { 1, 3 }, 0, 0 }, // 7: Edge between +x + +y
{ { 5, 4 }, { 2, 5 }, 0, 0 }, // 8: Edge between -y + +z
{ { 4, 6 }, { 0, 5 }, 0, 0 }, // 9: Edge between -x + +z
{ { 7, 5 }, { 1, 5 }, 0, 0 }, // 10:Edge between +x + +z
{ { 6, 7 }, { 3, 5 }, 0, 0 }, // 11:Edge between +y + +z
static EdgeInfo_t s_pEdges[12] =
{
{ 0, 1, 2, 4, 0, 0 }, // 0: Edge between -y + -z
{ 2, 0, 0, 4, 0, 0 }, // 1: Edge between -x + -z
{ 1, 3, 1, 4, 0, 0 }, // 2: Edge between +x + -z
{ 3, 2, 3, 4, 0, 0 }, // 3: Edge between +y + -z
{ 0, 4, 0, 2, 0, 0 }, // 4: Edge between -x + -y
{ 5, 1, 1, 2, 0, 0 }, // 5: Edge between +x + -y
{ 6, 2, 0, 3, 0, 0 }, // 6: Edge between -x + +y
{ 3, 7, 1, 3, 0, 0 }, // 7: Edge between +x + +y
{ 5, 4, 2, 5, 0, 0 }, // 8: Edge between -y + +z
{ 4, 6, 0, 5, 0, 0 }, // 9: Edge between -x + +z
{ 7, 5, 1, 5, 0, 0 }, // 10:Edge between +x + +z
{ 6, 7, 3, 5, 0, 0 }, // 11:Edge between +y + +z
};

static int s_pFaceEdges[6][4] =
Expand Down
7 changes: 1 addition & 6 deletions engine/audio/private/snd_dma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6572,17 +6572,12 @@ void S_Update_Thread()

// try to maintain a steadier rate by compensating for fluctuating mix times
// leave 1 ms for tighter timings in loop
const int nSleepMS = (int) ((THREADED_MIX_TIME - dt) * 1000 - 1);
const int nSleepMS = (int) ((THREADED_MIX_TIME - dt) * 1000);
if ( nSleepMS > 0 )
{
ThreadSleep( nSleepMS );
}

while (Plat_FloatTime() < fWaitEnd)
{
ThreadSleep();
}

// mimic a frametime needed for sound update
const double t1 = Plat_FloatTime();
frameTime = t1 - tf;
Expand Down
5 changes: 4 additions & 1 deletion engine/baseclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,10 @@ void CBaseClient::Disconnect( const char *fmt, ... )
if ( m_NetChannel )
{
m_NetChannel->Shutdown( string ) ;
m_NetChannel = NULL;
if (m_NetChannel)
{
m_NetChannel = NULL;
}
}

Clear(); // clear state
Expand Down

0 comments on commit cb0fc6a

Please sign in to comment.