dsound: Fix 3D positioning bug with head-relative buffers.
This commit is contained in:
parent
530a039dac
commit
1c73ce1ee7
|
@ -181,13 +181,14 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
||||||
case DS3DMODE_NORMAL:
|
case DS3DMODE_NORMAL:
|
||||||
TRACE("Normal 3D processing mode\n");
|
TRACE("Normal 3D processing mode\n");
|
||||||
/* we need to calculate distance between buffer and listener*/
|
/* we need to calculate distance between buffer and listener*/
|
||||||
vDistance = VectorBetweenTwoPoints(&dsb->ds3db_ds3db.vPosition, &dsb->device->ds3dl.vPosition);
|
vDistance = VectorBetweenTwoPoints(&dsb->device->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
|
||||||
flDistance = VectorMagnitude (&vDistance);
|
flDistance = VectorMagnitude (&vDistance);
|
||||||
break;
|
break;
|
||||||
case DS3DMODE_HEADRELATIVE:
|
case DS3DMODE_HEADRELATIVE:
|
||||||
TRACE("Head-relative 3D processing mode\n");
|
TRACE("Head-relative 3D processing mode\n");
|
||||||
/* distance between buffer and listener is same as buffer's position */
|
/* distance between buffer and listener is same as buffer's position */
|
||||||
flDistance = VectorMagnitude (&dsb->ds3db_ds3db.vPosition);
|
vDistance = dsb->ds3db_ds3db.vPosition;
|
||||||
|
flDistance = VectorMagnitude (&vDistance);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,8 +221,14 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
D3DVECTOR vDistanceInv;
|
||||||
|
|
||||||
|
vDistanceInv.x = -vDistance.x;
|
||||||
|
vDistanceInv.y = -vDistance.y;
|
||||||
|
vDistanceInv.z = -vDistance.z;
|
||||||
|
|
||||||
/* calculate angle */
|
/* calculate angle */
|
||||||
flAngle = AngleBetweenVectorsDeg(&dsb->ds3db_ds3db.vConeOrientation, &vDistance);
|
flAngle = AngleBetweenVectorsDeg(&dsb->ds3db_ds3db.vConeOrientation, &vDistanceInv);
|
||||||
/* if by any chance it happens that OutsideConeAngle = InsideConeAngle (that means that conning has no effect) */
|
/* if by any chance it happens that OutsideConeAngle = InsideConeAngle (that means that conning has no effect) */
|
||||||
if (dsb->ds3db_ds3db.dwInsideConeAngle != dsb->ds3db_ds3db.dwOutsideConeAngle)
|
if (dsb->ds3db_ds3db.dwInsideConeAngle != dsb->ds3db_ds3db.dwOutsideConeAngle)
|
||||||
{
|
{
|
||||||
|
@ -254,14 +261,10 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* panning */
|
/* panning */
|
||||||
if (dsb->device->ds3dl.vPosition.x == dsb->ds3db_ds3db.vPosition.x &&
|
if (vDistance.x == 0.0f && vDistance.y == 0.0f && vDistance.z == 0.0f)
|
||||||
dsb->device->ds3dl.vPosition.y == dsb->ds3db_ds3db.vPosition.y &&
|
|
||||||
dsb->device->ds3dl.vPosition.z == dsb->ds3db_ds3db.vPosition.z) {
|
|
||||||
flAngle = 0.0;
|
flAngle = 0.0;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vDistance = VectorBetweenTwoPoints(&dsb->device->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
|
|
||||||
vLeft = VectorProduct(&dsb->device->ds3dl.vOrientFront, &dsb->device->ds3dl.vOrientTop);
|
vLeft = VectorProduct(&dsb->device->ds3dl.vOrientFront, &dsb->device->ds3dl.vOrientTop);
|
||||||
flAngle = AngleBetweenVectorsRad(&dsb->device->ds3dl.vOrientFront, &vDistance);
|
flAngle = AngleBetweenVectorsRad(&dsb->device->ds3dl.vOrientFront, &vDistance);
|
||||||
flAngle2 = AngleBetweenVectorsRad(&vLeft, &vDistance);
|
flAngle2 = AngleBetweenVectorsRad(&vLeft, &vDistance);
|
||||||
|
|
Loading…
Reference in New Issue