Skip to content

Commit 697a9f3

Browse files
authored
Merge pull request #248 from nillerusr/mathlib-optimize
Mathlib optimize
2 parents 3b1b08f + 271c999 commit 697a9f3

File tree

11 files changed

+1522
-1775
lines changed

11 files changed

+1522
-1775
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@ waf3*/
3737
.vscode/
3838
.depproj/
3939
source-engine.sln
40-
hl2/
41-

game/server/hl2/ai_behavior_police.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ CAI_PolicingBehavior::CAI_PolicingBehavior( void )
3333
m_bEnabled = false;
3434
m_nNumWarnings = 0;
3535
m_bTargetIsHostile = false;
36+
m_hPoliceGoal = NULL;
3637
}
3738

3839
//-----------------------------------------------------------------------------

materialsystem/imaterialsysteminternal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class CMatCallQueue
3131
{
3232
MEM_ALLOC_CREDIT_( "CMatCallQueue.m_Allocator" );
3333
#ifdef SWDS
34-
m_Allocator.Init( 2*1024, 0, 0, 4 );
34+
m_Allocator.Init( 2*1024, 0, 0, 16 );
3535
#else
36-
m_Allocator.Init( IsX360() ? 2*1024*1024 : 8*1024*1024, 64*1024, 256*1024, 4 );
36+
m_Allocator.Init( IsX360() ? 2*1024*1024 : 8*1024*1024, 64*1024, 256*1024, 16 );
3737
#endif
3838
m_FunctorFactory.SetAllocator( &m_Allocator );
3939
m_pHead = m_pTail = NULL;

mathlib/mathlib_base.cpp

-85
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,6 @@ void MatrixGetColumn( const matrix3x4_t& in, int column, Vector &out )
420420
out.z = in[2][column];
421421
}
422422

423-
void MatrixSetColumn( const Vector &in, int column, matrix3x4_t& out )
424-
{
425-
out[0][column] = in.x;
426-
out[1][column] = in.y;
427-
out[2][column] = in.z;
428-
}
429-
430423
void MatrixScaleBy ( const float flScale, matrix3x4_t &out )
431424
{
432425
out[0][0] *= flScale;
@@ -1092,57 +1085,6 @@ void SetScaleMatrix( float x, float y, float z, matrix3x4_t &dst )
10921085
dst[2][0] = 0.0f; dst[2][1] = 0.0f; dst[2][2] = z; dst[2][3] = 0.0f;
10931086
}
10941087

1095-
1096-
//-----------------------------------------------------------------------------
1097-
// Purpose: Builds the matrix for a counterclockwise rotation about an arbitrary axis.
1098-
//
1099-
// | ax2 + (1 - ax2)cosQ axay(1 - cosQ) - azsinQ azax(1 - cosQ) + aysinQ |
1100-
// Ra(Q) = | axay(1 - cosQ) + azsinQ ay2 + (1 - ay2)cosQ ayaz(1 - cosQ) - axsinQ |
1101-
// | azax(1 - cosQ) - aysinQ ayaz(1 - cosQ) + axsinQ az2 + (1 - az2)cosQ |
1102-
//
1103-
// Input : mat -
1104-
// vAxisOrRot -
1105-
// angle -
1106-
//-----------------------------------------------------------------------------
1107-
void MatrixBuildRotationAboutAxis( const Vector &vAxisOfRot, float angleDegrees, matrix3x4_t &dst )
1108-
{
1109-
float radians;
1110-
float axisXSquared;
1111-
float axisYSquared;
1112-
float axisZSquared;
1113-
float fSin;
1114-
float fCos;
1115-
1116-
radians = angleDegrees * ( M_PI / 180.0 );
1117-
fSin = sin( radians );
1118-
fCos = cos( radians );
1119-
1120-
axisXSquared = vAxisOfRot[0] * vAxisOfRot[0];
1121-
axisYSquared = vAxisOfRot[1] * vAxisOfRot[1];
1122-
axisZSquared = vAxisOfRot[2] * vAxisOfRot[2];
1123-
1124-
// Column 0:
1125-
dst[0][0] = axisXSquared + (1 - axisXSquared) * fCos;
1126-
dst[1][0] = vAxisOfRot[0] * vAxisOfRot[1] * (1 - fCos) + vAxisOfRot[2] * fSin;
1127-
dst[2][0] = vAxisOfRot[2] * vAxisOfRot[0] * (1 - fCos) - vAxisOfRot[1] * fSin;
1128-
1129-
// Column 1:
1130-
dst[0][1] = vAxisOfRot[0] * vAxisOfRot[1] * (1 - fCos) - vAxisOfRot[2] * fSin;
1131-
dst[1][1] = axisYSquared + (1 - axisYSquared) * fCos;
1132-
dst[2][1] = vAxisOfRot[1] * vAxisOfRot[2] * (1 - fCos) + vAxisOfRot[0] * fSin;
1133-
1134-
// Column 2:
1135-
dst[0][2] = vAxisOfRot[2] * vAxisOfRot[0] * (1 - fCos) + vAxisOfRot[1] * fSin;
1136-
dst[1][2] = vAxisOfRot[1] * vAxisOfRot[2] * (1 - fCos) - vAxisOfRot[0] * fSin;
1137-
dst[2][2] = axisZSquared + (1 - axisZSquared) * fCos;
1138-
1139-
// Column 3:
1140-
dst[0][3] = 0;
1141-
dst[1][3] = 0;
1142-
dst[2][3] = 0;
1143-
}
1144-
1145-
11461088
//-----------------------------------------------------------------------------
11471089
// Computes the transpose
11481090
//-----------------------------------------------------------------------------
@@ -1450,33 +1392,6 @@ void VectorYawRotate( const Vector &in, float flYaw, Vector &out)
14501392
out.z = in.z;
14511393
}
14521394

1453-
1454-
1455-
float Bias( float x, float biasAmt )
1456-
{
1457-
// WARNING: not thread safe
1458-
static float lastAmt = -1;
1459-
static float lastExponent = 0;
1460-
if( lastAmt != biasAmt )
1461-
{
1462-
lastExponent = log( biasAmt ) * -1.4427f; // (-1.4427 = 1 / log(0.5))
1463-
}
1464-
float fRet = pow( x, lastExponent );
1465-
Assert ( !IS_NAN( fRet ) );
1466-
return fRet;
1467-
}
1468-
1469-
1470-
float Gain( float x, float biasAmt )
1471-
{
1472-
// WARNING: not thread safe
1473-
if( x < 0.5 )
1474-
return 0.5f * Bias( 2*x, 1-biasAmt );
1475-
else
1476-
return 1 - 0.5f * Bias( 2 - 2*x, 1-biasAmt );
1477-
}
1478-
1479-
14801395
float SmoothCurve( float x )
14811396
{
14821397
// Actual smooth curve. Visualization:

0 commit comments

Comments
 (0)