Skip to content

Commit

Permalink
When read-only, pass points by value
Browse files Browse the repository at this point in the history
  • Loading branch information
leonmavr committed Dec 12, 2024
1 parent c89a539 commit 561daf1
Show file tree
Hide file tree
Showing 4 changed files with 370 additions and 334 deletions.
4 changes: 2 additions & 2 deletions examples/01_particle_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main() {
}
for (int i = 0; i < niters; ++i) {
quadtree_t qtree;
qtree_new(&qtree, &boundary);
qtree_new(&qtree, boundary);
for (int ip = 0; ip < NPARTICLES; ++ip) {
particles[ip].velx += particles[ip].accelerationx * dt;
particles[ip].velx = CLAMP(particles[ip].velx, 20);
Expand All @@ -96,7 +96,7 @@ int main() {
if (particles[ip].point.y <= boundary.y0)
particles[ip].point.y = boundary.y1;
point_t pnew = {particles[ip].point.x , particles[ip].point.y, particles[ip].point.id};
qtree_insert(&qtree, &pnew);
qtree_insert(&qtree, pnew);
}
qtree_graph(&qtree);
viz.viz_flush();
Expand Down
8 changes: 4 additions & 4 deletions include/quad.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ typedef struct quadtree_t {
} quadtree_t;


void qtree_new(quadtree_t* qtree, rect_t* boundary);
void qtree_insert(quadtree_t* qtree, point_t* point);
void qtree_query(quadtree_t* qtree, rect_t* search_area, int* count);
double qtree_nearest_neighbor(quadtree_t* qtree, point_t* query, point_t* nearest);
void qtree_new(quadtree_t* qtree, rect_t boundary);
void qtree_insert(quadtree_t* qtree, point_t point);
void qtree_query(quadtree_t* qtree, rect_t search_area, int* count);
double qtree_nearest_neighbor(quadtree_t* qtree, point_t query, point_t* nearest);
void qtree_remove_point(quadtree_t* qtree, point_t* point);
void qtree_update_point(quadtree_t* qtree, point_t* old_point, point_t* new_point);
void qtree_merge(quadtree_t* qtree);
Expand Down
Loading

0 comments on commit 561daf1

Please sign in to comment.