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

PhysicsDirectSpaceState.intersect_ray returns a different result with Bullet and GodotPhysics #49055

Open
Tracked by #45333
QazPolma opened this issue May 25, 2021 · 4 comments

Comments

@QazPolma
Copy link

QazPolma commented May 25, 2021

Godot version:
3.3.2.stable

OS/device including version:
Linux Mint 20.1(Ubuntu 20.04 LTS)

Issue description:
When raycasting from the center of a KinematicBody to another KinematicBody with "get_world().direct_space_state.intersect_ray", I get different results depending on PhysicsEngine.
With "Bullet" I get the second body and with "GodotPhysics" I get the first body.

Steps to reproduce:
1.Make 2 KinematicBody objects.
2.Raycast between the 2 bodies.
3.Change "Project settings->Physics->3D->Physics Engine"

Minimal reproduction project:

RaycastBug_v2.zip

Edit: Removed the exclusion lists issue, since it was because of incorrect setup.

@pouleyKetchoupp
Copy link
Contributor

I can confirm the inconsistency between Bullet and Godot Physics.

Exclusion lists should work though. In your project, you're setting self in the exclusion list for the raycast, and because the script is on the root node, it doesn't affect the raycast. You would need to set the kinematic body itself in the exclude list to make it work properly.

@QazPolma
Copy link
Author

Thank you for the explanation. I have updated the case accordingly.

@rburing
Copy link
Member

rburing commented Mar 24, 2022

The behavior of raycasts with Bullet in this case is due to the following code:

//don't report time of impact for motion away from the contact normal (or causes minor penetration)
if (result.m_normal.dot(r) >= -result.m_allowedPenetration)
return false;

Even if that weren't there, there would still be this check:

//add hit
if (castResult.m_normal.length2() > btScalar(0.0001))

There are no settings in Bullet to change this behavior, so besides documenting this there is not much we can do (unless someone changes Bullet upstream).

In GodotPhysics in master there is a hit_from_inside parameter that can be passed in to intersect_ray.

@prominentdetail
Copy link
Contributor

This may be related, but I found that having a collisionShape that has its Z extents set below 0.5 will cause GodotPhysics to fail to hit it (in this case the intersect_ray is traveling along the X axis straight through the object). It works fine in Bullet physics, but not in GodotPhysics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants