vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
ragdoll_system.h
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include "core/system.h"
7#include "debug/fault_latch.h"
8#include "ecs/entity.h"
9#include "ecs/scene_observer.h"
10
11namespace Vkm::Engine {
12
13class Scene;
14struct Ragdoll;
15
27EntityId ragdollOwnerOf(const Scene& scene, EntityId body, int32_t* outBone = nullptr);
28
38void destroyRagdollBodies(Scene& scene, const Ragdoll& ragdoll);
39
50class RagdollSystem : public System, public ISceneObserver {
51 public:
52 RagdollSystem() = default;
53 ~RagdollSystem() override = default;
54
55 RagdollSystem(const RagdollSystem& other) = delete;
56 RagdollSystem& operator=(const RagdollSystem& other) = delete;
57
58 RagdollSystem(RagdollSystem && other) = delete;
59 RagdollSystem& operator=(RagdollSystem && other) = delete;
60
61 public:
62 void init(FrameContext& ctx) override;
63 void fixedUpdate(FrameContext& ctx) override;
64
66 void shutdown() override;
67
76 void onEntityDestroyed(EntityId id) override;
77
78 private:
79 Scene* m_scene = nullptr;
80 FaultLatch m_scaled;
81};
82
93bool isPosedByAnimation(const Scene& scene, EntityId entity);
94
103void markPosedByAnimation(const Scene& scene, std::vector<bool>& bySlot);
104
105} // namespace Vkm::Engine
Names a recurring fault once per gap rather than once a frame.
Definition fault_latch.h:11
void init(FrameContext &ctx) override
Called once after all systems are registered, before the first update.
void fixedUpdate(FrameContext &ctx) override
Execute this system at the fixed simulation rate.
void onEntityDestroyed(EntityId id) override
Destroy a ragdoll's bones when the thing they belong to goes.
void shutdown() override
Drops the observer registration, so nothing calls a dead system.
Central registry managing entities and an open set of component types.
Definition scene.h:29
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
Per-frame state bundle passed to every system.
Definition system.h:57
Turns a rig over to physics, and back.
Definition ragdoll.h:49