Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per entity/collider debug rendering #278

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

barsoosayque
Copy link

@barsoosayque barsoosayque commented Nov 15, 2022

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)

Copy link

@Dessix Dessix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it would work, but it could use a little bit of cleanup.

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?

src/render/mod.rs Show resolved Hide resolved
self.global || self.visible.contains(entity)
})
.unwrap_or(false),
_ => true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this _ => true imply that only collider rendering can ever be disabled per-entity, and everything else remains on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's what I'm using at the moment, colliders only, so I wasn't even sure if joints are rendered ? And for the bodies, I guess it's only the axes thing that is rendered. But what is DebugRenderObject::Other ?.. And how would I render joints, only if two bodies are marked as debug-visible ? Or any of two bodies is enough to be rendered

src/render/mod.rs Outdated Show resolved Hide resolved
@barsoosayque
Copy link
Author

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.

@Aceeri
Copy link
Sponsor Contributor

Aceeri commented Jul 5, 2023

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.

@barsoosayque
Copy link
Author

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 !

@Vrixyz
Copy link
Contributor

Vrixyz commented May 20, 2024

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 bevyengine/bevy#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 !

@barsoosayque
Copy link
Author

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 !

@Vrixyz Vrixyz added enhancement New feature or request A-Integration very bevy specific labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Integration very bevy specific D-Medium enhancement New feature or request P-Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants