1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Fix z coordinate for gSPObjSprite and gSPBgRect1Cyc.

This commit is contained in:
Sergey Lipskiy 2014-10-22 21:22:46 +07:00
parent 2ad3f17fc4
commit 246bc396ad

18
gSP.cpp
View File

@ -1976,6 +1976,7 @@ void gSPBgRect1Cyc( u32 bg )
const f32 ult = gSP.bgImage.imageY;
const f32 lrs = uls + frameW * scaleW;
const f32 lrt = ult + frameH * scaleH;
const float z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
//const f32 lrs = uls + gSP.bgImage.width * scaleW;
//const f32 lrt = ult + gSP.bgImage.height * scaleH;
@ -2008,28 +2009,28 @@ void gSPBgRect1Cyc( u32 bg )
SPVertex & vtx0 = render.getVertex(v0);
vtx0.x = ulx;
vtx0.y = uly;
vtx0.z = 0.0f;
vtx0.z = z;
vtx0.w = 1.0f;
vtx0.s = uls;
vtx0.t = ult;
SPVertex & vtx1 = render.getVertex(v1);
vtx1.x = lrx;
vtx1.y = uly;
vtx1.z = 0.0f;
vtx1.z = z;
vtx1.w = 1.0f;
vtx1.s = lrs;
vtx1.t = ult;
SPVertex & vtx2 = render.getVertex(v2);
vtx2.x = ulx;
vtx2.y = lry;
vtx2.z = 0.0f;
vtx2.z = z;
vtx2.w = 1.0f;
vtx2.s = uls;
vtx2.t = lrt;
SPVertex & vtx3 = render.getVertex(v3);
vtx3.x = lrx;
vtx3.y = lry;
vtx3.z = 0.0f;
vtx3.z = z;
vtx3.w = 1.0f;
vtx3.s = lrs;
vtx3.t = lrt;
@ -2179,32 +2180,33 @@ void gSPObjSprite(u32 sp)
ult = lrt;
lrt = 0;
}
const float z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
SPVertex & vtx0 = render.getVertex(v0);
vtx0.x = gSP.objMatrix.A * x0 + gSP.objMatrix.B * y0 + gSP.objMatrix.X;
vtx0.y = gSP.objMatrix.C * x0 + gSP.objMatrix.D * y0 + gSP.objMatrix.Y;
vtx0.z = 0.0f;
vtx0.z = z;
vtx0.w = 1.0f;
vtx0.s = uls;
vtx0.t = ult;
SPVertex & vtx1 = render.getVertex(v1);
vtx1.x = gSP.objMatrix.A * x1 + gSP.objMatrix.B * y0 + gSP.objMatrix.X;
vtx1.y = gSP.objMatrix.C * x1 + gSP.objMatrix.D * y0 + gSP.objMatrix.Y;
vtx1.z = 0.0f;
vtx1.z = z;
vtx1.w = 1.0f;
vtx1.s = lrs;
vtx1.t = ult;
SPVertex & vtx2 = render.getVertex(v2);
vtx2.x = gSP.objMatrix.A * x0 + gSP.objMatrix.B * y1 + gSP.objMatrix.X;
vtx2.y = gSP.objMatrix.C * x0 + gSP.objMatrix.D * y1 + gSP.objMatrix.Y;
vtx2.z = 0.0f;
vtx2.z = z;
vtx2.w = 1.0f;
vtx2.s = uls;
vtx2.t = lrt;
SPVertex & vtx3 = render.getVertex(v3);
vtx3.x = gSP.objMatrix.A * x1 + gSP.objMatrix.B * y1 + gSP.objMatrix.X;
vtx3.y = gSP.objMatrix.C * x1 + gSP.objMatrix.D * y1 + gSP.objMatrix.Y;
vtx3.z = 0.0f;
vtx3.z = z;
vtx3.w = 1.0f;
vtx3.s = lrs;
vtx3.t = lrt;