alexvoz / as3isolib

Automatically exported from code.google.com/p/as3isolib
0 stars 0 forks source link

DefaultSceneLayoutRenderer.renderScene() - bug and solution #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This bit of depth sorting code:

if ((objB.x < rightA) &&
    (objB.y < frontA) &&
    (objB.z < topA) &&
    (i !== j)) {
    behind.push(objB);
    output = true;
}

isn't sufficient on it's own because it only places an IsoSprite infront of 
another IsoSprite if it's to the right and below the one it's testing it 
against.
The issue is that an IsoSprite can be on the same y but to the right, in this 
case it should be placed infront of that IsoSprite. Same is true if it's on the 
same x and tested IsoSprite is below the other.
The Solution is to replace that if statement with this:

if (i !== j) {
    if ((objB.x < rightA) && (objB.y < frontA) && (objB.z < topA)) {
        behind.push(objB);
    }
    else if (objA.y == objB.y && objB.x < rightA) {
        behind.push(objB);
    }
    else if (objA.x == objB.x && objB.y < frontA) {
        behind.push(objB);
    }
}

Original issue reported on code.google.com by bedroom...@gmail.com on 25 May 2011 at 4:50

GoogleCodeExporter commented 9 years ago
Hang on, this solution doesn't fix all cases. There's definitely an issue here 
though.

Original comment by bedroom...@gmail.com on 25 May 2011 at 5:12