IMO the constant sortings are nearly useless.
It just needs to have 4 list of sorted blocks, one for each 90° angle. Then it just re-sorts them all when an object moves (which would be very cheap), or if few objects move it can just paint them dynamically at the right time (also cheap).
So at all times it has 4 presorted lists, and it chooses the right one depending on the camera position.
I have a feeling you're onto something but also something feels off, like there's a catch we're missing.
Then it just re-sorts them all when an object moves (which would be very cheap)
Given player input and moving enemies this is every frame anyway, and your solution sorts four angles instead of one.
Wait, do you mean "insertion sort the moved object from its original position"? I guess that would be cheap if it's just a handful.
EDIT: if he is using an adaptive sort it shouldn't really matter should it? Although using one sorted list per axis seems smart (you don't need four, symmetry means one sorted list is the other in reverse)
Moving your player means only changer its relative order to a few blocks, so even a bubble sort will do at most a few swaps (typically 0 or 1 swap per frame unless it moves many blocks per frame) so yes, it should be inexpensive.
And you don't need to run the full bubble sort on all blocks, just on the 2 blocks adjacent to the player (in the sorted list), and repeat until stabilized.
Edit: I'm not sure about the symmetry thing though. You're sorting into a cone, so maybe there are cases where you're not symmetrical at all.
Comments
IMO the constant sortings are nearly useless. It just needs to have 4 list of sorted blocks, one for each 90° angle. Then it just re-sorts them all when an object moves (which would be very cheap), or if few objects move it can just paint them dynamically at the right time (also cheap). So at all times it has 4 presorted lists, and it chooses the right one depending on the camera position.
I have a feeling you're onto something but also something feels off, like there's a catch we're missing.
Given player input and moving enemies this is every frame anyway, and your solution sorts four angles instead of one.
Wait, do you mean "insertion sort the moved object from its original position"? I guess that would be cheap if it's just a handful.
EDIT: if he is using an adaptive sort it shouldn't really matter should it? Although using one sorted list per axis seems smart (you don't need four, symmetry means one sorted list is the other in reverse)
Moving your player means only changer its relative order to a few blocks, so even a bubble sort will do at most a few swaps (typically 0 or 1 swap per frame unless it moves many blocks per frame) so yes, it should be inexpensive.
And you don't need to run the full bubble sort on all blocks, just on the 2 blocks adjacent to the player (in the sorted list), and repeat until stabilized.
Edit: I'm not sure about the symmetry thing though. You're sorting into a cone, so maybe there are cases where you're not symmetrical at all.
It's an isometric game, so the viewport is not a cone projection but a cube.