Skip to content

Commit

Permalink
fixed tile map bounding box calculation
Browse files Browse the repository at this point in the history
- prevents clipping issues when rotating/moving camera
  • Loading branch information
mrDIMAS committed Jul 7, 2024
1 parent 254aee7 commit 7eb6f1b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion fyrox-impl/src/scene/tilemap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,18 @@ impl NodeTrait for TileMap {
crate::impl_query_component!();

fn local_bounding_box(&self) -> AxisAlignedBoundingBox {
AxisAlignedBoundingBox::unit()
let mut min = Vector2::repeat(i32::MAX);
let mut max = Vector2::repeat(i32::MIN);

for tile in self.tiles.values() {
min = tile.position.inf(&min);
max = tile.position.sup(&max);
}

let min_pos = min.cast::<f32>().to_homogeneous();
let max_pos = max.cast::<f32>().to_homogeneous();

AxisAlignedBoundingBox::from_min_max(min_pos, max_pos)
}

fn world_bounding_box(&self) -> AxisAlignedBoundingBox {
Expand Down

0 comments on commit 7eb6f1b

Please sign in to comment.