Fixed bug with cache not updating
This commit is contained in:
parent
89925763cd
commit
f2f215fa91
2 changed files with 18 additions and 15 deletions
|
|
@ -28,7 +28,7 @@ namespace SCollision {
|
|||
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) {
|
||||
AABB<T> get_intersection_between_aabbs(const AABB<T>& other) const {
|
||||
return {
|
||||
cwise_vec_max(other.min, min),
|
||||
cwise_vec_min(other.max, max)
|
||||
|
|
|
|||
|
|
@ -356,7 +356,9 @@ void DrawingProgramCache::allocate_window_cache_area() {
|
|||
}
|
||||
|
||||
void DrawingProgramCache::update_window_cache_invalid_bounds(const DrawData& drawData) {
|
||||
auto iBounds = windowCache.invalidBounds.value();
|
||||
auto invalidBound = windowCache.invalidBounds.value();
|
||||
if(SCollision::collide(invalidBound, drawData.cam.viewingAreaGenerousCollider)) {
|
||||
auto iBounds = drawData.cam.viewingAreaGenerousCollider.get_intersection_between_aabbs(invalidBound);
|
||||
|
||||
SCollision::AABB<float> cameraSpaceInvalidAABB = drawData.cam.c.world_collider_to_coords<SCollision::AABB<float>>(iBounds);
|
||||
SCollision::AABB<float> clipRectBoundAABB{cameraSpaceInvalidAABB.min - Vector2f{4, 4}, cameraSpaceInvalidAABB.max + Vector2f{4, 4}};
|
||||
|
|
@ -374,6 +376,7 @@ void DrawingProgramCache::update_window_cache_invalid_bounds(const DrawData& dra
|
|||
cacheCanvas->clear(SkColor4f{0, 0, 0, 0});
|
||||
draw_components_to_canvas(cacheCanvas, drawData, clipRectBoundAABBWorld);
|
||||
cacheCanvas->restore();
|
||||
}
|
||||
windowCache.invalidBounds = std::nullopt;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue