godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.35k stars 21.06k forks source link

3D body_shape_entered/body_shape_exited works in Bullet but not in GodotPhysics #50050

Closed belzecue closed 3 years ago

belzecue commented 3 years ago

Godot version

v3.3.2.stable.official

System information

Linux Ubuntu 20.04 / Mesa Intel(R) UHD Graphics 605 (GLK 3)

Issue description

I had left my project physics at DEFAULT (Bullet) and happened to flip it over to GodotPhysics and got a shock seeing that my body_shape_entered/body_shape_exited signals no longer worked.

Here's a video demonstration showing it working under Bullet, changing over to GodotPhysics, and it no longer works:

https://www.youtube.com/watch?v=ntHQKE6akn4

What should happen -- and does happen under BULLET:

  1. Procedural generate 3D volume/gridmap
  2. Bake out meshes according to octant size (i.e. higher octant = less baked meshes). Each baked mesh has a staticbody
  3. Make all meshinstances invisible to begin with.
  4. Camera has sphere collision area radius to light/far length. Idea is that this collision sphere triggers meshes on (inside) and off (outside).
  5. Volume ready, rendering begins, camera's sphere collider triggers all meshes near camera to turn VISIBLE.
  6. As camera moves through scene, invisible meshes entering sphere become visible, visible meshes leaving sphere become invisible.

What happens under GodotPhysics:

1 through 4, as above, but

  1. Volume ready, rendering begins, but camera's sphere collider DOES NOT trigger all meshes near camera to switch to VISIBLE. In fact, no body_shape_entered/body_shape_exited signals are sent at all (as evidenced by the console empty of print statements) no matter where the camera moves.

Observations:

  1. I set up collision layers so that the camera collider would only interact with the gridmap meshes. I tested if leaving both at the default 1/1 layer/mask settings made any difference: No.
  2. Use BVH on/off makes no difference.

Steps to reproduce

I don't wish to upload my full project here, and will instead put together an MRP if no one has any clues as to what's going on here.

Minimal reproduction project

Per above.

Calinou commented 3 years ago

Camera has sphere collision area radius to light/far length. Idea is that this collision sphere triggers meshes on (inside) and off (outside).

As a workaround, you can use distance checks using Vector3.distance_to() on sporadic time intervals. It effectively works the same as a sphere.

belzecue commented 3 years ago

Okay, while doing the MRP, I discovered what setting causes this. It's the Area:Monitorable setting.

In my project, I had this set to OFF for the camera area sphere (and Area:Monitoring set to ON), on the assumption that only the camera sphere needed to actively monitor for collisions. This does indeed work for Bullet physics, as proven. But when you flip over to GodotPhysics, BOTH need to be set to ON.

For the MRP attached here, try these combinations, run, and WASD-move through the cube matrix, keeping an eye on the console printout:

  1. Bullet, with the camera area sphere set to Area:Monitoring ON, Area:Monitorable set to OFF (collisions work)
  2. GodotPhysics, same as above (collisions do not work)
  3. GodotPhysics, with the camera area sphere set to Area:Monitoring ON, Area:Monitorable set to ON (collisions work)

Is this a known difference between the two physics engines?

body_entered_GodotPhysics.zip

pouleyKetchoupp commented 3 years ago

I can confirm it's a bug, areas with monitorable set to false fail to detect static bodies in Godot Physics.

madmiraal commented 3 years ago

Duplicate of #17238.

pouleyKetchoupp commented 3 years ago

Closing as duplicate.