-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return RID instead of Object id in area-body_shape_entered-exited signals. #42742
Conversation
You're talking about the first parameter right? The body / area int id. I think I was wondering about that last I used these signals. It seemed redundant and thought maybe it was included by accident, since the API generally doesn't work with RIDs unless you're working with the servers, and when needed you can get that information from the instance itself. |
@avencherus Yes, this is about updating the first parameter. The RID is needed when, as described in #12215, there is no object, and, as you suggest, you're working directly with the server. |
@madmiraal Yeah, that makes sense. The more I look at it, the more I think that the RID was probably the original intention. At least from my point of view in development, I agree with your compatibility statement. If working with instances, I can't imagine myself or many others who would ignore the body reference in favor of doing an extra step like But more importantly, it would be fixing a hole for performance use cases like that bullet storm example. |
The current documentation also says that it is the RID; so that's the expectation and the issue this PR fixes e.g. for
|
f97f4c6
to
9ab7e9e
Compare
Rebased following merge of #44630. |
Is it possible that the pointer to collision object gets invalidated in the middle of signal emission? In that case, having the instance id would be preferable to use over |
I don't think it's possible, and even if it were the Object's instance id would be invalid too. Besides, the second parameter (the |
Rebased following merge of #46364. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is going to help in solving the underlying use case in godotengine/godot-proposals#2543.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no compatibility problem, given the documentation already states ids are supposed to be RIDs from the physics server:
Line 120 in cc57bb9
[code]area_id[/code] the [RID] of the other Area2D's [CollisionObject2D] used by the [PhysicsServer2D]. |
Thanks! |
Currently, the
Area
andRigidBody
area_shape_entered
,area_shape_exited
,body_shape_entered
andbody_shape_exited
signals incorrectly (try to) return the entering or exitingObject
's instance id instead of itsRID
. This PR ensures the signals correctly return theRID
.Fixes #12215
Note: Although, one could argue that this is a compat breaking change, it is highly unlikely that anyone is using the
Object
's instance id, because, as far as I know, it is generally only used to obtain theObject
, which is passed as the second parameter. Should theObject
's instance id be needed, it is easily obtained usingarea.get_instance_id()
orbody.get_instance_id()
.