8#include <glm/gtc/quaternion.hpp>
10#include "core/math/bounds.h"
11#include "ecs/entity.h"
12#include "ecs/component/physics/collider.h"
13#include "ecs/component/physics/rigidbody.h"
14#include "system/physics/body_pose.h"
15#include "system/physics/collision/contact.h"
17namespace Vkm::Engine {
35 uint32_t boxCount = 0;
36 uint32_t capsuleFirst = 0;
37 uint32_t capsuleCount = 0;
47 bool immovable =
false;
51 bool isTrigger =
false;
53 int collidesWith = ~0;
62inline constexpr uint32_t NARROWPHASE_CHUNK_PAIRS = 64;
72 glm::vec3
point = glm::vec3(0.0f);
73 glm::vec3
normal = glm::vec3(0.0f, 1.0f, 0.0f);
87 glm::vec3
point = glm::vec3(0.0f);
88 glm::vec3
normal = glm::vec3(0.0f, 1.0f, 0.0f);
101 if (x.
a.slot() != y.
a.slot())
return x.
a.slot() < y.
a.slot();
102 if (x.b.slot() != y.b.slot())
return x.b.slot() < y.b.slot();
103 if (x.
a.generation() != y.
a.generation())
return x.
a.generation() < y.
a.generation();
104 if (x.b.generation() != y.b.generation())
return x.b.generation() < y.b.generation();
129 BodyIslands() =
default;
130 ~BodyIslands() =
default;
132 BodyIslands(
const BodyIslands& other) =
delete;
133 BodyIslands& operator=(
const BodyIslands& other) =
delete;
135 BodyIslands(BodyIslands && other) =
delete;
136 BodyIslands& operator=(BodyIslands && other) =
delete;
141 m_parent.resize(count);
142 m_size.assign(count, 1);
143 for (
size_t i = 0; i < count; ++i) m_parent[i] = static_cast<uint32_t>(i);
146 uint32_t find(uint32_t i) {
147 while (m_parent[i] != i) {
148 m_parent[i] = m_parent[m_parent[i]];
154 void join(uint32_t a, uint32_t b) {
158 if (m_size[a] < m_size[b]) std::swap(a, b);
160 m_size[a] += m_size[b];
164 std::vector<uint32_t> m_parent;
165 std::vector<uint32_t> m_size;
179 RigidbodyMotion
motion = RigidbodyMotion::Dynamic;
198 glm::vec3
block = {0.0f, 1.0f, 0.0f};
void reset(size_t count)
Every body its own island again.
Definition physics_internal.h:140
What one tick's contacts add up to for one body, in the two reductions Rigidbody publishes.
Definition physics_internal.h:193
glm::vec3 block
Most horizontal contact normal.
Definition physics_internal.h:198
bool touched
A resolved, non-trigger contact reached this body.
Definition physics_internal.h:200
glm::vec3 support
Most upward contact normal.
Definition physics_internal.h:195
Per-tick body state cached at gather: mass properties, and the frame writeback maps through.
Definition physics_internal.h:174
glm::mat3 invInertiaLocal
Body-local inverse inertia; 0 = no rotational response.
Definition physics_internal.h:184
RigidbodyMotion motion
Rigidbody::motion, or Kinematic for a bone a ragdoll poses (isPosedByAnimation)
Definition physics_internal.h:179
float reach
Definition physics_internal.h:182
bool decided
This end decides where it goes; always true offline.
Definition physics_internal.h:180
float invMass
1/mass this tick; 0 = nothing the solver does moves it.
Definition physics_internal.h:181
Rigidbody * rb
Looked up at gather; valid for the tick, which adds and removes no Rigidbody.
Definition physics_internal.h:176
BodyPose pose
Definition physics_internal.h:177
Where a body sits in the world, and the frame that maps back to local.
Definition body_pose.h:20
Broadphase and narrowphase view of one collidable body, cached per tick.
Definition physics_internal.h:25
bool fixed
RigidbodyMotion::Static: never moves at all, unlike a kinematic body.
Definition physics_internal.h:48
Math::AABB bounds
World bound of every part together.
Definition physics_internal.h:46
const Collider * collider
The component this proxy was built from: its parts, and a mesh part's triangles and tree.
Definition physics_internal.h:45
uint32_t boxFirst
This body's parts already placed in world space, as two spans.
Definition physics_internal.h:34
Collision geometry attached to an entity, evaluated in its Transform frame.
Definition collider.h:72
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
An axis-aligned box.
Definition bounds.h:14
Everything one narrowphase chunk writes, so chunks on different threads share nothing.
Definition physics_internal.h:116
std::vector< ContactManifold > manifolds
The touching pairs', end to end, same order.
Definition physics_internal.h:118
std::vector< uint32_t > meshCandidates
Scratch: the triangles a tree walk found.
Definition physics_internal.h:119
std::vector< TouchingPair > touching
In pair order.
Definition physics_internal.h:117
Dynamics state for a physics body: motion, material response and mass.
Definition rigidbody.h:31
A broadphase pair that touched this tick, as its chunk hands it to the merge.
Definition physics_internal.h:67
uint32_t pair
Definition physics_internal.h:68
glm::vec3 point
First contact found, the event's representative.
Definition physics_internal.h:72
glm::vec3 normal
That contact's normal, A -> B.
Definition physics_internal.h:73
uint32_t manifoldCount
Its manifolds, next in the chunk's list; none for a trigger.
Definition physics_internal.h:70
Two colliders touching on a live tick, as the contact events track them across ticks.
Definition physics_internal.h:82
glm::vec3 point
The event's representative contact.
Definition physics_internal.h:87
static bool before(const TrackedPair &x, const TrackedPair &y)
The order tracked pairs are kept and reported in: slot pair, generation, trigger flags.
Definition physics_internal.h:100
bool aTrigger
a's collider is a trigger
Definition physics_internal.h:85
EntityId a
The lower slot.
Definition physics_internal.h:83
glm::vec3 normal
That contact's normal, a -> b.
Definition physics_internal.h:88
bool bTrigger
b's collider is a trigger
Definition physics_internal.h:86