vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
part_bounds.h
1#pragma once
2
3#include "core/math/bounds.h"
4#include "ecs/component/physics/collider.h"
5
6namespace Vkm::Engine {
7
15inline Math::AABB partLocalBounds(const Collider& collider, const ColliderPart& part) {
16 switch (part.shape) {
17 case ColliderShape::Box:
18 return {-part.halfExtents, part.halfExtents};
19
20 case ColliderShape::Capsule: {
21 const glm::vec3 reach(part.radius, part.halfHeight + part.radius, part.radius);
22 return {-reach, reach};
23 }
24
25 case ColliderShape::Mesh:
26 case ColliderShape::Terrain:
27 if (collider.meshNodes.empty()) return {glm::vec3(0.0f), glm::vec3(0.0f)};
28 return {collider.meshNodes[0].min, collider.meshNodes[0].max};
29
30 case ColliderShape::Count:
31 break;
32 }
33 return {-part.halfExtents, part.halfExtents};
34}
35
36} // namespace Vkm::Engine
Region reach(const TerrainAsset &terrain, const Dab &dab)
The grid vertices within dab, clamped to terrain's grid.
One primitive of a collider, in the entity's local frame.
Definition collider.h:44
Collision geometry attached to an entity, evaluated in its Transform frame.
Definition collider.h:84
An axis-aligned box.
Definition bounds.h:17