-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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] Convex Collision Sibling wrong margin with Bullet #27427
Comments
This is still reproducible in 3.2.2 RC 2 with the above project. It only affects the Bullet backend, GodotPhysics doesn't have this margin. |
It's how bullet handles the margin. Depending the shape type, it may add or remove the specified amount of margin; this because each algorithm perform better with positive or negative margin. Try to lower the Make the engine to automatically mask this margin is not a good idea IMO. |
Maybe this should be documented in the And/or it might be worth having a doc page about differences between GodotPhysics and Bullet, like we have for GLES2 vs GLES3. |
Yes, I think that would be useful have the list of the various differences. |
I would still consider this a bug, because the type of It brings up the debate on why collision masks are required and how they are used. As @AndreaCatania points out, the margin makes the GJK distance algorithm an efficient way of determining collisions by terminating if the distance is known to be less than the margin. In Bullet physics Godot uses collision margins differently. I've described this in detail here, but the short, over-simplified version is: it uses the margin to push objects apart and then allows them to come back together again. |
The reason why I would not mark this as bug is because try to mask this issue by making the shape bigger or smaller than the mesh, when generating the collision shape is not a good option: Each physics engine has its own way to handle the margins and just mask this issue will just invert the problem, that will be then present with Godot Physics. However, this is not all; because someone may add another physics engine (even if not supported by the Godot community, or just privately for their game). In any case, the differences between physics engines exists (otherwise would not even make sense integrate a new one), and all the features of the Game Engine should just do the "right" thing. So is better document instead of mask the various differences between physics engines. Of course, this is not always true, but for this case I think that is better document the difference and allow the developer choose how to deal with it:
|
I don't know what the solution is. I haven't looked into it. I'm definitely not suggesting the issue is masked; for all the reasons stated and more. But not knowing what the solution is doesn't stop it from being a bug. Whether the issue lies within Bullet or within Godot's implementation of Bullet doesn't stop it from being a bug. In the meantime, I agree that, as long as there isn't a solution, the known issue should be documented. |
I think the best solution at the moment is to make the margin very small and use double precision in bullet. The 4cm margin (8cm total between 2 objects) is pretty massive, and not only does it create gaps, but it creates potentially undesired behavior along edges (unexpected normals). |
The issue isn't easily fixable for if parent is PhysicsBody and child is CollisionPolygon:
var body = parent.get_rid()
for i in PhysicsServer.body_get_shape_count(body):
var shape = PhysicsServer.body_get_shape(body, i)
if PhysicsServer.shape_get_type(shape) == PhysicsServer.SHAPE_CONVEX_POLYGON:
var new_convex_polygon_shape = ConvexPolygonShape.new()
new_convex_polygon_shape.margin = 0
new_convex_polygon_shape.set_points(PhysicsServer.shape_get_data(shape))
var new_collision_shape = CollisionShape.new()
new_collision_shape.shape = new_convex_polygon_shape
new_collision_shape.transform = child.transform
parent.add_child(new_collision_shape)
child.free() |
Godot version:
3.1
OS/device including version:
Windows 10 x64 / NVIDIA GeForce GTX 1060 6GB / Intel Core i7 4790K
Issue description:
When a CollisionShape is created from a mesh using "Create Convex Collision Sibling", it's being it is getting away from the bottom cube by the "collision margin" distance (0.04):
This only happens with ConvexPolygonShape.
With ConcavePolygonShape or even a BoxShape or other native collision shapes, this does not occur.
Steps to reproduce:
Minimal reproduction project:
testes.zip
The text was updated successfully, but these errors were encountered: