From 08664e8d3f22e7d2885bef930f696e33c88827d6 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 22 Feb 2022 12:34:28 -0500 Subject: Holy shit we're in business --- src/spatial.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/spatial.c b/src/spatial.c index 791c6f9..4a93fdd 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -78,14 +78,23 @@ static void rotate(xas_spatial_coord rotation, static int within_cone(xas_spatial_coord coord, xas_spatial_cone cone) { - xas_spatial_coord apex_to_x; + xas_spatial_coord apex_to_x_vect, + axis_vect; - float cosf_angle = cosf(cone.angle / 2.0f); + int is_infinite; - diff(&apex_to_x, cone.coord, coord); + diff(&apex_to_x_vect, cone.apex, coord); + diff(&axis_vect, cone.apex, cone.base); - return dotf(apex_to_x, cone.rotation) / magnf(apex_to_x) / magnf(cone.rotation) - > cosf_angle; + is_infinite = dotf(apex_to_x_vect, axis_vect) + / magnf(apex_to_x_vect) + / magnf(axis_vect) > cosf(cone.angle / 2.0f); + + if (!is_infinite) { + return 0; + } + + return dotf(apex_to_x_vect, axis_vect) / magnf(axis_vect) < magnf(axis_vect); } static int buffer_realloc(xas_spatial_scene *scene, @@ -177,22 +186,12 @@ ssize_t scene_fill(xas_spatial_scene *scene, int16_t *dest = (int16_t *)(scene->buffer + 1); xas_spatial_cone cone_l = { - .coord = scene->speaker_l, - .rotation = { - .x = 0.0f, - .y = 0.5f * M_PI, - .z = 0.0f - }, - + .apex = scene->speaker_l, + .base = { scene->speaker_l.x - 20.0f, scene->speaker_l.y, scene->speaker_l.z }, .angle = M_PI / 4.0f }, cone_r = { - .coord = scene->speaker_r, - .rotation = { - .x = 0.0f, - .y = 1.5f * M_PI, - .z = 0.0f - }, - + .apex = scene->speaker_r, + .base = { scene->speaker_r.x + 20.0f, scene->speaker_r.y, scene->speaker_r.z }, .angle = M_PI / 4.0f }; -- cgit v1.2.3