Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/engine/qcommon/q_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up )

d = DotProduct( right, forward );
VectorMA( right, -d, forward, right );
VectorNormalize( right );
VectorNormalizeFast( right );
CrossProduct( right, forward, up );
}

Expand Down Expand Up @@ -1082,7 +1082,7 @@ void PerpendicularVector( vec3_t dst, const vec3_t src )
/*
* * normalize the result
*/
VectorNormalize( dst );
VectorNormalizeFast( dst );
}

// Ridah
Expand All @@ -1099,13 +1099,13 @@ void GetPerpendicularViewVector( const vec3_t point, const vec3_t p1, const vec3
vec3_t v1, v2;

VectorSubtract( point, p1, v1 );
VectorNormalize( v1 );
VectorNormalizeFast( v1 );

VectorSubtract( point, p2, v2 );
VectorNormalize( v2 );
VectorNormalizeFast( v2 );

CrossProduct( v1, v2, up );
VectorNormalize( up );
VectorNormalizeFast( up );
}

/*
Expand All @@ -1119,7 +1119,7 @@ void ProjectPointOntoVector( const vec3_t point, const vec3_t vStart, const vec3

VectorSubtract( point, vStart, pVec );
VectorSubtract( vEnd, vStart, vec );
VectorNormalize( vec );
VectorNormalizeFast( vec );
// project onto the directional vector for this segment
VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
}
Expand Down Expand Up @@ -1255,7 +1255,7 @@ void ProjectPointOntoVectorBounded( const vec3_t point, const vec3_t vStart, con

VectorSubtract( point, vStart, pVec );
VectorSubtract( vEnd, vStart, vec );
VectorNormalize( vec );
VectorNormalizeFast( vec );
// project onto the directional vector for this segment
VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );

Expand Down Expand Up @@ -2684,16 +2684,16 @@ void MatrixLookAtLH( matrix_t m, const vec3_t eye, const vec3_t dir, const vec3_

#if 1
CrossProduct( up, dir, sideN );
VectorNormalize( sideN );
VectorNormalizeFast( sideN );

CrossProduct( dir, sideN, upN );
VectorNormalize( upN );
VectorNormalizeFast( upN );
#else
CrossProduct( dir, up, sideN );
VectorNormalize( sideN );
VectorNormalizeFast( sideN );

CrossProduct( sideN, dir, upN );
VectorNormalize( upN );
VectorNormalizeFast( upN );
#endif

VectorNormalize2( dir, dirN );
Expand Down Expand Up @@ -2723,10 +2723,10 @@ void MatrixLookAtRH( matrix_t m, const vec3_t eye, const vec3_t dir, const vec3_
vec3_t sideN;

CrossProduct( dir, up, sideN );
VectorNormalize( sideN );
VectorNormalizeFast( sideN );

CrossProduct( sideN, dir, upN );
VectorNormalize( upN );
VectorNormalizeFast( upN );

VectorNormalize2( dir, dirN );

Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ void RB_RunVisTests( )
Tess_MapVBOs( false );
VectorSubtract( backEnd.orientation.viewOrigin,
test->position, diff );
VectorNormalize( diff );
VectorNormalizeFast( diff );
VectorMA( test->position, test->depthAdjust, diff, center );

VectorScale( backEnd.viewParms.orientation.axis[ 1 ],
Expand Down
4 changes: 2 additions & 2 deletions src/engine/renderer/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ void ValidateVertex( srfVert_t* vertex, int vertexID, shader_t* shader ) {
VertexToString( vertex ), shader->name );
vertex->normal[i] = 0.0f;

VectorNormalize( vertex->normal );
VectorNormalizeFast( vertex->normal );
}
}

Expand Down Expand Up @@ -4667,7 +4667,7 @@ void RE_LoadWorldMap( const char *name )
tr.sunDirection[ 1 ] = 0.3f;
tr.sunDirection[ 2 ] = 0.9f;

VectorNormalize( tr.sunDirection );
VectorNormalizeFast( tr.sunDirection );

tr.worldMapLoaded = true;

Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[
// dist-from-midpoint
VectorSubtract( midxyz, gridctrl[ i ][ j ].xyz, midxyz );
VectorSubtract( gridctrl[ i ][ j + 2 ].xyz, gridctrl[ i ][ j ].xyz, direction );
VectorNormalize( direction );
VectorNormalizeFast( direction );

d = DotProduct( midxyz, direction );
VectorScale( direction, d, projected );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
n[ 1 ] = Tex_ByteToFloat( scaledBuffer[ j * 4 + 1 ] );
n[ 2 ] = Tex_ByteToFloat( scaledBuffer[ j * 4 + 2 ] );

VectorNormalize( n );
VectorNormalizeFast( n );

scaledBuffer[ j * 4 + 0 ] = Tex_FloatToByte( n[ 0 ] );
scaledBuffer[ j * 4 + 1 ] = Tex_FloatToByte( n[ 1 ] );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, ve
lightDir[ 1 ] = copysignf( 1.0f - fabsf( X ), Y );
}

VectorNormalize( lightDir );
VectorNormalizeFast( lightDir );

if ( ambientLight[ 0 ] < r_forceAmbient.Get() &&
ambientLight[ 1 ] < r_forceAmbient.Get() &&
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ static void R_SetupPortalFrustum( const viewParms_t& oldParms, const orientation

for (int i = 0; i < 4; i++)
{
VectorNormalize(frustum[i].normal);
VectorNormalizeFast(frustum[i].normal);
SetPlaneSignbits(&frustum[i]);
frustum[i].dist = 0; // all side planes intersect the view origin
frustum[i].type = PLANE_NON_AXIAL;
Expand Down
12 changes: 6 additions & 6 deletions src/engine/renderer/tr_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ int RE_LerpTagET( orientation_t *tag, const refEntity_t *refent, const char *tag
VectorCopy( tag->axis[ 1 ], tag->axis[ 2 ] );
VectorCopy( tag->axis[ 0 ], tag->axis[ 1 ] );
VectorCopy( tmp, tag->axis[ 0 ] );
VectorNormalize( tag->axis[ 0 ] );
VectorNormalize( tag->axis[ 1 ] );
VectorNormalize( tag->axis[ 2 ] );
VectorNormalizeFast( tag->axis[ 0 ] );
VectorNormalizeFast( tag->axis[ 1 ] );
VectorNormalizeFast( tag->axis[ 2 ] );
return retval;
}
else if ( model->type == modtype_t::MOD_MESH )
Expand All @@ -497,9 +497,9 @@ int RE_LerpTagET( orientation_t *tag, const refEntity_t *refent, const char *tag
tag->axis[ 2 ][ i ] = start->axis[ 2 ][ i ] * backLerp + end->axis[ 2 ][ i ] * frontLerp;
}

VectorNormalize( tag->axis[ 0 ] );
VectorNormalize( tag->axis[ 1 ] );
VectorNormalize( tag->axis[ 2 ] );
VectorNormalizeFast( tag->axis[ 0 ] );
VectorNormalizeFast( tag->axis[ 1 ] );
VectorNormalizeFast( tag->axis[ 2 ] );

return retval;
}
Expand Down
4 changes: 2 additions & 2 deletions src/engine/renderer/tr_model_md3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ bool R_LoadMD3( model_t *mod, int lod, const void *buffer, const char *modName )

for ( j = 0; j < surf->numVerts; j++ )
{
VectorNormalize( tangents[ j ] );
VectorNormalize( binormals[ j ] );
VectorNormalizeFast( tangents[ j ] );
VectorNormalizeFast( binormals[ j ] );
R_TBNtoQtangents(
tangents[ j ], binormals[ j ],
surf->normals[ f * surf->numVerts + j ].normal,
Expand Down
6 changes: 3 additions & 3 deletions src/engine/renderer/tr_model_md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ static void CalcTangentSpaces( md5Surface_t &surf, const vec2_t *texCoords )
v = surf.verts;
for ( unsigned j = 0; j < surf.numVerts; j++, v++ )
{
VectorNormalize( v->tangent );
VectorNormalizeFast( v->tangent );
v->tangent[ 3 ] = 0;
VectorNormalize( v->binormal );
VectorNormalizeFast( v->binormal );
v->binormal[ 3 ] = 0;
VectorNormalize( v->normal );
VectorNormalizeFast( v->normal );
v->normal[ 3 ] = 0;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/engine/renderer/tr_shade_calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,12 @@ static void Autosprite2Deform( uint32_t numVertexes )
vec3_t quadCenter;
VectorMA( sides[ 2 ].firstVert, 0.5f, sides[ 2 ].vector, quadCenter );
VectorSubtract( quadCenter, backEnd.viewParms.orientation.origin, forward );
VectorNormalize( forward );
VectorNormalizeFast( forward );
}

vec3_t newMinorAxis;
CrossProduct( sides[ 1 ].vector, forward, newMinorAxis);
VectorNormalize( newMinorAxis );
VectorNormalizeFast( newMinorAxis );
plane_t projection;
VectorNormalize2( sides[ 0 ].vector, projection.normal );
projection.dist = DotProduct( sides[ 0 ].firstVert, projection.normal )
Expand All @@ -628,7 +628,7 @@ static void Autosprite2Deform( uint32_t numVertexes )
{
VectorNegate( normal, normal );
}
VectorNormalize( normal );
VectorNormalizeFast( normal );
// What the fuck are tangent and binormal even for?
// I'll just put in zeroes and let R_TBNtoQtangents make some up for me.
R_TBNtoQtangents( vec3_origin, vec3_origin, normal, qtangents );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4084,7 +4084,7 @@ static bool ParseShader( const char *_text )

tr.sunLight[ 2 ] = atof( token );

VectorNormalize( tr.sunLight );
VectorNormalizeFast( tr.sunLight );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any point to using the fast version for something that's done very infrequently and only at loading time.


token = COM_ParseExt2( text, false );

Expand Down