Cache surfaces only update in locations that require updating

This commit is contained in:
Yousef Khadadeh 2025-08-03 12:31:30 +03:00
parent 50fcaee52c
commit 81ac5a2302
3 changed files with 67 additions and 31 deletions

View file

@ -27,6 +27,13 @@ namespace SCollision {
Vector<T, 2> dim() const { return max - min; }
T width() const { return max.x() - min.x(); }
T height() const { return max.y() - min.y(); }
// Do not try to get intersection between AABBs unless you know they collide
AABB<T> get_intersection_between_aabbs(const AABB<T>& other) {
return {
cwise_vec_max(other.min, min),
cwise_vec_min(other.max, max)
};
}
void include_aabb_in_bounds(const AABB<T>& other) {
min = cwise_vec_min(other.min, min);
max = cwise_vec_max(other.max, max);