From 721ffeb765b01cfaba4a464de8e343937bc1cc99 Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Sun, 17 Dec 2023 02:13:25 -0600 Subject: [PATCH] limit indefinite r-tree growth --- server/src/main.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 661e77f..f81eb73 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -258,20 +258,26 @@ fn process_turtle_update( turtle.position.0 += turtle.queued_movement; } - world.insert(Block { + let above = Block { name: update.above, pos: turtle.position.0 + Vec3::y(), - }); + }; + world.remove_at_point(&above.pos.into()); + world.insert(above); - world.insert(Block { + let ahead = Block { name: update.ahead, pos: turtle.position.0 + turtle.position.1.clone().unit(), - }); + }; + world.remove_at_point(&ahead.pos.into()); + world.insert(ahead); - world.insert(Block { + let below = Block { name: update.below, pos: turtle.position.0 - Vec3::y(), - }); + }; + world.remove_at_point(&below.pos.into()); + world.insert(below); turtle.queued_movement = turtle.position.1.clone().unit();