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

Fix rapier debug render #224

Merged
merged 2 commits into from
Aug 12, 2022
Merged

Conversation

zicklag
Copy link
Member

@zicklag zicklag commented Aug 12, 2022

Fixes #132.

Found out that #132 was caused by the fact that the debug lines plugin that rapier uses to manage debug rendering requires that 4 entities be kept alive to contain the debug lines.

The issue is when we try to reset the world by deleting all entities other than the camera, those entities get deleted, too. And we can't filter those entities out because their distinguishing component is private. Also, there isn't a way to re-create those entities after adding the plugin.

This works around the issue by implementing a custom debug lines renderer for Rapier that uses Egui to draw the lines instead.

It's simple and mostly copied from rapier's plugin.

It's a little annoying to have to show the debug window and then click
the checkbox, so this makes it easier.
Implements custom debug renderer for Rapier using Egui.

This is to avoid an issue we have using Rapier's built-in debug renderer,
which requires entities to be kept alive that we can't filter based on
components.

Fixes fishfolk#132
Copy link
Collaborator

@edgarssilva edgarssilva left a comment

Choose a reason for hiding this comment

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

Seems to work really nicely, way easier to see as well.

Also figured out that the flashing boxes are the enemies' hitboxes, we might wanna check that.
If I'm not mistaken the flop attack staying in place is due to the refractor before right, if so seems ready to go.

@zicklag
Copy link
Member Author

zicklag commented Aug 12, 2022

Also figured out that the flashing boxes are the enemies' hitboxes, we might wanna check that.

Yeah we should probably create an issue for it.

If I'm not mistaken the flop attack staying in place is due to the refractor before right

Yep!


Bors r+

bors bot added a commit that referenced this pull request Aug 12, 2022
224: Fix rapier debug render r=zicklag a=zicklag

Fixes #132.

Found out that #132 was caused by the fact that the debug lines plugin that rapier uses to manage debug rendering requires that 4 entities be kept alive to contain the debug lines.

The issue is when we try to reset the world by deleting all entities other than the camera, those entities get deleted, too. And we can't filter those entities out because their distinguishing component is private. Also, there isn't a way to re-create those entities after adding the plugin.

This works around the issue by implementing a custom debug lines renderer for Rapier that uses Egui to draw the lines instead.

It's simple and mostly copied from rapier's plugin.

Co-authored-by: Zicklag <zicklag@katharostech.com>
@64kramsystem
Copy link
Member

64kramsystem commented Aug 12, 2022

If I'm not mistaken the flop attack staying in place is due to the refractor before right, if so seems ready to go.

The last time I've tested the state PR before it was merged, the problem was the opposite - enemies were always jumping when attacking. Seems to be kind of the opposite, now 😁

@zicklag
Copy link
Member Author

zicklag commented Aug 12, 2022

bors cancel

Oh, wait, I didn't know what you guys meant, that's weird.

@bors
Copy link
Contributor

bors bot commented Aug 12, 2022

Canceled.

@zicklag
Copy link
Member Author

zicklag commented Aug 12, 2022

I think it might be from #221 but I've got to double-check that happens on master right now.

@zicklag
Copy link
Member Author

zicklag commented Aug 12, 2022

OK yeah, that's happening on master, so it's not from this PR. :)

Bors r+

@odecay
Copy link
Collaborator

odecay commented Aug 12, 2022

Don't worry it's intended (for now)

@bors bors bot merged commit b2cbe33 into fishfolk:master Aug 12, 2022
@odecay
Copy link
Collaborator

odecay commented Aug 12, 2022

Also re: flashing box, if I understand what you mean I'm pretty sure it's because when we spawn attacks/collision entities they don't have a Collider shape at first, till they are activated in activate hotbox system which adds the required component.
I think the debug render doesn't deal with the case where there is an entity with a bunch of rapier components but not a Collider shape.

Not 100% certain but it started happening when I changed it to work that way.

@zicklag zicklag deleted the fix-rapier-debug-render branch August 12, 2022 14:25
@zicklag
Copy link
Member Author

zicklag commented Aug 12, 2022

Interesting. It's possible for us to filter out certain shapes that rapier gives us to debug render now that we have the custom implementation, so we could potentially filter those out if they aren't actually there.

We can also add a custom debug collor to different colliders with the ColliderDebugColor, so we could use that to debug which colliders are actually getting spawned in the middle of the world.

Another possible cause could be hierarchy flushing issues, maybe? But I think Bevy 0.8 fixed those.

@zicklag zicklag mentioned this pull request Aug 12, 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.

Returning to main menu in debug mode turns off rapier debug draw plugin
4 participants