darthdeus / comfy

Comfy is a fun 2D game engine built in Rust. It's designed to be opinionated, productive, and easy to use.
https://comfyengine.org
Apache License 2.0
678 stars 28 forks source link

Use BTreeMap for deterministic MeshKey iteration to prevent z-fighting #80

Closed setzer22 closed 7 months ago

setzer22 commented 7 months ago

The render queues are currently stored in a HashMap that is discarded and re-created each frame.

This is problematic, because each time the hashmap is created, it randomizes iteration order. And then, when two overlapping sprites are rendered with the same z-index, you get z-fighting.

I think the easiest way to solve this is to simply swap the HashMaps with BTreeMap, but feel free to implement something else if you have a better idea :+1: