Skip to content

Commit

Permalink
Shared: Move vector2D functions into q_math to avoid redundancy.
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform committed Oct 2, 2016
1 parent 47403da commit ffa7ab7
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 127 deletions.
2 changes: 1 addition & 1 deletion code/cgame/FxPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ void CPoly::Draw()
verts[i].modulate[k] = mRefEnt.shaderRGBA[k];

// Copy the ST coords
Vector2Copy( mST[i], verts[i].st );
VectorCopy2( mST[i], verts[i].st );
}

// Add this poly
Expand Down
20 changes: 0 additions & 20 deletions code/cgame/FxSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
extern vmCvar_t fx_debug;
extern vmCvar_t fx_freeze;

inline void Vector2Clear(vec2_t a)
{
a[0] = 0.0f;
a[1] = 0.0f;
}

inline void Vector2Set(vec2_t a,float b,float c)
{
a[0] = b;
a[1] = c;
}

inline void Vector2Copy(vec2_t src,vec2_t dst)
{
dst[0] = src[0];
dst[1] = src[1];
}


extern void CG_CalcEntityLerpPositions( centity_t * );


struct SFxHelper
{
int mTime;
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/FxUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts,
for ( int i = 0; i < numVerts; i++ )
{
VectorCopy( verts[i], fx->mOrg[i] );
Vector2Copy( st[i], fx->mST[i] );
VectorCopy2( st[i], fx->mST[i] );
}

fx->SetVel( vel );
Expand Down
8 changes: 4 additions & 4 deletions code/cgame/cg_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[0], xx, zz );
VectorSet2( biPoints[0], xx, zz );

if ( t + 1 > 0 && t + 1 < mxWidth )
{
Expand All @@ -894,7 +894,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[1], xx + stepWidth, zz );
VectorSet2( biPoints[1], xx + stepWidth, zz );

if ( t + 1 > 0 && t + 1 < mxWidth )
{
Expand All @@ -914,7 +914,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[2], xx + stepWidth, zz + stepHeight);
VectorSet2( biPoints[2], xx + stepWidth, zz + stepHeight);

if ( t > 0 && t < mxWidth )
{
Expand All @@ -934,7 +934,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[3], xx, zz + stepHeight );
VectorSet2( biPoints[3], xx, zz + stepHeight );

CG_CalcBiLerp( verts, subVerts, biPoints );

Expand Down
8 changes: 4 additions & 4 deletions code/cgame/cg_players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4862,10 +4862,10 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
tent.reType = RT_LATHE;

// Setting up the 2d control points, these get swept around to make a 3D lathed model
Vector2Set( tent.axis[0], 0.5, 0 ); // start point of curve
Vector2Set( tent.axis[1], 50, 85 ); // control point 1
Vector2Set( tent.axis[2], 135, -100 ); // control point 2
Vector2Set( tent.oldorigin, 0, -90 ); // end point of curve
VectorSet2( tent.axis[0], 0.5, 0 ); // start point of curve
VectorSet2( tent.axis[1], 50, 85 ); // control point 1
VectorSet2( tent.axis[2], 135, -100 ); // control point 2
VectorSet2( tent.oldorigin, 0, -90 ); // end point of curve

if ( gent->client->poisonTime && gent->client->poisonTime + 1000 > cg.time )
{
Expand Down
32 changes: 10 additions & 22 deletions code/rd-vanilla/tr_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1580,18 +1580,6 @@ void RB_SurfaceGrid( srfGridMesh_t *cv ) {
}
}

static inline void Vector2Set(vec2_t a,float b,float c)
{
a[0] = b;
a[1] = c;
}

static inline void Vector2Copy(vec2_t src,vec2_t dst)
{
dst[0] = src[0];
dst[1] = src[1];
}

#define LATHE_SEG_STEP 10
#define BEZIER_STEP 0.05f // must be in the range of 0 to 1

Expand Down Expand Up @@ -1621,7 +1609,7 @@ static void RB_SurfaceLathe()
pain = ( 1.0f - pain ) * 0.08f;
}

Vector2Set( l_oldpt, e->axis[0][0], e->axis[0][1] );
VectorSet2( l_oldpt, e->axis[0][0], e->axis[0][1] );

// do scalability stuff...r_lodbias 0-3
int lod = r_lodbias->integer + 1;
Expand All @@ -1648,14 +1636,14 @@ static void RB_SurfaceLathe()
l_oldpt2[i] = mum13 * e->axis[0][i] + group1 * e->axis[1][i] + group2 * e->axis[2][i] + mu3 * e->oldorigin[i];
}

Vector2Set( oldpt, l_oldpt[0], 0 );
Vector2Set( oldpt2, l_oldpt2[0], 0 );
VectorSet2( oldpt, l_oldpt[0], 0 );
VectorSet2( oldpt2, l_oldpt2[0], 0 );

// lathe patch section around in a complete circle
for ( t = latheStep; t <= 360; t += latheStep )
{
Vector2Set( pt, l_oldpt[0], 0 );
Vector2Set( pt2, l_oldpt2[0], 0 );
VectorSet2( pt, l_oldpt[0], 0 );
VectorSet2( pt2, l_oldpt2[0], 0 );

s = sin( DEG2RAD( t ));
c = cos( DEG2RAD( t ));
Expand Down Expand Up @@ -1733,12 +1721,12 @@ static void RB_SurfaceLathe()
tess.indexes[tess.numIndexes++] = vbase;

// Shuffle new points to old
Vector2Copy( pt, oldpt );
Vector2Copy( pt2, oldpt2 );
VectorCopy2( pt, oldpt );
VectorCopy2( pt2, oldpt2 );
}

// shuffle lathe points
Vector2Copy( l_oldpt2, l_oldpt );
VectorCopy2( l_oldpt2, l_oldpt );
}
}

Expand Down Expand Up @@ -1902,8 +1890,8 @@ static void RB_SurfaceClouds()
tess.indexes[tess.numIndexes++] = vbase;

// Shuffle new points to old
Vector2Copy( pt, oldpt );
Vector2Copy( pt2, oldpt2 );
VectorCopy2( pt, oldpt );
VectorCopy2( pt2, oldpt2 );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion codeJK2/cgame/FxPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ void CPoly::Draw()
verts[i].modulate[3] = mRefEnt.shaderRGBA[3];

// Copy the ST coords
Vector2Copy( mST[i], verts[i].st );
VectorCopy2( mST[i], verts[i].st );
}

// Add this poly
Expand Down
20 changes: 0 additions & 20 deletions codeJK2/cgame/FxSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
extern vmCvar_t fx_debug;
extern vmCvar_t fx_freeze;

inline void Vector2Clear(vec2_t a)
{
a[0] = 0.0f;
a[1] = 0.0f;
}

inline void Vector2Set(vec2_t a,float b,float c)
{
a[0] = b;
a[1] = c;
}

inline void Vector2Copy(vec2_t src,vec2_t dst)
{
dst[0] = src[0];
dst[1] = src[1];
}


extern void CG_CalcEntityLerpPositions( centity_t * );


struct SFxHelper
{
int mTime;
Expand Down
2 changes: 1 addition & 1 deletion codeJK2/cgame/FxUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts,
for ( int i = 0; i < numVerts; i++ )
{
VectorCopy( verts[i], fx->mOrg[i] );
Vector2Copy( st[i], fx->mST[i] );
VectorCopy2( st[i], fx->mST[i] );
}

fx->SetVel( vel );
Expand Down
8 changes: 4 additions & 4 deletions codeJK2/cgame/cg_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[0], xx, zz );
VectorSet2( biPoints[0], xx, zz );

if ( t + 1 > 0 && t + 1 < mxWidth )
{
Expand All @@ -862,7 +862,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[1], xx + stepWidth, zz );
VectorSet2( biPoints[1], xx + stepWidth, zz );

if ( t + 1 > 0 && t + 1 < mxWidth )
{
Expand All @@ -882,7 +882,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[2], xx + stepWidth, zz + stepHeight);
VectorSet2( biPoints[2], xx + stepWidth, zz + stepHeight);

if ( t > 0 && t < mxWidth )
{
Expand All @@ -902,7 +902,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[3], xx, zz + stepHeight );
VectorSet2( biPoints[3], xx, zz + stepHeight );

CG_CalcBiLerp( verts, subVerts, biPoints );

Expand Down
8 changes: 4 additions & 4 deletions codeJK2/cgame/cg_players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3604,10 +3604,10 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
tent.reType = RT_LATHE;

// Setting up the 2d control points, these get swept around to make a 3D lathed model
Vector2Set( tent.axis[0], 0.5, 0 ); // start point of curve
Vector2Set( tent.axis[1], 50, 85 ); // control point 1
Vector2Set( tent.axis[2], 135, -100 ); // control point 2
Vector2Set( tent.oldorigin, 0, -90 ); // end point of curve
VectorSet2( tent.axis[0], 0.5, 0 ); // start point of curve
VectorSet2( tent.axis[1], 50, 85 ); // control point 1
VectorSet2( tent.axis[2], 135, -100 ); // control point 2
VectorSet2( tent.oldorigin, 0, -90 ); // end point of curve

if ( gent->client->poisonTime && gent->client->poisonTime + 1000 > cg.time )
{
Expand Down
14 changes: 4 additions & 10 deletions codemp/cgame/cg_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,6 @@ void CG_InitGlass( void )
}
}

void Vector2Set(vec2_t a,float b,float c)
{
a[0] = b;
a[1] = c;
}

#define TIME_DECAY_SLOW 0.1f
#define TIME_DECAY_MED 0.04f
#define TIME_DECAY_FAST 0.009f
Expand Down Expand Up @@ -538,7 +532,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[0], xx, zz );
VectorSet2( biPoints[0], xx, zz );

if ( t + 1 > 0 && t + 1 < mxWidth )
{
Expand All @@ -558,7 +552,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[1], xx + stepWidth, zz );
VectorSet2( biPoints[1], xx + stepWidth, zz );

if ( t + 1 > 0 && t + 1 < mxWidth )
{
Expand All @@ -578,7 +572,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[2], xx + stepWidth, zz + stepHeight);
VectorSet2( biPoints[2], xx + stepWidth, zz + stepHeight);

if ( t > 0 && t < mxWidth )
{
Expand All @@ -598,7 +592,7 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl
zz = z;
}

Vector2Set( biPoints[3], xx, zz + stepHeight );
VectorSet2( biPoints[3], xx, zz + stepHeight );

CG_CalcBiLerp( verts, subVerts, biPoints );

Expand Down
2 changes: 1 addition & 1 deletion codemp/client/FxPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ void CPoly::Draw(void)
verts[i].modulate[k] = mRefEnt.shaderRGBA[k];

// Copy the ST coords
Vector2Copy( mST[i], verts[i].st );
VectorCopy2( mST[i], verts[i].st );
}

// Add this poly
Expand Down
2 changes: 1 addition & 1 deletion codemp/client/FxScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ void CFxScheduler::PlayEffect( int id, vec3_t origin, matrix3_t axis, const int

if ( sfx == NULL )
{
Com_Error (ERR_DROP, "ERROR: Failed to allocate EFX from memory pool.\n");
Com_Error (ERR_DROP, "ERROR: Failed to allocate EFX from memory pool.");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion codemp/client/FxSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cvar_t *fx_nearCull;

// Stuff for the FxHelper
//------------------------------------------------------
SFxHelper::SFxHelper(void) :
SFxHelper::SFxHelper() :
mTime(0),
mOldTime(0),
mFrameTime(0),
Expand Down
32 changes: 1 addition & 31 deletions codemp/client/FxSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,6 @@ extern cvar_t *fx_freeze;
extern cvar_t *fx_countScale;
extern cvar_t *fx_nearCull;

inline void Vector2Clear(vec2_t a)
{
a[0] = 0.0f;
a[1] = 0.0f;
}

inline void Vector2Set(vec2_t a,float b,float c)
{
a[0] = b;
a[1] = c;
}

inline void Vector2Copy(vec2_t src,vec2_t dst)
{
dst[0] = src[0];
dst[1] = src[1];
}

inline void Vector2MA(vec2_t src, float m, vec2_t v, vec2_t dst)
{
dst[0] = src[0] + (m*v[0]);
dst[1] = src[1] + (m*v[1]);
}

inline void Vector2Scale(vec2_t src,float b,vec2_t dst)
{
dst[0] = src[0] * b;
dst[1] = src[1] * b;
}

class SFxHelper
{
public:
Expand All @@ -79,7 +49,7 @@ class SFxHelper
#endif

public:
SFxHelper(void);
SFxHelper();

inline int GetTime(void) { return mTime; }
inline int GetFrameTime(void) { return mFrameTime; }
Expand Down
Loading

0 comments on commit ffa7ab7

Please sign in to comment.