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

[WIP] Debug Renderer Improvements #106

Closed
wants to merge 6 commits into from
Closed

[WIP] Debug Renderer Improvements #106

wants to merge 6 commits into from

Conversation

patrickisgreene
Copy link

@patrickisgreene patrickisgreene commented Nov 15, 2021

This is still a work in progress, but it's ready for initial review.

RapierDebugPlugin adds a custom render pass named RapierDebugPass that will be rendered after the main_pass. The debug components can be viewed on this pass or the default MainPass. To change the default behavior currently the 'default_main_pass' feature can be set.

Components

  • RapierDebugCollider

    Displays the collider
  • RapierDebugPosition

    Displays a 'x' on position of a collider or a rigidbody.
  • RapierDebugPath

    Tracks the path of motion of a collider and displays a line created from the past 1000 positions

Events

  • RapierDebugToggleVisibilty

    Toggles the visibilty of a debug component using the bevy Visible struct.
  • RapierDebugToggleRenderPass

    Toggles the render pass used to display the components between main pass & rapier debug pass.

List of things left to do:

  • Fix colors in the examples
  • Write Docs
  • Figure out best name for the feature that toggles the default render pass and implement it
  • Fix the ray_casting3 example

@patrickisgreene
Copy link
Author

Hey @sebcrozet, This just needs one more thing, as a library i used a cargo feature to swap whether the Debug Components were put on their own render pass or on the main pass by default. i just used 'default_main_pass' as it made sense in the library context, but in rapier i think changing the name of the feature to 'debug_renderer_default_main_pass' is the clearest and most descriptive. It's to long i think but i haven't thought of any better alternatives, does that feature name work for you?

Copy link
Contributor

@Aceeri Aceeri left a comment

Choose a reason for hiding this comment

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

You have no idea how much I appreciate your work on this! I was using this for a bit and figured out the trimesh stuff I think. I also added rendering for convex meshes and compound meshes in my branch, will try and see if I can push it to this PR later.

src/render/mesh/trimesh.rs Outdated Show resolved Hide resolved

#[cfg(feature = "dim3")]
pub fn wire_trimesh(trimesh: &TriMesh) -> Mesh {
let mut mesh = Mesh::new(PrimitiveTopology::LineList);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can fix this by using:

Suggested change
let mut mesh = Mesh::new(PrimitiveTopology::LineList);
let mut mesh = Mesh::new(PrimitiveTopology::LineStrip);

image

Copy link
Contributor

Choose a reason for hiding this comment

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

This might actually be adding too many lines?

Copy link
Author

Choose a reason for hiding this comment

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

It's been a while since i've looked at this but, if i remember correctly the code to generate the timesh mesh was basically just taken from the current debug renderer.

@sebcrozet
Copy link
Member

@ByteBuddha The feature name debug_renderer_default_main_pass sounds fine to me. I updated bevy_rapier to work with bevy 0.6. How difficult would it be to make the changes in this PR compatible with 0.6?

@patrickisgreene
Copy link
Author

It should't be too difficult, Creating the Custom material is easy enough, i just need to figure out how to actually create a custom render pass in the new renderer.

Unfortunately I'm having issues getting bevy 0.6 to work on my laptop, I didnt have any trouble using main a week or 2 ago, but for some reason it's unable to find my GPU, going to spend the day installing arch linux cause i think that might fix it. I know @Aceeri has some code i read he was planning to push we might also want to wait for that.

I'll pick this back up as soon as i can get a working bevy 0.6 install 😢 If anyone else gets to it before me be my guest to push a PR

@Aceeri
Copy link
Contributor

Aceeri commented Jan 10, 2022

I can definitely work a bit on this, might not have a whole lot of time today specifically but I do have some additions for some more rendering stuff too.

@patrickisgreene
Copy link
Author

I briefly looked into this today. There seems like there are going to be a couple of issue's updating this to bevy 0.6.0. With so much changed it might even be worth just a total rewrite. The two most difficult to deal with as i see them are

  1. I'm using marker components to change which render pass is in use, these marker components aren't in use anymore and from my very brief research i don't see a way to switch render pass's at runtime.
  2. I used superdump/bevy_hud_pass as an example of creating a custom render pass, without this being updated i probably need to spend some time working with the main 3d/2d render pass's to figure this out.

I don't think these would be too hard to figure out, but i won't have the time to devote to this for probably the next several months maybe even upwards of a year, I'm having some issues with my wife so I'm effectively yeeting all of my more time intensive personal projects out the window to focus on my personal life.

I would really love it if someone wanted to pick up the torch on this one, I really feel the need for a better debug renderer for rapier and i like the approach used here, I just don't have the time to look into all the new changes for the brand new renderer. otherwise this PR will probably end up stale and unusable by the time i can come back.

I'd love to help anyone willing to put in the work for this, I can be reached here on github or under the username perjoratic on the bevy/rapier discord servers.

@Aceeri
Copy link
Contributor

Aceeri commented Jan 11, 2022

I'll try and take the reins of it as I definitely agree this is very useful. I did a bit of research around to see what other crates seem to be using and it seems like I'll try and make something based off of an updated version of https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline, specifically aevyrie's fork here: https://github.com/aevyrie/bevy_poly_line

@Aceeri
Copy link
Contributor

Aceeri commented Jan 13, 2022

Made some progress on this, I implemented a wireframe renderer here: https://github.com/Aceeri/bevy_stylized_wireframe

Still planning on updating it a bit to add some more options for color/dashed/etc. But is pretty solid so far, will try and put in a PR in the next couple days.

@CleanCut
Copy link
Contributor

@Aceeri How are things going? Any progress?

@Aceeri
Copy link
Contributor

Aceeri commented Feb 25, 2022

@CleanCut I have some stuff working here if you wanted to take a look: https://github.com/aceeri/bevy_rapier/tree/convex-compound

I need to add some amount of customizability to wireframes colors and stuff is the main thing I need to do I think.

@Aceeri
Copy link
Contributor

Aceeri commented Mar 19, 2022

Alright, sorry about that, I had some rust stuff to do at work which ended up taking up most of my time/mental energy, going to focus on getting this out the door as a PR this weekend.

@Aceeri
Copy link
Contributor

Aceeri commented Mar 19, 2022

I do have my attention divided between making some steam audio support for rust though, heron does seem to have its own debug renderer stuff going pretty well. Might be worth taking a look at their stuff.

@CleanCut
Copy link
Contributor

Alright, sorry about that, I had some rust stuff to do at work which ended up taking up most of my time/mental energy, going to focus on getting this out the door as a PR this weekend.

No need to apologize! You contribute on your own timeframe.

@sebcrozet
Copy link
Member

Thank you for your work on this @ByteBuddha! Rapier has now its official line-based debug-renderer that bevy_rapier can use (#138). This PR was a great source of inspiration.

@sebcrozet sebcrozet closed this Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants