vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
joint.h
1#pragma once
2
3#include <cstdint>
4
5#include <glm/glm.hpp>
6#include <glm/gtc/quaternion.hpp>
7
8#include "core/reflect.h"
9#include "ecs/entity.h"
10
11namespace Vkm::Engine {
12
18enum class JointType : uint8_t {
19 Point = 0,
20 Distance = 1,
21 Count
22};
23
31struct Joint {
32 JointType type = JointType::Point;
33
35 glm::vec3 anchor = {0.0f, 0.0f, 0.0f};
36 glm::vec3 connectedAnchor = {0.0f, 0.0f, 0.0f};
37
43 float distance = -1.0f;
44
50 float resolvedDistance = -1.0f;
51
59 float stiffness = 1.0f;
60
68 float holdTorque = 0.0f;
69
71 glm::quat heldRotation = {1.0f, 0.0f, 0.0f, 0.0f};
72
74 bool heldResolved = false;
75
76 bool collideConnected = false;
77};
78
79} // namespace Vkm::Engine
80
81VKM_ENUM_NAMES(::Vkm::Engine::JointType, "Point", "Distance")
82
83VKM_REFLECT_BEGIN(::Vkm::Engine::Joint)
84 VKM_F(type)
85 VKM_F(anchor)
86 VKM_F(connectedAnchor)
87 VKM_F(distance)
88 VKM_F(stiffness)
89 VKM_F(holdTorque)
90 VKM_F(collideConnected)
91VKM_REFLECT_END()
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
Ties this entity's body to another, at a point on each.
Definition joint.h:31
float holdTorque
Most torque, in newton-metres, spent holding the two bodies at the angle between them.
Definition joint.h:68
float distance
Distance the anchors are held at, in metres, for a Distance joint.
Definition joint.h:43
bool collideConnected
Whether the two bodies still collide.
Definition joint.h:76
float resolvedDistance
The length actually held, once the solver has measured it; runtime, not serialized.
Definition joint.h:50
glm::vec3 anchor
On this body, local.
Definition joint.h:35
glm::quat heldRotation
The angle held, the connected body's rotation in this one's frame; runtime, not serialized.
Definition joint.h:71
bool heldResolved
Whether heldRotation is current; cleared while neither body can move. Runtime.
Definition joint.h:74
float stiffness
How hard the joint pulls drifted anchors back together, 0 to 1.
Definition joint.h:59
EntityId connected
The other body; empty, or this entity, disables.
Definition joint.h:34
glm::vec3 connectedAnchor
On the other, local.
Definition joint.h:36