Fixed triangle rasterizing sorting algorithm.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
7b0467cc5d
commit
344e91502d
@ -89,7 +89,7 @@ public class Panel extends JPanel implements Runnable {
|
|||||||
accumulatedTris.clear();
|
accumulatedTris.clear();
|
||||||
|
|
||||||
Matrix matRotZ = Matrix.MakeRotationZ(fTheta),matRotX = Matrix.MakeRotationX(fTheta*0.5f);
|
Matrix matRotZ = Matrix.MakeRotationZ(fTheta),matRotX = Matrix.MakeRotationX(fTheta*0.5f);
|
||||||
Matrix matTranslation = Matrix.MakeTranslation(0,0,16);
|
Matrix matTranslation = Matrix.MakeTranslation(0,0,6);
|
||||||
Matrix matWorld = Matrix.IDENTITY;
|
Matrix matWorld = Matrix.IDENTITY;
|
||||||
matWorld = Matrix.MultiplyMatrix(matRotZ,matRotX);
|
matWorld = Matrix.MultiplyMatrix(matRotZ,matRotX);
|
||||||
matWorld = Matrix.MultiplyMatrix(matWorld,matTranslation);
|
matWorld = Matrix.MultiplyMatrix(matWorld,matTranslation);
|
||||||
@ -147,7 +147,7 @@ public class Panel extends JPanel implements Runnable {
|
|||||||
public int compare(Triangle t1, Triangle t2) {
|
public int compare(Triangle t1, Triangle t2) {
|
||||||
float z1=(t1.A.z+t1.B.z+t1.C.z)/3f;
|
float z1=(t1.A.z+t1.B.z+t1.C.z)/3f;
|
||||||
float z2=(t2.A.z+t2.B.z+t2.C.z)/3f;
|
float z2=(t2.A.z+t2.B.z+t2.C.z)/3f;
|
||||||
return (int)(z1-z2);
|
return (z1<z2)?1:(z1==z2)?0:-1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user