|
@@ -45,49 +45,15 @@ class AreaBullet;
|
|
|
class SpaceBullet;
|
|
|
class btRigidBody;
|
|
|
class GodotMotionState;
|
|
|
-class BulletPhysicsDirectBodyState;
|
|
|
-
|
|
|
-/// This class could be used in multi thread with few changes but currently
|
|
|
-/// is set to be only in one single thread.
|
|
|
-///
|
|
|
-/// In the system there is only one object at a time that manage all bodies and is
|
|
|
-/// created by BulletPhysicsServer and is held by the "singleton" variable of this class
|
|
|
-/// Each time something require it, the body must be set again.
|
|
|
+
|
|
|
class BulletPhysicsDirectBodyState : public PhysicsDirectBodyState {
|
|
|
GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState);
|
|
|
|
|
|
- static BulletPhysicsDirectBodyState *singleton;
|
|
|
-
|
|
|
-public:
|
|
|
- /// This class avoid the creation of more object of this class
|
|
|
- static void initSingleton() {
|
|
|
- if (!singleton) {
|
|
|
- singleton = memnew(BulletPhysicsDirectBodyState);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- static void destroySingleton() {
|
|
|
- memdelete(singleton);
|
|
|
- singleton = nullptr;
|
|
|
- }
|
|
|
-
|
|
|
- static void singleton_setDeltaTime(real_t p_deltaTime) {
|
|
|
- singleton->deltaTime = p_deltaTime;
|
|
|
- }
|
|
|
-
|
|
|
- static BulletPhysicsDirectBodyState *get_singleton(RigidBodyBullet *p_body) {
|
|
|
- singleton->body = p_body;
|
|
|
- return singleton;
|
|
|
- }
|
|
|
-
|
|
|
public:
|
|
|
- RigidBodyBullet *body;
|
|
|
- real_t deltaTime;
|
|
|
+ RigidBodyBullet *body = nullptr;
|
|
|
|
|
|
-private:
|
|
|
BulletPhysicsDirectBodyState() {}
|
|
|
|
|
|
-public:
|
|
|
virtual Vector3 get_total_gravity() const;
|
|
|
virtual float get_total_angular_damp() const;
|
|
|
virtual float get_total_linear_damp() const;
|
|
@@ -135,7 +101,7 @@ public:
|
|
|
virtual int get_contact_collider_shape(int p_contact_idx) const;
|
|
|
virtual Vector3 get_contact_collider_velocity_at_position(int p_contact_idx) const;
|
|
|
|
|
|
- virtual real_t get_step() const { return deltaTime; }
|
|
|
+ virtual real_t get_step() const;
|
|
|
virtual void integrate_forces() {
|
|
|
// Skip the execution of this function
|
|
|
}
|
|
@@ -188,6 +154,7 @@ public:
|
|
|
};
|
|
|
|
|
|
private:
|
|
|
+ BulletPhysicsDirectBodyState *direct_access = nullptr;
|
|
|
friend class BulletPhysicsDirectBodyState;
|
|
|
|
|
|
// This is required only for Kinematic movement
|
|
@@ -232,6 +199,8 @@ public:
|
|
|
RigidBodyBullet();
|
|
|
~RigidBodyBullet();
|
|
|
|
|
|
+ BulletPhysicsDirectBodyState *get_direct_state() const { return direct_access; }
|
|
|
+
|
|
|
void init_kinematic_utilities();
|
|
|
void destroy_kinematic_utilities();
|
|
|
_FORCE_INLINE_ KinematicUtilities *get_kinematic_utilities() const { return kinematic_utilities; }
|