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

PhysicsDirectBodyState3D: report contact points using global coordinates #76088

Merged
merged 1 commit into from
May 10, 2023

Conversation

rburing
Copy link
Member

@rburing rburing commented Apr 15, 2023

Also update the documentation to reflect this in both 2D and 3D. (It was already the case in 2D, just not documented.)

Follow-up to #58880

This is the most pragmatic solution, keeping 2D as it has always been (since Godot was made open source), and updating 3D which was bugged for a long time, then fixed recently by #58880 to be self-consistent but inconsistent with 2D; now this PR makes it consistent with 2D.

Also update the documentation to reflect this in both 2D and 3D.
@rburing
Copy link
Member Author

rburing commented Apr 15, 2023

Technically breaks compatibility, but only in methods which were just recently made bug-free.

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

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

I agree with the change. More consistency is desired between 2D and 3D features.

@clayjohn
Copy link
Member

Adding offset_a to global_b seems a little bit fishy to me. But I'm pretty unfamiliar with this code. Could you explain why offset_a is used and not offset_b as in the previous code?

@rburing
Copy link
Member Author

rburing commented Apr 15, 2023

@clayjohn The reason is basically this:

//use local A coordinates to avoid numerical issues on collision detection

The global_A and global_B vectors are the coordinates of the contact points in a coordinate system which is centered on body A (and has the same orientation as the global coordinate system). So to translate to the global coordinate system you add offset_A, which is defined as body A's origin in global coordinates.

Edit: For completeness, the previous code was reporting global_A and global_B - offset_B, where offset_B = B->get_transform().get_origin() - A->get_transform().get_origin(), so it was reporting offsets from body origins, as noted in the linked issue that this PR closes.

@akien-mga akien-mga merged commit 769d8a7 into godotengine:master May 10, 2023
@akien-mga
Copy link
Member

Thanks!

@rburing rburing deleted the contact_points_global_3d branch May 10, 2023 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants