-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
[Bullet] Bullet physics: scaled collision shapes return incorrect normals #30214
Comments
I think Bullet does not support non-uniformly-scaled collision shapes. |
Thanks @Zylann! That was the issue. It works fine when using a uniform scale. Since that fixed the issue, should I keep this issue open and rename it accordingly or just close it? |
Oh, yeah there was definitely a change between 3.1.1 and current master in relation to this. I was somewhat shocked to find that my game was totally broken when trying it last week in current master. I quickly discovered that any scaling(non-uniform of not) of a collision shape would cause problems. Was just a matter of setting every collision shape in my game to 1,1,1 scale and just adjusting the collision shape dimensions directly. This should be documented as a breaking change for 3.2, as no doubt many users will encounter it. |
@jonri ah, thanks for the info! Still seems like a good idea that not have any scaling info on collision shapes, so I am glad I at least changed them all. |
Godot version:
Godot 3.1.1 and Godot 3.2.dev.b4aba3ae7
OS/device including version:
Windows 10 64bit, Nvidia 660 TI
Issue description:
Bullet physics doesn't seem to take the scale of the collision shape into account when returning the normal vector from a Raycast, though the position returned is accurate. GodotPhysics does not have this issue.
While working on my painting system, I discovered that angled surfaces, like ramps, were not returning the correct normal vectors when using a raycast.
After many hours of debugging, I found that for a 45 degree surface, the raycast returned was off by roughly 4 degrees. For other angles, the offset is less, but still there. The raycast would not return accurate normal vectors for angular surfaces, it was always off at least by a couple degrees. For my paint system, the decal-like shader I am using requires fairly precise angles, so this issue made it nearly impossible to paint on angled surfaces.
I should note that the issue is only present in angled collision meshes. A rotated cube, for example, does not have this issue.
After lots of investigating, trying to write code to compensate, and more, I discovered the source of the issue: The MeshInstance nodes I was using for the ramp were scaled. For whatever reason, the scale of the MeshInstance node was messing up the normal vector returned by the raycast, despite everything else physics related, including the returned raycast position, works fine.
On a whim, I decided to see if the issue is present in both Bullet and GodotPhysics. Surprisingly, GodotPhysics does not have this issue, it returns the correct normal vector regardless of the scale, which is what I would expect and my project works like normal.
This leads me to believe the issue is somewhere with Bullet. I would expect the normal vector returned by the raycast to account for the scale of the collision shape when returning the normal vector.
I can attempt to help fix this issue, but I know little about Bullet/Game-Physics, so I have no idea where to look or what in the code base could be causing the issue.
Steps to reproduce:
For the sample project, try the following with both Bullet physics and Godot physics:
Minimal reproduction project:
Godot_Scaled_Physics_Shape_Example.zip
The text was updated successfully, but these errors were encountered: