Fixed bug where cache doesnt get updated at times

This commit is contained in:
Yousef Khadadeh 2025-08-03 14:23:45 +03:00
parent c21d3e0595
commit d350ead7b3
2 changed files with 8 additions and 1 deletions

View file

@ -174,6 +174,11 @@ namespace SCollision {
} }
}; };
template <typename T> std::ostream& operator<<(std::ostream& os, const AABB<T>& a) {
return os << "min: [" << a.min.x() << " " << a.min.y() << "]\n"
<< "max: [" << a.max.x() << " " << a.max.y() << "]\n";
}
template <typename T> const AABB<T>& get_bounds(const Circle<T>& c) { return c.bounds; } template <typename T> const AABB<T>& get_bounds(const Circle<T>& c) { return c.bounds; }
template <typename T> const AABB<T>& get_bounds(const Triangle<T>& c) { return c.bounds; } template <typename T> const AABB<T>& get_bounds(const Triangle<T>& c) { return c.bounds; }
template <typename T> const AABB<T>& get_bounds(const AABB<T>& a) { return a; } template <typename T> const AABB<T>& get_bounds(const AABB<T>& a) { return a; }

View file

@ -356,7 +356,9 @@ void DrawingProgramCache::refresh_draw_cache(const std::shared_ptr<DrawingProgra
cacheCanvas->save(); cacheCanvas->save();
cacheCanvas->clipIRect(clipRect); cacheCanvas->clipIRect(clipRect);
cacheCanvas->clear(SkColor4f{0, 0, 0, 0}); cacheCanvas->clear(SkColor4f{0, 0, 0, 0});
draw_components_to_canvas(cacheCanvas, cacheDrawData, &drawCache.lastDrawnComponentPlacement, clipRectBoundAABBWorld); uint64_t lastDrawnComponentPlacementNew = 0;
draw_components_to_canvas(cacheCanvas, cacheDrawData, &lastDrawnComponentPlacementNew, clipRectBoundAABBWorld);
drawCache.lastDrawnComponentPlacement = std::max(lastDrawnComponentPlacementNew, drawCache.lastDrawnComponentPlacement);
cacheCanvas->restore(); cacheCanvas->restore();
drawCache.invalidBounds = std::nullopt; drawCache.invalidBounds = std::nullopt;
} }