git-svn-id: https://svn.eduke32.com/eduke32@208 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2006-07-04 05:46:38 +00:00
parent d25cf07e54
commit d826db409e
3 changed files with 48 additions and 26 deletions

View file

@ -71,7 +71,9 @@ long usemodels=1, usehightile=1;
float foggymcfogfogger; float foggymcfogfogger;
float fogtable[] = { 0.132, 0.165, 0.198, 0.231, 0.264, 0.297, 0.330, 0.363, 0.396, 0.429, 0.462, 0.495, 0.528, 0.561, 0.594, 0.627, 0.660, 0.693, 0.726, 0.759, 0.792, 0.825, 0.858, 0.891, 0.924, 0.957, 1.023, 1.056, 1.089, 1.122, 1.155, 1.188 }; // float fogtable[] = { 0.132, 0.165, 0.198, 0.231, 0.264, 0.297, 0.330, 0.363, 0.396, 0.429, 0.462, 0.495, 0.528, 0.561, 0.594, 0.627, 0.660, 0.693, 0.726, 0.759, 0.792, 0.825, 0.858, 0.891, 0.924, 0.957, 1.023, 1.056, 1.089, 1.122, 1.155, 1.188 };
float fogtable[] = { 0.125, 0.150, 0.175, 0.200, 0.225, 0.250, 0.275, 0.300, 0.325, 0.350, 0.375, 0.400, 0.425, 0.450, 0.475, 0.500, 0.525, 0.550, 0.575, 0.600, 0.625, 0.650, 0.675, 0.700, 0.725, 0.750, 0.775, 0.800, 0.825, 0.850, 0.875, 0.900 };
#include <math.h> //<-important! #include <math.h> //<-important!
typedef struct { float x, cy[2], fy[2]; long n, p, tag, ctag, ftag; } vsptyp; typedef struct { float x, cy[2], fy[2]; long n, p, tag, ctag, ftag; } vsptyp;
@ -2374,7 +2376,7 @@ static void polymost_drawalls (long bunch)
{ {
int i = klabs(sec->floorshade); int i = klabs(sec->floorshade);
if(i > 30) i = 30; if(i > 30) i = 30;
bglFogf(GL_FOG_DENSITY,gvisibility/(sec->floorshade<0?klabs(sec->floorshade):1)*(sec->floorshade<0?fogtable[0]:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16)))); bglFogf(GL_FOG_DENSITY,gvisibility/(sec->floorshade<0?i<<1:1)*(sec->floorshade<0?1:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16))));
} }
pow2xsplit = 0; domost(x0,fy0,x1,fy1); //flor pow2xsplit = 0; domost(x0,fy0,x1,fy1); //flor
bglFogf(GL_FOG_DENSITY,foggymcfogfogger); bglFogf(GL_FOG_DENSITY,foggymcfogfogger);
@ -2734,7 +2736,7 @@ static void polymost_drawalls (long bunch)
{ {
int i = klabs(sec->ceilingshade); int i = klabs(sec->ceilingshade);
if(i > 30) i = 30; if(i > 30) i = 30;
bglFogf(GL_FOG_DENSITY,gvisibility/(sec->ceilingshade<0?klabs(sec->ceilingshade):1)*(sec->ceilingshade<0?fogtable[0]:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16)))); bglFogf(GL_FOG_DENSITY,gvisibility/(sec->ceilingshade<0?i<<1:1)*(sec->ceilingshade<0?1:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16))));
} }
pow2xsplit = 0; domost(x1,cy1,x0,cy0); //ceil pow2xsplit = 0; domost(x1,cy1,x0,cy0); //ceil
bglFogf(GL_FOG_DENSITY,foggymcfogfogger); bglFogf(GL_FOG_DENSITY,foggymcfogfogger);
@ -3066,7 +3068,7 @@ static void polymost_drawalls (long bunch)
int i = klabs(wal->shade); int i = klabs(wal->shade);
if(i > 30) i = 30; if(i > 30) i = 30;
bglGetFloatv(GL_FOG_DENSITY,&foggymcfogfogger); bglGetFloatv(GL_FOG_DENSITY,&foggymcfogfogger);
bglFogf(GL_FOG_DENSITY,gvisibility/(wal->shade<0?klabs(wal->shade):1)*(wal->shade<0?fogtable[0]:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16)))); bglFogf(GL_FOG_DENSITY,gvisibility/(wal->shade<0?i<<1:1)*(wal->shade<0?1:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16))));
pow2xsplit = 1; domost(x1,ocy1,x0,ocy0); pow2xsplit = 1; domost(x1,ocy1,x0,ocy0);
bglFogf(GL_FOG_DENSITY,foggymcfogfogger); bglFogf(GL_FOG_DENSITY,foggymcfogfogger);
} }
@ -3109,7 +3111,7 @@ static void polymost_drawalls (long bunch)
int i = klabs(nwal->shade); int i = klabs(nwal->shade);
if(i > 30) i = 30; if(i > 30) i = 30;
bglGetFloatv(GL_FOG_DENSITY,&foggymcfogfogger); bglGetFloatv(GL_FOG_DENSITY,&foggymcfogfogger);
bglFogf(GL_FOG_DENSITY,gvisibility/(nwal->shade<0?klabs(nwal->shade):1)*(nwal->shade<0?fogtable[0]:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16)))); bglFogf(GL_FOG_DENSITY,gvisibility/(nwal->shade<0?i<<1:1)*(nwal->shade<0?1:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16))));
pow2xsplit = 1; domost(x0,ofy0,x1,ofy1); pow2xsplit = 1; domost(x0,ofy0,x1,ofy1);
bglFogf(GL_FOG_DENSITY,foggymcfogfogger); bglFogf(GL_FOG_DENSITY,foggymcfogfogger);
} }
@ -3148,7 +3150,7 @@ static void polymost_drawalls (long bunch)
int i = klabs(wal->shade); int i = klabs(wal->shade);
if(i > 30) i = 30; if(i > 30) i = 30;
bglGetFloatv(GL_FOG_DENSITY,&foggymcfogfogger); bglGetFloatv(GL_FOG_DENSITY,&foggymcfogfogger);
bglFogf(GL_FOG_DENSITY,gvisibility/(wal->shade<0?klabs(wal->shade):1)*(wal->shade<0?fogtable[0]:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16)))); bglFogf(GL_FOG_DENSITY,gvisibility/(wal->shade<0?i<<1:1)*(wal->shade<0?1:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16))));
pow2xsplit = 1; domost(x0,-10000,x1,-10000); pow2xsplit = 1; domost(x0,-10000,x1,-10000);
bglFogf(GL_FOG_DENSITY,foggymcfogfogger); bglFogf(GL_FOG_DENSITY,foggymcfogfogger);
} }
@ -3606,7 +3608,7 @@ if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0;
{ {
int i = klabs(wal->shade); int i = klabs(wal->shade);
if(i > 30) i = 30; if(i > 30) i = 30;
bglFogf(GL_FOG_DENSITY,gvisibility/(wal->shade<0?klabs(wal->shade):1)*(wal->shade<0?fogtable[0]:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16)))); bglFogf(GL_FOG_DENSITY,gvisibility/(wal->shade<0?i<<1:1)*(wal->shade<0?1:fogtable[i]*3.5)*((float)((unsigned char)(sec->visibility+16))));
} }
} }
} }
@ -3717,7 +3719,7 @@ if (tspr->cstat&2) { if (!(tspr->cstat&512)) method = 2+4; else method = 3+4; }
{ {
int i = klabs(globalshade); int i = klabs(globalshade);
if(i > 30) i = 30; if(i > 30) i = 30;
bglFogf(GL_FOG_DENSITY,gvisibility/(globalshade<0?klabs(globalshade):1)*(globalshade<0?fogtable[0]:fogtable[i]*3.5)*((float)((unsigned char)(sector[tspr->sectnum].visibility+16)))); bglFogf(GL_FOG_DENSITY,gvisibility/(globalshade<0?i<<1:1)*(globalshade<0?1:fogtable[i]*2.5)*((float)((unsigned char)(sector[tspr->sectnum].visibility+16))));
} }
} }

View file

@ -37,7 +37,7 @@ CXX=g++
# -Werror-implicit-function-declaration # -Werror-implicit-function-declaration
OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wunused \ OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wunused \
-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -DNOCOPYPROTECT \ -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -DNOCOPYPROTECT \
-I$(INC:/=) -I$(EINC:/=) -I$(SRC)jmact -I$(SRC)jaudiolib -I../jfaud/src -I$(INC:/=) -I$(EINC:/=) -I$(SRC)jmact -I$(SRC)jaudiolib -I../jfaud/inc
OURCXXFLAGS=-fno-exceptions -fno-rtti OURCXXFLAGS=-fno-exceptions -fno-rtti
LIBS=-lm LIBS=-lm
ifneq (0,$(JFAUD)) ifneq (0,$(JFAUD))

View file

@ -46,7 +46,11 @@ typedef uint64 uint64_t;
#define SOUNDM_NICE 64 // Added for JFDuke3D so JFAud doesn't use nearest filtering for the sound #define SOUNDM_NICE 64 // Added for JFDuke3D so JFAud doesn't use nearest filtering for the sound
#define SOUNDM_PLAYER 128 #define SOUNDM_PLAYER 128
#define UNITSPERMETRE 512.0 #define UNITSPERMETRE 1024.0
#define DEFAULTREFDIST 6.5 // in the original code, ((255-150)<<6) == 6720
#define DEFAULTMAXDIST 30.0 // in the original code, 31444
#define DEFAULTROLLOFF 1.0//0.75
#define OCCLUDEDFACTOR 0.8
#include <cmath> #include <cmath>
@ -314,7 +318,7 @@ int isspritemakingsound(short i, int num) // if num<0, check if making any sound
return n; return n;
} }
int issoundplaying(int num) int issoundplaying(short i, int num)
{ {
int j,n=0; int j,n=0;
@ -331,7 +335,7 @@ int xyzsound(short num, short i, long x, long y, long z)
{ {
JFAudMixerChannel *chan; JFAudMixerChannel *chan;
int r, global = 0; int r, global = 0;
float gain = 1.0, pitch = 1.0; float gain = 1.0, pitch = 1.0, refdist = DEFAULTREFDIST, maxdist = DEFAULTMAXDIST, rolloff = DEFAULTROLLOFF;
if (!jfaud || !havewave || if (!jfaud || !havewave ||
num >= NUM_SOUNDS || num >= NUM_SOUNDS ||
@ -360,7 +364,12 @@ int xyzsound(short num, short i, long x, long y, long z)
} }
} }
// XXX: here goes musicandsfx ranging. This will change the refdist. if( i >= 0 && !(soundm[num] & SOUNDM_GLOBAL) && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9) {
float d = (float)SHT/UNITSPERMETRE;
refdist = d / 2.0;
maxdist = d;
rolloff = 1.0;
}
{ {
int ps = soundps[num], pe = soundpe[num], cx; int ps = soundps[num], pe = soundpe[num], cx;
@ -371,11 +380,15 @@ int xyzsound(short num, short i, long x, long y, long z)
} else pitch = translatepitch(ps); } else pitch = translatepitch(ps);
} }
//gain += soundvo[num]; {
float d = 1.0-(float)soundvo[num]/(12.0*1024.0);
maxdist *= d;
refdist *= d;
}
if (PN != MUSICANDSFX && if (PN != MUSICANDSFX &&
!cansee(ps[screenpeek].oposx,ps[screenpeek].oposy,ps[screenpeek].oposz-(24<<8), !cansee(ps[screenpeek].oposx,ps[screenpeek].oposy,ps[screenpeek].oposz-(24<<8),
ps[screenpeek].cursectnum,SX,SY,SZ-(24<<8),SECT) ) ps[screenpeek].cursectnum,SX,SY,SZ-(24<<8),SECT) )
gain *= 1.0/32.0; gain *= OCCLUDEDFACTOR;
switch(num) switch(num)
{ {
@ -409,8 +422,10 @@ int xyzsound(short num, short i, long x, long y, long z)
chan->SetGain(gain); chan->SetGain(gain);
chan->SetPitch(pitch); chan->SetPitch(pitch);
chan->SetLoop(soundm[num] & SOUNDM_LOOP); chan->SetLoop((soundm[num] & SOUNDM_LOOP) == SOUNDM_LOOP);
if (soundm[num] & SOUNDM_GLOBAL) global = 1; if (soundm[num] & SOUNDM_GLOBAL) global = 1;
chan->SetRefDist(refdist);
chan->SetMaxDist(maxdist);
chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : JFAudMixerChannel::FilterNearest); chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : JFAudMixerChannel::FilterNearest);
if (PN == APLAYER && sprite[i].yvel == screenpeek) { if (PN == APLAYER && sprite[i].yvel == screenpeek) {
@ -418,11 +433,12 @@ int xyzsound(short num, short i, long x, long y, long z)
chan->SetFollowListener(true); chan->SetFollowListener(true);
chan->SetPosition(0.0, 0.0, 0.0); chan->SetPosition(0.0, 0.0, 0.0);
} else { } else {
chan->SetRolloff(global ? 0.0 : 1.0); chan->SetRolloff(global ? 0.0 : rolloff);
chan->SetFollowListener(false); chan->SetFollowListener(false);
chan->SetPosition((float)x/UNITSPERMETRE, (float)(-z>>4)/UNITSPERMETRE, (float)y/UNITSPERMETRE); chan->SetPosition((float)x/UNITSPERMETRE, (float)(-z>>4)/UNITSPERMETRE, (float)y/UNITSPERMETRE);
} }
initprintf("%d gain=%g ptch=%g loop=%d glob=%d refd=%g maxd=%g\n",num,gain,pitch,
(soundm[num] & SOUNDM_LOOP) == SOUNDM_LOOP, global, refdist, maxdist);
r = keephandle(chan, num, i); r = keephandle(chan, num, i);
if (r >= 0) chan->SetStopCallback(stopcallback, r); if (r >= 0) chan->SetStopCallback(stopcallback, r);
chan->Play(); chan->Play();
@ -457,8 +473,9 @@ void sound(short num)
chan->SetGain(1.0); chan->SetGain(1.0);
chan->SetPitch(pitch); chan->SetPitch(pitch);
chan->SetLoop(soundm[num] & SOUNDM_LOOP); chan->SetLoop((soundm[num] & SOUNDM_LOOP) == SOUNDM_LOOP);
chan->SetRolloff(0.0); chan->SetRolloff(0.0);
chan->SetRefDist(DEFAULTREFDIST);
chan->SetFollowListener(true); chan->SetFollowListener(true);
chan->SetPosition(0.0, 0.0, 0.0); chan->SetPosition(0.0, 0.0, 0.0);
chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : JFAudMixerChannel::FilterNearest); chan->SetFilter((soundm[num]&SOUNDM_NICE) ? JFAudMixerChannel::Filter4Point : JFAudMixerChannel::FilterNearest);
@ -524,7 +541,7 @@ void pan3dsound(void)
short i; short i;
long cx, cy, cz, sx,sy,sz; long cx, cy, cz, sx,sy,sz;
short ca,cs; short ca,cs;
float gain; float gain, rolloff;
numenvsnds = 0; numenvsnds = 0;
if (!jfaud || !havewave) return; if (!jfaud || !havewave) return;
@ -556,17 +573,20 @@ void pan3dsound(void)
global = 0; global = 0;
gain = 1.0; gain = 1.0;
rolloff = DEFAULTROLLOFF;
i = chans[j].owner; i = chans[j].owner;
sx = sprite[i].x; sx = sprite[i].x;
sy = sprite[i].y; sy = sprite[i].y;
sz = sprite[i].z; sz = sprite[i].z;
//gain += soundvo[num];
if (PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT) ) if (PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,sx,sy,sz-(24<<8),SECT) )
gain *= 1.0/32.0; gain *= OCCLUDEDFACTOR;
if(PN == MUSICANDSFX && SLT < 999) numenvsnds++; if(PN == MUSICANDSFX && SLT < 999) {
numenvsnds++;
rolloff = 1.0;
}
if( soundm[ chans[j].soundnum ]&SOUNDM_GLOBAL ) global = 1; if( soundm[ chans[j].soundnum ]&SOUNDM_GLOBAL ) global = 1;
switch(chans[j].soundnum) { switch(chans[j].soundnum) {
@ -592,7 +612,7 @@ void pan3dsound(void)
chans[j].chan->SetFollowListener(true); chans[j].chan->SetFollowListener(true);
chans[j].chan->SetPosition(0.0, 0.0, 0.0); chans[j].chan->SetPosition(0.0, 0.0, 0.0);
} else { } else {
chans[j].chan->SetRolloff(global ? 0.0 : 1.0); chans[j].chan->SetRolloff(global ? 0.0 : rolloff);
chans[j].chan->SetFollowListener(false); chans[j].chan->SetFollowListener(false);
chans[j].chan->SetPosition((float)sx/UNITSPERMETRE, (float)(-sz>>4)/UNITSPERMETRE, (float)sy/UNITSPERMETRE); chans[j].chan->SetPosition((float)sx/UNITSPERMETRE, (float)(-sz>>4)/UNITSPERMETRE, (float)sy/UNITSPERMETRE);
} }