vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
joint_solver.h
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include <glm/glm.hpp>
7
8#include "system/physics/solver/solver.h"
9#include "system/physics/solver/solver_math.h"
10
11namespace Vkm::Engine {
12
20 uint32_t bodyA = 0;
21 uint32_t bodyB = 0;
22
23 glm::vec3 anchorA = {0.0f, 0.0f, 0.0f};
24 glm::vec3 anchorB = {0.0f, 0.0f, 0.0f};
25
32 float distance = -1.0f;
33
34 float stiffness = 1.0f;
35
42 bool solvable = false;
43 glm::mat3 mass = glm::mat3(0.0f);
44 glm::vec3 bias = {0.0f, 0.0f, 0.0f};
45
49 glm::vec3 impulse = {0.0f, 0.0f, 0.0f};
50
51 float holdTorque = 0.0f;
52 glm::quat heldRotation = {1.0f, 0.0f, 0.0f, 0.0f};
53 float holdLimit = 0.0f;
54
55 bool holdSolvable = false;
56 glm::mat3 holdMass = glm::mat3(0.0f);
57 glm::vec3 holdBias = {0.0f, 0.0f, 0.0f};
58 glm::vec3 holdImpulse = {0.0f, 0.0f, 0.0f};
59};
60
68
84JointSprings prepareJoints(
85 const std::vector<PhysicsBody>& bodies,
86 std::vector<JointConstraint>& joints,
87 float dt
88);
89
99void warmStartJoints(std::vector<PhysicsBody>& bodies, const std::vector<JointConstraint>& joints);
100
113void solveJointPass(
114 std::vector<PhysicsBody>& bodies,
115 std::vector<JointConstraint>& joints,
116 const JointSprings& springs,
117 bool useBias
118);
119
120} // namespace Vkm::Engine
One joint, resolved to the two solver bodies it constrains.
Definition joint_solver.h:19
glm::vec3 impulse
Accumulated over this tick's passes from last tick's final value, world space.
Definition joint_solver.h:49
glm::vec3 anchorA
World, relative to A's origin.
Definition joint_solver.h:23
bool solvable
The solve's working state, built once per tick by prepareJoints.
Definition joint_solver.h:42
glm::vec3 holdImpulse
Accumulated like impulse, world space, within holdLimit.
Definition joint_solver.h:58
glm::vec3 anchorB
World, relative to B's origin.
Definition joint_solver.h:24
glm::quat heldRotation
B's rotation in A's frame that the hold keeps.
Definition joint_solver.h:52
glm::mat3 holdMass
Angular impulse per unit of relative spin.
Definition joint_solver.h:56
glm::vec3 bias
Relative velocity that closes the drift, stiffness applied.
Definition joint_solver.h:44
glm::vec3 holdBias
Relative spin that turns the pair back.
Definition joint_solver.h:57
bool holdSolvable
False when free, or nothing can turn.
Definition joint_solver.h:55
glm::mat3 mass
Impulse per unit of relative anchor velocity.
Definition joint_solver.h:43
float holdLimit
Most angular impulse it carries this tick.
Definition joint_solver.h:53
float holdTorque
Joint::holdTorque; 0 leaves the rotation free.
Definition joint_solver.h:51
float distance
Distance the anchors are held at; negative for a point joint.
Definition joint_solver.h:32
The two springs a joint solves with: the anchors', and the softer hold on the angle.
Definition joint_solver.h:64
The three numbers that make a correction a stiff, damped spring.
Definition solver_math.h:70