-
Notifications
You must be signed in to change notification settings - Fork 17
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
Improve calulation_entities_to_redraw system #1
Comments
Whenever a sprite moves you know in O(1) what rect it occupied before and after, and can redraw that region only. But what sprites are in those regions that need to be redrawn now? How to avoid an O(n) search for intersection? I believe you can accomplish this by maintaining a "pointerless octree" (quadtree for this project as it is 2D), which leverages Morton keys for each subquadrant. I think there is a way to very quickly convert a region to the morton keys that make it up, which then immediately provides the sprites to re-render to composite back into the frame, and if you're clever even which subrect inside a sprite you need, but that may be worse for performance on most sprites. Here is a link to the paper that gave me information about this technique, albeit for a totally different application: |
Something adjacent to the technique I proposed can be found in the https://docs.rs/isosurface/0.0.4/isosurface/linear_hashed_marching_cubes/index.html If I have the free time I may implement a proof of concept for |
Wow this is good info thanks! I would certainly appreciate a crate which implements pointerless quadtree duals. After reading through the paper, I'm not sure I could pull it off as this domain (and computer graphics in general) is not one I'm very familiar with.
|
Awesome! Haven't had time, but probably soon! Do we have any profiling to determine which subsystems are most expensive? If every frame is redrawn from scratch I imagine that's your biggest problem, but I may be wrong. I've played with high performance string manipulation before and found some methods are sneakily very slow (compared to a manual implementation) like |
I'm realizing now that you and I may have been talking about different things! I am not actually involved or familiar with bevy_crossterm, I think you were talking about asset substitution or something, while I was talking about partial frame rendering etc. I'll check the source and see how bevy_crossterm works and if it makes any sense what I was saying 😅 |
You’re actually right on track! This system needs some improvement with collision detection for sure. Currently I use the broccoli crate with implements a hybrid structure of a k-d tree and mark and sweep algorithm to find collisions. Since the tree created by broccoli cannot have entities inserted after construction, I recreate the tree every frame, which seems expensive to me. I didn’t lead with improvements to collision detection because it’s a domain I’m very unfamiliar with, but I welcome any input/contributions in this area! WRT to perf. I think there’s a lot of perf on the table that I haven’t been able to find yet. I’m not sure what your platform of choice is to develop on rust is but if you know how to work |
The asset change detection is rough. We have to loop through all asset added/changed events, then loop through ALL entities to see which ones have assets that need to be changed. Not very graceful. There are a few improvements to be made here:
The text was updated successfully, but these errors were encountered: