FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.48k stars 339 forks source link

Changing AABB validity to include zero-size dimensions to allow camera fitting to work with 2D objects. #648

Closed b-guild closed 1 month ago

b-guild commented 1 month ago

I noticed that camera fitting tended to fail with some objects in my scene and I tracked the problem down to how the fitting algorithm excludes certain AABBs as "invalid" when the only problem with them is that they have zero length in one dimension. I think what validity is really supposed to check for that an AABB is not negative in any of its dimensions, so I changed the test for positive into a test for not-negative.

b-guild commented 1 month ago

I think the problem was with the test, not with is_valid. Surely zero-size AABBs should be considered valid. We have is_degenerate to test for zero-size AABBs, and we have is_invalid_or_degenerate which would be a completely redundant function if all degenerate AABBs are invalid.