stuff
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#ifndef RAGDOLL_CLASS
|
||||
#define RAGDOLL_CLASS
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "t.h"
|
||||
|
||||
class CharacterBody;
|
||||
class CollisionMesh;
|
||||
class Physics;
|
||||
class p;
|
||||
|
||||
// Splits a character's rig into rigid bodies joined by ball joints.
|
||||
// Each part collides using the rig triangles skinned mostly to its bones.
|
||||
class Ragdoll {
|
||||
public:
|
||||
struct Part {
|
||||
t_package transform; // scale is the part's bounding box, orientation starts at identity
|
||||
p* body = nullptr;
|
||||
CollisionMesh* mesh = nullptr;
|
||||
glm::vec3 restPosition = glm::vec3(0.0f);
|
||||
};
|
||||
|
||||
// rigMatrix is the model matrix the rig was being drawn with
|
||||
Ragdoll(CharacterBody& characterBody, const glm::mat4& rigMatrix, Physics& physics);
|
||||
|
||||
// Call once a frame after the physics steps
|
||||
void Update(float dt);
|
||||
|
||||
// Bone matrices in world space, draw the rig with an identity model matrix
|
||||
std::vector<glm::mat4> GetBoneMatrices() const;
|
||||
|
||||
const std::vector<Part*>& GetParts() const { return parts; }
|
||||
|
||||
private:
|
||||
void Reset();
|
||||
|
||||
std::vector<Part*> parts;
|
||||
std::vector<int> boneParts; // part index of each bone
|
||||
std::vector<glm::mat4> restBones; // world space bone matrices at the moment of going limp
|
||||
std::vector<glm::mat4> restInverses; // inverse of each part's starting transform
|
||||
int group = 0;
|
||||
float settleTimer = 0.0f;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user