Demindiro / godot_rapier3d

Godot bindings for the Rapier3D physics engine
MIT License
43 stars 2 forks source link

ConvexPolygonShape not supported? Tips for using the binding? #19

Closed geekrelief closed 3 years ago

geekrelief commented 3 years ago

Hi, Sorry to bother you with so many issues. But my hopes of a dropin replacement for Bullet were dashed. :) I tried dropping in rapier into my third person controller project, and my rigidbodies fell through my floor. I got a bunch of errors:

ERROR: Not implemented
   At: modules\pluggable_physics\server.gen.cpp:584
ERROR: Not implemented
   At: modules\pluggable_physics\server.gen.cpp:593

584 referring to body_test_motion and 593 is body_test_ray_separation.

Here's what it's supposed to look like

https://user-images.githubusercontent.com/27040/120148491-29307580-c19d-11eb-87b1-9aa1ac655262.mp4

The RigidBodys are meshes I imported from blender and have a ConvexPolygonShape that was generated from the MeshInstance -> Mesh -> Create Single Convex Collision Sibling.

I created a simple scene with a rounded cube from blender and another cube created in godot.

https://user-images.githubusercontent.com/27040/120148317-e2428000-c19c-11eb-9710-20f10061cfbe.mp4

And I get this error:

ERROR: <native>: Failed to apply data: IncompleteTriangle
   At: rapier3d\src\server\shape.rs:304

What would it take to get ConvexPolygonShape supported? What I'm really after is creating a third person controller, KinematicBody, that can navigate a terrain and interact with RigidBodys. Do you have any tips for getting my project working or working with the binding in general?

Demindiro commented 3 years ago

584 referring to body_test_motion and 593 is body_test_ray_separation.

I wasn't aware those existed. It seems they aren't documented in Godot's docs which is probably why I missed them. I'll add them to the tracker.

And I get this error:

ERROR: <native>: Failed to apply data: IncompleteTriangle
  At: rapier3d\src\server\shape.rs:304

This error means that the amount of vertices passed is not a multiple of 3. For concave shapes this is always the case and I assumed the same applied to convex shapes but it seems I was wrong.

The documentation for ConvexPolygonShape only describes points as "The list of 3D points forming the convex polygon shape.", so the best bet is probably to check the source code of ConvexPolygonShape to figure out the format.

To see what kind of data is being received on the Rust side you can stick a dbg!(&array); between line 170 and 171 of src/server/shape.rs.


While character controllers (MODE_CHARACTER) may work, I have never tested them so they may not behave as expected. AFAIK I'm simply instantiating them as regular dynamic bodies and I don't do anything else with it.

geekrelief commented 3 years ago

Thanks for the reply. I saw on #4 that a character controller is on the TODO list, so I guess I have a bit of research ahead of me if I want to get my project going with rapier.

geekrelief commented 3 years ago

In my testing, ConvexPolygonShape looks pretty good with the fix-convex-shape branch. We can close this issue when it's merged.

For my use case, I'm going to switch away from using KinematicBody. So, issues for KinematicBody and ray casting can be created for those separately as needed.