42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#ifndef BOXCOLLIDER_H
|
|
#define BOXCOLLIDER_H
|
|
|
|
#include <destrum/Components/Physics/Collider.h>
|
|
|
|
class BoxCollider final : public Collider {
|
|
public:
|
|
explicit BoxCollider(GameObject& owner, const glm::vec3& halfExtents = glm::vec3{0.5f})
|
|
: Collider(owner)
|
|
, m_HalfExtents(glm::max(halfExtents, glm::vec3{0.0001f})) {}
|
|
|
|
void Update(float) override {}
|
|
|
|
nlohmann::json Serialize() const override;
|
|
void Deserialize(const nlohmann::json& data) override;
|
|
void ImGuiInspector() override;
|
|
|
|
std::string GetTypeName() const override
|
|
{
|
|
return "BoxCollider";
|
|
}
|
|
|
|
|
|
[[nodiscard]] PhysicsShapeDesc BuildPhysicsShape() const override {
|
|
return PhysicsShapeDesc::Box(m_HalfExtents, m_CenterOffset, m_IsTrigger);
|
|
}
|
|
|
|
[[nodiscard]] const glm::vec3& GetHalfExtents() const {
|
|
return m_HalfExtents;
|
|
}
|
|
|
|
void SetHalfExtents(const glm::vec3& halfExtents) {
|
|
m_HalfExtents = glm::max(halfExtents, glm::vec3{0.0001f});
|
|
NotifyPhysicsChanged();
|
|
}
|
|
|
|
private:
|
|
glm::vec3 m_HalfExtents{0.5f};
|
|
};
|
|
|
|
#endif
|