Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c1c108f5
Commit
c1c108f5
authored
Mar 22, 2015
by
Stas Cymbalov
Committed by
Alexandre Julliard
Apr 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Fix angle to sound source calculation.
parent
f991b70d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
sound3d.c
dlls/dsound/sound3d.c
+14
-11
No files found.
dlls/dsound/sound3d.c
View file @
c1c108f5
...
...
@@ -112,7 +112,6 @@ static inline D3DVALUE AngleBetweenVectorsRad (const D3DVECTOR *a, const D3DVECT
cos
=
product
/
(
la
*
lb
);
angle
=
acos
(
cos
);
if
(
cos
<
0
.
0
f
)
{
angle
-=
M_PI
;
}
TRACE
(
"angle between (%f,%f,%f) and (%f,%f,%f) = %f radians (%f degrees)
\n
"
,
a
->
x
,
a
->
y
,
a
->
z
,
b
->
x
,
b
->
y
,
b
->
z
,
angle
,
RadToDeg
(
angle
));
return
angle
;
...
...
@@ -264,16 +263,20 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
else
{
vLeft
=
VectorProduct
(
&
dsb
->
device
->
ds3dl
.
vOrientFront
,
&
dsb
->
device
->
ds3dl
.
vOrientTop
);
flAngle
=
AngleBetweenVectorsRad
(
&
dsb
->
device
->
ds3dl
.
vOrientFront
,
&
vDistance
);
flAngle2
=
AngleBetweenVectorsRad
(
&
vLeft
,
&
vDistance
);
/* AngleBetweenVectorsRad performs a dot product, which gives us the cosine of the angle
* between two vectors. Unfortunately, because cos(theta) = cos(-theta), we've no idea from
* this whether the sound is to our left or to our right. We have to perform another dot
* product, with a vector at right angles to the initial one, to get the correct angle.
* The angle should be between -180 degrees and 180 degrees. */
if
(
flAngle
<
0
.
0
f
)
{
flAngle
+=
M_PI
;
}
if
(
flAngle2
>
0
.
0
f
)
{
flAngle
=
-
flAngle
;
}
/* To calculate angle to sound source we need to:
* 1) Get angle between vDistance and a plane on which angle to sound source should be 0.
* Such a plane is given by vectors vOrientFront and vOrientTop, and angle between vector
* and a plane equals to M_PI_2 - angle between vector and normal to this plane (vLeft in this case).
* 2) Determine if the source is behind or in front of us by calculating angle between vDistance
* and vOrientFront.
*/
flAngle
=
AngleBetweenVectorsRad
(
&
vLeft
,
&
vDistance
);
flAngle2
=
AngleBetweenVectorsRad
(
&
dsb
->
device
->
ds3dl
.
vOrientFront
,
&
vDistance
);
if
(
flAngle2
>
M_PI_2
)
flAngle
=
-
flAngle
;
flAngle
-=
M_PI_2
;
if
(
flAngle
<
-
M_PI
)
flAngle
+=
2
*
M_PI
;
}
TRACE
(
"panning: Angle = %f rad, lPan = %d
\n
"
,
flAngle
,
dsb
->
volpan
.
lPan
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment