From 60a5373b049169e6427f22bd3e7a80fdbf1df02d Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Tue, 27 Jul 2021 19:11:32 -0400 Subject: [PATCH] Avoid duplicate work across chunks when blitting site2 primitives. --- world/src/site2/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index 38dde808b2..eda9a6a6ef 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -756,6 +756,12 @@ impl Site { let mut plots_to_render = plots.into_iter().collect::>(); plots_to_render.sort_unstable(); + let wpos2d = canvas.info().wpos(); + let chunk_aabr = Aabr { + min: wpos2d, + max: wpos2d + TerrainChunkSize::RECT_SIZE.as_::(), + }; + for plot in plots_to_render { let (prim_tree, fills) = match &self.plots[plot].kind { PlotKind::House(house) => house.render_collect(self, &canvas.land()), @@ -765,7 +771,9 @@ impl Site { }; for (prim, fill) in fills { - let aabb = fill.get_bounds(&prim_tree, prim); + let mut aabb = fill.get_bounds(&prim_tree, prim); + aabb.min = Vec2::max(aabb.min.xy(), chunk_aabr.min).with_z(aabb.min.z); + aabb.max = Vec2::min(aabb.max.xy(), chunk_aabr.max).with_z(aabb.max.z); for x in aabb.min.x..aabb.max.x { for y in aabb.min.y..aabb.max.y {