Audio fixes;

This commit is contained in:
bjorn 2017-01-06 18:43:24 -08:00
parent 9cbfeb0bf4
commit d2d28e6100
3 changed files with 21 additions and 4 deletions

View File

@ -79,6 +79,14 @@ else()
set(LOVR_ASSIMP ${ASSIMP_LIBRARIES})
endif()
# OpenAL
if (WIN32)
add_subdirectory(deps/openal-soft openal)
include_directories(deps/openal-soft/include)
set(LOVR_OPENAL OpenAL32)
endif()
# openvr
if(WIN32)
include_directories(deps/openvr/headers)
@ -109,6 +117,7 @@ set(LOVR_LIB
${LOVR_GLFW}
${LOVR_PHYSFS}
${LOVR_ASSIMP}
${LOVR_OPENAL}
${LOVR_OPENVR}
)
@ -120,4 +129,5 @@ if(WIN32)
move_dll(${LOVR_GLFW})
move_dll(${LOVR_PHYSFS})
move_dll(${LOVR_ASSIMP})
move_dll(${LOVR_OPENAL})
endif()

View File

@ -78,9 +78,16 @@ void lovrAudioGetOrientation(float* angle, float* ax, float* ay, float* az) {
float 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 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);
float s = sqrt(1 - w * w);
if (w < .001) {
if (s < .001) {
*ax = cx;
*ay = cy;
*az = cz;

View File

@ -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 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;
qx = (matrix[9] - matrix[6]) < 0 ? -qx : qx;
qy = (matrix[2] - matrix[8]) < 0 ? -qy : qy;
qz = (matrix[4] - matrix[1]) < 0 ? -qz : qz;
qx = (matrix[9] - matrix[6]) > 0 ? -qx : qx;
qy = (matrix[2] - matrix[8]) > 0 ? -qy : qy;
qz = (matrix[4] - matrix[1]) > 0 ? -qz : qz;
float s = sqrt(1 - qw * qw);
s = s < .001 ? 1 : s;