Has anyone actually come up with perfect isometric depth sorting?
Ive been going back to isometrics again recently, and Ive been trying to come up with the elusive perfect depth swapping method. By perfect I mean the following that objects can move freely in 3D isometric space in units of pixels, and depth swapping is independent of tile size. My definition of isometric space is where the x-axis runs NW-SE, the z-axis runs NE-SW, and the y-axis runs N-S.
Ive come close to it before by using a method like the following, but I dont think I ever came up with a perfect solution. This is just off the top of my head now so it might not be perfect. Note that this presumes all MovieClips that were attached to the stage where attached at the same depth level (e.g. -100) and their depth sorted isometrically immediatly.
Code:
function isoDepthSort (mc, isoPos) {
mc.swapDepths((isoPos.x*103)+(isoPos.z*100)+(isoPos.y*103));
}
Searching for the Perfect Isometric Depth Sorting
Not sure if anyone will read this but oh well here it goes:
Funny how this subject goes in spurts. Anyway, I am the developer for the as3isolib and have encountered a few problematic areas with my default layout algorithm for absolute positioning of isometric objects (much like Covenant, the thread's owner). For the most part, a flat map generates little or no errors, however any variable height terrain proves to be too much for the algorithm to handle.
I based my default algorithm on the Filmation algorithm. The problem is not necessarily the algorithm itself but rather the array sort on mechanism in AS3.
My problem is that if you rely on the low-level array.sortOn sort algorithm, not all of you objects necessarily get compared to one another. Implementing a manual sort would be performance prohibitive at best.
So I decide to go back and try a more brute force approach to this. Namely I re-tried Tonypa's sort method modified to AS3 and for 3 dimension with variable height terrain. Did not work in certain situations. Tonypa, if you are interested in seeing examples to maybe try to refine your algorithm, I would be happy to do so.
I also tried Jobe Makar's method outlined here and in his old game dev book. That did not work at all.
I have seen some interesting approaches to this: One is what I will call the tile-owner approach. Basically your depths are presorted by a terrain map. Since terrain never moves, its depth can be set ahead of time and sorted as such. Then for animated content, rather than treat each animated object as a sibling of the terrain objects, it gets passed amongst the terrain objects as a child. This is still not perfect as I have seen many examples of this not ordering correctly. This also requires that bigger-than-tile-size objects to be sliced up in most cases. I know for certain the OpenSpace Engine utilizes this technique and I think Dofus might use it as well. Any thoughts on this?
For now it seems that the perfect isometric depth sorting algorithm is still evading us. Well I wanted to throw this out here just to say my 2ยข.