feat: add debug rendering for other types of colliders / split game into more logical functions / files

This commit is contained in:
2026-10-16 15:08:10 +02:00
parent 4c9b77c948
commit 469bb287b7
32 changed files with 42809 additions and 882 deletions
@@ -1,9 +1,14 @@
#include <destrum/Components/Physics/BoxCollider.h>
#include <destrum/Graphics/DebugDraw.h>
#include <destrum/Util/ImGuiUtils.h>
#include <imgui.h>
void BoxCollider::DrawDebugLines(const glm::vec4& color) const {
DebugDraw::Box(GetWorldCenter(), GetWorldRotation(), m_HalfExtents, color);
}
nlohmann::json BoxCollider::Serialize() const {
auto data = SerializeCollider();
data["halfExtents"] = {m_HalfExtents.x, m_HalfExtents.y, m_HalfExtents.z};
@@ -1,7 +1,13 @@
#include <destrum/Components/Physics/CapsuleCollider.h>
#include <destrum/Graphics/DebugDraw.h>
#include <imgui.h>
void CapsuleCollider::DrawDebugLines(const glm::vec4& color) const {
DebugDraw::Capsule(GetWorldCenter(), GetWorldRotation(), m_Radius, m_Height, color);
}
void CapsuleCollider::ImGuiInspector() {
Collider::ImGuiInspector();
@@ -2,8 +2,18 @@
#include <imgui.h>
#include <destrum/ObjectModel/Transform.h>
#include <destrum/Util/ImGuiUtils.h>
glm::vec3 Collider::GetWorldCenter() const {
Transform& transform = GetTransform();
return transform.GetWorldPosition() + transform.GetWorldRotation() * m_CenterOffset;
}
glm::quat Collider::GetWorldRotation() const {
return GetTransform().GetWorldRotation();
}
void Collider::ImGuiInspector() {
bool isTrigger = m_IsTrigger;
if (ImGui::Checkbox("Is trigger", &isTrigger)) {
@@ -1,7 +1,13 @@
#include <destrum/Components/Physics/SphereCollider.h>
#include <destrum/Graphics/DebugDraw.h>
#include <imgui.h>
void SphereCollider::DrawDebugLines(const glm::vec4& color) const {
DebugDraw::Sphere(GetWorldCenter(), m_Radius, color);
}
nlohmann::json SphereCollider::Serialize() const {
auto data = SerializeCollider();
data["radius"] = m_Radius;