#ifndef DUST3D_RAGDOLL_H #define DUST3D_RAGDOLL_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "rigger.h" #include "jointnodetree.h" class RagDoll : public QObject { Q_OBJECT public: RagDoll(const std::vector *rigBones, const JointNodeTree *initialJointNodeTree=nullptr); ~RagDoll(); bool stepSimulation(float amount); const JointNodeTree &getStepJointNodeTree(); const std::vector> &getStepBonePositions(); private: btDefaultCollisionConfiguration *m_collisionConfiguration = nullptr; btCollisionDispatcher *m_collisionDispather = nullptr; btDbvtBroadphase *m_broadphase = nullptr; btSequentialImpulseConstraintSolver *m_constraintSolver = nullptr; btDynamicsWorld *m_world = nullptr; btCollisionShape *m_groundShape = nullptr; btRigidBody *m_groundBody = nullptr; float m_groundY = 0; std::vector> m_boneInitialPositions; std::map m_boneShapes; std::map m_boneBodies; std::vector m_boneConstraints; std::map m_boneMiddleMap; std::map m_boneLengthMap; std::map m_boneRadiusMap; JointNodeTree m_jointNodeTree; JointNodeTree m_stepJointNodeTree; std::vector m_bones; std::vector> m_stepBonePositions; std::map m_boneNameToIndexMap; std::map> m_chains; btRigidBody *createRigidBody(btScalar mass, const btTransform &startTransform, btCollisionShape *shape); void createDynamicsWorld(); void addConstraint(const RiggerBone &child, const RiggerBone &parent, bool isBorrowedParent=false); }; #endif