appsinacup / godot-rapier-physics

Godot Rapier Physics – A 2D and 3D drop-in replacement for the Godot engine that adds stability and fluids.
https://godot.rapier.rs
MIT License
348 stars 17 forks source link

SegmentShape2D collider not working correctly #181

Closed mikahpls closed 2 months ago

mikahpls commented 2 months ago

Describe the bug

If the SegmentShape2D has negative and positive coordinates in one axis, e.g. A = (0, 100) and B = (0, -100), the collider will only work on the positive side, meaning: A = (0, 100) and B = (0, 0). The other side will be discarded bespite being shown by the debug setting "visible collision shapes"

To Reproduce

Create a StaticBody2D with a CollisionShape2D as a child. There create as a collision shape a SegmentShape2D with A = (-200, 0) and B = (200, 0). Create a Rigidbody2D with a CollisionShape2D as a child and give it a CircleShape2D. Place a copy of the Rigidbody over the left and the right side of the line and press play with Rapier2D selected as PhysicsEngine. The left Rigidbody will land on the line, the right one will fall through.

A clear and concise description of what you expected to happen.

Both Rigidbodies should land on the line.

Environment:

Please attach a zip with project where issue occurs.

https://drive.google.com/file/d/12NpukZ67KxSGs839RAveVP9z6coZ9ghz/view?usp=drive_link Sorry, compressed project was bigger than 25 MB.

Ughuuu commented 2 months ago

Thanks you for making the issue. for future, you can remove the addons folder, as that is not needed.

mikahpls commented 2 months ago

After further investigation we found, that the vector from A to B (AB) can not have a negative component.

For example: A = (0, 100) and B = (100, 0) results in AB = (100, -100). The resulting collider will ignore the negative part of AB and realize itself in A_collider = (0, 100) and B_collider = (100, 100)

image

A temporary fix for us is to set A to (0, 0) and B = B - A. Then everything works fine.