From 15e370b5e025ecd11f82a6a15dab25c81fc586fc Mon Sep 17 00:00:00 2001 From: leonmavr <0xleo.git@gmail.com> Date: Mon, 16 Sep 2024 14:28:07 +0200 Subject: [PATCH] Adjust flush refresh rate --- main.c | 4 ++-- src/quad.c | 4 ++-- src/viz.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 952eb57..136eb4b 100644 --- a/main.c +++ b/main.c @@ -52,7 +52,7 @@ int main() { particles[ip].vely = CLAMP(particles[ip].vely, 40); particles[ip].point.x += particles[ip].velx * dt; particles[ip].point.y += particles[ip].vely * dt; - // reflection + // reflection left and right, wrapping up and down particles[ip].point.x %= boundary.x1; particles[ip].point.y %= boundary.y1; if (particles[ip].point.x <= boundary.x0) @@ -64,9 +64,9 @@ int main() { } qtree_graph(qtree.root); viz_flush(); - usleep(33000); qtree_delete(qtree.root); } + free(qtree.root); sleep(1); viz_close(); } diff --git a/src/quad.c b/src/quad.c index 86d3e4b..5ebd2b5 100644 --- a/src/quad.c +++ b/src/quad.c @@ -46,8 +46,8 @@ int point_get_quadrant(rect_t* rect, point_t* point) { else if ((rect->x0 + w/2 <= x) && (x < rect->x1) && (rect->y0 <= y) && (y < rect->y0 + h/2)) return IND_NE; else if ((rect->x0 + w/2 <= x) && (x < rect->x1) && (rect->y0 + h/2 <= y) && (y < rect->y1)) - return IND_SE; - else if ((rect->x0 <= x) && (x < rect->x0 + w/2) && (rect->y0 + h/2 <= y) && (y < rect->y1)) + return IND_SE; +else if ((rect->x0 <= x) && (x < rect->x0 + w/2) && (rect->y0 + h/2 <= y) && (y < rect->y1)) return IND_SW; return -1; // error - not in rectangle } diff --git a/src/viz.c b/src/viz.c index 4311437..a33e61a 100644 --- a/src/viz.c +++ b/src/viz.c @@ -42,7 +42,7 @@ void viz_flush() { fprintf(viz_plot_pipe, "replot\n"); irect = ipoint = 0; fflush(viz_plot_pipe); - usleep(16000); + usleep(25000); }