godotengine / godot

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

[Bullet] No shape ID in a result of RayCast against PhysicsBody with multiple ConcavePolygonShapes. #62223

Open dmitrijbes opened 2 years ago

dmitrijbes commented 2 years ago

Godot version

v3.5.rc4.official [e047c5006]

System information

Windows 10

Issue description

According to doc intersect_ray must have shape id in resulting Dict. However, its always 0.

This issue was already reported and fixed in #55533. According to changelog it must be fixed in 3.5 rc4.

It doesn't.

Steps to reproduce

  1. Create 2 Shapes and add to StaticBody.
  2. Racayst shapes using intersect_ray.
  3. Look for shape id in raycast result Dict.

You can find example in attached MRP.

Minimal reproduction project

raycast_shape_bug.zip

dmitrijbes commented 2 years ago

I dug into it more and stumble upon great research by pouleyKetchoupp. In short, its a bug of Bullet integration, which was quick-fixed with exception: Single PhysicsBody, which owns multiple ConcavePolygonShapes always return 0 instead of shape id. As always with such things, this unlikely exception is exactly my case)

How To Fix I circumvented issue by switching to GodotPhysics. Project -> Project Settings -> Physics -> Physics Engine

Still would not close this issue, because solution is far from good and issue is not documented anywhere. I spent several hours fixing it, hopefully this info will save someone's time)

dmitrijbes commented 2 years ago

Probably related to: #57452.