dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.97k stars 248 forks source link

debug renderer - update to bevy 0.11 #541

Closed johnny-smitherson closed 8 months ago

johnny-smitherson commented 11 months ago

The debug renderer included in rapier2d/3d uses an outdated version of bevy.

This means we can't use the debug renderer with newer versions of Bevy.

This problem is especially unforgiving when trying to use some library that doesn't have optional dependency on the rapier features that pull bevy, like https://docs.rs/salva3d/latest/salva3d/

This problem also extends to bevy_rapier plugin that lists bevy = 0.11 in its own dependencies, but the optional debug-renderer feature pulls in rapier/debug-renderer which pulls in bevy=0.9 instead.

I started upgrading the code and have a branch that successfully compiles.

The only thing left is a panic involving the render app (DebugDrawLines plugin).

Here is the output of the error:

2023-10-23T16:43:14.689382Z  INFO bevy_winit::system: Creating new window "Rapier: 3D demos" (0v0)
thread 'main' panicked at 'DrawFunctions<bevy_core_pipeline::core_3d::Opaque3d> must be added to the world as a resource before adding render commands to it

In the codebase, bevy_core_pipeline::core_3d::Opaque3d is aliased as dim::Phase. I tried adding the resource as it asks:

        app.sub_app_mut(RenderApp)
            .init_resource::<DrawFunctions<dim::Phase>>()
            .add_render_command::<dim::Phase, dim::DrawDebugLines>()

Above fails with same error. I also tried adding the resource to the World app (instead of the resource app).

I also tried removing the DebugLinesPlugin and all related plugins from the main file, but it still errors out with the above error. Also tried cargo clean and recompiling - same error.

Here is the PR: https://github.com/dimforge/rapier/pull/540

Any idea how to fix this and finish the upgrade?