-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Change physics disabled booleans to enabled #44141
Conversation
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.
Thanks for doing this necessary cleaning!
I've left some comments about details, mostly around boolean setters/getters naming.
@@ -31,20 +32,22 @@ | |||
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference. | |||
</description> | |||
</method> | |||
<method name="get_rid" qualifiers="const"> | |||
<return type="RID"> | |||
<method name="enable_shape_owner"> |
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.
It would be a bit clearer to call this method set_shape_owner_enabled
since it can be used to disable as well. It can be a simple setter, without the default value.
@@ -35,6 +36,17 @@ | |||
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference. | |||
</description> | |||
</method> | |||
<method name="enable_shape_owner"> |
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.
Same for 3D.
@@ -590,8 +590,8 @@ class PhysicsServer3D : public Object { | |||
virtual void joint_set_solver_priority(RID p_joint, int p_priority) = 0; | |||
virtual int joint_get_solver_priority(RID p_joint) const = 0; | |||
|
|||
virtual void joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) = 0; | |||
virtual bool joint_is_disabled_collisions_between_bodies(RID p_joint) const = 0; | |||
virtual void joint_enable_collisions_between_bodies(RID p_joint, const bool p_enable = true) = 0; |
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's no need for the default value (same for 2D and 3D), it's always called with an explicit argument (which is clearer anyway).
@@ -434,6 +434,34 @@ | |||
Creates a physics body. | |||
</description> | |||
</method> | |||
<method name="body_enable_shape"> |
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.
Same as enable_shape_owner
, it would be more explicit with something like body_set_shape_enabled
, without the default value.
Sets whether or not the body's shape specified by [code]shape_idx[/code] is enabled. | ||
</description> | ||
</method> | ||
<method name="body_enable_shape_one_way_collision"> |
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.
Same as enable_shape_owner
, it would be more explicit with something like body_set_shape_one_way_collision_enabled
, without the default value.
@@ -51,6 +51,19 @@ | |||
Creates an [Area3D]. | |||
</description> | |||
</method> | |||
<method name="area_enable_shape"> |
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.
Same as for 2D with area_enable_shape
and body_enable_shape
.
@@ -429,6 +430,30 @@ | |||
Creates a physics body. The first parameter can be any value from [enum BodyMode] constants, for the type of body created. Additionally, the body can be created in sleeping state to save processing time. | |||
</description> | |||
</method> | |||
<method name="body_enable_continuous_collision_detection"> |
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 method could be body_set_continuous_collision_detection
since it can be enabled or disabled.
@@ -231,10 +231,10 @@ void PhysicsShapeQueryParameters3D::_bind_methods() { | |||
ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters3D::set_exclude); | |||
ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters3D::get_exclude); | |||
|
|||
ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_bodies); |
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.
In order to make things more explicit, you can use set_colliding_with_bodies
(without the default value), is_colliding_with_bodies
, set_colliding_with_areas
, is_colliding_with_areas
.
See #33026 for the discussion about boolean setters/getters convention.
To avoid discussing boolean naming standards here, which would be off topic and lost when this PR is merged, I've created godotengine/godot-proposals#1994, where it can be discussed and agreed separately. |
b5df8f3
to
4b673e8
Compare
Rebased following merge of #44703. |
4b673e8
to
1d21245
Compare
Rebased following merge of #45519. |
1d21245
to
92b5cd5
Compare
Rebased following merge of #45564. |
92b5cd5
to
0baaacd
Compare
0baaacd
to
a8ac549
Compare
a8ac549
to
26d863d
Compare
Rebased following merge of ##46704. |
26d863d
to
cc01559
Compare
I think instead of just rebasing every few days you should also address the review comments 🤔 |
@KoBeWi As mentioned previously, the review comments were based on a different opinion about what the naming standards should be. I created proposal godotengine/godot-proposals#1994 to keep this discussion separate from the PR. There seems to be general agreement with that proposal; so I don't think there is any need to make any further changes. |
cc01559
to
d1dc168
Compare
Updated documentation with |
d1dc168
to
442d457
Compare
Rebased following merge of #47846. |
442d457
to
ac03f8d
Compare
I think the review comments should be addressed to match the current status quo. There are some points still under discussion in godotengine/godot-proposals#1994, and especially the name of setters starting with |
Save for some cases where wording is bad, I generally prefer the boolean as the exception rather the always positive, since it makes it easier to understand the intention and common use case of it. Also in this case I don't think it can be considered a double negative as 'disabled' is the opposite, but not the negative of 'enabled' |
What's the status on this? |
Since there is no consensus, there are unresolved requests for changes, this PR has been idle for over a year, and we're at the end of the beta stage, I'm going to close it. Thanks for your contribution nonetheless. Perhaps for Godot 5 we'll figure out a better way to consistently name these boolean properties. |
To avoid double negatives, boolean names should be positive. Currently, a
Shape
defaults to not beingdisabled
. Similarly, to enable collisions between the bodies attached to aJoint
's we need to notexclude_nodes
.This PR makes physics boolean names positive, standardises their functions; and updates the documentation.
Part of #16863, specifically this comment and the following two comments.
Note: Includes a clarification of
pickable
being associated withInputEvent
s, specificallyInputEventMouse
events i.e. it has nothing to do with rays (other than a ray being used in 3D to detect objects under the mouse). Also ensures that 2D and 3D are the same (except for 2D being disabled by default and 3D enabled).