From 204e2666262247e1c87e27808cac4652e443c5e1 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Fri, 11 Mar 2022 13:24:39 -0500 Subject: Save a few CPU cycles (the drones need 'em) --- src/spatial.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/spatial.c b/src/spatial.c index c79b8e8..fc13a53 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -255,6 +255,9 @@ ssize_t scene_fill(xas_spatial_scene *scene, size_t value_l, index_l, value_r, index_r; + int within_cone_l = within_cone(obj->point, cone_l), + within_cone_r = within_cone(obj->point, cone_r); + if (obj->speed != 0.0f) { xas_spatial_coord point = obj->point; @@ -269,16 +272,16 @@ ssize_t scene_fill(xas_spatial_scene *scene, value_l = sample_scale(src[i], obj->distance_l); value_r = sample_scale(src[i], obj->distance_r); - if (!within_cone(obj->point, cone_l)) { - if (within_cone(obj->point, cone_r)) { + if (!within_cone_l) { + if (within_cone_r) { value_l /= 8.0f; } else { value_l /= 3.0f; } } - if (!within_cone(obj->point, cone_r)) { - if (within_cone(obj->point, cone_l)) { + if (!within_cone_r) { + if (within_cone_l) { value_r /= 8.0f; } else { value_r /= 3.0f; -- cgit v1.2.3