50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <algorithm>
|
|
|
|
#include <destrum/Components/Physics/Collider.h>
|
|
|
|
class CylinderCollider final : public Collider {
|
|
public:
|
|
explicit CylinderCollider(GameObject& owner, float radius = 0.5f, float height = 1.0f)
|
|
: Collider(owner)
|
|
, m_Radius(std::max(radius, 0.0001f))
|
|
, m_Height(std::max(height, 0.0001f)) {}
|
|
|
|
void Update(float) override {}
|
|
|
|
std::string GetTypeName() const override {
|
|
return "CylinderCollider";
|
|
}
|
|
|
|
void Reflect(FieldVisitor& v) override;
|
|
|
|
void DrawDebugLines(const glm::vec4& color) const override;
|
|
|
|
[[nodiscard]] PhysicsShapeDesc BuildPhysicsShape() const override {
|
|
return PhysicsShapeDesc::Cylinder(m_Radius, m_Height, m_CenterOffset, m_IsTrigger);
|
|
}
|
|
|
|
[[nodiscard]] float GetRadius() const {
|
|
return m_Radius;
|
|
}
|
|
|
|
void SetRadius(float radius) {
|
|
m_Radius = std::max(radius, 0.0001f);
|
|
NotifyPhysicsChanged();
|
|
}
|
|
|
|
[[nodiscard]] float GetHeight() const {
|
|
return m_Height;
|
|
}
|
|
|
|
void SetHeight(float height) {
|
|
m_Height = std::max(height, 0.0001f);
|
|
NotifyPhysicsChanged();
|
|
}
|
|
|
|
private:
|
|
float m_Radius{0.5f};
|
|
float m_Height{1.0f};
|
|
};
|