Commit e7b5548b authored by Rinnegatamante's avatar Rinnegatamante
Browse files
parent bb677f64
...@@ -664,6 +664,44 @@ static void CG_Portal( centity_t *cent ) { ...@@ -664,6 +664,44 @@ static void CG_Portal( centity_t *cent ) {
} }
/*
================
CG_CreateRotationMatrix
================
*/
void CG_CreateRotationMatrix(vec3_t angles, vec3_t matrix[3]) {
AngleVectors(angles, matrix[0], matrix[1], matrix[2]);
VectorInverse(matrix[1]);
}
/*
================
CG_TransposeMatrix
================
*/
void CG_TransposeMatrix(vec3_t matrix[3], vec3_t transpose[3]) {
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
transpose[i][j] = matrix[j][i];
}
}
}
/*
================
CG_RotatePoint
================
*/
void CG_RotatePoint(vec3_t point, vec3_t matrix[3]) {
vec3_t tvec;
VectorCopy(point, tvec);
point[0] = DotProduct(matrix[0], tvec);
point[1] = DotProduct(matrix[1], tvec);
point[2] = DotProduct(matrix[2], tvec);
}
/* /*
========================= =========================
CG_AdjustPositionForMover CG_AdjustPositionForMover
...@@ -675,6 +713,8 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int ...@@ -675,6 +713,8 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int
centity_t *cent; centity_t *cent;
vec3_t oldOrigin, origin, deltaOrigin; vec3_t oldOrigin, origin, deltaOrigin;
vec3_t oldAngles, angles, deltaAngles; vec3_t oldAngles, angles, deltaAngles;
vec3_t matrix[3], transpose[3];
vec3_t org, org2, move2;
if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) { if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) {
VectorCopy( in, out ); VectorCopy( in, out );
...@@ -698,9 +738,17 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int ...@@ -698,9 +738,17 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int
VectorSubtract( origin, oldOrigin, deltaOrigin ); VectorSubtract( origin, oldOrigin, deltaOrigin );
VectorSubtract( angles, oldAngles, deltaAngles ); VectorSubtract( angles, oldAngles, deltaAngles );
// origin change when on a rotating object
CG_CreateRotationMatrix( deltaAngles, transpose );
CG_TransposeMatrix( transpose, matrix );
VectorSubtract( in, oldOrigin, org );
VectorCopy( org, org2 );
CG_RotatePoint( org2, matrix );
VectorSubtract( org2, org, move2 );
VectorAdd( deltaOrigin, move2, deltaOrigin );
VectorAdd( in, deltaOrigin, out ); VectorAdd( in, deltaOrigin, out );
VectorAdd( angles_in, deltaAngles, angles_out ); VectorAdd( angles_in, deltaAngles, angles_out );
// FIXME: origin change when on a rotating object
} }
...@@ -1045,4 +1093,3 @@ void CG_AddPacketEntities( void ) { ...@@ -1045,4 +1093,3 @@ void CG_AddPacketEntities( void ) {
CG_AddCEntity( cent ); CG_AddCEntity( cent );
} }
} }
...@@ -71,6 +71,7 @@ can then be moved around ...@@ -71,6 +71,7 @@ can then be moved around
void CG_TestModel_f (void) { void CG_TestModel_f (void) {
vec3_t angles; vec3_t angles;
cg.testGun = qfalse;
memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) ); memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) );
if ( trap_Argc() < 2 ) { if ( trap_Argc() < 2 ) {
return; return;
...@@ -96,7 +97,6 @@ void CG_TestModel_f (void) { ...@@ -96,7 +97,6 @@ void CG_TestModel_f (void) {
angles[ROLL] = 0; angles[ROLL] = 0;
AnglesToAxis( angles, cg.testModelEntity.axis ); AnglesToAxis( angles, cg.testModelEntity.axis );
cg.testGun = qfalse;
} }
/* /*
...@@ -108,6 +108,9 @@ Replaces the current view weapon with the given model ...@@ -108,6 +108,9 @@ Replaces the current view weapon with the given model
*/ */
void CG_TestGun_f (void) { void CG_TestGun_f (void) {
CG_TestModel_f(); CG_TestModel_f();
if ( !cg.testModelEntity.hModel ) {
return;
}
cg.testGun = qtrue; cg.testGun = qtrue;
cg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON; cg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON;
} }
......
...@@ -23,6 +23,28 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -23,6 +23,28 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// q_shared.c -- stateless support routines that are included in each code dll // q_shared.c -- stateless support routines that are included in each code dll
#include "q_shared.h" #include "q_shared.h"
// ^[0-9a-zA-Z]
qboolean Q_IsColorString(const char *p) {
if (!p)
return qfalse;
if (p[0] != Q_COLOR_ESCAPE)
return qfalse;
if (p[1] == 0)
return qfalse;
// isalnum expects a signed integer in the range -1 (EOF) to 255, or it might assert on undefined behaviour
// a dereferenced char pointer has the range -128 to 127, so we just need to rangecheck the negative part
if (p[1] < 0)
return qfalse;
if (isalnum(p[1]) == 0)
return qfalse;
return qtrue;
}
float Com_Clamp( float min, float max, float value ) { float Com_Clamp( float min, float max, float value ) {
if ( value < min ) { if ( value < min ) {
return min; return min;
......
...@@ -664,6 +664,44 @@ static void CG_Portal( centity_t *cent ) { ...@@ -664,6 +664,44 @@ static void CG_Portal( centity_t *cent ) {
} }
/*
================
CG_CreateRotationMatrix
================
*/
void CG_CreateRotationMatrix(vec3_t angles, vec3_t matrix[3]) {
AngleVectors(angles, matrix[0], matrix[1], matrix[2]);
VectorInverse(matrix[1]);
}
/*
================
CG_TransposeMatrix
================
*/
void CG_TransposeMatrix(vec3_t matrix[3], vec3_t transpose[3]) {
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
transpose[i][j] = matrix[j][i];
}
}
}
/*
================
CG_RotatePoint
================
*/
void CG_RotatePoint(vec3_t point, vec3_t matrix[3]) {
vec3_t tvec;
VectorCopy(point, tvec);
point[0] = DotProduct(matrix[0], tvec);
point[1] = DotProduct(matrix[1], tvec);
point[2] = DotProduct(matrix[2], tvec);
}
/* /*
========================= =========================
CG_AdjustPositionForMover CG_AdjustPositionForMover
...@@ -675,6 +713,8 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int ...@@ -675,6 +713,8 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int
centity_t *cent; centity_t *cent;
vec3_t oldOrigin, origin, deltaOrigin; vec3_t oldOrigin, origin, deltaOrigin;
vec3_t oldAngles, angles, deltaAngles; vec3_t oldAngles, angles, deltaAngles;
vec3_t matrix[3], transpose[3];
vec3_t org, org2, move2;
if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) { if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) {
VectorCopy( in, out ); VectorCopy( in, out );
...@@ -698,9 +738,17 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int ...@@ -698,9 +738,17 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int
VectorSubtract( origin, oldOrigin, deltaOrigin ); VectorSubtract( origin, oldOrigin, deltaOrigin );
VectorSubtract( angles, oldAngles, deltaAngles ); VectorSubtract( angles, oldAngles, deltaAngles );
// origin change when on a rotating object
CG_CreateRotationMatrix( deltaAngles, transpose );
CG_TransposeMatrix( transpose, matrix );
VectorSubtract( in, oldOrigin, org );
VectorCopy( org, org2 );
CG_RotatePoint( org2, matrix );
VectorSubtract( org2, org, move2 );
VectorAdd( deltaOrigin, move2, deltaOrigin );
VectorAdd( in, deltaOrigin, out ); VectorAdd( in, deltaOrigin, out );
VectorAdd( angles_in, deltaAngles, angles_out ); VectorAdd( angles_in, deltaAngles, angles_out );
// FIXME: origin change when on a rotating object
} }
...@@ -1045,4 +1093,3 @@ void CG_AddPacketEntities( void ) { ...@@ -1045,4 +1093,3 @@ void CG_AddPacketEntities( void ) {
CG_AddCEntity( cent ); CG_AddCEntity( cent );
} }
} }
...@@ -150,7 +150,7 @@ void CG_SelectNextPlayer( void ) { ...@@ -150,7 +150,7 @@ void CG_SelectNextPlayer( void ) {
void CG_SelectPrevPlayer( void ) { void CG_SelectPrevPlayer( void ) {
CG_CheckOrderPending(); CG_CheckOrderPending();
if (cg_currentSelectedPlayer.integer > 0 && cg_currentSelectedPlayer.integer < numSortedTeamPlayers) { if (cg_currentSelectedPlayer.integer > 0 && cg_currentSelectedPlayer.integer <= numSortedTeamPlayers) {
cg_currentSelectedPlayer.integer--; cg_currentSelectedPlayer.integer--;
} else { } else {
cg_currentSelectedPlayer.integer = numSortedTeamPlayers; cg_currentSelectedPlayer.integer = numSortedTeamPlayers;
...@@ -1832,4 +1832,3 @@ void CG_GetTeamColor(vec4_t *color) { ...@@ -1832,4 +1832,3 @@ void CG_GetTeamColor(vec4_t *color) {
(*color)[3] = 0.25f; (*color)[3] = 0.25f;
} }
} }
...@@ -71,6 +71,7 @@ can then be moved around ...@@ -71,6 +71,7 @@ can then be moved around
void CG_TestModel_f (void) { void CG_TestModel_f (void) {
vec3_t angles; vec3_t angles;
cg.testGun = qfalse;
memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) ); memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) );
if ( trap_Argc() < 2 ) { if ( trap_Argc() < 2 ) {
return; return;
...@@ -96,7 +97,6 @@ void CG_TestModel_f (void) { ...@@ -96,7 +97,6 @@ void CG_TestModel_f (void) {
angles[ROLL] = 0; angles[ROLL] = 0;
AnglesToAxis( angles, cg.testModelEntity.axis ); AnglesToAxis( angles, cg.testModelEntity.axis );
cg.testGun = qfalse;
} }
/* /*
...@@ -108,6 +108,9 @@ Replaces the current view weapon with the given model ...@@ -108,6 +108,9 @@ Replaces the current view weapon with the given model
*/ */
void CG_TestGun_f (void) { void CG_TestGun_f (void) {
CG_TestModel_f(); CG_TestModel_f();
if ( !cg.testModelEntity.hModel ) {
return;
}
cg.testGun = qtrue; cg.testGun = qtrue;
cg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON; cg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON;
} }
......
...@@ -23,6 +23,28 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -23,6 +23,28 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// q_shared.c -- stateless support routines that are included in each code dll // q_shared.c -- stateless support routines that are included in each code dll
#include "q_shared.h" #include "q_shared.h"
// ^[0-9a-zA-Z]
qboolean Q_IsColorString(const char *p) {
if (!p)
return qfalse;
if (p[0] != Q_COLOR_ESCAPE)
return qfalse;
if (p[1] == 0)
return qfalse;
// isalnum expects a signed integer in the range -1 (EOF) to 255, or it might assert on undefined behaviour
// a dereferenced char pointer has the range -128 to 127, so we just need to rangecheck the negative part
if (p[1] < 0)
return qfalse;
if (isalnum(p[1]) == 0)
return qfalse;
return qtrue;
}
float Com_Clamp( float min, float max, float value ) { float Com_Clamp( float min, float max, float value ) {
if ( value < min ) { if ( value < min ) {
return min; return min;
......
...@@ -825,6 +825,7 @@ to be configured even if they don't have defined names. ...@@ -825,6 +825,7 @@ to be configured even if they don't have defined names.
*/ */
int Key_StringToKeynum( char *str ) { int Key_StringToKeynum( char *str ) {
keyname_t *kn; keyname_t *kn;
int n;
if ( !str || !str[0] ) { if ( !str || !str[0] ) {
return -1; return -1;
...@@ -834,12 +835,9 @@ int Key_StringToKeynum( char *str ) { ...@@ -834,12 +835,9 @@ int Key_StringToKeynum( char *str ) {
} }
// check for hex code // check for hex code
if ( strlen( str ) == 4 ) { n = Com_HexStrToInt( str );
int n = Com_HexStrToInt( str ); if ( n >= 0 && n < MAX_KEYS ) {
return n;
if ( n >= 0 ) {
return n;
}
} }
// scan for a text match // scan for a text match
......
...@@ -98,9 +98,9 @@ void S_Base_SoundInfo(void) { ...@@ -98,9 +98,9 @@ void S_Base_SoundInfo(void) {
if (!s_soundStarted) { if (!s_soundStarted) {
Com_Printf ("sound system not started\n"); Com_Printf ("sound system not started\n");
} else { } else {
Com_Printf("%5d stereo\n", dma.channels - 1); Com_Printf("%5d channels\n", dma.channels);
Com_Printf("%5d samples\n", dma.samples); Com_Printf("%5d samples\n", dma.samples);
Com_Printf("%5d samplebits\n", dma.samplebits); Com_Printf("%5d samplebits (%s)\n", dma.samplebits, dma.isfloat ? "float" : "int");
Com_Printf("%5d submission_chunk\n", dma.submission_chunk); Com_Printf("%5d submission_chunk\n", dma.submission_chunk);
Com_Printf("%5d speed\n", dma.speed); Com_Printf("%5d speed\n", dma.speed);
Com_Printf("%p dma buffer\n", dma.buffer); Com_Printf("%p dma buffer\n", dma.buffer);
...@@ -119,32 +119,31 @@ void S_Base_SoundInfo(void) { ...@@ -119,32 +119,31 @@ void S_Base_SoundInfo(void) {
static static
void S_Base_StartCapture( void ) void S_Base_StartCapture( void )
{ {
// !!! FIXME: write me. SNDDMA_StartCapture();
} }
static static
int S_Base_AvailableCaptureSamples( void ) int S_Base_AvailableCaptureSamples( void )
{ {
// !!! FIXME: write me. return SNDDMA_AvailableCaptureSamples();
return 0;
} }
static static
void S_Base_Capture( int samples, byte *data ) void S_Base_Capture( int samples, byte *data )
{ {
// !!! FIXME: write me. SNDDMA_Capture(samples, data);
} }
static static
void S_Base_StopCapture( void ) void S_Base_StopCapture( void )
{ {
// !!! FIXME: write me. SNDDMA_StopCapture();
} }
static static
void S_Base_MasterGain( float val ) void S_Base_MasterGain( float val )
{ {
// !!! FIXME: write me. SNDDMA_MasterGain(val);
} }
#endif #endif
...@@ -1243,9 +1242,6 @@ void S_GetSoundtime(void) ...@@ -1243,9 +1242,6 @@ void S_GetSoundtime(void)
int samplepos; int samplepos;
static int buffers; static int buffers;
static int oldsamplepos; static int oldsamplepos;
int fullsamples;
fullsamples = dma.samples / dma.channels;
if( CL_VideoRecording( ) ) if( CL_VideoRecording( ) )
{ {
...@@ -1269,13 +1265,13 @@ void S_GetSoundtime(void) ...@@ -1269,13 +1265,13 @@ void S_GetSoundtime(void)
if (s_paintedtime > 0x40000000) if (s_paintedtime > 0x40000000)
{ // time to chop things off to avoid 32 bit limits { // time to chop things off to avoid 32 bit limits
buffers = 0; buffers = 0;
s_paintedtime = fullsamples; s_paintedtime = dma.fullsamples;
S_Base_StopAllSounds (); S_Base_StopAllSounds ();
} }
} }
oldsamplepos = samplepos; oldsamplepos = samplepos;
s_soundtime = buffers*fullsamples + samplepos/dma.channels; s_soundtime = buffers*dma.fullsamples + samplepos/dma.channels;
#if 0 #if 0
// check to make sure that we haven't overshot // check to make sure that we haven't overshot
...@@ -1296,7 +1292,6 @@ void S_GetSoundtime(void) ...@@ -1296,7 +1292,6 @@ void S_GetSoundtime(void)
void S_Update_(void) { void S_Update_(void) {
unsigned endtime; unsigned endtime;
int samps;
static float lastTime = 0.0f; static float lastTime = 0.0f;
float ma, op; float ma, op;
float thisTime, sane; float thisTime, sane;
...@@ -1340,9 +1335,8 @@ void S_Update_(void) { ...@@ -1340,9 +1335,8 @@ void S_Update_(void) {
& ~(dma.submission_chunk-1); & ~(dma.submission_chunk-1);
// never mix more than the complete buffer // never mix more than the complete buffer
samps = dma.samples >> (dma.channels-1); if (endtime - s_soundtime > dma.fullsamples)
if (endtime - s_soundtime > samps) endtime = s_soundtime + dma.fullsamples;
endtime = s_soundtime + samps;
......
...@@ -65,8 +65,10 @@ typedef struct sfx_s { ...@@ -65,8 +65,10 @@ typedef struct sfx_s {
typedef struct { typedef struct {
int channels; int channels;
int samples; // mono samples in buffer int samples; // mono samples in buffer
int fullsamples; // samples with all channels in buffer (samples divided by channels)
int submission_chunk; // don't mix less than this # int submission_chunk; // don't mix less than this #
int samplebits; int samplebits;
int isfloat;
int speed; int speed;
byte *buffer; byte *buffer;
} dma_t; } dma_t;
...@@ -175,6 +177,15 @@ void SNDDMA_BeginPainting (void); ...@@ -175,6 +177,15 @@ void SNDDMA_BeginPainting (void);
void SNDDMA_Submit(void); void SNDDMA_Submit(void);
#ifdef USE_VOIP
void SNDDMA_StartCapture(void);
int SNDDMA_AvailableCaptureSamples(void);
void SNDDMA_Capture(int samples, byte *data);
void SNDDMA_StopCapture(void);
void SNDDMA_MasterGain(float val);
#endif
//==================================================================== //====================================================================
#define MAX_CHANNELS 96 #define MAX_CHANNELS 96
...@@ -254,3 +265,7 @@ typedef enum ...@@ -254,3 +265,7 @@ typedef enum
typedef int srcHandle_t; typedef int srcHandle_t;
qboolean S_AL_Init( soundInterface_t *si ); qboolean S_AL_Init( soundInterface_t *si );
#ifdef idppc_altivec
void S_PaintChannelFrom16_altivec( portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE], int snd_vol, channel_t *ch, const sfx_t *sc, int count, int sampleOffset, int bufferOffset );
#endif
...@@ -23,9 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -23,9 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "client.h" #include "client.h"
#include "snd_local.h" #include "snd_local.h"
#if idppc_altivec && !defined(__APPLE__)
#include <altivec.h>
#endif
static portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE]; static portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
static int snd_vol; static int snd_vol;
...@@ -122,24 +119,24 @@ void S_TransferStereo16 (unsigned long *pbuf, int endtime) ...@@ -122,24 +119,24 @@ void S_TransferStereo16 (unsigned long *pbuf, int endtime)
while (ls_paintedtime < endtime) while (ls_paintedtime < endtime)
{ {
// handle recirculating buffer issues // handle recirculating buffer issues
lpos = ls_paintedtime & ((dma.samples>>1)-1); lpos = ls_paintedtime % dma.fullsamples;
snd_out = (short *) pbuf + (lpos<<1); snd_out = (short *) pbuf + (lpos<<1); // lpos * dma.channels
snd_linear_count = (dma.samples>>1) - lpos; snd_linear_count = dma.fullsamples - lpos;
if (ls_paintedtime + snd_linear_count > endtime) if (ls_paintedtime + snd_linear_count > endtime)
snd_linear_count = endtime - ls_paintedtime; snd_linear_count = endtime - ls_paintedtime;
snd_linear_count <<= 1; snd_linear_count <<= 1; // snd_linear_count *= dma.channels
// write a linear blast of samples // write a linear blast of samples