[openjk] 101/130: Shared: Move vector2D functions into q_math to avoid redundancy.
Simon McVittie
smcv at debian.org
Fri Oct 28 11:09:25 UTC 2016
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository openjk.
commit ffa7ab7825ed1c841a536f9d5e06cfe71381aa02
Author: Ensiform <ensiform at gmail.com>
Date: Sat Oct 1 22:52:28 2016 -0500
Shared: Move vector2D functions into q_math to avoid redundancy.
---
code/cgame/FxPrimitives.cpp | 2 +-
code/cgame/FxSystem.h | 20 ------------------
code/cgame/FxUtil.cpp | 2 +-
code/cgame/cg_effects.cpp | 8 +++----
code/cgame/cg_players.cpp | 8 +++----
code/rd-vanilla/tr_surface.cpp | 32 +++++++++-------------------
codeJK2/cgame/FxPrimitives.cpp | 2 +-
codeJK2/cgame/FxSystem.h | 20 ------------------
codeJK2/cgame/FxUtil.cpp | 2 +-
codeJK2/cgame/cg_effects.cpp | 8 +++----
codeJK2/cgame/cg_players.cpp | 8 +++----
codemp/cgame/cg_effects.c | 14 ++++--------
codemp/client/FxPrimitives.cpp | 2 +-
codemp/client/FxScheduler.cpp | 2 +-
codemp/client/FxSystem.cpp | 2 +-
codemp/client/FxSystem.h | 32 +---------------------------
codemp/client/FxUtil.cpp | 2 +-
shared/qcommon/q_math.c | 48 ++++++++++++++++++++++++++++++++++++++++++
shared/qcommon/q_math.h | 25 ++++++++++++++++++++++
19 files changed, 112 insertions(+), 127 deletions(-)
diff --git a/code/cgame/FxPrimitives.cpp b/code/cgame/FxPrimitives.cpp
index f902da0..74dc874 100644
--- a/code/cgame/FxPrimitives.cpp
+++ b/code/cgame/FxPrimitives.cpp
@@ -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
diff --git a/code/cgame/FxSystem.h b/code/cgame/FxSystem.h
index 0b65d72..3a81749 100644
--- a/code/cgame/FxSystem.h
+++ b/code/cgame/FxSystem.h
@@ -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;
diff --git a/code/cgame/FxUtil.cpp b/code/cgame/FxUtil.cpp
index 8bb9c87..499dad0 100644
--- a/code/cgame/FxUtil.cpp
+++ b/code/cgame/FxUtil.cpp
@@ -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 );
diff --git a/code/cgame/cg_effects.cpp b/code/cgame/cg_effects.cpp
index 8c6afc4..bd58dc4 100644
--- a/code/cgame/cg_effects.cpp
+++ b/code/cgame/cg_effects.cpp
@@ -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 )
{
@@ -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 )
{
@@ -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 )
{
@@ -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 );
diff --git a/code/cgame/cg_players.cpp b/code/cgame/cg_players.cpp
index c0fa06c..fb0b663 100644
--- a/code/cgame/cg_players.cpp
+++ b/code/cgame/cg_players.cpp
@@ -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 )
{
diff --git a/code/rd-vanilla/tr_surface.cpp b/code/rd-vanilla/tr_surface.cpp
index de693ea..89982fd 100644
--- a/code/rd-vanilla/tr_surface.cpp
+++ b/code/rd-vanilla/tr_surface.cpp
@@ -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
@@ -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;
@@ -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 ));
@@ -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 );
}
}
@@ -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 );
}
}
}
diff --git a/codeJK2/cgame/FxPrimitives.cpp b/codeJK2/cgame/FxPrimitives.cpp
index a53dde9..9cda3a5 100644
--- a/codeJK2/cgame/FxPrimitives.cpp
+++ b/codeJK2/cgame/FxPrimitives.cpp
@@ -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
diff --git a/codeJK2/cgame/FxSystem.h b/codeJK2/cgame/FxSystem.h
index e1bd1df..565e321 100644
--- a/codeJK2/cgame/FxSystem.h
+++ b/codeJK2/cgame/FxSystem.h
@@ -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;
diff --git a/codeJK2/cgame/FxUtil.cpp b/codeJK2/cgame/FxUtil.cpp
index 436e115..8df8097 100644
--- a/codeJK2/cgame/FxUtil.cpp
+++ b/codeJK2/cgame/FxUtil.cpp
@@ -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 );
diff --git a/codeJK2/cgame/cg_effects.cpp b/codeJK2/cgame/cg_effects.cpp
index ddf8086..eb2dd99 100644
--- a/codeJK2/cgame/cg_effects.cpp
+++ b/codeJK2/cgame/cg_effects.cpp
@@ -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 )
{
@@ -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 )
{
@@ -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 )
{
@@ -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 );
diff --git a/codeJK2/cgame/cg_players.cpp b/codeJK2/cgame/cg_players.cpp
index 48ae0c4..0c521cf 100644
--- a/codeJK2/cgame/cg_players.cpp
+++ b/codeJK2/cgame/cg_players.cpp
@@ -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 )
{
diff --git a/codemp/cgame/cg_effects.c b/codemp/cgame/cg_effects.c
index 03defa5..3a1cee6 100644
--- a/codemp/cgame/cg_effects.c
+++ b/codemp/cgame/cg_effects.c
@@ -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
@@ -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 )
{
@@ -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 )
{
@@ -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 )
{
@@ -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 );
diff --git a/codemp/client/FxPrimitives.cpp b/codemp/client/FxPrimitives.cpp
index 38818ae..1497924 100644
--- a/codemp/client/FxPrimitives.cpp
+++ b/codemp/client/FxPrimitives.cpp
@@ -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
diff --git a/codemp/client/FxScheduler.cpp b/codemp/client/FxScheduler.cpp
index 215a1c7..15a3ecc 100644
--- a/codemp/client/FxScheduler.cpp
+++ b/codemp/client/FxScheduler.cpp
@@ -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;
}
diff --git a/codemp/client/FxSystem.cpp b/codemp/client/FxSystem.cpp
index 79fb2f8..f54d991 100644
--- a/codemp/client/FxSystem.cpp
+++ b/codemp/client/FxSystem.cpp
@@ -36,7 +36,7 @@ cvar_t *fx_nearCull;
// Stuff for the FxHelper
//------------------------------------------------------
-SFxHelper::SFxHelper(void) :
+SFxHelper::SFxHelper() :
mTime(0),
mOldTime(0),
mFrameTime(0),
diff --git a/codemp/client/FxSystem.h b/codemp/client/FxSystem.h
index 38ea37d..d42750f 100644
--- a/codemp/client/FxSystem.h
+++ b/codemp/client/FxSystem.h
@@ -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:
@@ -79,7 +49,7 @@ public:
#endif
public:
- SFxHelper(void);
+ SFxHelper();
inline int GetTime(void) { return mTime; }
inline int GetFrameTime(void) { return mFrameTime; }
diff --git a/codemp/client/FxUtil.cpp b/codemp/client/FxUtil.cpp
index f98e87e..ca709d0 100644
--- a/codemp/client/FxUtil.cpp
+++ b/codemp/client/FxUtil.cpp
@@ -1037,7 +1037,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 );
diff --git a/shared/qcommon/q_math.c b/shared/qcommon/q_math.c
index 7401bb6..b15b3db 100644
--- a/shared/qcommon/q_math.c
+++ b/shared/qcommon/q_math.c
@@ -1018,6 +1018,54 @@ void AnglesToAxis( const vec3_t angles, matrix3_t axis ) {
///////////////////////////////////////////////////////////////////////////
//
+// VEC2
+//
+///////////////////////////////////////////////////////////////////////////
+vec2_t vec2_zero = {0,0};
+
+void VectorAdd2( const vec2_t vec1, const vec2_t vec2, vec2_t vecOut )
+{
+ vecOut[0] = vec1[0]+vec2[0];
+ vecOut[1] = vec1[1]+vec2[1];
+}
+
+void VectorSubtract2( const vec2_t vec1, const vec2_t vec2, vec2_t vecOut )
+{
+ vecOut[0] = vec1[0]-vec2[0];
+ vecOut[1] = vec1[1]-vec2[1];
+}
+
+void VectorScale2( const vec2_t vecIn, float scale, vec2_t vecOut )
+{
+ vecOut[0] = vecIn[0]*scale;
+ vecOut[1] = vecIn[1]*scale;
+}
+
+void VectorMA2( const vec2_t vec1, float scale, const vec2_t vec2, vec2_t vecOut )
+{
+ vecOut[0] = vec1[0] + scale*vec2[0];
+ vecOut[1] = vec1[1] + scale*vec2[1];
+}
+
+void VectorSet2( vec2_t vec, float x, float y )
+{
+ vec[0]=x; vec[1]=y;
+}
+
+void VectorClear2( vec2_t vec )
+{
+ vec[0] = vec[1] = 0.0f;
+}
+
+void VectorCopy2( const vec2_t vecIn, vec2_t vecOut )
+{
+ vecOut[0] = vecIn[0];
+ vecOut[1] = vecIn[1];
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+//
// VEC3
//
///////////////////////////////////////////////////////////////////////////
diff --git a/shared/qcommon/q_math.h b/shared/qcommon/q_math.h
index e4399d6..74cbefb 100644
--- a/shared/qcommon/q_math.h
+++ b/shared/qcommon/q_math.h
@@ -201,6 +201,31 @@ void AnglesToAxis( const vec3_t angles, matrix3_t axis );
///////////////////////////////////////////////////////////////////////////
//
+// VEC2
+//
+///////////////////////////////////////////////////////////////////////////
+extern vec2_t vec3_zero;
+
+#define VectorScale2M(v, factor, dst) \
+ (dst)[0] = (v[0]) * (factor), \
+ (dst)[1] = (v[1]) * (factor)
+#define VectorCopy2M(src, dst) \
+ (dst)[0] = (src[0]), \
+ (dst)[1] = (src[1])
+#define VectorClear2M(dst) \
+ memset((dst), 0, sizeof((dst)[0]) * 2)
+
+void VectorAdd2( const vec2_t vec1, const vec2_t vec2, vec2_t vecOut );
+void VectorSubtract2( const vec2_t vec1, const vec2_t vec2, vec2_t vec2_t );
+void VectorScale2( const vec2_t vecIn, float scale, vec2_t vecOut );
+void VectorMA2( const vec2_t vec1, float scale, const vec2_t vec2, vec2_t vecOut );
+void VectorSet2( vec2_t vec, float x, float y );
+void VectorClear2( vec2_t vec );
+void VectorCopy2( const vec2_t vecIn, vec2_t vecOut );
+
+
+///////////////////////////////////////////////////////////////////////////
+//
// VEC3
//
///////////////////////////////////////////////////////////////////////////
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git
More information about the Pkg-games-commits
mailing list