Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
RigidBody3D.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
18#pragma once
19
20#include "../../core/Types.hpp"
22#include "../../math/Math.hpp"
23#include "./BodyType.hpp"
24
25namespace esengine::ecs {
26
40
42 ES_PROPERTY(min=0)
44
45 ES_PROPERTY(min=0)
47
48 ES_PROPERTY(min=0)
50
54 ES_PROPERTY(min=0, tooltip="Kilograms. 0 = from its shape at the density of water (a ball of 10 cm radius is 4.2 kg).")
55 f32 mass{0.0f};
56
60 bool fixedRotation{false};
61
64 ES_PROPERTY(min=0, max=15, advanced)
66
72 ES_PROPERTY(advanced)
74
77 bool enabled{true};
78};
79
83 // World units at the reference 100 a metre, scaled by the project's units per metre (sdk ecs/worldUnits.ts).
85 glm::vec3 halfExtents{50.0f, 50.0f, 50.0f};
86
88 ES_PROPERTY(optional)
89 glm::vec3 center{0.0f, 0.0f, 0.0f};
90
91 ES_PROPERTY(min=0)
93
94 ES_PROPERTY(min=0, max=1)
96
99 bool isSensor{false};
100
102 bool enabled{true};
103};
104
107 ES_PROPERTY(min=0)
108 f32 radius{50.0f};
109
111 ES_PROPERTY(optional)
112 glm::vec3 center{0.0f, 0.0f, 0.0f};
113
114 ES_PROPERTY(min=0)
116
117 ES_PROPERTY(min=0, max=1)
119
121 bool isSensor{false};
122
124 bool enabled{true};
125};
126
136 ES_PROPERTY(min=0)
137 f32 radius{30.0f};
138
139 ES_PROPERTY(min=0)
141
143 ES_PROPERTY(optional)
144 glm::vec3 center{0.0f, 0.0f, 0.0f};
145
146 ES_PROPERTY(min=0)
148
149 ES_PROPERTY(min=0, max=1)
151
153 bool isSensor{false};
154
156 bool enabled{true};
157};
158
170 ES_PROPERTY(asset = mesh, tooltip="Geometry (.esmesh) to collide against.")
171 resource::MeshHandle mesh;
172
173 ES_PROPERTY(min=0)
175
176 ES_PROPERTY(min=0, max=1)
178
180 ES_PROPERTY(min=0, max=15, advanced)
182
184 bool enabled{true};
185};
186
198 ES_PROPERTY(asset = mesh, tooltip="Geometry (.esmesh) whose convex hull collides.")
199 resource::MeshHandle mesh;
200
201 ES_PROPERTY(min=0)
203
204 ES_PROPERTY(min=0, max=1)
206
208 bool isSensor{false};
209
211 bool enabled{true};
212};
213
226 glm::vec3 velocity{0.0f, 0.0f, 0.0f};
227
231 ES_PROPERTY(min=0)
232 f32 radius{30.0f};
233
235 ES_PROPERTY(min=0)
237
239 ES_PROPERTY(min=0, max=1.5708, unit="rad")
240 f32 maxSlope{0.87f};
241
243 ES_PROPERTY(min=0, advanced)
245
247 ES_PROPERTY(min=0, advanced)
248 f32 snapDown{50.0f};
249
251 ES_PROPERTY(min=0, advanced)
252 f32 mass{70.0f};
253
259 ES_PROPERTY(min=0, advanced)
260 f32 pushForce{5000.0f};
261
263 bool enabled{true};
264
266 ES_PROPERTY(min=0, max=15, advanced)
268
270 ES_PROPERTY(advanced)
271 bool isOnFloor{false};
272
274 ES_PROPERTY(advanced)
275 glm::vec3 floorNormal{0.0f, 0.0f, 0.0f};
276
278 ES_PROPERTY(advanced)
279 glm::vec3 realVelocity{0.0f, 0.0f, 0.0f};
280};
281
282} // namespace esengine::ecs
How a solver is allowed to move a body — the one answer both worlds give.
Math utilities and GLM configuration for ESEngine.
Reflection and metadata system for automatic binding generation.
#define ES_COMPONENT(...)
Mark a struct/class as a component that should be exposed to scripts.
#define ES_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Core type definitions and utilities for ESEngine.
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
float f32
32-bit floating point
Definition Types.hpp:59
An axis-aligned box, sized in world units around the entity's origin.
glm::vec3 center
Where the shape sits from the entity's origin, in world units; zero is centred on it.
bool isSensor
A sensor reports overlaps and stops nothing.
An upright capsule — the shape a character is.
glm::vec3 center
Where the shape sits from the entity's origin, in world units; zero is centred on it.
A kinematic mover for a 3D player or NPC.
glm::vec3 realVelocity
Output: what it actually moved, per second, after collisions.
f32 mass
Mass used when it pushes dynamic bodies.
f32 halfHeight
Half the cylinder; total height is 2*(halfHeight + radius).
glm::vec3 floorNormal
Output: the floor's normal; zero while airborne.
f32 maxSlope
Steepest ground it can stand on. Beyond this it slides.
bool isOnFloor
Output: standing on ground it can walk on.
glm::vec3 velocity
Desired velocity in world units/second. A positive y is a jump.
f32 snapDown
How far it reaches down to stay on the floor over a crest. 0 = off.
f32 radius
World units, as every length here: these defaults are a 1.6 m person at the reference scale of 100 un...
u32 layer
Which collision layer it is in (0..15).
f32 stepHeight
Tallest step it climbs instead of stopping at. 0 = climbs nothing.
f32 pushForce
How hard it can shove what it walks into, in newtons. A character is swept rather than solved,...
The convex hull of imported geometry — a shape a solver can push.
resource::MeshHandle mesh
Geometry whose hull is the shape. Its concave detail is filled in.
Imported geometry, used as it is, for a level to collide against.
resource::MeshHandle mesh
The geometry to collide against. Its triangles are used directly.
u32 layer
Which collision layer the geometry is in (0..15).
A body in the 3D world.
bool enabled
Disabled bodies are left out of the world entirely.
f32 mass
Its mass in kilograms. 0 = as heavy as its shape at the density of water, a ball of 10 cm radius 4....
u32 layer
Which collision layer this body is in (0..15). ONE layer, unlike the 2D world's category bits: Jolt c...
bool continuousCollision
Checks the whole path a step covers rather than where the body ended up. What a bullet needs: discret...
f32 gravityScale
Scales this body's share of the world's gravity. 0 = weightless.
bool fixedRotation
Keeps the body upright: the solver may move it, never turn it. What a character on legs wants,...
BodyType bodyType
Static never moves, Kinematic is moved by hand, Dynamic is solved.
glm::vec3 center
Where the shape sits from the entity's origin, in world units; zero is centred on it.