38 lines
875 B
C++
38 lines
875 B
C++
#pragma once
|
|
|
|
#include <algorithm>
|
|
|
|
#include <destrum/Components/Collider.h>
|
|
|
|
class CapsuleCollider final : public Collider {
|
|
public:
|
|
explicit CapsuleCollider(GameObject& owner, float radius = 0.5f, float height = 2.0f)
|
|
: Collider(owner)
|
|
, m_Radius(radius)
|
|
, m_Height(height) {}
|
|
|
|
[[nodiscard]] PhysicsShapeDesc BuildPhysicsShape() const override {
|
|
return PhysicsShapeDesc::Capsule(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.0f);
|
|
}
|
|
|
|
[[nodiscard]] float GetHeight() const {
|
|
return m_Height;
|
|
}
|
|
|
|
void SetHeight(float height) {
|
|
m_Height = std::max(height, m_Radius * 2.0f);
|
|
}
|
|
|
|
private:
|
|
float m_Radius{0.5f};
|
|
float m_Height{2.0f};
|
|
};
|