25 &verts[0].px, count,
sizeof(
Vertex));
31 float maxDistSq = 0.0f;
32 for (
size_t i = 0; i < count; ++i) {
35 float dSq = diff.
Dot(diff);
36 if (dSq > maxDistSq) maxDistSq = dSq;
40 std::sqrt(maxDistSq));
68 m_shape = std::move(mesh);
91 auto* transform =
const_cast<GameObject*
>(
owner)->GetComponent<TransformComponent>();
93 worldPos = transform->GetWorldPosition() + m_offset;
94 worldScale = transform->GetWorldScale();
95 }
else if (
auto* cam =
dynamic_cast<Camera*
>(
owner)) {
96 worldPos = cam->GetPosition() + m_offset;
void Update(float deltaTime) override
Physics::AABB GetWorldAABB() const
Local shape transformed into world space by the owner's current transform.
ColliderComponent(GameObject *owner, const Physics::AABB &aabb)
Wraps a pre-built axis-aligned box shape.
bool Initialize() override
One-time setup, called after the component is attached and the owner is initialized.
Component(GameObject *object)
float Dot(const Vector3D &other) const
const Vertex * GetData() const
Collision shapes, the broadphase tree, and the world that steps them.
AABB GetWorldAABB(const ColliderShape &shape, const Vector3D &worldPos, const Vector3D &worldScale)
Transforms a local-space collider shape into a world-space AABB for broadphase queries.
Root namespace for everything the engine exposes.
Vector3D GetCenter() const
static AABB FromVertices(const float *positions, size_t count, size_t stride)
Computes a tight AABB over raw interleaved vertex positions.
static BoundingCapsule FromAABB(const AABB &aabb)
Fits a capsule inside the AABB, picking its longest axis as the capsule axis.
void Build(const float *positions, size_t count, size_t stride, const uint32_t *indexData, size_t indexCount)
Copies vertex positions and indices out of raw mesh buffers and recomputes bounds.