vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
ragdoll.h
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include <glm/glm.hpp>
7#include <glm/gtc/quaternion.hpp>
8
9#include "core/reflect.h"
10#include "ecs/entity.h"
11
12namespace Vkm::Engine {
13
23 int32_t bone = -1;
25 glm::mat4 bodyFromBone = glm::mat4(1.0f);
26
33 glm::vec3 lastPosition = {0.0f, 0.0f, 0.0f};
34 glm::quat lastRotation = {1.0f, 0.0f, 0.0f, 0.0f};
35 bool posed = false;
36};
37
49struct Ragdoll {
50 bool active = false;
52
58 int boneLayer = 1 << 1;
59
66 float rigScale = 1.0f;
67 std::vector<RagdollBone> bones;
68
70 bool held = false;
71};
72
73} // namespace Vkm::Engine
74
75VKM_REFLECT_BEGIN(::Vkm::Engine::Ragdoll)
76 VKM_F(active)
77 VKM_F(boneLayer)
78 VKM_F(rigScale)
79VKM_REFLECT_END()
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
One bone of a ragdoll, and the body that moves it.
Definition ragdoll.h:22
int32_t bone
Index into the rig's bone array.
Definition ragdoll.h:23
glm::mat4 bodyFromBone
Bone space -> body space: the bone as the body sees it.
Definition ragdoll.h:25
glm::vec3 lastPosition
Where the pose put the body last tick, world space; runtime, not serialized.
Definition ragdoll.h:33
EntityId body
The entity simulating it.
Definition ragdoll.h:24
Turns a rig over to physics, and back.
Definition ragdoll.h:49
std::vector< RagdollBone > bones
One per simulated bone.
Definition ragdoll.h:67
bool active
Physics drives the rig when true.
Definition ragdoll.h:50
float rigScale
The rig's world scale when the bones were built.
Definition ragdoll.h:66
int boneLayer
The layer bit the bones were built on.
Definition ragdoll.h:58
bool held
The pose held the bones last tick; runtime, not serialized.
Definition ragdoll.h:70
EntityId root
Node the bones are grouped under.
Definition ragdoll.h:51