vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
contact.h
1#pragma once
2
3#include <cstdint>
4
5#include <glm/glm.hpp>
6
7namespace Vkm::Engine {
8
12inline constexpr int MAX_CONTACTS_PER_MANIFOLD = 4;
13
20struct Contact {
21 glm::vec3 point = {0.0f, 0.0f, 0.0f};
22 glm::vec3 normal = {0.0f, 1.0f, 0.0f};
23 float penetration = 0.0f;
24
25 float normalImpulse = 0.0f;
26 float restitutionBias = 0.0f;
27
34 glm::vec3 tangent1 = {0.0f, 0.0f, 0.0f};
35 glm::vec3 tangent2 = {0.0f, 0.0f, 0.0f};
36 float tangentImpulse1 = 0.0f;
37 float tangentImpulse2 = 0.0f;
38
46 glm::vec3 warmFriction = {0.0f, 0.0f, 0.0f};
47
54 glm::vec3 rA = {0.0f, 0.0f, 0.0f};
55 glm::vec3 rB = {0.0f, 0.0f, 0.0f};
56 float normalMass = 0.0f;
57 float tangentMass1 = 0.0f;
58 float tangentMass2 = 0.0f;
59};
60
67 uint32_t bodyA = 0;
68 uint32_t bodyB = 0;
69 int count = 0;
70 Contact contacts[MAX_CONTACTS_PER_MANIFOLD];
71};
72
73} // namespace Vkm::Engine
Contacts between one pair of bodies for a single tick.
Definition contact.h:66
uint32_t bodyB
Index into the tick body snapshot.
Definition contact.h:68
uint32_t bodyA
Index into the tick body snapshot.
Definition contact.h:67
int count
Number of valid entries in contacts[].
Definition contact.h:69
A single collision contact point in world space.
Definition contact.h:20
glm::vec3 rA
Pre-solve constants: the lever arms and the effective masses.
Definition contact.h:54
float restitutionBias
Target separation speed (set once, pre-solve)
Definition contact.h:26
glm::vec3 tangent1
Friction as two impulses along a basis fixed for the whole tick.
Definition contact.h:34
glm::vec3 normal
Unit normal, A -> B.
Definition contact.h:22
glm::vec3 warmFriction
Last tick's friction, as a world vector, waiting for a basis.
Definition contact.h:46
float normalImpulse
Accumulated normal impulse, seeded from last tick.
Definition contact.h:25
glm::vec3 point
Contact position (world)
Definition contact.h:21
float penetration
Positive overlap depth.
Definition contact.h:23