diff options
Diffstat (limited to 'servers/physics_server.h')
-rw-r--r-- | servers/physics_server.h | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/servers/physics_server.h b/servers/physics_server.h index c6d312e0fe..7cccd9b4cb 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -71,16 +71,16 @@ public: virtual int get_contact_count() const = 0; - virtual Vector3 get_contact_local_pos(int p_contact_idx) const = 0; + virtual Vector3 get_contact_local_position(int p_contact_idx) const = 0; virtual Vector3 get_contact_local_normal(int p_contact_idx) const = 0; virtual int get_contact_local_shape(int p_contact_idx) const = 0; virtual RID get_contact_collider(int p_contact_idx) const = 0; - virtual Vector3 get_contact_collider_pos(int p_contact_idx) const = 0; + virtual Vector3 get_contact_collider_position(int p_contact_idx) const = 0; virtual ObjectID get_contact_collider_id(int p_contact_idx) const = 0; virtual Object *get_contact_collider_object(int p_contact_idx) const; virtual int get_contact_collider_shape(int p_contact_idx) const = 0; - virtual Vector3 get_contact_collider_velocity_at_pos(int p_contact_idx) const = 0; + virtual Vector3 get_contact_collider_velocity_at_position(int p_contact_idx) const = 0; virtual real_t get_step() const = 0; virtual void integrate_forces(); @@ -276,7 +276,7 @@ public: virtual void space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) = 0; virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0; - // this function only works on fixed process, errors and returns null otherwise + // this function only works on physics process, errors and returns null otherwise virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space) = 0; virtual void space_set_debug_contacts(RID p_space, int p_max_contacts) = 0; @@ -357,7 +357,7 @@ public: BODY_MODE_STATIC, BODY_MODE_KINEMATIC, BODY_MODE_RIGID, - //BODY_MODE_SOFT + BODY_MODE_SOFT, BODY_MODE_CHARACTER }; @@ -464,6 +464,9 @@ public: virtual void body_set_ray_pickable(RID p_body, bool p_enable) = 0; virtual bool body_is_ray_pickable(RID p_body) const = 0; + // this function only works on physics process, errors and returns null otherwise + virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body) = 0; + struct MotionResult { Vector3 motion; @@ -655,6 +658,43 @@ public: ~PhysicsServer(); }; +typedef PhysicsServer *(*CreatePhysicsServerCallback)(); + +class PhysicsServerManager { + struct ClassInfo { + String name; + CreatePhysicsServerCallback create_callback; + + ClassInfo() + : name(""), create_callback(NULL) {} + + ClassInfo(String p_name, CreatePhysicsServerCallback p_create_callback) + : name(p_name), create_callback(p_create_callback) {} + + ClassInfo(const ClassInfo &p_ci) + : name(p_ci.name), create_callback(p_ci.create_callback) {} + }; + + static Vector<ClassInfo> physics_servers; + static int default_server_id; + static int default_server_priority; + +public: + static const String setting_property_name; + +private: + static void on_servers_changed(); + +public: + static void register_server(const String &p_name, CreatePhysicsServerCallback p_creat_callback); + static void set_default_server(const String &p_name, int p_priority = 0); + static int find_server_id(const String &p_name); + static int get_servers_count(); + static String get_server_name(int p_id); + static PhysicsServer *new_default_server(); + static PhysicsServer *new_server(const String &p_name); +}; + VARIANT_ENUM_CAST(PhysicsServer::ShapeType); VARIANT_ENUM_CAST(PhysicsServer::SpaceParameter); VARIANT_ENUM_CAST(PhysicsServer::AreaParameter); |