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

Use parameter classes instead of arguments for all physics queries #54573

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

pouleyKetchoupp
Copy link
Contributor

Same as what is already done for shape queries, applied to point and ray queries. Easier to document and more flexible to add more parameters.

Also expose intersect_point method to script in 3D.
(closes godotengine/godot-proposals#3262 for 4.0)

Remove intersect_point_on_canvas in 2D, replaced with a parameter.

ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_instance_id", PROPERTY_HINT_OBJECT_ID), "set_canvas_instance_id", "get_canvas_instance_id");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_NONE, itos(Variant::RID) + ":"), "set_exclude", "get_exclude");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for info, could you explain to me what does this itos(Variant::RID) + ":" in the PropertyInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks! I had just copied these lines from PhysicsShapeQueryParameters and I have no idea what it's supposed to do :D

It looks like it's the only case in the engine where an Array of a specific type is done this way, so I'm going to change it to the proper syntax, which seems to be PROPERTY_HINT_ARRAY_TYPE, "RID".

Copy link
Contributor

@fabriceci fabriceci Nov 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(there is the same syntax in the 3D file and 2 occurrences on both files)

@pouleyKetchoupp
Copy link
Contributor Author

Updated from @fabriceci's comment and made a couple more fixes around intersect_shape:
In 2D, I've made a little fix that allows motion to work properly and removed the note in doc that says it doesn't.
In 3D, this is not supported (yet) so I've added a similar note in the doc.

Same as what is already done for shape queries, applied to point and ray
queries. Easier to document and more flexible to add more parameters.

Also expose intersect_point method to script in 3D.
Remove intersect_point_on_canvas in 2D, replaced with a parameter.
@pouleyKetchoupp
Copy link
Contributor Author

And I've pushed one last fix to add the missing motion property in PhysicsShapeQueryParameters3D, since now it's working the same way as in 2D (shape motion in parameters rather than argument).

Should be good to go now :)

@akien-mga akien-mga merged commit 13aaa73 into godotengine:master Nov 5, 2021
@akien-mga
Copy link
Member

Thanks!

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.

Expose PhysicsDirectSpaceState.intersect_point() to scripting
3 participants