3030
3131#include " physics_body_2d.h"
3232
33- #include " scene/scene_string_names.h"
34-
3533void PhysicsBody2D::_bind_methods () {
3634 ClassDB::bind_method (D_METHOD (" move_and_collide" , " motion" , " test_only" , " safe_margin" , " recovery_as_collision" ), &PhysicsBody2D::_move, DEFVAL (false ), DEFVAL (0.08 ), DEFVAL (false ));
3735 ClassDB::bind_method (D_METHOD (" test_move" , " from" , " motion" , " collision" , " safe_margin" , " recovery_as_collision" ), &PhysicsBody2D::test_move, DEFVAL (Variant ()), DEFVAL (0.08 ), DEFVAL (false ));
@@ -48,12 +46,6 @@ PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) :
4846 set_pickable (false );
4947}
5048
51- PhysicsBody2D::~PhysicsBody2D () {
52- if (motion_cache.is_valid ()) {
53- motion_cache->owner = nullptr ;
54- }
55- }
56-
5749Ref<KinematicCollision2D> PhysicsBody2D::_move (const Vector2 &p_motion, bool p_test_only, real_t p_margin, bool p_recovery_as_collision) {
5850 PhysicsServer2D::MotionParameters parameters (get_global_transform (), p_motion, p_margin);
5951 parameters.recovery_as_collision = p_recovery_as_collision;
@@ -64,7 +56,7 @@ Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_motion, bool p_t
6456 // Create a new instance when the cached reference is invalid or still in use in script.
6557 if (motion_cache.is_null () || motion_cache->get_reference_count () > 1 ) {
6658 motion_cache.instantiate ();
67- motion_cache->owner = this ;
59+ motion_cache->owner_id = get_instance_id () ;
6860 }
6961
7062 motion_cache->result = result;
0 commit comments