diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/bullet/bullet_physics_server.cpp | 4 | ||||
-rw-r--r-- | modules/bullet/bullet_physics_server.h | 2 | ||||
-rw-r--r-- | modules/bullet/rigid_body_bullet.cpp | 14 | ||||
-rw-r--r-- | modules/bullet/rigid_body_bullet.h | 5 |
4 files changed, 12 insertions, 13 deletions
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 93642f2d5c..e601884486 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -824,10 +824,10 @@ bool BulletPhysicsServer3D::body_is_omitting_force_integration(RID p_body) const return body->get_omit_forces_integration(); } -void BulletPhysicsServer3D::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { +void BulletPhysicsServer3D::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata); + body->set_force_integration_callback(p_callable, p_udata); } void BulletPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) { diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h index 856ff74963..de0379c873 100644 --- a/modules/bullet/bullet_physics_server.h +++ b/modules/bullet/bullet_physics_server.h @@ -246,7 +246,7 @@ public: virtual void body_set_omit_force_integration(RID p_body, bool p_omit) override; virtual bool body_is_omitting_force_integration(RID p_body) const override; - virtual void body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata = Variant()) override; + virtual void body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata = Variant()) override; virtual void body_set_ray_pickable(RID p_body, bool p_enable) override; diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 433bff8c38..675da1a597 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -346,16 +346,17 @@ void RigidBodyBullet::dispatch_callbacks() { Variant variantBodyDirect = bodyDirect; - Object *obj = ObjectDB::get_instance(force_integration_callback->id); + Object *obj = force_integration_callback->callable.get_object(); if (!obj) { // Remove integration callback - set_force_integration_callback(ObjectID(), StringName()); + set_force_integration_callback(Callable()); } else { const Variant *vp[2] = { &variantBodyDirect, &force_integration_callback->udata }; Callable::CallError responseCallError; int argc = (force_integration_callback->udata.get_type() == Variant::NIL) ? 1 : 2; - obj->call(force_integration_callback->method, vp, argc, responseCallError); + Variant rv; + force_integration_callback->callable.call(vp, argc, rv, responseCallError); } } @@ -371,16 +372,15 @@ void RigidBodyBullet::dispatch_callbacks() { previousActiveState = btBody->isActive(); } -void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) { +void RigidBodyBullet::set_force_integration_callback(const Callable &p_callable, const Variant &p_udata) { if (force_integration_callback) { memdelete(force_integration_callback); force_integration_callback = nullptr; } - if (p_id.is_valid()) { + if (p_callable.get_object()) { force_integration_callback = memnew(ForceIntegrationCallback); - force_integration_callback->id = p_id; - force_integration_callback->method = p_method; + force_integration_callback->callable = p_callable; force_integration_callback->udata = p_udata; } } diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index a4be7f9e07..843ff4a7af 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -154,8 +154,7 @@ public: }; struct ForceIntegrationCallback { - ObjectID id; - StringName method; + Callable callable; Variant udata; }; @@ -240,7 +239,7 @@ public: virtual void set_space(SpaceBullet *p_space); virtual void dispatch_callbacks(); - void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant()); + void set_force_integration_callback(const Callable &p_callable, const Variant &p_udata = Variant()); void scratch_space_override_modificator(); virtual void on_collision_filters_change(); |