Fixed a node sorting bug

This commit is contained in:
2023-06-16 04:11:03 +10:00
parent 4d64d72a8f
commit 86b5ed63ec
3 changed files with 15 additions and 31 deletions

View File

@@ -1,5 +1 @@
//this file is a polyfill TODO: fix this
fn getRealPos(node: opaque) {
return [0, 0];
}

View File

@@ -130,21 +130,15 @@ fn depthComparator(lhs: opaque, rhs: opaque) { //for sorting by depth
var lhsPos = lhs.callNodeFn("getRealPos");
var rhsPos = rhs.callNodeFn("getRealPos");
var result = null;
if (lhsPos == null || rhsPos == null) { //BUGFIX: children without that function
return true;
}
if (lhsPos[1] == rhsPos[1]) { //BUGFIX: prevent z-fighting
if (lhsPos[0] == rhsPos[0]) {
result = true;
}
else {
result = lhsPos[0] < rhsPos[0];
}
}
else {
result = lhsPos[1] < rhsPos[1];
return lhsPos[0] <= rhsPos[0];
}
return result;
return lhsPos[1] < rhsPos[1];
}
fn getCameraPos(node: opaque) {