bevy_rapier icon indicating copy to clipboard operation
bevy_rapier copied to clipboard

Per entity/collider debug rendering

Open barsoosayque opened this issue 3 years ago • 5 comments

I needed a way to toggle debug rendering of colliders for group of entities in my project, so I thought of implementing it kind of like bevy Wireframe works, with global flag in resource, and if it's off, then per entity with marker component. I also considered just using Visibility for collider entities, but that's seems unintuitive.

~Oh, I also fixed RapierDebugRenderPlugin::enabled not being used, I'm not sure if creating context with enabled: true was intentional or just a typo.~ (fixed in recent master)

barsoosayque avatar Nov 15 '22 11:11 barsoosayque

Is there any way to elevate "draw only entities with ColliderDebug components" to a system, and have a global system and a selective one, and bail out at the start of either, instead of doing this per-line?

I think no, there is no way. Well I don't see any, since rendering is done by DebugRenderPipeline which is using whole RigidBodySet, ColliderSet, etc. So it seems I can't use Queries to filter what to render before calling a .render fn, only in the process.

barsoosayque avatar Nov 27 '22 17:11 barsoosayque

Overall a good idea/impl imo :)

I think adding a per-entity "DebugRenderMode" would be useful in the future as well, but I think getting this in first would be preferable.

Aceeri avatar Jul 05 '23 06:07 Aceeri

I have updated this PR once again, I wonder if anything is blocking this PR from being merged ? Would really like to get this feature into the library !

barsoosayque avatar Sep 15 '23 05:09 barsoosayque

I have updated this PR once again, I wonder if anything is blocking this PR from being merged ? Would really like to get this feature into the library !

Thanks for the pull request!

I like it overall, I, too, would have appreciated a more customizable approach, to more easily switching from different modes/selection, maybe https://github.com/bevyengine/bevy/pull/7328 is interesting to take inspiration from it.

In the meanwhile, this is an acceptable implementation for me.

An example and changelog would be great !

ThierryBerger avatar May 20 '24 15:05 ThierryBerger

I initially based this PR on how Wireframe worked, but that was a long time ago. I'm happy to update it so it would have AlwaysRender/NeverRender to mimic the modern Wireframe, looks straightforward enough. And since I have weekends now, I hope to be done shortly !

barsoosayque avatar May 21 '24 06:05 barsoosayque

@Vrixyz I've rewrote this PR to mirror bevy's Wireframe (hopefully) and added a changelog, a while back actually, just updated the branch. Couldn't add an example, because I'm a little bit burned out from this PR (I just pray that it will be upstreamed this time :pray: )

barsoosayque avatar Jul 15 '24 21:07 barsoosayque

Thanks!

ThierryBerger avatar Aug 02 '24 15:08 ThierryBerger