Skip to content

Commit b0069d3

Browse files
committed
engine: use VectorNormalizeFast() when the return value isn't used
1 parent 4891683 commit b0069d3

14 files changed

+53
-53
lines changed

src/engine/qcommon/q_math.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up )
544544

545545
d = DotProduct( right, forward );
546546
VectorMA( right, -d, forward, right );
547-
VectorNormalize( right );
547+
VectorNormalizeFast( right );
548548
CrossProduct( right, forward, up );
549549
}
550550

@@ -1082,7 +1082,7 @@ void PerpendicularVector( vec3_t dst, const vec3_t src )
10821082
/*
10831083
* * normalize the result
10841084
*/
1085-
VectorNormalize( dst );
1085+
VectorNormalizeFast( dst );
10861086
}
10871087

10881088
// Ridah
@@ -1099,13 +1099,13 @@ void GetPerpendicularViewVector( const vec3_t point, const vec3_t p1, const vec3
10991099
vec3_t v1, v2;
11001100

11011101
VectorSubtract( point, p1, v1 );
1102-
VectorNormalize( v1 );
1102+
VectorNormalizeFast( v1 );
11031103

11041104
VectorSubtract( point, p2, v2 );
1105-
VectorNormalize( v2 );
1105+
VectorNormalizeFast( v2 );
11061106

11071107
CrossProduct( v1, v2, up );
1108-
VectorNormalize( up );
1108+
VectorNormalizeFast( up );
11091109
}
11101110

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

11201120
VectorSubtract( point, vStart, pVec );
11211121
VectorSubtract( vEnd, vStart, vec );
1122-
VectorNormalize( vec );
1122+
VectorNormalizeFast( vec );
11231123
// project onto the directional vector for this segment
11241124
VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
11251125
}
@@ -1255,7 +1255,7 @@ void ProjectPointOntoVectorBounded( const vec3_t point, const vec3_t vStart, con
12551255

12561256
VectorSubtract( point, vStart, pVec );
12571257
VectorSubtract( vEnd, vStart, vec );
1258-
VectorNormalize( vec );
1258+
VectorNormalizeFast( vec );
12591259
// project onto the directional vector for this segment
12601260
VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
12611261

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

26852685
#if 1
26862686
CrossProduct( up, dir, sideN );
2687-
VectorNormalize( sideN );
2687+
VectorNormalizeFast( sideN );
26882688

26892689
CrossProduct( dir, sideN, upN );
2690-
VectorNormalize( upN );
2690+
VectorNormalizeFast( upN );
26912691
#else
26922692
CrossProduct( dir, up, sideN );
2693-
VectorNormalize( sideN );
2693+
VectorNormalizeFast( sideN );
26942694
26952695
CrossProduct( sideN, dir, upN );
2696-
VectorNormalize( upN );
2696+
VectorNormalizeFast( upN );
26972697
#endif
26982698

26992699
VectorNormalize2( dir, dirN );
@@ -2723,10 +2723,10 @@ void MatrixLookAtRH( matrix_t m, const vec3_t eye, const vec3_t dir, const vec3_
27232723
vec3_t sideN;
27242724

27252725
CrossProduct( dir, up, sideN );
2726-
VectorNormalize( sideN );
2726+
VectorNormalizeFast( sideN );
27272727

27282728
CrossProduct( sideN, dir, upN );
2729-
VectorNormalize( upN );
2729+
VectorNormalizeFast( upN );
27302730

27312731
VectorNormalize2( dir, dirN );
27322732

src/engine/renderer/tr_backend.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1608,18 +1608,18 @@ static void RB_SetupLightForShadowing( trRefLight_t *light, int index,
16081608
{
16091609
// original light direction is from surface to light
16101610
VectorInverse( lightDirection );
1611-
VectorNormalize( lightDirection );
1611+
VectorNormalizeFast( lightDirection );
16121612

16131613
VectorCopy( backEnd.viewParms.orientation.origin, viewOrigin );
16141614
VectorCopy( backEnd.viewParms.orientation.axis[ 0 ], viewDirection );
1615-
VectorNormalize( viewDirection );
1615+
VectorNormalizeFast( viewDirection );
16161616

16171617
// calculate new up dir
16181618
CrossProduct( lightDirection, viewDirection, side );
1619-
VectorNormalize( side );
1619+
VectorNormalizeFast( side );
16201620

16211621
CrossProduct( side, lightDirection, up );
1622-
VectorNormalize( up );
1622+
VectorNormalizeFast( up );
16231623

16241624
vectoangles( lightDirection, angles );
16251625
MatrixFromAngles( rotationMatrix, angles[ PITCH ], angles[ YAW ], angles[ ROLL ] );
@@ -2736,7 +2736,7 @@ void RB_RunVisTests( )
27362736
Tess_MapVBOs( false );
27372737
VectorSubtract( backEnd.orientation.viewOrigin,
27382738
test->position, diff );
2739-
VectorNormalize( diff );
2739+
VectorNormalizeFast( diff );
27402740
VectorMA( test->position, test->depthAdjust, diff, center );
27412741

27422742
VectorScale( backEnd.viewParms.orientation.axis[ 1 ],

src/engine/renderer/tr_bsp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5042,7 +5042,7 @@ void RE_LoadWorldMap( const char *name )
50425042
tr.sunDirection[ 1 ] = 0.3f;
50435043
tr.sunDirection[ 2 ] = 0.9f;
50445044

5045-
VectorNormalize( tr.sunDirection );
5045+
VectorNormalizeFast( tr.sunDirection );
50465046

50475047
// set default ambient color
50485048
tr.worldEntity.ambientLight[ 0 ] = r_forceAmbient->value;

src/engine/renderer/tr_curve.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[
559559
// dist-from-midpoint
560560
VectorSubtract( midxyz, gridctrl[ i ][ j ].xyz, midxyz );
561561
VectorSubtract( gridctrl[ i ][ j + 2 ].xyz, gridctrl[ i ][ j ].xyz, direction );
562-
VectorNormalize( direction );
562+
VectorNormalizeFast( direction );
563563

564564
d = DotProduct( midxyz, direction );
565565
VectorScale( direction, d, projected );

src/engine/renderer/tr_flares.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t
206206
if ( normal )
207207
{
208208
VectorSubtract( backEnd.viewParms.orientation.origin, point, local );
209-
VectorNormalize( local );
209+
VectorNormalizeFast( local );
210210
d1 = DotProduct( local, normal );
211211
d1 *= ( 1.0 - distLerp );
212212
d1 += d2;

src/engine/renderer/tr_image.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
11211121
n[ 1 ] = Tex_ByteToFloat( scaledBuffer[ j * 4 + 1 ] );
11221122
n[ 2 ] = Tex_ByteToFloat( scaledBuffer[ j * 4 + 2 ] );
11231123

1124-
VectorNormalize( n );
1124+
VectorNormalizeFast( n );
11251125

11261126
scaledBuffer[ j * 4 + 0 ] = Tex_FloatToByte( n[ 0 ] );
11271127
scaledBuffer[ j * 4 + 1 ] = Tex_FloatToByte( n[ 1 ] );
@@ -2497,7 +2497,7 @@ static void R_CreateRandomNormalsImage()
24972497
angle = 2.0f * M_PI * r; // / 360.0f;
24982498

24992499
VectorSet( n, cosf( angle ), sinf( angle ), r );
2500-
VectorNormalize( n );
2500+
VectorNormalizeFast( n );
25012501

25022502
ptr[ 0 ] = ( byte )( 128 + 127 * n[ 0 ] );
25032503
ptr[ 1 ] = ( byte )( 128 + 127 * n[ 1 ] );

src/engine/renderer/tr_light.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, ve
246246
lightDir[ 1 ] = copysignf( 1.0f - fabsf( X ), Y );
247247
}
248248

249-
VectorNormalize( lightDir );
249+
VectorNormalizeFast( lightDir );
250250

251251
if ( ambientLight[ 0 ] < r_forceAmbient->value &&
252252
ambientLight[ 1 ] < r_forceAmbient->value &&
@@ -335,7 +335,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent, vec3_t
335335
ent->directedLight[ 2 ] = 224.0f / 255.0f;
336336

337337
VectorSet( ent->lightDir, -1, 1, 1.25 );
338-
VectorNormalize( ent->lightDir );
338+
VectorNormalizeFast( ent->lightDir );
339339
}
340340

341341
if ( ( ent->e.renderfx & RF_MINLIGHT ) ) // && VectorLength(ent->ambientLight) <= 0)
@@ -368,7 +368,7 @@ void R_SetupLightOrigin( trRefLight_t *light )
368368
{
369369
MatrixTransformPoint( light->transformMatrix, light->l.center, transformed );
370370
VectorSubtract( transformed, light->l.origin, light->direction );
371-
VectorNormalize( light->direction );
371+
VectorNormalizeFast( light->direction );
372372

373373
VectorMA( light->l.origin, 10000, light->direction, light->origin );
374374
}
@@ -378,7 +378,7 @@ void R_SetupLightOrigin( trRefLight_t *light )
378378

379379
MatrixTransformPoint( light->transformMatrix, down, transformed );
380380
VectorSubtract( transformed, light->l.origin, light->direction );
381-
VectorNormalize( light->direction );
381+
VectorNormalizeFast( light->direction );
382382

383383
VectorMA( light->l.origin, 10000, light->direction, light->origin );
384384

@@ -614,7 +614,7 @@ void R_SetupLightFrustum( trRefLight_t *light )
614614
{
615615
VectorMA( light->l.origin, light->l.radius, axis[ i ], planeOrigin );
616616
VectorNegate( axis[ i ], planeNormal );
617-
VectorNormalize( planeNormal );
617+
VectorNormalizeFast( planeNormal );
618618

619619
VectorCopy( planeNormal, light->frustum[ i ].normal );
620620
light->frustum[ i ].dist = DotProduct( planeOrigin, planeNormal );
@@ -624,7 +624,7 @@ void R_SetupLightFrustum( trRefLight_t *light )
624624
{
625625
VectorMA( light->l.origin, -light->l.radius, axis[ i ], planeOrigin );
626626
VectorCopy( axis[ i ], planeNormal );
627-
VectorNormalize( planeNormal );
627+
VectorNormalizeFast( planeNormal );
628628

629629
VectorCopy( planeNormal, light->frustum[ i + 3 ].normal );
630630
light->frustum[ i + 3 ].dist = DotProduct( planeOrigin, planeNormal );
@@ -714,7 +714,7 @@ void R_SetupLightProjection( trRefLight_t *light )
714714
float uLen = VectorNormalize2( light->l.projUp, up );
715715

716716
CrossProduct( up, right, normal );
717-
VectorNormalize( normal );
717+
VectorNormalizeFast( normal );
718718

719719
vec_t dist = DotProduct( light->l.projTarget, normal );
720720

src/engine/renderer/tr_main.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void R_CalcFaceNormal( vec3_t normal,
6060
VectorSubtract( v1, v0, v );
6161
CrossProduct( u, v, normal );
6262

63-
VectorNormalize( normal );
63+
VectorNormalizeFast( normal );
6464
}
6565

6666

@@ -97,8 +97,8 @@ void R_CalcTangents( vec3_t tangent, vec3_t binormal,
9797
binormal[1] = dtx[0] * dpy[1] - dpx[1] * dty[0];
9898
binormal[2] = dtx[0] * dpy[2] - dpx[2] * dty[0];
9999

100-
VectorNormalize( tangent );
101-
VectorNormalize( binormal );
100+
VectorNormalizeFast( tangent );
101+
VectorNormalizeFast( binormal );
102102
}
103103

104104
void R_CalcTangents( vec3_t tangent, vec3_t binormal,
@@ -138,8 +138,8 @@ void R_CalcTangents( vec3_t tangent, vec3_t binormal,
138138
binormal[1] = dtx[0] * dpy[1] - dpx[1] * dty[0];
139139
binormal[2] = dtx[0] * dpy[2] - dpx[2] * dty[0];
140140

141-
VectorNormalize( tangent );
142-
VectorNormalize( binormal );
141+
VectorNormalizeFast( tangent );
142+
VectorNormalizeFast( binormal );
143143
}
144144

145145

@@ -1660,7 +1660,7 @@ static void R_SetupPortalFrustum( const viewParms_t& oldParms, const orientation
16601660

16611661
for (int i = 0; i < 4; i++)
16621662
{
1663-
VectorNormalize(frustum[i].normal);
1663+
VectorNormalizeFast(frustum[i].normal);
16641664
SetPlaneSignbits(&frustum[i]);
16651665
frustum[i].dist = 0; // all side planes intersect the view origin
16661666
frustum[i].type = PLANE_NON_AXIAL;
@@ -2271,7 +2271,7 @@ void R_TransformShadowLight( trRefLight_t *light ) {
22712271

22722272
light->l.rlType = refLightType_t::RL_PROJ;
22732273
VectorSubtract( mids, light->l.origin, forward );
2274-
VectorNormalize( forward );
2274+
VectorNormalizeFast( forward );
22752275
PerpendicularVector( right, forward );
22762276
CrossProduct( forward, right, up );
22772277

src/engine/renderer/tr_model.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,9 @@ int RE_LerpTagET( orientation_t *tag, const refEntity_t *refent, const char *tag
469469
VectorCopy( tag->axis[ 1 ], tag->axis[ 2 ] );
470470
VectorCopy( tag->axis[ 0 ], tag->axis[ 1 ] );
471471
VectorCopy( tmp, tag->axis[ 0 ] );
472-
VectorNormalize( tag->axis[ 0 ] );
473-
VectorNormalize( tag->axis[ 1 ] );
474-
VectorNormalize( tag->axis[ 2 ] );
472+
VectorNormalizeFast( tag->axis[ 0 ] );
473+
VectorNormalizeFast( tag->axis[ 1 ] );
474+
VectorNormalizeFast( tag->axis[ 2 ] );
475475
return retval;
476476
}
477477
else if ( model->type == modtype_t::MOD_MESH )
@@ -496,9 +496,9 @@ int RE_LerpTagET( orientation_t *tag, const refEntity_t *refent, const char *tag
496496
tag->axis[ 2 ][ i ] = start->axis[ 2 ][ i ] * backLerp + end->axis[ 2 ][ i ] * frontLerp;
497497
}
498498

499-
VectorNormalize( tag->axis[ 0 ] );
500-
VectorNormalize( tag->axis[ 1 ] );
501-
VectorNormalize( tag->axis[ 2 ] );
499+
VectorNormalizeFast( tag->axis[ 0 ] );
500+
VectorNormalizeFast( tag->axis[ 1 ] );
501+
VectorNormalizeFast( tag->axis[ 2 ] );
502502

503503
return retval;
504504
}

src/engine/renderer/tr_model_md3.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ bool R_LoadMD3( model_t *mod, int lod, const void *buffer, const char *modName )
306306

307307
for ( j = 0; j < surf->numVerts; j++ )
308308
{
309-
VectorNormalize( tangents[ j ] );
310-
VectorNormalize( binormals[ j ] );
309+
VectorNormalizeFast( tangents[ j ] );
310+
VectorNormalizeFast( binormals[ j ] );
311311
R_TBNtoQtangents(
312312
tangents[ j ], binormals[ j ],
313313
surf->normals[ f * surf->numVerts + j ].normal,

src/engine/renderer/tr_model_md5.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ static void CalcTangentSpaces( md5Surface_t &surf, const vec2_t *texCoords )
7777
v = surf.verts;
7878
for ( unsigned j = 0; j < surf.numVerts; j++, v++ )
7979
{
80-
VectorNormalize( v->tangent );
80+
VectorNormalizeFast( v->tangent );
8181
v->tangent[ 3 ] = 0;
82-
VectorNormalize( v->binormal );
82+
VectorNormalizeFast( v->binormal );
8383
v->binormal[ 3 ] = 0;
84-
VectorNormalize( v->normal );
84+
VectorNormalizeFast( v->normal );
8585
v->normal[ 3 ] = 0;
8686
}
8787
}

src/engine/renderer/tr_shade_calc.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,12 @@ static void Autosprite2Deform( uint32_t numVertexes )
597597
vec3_t quadCenter;
598598
VectorMA( sides[ 2 ].firstVert, 0.5f, sides[ 2 ].vector, quadCenter );
599599
VectorSubtract( quadCenter, backEnd.viewParms.orientation.origin, forward );
600-
VectorNormalize( forward );
600+
VectorNormalizeFast( forward );
601601
}
602602

603603
vec3_t newMinorAxis;
604604
CrossProduct( sides[ 1 ].vector, forward, newMinorAxis);
605-
VectorNormalize( newMinorAxis );
605+
VectorNormalizeFast( newMinorAxis );
606606
plane_t projection;
607607
VectorNormalize2( sides[ 0 ].vector, projection.normal );
608608
projection.dist = DotProduct( sides[ 0 ].firstVert, projection.normal )
@@ -629,7 +629,7 @@ static void Autosprite2Deform( uint32_t numVertexes )
629629
{
630630
VectorNegate( normal, normal );
631631
}
632-
VectorNormalize( normal );
632+
VectorNormalizeFast( normal );
633633
// What the fuck are tangent and binormal even for?
634634
// I'll just put in zeroes and let R_TBNtoQtangents make some up for me.
635635
R_TBNtoQtangents( vec3_origin, vec3_origin, normal, qtangents );

src/engine/renderer/tr_shader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4099,7 +4099,7 @@ static bool ParseShader( const char *_text )
40994099

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

4102-
VectorNormalize( tr.sunLight );
4102+
VectorNormalizeFast( tr.sunLight );
41034103

41044104
token = COM_ParseExt2( text, false );
41054105

src/engine/renderer/tr_surface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ static void Tess_SurfaceFlare( srfFlare_t *surf )
13711371

13721372
VectorMA( surf->origin, 2.0F, surf->normal, origin );
13731373
VectorSubtract( origin, backEnd.viewParms.orientation.origin, dir );
1374-
VectorNormalize( dir );
1374+
VectorNormalizeFast( dir );
13751375
d = -DotProduct( dir, surf->normal );
13761376
VectorMA( origin, r_ignore->value, dir, origin );
13771377

0 commit comments

Comments
 (0)