vkmEngine 1.0.15
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 {
51 static constexpr int DEFAULT_BONE_LAYER = 1 << 1;
52
53 bool active = false;
55
62
69 float rigScale = 1.0f;
70 std::vector<RagdollBone> bones;
71
73 bool held = false;
74};
75
76} // namespace Vkm::Engine
77
78VKM_REFLECT_BEGIN(::Vkm::Engine::Ragdoll)
79 VKM_F(active)
80 VKM_F(boneLayer)
81 VKM_F(rigScale)
82VKM_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:70
bool active
Physics drives the rig when true.
Definition ragdoll.h:53
float rigScale
The rig's world scale when the bones were built.
Definition ragdoll.h:69
int boneLayer
The layer bit the bones were built on.
Definition ragdoll.h:61
bool held
The pose held the bones last tick; runtime, not serialized.
Definition ragdoll.h:73
static constexpr int DEFAULT_BONE_LAYER
The layer bit the bones go on unless the build names another (RagdollSettings::boneLayer).
Definition ragdoll.h:51
EntityId root
Node the bones are grouped under.
Definition ragdoll.h:54