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

Add debug wireframe rendering for Aabb, Frustum, and Sphere #4082

Open
superdump opened this issue Mar 2, 2022 · 7 comments · May be fixed by #10038
Open

Add debug wireframe rendering for Aabb, Frustum, and Sphere #4082

superdump opened this issue Mar 2, 2022 · 7 comments · May be fixed by #10038
Labels
A-Rendering Drawing game state to the screen A-Utils Utility functions and types C-Feature A new feature, making something new possible C-Testing A change that impacts how we test Bevy or how users test their apps C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@superdump
Copy link
Contributor

What problem does this solve or what need does it fill?

Debugging intersections for the primitives currently used for culling for rendering is difficult without visualisation.

What solution would you like?

Add debug wireframe rendering for Aabb, Frustum, and Sphere. Mesh types exist for all but Frustum so those should probably be reused, and then there will need to be a way to differentiate debug meshes and general meshes so that it doesn’t create a feedback loop of a mesh having an Aabb, with a debug mesh for the Aabb that itself gets an Aabb that gets a debug mesh…

What alternative(s) have you considered?

None yet. Just noting that this would be good to do.

Additional context

@aevyrie ’s bevy_mod_bounding has support for this already and there’s the primitive shapes RFC.

@superdump superdump added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use C-Testing A change that impacts how we test Bevy or how users test their apps A-Utils Utility functions and types labels Mar 2, 2022
@superdump superdump moved this to Todo in Rendering Mar 2, 2022
@jakobhellermann
Copy link
Contributor

there will need to be a way to differentiate debug meshes and general meshes so that it doesn’t create a feedback loop of a mesh having an Aabb, with a debug mesh for the Aabb that itself gets an Aabb that gets a debug mesh…

The way I imagined how this feature would works is not not inserting a mesh of the bounding box into the world, but having a general "draw these lines somehow" mechanism like bevy_polyline or bevy_debug_lines and having a system that iterates over &Aabb's and draws debug lines corresponding to the bounding box. That way, no entities would be actually added to the world.

Alternatively, there could be one "hollow box" mesh, and we add an Extract system that queries for &Aabb and inserts a new entity into the render world that will draw the Aabb. Again, no entities in the main world so no need to differentiate the debug mesh.

@aevyrie
Copy link
Member

aevyrie commented Mar 2, 2022

I used bevy_polyline for the debug wireframes in bevy_mod_bounding, although I was setting them as child entities. I don't think it runs into the recursive loop of AABBs issue because I'm inserting a polyline, not a mesh, therefore no AABB will be generated from the debug wireframe.

It might be better - as @jakobhellermann mentions - to take an immediate mode rendering approach and convert all AABBs into wireframes in a function call without generating any entities. We could do this without needing any fancy line rendering to be implemented in bevy, just draw wireframe box meshes in the render subapp.

@superdump superdump moved this from Todo to In Progress in Rendering Jun 25, 2022
@superdump
Copy link
Contributor Author

I had started on this and was adding debug meshes similar to bevy_mod_bounding. I think I used a new component type and side-stepped the recursiveness that way. With an immediate mode approach without caching the vertices, they would have to be recalculated every frame. I think calculating the vertex positions and skipping transforms could be practically simpler (I was having problems with Frustum) but it could also have a negative performance impact, perhaps. I suppose bounding volumes tend to have few vertices though so maybe it's fine...

@nerdachse
Copy link

Any progress on this?

@tim-blackbird
Copy link
Contributor

An immediate mode rendering api was added and you can enable drawing oriented bounding boxes via GizmoConfig or the AabbGizmo component.
Drawing axis aligned bounding boxes, bounding spheres, and frustums has not been implemented yet.

@superdump
Copy link
Contributor Author

We now have this for aabbs, spheres, and camera frusta, right @devil-ira ?

@tim-blackbird
Copy link
Contributor

The pr for frusta isn't merged yet, but I'll set this issue to be closed when it does

@tim-blackbird tim-blackbird linked a pull request Nov 5, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-Utils Utility functions and types C-Feature A new feature, making something new possible C-Testing A change that impacts how we test Bevy or how users test their apps C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

5 participants