-
Notifications
You must be signed in to change notification settings - Fork 0
/
rigid_body_object.h
55 lines (41 loc) · 1.63 KB
/
rigid_body_object.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "obj_model.h"
#include "pbd/pbd.h"
class RigidBodyComponent : public TransformComponent {
struct RigidBody* rigid_body_ = nullptr;
struct ICollisionObject* collision_ = nullptr;
bool b_self_update_ = false;
virtual ~RigidBodyComponent() {};
void on_transformed();
public:
static const ComponentType type_ = ComponentType::kRigidBody;
virtual ComponentType GetType() const override { return type_; }
RigidBodyComponent() {};
const Pose& getPose() const { return rigid_body_->pose; }
static void on_transformed(TransformComponent* );
void setKinematic(bool b_kinematic);
virtual void UpdateComponent(float dt) override;
static RigidBodyComponent* Create(class PBDSimulation *sim, ICollisionDetection* cd, const vec3 &dim, bool b_invert);
static void Destroy(RigidBodyComponent* comp, PBDSimulation *sim, ICollisionDetection* cd);
};
class RigidBodyObject: public GameObject {
struct RigidBodyTuple {
TransformComponent* tr_;
RigidBodyComponent* rb_;
MeshComponent* mesh_;
};
RigidBodyTuple Tuple_;
static void on_transformed(TransformComponent*);
public:
static RigidBodyObject* Create(const vec3 &dim);
RigidBodyObject() = default;
~RigidBodyObject();
// IEditorObject
virtual int GetIconID() const override { return 2; }
//
void addToSimulation(PBDSimulation* sim);
void removeFromSimulation(PBDSimulation* sim);
void setKinematic(bool);
virtual const char* GetName() const override { return "rigid body"; };
virtual void Update(float dt) override;
void SetTransform(const vec3& pos, const quaternion& rot);
};