Cleaned up chasecam code, added new cvars to control pitch, yaw and roll.
This commit is contained in:
parent
6f4199658a
commit
be560d872b
2 changed files with 188 additions and 352 deletions
138
audio/snd_mix.c
138
audio/snd_mix.c
|
@ -34,7 +34,8 @@ int *snd_p, snd_linear_count, snd_vol;
|
||||||
short *snd_out;
|
short *snd_out;
|
||||||
extern cvar_t *s_underwater;
|
extern cvar_t *s_underwater;
|
||||||
void Snd_WriteLinearBlastStereo16 (void);
|
void Snd_WriteLinearBlastStereo16 (void);
|
||||||
int playersnd; // leilei - dsp effects
|
int playersnd;
|
||||||
|
|
||||||
#if !id386
|
#if !id386
|
||||||
void Snd_WriteLinearBlastStereo16 (void)
|
void Snd_WriteLinearBlastStereo16 (void)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +62,7 @@ void Snd_WriteLinearBlastStereo16 (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
void SND_PaintDumb(int count);
|
|
||||||
void S_TransferStereo16 (int endtime)
|
void S_TransferStereo16 (int endtime)
|
||||||
{
|
{
|
||||||
int lpos;
|
int lpos;
|
||||||
|
@ -89,7 +90,7 @@ void S_TransferStereo16 (int endtime)
|
||||||
{
|
{
|
||||||
if (hresult != DSERR_BUFFERLOST)
|
if (hresult != DSERR_BUFFERLOST)
|
||||||
{
|
{
|
||||||
Con_Printf ("S_TransferStereo16: DS::Lock Sound Buffer Failed\n");
|
Con_Printf ("[SOUND] DS::Lock Sound Buffer Failed\n");
|
||||||
S_Shutdown ();
|
S_Shutdown ();
|
||||||
S_Startup ();
|
S_Startup ();
|
||||||
return;
|
return;
|
||||||
|
@ -97,7 +98,7 @@ void S_TransferStereo16 (int endtime)
|
||||||
|
|
||||||
if (++reps > 10000)
|
if (++reps > 10000)
|
||||||
{
|
{
|
||||||
Con_Printf ("S_TransferStereo16: DS: couldn't restore buffer\n");
|
Con_Printf ("[SOUND] DS: couldn't restore buffer\n");
|
||||||
S_Shutdown ();
|
S_Shutdown ();
|
||||||
S_Startup ();
|
S_Startup ();
|
||||||
return;
|
return;
|
||||||
|
@ -146,6 +147,7 @@ void S_TransferPaintBuffer(int endtime)
|
||||||
int val;
|
int val;
|
||||||
int snd_vol;
|
int snd_vol;
|
||||||
DWORD *pbuf;
|
DWORD *pbuf;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int reps;
|
int reps;
|
||||||
DWORD dwSize,dwSize2;
|
DWORD dwSize,dwSize2;
|
||||||
|
@ -176,7 +178,7 @@ void S_TransferPaintBuffer(int endtime)
|
||||||
{
|
{
|
||||||
if (hresult != DSERR_BUFFERLOST)
|
if (hresult != DSERR_BUFFERLOST)
|
||||||
{
|
{
|
||||||
Con_Printf ("S_TransferPaintBuffer: DS::Lock Sound Buffer Failed\n");
|
Con_Printf ("[SOUND] DS::Lock Sound Buffer Failed\n");
|
||||||
S_Shutdown ();
|
S_Shutdown ();
|
||||||
S_Startup ();
|
S_Startup ();
|
||||||
return;
|
return;
|
||||||
|
@ -184,7 +186,7 @@ void S_TransferPaintBuffer(int endtime)
|
||||||
|
|
||||||
if (++reps > 10000)
|
if (++reps > 10000)
|
||||||
{
|
{
|
||||||
Con_Printf ("S_TransferPaintBuffer: DS: couldn't restore buffer\n");
|
Con_Printf ("[SOUND] DS: couldn't restore buffer\n");
|
||||||
S_Shutdown ();
|
S_Shutdown ();
|
||||||
S_Startup ();
|
S_Startup ();
|
||||||
return;
|
return;
|
||||||
|
@ -239,9 +241,6 @@ void S_TransferPaintBuffer(int endtime)
|
||||||
pDSBuf->lpVtbl->Unlock(pDSBuf, pbuf, dwSize, NULL, 0);
|
pDSBuf->lpVtbl->Unlock(pDSBuf, pbuf, dwSize, NULL, 0);
|
||||||
|
|
||||||
pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &dwNewpos, &dwWrite);
|
pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &dwNewpos, &dwWrite);
|
||||||
|
|
||||||
// if ((dwNewpos >= il) && (dwNewpos <= ir))
|
|
||||||
// Con_Printf("%d-%d p %d c\n", il, ir, dwNewpos);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -257,12 +256,9 @@ CHANNEL MIXING
|
||||||
|
|
||||||
void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime);
|
void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime);
|
||||||
void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime);
|
void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime);
|
||||||
|
|
||||||
void SND_PaintChannelFrom8_II (channel_t *ch, sfxcache_t *sc, int endtime);
|
void SND_PaintChannelFrom8_II (channel_t *ch, sfxcache_t *sc, int endtime);
|
||||||
void SND_PaintChannelFrom16_II (channel_t *ch, sfxcache_t *sc, int endtime);
|
void SND_PaintChannelFrom16_II (channel_t *ch, sfxcache_t *sc, int endtime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void S_PaintChannels(int endtime)
|
void S_PaintChannels(int endtime)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -317,26 +313,6 @@ void S_PaintChannels(int endtime)
|
||||||
else
|
else
|
||||||
SND_PaintChannelFrom16_II(ch, sc, count);
|
SND_PaintChannelFrom16_II(ch, sc, count);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// lol?
|
|
||||||
// SND_PaintChannelFrom8_II(ch, sc, count + 8);
|
|
||||||
// SND_PaintChannelFrom8_II(ch, sc, count + 16);
|
|
||||||
|
|
||||||
#ifdef DUMB
|
|
||||||
// SND_PaintDumb(count);
|
|
||||||
|
|
||||||
/*
|
|
||||||
long duh_sigrenderer_generate_samples(
|
|
||||||
DUH_SIGRENDERER *sigrenderer,
|
|
||||||
float volume, float delta,
|
|
||||||
long size, sample_t **samples);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
ltime += count;
|
ltime += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,9 +321,6 @@ void S_PaintChannels(int endtime)
|
||||||
{
|
{
|
||||||
if (sc->loopstart >= 0)
|
if (sc->loopstart >= 0)
|
||||||
{
|
{
|
||||||
// ch->pos = sc->loopstart;
|
|
||||||
// ch->end = ltime + sc->length - ch->pos;
|
|
||||||
|
|
||||||
// leilei - HACK!
|
// leilei - HACK!
|
||||||
ch->pos = sc->loopstart >> 8;
|
ch->pos = sc->loopstart >> 8;
|
||||||
ch->end = ltime + sc->length - ch->pos;
|
ch->end = ltime + sc->length - ch->pos;
|
||||||
|
@ -359,7 +332,6 @@ void S_PaintChannels(int endtime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transfer out according to DMA format
|
// transfer out according to DMA format
|
||||||
|
@ -403,7 +375,6 @@ void SND_PaintChanneledFrom8 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
paintbuffer[i].left += lscale[*sfx++];
|
paintbuffer[i].left += lscale[*sfx++];
|
||||||
paintbuffer[i].right += rscale[*sfx++];
|
paintbuffer[i].right += rscale[*sfx++];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -415,11 +386,7 @@ void SND_PaintChanneledFrom8 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
paintbuffer[i].left += lscale[*sfx];
|
paintbuffer[i].left += lscale[*sfx];
|
||||||
paintbuffer[i].right += rscale[*sfx++];
|
paintbuffer[i].right += rscale[*sfx++];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
ch->pos += count;
|
ch->pos += count;
|
||||||
}
|
}
|
||||||
|
@ -429,87 +396,60 @@ void SND_PaintChanneledFrom8 (channel_t *ch, sfxcache_t *sc, int count)
|
||||||
extern cvar_t *temp2;
|
extern cvar_t *temp2;
|
||||||
extern cvar_t *temp3;
|
extern cvar_t *temp3;
|
||||||
|
|
||||||
void
|
void SND_PaintChannelFrom8_II(channel_t *ch, sfxcache_t *sc, int count)
|
||||||
SND_PaintChannelFrom8_II(channel_t *ch, sfxcache_t *sc, int count)
|
|
||||||
{
|
{
|
||||||
int data;
|
int data;
|
||||||
unsigned char dater;
|
|
||||||
int *lscale, *rscale;
|
int *lscale, *rscale;
|
||||||
int lscale2, rscale2;
|
int lscale2, rscale2;
|
||||||
unsigned char *sfx;
|
|
||||||
int i;
|
int i;
|
||||||
int verb; // leilei - lame processing test
|
int verb;
|
||||||
int ah;
|
int ah;
|
||||||
float arb;
|
float arb;
|
||||||
float sterp;
|
float sterp;
|
||||||
|
unsigned char *sfx;
|
||||||
|
unsigned char dater;
|
||||||
|
|
||||||
if (ch->leftvol > 255)
|
if (ch->leftvol > 255)
|
||||||
ch->leftvol = 255;
|
ch->leftvol = 255;
|
||||||
if (ch->rightvol > 255)
|
if (ch->rightvol > 255)
|
||||||
ch->rightvol = 255;
|
ch->rightvol = 255;
|
||||||
// if (ch->step < 5)
|
|
||||||
// ch->step = 256; // ambient suck hack
|
|
||||||
lscale = snd_scaletable[ch->leftvol >> 3];
|
lscale = snd_scaletable[ch->leftvol >> 3];
|
||||||
rscale = snd_scaletable[ch->rightvol >> 3];
|
rscale = snd_scaletable[ch->rightvol >> 3];
|
||||||
|
|
||||||
|
|
||||||
sterp = ch->step * host_timescale->value;
|
sterp = ch->step * host_timescale->value;
|
||||||
|
|
||||||
if (sc->stereo > 1)
|
if (sc->stereo > 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
// LordHavoc: stereo sound support, and optimizations
|
|
||||||
|
|
||||||
|
|
||||||
// leilei - VERY BAD attempt at stereo sound support
|
|
||||||
|
|
||||||
// sfx = (unsigned char *)sc->data;
|
|
||||||
|
|
||||||
sfx = (unsigned char *)sc->data;
|
sfx = (unsigned char *)sc->data;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
data = (sfx[ch->pos >> 8]);
|
data = (sfx[ch->pos >> 8]);
|
||||||
dater = (sfx[ch->pos * 2 >> 8]);
|
dater = (sfx[ch->pos * 2 >> 8]);
|
||||||
// paintbuffer[i].left += lscale[*sfx++];
|
|
||||||
// paintbuffer[i].right += rscale[*sfx++];
|
|
||||||
|
|
||||||
paintbuffer[i].left += lscale[dater++];
|
paintbuffer[i].left += lscale[dater++];
|
||||||
|
|
||||||
paintbuffer[i].right += rscale[dater++];
|
paintbuffer[i].right += rscale[dater++];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ch->step *= host_timescale->value; // slowmo sounds hack
|
|
||||||
ch->pos += (sterp);
|
ch->pos += (sterp);
|
||||||
|
|
||||||
if ((ch->pos >> 8) >= sc->length) break;
|
if ((ch->pos >> 8) >= sc->length)
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sfx = (signed char *)sc->data; //@@@
|
sfx = (signed char *)sc->data;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
//@@@
|
|
||||||
data = sfx[ch->pos >> 8];
|
data = sfx[ch->pos >> 8];
|
||||||
// paintbuffer[i].left += lscale[data];
|
|
||||||
// paintbuffer[i].right += rscale[data];
|
|
||||||
|
|
||||||
// dumb DSP effects test test
|
|
||||||
|
|
||||||
|
|
||||||
// This makes it sound muffled. Might use for underwater?
|
|
||||||
//if (playersnd == 2){
|
|
||||||
if ((sc->flags == 2 || playersnd == 2) && s_underwater->value > 1){
|
|
||||||
|
|
||||||
|
if ((sc->flags == 2 || playersnd == 2) && s_underwater->value > 1)
|
||||||
|
{
|
||||||
for (verb = 1; verb > 8; verb++)
|
for (verb = 1; verb > 8; verb++)
|
||||||
{
|
{
|
||||||
|
lscale2 = lscale[data];
|
||||||
lscale2 = lscale[data];// / verb;
|
rscale2 = rscale[data];
|
||||||
rscale2 = rscale[data];// / verb;
|
|
||||||
paintbuffer[i].left += lscale2;
|
paintbuffer[i].left += lscale2;
|
||||||
paintbuffer[i].right += rscale2;
|
paintbuffer[i].right += rscale2;
|
||||||
}
|
}
|
||||||
|
@ -519,24 +459,12 @@ void
|
||||||
paintbuffer[i].left += lscale[data];
|
paintbuffer[i].left += lscale[data];
|
||||||
paintbuffer[i].right += rscale[data];
|
paintbuffer[i].right += rscale[data];
|
||||||
}
|
}
|
||||||
//@@@
|
|
||||||
|
|
||||||
|
|
||||||
/* {
|
|
||||||
int ehhh;
|
|
||||||
for (ehhh=0; ehhh<count; ehhh++){
|
|
||||||
if (ehhh > count+8)
|
|
||||||
paintbuffer[ehhh+8].left += 0;
|
|
||||||
else
|
|
||||||
paintbuffer[ehhh+8].left += paintbuffer[ehhh].left * 0.2;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
ch->pos += sterp;
|
ch->pos += sterp;
|
||||||
if ((ch->pos >> 8) >= sc->length) break;
|
if ((ch->pos >> 8) >= sc->length)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -560,23 +488,16 @@ void SND_PaintChannelFrom16_II(channel_t *ch, sfxcache_t *sc, int count)
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
data = sfx[ch->pos >> 8]; //@@@
|
data = sfx[ch->pos >> 8]; //@@@
|
||||||
|
|
||||||
left = (data * leftvol) >> 8;
|
left = (data * leftvol) >> 8;
|
||||||
right = (data * rightvol) >> 8;
|
right = (data * rightvol) >> 8;
|
||||||
// paintbuffer[i].left += left;
|
|
||||||
// paintbuffer[i].right += right;
|
|
||||||
|
|
||||||
// leilei - dsp "effects"
|
|
||||||
|
|
||||||
if ((sc->flags == 2 || playersnd == 2) && s_underwater->value > 1){
|
|
||||||
|
|
||||||
|
if ((sc->flags == 2 || playersnd == 2) && s_underwater->value > 1)
|
||||||
|
{
|
||||||
for (verb = 22; verb < 58; verb++)
|
for (verb = 22; verb < 58; verb++)
|
||||||
{
|
{
|
||||||
arb = 1.2 / verb;
|
arb = 1.2 / verb;
|
||||||
// paintbuffer[i+verb].left += (left * (arb));
|
|
||||||
// paintbuffer[i+verb].right += (right * (arb));
|
|
||||||
paintbuffer[i+verb].left += left * 0.05;
|
paintbuffer[i+verb].left += left * 0.05;
|
||||||
paintbuffer[i+verb].right += right * 0.04;
|
paintbuffer[i+verb].right += right * 0.04;
|
||||||
}
|
}
|
||||||
|
@ -587,8 +508,9 @@ void SND_PaintChannelFrom16_II(channel_t *ch, sfxcache_t *sc, int count)
|
||||||
paintbuffer[i].right += right;
|
paintbuffer[i].right += right;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@@@
|
|
||||||
ch->pos += sterp;
|
ch->pos += sterp;
|
||||||
if ((ch->pos >> 8) >= sc->length) break;
|
|
||||||
|
if ((ch->pos >> 8) >= sc->length)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,10 @@ cvar_t *chase_up;
|
||||||
cvar_t *chase_right;
|
cvar_t *chase_right;
|
||||||
cvar_t *chase_active;
|
cvar_t *chase_active;
|
||||||
|
|
||||||
|
cvar_t *chase_yaw;
|
||||||
|
cvar_t *chase_pitch;
|
||||||
|
cvar_t *chase_roll;
|
||||||
|
|
||||||
vec3_t chase_pos;
|
vec3_t chase_pos;
|
||||||
vec3_t chase_angles;
|
vec3_t chase_angles;
|
||||||
|
|
||||||
|
@ -40,10 +44,8 @@ cvar_t *cl_diecam; // leilei
|
||||||
// 2 - quake3-like - fixed chase camera, can't move it at all. no tilt either.
|
// 2 - quake3-like - fixed chase camera, can't move it at all. no tilt either.
|
||||||
// 3 - unrealike - rotatable chase camera - scores are automatically displayed a few seconds later.
|
// 3 - unrealike - rotatable chase camera - scores are automatically displayed a few seconds later.
|
||||||
float deathcamtime; // resets to 0 if we're alive.
|
float deathcamtime; // resets to 0 if we're alive.
|
||||||
|
|
||||||
float deathcam_whenidied; // sets to time if died, used for timing deathcam effects...
|
float deathcam_whenidied; // sets to time if died, used for timing deathcam effects...
|
||||||
float deathcam_whenidiedafter;
|
float deathcam_whenidiedafter; // used to time the sinks into the floor or the rankings appearing.....
|
||||||
// used to time the sinks into the floor or the rankings appearing.....
|
|
||||||
vec3_t deathcam_angles; // this'll update chase angles when we're dead so we don't move the
|
vec3_t deathcam_angles; // this'll update chase angles when we're dead so we don't move the
|
||||||
// player - so we can rotate the death cam in cl_diecam 3.
|
// player - so we can rotate the death cam in cl_diecam 3.
|
||||||
int deathcam_yesiamdead; // pretty stupid indicator of dead.
|
int deathcam_yesiamdead; // pretty stupid indicator of dead.
|
||||||
|
@ -54,57 +56,12 @@ void Chase_Init_Cvars (void)
|
||||||
chase_up = Cvar_Get ("chase_up", "16", CVAR_ORIGINAL);
|
chase_up = Cvar_Get ("chase_up", "16", CVAR_ORIGINAL);
|
||||||
chase_right = Cvar_Get ("chase_right", "0", CVAR_ORIGINAL);
|
chase_right = Cvar_Get ("chase_right", "0", CVAR_ORIGINAL);
|
||||||
chase_active = Cvar_Get ("chase_active", "0", CVAR_ORIGINAL);
|
chase_active = Cvar_Get ("chase_active", "0", CVAR_ORIGINAL);
|
||||||
|
chase_yaw = Cvar_Get ("chase_yaw", "0", CVAR_ORIGINAL);
|
||||||
cl_diecam = Cvar_Get ("cl_diecam", "0", CVAR_ORIGINAL | CVAR_ARCHIVE); // leilei
|
chase_pitch = Cvar_Get ("chase_pitch", "0", CVAR_ORIGINAL);
|
||||||
|
chase_roll = Cvar_Get ("chase_roll", "0", CVAR_ORIGINAL);
|
||||||
|
cl_diecam = Cvar_Get ("cl_diecam", "0", CVAR_ORIGINAL | CVAR_ARCHIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VMTOC
|
|
||||||
|
|
||||||
extern qboolean SV_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace);
|
|
||||||
|
|
||||||
static trace_t CL_TraceLine(vec3_t start, vec3_t end)
|
|
||||||
{
|
|
||||||
trace_t trace;
|
|
||||||
|
|
||||||
memset(&trace, 0, sizeof(trace));
|
|
||||||
trace.fraction = 1.0f;
|
|
||||||
trace.allsolid = true;
|
|
||||||
VectorCopy(end, trace.endpos);
|
|
||||||
|
|
||||||
SV_RecursiveHullCheck(cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
|
|
||||||
|
|
||||||
return trace;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chase_Update(void)
|
|
||||||
{
|
|
||||||
float dist;
|
|
||||||
vec3_t forward, right;
|
|
||||||
vec3_t chase_dest;
|
|
||||||
trace_t trace;
|
|
||||||
|
|
||||||
vec_t camback = chase_back->value;
|
|
||||||
vec_t camup = chase_up->value;
|
|
||||||
|
|
||||||
|
|
||||||
if (deathcam_yesimdead)
|
|
||||||
AngleVectors(deathcam_angles, forward, right, NULL);
|
|
||||||
else
|
|
||||||
AngleVectors(cl.viewangles, forward, right, NULL);
|
|
||||||
|
|
||||||
dist = -camback - 8;
|
|
||||||
chase_dest[0] = r_refdef.vieworg[0] + forward[0] * dist;
|
|
||||||
chase_dest[1] = r_refdef.vieworg[1] + forward[1] * dist;
|
|
||||||
chase_dest[2] = r_refdef.vieworg[2] + forward[2] * dist + camup;
|
|
||||||
|
|
||||||
trace = CL_TraceLine(r_refdef.vieworg, chase_dest);
|
|
||||||
|
|
||||||
r_refdef.vieworg[0] = trace.endpos[0] + 8 * forward[0] + 4 * trace.plane.normal[0];
|
|
||||||
r_refdef.vieworg[1] = trace.endpos[1] + 8 * forward[1] + 4 * trace.plane.normal[1];
|
|
||||||
r_refdef.vieworg[2] = trace.endpos[2] + 8 * forward[2] + 4 * trace.plane.normal[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
void Chase_Reset (void)
|
void Chase_Reset (void)
|
||||||
{
|
{
|
||||||
// for respawning and teleporting
|
// for respawning and teleporting
|
||||||
|
@ -121,35 +78,6 @@ void TraceLine (vec3_t start, vec3_t end, vec3_t impact)
|
||||||
VectorCopy (trace.endpos, impact);
|
VectorCopy (trace.endpos, impact);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceLineWithAVengeance (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
|
|
||||||
{
|
|
||||||
trace_t trace;
|
|
||||||
|
|
||||||
memset (&trace, 0, sizeof(trace));
|
|
||||||
SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
|
|
||||||
|
|
||||||
VectorCopy (trace.endpos, impact);
|
|
||||||
VectorCopy (trace.plane.normal, normal);
|
|
||||||
// Con_Printf("%f %f %f norm\n",normal[0],normal[1],normal[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TraceLineOrDie (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, vec3_t fracin)
|
|
||||||
{
|
|
||||||
trace_t trace;
|
|
||||||
|
|
||||||
memset (&trace, 0, sizeof(trace));
|
|
||||||
SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
|
|
||||||
|
|
||||||
VectorCopy (trace.endpos, impact);
|
|
||||||
VectorCopy (trace.plane.normal, normal);
|
|
||||||
|
|
||||||
fracin[0] = trace.fraction;
|
|
||||||
|
|
||||||
Con_Printf("%f %f %f norm\n",normal[0],normal[1],normal[2]);
|
|
||||||
Con_Printf("%f fraction\n",fracin[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Chase_Update (void)
|
void Chase_Update (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -159,13 +87,12 @@ void Chase_Update (void)
|
||||||
float deest;
|
float deest;
|
||||||
int dontspinme;
|
int dontspinme;
|
||||||
|
|
||||||
|
|
||||||
deest = sv.time - deathcam_whenidied;
|
deest = sv.time - deathcam_whenidied;
|
||||||
|
|
||||||
//
|
|
||||||
if(deathcam_yesiamdead == 4)
|
if(deathcam_yesiamdead == 4)
|
||||||
{
|
{
|
||||||
if (deest < 1){
|
if (deest < 1)
|
||||||
|
{
|
||||||
deathcam_angles[PITCH] = 0;
|
deathcam_angles[PITCH] = 0;
|
||||||
deathcam_angles[YAW] = cl.viewangles[YAW];
|
deathcam_angles[YAW] = cl.viewangles[YAW];
|
||||||
deathcam_angles[ROLL] = 0;
|
deathcam_angles[ROLL] = 0;
|
||||||
|
@ -174,8 +101,6 @@ void Chase_Update (void)
|
||||||
{
|
{
|
||||||
deathcam_angles[PITCH] = 90;
|
deathcam_angles[PITCH] = 90;
|
||||||
deathcam_angles[YAW] = 0;
|
deathcam_angles[YAW] = 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,46 +111,39 @@ void Chase_Update (void)
|
||||||
AngleVectors (cl.viewangles, forward, right, up);
|
AngleVectors (cl.viewangles, forward, right, up);
|
||||||
|
|
||||||
// calc exact destination
|
// calc exact destination
|
||||||
if (deathcam_yesiamdead == 2){ // close, nonspinnable
|
if (deathcam_yesiamdead == 2) // close, nonspinnable
|
||||||
|
{
|
||||||
AngleVectors (cl.viewangles, forward, right, up);
|
AngleVectors (cl.viewangles, forward, right, up);
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
chase_dest[i] = r_refdef.vieworg[i]
|
chase_dest[i] = r_refdef.vieworg[i] - forward[i]*70 - right[i]*0;
|
||||||
- forward[i]*70
|
|
||||||
- right[i]*0;
|
|
||||||
chase_dest[2] = r_refdef.vieworg[2];
|
chase_dest[2] = r_refdef.vieworg[2];
|
||||||
dontspinme = 1;
|
dontspinme = 1;
|
||||||
}
|
}
|
||||||
else
|
else if (deathcam_yesiamdead == 3) // spinabble...
|
||||||
if (deathcam_yesiamdead == 3){ // spinabble...
|
{
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
chase_dest[i] = r_refdef.vieworg[i]
|
chase_dest[i] = r_refdef.vieworg[i] - forward[i]*150 - right[i]*0;
|
||||||
- forward[i]*150
|
|
||||||
- right[i]*0;
|
|
||||||
// chase_dest[2] = r_refdef.vieworg[2];
|
|
||||||
dontspinme = 0;
|
dontspinme = 0;
|
||||||
}
|
}
|
||||||
else
|
else if (deathcam_yesiamdead == 4) // non spinabble... and after a duration it kinda increases....
|
||||||
if (deathcam_yesiamdead == 4){ // non spinabble... and after a duration it kinda increases....
|
{
|
||||||
|
|
||||||
if (deest < 1)
|
if (deest < 1)
|
||||||
deest = 0;
|
deest = 0;
|
||||||
dontspinme = 1;
|
|
||||||
for (i=0 ; i<3 ; i++)
|
|
||||||
chase_dest[i] = r_refdef.vieworg[i]
|
|
||||||
- forward[i]*(55 + deest * 22)
|
|
||||||
- right[i]*0;
|
|
||||||
// chase_dest[2] = r_refdef.vieworg[2];
|
|
||||||
|
|
||||||
|
dontspinme = 1;
|
||||||
|
|
||||||
|
for (i=0 ; i<3 ; i++)
|
||||||
|
chase_dest[i] = r_refdef.vieworg[i] - forward[i]*(55 + deest * 22) - right[i]*0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
chase_dest[i] = r_refdef.vieworg[i]
|
chase_dest[i] = r_refdef.vieworg[i] - forward[i]*chase_back->value - right[i]*chase_right->value;
|
||||||
- forward[i]*chase_back->value
|
|
||||||
- right[i]*chase_right->value;
|
|
||||||
chase_dest[2] = r_refdef.vieworg[2] + chase_up->value;
|
chase_dest[2] = r_refdef.vieworg[2] + chase_up->value;
|
||||||
dontspinme = 1;
|
dontspinme = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the spot the player is looking at
|
// find the spot the player is looking at
|
||||||
VectorMA (r_refdef.vieworg, 4096, forward, dest);
|
VectorMA (r_refdef.vieworg, 4096, forward, dest);
|
||||||
TraceLine (r_refdef.vieworg, dest, stop);
|
TraceLine (r_refdef.vieworg, dest, stop);
|
||||||
|
@ -239,38 +157,36 @@ void Chase_Update (void)
|
||||||
if (dontspinme) // leilei - allow spin....
|
if (dontspinme) // leilei - allow spin....
|
||||||
r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180;
|
r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180;
|
||||||
|
|
||||||
if (deathcam_yesiamdead){
|
|
||||||
|
|
||||||
// The..... style?
|
// The..... style?
|
||||||
if (deathcam_yesiamdead == 1){
|
if (deathcam_yesiamdead == 1)
|
||||||
|
{
|
||||||
r_refdef.viewangles[YAW] = deathcam_angles[YAW];
|
r_refdef.viewangles[YAW] = deathcam_angles[YAW];
|
||||||
r_refdef.viewangles[PITCH] = deathcam_angles[PITCH];
|
r_refdef.viewangles[PITCH] = deathcam_angles[PITCH];
|
||||||
r_refdef.viewangles[ROLL] = deathcam_angles[ROLL];
|
r_refdef.viewangles[ROLL] = deathcam_angles[ROLL];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The Q3 style - fixed pitch and yaw
|
// The Q3 style - fixed pitch and yaw
|
||||||
else if (deathcam_yesiamdead == 2){
|
else if (deathcam_yesiamdead == 2)
|
||||||
|
{
|
||||||
r_refdef.viewangles[YAW] = cl.viewangles[YAW];
|
r_refdef.viewangles[YAW] = cl.viewangles[YAW];
|
||||||
r_refdef.viewangles[PITCH] = 0;
|
r_refdef.viewangles[PITCH] = 0;
|
||||||
r_refdef.viewangles[ROLL] = 0;
|
r_refdef.viewangles[ROLL] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The U style
|
// The U style
|
||||||
else if (deathcam_yesiamdead == 3){
|
else if (deathcam_yesiamdead == 3)
|
||||||
|
{
|
||||||
r_refdef.viewangles[YAW] = deathcam_angles[YAW];
|
r_refdef.viewangles[YAW] = deathcam_angles[YAW];
|
||||||
r_refdef.viewangles[PITCH] = deathcam_angles[PITCH];
|
r_refdef.viewangles[PITCH] = deathcam_angles[PITCH];
|
||||||
r_refdef.viewangles[ROLL] = deathcam_angles[ROLL];
|
r_refdef.viewangles[ROLL] = deathcam_angles[ROLL];
|
||||||
}
|
}
|
||||||
|
|
||||||
// The DX style
|
// The DX style
|
||||||
else if (deathcam_yesiamdead == 4){
|
else if (deathcam_yesiamdead == 4)
|
||||||
if (deest < 1){
|
{
|
||||||
|
if (deest < 1)
|
||||||
|
{
|
||||||
r_refdef.viewangles[YAW] = cl.viewangles[YAW];
|
r_refdef.viewangles[YAW] = cl.viewangles[YAW];
|
||||||
r_refdef.viewangles[PITCH] = 0;
|
r_refdef.viewangles[PITCH] = 0;
|
||||||
r_refdef.viewangles[ROLL] = 0;
|
r_refdef.viewangles[ROLL] = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -279,18 +195,16 @@ void Chase_Update (void)
|
||||||
r_refdef.viewangles[ROLL] = deest * 18;
|
r_refdef.viewangles[ROLL] = deest * 18;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 2000-01-09 ChaseCam fix by FrikaC start
|
r_refdef.viewangles[YAW] += (int)chase_yaw->value;
|
||||||
|
r_refdef.viewangles[PITCH] += (int)chase_pitch->value;
|
||||||
|
r_refdef.viewangles[ROLL] += (int)chase_roll->value;
|
||||||
|
|
||||||
TraceLine(r_refdef.vieworg, chase_dest, stop);
|
TraceLine(r_refdef.vieworg, chase_dest, stop);
|
||||||
if (Length(stop) != 0)
|
if (Length(stop) != 0)
|
||||||
{
|
{
|
||||||
VectorCopy(stop, chase_dest);
|
VectorCopy(stop, chase_dest);
|
||||||
}
|
}
|
||||||
// 2000-01-09 ChaseCam fix by FrikaC end
|
|
||||||
|
|
||||||
// move towards destination
|
|
||||||
VectorCopy (chase_dest, r_refdef.vieworg);
|
VectorCopy (chase_dest, r_refdef.vieworg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in a new issue