Commit 53b5a474 authored by Rok Mandeljc's avatar Rok Mandeljc Committed by Alexandre Julliard

Changed some stuff so distance attenuation works for both 3d

processing modes.
parent d04ccb8e
......@@ -174,16 +174,30 @@ static void WINAPI DSOUND_Mix3DBuffer(IDirectSound3DBufferImpl *ds3db)
dsl = ds3db->dsb->dsound->listener;
/* FIXME: i guess initial volume should be that, but if it's set, sounds get too quiet */
/* FIXME: i guess initial volume should be that, but if it's set, sounds get too quiet.
It makes sense, though: at min. distance we hear sound with practically no
attuneation. If someone has idea, please do it.*/
/* lVolume = ds3db->lVolume; */
switch (ds3db->ds3db.dwMode)
{
case DS3DMODE_DISABLE:
TRACE("3D processing disabled\n");
DSOUND_RecalcVolPan (&ds3db->dsb->volpan);
DSOUND_ForceRemix (ds3db->dsb);
break;
case DS3DMODE_NORMAL:
{
/* distance attuneation stuff */
TRACE("Normal 3D processing mode\n");
/* we need to calculate distance between buffer and listener*/
vDistance = VectorBetweenTwoPoints(&ds3db->ds3db.vPosition, &dsl->ds3dl.vPosition);
flDistance = VectorMagnitude (&vDistance);
break;
case DS3DMODE_HEADRELATIVE:
TRACE("Head-relative 3D processing mode\n");
/* distance between buffer and listener is same as buffer's position */
flDistance = VectorMagnitude (&ds3db->ds3db.vPosition);
break;
}
if (flDistance > ds3db->ds3db.flMaxDistance)
{
......@@ -198,9 +212,9 @@ static void WINAPI DSOUND_Mix3DBuffer(IDirectSound3DBufferImpl *ds3db)
else
flDistance = ds3db->ds3db.flMaxDistance;
}
if (flDistance < ds3db->ds3db.flMinDistance)
flDistance = ds3db->ds3db.flMinDistance;
/* the following formula is taken from my physics book. I think it's ok for the *real* world...i hope m$ does it that way */
lVolume += 10000; /* ms likes working with negative volume...i don't */
lVolume /= 1000; /* convert hundreths of dB into B */
......@@ -212,21 +226,11 @@ static void WINAPI DSOUND_Mix3DBuffer(IDirectSound3DBufferImpl *ds3db)
lVolume *= 1000; /* convert back to hundreths of dB */
lVolume -= 10000; /* we need to do it in ms way */
TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %ld to %ld\n", flDistance, ds3db->ds3db.flMinDistance, ds3db->lVolume, lVolume);
/* add correct conning here */
/* at last, we got the desired volume */
ds3db->dsb->volpan.lVolume = lVolume;
DSOUND_RecalcVolPan (&ds3db->dsb->volpan);
DSOUND_ForceRemix (ds3db->dsb);
break;
}
case DS3DMODE_HEADRELATIVE:
case DS3DMODE_DISABLE:
DSOUND_RecalcVolPan (&ds3db->dsb->volpan);
DSOUND_ForceRemix (ds3db->dsb);
break;
}
}
static void WINAPI DSOUND_ChangeListener(IDirectSound3DListenerImpl *ds3dl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment