Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
DefaultCollider.hpp
Go to the documentation of this file.
1/**************************************************************************
2 * EngineSquared v0.1.1
3 *
4 * EngineSquared is a software package, part of the Engine² organization.
5 *
6 * This file is part of the EngineSquared project that is under MIT License.
7 * Copyright © 2025-present by @EngineSquared, All rights reserved.
8 *
9 * EngineSquared is a free software: you can redistribute it and/or modify
10 * it under the terms of the MIT License. See the project's LICENSE file for
11 * the full license text and details.
12 *
13 * @file DefaultCollider.hpp
14 * @brief Default collider component auto-created when no explicit collider
15 *
16 * This collider is automatically created when a RigidBody is added to an
17 * entity that has no explicit collider component (BoxCollider, etc.).
18 * It creates a box shape based on the entity's mesh bounds.
19 *
20 * @author @EngineSquared
21 * @version 0.1.1
22 * @date 2025-10-28
23 **************************************************************************/
24
25#pragma once
26
27#include <glm/vec3.hpp>
28
29namespace Physics::Component {
30
45 glm::vec3 halfExtents{0.5f, 0.5f, 0.5f};
46
48 glm::vec3 offset{0.0f, 0.0f, 0.0f};
49
53 DefaultCollider() = default;
54
59 explicit DefaultCollider(const glm::vec3 &extents) : halfExtents(extents) {}
60
66 DefaultCollider(const glm::vec3 &extents, const glm::vec3 &localOffset) : halfExtents(extents), offset(localOffset)
67 {
68 }
69
73 [[nodiscard]] glm::vec3 GetSize() const { return halfExtents * 2.0f; }
74};
75
76} // namespace Physics::Component
Definition BoxCollider.hpp:27
glm::vec3 GetSize() const
Get full dimensions of the box.
Definition DefaultCollider.hpp:73
DefaultCollider(const glm::vec3 &extents, const glm::vec3 &localOffset)
Construct with half-extents and offset.
Definition DefaultCollider.hpp:66
DefaultCollider(const glm::vec3 &extents)
Construct with half-extents.
Definition DefaultCollider.hpp:59
glm::vec3 offset
Local offset from entity transform.
Definition DefaultCollider.hpp:48
DefaultCollider()=default
Default constructor (1x1x1 box).
glm::vec3 halfExtents
Half-extents of the box (size / 2).
Definition DefaultCollider.hpp:45