feat: add debug rendering for other types of colliders / split game into more logical functions / files
This commit is contained in:
@@ -21,6 +21,8 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void DrawDebugLines(const glm::vec4& color) const override;
|
||||
|
||||
[[nodiscard]] PhysicsShapeDesc BuildPhysicsShape() const override {
|
||||
return PhysicsShapeDesc::Box(m_HalfExtents, m_CenterOffset, m_IsTrigger);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void DrawDebugLines(const glm::vec4& color) const override;
|
||||
|
||||
[[nodiscard]] PhysicsShapeDesc BuildPhysicsShape() const override {
|
||||
return PhysicsShapeDesc::Capsule(m_Radius, m_Height, m_CenterOffset, m_IsTrigger);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
#include <destrum/Physics/PhysicsTypes.h>
|
||||
@@ -15,11 +16,14 @@ public:
|
||||
void ImGuiInspector() override;
|
||||
|
||||
[[nodiscard]] virtual PhysicsShapeDesc BuildPhysicsShape() const = 0;
|
||||
virtual void DrawDebugLines(const glm::vec4& color) const = 0;
|
||||
|
||||
[[nodiscard]] bool IsTrigger() const { return m_IsTrigger; }
|
||||
void SetTrigger(bool trigger) { m_IsTrigger = trigger; NotifyPhysicsChanged(); }
|
||||
|
||||
[[nodiscard]] const glm::vec3& GetCenterOffset() const { return m_CenterOffset; }
|
||||
[[nodiscard]] glm::vec3 GetWorldCenter() const;
|
||||
[[nodiscard]] glm::quat GetWorldRotation() const;
|
||||
void SetCenterOffset(const glm::vec3& offset) { m_CenterOffset = offset; NotifyPhysicsChanged(); }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
return "SphereCollider";
|
||||
}
|
||||
|
||||
void DrawDebugLines(const glm::vec4& color) const override;
|
||||
|
||||
[[nodiscard]] PhysicsShapeDesc BuildPhysicsShape() const override {
|
||||
return PhysicsShapeDesc::Sphere(m_Radius, m_CenterOffset, m_IsTrigger);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef DEBUGDRAW_H
|
||||
#define DEBUGDRAW_H
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
namespace DebugDraw {
|
||||
void Arc(const glm::vec3& center, const glm::vec3& axisA, const glm::vec3& axisB, float radius,
|
||||
float fromAngle, float toAngle, const glm::vec4& color, int segments = 16);
|
||||
void Circle(const glm::vec3& center, const glm::vec3& axisA, const glm::vec3& axisB, float radius,
|
||||
const glm::vec4& color, int segments = 32);
|
||||
|
||||
void Box(const glm::vec3& center, const glm::quat& rotation, const glm::vec3& halfExtents, const glm::vec4& color);
|
||||
void Sphere(const glm::vec3& center, float radius, const glm::vec4& color);
|
||||
|
||||
void Capsule(const glm::vec3& center, const glm::quat& rotation, float radius, float height, const glm::vec4& color);
|
||||
}
|
||||
|
||||
#endif // DEBUGDRAW_H
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef PRIMITIVEMESHES_H
|
||||
#define PRIMITIVEMESHES_H
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <destrum/Graphics/Resources/CPUMesh.h>
|
||||
|
||||
namespace PrimitiveMeshes {
|
||||
[[nodiscard]] CPUMesh MakeBox(const glm::vec3& size);
|
||||
}
|
||||
|
||||
#endif // PRIMITIVEMESHES_H
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MODELSPAWNER_H
|
||||
#define MODELSPAWNER_H
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
class GameObject;
|
||||
class GfxDevice;
|
||||
class RenderResources;
|
||||
class Scene;
|
||||
|
||||
namespace ModelDoc {
|
||||
struct LoadOptions;
|
||||
}
|
||||
|
||||
namespace ModelSpawner {
|
||||
// Loads a model and creates a root GameObject with one child per mesh primitive, using the model's PBR materials
|
||||
GameObject* SpawnStaticModel(
|
||||
Scene& scene,
|
||||
GfxDevice& gfxDevice,
|
||||
RenderResources& resources,
|
||||
std::string_view reference,
|
||||
const ModelDoc::LoadOptions& options,
|
||||
const std::string& name);
|
||||
}
|
||||
|
||||
#endif // MODELSPAWNER_H
|
||||
Reference in New Issue
Block a user