ref: use vector initializer macros

This commit is contained in:
Alibek Omarov
2026-05-20 13:13:07 -04:00
committed by a1batross
parent 3e24d5a347
commit 142dc7b87a
14 changed files with 67 additions and 98 deletions

View File

@@ -194,8 +194,7 @@ void R_PushDlightsForBmodel( model_t *model, int framecount, const matrix4x4 obj
if( l->die < gp_cl->time || !l->radius )
continue;
vec3_t oldorigin;
VectorCopy( l->origin, oldorigin );
vec3_t oldorigin = Vec3( l->origin );
Matrix4x4_VectorITransform( object_matrix, oldorigin, l->origin );
R_MarkLights( l, 1 << i, model->nodes + model->hulls[0].firstclipnode, model, framecount );
@@ -341,10 +340,16 @@ start:
if( dm != NULL )
{
vec3_t srcNormal, lightNormal;
float f = (1.0f / 128.0f);
const float f = (1.0f / 128.0f);
vec3_t srcNormal =
{
((float)dm->r - 128.0f) * f,
((float)dm->g - 128.0f) * f,
((float)dm->b - 128.0f) * f,
};
vec3_t lightNormal;
VectorSet( srcNormal, ((float)dm->r - 128.0f) * f, ((float)dm->g - 128.0f) * f, ((float)dm->b - 128.0f) * f );
Matrix3x4_VectorIRotate( tbn, srcNormal, lightNormal ); // turn to world space
VectorScale( lightNormal, (float)scale * -1.0f, lightNormal ); // turn direction from light
VectorAdd( g_trace_lightvec, lightNormal, g_trace_lightvec );
@@ -465,9 +470,7 @@ light from floor
*/
colorVec R_LightPoint( const vec3_t p0 )
{
vec3_t p1;
VectorSet( p1, p0[0], p0[1], p0[2] - 2048.0f );
vec3_t p1 = { p0[0], p0[1], p0[2] - 2048.0f };
return R_LightVec( p0, p1, NULL, NULL );
}
@@ -516,11 +519,10 @@ void R_EntityDynamicLight( cl_entity_t *ent, alight_t *plight, qboolean draw_wor
else
VectorSet( lightDir, 0.0f, 0.0f, -1.0f );
vec3_t origin;
VectorCopy( ent->origin, origin );
vec3_t origin = Vec3( ent->origin );
vec3_t vecSrc, vecEnd;
VectorSet( vecSrc, origin[0], origin[1], origin[2] - lightDir[2] * 8.0f );
vec3_t vecSrc = { origin[0], origin[1], origin[2] - lightDir[2] * 8.0f };
vec3_t vecEnd;
colorVec light;
light.r = light.g = light.b = light.a = 0;
@@ -609,8 +611,7 @@ void R_EntityDynamicLight( cl_entity_t *ent, alight_t *plight, qboolean draw_wor
light.b *= ent->curstate.iuser4 / 10.0f;
}
vec3_t finalLight;
VectorSet( finalLight, light.r, light.g, light.b );
vec3_t finalLight = { light.r, light.g, light.b };
ent->cvFloorColor = light;
float total = Q_max( Q_max( light.r, light.g ), light.b );

View File

@@ -952,8 +952,7 @@ void R_DrawAliasModel( cl_entity_t *e )
R_AliasSetupTimings();
// angles will be modify below keep original
vec3_t angles;
VectorCopy( e->angles, angles );
vec3_t angles = Vec3( e->angles );
R_AliasLerpMovement( e );

View File

@@ -457,8 +457,7 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
{
float s, c;
float fraction = i * div;
vec3_t point;
VectorCopy( source, point );
vec3_t point = Vec3( source );
TriBrightness( 1.0f );
TriTexCoord2f( 1.0f, vLast );
@@ -717,15 +716,14 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
vec3_t center;
VectorAdd( source, delta, center );
vec3_t xaxis;
VectorCopy( delta, xaxis );
vec3_t xaxis = Vec3( delta );
float radius = VectorLength( xaxis );
// cull beamring
// --------------------------------
// Compute box center +/- radius
vec3_t last1, tmp, screen;
VectorSet( last1, radius, radius, scale );
vec3_t last1 = { radius, radius, scale };
vec3_t tmp, screen;
VectorAdd( center, last1, tmp ); // maxs
VectorSubtract( center, last1, screen ); // mins
@@ -738,8 +736,7 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
return;
}
vec3_t yaxis;
VectorSet( yaxis, xaxis[1], -xaxis[0], 0.0f );
vec3_t yaxis = { xaxis[1], -xaxis[0], 0.0f };
VectorNormalize( yaxis );
VectorScale( yaxis, radius, yaxis );

View File

@@ -421,8 +421,6 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
vec3_t testBasis[3];
vec3_t testPosition[2];
float testWorldScale[2];
vec2_t vDecalMin, vDecalMax;
vec2_t vUnionMin, vUnionMax;
R_SetupDecalTextureSpaceBasis( pDecal, surf, texture, testBasis, testWorldScale );
@@ -432,21 +430,21 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
// Here, we project the min and max extents of the decal that got passed in into
// this decal's (pDecal's) [0,0,1,1] clip space, just like we would if we were
// clipping a triangle into pDecal's clip space.
Vector2Set( vDecalMin,
vec2_t vDecalMin = {
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f };
VectorAdd( decalinfo->m_Position, decalExtents[0], testPosition[0] );
VectorAdd( decalinfo->m_Position, decalExtents[1], testPosition[1] );
Vector2Set( vDecalMax,
vec2_t vDecalMax = {
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f };
// Now figure out the part of the projection that intersects pDecal's
// clip box [0,0,1,1].
Vector2Set( vUnionMin, Q_max( vDecalMin[0], 0 ), Q_max( vDecalMin[1], 0 ));
Vector2Set( vUnionMax, Q_min( vDecalMax[0], 1 ), Q_min( vDecalMax[1], 1 ));
vec2_t vUnionMin = { Q_max( vDecalMin[0], 0 ), Q_max( vDecalMin[1], 0 ) };
vec2_t vUnionMax = { Q_min( vDecalMax[0], 1 ), Q_min( vDecalMax[1], 1 ) };
if( vUnionMin[0] < 1 && vUnionMin[1] < 1 && vUnionMax[0] > 0 && vUnionMax[1] > 0 )
{
@@ -593,9 +591,8 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
}
}
vec4_t textureU, textureV;
Vector4Copy( tex->vecs[0], textureU );
Vector4Copy( tex->vecs[1], textureV );
vec4_t textureU = Vec4( tex->vecs[0] );
vec4_t textureV = Vec4( tex->vecs[1] );
// project decal center into the texture space of the surface
float s = DotProduct( decalinfo->m_Position, textureU ) + textureU[3] - surf->texturemins[0];

View File

@@ -1232,8 +1232,7 @@ int CL_FxBlend( cl_entity_t *e )
case kRenderFxHologram:
case kRenderFxDistort:
{
vec3_t tmp;
VectorCopy( e->origin, tmp );
vec3_t tmp = Vec3( e->origin );
VectorSubtract( tmp, RI.rvp.vieworigin, tmp );
float dist = DotProduct( tmp, RI.vforward );

View File

@@ -294,8 +294,7 @@ static void GL_BuildLightmapWater( model_t *mod, msurface_t *fa )
{
for( int i = 0; i < poly->numverts; i++ )
{
vec3_t vec;
VectorCopy( poly->verts[i], vec );
vec3_t vec = Vec3( poly->verts[i] );
R_LightmapCoord( vec, fa, sample_size, &poly->verts[i][5] );
}
}
@@ -3735,7 +3734,6 @@ void R_MarkLeaves( void )
qboolean novis = false;
qboolean force = false;
mleaf_t *leaf = NULL;
vec3_t test;
if( !FBitSet( RI.rvp.flags, RF_DRAW_WORLD ))
return;
@@ -3748,7 +3746,7 @@ void R_MarkLeaves( void )
RI.viewleaf = NULL;
}
VectorCopy( RI.rvp.vieworigin, test );
vec3_t test = Vec3( RI.rvp.vieworigin );
if( RI.viewleaf != NULL )
{

View File

@@ -369,9 +369,9 @@ void R_DrawSpriteModel( cl_entity_t *e )
model_t *model = e->model;
msprite_t *psprite = (msprite_t *)model->cache.data;
vec3_t origin, color, color2 = { 0.0f };
vec3_t color, color2 = { 0.0f };
vec3_t v_right, v_up;
VectorCopy( e->origin, origin ); // set render origin
vec3_t origin = Vec3( e->origin ); // set render origin
// do movewith
if( e->curstate.aiment > 0 && e->curstate.movetype == MOVETYPE_FOLLOW )

View File

@@ -526,10 +526,8 @@ StudioSetUpTransform
*/
static void R_StudioSetUpTransform( cl_entity_t *e )
{
vec3_t origin, angles;
VectorCopy( e->origin, origin );
VectorCopy( e->angles, angles );
vec3_t origin = Vec3( e->origin );
vec3_t angles = Vec3( e->angles );
// interpolate monsters position (moved into UpdateEntityFields by user request)
if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( gp_host->features, ENGINE_COMPUTE_STUDIO_LERP ))
@@ -1384,8 +1382,7 @@ static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal,
return;
}
vec3_t finalLight;
VectorSet( finalLight, 0, 0, 0 );
vec3_t finalLight = { 0, 0, 0 };
for( int i = 0; i < g_studio.numlocallights; i++ )
{
@@ -2972,10 +2969,8 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( pplayer->gaitsequence )
{
vec3_t orig_angles;
m_pPlayerInfo = pfnPlayerInfo( m_nPlayerIndex );
VectorCopy( RI.currententity->angles, orig_angles );
vec3_t orig_angles = Vec3( RI.currententity->angles );
R_StudioProcessGait( pplayer );
@@ -3269,8 +3264,6 @@ R_RunViewmodelEvents
*/
void R_RunViewmodelEvents( void )
{
vec3_t simorg;
if( r_drawviewmodel->value == 0 )
return;
@@ -3288,7 +3281,7 @@ void R_RunViewmodelEvents( void )
R_StudioSetupTimings();
VectorCopy( gp_cl->simorg, simorg );
vec3_t simorg = Vec3( gp_cl->simorg );
for( int i = 0; i < 4; i++ )
VectorCopy( simorg, RI.currententity->attachment[i] );
RI.currentmodel = RI.currententity->model;

View File

@@ -407,8 +407,6 @@ Draw beamdisk
*/
static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float freq, float speed, int segments )
{
vec3_t point;
if( segments < 2 )
return;
@@ -435,7 +433,7 @@ static void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, f
float s, c;
float fraction = i * div;
VectorCopy( source, point );
vec3_t point = Vec3( source );
TriBrightness( 1.0f );
TriTexCoord2f( 1.0f, vLast );
@@ -679,13 +677,13 @@ Draw beamring
*/
static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, float freq, float speed, int segments )
{
vec3_t last1, last2, point, screen, screenLast;
vec3_t tmp, normal, center, xaxis, yaxis;
vec3_t last2, point, screen;
vec3_t screenLast = { 0 };
vec3_t tmp, normal, center;
if( segments < 2 )
return;
VectorClear( screenLast );
segments = segments * M_PI;
if( segments > NOISE_DIVISIONS * 8 )
@@ -710,13 +708,13 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
VectorScale( delta, 0.5f, delta );
VectorAdd( source, delta, center );
VectorCopy( delta, xaxis );
vec3_t xaxis = Vec3( delta );
float radius = VectorLength( xaxis );
// cull beamring
// --------------------------------
// Compute box center +/- radius
VectorSet( last1, radius, radius, scale );
vec3_t last1 = { radius, radius, scale };
VectorAdd( center, last1, tmp ); // maxs
VectorSubtract( center, last1, screen ); // mins
@@ -729,7 +727,7 @@ static void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitud
return;
}
VectorSet( yaxis, xaxis[1], -xaxis[0], 0.0f );
vec3_t yaxis = { xaxis[1], -xaxis[0], 0.0f };
VectorNormalize( yaxis );
VectorScale( yaxis, radius, yaxis );

View File

@@ -77,9 +77,8 @@ R_EntityRotate
*/
static void R_EntityRotate( vec3_t vec )
{
vec3_t tvec;
vec3_t tvec = Vec3( vec );
VectorCopy( vec, tvec );
vec[0] = DotProduct( entity_rotation[0], tvec );
vec[1] = DotProduct( entity_rotation[1], tvec );
vec[2] = DotProduct( entity_rotation[2], tvec );

View File

@@ -428,8 +428,6 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
vec3_t testBasis[3];
vec3_t testPosition[2];
float testWorldScale[2];
vec2_t vDecalMin, vDecalMax;
vec2_t vUnionMin, vUnionMax;
R_SetupDecalTextureSpaceBasis( pDecal, surf, texture, testBasis, testWorldScale );
@@ -439,21 +437,21 @@ static decal_t *R_DecalIntersect( decalinfo_t *decalinfo, msurface_t *surf, int
// Here, we project the min and max extents of the decal that got passed in into
// this decal's (pDecal's) [0,0,1,1] clip space, just like we would if we were
// clipping a triangle into pDecal's clip space.
Vector2Set( vDecalMin,
vec2_t vDecalMin = {
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f };
VectorAdd( decalinfo->m_Position, decalExtents[0], testPosition[0] );
VectorAdd( decalinfo->m_Position, decalExtents[1], testPosition[1] );
Vector2Set( vDecalMax,
vec2_t vDecalMax = {
DotProduct( testPosition[0], testBasis[0] ) - pDecal->dx + 0.5f,
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f );
DotProduct( testPosition[1], testBasis[1] ) - pDecal->dy + 0.5f };
// Now figure out the part of the projection that intersects pDecal's
// clip box [0,0,1,1].
Vector2Set( vUnionMin, Q_max( vDecalMin[0], 0 ), Q_max( vDecalMin[1], 0 ));
Vector2Set( vUnionMax, Q_min( vDecalMax[0], 1 ), Q_min( vDecalMax[1], 1 ));
vec2_t vUnionMin = { Q_max( vDecalMin[0], 0 ), Q_max( vDecalMin[1], 0 ) };
vec2_t vUnionMax = { Q_min( vDecalMax[0], 1 ), Q_min( vDecalMax[1], 1 ) };
if( vUnionMin[0] < 1 && vUnionMin[1] < 1 && vUnionMax[0] > 0 && vUnionMax[1] > 0 )
{
@@ -594,7 +592,6 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
// get the texture associated with this surface
mtexinfo_t *tex = surf->texinfo;
decal_t *decal = surf->pdecals;
vec4_t textureU, textureV;
connstate_t state = ENGINE_GET_PARM( PARM_CONNSTATE );
// we in restore mode
@@ -610,8 +607,8 @@ static void R_DecalSurface( msurface_t *surf, decalinfo_t *decalinfo )
}
}
Vector4Copy( tex->vecs[0], textureU );
Vector4Copy( tex->vecs[1], textureV );
vec4_t textureU = Vec4( tex->vecs[0] );
vec4_t textureV = Vec4( tex->vecs[1] );
// project decal center into the texture space of the surface
float s = DotProduct( decalinfo->m_Position, textureU ) + textureU[3] - surf->texturemins[0];

View File

@@ -771,11 +771,10 @@ R_DrawBEntitiesOnList
*/
static void R_DrawBEntitiesOnList( void )
{
vec3_t oldorigin;
vec3_t mins, maxs;
float minmaxs[6];
VectorCopy( tr.modelorg, oldorigin );
vec3_t oldorigin = Vec3( tr.modelorg );
insubmodel = true;
for( int i = 0; i < tr.draw_list->num_edge_entities && !FBitSet( RI.rvp.flags, RF_ONLY_CLIENTDRAW ); i++ )
@@ -852,7 +851,6 @@ R_DrawBEntitiesOnList
*/
void R_DrawBrushModel( cl_entity_t *pent )
{
vec3_t oldorigin;
vec3_t mins, maxs;
float minmaxs[6];
edge_t ledges[NUMSTACKEDGES
@@ -887,7 +885,7 @@ void R_DrawBrushModel( cl_entity_t *pent )
R_BeginEdgeFrame();
VectorCopy( tr.modelorg, oldorigin );
vec3_t oldorigin = Vec3( tr.modelorg );
insubmodel = true;
if( !RI.currentmodel )
@@ -1399,7 +1397,6 @@ int CL_FxBlend( cl_entity_t *e )
{
int blend = 0;
float dist;
vec3_t tmp;
float offset = ((int)e->index ) * 363.0f; // Use ent index to de-sync these fx
@@ -1482,7 +1479,8 @@ int CL_FxBlend( cl_entity_t *e )
break;
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
{
vec3_t tmp = Vec3( e->origin );
VectorSubtract( tmp, RI.rvp.vieworigin, tmp );
dist = DotProduct( tmp, RI.vforward );
@@ -1504,6 +1502,7 @@ int CL_FxBlend( cl_entity_t *e )
blend += gEngfuncs.COM_RandomLong( -32, 31 );
}
break;
}
default:
blend = e->curstate.renderamt;
break;

View File

@@ -521,10 +521,8 @@ StudioSetUpTransform
*/
static void R_StudioSetUpTransform( cl_entity_t *e )
{
vec3_t origin, angles;
VectorCopy( e->origin, origin );
VectorCopy( e->angles, angles );
vec3_t origin = Vec3( e->origin );
vec3_t angles = Vec3( e->angles );
// interpolate monsters position (moved into UpdateEntityFields by user request)
if( e->curstate.movetype == MOVETYPE_STEP && !FBitSet( gp_host->features, ENGINE_COMPUTE_STUDIO_LERP ))
@@ -1451,15 +1449,13 @@ R_LightLambert
*/
static void R_LightLambert( vec4_t light[MAX_LOCALLIGHTS], const vec3_t normal, const vec3_t color, byte *out )
{
vec3_t finalLight;
if( !g_studio.numlocallights )
{
VectorScale( color, 255.0f, out );
return;
}
VectorSet( finalLight, 0, 0, 0 );
vec3_t finalLight = { 0, 0, 0 };
for( int i = 0; i < g_studio.numlocallights; i++ )
{
@@ -2594,10 +2590,8 @@ static int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
if( pplayer->gaitsequence )
{
vec3_t orig_angles;
m_pPlayerInfo = pfnPlayerInfo( m_nPlayerIndex );
VectorCopy( RI.currententity->angles, orig_angles );
vec3_t orig_angles = Vec3( RI.currententity->angles );
R_StudioProcessGait( pplayer );
@@ -2902,7 +2896,6 @@ R_RunViewmodelEvents
void R_RunViewmodelEvents( void )
{
int i;
vec3_t simorg;
if( r_drawviewmodel->value == 0 )
return;
@@ -2921,7 +2914,7 @@ void R_RunViewmodelEvents( void )
R_StudioSetupTimings();
VectorCopy( gp_cl->simorg, simorg );
vec3_t simorg = Vec3( gp_cl->simorg );
for( i = 0; i < 4; i++ )
VectorCopy( simorg, RI.currententity->attachment[i] );
RI.currentmodel = RI.currententity->model;

View File

@@ -918,7 +918,6 @@ static void R_DrawSurfaceDecals( void )
for( decal_t *p = fa->pdecals; p; p = p->pnext )
{
pixel_t *dest, *source;
vec4_t textureU, textureV;
image_t *tex = R_GetTexture( p->texture );
int s1 = 0, t1 = 0, s2 = tex->width, t2 = tex->height;
unsigned int height;
@@ -929,8 +928,8 @@ static void R_DrawSurfaceDecals( void )
int x, y, u, v, sv, w, h;
vec3_t basis[3];
Vector4Copy( fa->texinfo->vecs[0], textureU );
Vector4Copy( fa->texinfo->vecs[1], textureV );
vec4_t textureU = Vec4( fa->texinfo->vecs[0] );
vec4_t textureV = Vec4( fa->texinfo->vecs[1] );
R_DecalComputeBasis( fa, 0, basis );