Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
BoxCollider.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 BoxCollider.hpp
14 * @brief Explicit box collider component
15 *
16 * User-specified box collider with customizable dimensions and offset.
17 *
18 * @author @EngineSquared
19 * @version 0.1.1
20 * @date 2025-10-28
21 **************************************************************************/
22
23#pragma once
24
25#include <glm/vec3.hpp>
26
28
46 glm::vec3 halfExtents{0.5f, 0.5f, 0.5f};
47
49 glm::vec3 offset{0.0f, 0.0f, 0.0f};
50
52 float convexRadius = 0.05f;
53
57 BoxCollider() = default;
58
63 explicit BoxCollider(const glm::vec3 &extents) : halfExtents(extents) {}
64
70 BoxCollider(const glm::vec3 &extents, const glm::vec3 &localOffset) : halfExtents(extents), offset(localOffset) {}
71
75 [[nodiscard]] glm::vec3 GetSize() const { return halfExtents * 2.0f; }
76
81 void SetSize(const glm::vec3 &size) { halfExtents = size * 0.5f; }
82};
83
84} // namespace Physics::Component
Definition BoxCollider.hpp:27
BoxCollider()=default
Default constructor (1x1x1 box).
BoxCollider(const glm::vec3 &extents)
Construct with half-extents.
Definition BoxCollider.hpp:63
glm::vec3 halfExtents
Half-extents of the box (size / 2).
Definition BoxCollider.hpp:46
BoxCollider(const glm::vec3 &extents, const glm::vec3 &localOffset)
Construct with half-extents and offset.
Definition BoxCollider.hpp:70
glm::vec3 GetSize() const
Get full dimensions of the box.
Definition BoxCollider.hpp:75
float convexRadius
Convex radius for collision detection (smaller = sharper corners).
Definition BoxCollider.hpp:52
void SetSize(const glm::vec3 &size)
Set size directly (converts to half-extents).
Definition BoxCollider.hpp:81
glm::vec3 offset
Local offset from entity transform.
Definition BoxCollider.hpp:49