mirror of https://github.com/bjornbytes/lovr.git
Audio fixes;
This commit is contained in:
parent
9cbfeb0bf4
commit
d2d28e6100
|
@ -79,6 +79,14 @@ else()
|
||||||
set(LOVR_ASSIMP ${ASSIMP_LIBRARIES})
|
set(LOVR_ASSIMP ${ASSIMP_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# OpenAL
|
||||||
|
if (WIN32)
|
||||||
|
add_subdirectory(deps/openal-soft openal)
|
||||||
|
include_directories(deps/openal-soft/include)
|
||||||
|
set(LOVR_OPENAL OpenAL32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# openvr
|
# openvr
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
include_directories(deps/openvr/headers)
|
include_directories(deps/openvr/headers)
|
||||||
|
@ -109,6 +117,7 @@ set(LOVR_LIB
|
||||||
${LOVR_GLFW}
|
${LOVR_GLFW}
|
||||||
${LOVR_PHYSFS}
|
${LOVR_PHYSFS}
|
||||||
${LOVR_ASSIMP}
|
${LOVR_ASSIMP}
|
||||||
|
${LOVR_OPENAL}
|
||||||
${LOVR_OPENVR}
|
${LOVR_OPENVR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -120,4 +129,5 @@ if(WIN32)
|
||||||
move_dll(${LOVR_GLFW})
|
move_dll(${LOVR_GLFW})
|
||||||
move_dll(${LOVR_PHYSFS})
|
move_dll(${LOVR_PHYSFS})
|
||||||
move_dll(${LOVR_ASSIMP})
|
move_dll(${LOVR_ASSIMP})
|
||||||
|
move_dll(${LOVR_OPENAL})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -78,9 +78,16 @@ void lovrAudioGetOrientation(float* angle, float* ax, float* ay, float* az) {
|
||||||
float cx, cy, cz;
|
float cx, cy, cz;
|
||||||
cross(v[0], v[1], v[2], v[3], v[4], v[5], &cx, &cy, &cz);
|
cross(v[0], v[1], v[2], v[3], v[4], v[5], &cx, &cy, &cz);
|
||||||
float w = 1 + v[0] * v[3] + v[1] * v[4] + v[2] * v[5];
|
float w = 1 + v[0] * v[3] + v[1] * v[4] + v[2] * v[5];
|
||||||
|
float len = sqrt(cx * cx + cy * cy + cz * cz + w * w);
|
||||||
|
if (len != 1) {
|
||||||
|
cx /= len;
|
||||||
|
cy /= len;
|
||||||
|
cz /= len;
|
||||||
|
w /= len;
|
||||||
|
}
|
||||||
*angle = 2 * acos(w);
|
*angle = 2 * acos(w);
|
||||||
float s = sqrt(1 - w * w);
|
float s = sqrt(1 - w * w);
|
||||||
if (w < .001) {
|
if (s < .001) {
|
||||||
*ax = cx;
|
*ax = cx;
|
||||||
*ay = cy;
|
*ay = cy;
|
||||||
*az = cz;
|
*az = cz;
|
||||||
|
|
|
@ -141,9 +141,9 @@ void mat4_getRotation(mat4 matrix, float* w, float* x, float* y, float* z) {
|
||||||
float qx = sqrt(MAX(0, 1 + matrix[0] - matrix[5] - matrix[10])) / 2;
|
float qx = sqrt(MAX(0, 1 + matrix[0] - matrix[5] - matrix[10])) / 2;
|
||||||
float qy = sqrt(MAX(0, 1 - matrix[0] + matrix[5] - matrix[10])) / 2;
|
float qy = sqrt(MAX(0, 1 - matrix[0] + matrix[5] - matrix[10])) / 2;
|
||||||
float qz = sqrt(MAX(0, 1 - matrix[0] - matrix[5] + matrix[10])) / 2;
|
float qz = sqrt(MAX(0, 1 - matrix[0] - matrix[5] + matrix[10])) / 2;
|
||||||
qx = (matrix[9] - matrix[6]) < 0 ? -qx : qx;
|
qx = (matrix[9] - matrix[6]) > 0 ? -qx : qx;
|
||||||
qy = (matrix[2] - matrix[8]) < 0 ? -qy : qy;
|
qy = (matrix[2] - matrix[8]) > 0 ? -qy : qy;
|
||||||
qz = (matrix[4] - matrix[1]) < 0 ? -qz : qz;
|
qz = (matrix[4] - matrix[1]) > 0 ? -qz : qz;
|
||||||
|
|
||||||
float s = sqrt(1 - qw * qw);
|
float s = sqrt(1 - qw * qw);
|
||||||
s = s < .001 ? 1 : s;
|
s = s < .001 ? 1 : s;
|
||||||
|
|
Loading…
Reference in New Issue