engine: use vector initializer macros

This commit is contained in:
Alibek Omarov
2026-05-20 13:09:08 -04:00
committed by a1batross
parent 64b1b54f5b
commit 3e24d5a347
15 changed files with 55 additions and 93 deletions

View File

@@ -1063,8 +1063,7 @@ void GAME_EXPORT R_EntityParticles( cl_entity_t *ent )
angle = cl.time * cl_avelocities[i][2];
SinCos( angle, &sr, &cr );
vec3_t forward;
VectorSet( forward, cp * cy, cp * sy, -sp );
vec3_t forward = { cp * cy, cp * sy, -sp };
p->die = cl.time + 0.001f;
p->color = 111; // yellow
@@ -1688,12 +1687,12 @@ R_ShowLine
*/
void GAME_EXPORT R_ShowLine( const vec3_t start, const vec3_t end )
{
vec3_t dir, org;
vec3_t dir;
VectorSubtract( end, start, dir );
float len = VectorNormalizeLength( dir );
VectorScale( dir, 5.0f, dir );
VectorCopy( start, org );
vec3_t org = Vec3( start );
while( len > 0 )
{

View File

@@ -632,7 +632,6 @@ static void CL_CreateCmd( void )
{
usercmd_t nullcmd = { 0 }, *cmd;
runcmd_t *pcmd;
vec3_t angles;
int input_override;
int ms;
@@ -640,7 +639,7 @@ static void CL_CreateCmd( void )
return;
// store viewangles in case it's will be freeze
VectorCopy( cl.viewangles, angles );
vec3_t angles = Vec3( cl.viewangles );
input_override = 0;
// fix rounding error and framerate depending player move

View File

@@ -159,12 +159,12 @@ void SCR_DrawEnts( void )
{
const cl_entity_t *ent = &clgame.entities[i];
string msg;
vec3_t screen, pos;
vec3_t screen;
if( ent->curstate.messagenum != cl.parsecount )
continue;
VectorCopy( ent->origin, pos );
vec3_t pos = Vec3( ent->origin );
if( ent->model != NULL )
{

View File

@@ -565,14 +565,14 @@ void GAME_EXPORT R_FizzEffect( cl_entity_t *ent, int modelIndex, int density )
{
const float base_time = cl.time - 0.1f;
model_t *mod = CL_ModelHandle( modelIndex );
vec3_t volume, mins, maxs;
vec3_t volume;
vec2_t speed;
if( !ent || !ent->model || !modelIndex || !mod )
return;
VectorCopy( ent->model->mins, mins );
VectorCopy( ent->model->maxs, maxs );
vec3_t mins = Vec3( ent->model->mins );
vec3_t maxs = Vec3( ent->model->maxs );
if( ent->angles[1] != 0.0f )
{
@@ -588,9 +588,8 @@ void GAME_EXPORT R_FizzEffect( cl_entity_t *ent, int modelIndex, int density )
for( int i = 0; i <= density; i++ )
{
TEMPENTITY *tent;
vec3_t origin;
vec3_t origin = Vec3( mins );
VectorCopy( mins, origin );
origin[0] += COM_RandomLong( 0, (int)volume[0] - 1 );
origin[1] += COM_RandomLong( 0, (int)volume[1] - 1 );
@@ -708,7 +707,6 @@ Attaches entity to player
void GAME_EXPORT R_AttachTentToPlayer( int client, int modelIndex, float zoffset, float life )
{
TEMPENTITY *pTemp;
vec3_t position;
cl_entity_t *pClient;
model_t *pModel;
@@ -723,7 +721,7 @@ void GAME_EXPORT R_AttachTentToPlayer( int client, int modelIndex, float zoffset
if(( pModel = CL_ModelHandle( modelIndex )) == NULL )
return;
VectorCopy( pClient->origin, position );
vec3_t position = Vec3( pClient->origin );
position[2] += zoffset;
pTemp = CL_TempEntAllocHigh( position, pModel );
@@ -875,7 +873,6 @@ void GAME_EXPORT R_BloodSprite( const vec3_t org, int colorIndex, int modelIndex
{
model_t *pModel, *pModel2;
TEMPENTITY *pTemp;
vec3_t pos;
colorIndex += COM_RandomLong( 1, 3 );
int impactindex = colorIndex;
@@ -884,7 +881,7 @@ void GAME_EXPORT R_BloodSprite( const vec3_t org, int colorIndex, int modelIndex
// validate the model first
if(( pModel = CL_ModelHandle( modelIndex )) != NULL )
{
VectorCopy( org, pos );
vec3_t pos = Vec3( org );
pos[2] += COM_RandomFloat( 2.0f, 4.0f ); // make offset from ground (snarks issues)
// large, single blood sprite is a high-priority tent
@@ -1635,7 +1632,6 @@ void GAME_EXPORT R_PlayerSprites( int client, int modelIndex, int count, int siz
{
TEMPENTITY *pTemp;
cl_entity_t *pEnt;
vec3_t position;
vec3_t dir;
pEnt = CL_GetEntityByIndex( client );
@@ -1645,7 +1641,7 @@ void GAME_EXPORT R_PlayerSprites( int client, int modelIndex, int count, int siz
for( int i = 0; i < count; i++ )
{
VectorCopy( pEnt->origin, position );
vec3_t position = Vec3( pEnt->origin );
position[0] += COM_RandomFloat( -10.0f, 10.0f );
position[1] += COM_RandomFloat( -10.0f, 10.0f );
position[2] += COM_RandomFloat( -20.0f, 36.0f );
@@ -1696,14 +1692,13 @@ void GAME_EXPORT R_FireField( float *org, int radius, int modelIndex, int count,
{
TEMPENTITY *pTemp;
model_t *pmodel;
vec3_t pos;
if(( pmodel = CL_ModelHandle( modelIndex )) == NULL )
return;
for( int i = 0; i < count; i++ )
{
VectorCopy( org, pos );
vec3_t pos = Vec3( org );
pos[0] += COM_RandomFloat( -radius, radius );
pos[1] += COM_RandomFloat( -radius, radius );
@@ -1769,10 +1764,10 @@ void GAME_EXPORT R_MultiGunshot( const vec3_t org, const vec3_t dir, const vec3_
{
pmtrace_t trace;
vec3_t right, up;
vec3_t vecSrc, vecDir, vecEnd;
vec3_t vecDir, vecEnd;
VectorVectors( dir, right, up );
VectorCopy( org, vecSrc );
vec3_t vecSrc = Vec3( org );
for( int i = 0; i < count; i++ )
{

View File

@@ -187,7 +187,6 @@ merge refdef with overview settings
static void V_RefApplyOverview( ref_viewpass_t *rvp )
{
ref_overview_t *ov = &clgame.overView;
vec2_t mins, maxs;
if( !CL_IsDevOverviewMode( ))
return;
@@ -212,8 +211,8 @@ static void V_RefApplyOverview( ref_viewpass_t *rvp )
VectorCopy( ov->origin, rvp->vieworigin );
rvp->vieworigin[2] = ov->zFar + ov->zNear;
Vector2Copy( rvp->vieworigin, mins );
Vector2Copy( rvp->vieworigin, maxs );
vec2_t mins = Vec2( rvp->vieworigin );
vec2_t maxs = Vec2( rvp->vieworigin );
mins[!ov->rotated] += ov->xLeft;
maxs[!ov->rotated] += ov->xRight;

View File

@@ -81,11 +81,9 @@ static winding_t *winding_copy( winding_t *w )
static void winding_reverse( winding_t *w )
{
vec3_t point;
for( int i = 0; i < w->numpoints / 2; i++ )
{
VectorCopy( w->p[i], point );
vec3_t point = Vec3( w->p[i] );
VectorCopy( w->p[w->numpoints - i - 1], w->p[i] );
VectorCopy( point, w->p[w->numpoints - i - 1] );
}

View File

@@ -370,7 +370,6 @@ NOTE: pEdict may be NULL
*/
hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t angles, vec3_t origin, vec3_t size, byte *pcontroller, byte *pblending, int *numhitboxes, edict_t *pEdict )
{
vec3_t angles2;
qboolean bSkipShield = false;
*numhitboxes = 0; // assume error
@@ -393,7 +392,7 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang
mod_studiohdr = Mod_StudioExtradata( model );
if( !mod_studiohdr ) return NULL; // probably not a studiomodel
VectorCopy( angles, angles2 );
vec3_t angles2 = Vec3( angles );
if( !FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
angles2[PITCH] = -angles2[PITCH]; // stupid quake bug
@@ -732,7 +731,6 @@ StudioGetAttachment
void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float *angles )
{
mstudioattachment_t *pAtt;
vec3_t angles2;
matrix3x4 localPose;
matrix3x4 worldPose;
model_t *mod;
@@ -755,7 +753,7 @@ void Mod_StudioGetAttachment( const edict_t *e, int iAtt, float *origin, float *
// calculate attachment origin and angles
pAtt = (mstudioattachment_t *)((byte *)mod_studiohdr + mod_studiohdr->attachmentindex) + iAtt;
VectorCopy( e->v.angles, angles2 );
vec3_t angles2 = Vec3( e->v.angles );
if( !FBitSet( host.features, ENGINE_COMPENSATE_QUAKE_BUG ))
angles2[PITCH] = -angles2[PITCH];

View File

@@ -506,8 +506,7 @@ pmtrace_t PM_PlayerTraceExt( playermove_t *pmove, vec3_t start, vec3_t end, int
if( rotated )
{
vec3_t temp;
VectorCopy( trace_bbox.plane.normal, temp );
vec3_t temp = Vec3( trace_bbox.plane.normal );
Matrix4x4_TransformPositivePlane( matrix, temp, trace_bbox.plane.dist, trace_bbox.plane.normal, &trace_bbox.plane.dist );
}
else
@@ -764,8 +763,7 @@ float PM_TraceModel( playermove_t *pmove, physent_t *pe, float *start, float *en
if( rotated )
{
vec3_t temp;
VectorCopy( trace->plane.normal, temp );
vec3_t temp = Vec3( trace->plane.normal );
Matrix4x4_TransformPositivePlane( matrix, temp, trace->plane.dist, trace->plane.normal, &trace->plane.dist );
}

View File

@@ -2313,7 +2313,6 @@ static edict_t *SV_GetCrossEnt( edict_t *player )
vec3_t vecLOS;
vec3_t vecOrigin;
float flDot, traceLen;
vec3_t boxSize;
trace_t trace;
vec3_t vecTrace;
@@ -2339,7 +2338,7 @@ static edict_t *SV_GetCrossEnt( edict_t *player )
if( traceLen > maxLen )
continue;
VectorCopy( ent->v.size, boxSize);
vec3_t boxSize = Vec3( ent->v.size );
VectorScale( boxSize, 0.5, boxSize );
if ( vecLOS[0] > boxSize[0] )

View File

@@ -1854,13 +1854,12 @@ int GAME_EXPORT pfnDropToFloor( edict_t *e )
{
qboolean monsterClip;
trace_t trace;
vec3_t end;
if( !SV_IsValidEdict( e ))
return 0;
monsterClip = FBitSet( e->v.flags, FL_MONSTERCLIP ) ? true : false;
VectorCopy( e->v.origin, end );
vec3_t end = Vec3( e->v.origin );
end[2] -= 256.0f;
trace = SV_Move( e->v.origin, e->v.mins, e->v.maxs, end, MOVE_NORMAL, e, monsterClip );
@@ -1887,8 +1886,6 @@ pfnWalkMove
*/
static int GAME_EXPORT pfnWalkMove( edict_t *ent, float yaw, float dist, int iMode )
{
vec3_t move;
if( !SV_IsValidEdict( ent ))
return 0;
@@ -1896,7 +1893,7 @@ static int GAME_EXPORT pfnWalkMove( edict_t *ent, float yaw, float dist, int iMo
return 0;
yaw = DEG2RAD( yaw );
VectorSet( move, cos( yaw ) * dist, sin( yaw ) * dist, 0.0f );
vec3_t move = { cos( yaw ) * dist, sin( yaw ) * dist, 0.0f };
switch( iMode )
{

View File

@@ -409,11 +409,10 @@ static qboolean SV_StepDirection( edict_t *ent, float yaw, float dist )
{
int ret;
float cSin, cCos;
vec3_t move;
yaw = yaw * M_PI2 / 360.0f;
SinCos( yaw, &cSin, &cCos );
VectorSet( move, cCos * dist, cSin * dist, 0.0f );
vec3_t move = { cCos * dist, cSin * dist, 0.0f };
ret = SV_MoveStep( ent, move, false );
SV_LinkEdict( ent, true );
@@ -519,9 +518,7 @@ static void SV_NewChaseDir( edict_t *actor, vec3_t destination, float dist )
void SV_MoveToOrigin( edict_t *ent, const vec3_t pflGoal, float dist, int iMoveType )
{
vec3_t vecDist;
VectorCopy( pflGoal, vecDist );
vec3_t vecDist = Vec3( pflGoal );
if( ent->v.flags & ( FL_FLY|FL_SWIM|FL_ONGROUND ))
{

View File

@@ -397,13 +397,12 @@ recursively recalculating the middle
*/
static float SV_RecursiveWaterLevel( vec3_t origin, float out, float in, int count )
{
vec3_t point;
float offset;
offset = ((out - in) * 0.5f) + in;
if( ++count > 5 ) return offset;
VectorSet( point, origin[0], origin[1], origin[2] + offset );
vec3_t point = { origin[0], origin[1], origin[2] + offset };
if( SV_PointContents( point ) == CONTENTS_WATER )
return SV_RecursiveWaterLevel( origin, out, offset, count );
@@ -420,7 +419,6 @@ determine how deep the entity is
static float SV_Submerged( edict_t *ent )
{
float start, bottom;
vec3_t point;
vec3_t center;
VectorAverage( ent->v.absmin, ent->v.absmax, center );
@@ -432,10 +430,12 @@ static float SV_Submerged( edict_t *ent )
bottom = SV_RecursiveWaterLevel( center, 0.0f, start, 0 );
return bottom - start;
case 3:
VectorSet( point, center[0], center[1], ent->v.absmax[2] );
{
vec3_t point = { center[0], center[1], ent->v.absmax[2] };
svs.groupmask = ent->v.groupinfo;
if( SV_PointContents( point ) == CONTENTS_WATER )
return (ent->v.maxs[2] - ent->v.mins[2]);
}
// intentionally fallthrough
case 2:
bottom = SV_RecursiveWaterLevel( center, ent->v.absmax[2] - center[2], 0.0f, 0 );
@@ -587,15 +587,14 @@ static int SV_FlyMove( edict_t *ent, float time, trace_t *steptrace )
{
int i, j, numplanes, blocked;
vec3_t dir, end, planes[MAX_CLIP_PLANES];
vec3_t primal_velocity, original_velocity, new_velocity;
float time_left, allFraction;
qboolean monsterClip = FBitSet( ent->v.flags, FL_MONSTERCLIP ) ? true : false;
trace_t trace;
blocked = 0;
VectorCopy( ent->v.velocity, original_velocity );
VectorCopy( ent->v.velocity, primal_velocity );
VectorClear( new_velocity );
vec3_t original_velocity = Vec3( ent->v.velocity );
vec3_t primal_velocity = Vec3( ent->v.velocity );
vec3_t new_velocity = { 0 };
numplanes = 0;
allFraction = 0.0f;

View File

@@ -971,11 +971,9 @@ void SV_RunCmd( sv_client_t *cl, usercmd_t *ucmd, int random_seed )
}
else
{
vec3_t oldvel;
// link into place and touch triggers
SV_LinkEdict( clent, true );
VectorCopy( clent->v.velocity, oldvel ); // save velocity
vec3_t oldvel = Vec3( clent->v.velocity ); // save velocity
// touch other objects
for( int i = 0; i < svgame.pmove->numtouch; i++ )

View File

@@ -1105,15 +1105,14 @@ static void RestoreDecal( SAVERESTOREDATA *pSaveData, decallist_t *entry, qboole
// this can happens if brush entity from previous level was turned into world geometry
if( adjacent && entry->entityIndex != 0 && !SV_IsValidEdict( pEdict ))
{
vec3_t testspot, testend;
trace_t tr;
Con_Printf( S_ERROR "RestoreDecal: couldn't restore entity index %i\n", entry->entityIndex );
VectorCopy( entry->position, testspot );
vec3_t testspot = Vec3( entry->position );
VectorMA( testspot, 5.0f, entry->impactPlaneNormal, testspot );
VectorCopy( entry->position, testend );
vec3_t testend = Vec3( entry->position );
VectorMA( testend, -5.0f, entry->impactPlaneNormal, testend );
tr = SV_Move( testspot, vec3_origin, vec3_origin, testend, MOVE_NOMONSTERS, NULL, false );

View File

@@ -108,7 +108,7 @@ static qboolean SV_CheckSphereIntersection( edict_t *ent, const vec3_t start, co
{
int sequence;
float radiusSquared;
vec3_t traceOrg, traceDir;
vec3_t traceDir;
studiohdr_t *pstudiohdr;
mstudioseqdesc_t *pseqdesc;
model_t *mod;
@@ -128,7 +128,7 @@ static qboolean SV_CheckSphereIntersection( edict_t *ent, const vec3_t start, co
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + sequence;
VectorCopy( start, traceOrg );
vec3_t traceOrg = Vec3( start );
VectorSubtract( end, start, traceDir );
radiusSquared = 0.0f;
@@ -324,12 +324,11 @@ static hull_t *SV_HullForStudioModel( edict_t *ent, vec3_t mins, vec3_t maxs, ve
mstudioseqdesc_t *pseqdesc;
byte controller[4];
byte blending[2];
vec3_t angles;
int iBlend;
pstudio = Mod_StudioExtradata( mod );
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudio + pstudio->seqindex) + ent->v.sequence;
VectorCopy( ent->v.angles, angles );
vec3_t angles = Vec3( ent->v.angles );
SV_StudioPlayerBlend( pseqdesc, &iBlend, &angles[PITCH] );
@@ -421,8 +420,6 @@ static areanode_t *SV_CreateAreaNode( int depth, vec3_t mins, vec3_t maxs )
{
areanode_t *anode;
vec3_t size;
vec3_t mins1, maxs1;
vec3_t mins2, maxs2;
anode = &sv_areanodes[sv_numareanodes++];
@@ -443,10 +440,10 @@ static areanode_t *SV_CreateAreaNode( int depth, vec3_t mins, vec3_t maxs )
else anode->axis = 1;
anode->dist = 0.5f * ( maxs[anode->axis] + mins[anode->axis] );
VectorCopy( mins, mins1 );
VectorCopy( mins, mins2 );
VectorCopy( maxs, maxs1 );
VectorCopy( maxs, maxs2 );
vec3_t mins1 = Vec3( mins );
vec3_t mins2 = Vec3( mins );
vec3_t maxs1 = Vec3( maxs );
vec3_t maxs2 = Vec3( maxs );
maxs1[anode->axis] = mins2[anode->axis] = anode->dist;
anode->children[0] = SV_CreateAreaNode( depth+1, mins2, maxs2 );
@@ -939,10 +936,8 @@ void SV_ClipMoveToEntity( edict_t *ent, const vec3_t start, vec3_t mins, vec3_t
if( rotated )
{
vec3_t temp;
// transform plane
VectorCopy( trace->plane.normal, temp );
vec3_t temp = Vec3( trace->plane.normal );
Matrix4x4_TransformPositivePlane( matrix, temp, trace->plane.dist, trace->plane.normal, &trace->plane.dist );
}
else
@@ -1321,8 +1316,7 @@ trace_t SV_Move( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end,
if( clip.trace.fraction != 0.0f )
{
const float trace_fraction = clip.trace.fraction;
vec3_t trace_endpos;
VectorCopy( clip.trace.endpos, trace_endpos );
vec3_t trace_endpos = Vec3( clip.trace.endpos );
clip.trace.fraction = 1.0f;
clip.start = start;
@@ -1369,16 +1363,14 @@ SV_MoveNoEnts
trace_t GAME_EXPORT SV_MoveNoEnts( const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int type, edict_t *e )
{
moveclip_t clip;
vec3_t trace_endpos;
float trace_fraction;
memset( &clip, 0, sizeof( moveclip_t ));
SV_ClipMoveToEntity( SV_EdictNum( 0 ), start, mins, maxs, end, &clip.trace );
if( clip.trace.fraction != 0.0f )
{
VectorCopy( clip.trace.endpos, trace_endpos );
trace_fraction = clip.trace.fraction;
vec3_t trace_endpos = Vec3( clip.trace.endpos );
float trace_fraction = clip.trace.fraction;
clip.trace.fraction = 1.0f;
clip.start = start;
clip.end = trace_endpos;
@@ -1468,16 +1460,12 @@ trace_t SV_MoveToss( edict_t *tossent, edict_t *ignore )
{
float gravity;
vec3_t move, end;
vec3_t original_origin;
vec3_t original_velocity;
vec3_t original_angles;
vec3_t original_avelocity;
trace_t trace;
VectorCopy( tossent->v.origin, original_origin );
VectorCopy( tossent->v.velocity, original_velocity );
VectorCopy( tossent->v.angles, original_angles );
VectorCopy( tossent->v.avelocity, original_avelocity );
vec3_t original_origin = Vec3( tossent->v.origin );
vec3_t original_velocity = Vec3( tossent->v.velocity );
vec3_t original_angles = Vec3( tossent->v.angles );
vec3_t original_avelocity = Vec3( tossent->v.avelocity );
gravity = tossent->v.gravity * sv_gravity.value * 0.05f;
for( int i = 0; i < 200; i++ )
@@ -1639,7 +1627,6 @@ grab the ambient lighting color for current point
int SV_LightForEntity( edict_t *pEdict )
{
vec3_t point_color = { 1.0f, 1.0f, 1.0f };
vec3_t start, end;
if( !SV_IsValidEdict( pEdict ))
return -1;
@@ -1651,8 +1638,8 @@ int SV_LightForEntity( edict_t *pEdict )
if( FBitSet( pEdict->v.flags, FL_CLIENT ))
return pEdict->v.light_level;
VectorCopy( pEdict->v.origin, start );
VectorCopy( pEdict->v.origin, end );
vec3_t start = Vec3( pEdict->v.origin );
vec3_t end = Vec3( pEdict->v.origin );
if( FBitSet( pEdict->v.effects, EF_INVLIGHT ))
end[2] = start[2] + world.size[2];