Tramway SDK
collisionshape.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_PHYSICS_COLLISIONSHAPE_H
5#define TRAM_SDK_PHYSICS_COLLISIONSHAPE_H
6
7#include <framework/math.h>
8
9namespace tram::Physics {
10
11enum Shape : uint32_t {
19};
20
23};
24
27
28 union {
29 struct {
30 union {
31 float radius;
32 float radius_x;
33 float extent_x;
34 };
35
36 union {
37 float height;
38 float extent_y;
39 };
40
41 union {
42 float extent_z;
43 float radius_z;
44 };
45 };
46
47 struct {
49 size_t hull_size;
50 };
51
52 struct {
54 size_t mesh_size;
55 };
56 };
57
58 static inline CollisionShape Sphere(float radius);
59 static inline CollisionShape Cylinder(float radius, float height);
60 static inline CollisionShape Capsule(float radius, float height);
61 static inline CollisionShape Cone(float radius, float height);
62 static inline CollisionShape Box(vec3 dimensions);
63 static inline CollisionShape Hull(vec3* points, size_t size);
64 static inline CollisionShape Mesh(CollisionTriangle* triangles, size_t size);
65};
66
68 return {SHAPE_SPHERE, radius, 0.0f, 0.0f};
69}
70
71CollisionShape CollisionShape::Cylinder(float radius, float height) {
73}
74
75CollisionShape CollisionShape::Capsule(float radius, float height) {
76 return {SHAPE_CAPSULE, radius, height, 0.0f};
77}
78
79CollisionShape CollisionShape::Cone(float radius, float height) {
80 return {SHAPE_CONE, radius, height, 0.0f};
81}
82
84 return {SHAPE_BOX, dimensions.x, dimensions.y, dimensions.z};
85}
86
88 return CollisionShape {.type = SHAPE_HULL, .hull_points = points, .hull_size = size};
89}
90
92 return CollisionShape {.type = SHAPE_MESH, .mesh_triangles = triangles, .mesh_size = size};
93}
94
95}
96
97#endif // TRAM_SDK_PHYSICS_COLLISIONSHAPE_H
Definition: api.h:10
Shape
Definition: collisionshape.h:11
@ SHAPE_CONE
Definition: collisionshape.h:15
@ SHAPE_SPHERE
Definition: collisionshape.h:12
@ SHAPE_CAPSULE
Definition: collisionshape.h:14
@ SHAPE_MESH
Definition: collisionshape.h:18
@ SHAPE_BOX
Definition: collisionshape.h:16
@ SHAPE_HULL
Definition: collisionshape.h:17
@ SHAPE_CYLINDER
Definition: collisionshape.h:13
glm::vec3 vec3
Definition: math.h:12
Definition: collisionshape.h:25
float radius_x
Definition: collisionshape.h:32
static CollisionShape Cylinder(float radius, float height)
Definition: collisionshape.h:71
static CollisionShape Sphere(float radius)
Definition: collisionshape.h:67
float height
Definition: collisionshape.h:37
static CollisionShape Box(vec3 dimensions)
Definition: collisionshape.h:83
float radius
Definition: collisionshape.h:31
float extent_x
Definition: collisionshape.h:33
size_t hull_size
Definition: collisionshape.h:49
vec3 * hull_points
Definition: collisionshape.h:48
static CollisionShape Cone(float radius, float height)
Definition: collisionshape.h:79
CollisionTriangle * mesh_triangles
Definition: collisionshape.h:53
float extent_z
Definition: collisionshape.h:42
static CollisionShape Hull(vec3 *points, size_t size)
Definition: collisionshape.h:87
float radius_z
Definition: collisionshape.h:43
float extent_y
Definition: collisionshape.h:38
static CollisionShape Mesh(CollisionTriangle *triangles, size_t size)
Definition: collisionshape.h:91
Shape type
Definition: collisionshape.h:26
size_t mesh_size
Definition: collisionshape.h:54
static CollisionShape Capsule(float radius, float height)
Definition: collisionshape.h:75
Definition: collisionshape.h:21
vec3 p2
Definition: collisionshape.h:22
vec3 p1
Definition: collisionshape.h:22
vec3 p0
Definition: collisionshape.h:22