summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/spatial.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/spatial.c b/src/spatial.c
index 9885418..654ef0b 100644
--- a/src/spatial.c
+++ b/src/spatial.c
@@ -78,15 +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_vect,
- axis_vect;
-
- diff(&apex_to_x_vect, cone.apex, coord);
- diff(&axis_vect, cone.apex, cone.base);
-
- return dotf(apex_to_x_vect, axis_vect)
- / magnf(apex_to_x_vect)
- / magnf(axis_vect) > cosf(cone.angle / 2.0f);
+ xas_spatial_coord apex_to_point_vect,
+ axis_vect,
+ rotated = cone.apex,
+ opposite = {
+ .x = cone.rotation.x * -2.0f,
+ .y = cone.rotation.y * -2.0f,
+ .z = cone.rotation.z * -2.0f
+ };
+
+ rotate(opposite, &rotated);
+
+ diff(&apex_to_point_vect, cone.apex, coord);
+ diff(&axis_vect, cone.apex, rotated);
+
+ return dotf(apex_to_point_vect, axis_vect)
+ / magnf(apex_to_point_vect)
+ / magnf(axis_vect) <= cosf(cone.angle / 2.0f);
}
static int buffer_realloc(xas_spatial_scene *scene,
@@ -178,13 +186,13 @@ ssize_t scene_fill(xas_spatial_scene *scene,
int16_t *dest = (int16_t *)(scene->buffer + 1);
xas_spatial_cone cone_l = {
- .apex = scene->speaker_l,
- .base = { scene->speaker_l.x - 20.0f, scene->speaker_l.y, scene->speaker_l.z },
- .angle = M_PI / 4.0f
+ .apex = scene->speaker_l,
+ .rotation = { 0.0f, M_PI * 1.5f, 0.0f },
+ .angle = M_PI / 4.0f
}, cone_r = {
- .apex = scene->speaker_r,
- .base = { scene->speaker_r.x + 20.0f, scene->speaker_r.y, scene->speaker_r.z },
- .angle = M_PI / 4.0f
+ .apex = scene->speaker_r,
+ .rotation = { 0.0f, M_PI * 0.5f, 0.0f },
+ .angle = M_PI / 4.0f
};
buffer_zero(buffer, count);