Skip to content
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

Closed

Conversation

madmiraal
Copy link
Contributor

To avoid double negatives, boolean names should be positive. Currently, a Shape defaults to not being disabled. Similarly, to enable collisions between the bodies attached to a Joint's we need to not exclude_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 with InputEvents, specifically InputEventMouse 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).

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a 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.

doc/classes/CollisionObject2D.xml Show resolved Hide resolved
doc/classes/CollisionShape2D.xml Outdated Show resolved Hide resolved
@@ -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">
Copy link
Contributor

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">
Copy link
Contributor

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;
Copy link
Contributor

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">
Copy link
Contributor

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">
Copy link
Contributor

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">
Copy link
Contributor

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">
Copy link
Contributor

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);
Copy link
Contributor

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.

@madmiraal
Copy link
Contributor Author

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.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #44703.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #45519.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #45564.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #44630, #45775 and #45852.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #45783, #45863, #46148 and #46221.

@madmiraal
Copy link
Contributor Author

Rebased following merge of ##46704.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #46917 and #46937.

@KoBeWi
Copy link
Member

KoBeWi commented Mar 26, 2021

I think instead of just rebasing every few days you should also address the review comments 🤔

@madmiraal
Copy link
Contributor Author

@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.

@madmiraal
Copy link
Contributor Author

Updated documentation with --doctool ..

@madmiraal
Copy link
Contributor Author

Rebased following merge of #47846.

@madmiraal
Copy link
Contributor Author

Rebased following merge of #42770 and #47485.

@akien-mga
Copy link
Member

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 enable_* for setters which can both set ON and OFF seems unlikely to become the standard IMO.

@reduz
Copy link
Member

reduz commented Jul 29, 2022

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'

@fabriceci
Copy link
Contributor

fabriceci commented Aug 26, 2022

What's the status on this?

@YuriSizov
Copy link
Contributor

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.

@YuriSizov YuriSizov closed this Jan 25, 2023
@YuriSizov YuriSizov removed this from the 4.0 milestone Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants