Split stage rendering and debug overlay

This commit is contained in:
2026-06-09 00:39:15 +08:00
parent ce815ed58b
commit cc75b94c44
9 changed files with 199 additions and 47 deletions
+49
View File
@@ -0,0 +1,49 @@
#include "debug_overlay.h"
#include <frostbite2D/graphics/renderer.h>
namespace ns_game {
namespace {
void drawRect(const frostbite2D::Rect& rect, const frostbite2D::Color& color) {
frostbite2D::Renderer::get().drawQuad(rect, color);
}
void drawOutline(const frostbite2D::Rect& rect, const frostbite2D::Color& color,
float thickness = 2.0f) {
drawRect(frostbite2D::Rect(rect.left(), rect.top(), rect.width(), thickness),
color);
drawRect(frostbite2D::Rect(rect.left(), rect.bottom() - thickness,
rect.width(), thickness),
color);
drawRect(frostbite2D::Rect(rect.left(), rect.top(), thickness, rect.height()),
color);
drawRect(frostbite2D::Rect(rect.right() - thickness, rect.top(), thickness,
rect.height()),
color);
}
} // namespace
void DebugOverlay::Render(const LevelDefinition& level, const DebugFlags& flags,
const frostbite2D::Rect* playerBounds) const {
if (flags.showCollision) {
drawCollision(level);
}
if (flags.showActorBounds && playerBounds) {
drawActorBounds(*playerBounds);
}
}
void DebugOverlay::drawCollision(const LevelDefinition& level) const {
for (const auto& platform : level.collision.platforms) {
drawOutline(platform, frostbite2D::Color(0.1f, 0.95f, 0.45f, 0.85f));
}
}
void DebugOverlay::drawActorBounds(const frostbite2D::Rect& bounds) const {
drawOutline(bounds, frostbite2D::Color(1.0f, 0.78f, 0.1f, 0.9f));
}
} // namespace ns_game