Browse Source

public: move some simple functions to mathlib header. Remove assembler version specific for MSVC6

pull/2/head
Alibek Omarov 1 year ago
parent
commit
0d89849cab
  1. 14
      public/matrixlib.c
  2. 25
      public/xash3d_mathlib.c
  3. 23
      public/xash3d_mathlib.h

14
public/matrixlib.c

@ -83,20 +83,6 @@ void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matri @@ -83,20 +83,6 @@ void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matri
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + in1[2][2] * in2[2][3] + in1[2][3];
}
void Matrix3x4_SetOrigin( matrix3x4 out, float x, float y, float z )
{
out[0][3] = x;
out[1][3] = y;
out[2][3] = z;
}
void Matrix3x4_OriginFromMatrix( const matrix3x4 in, float *out )
{
out[0] = in[0][3];
out[1] = in[1][3];
out[2] = in[2][3];
}
void Matrix3x4_AnglesFromMatrix( const matrix3x4 in, vec3_t out )
{
float xyDist = sqrt( in[0][0] * in[0][0] + in[1][0] * in[1][0] );

25
public/xash3d_mathlib.c

@ -224,31 +224,6 @@ float rsqrt( float number ) @@ -224,31 +224,6 @@ float rsqrt( float number )
return y;
}
/*
=================
SinCos
=================
*/
void SinCos( float radians, float *sine, float *cosine )
{
#if _MSC_VER == 1200
_asm
{
fld dword ptr [radians]
fsincos
mov edx, dword ptr [cosine]
mov eax, dword ptr [sine]
fstp dword ptr [edx]
fstp dword ptr [eax]
}
#else
*sine = sin(radians);
*cosine = cos(radians);
#endif
}
/*
==============
VectorCompareEpsilon

23
public/xash3d_mathlib.h

@ -173,6 +173,12 @@ static inline float UintAsFloat( uint32_t u ) @@ -173,6 +173,12 @@ static inline float UintAsFloat( uint32_t u )
return bits.fl;
}
static inline void SinCos( float radians, float *sine, float *cosine )
{
*sine = sin(radians);
*cosine = cos(radians);
}
float rsqrt( float number );
float anglemod( float a );
word FloatToHalf( float v );
@ -181,7 +187,6 @@ void RoundUpHullSize( vec3_t size ); @@ -181,7 +187,6 @@ void RoundUpHullSize( vec3_t size );
int SignbitsForPlane( const vec3_t normal );
int PlaneTypeForNormal( const vec3_t normal );
int NearestPOW( int value, qboolean roundDown );
void SinCos( float radians, float *sine, float *cosine );
float VectorNormalizeLength2( const vec3_t v, vec3_t out );
qboolean VectorCompareEpsilon( const vec3_t vec1, const vec3_t vec2, vec_t epsilon );
void VectorVectors( const vec3_t forward, vec3_t right, vec3_t up );
@ -208,6 +213,20 @@ void QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt ); @@ -208,6 +213,20 @@ void QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt );
#define Matrix3x4_LoadIdentity( mat ) Matrix3x4_Copy( mat, m_matrix3x4_identity )
#define Matrix3x4_Copy( out, in ) memcpy( out, in, sizeof( matrix3x4 ))
static inline void Matrix3x4_SetOrigin( matrix3x4 out, float x, float y, float z )
{
out[0][3] = x;
out[1][3] = y;
out[2][3] = z;
}
static inline void Matrix3x4_OriginFromMatrix( const matrix3x4 in, float *out )
{
out[0] = in[0][3];
out[1] = in[1][3];
out[2] = in[2][3];
}
void Matrix3x4_VectorTransform( const matrix3x4 in, const float v[3], float out[3] );
void Matrix3x4_VectorITransform( const matrix3x4 in, const float v[3], float out[3] );
void Matrix3x4_VectorRotate( const matrix3x4 in, const float v[3], float out[3] );
@ -216,8 +235,6 @@ void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matri @@ -216,8 +235,6 @@ void Matrix3x4_ConcatTransforms( matrix3x4 out, const matrix3x4 in1, const matri
void Matrix3x4_FromOriginQuat( matrix3x4 out, const vec4_t quaternion, const vec3_t origin );
void Matrix3x4_CreateFromEntity( matrix3x4 out, const vec3_t angles, const vec3_t origin, float scale );
void Matrix3x4_TransformAABB( const matrix3x4 world, const vec3_t mins, const vec3_t maxs, vec3_t absmin, vec3_t absmax );
void Matrix3x4_SetOrigin( matrix3x4 out, float x, float y, float z );
void Matrix3x4_OriginFromMatrix( const matrix3x4 in, float *out );
void Matrix3x4_AnglesFromMatrix( const matrix3x4 in, vec3_t out );
#define Matrix4x4_LoadIdentity( mat ) Matrix4x4_Copy( mat, m_matrix4x4_identity )

Loading…
Cancel
Save