From 8e3679e321f8709d0b81072b7f8af2d3dbf476c1 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Tue, 23 Dec 2014 16:57:21 +0600 Subject: [PATCH] Fix set vertex z in prim-depth mode. Fixed flagshot in Mario Golf. --- OpenGL.cpp | 7 +++++++ gSP.cpp | 12 ++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/OpenGL.cpp b/OpenGL.cpp index c52141e7..57c00314 100644 --- a/OpenGL.cpp +++ b/OpenGL.cpp @@ -290,6 +290,13 @@ void OGLRender::addTriangle(int _v0, int _v1, int _v2) vtx.flat_a = vtx.a; } } + + if (gDP.otherMode.depthSource == G_ZS_PRIM) { + for (u32 i = triangles.num - 3; i < triangles.num; ++i) { + SPVertex & vtx = triangles.vertices[triangles.elements[i]]; + vtx.z = gDP.primDepth.z * vtx.w; + } + } } #define ORKIN_BLENDMODE diff --git a/gSP.cpp b/gSP.cpp index 38e9e42e..ba41ad2e 100644 --- a/gSP.cpp +++ b/gSP.cpp @@ -326,12 +326,11 @@ void gSPProcessVertex4(u32 v) } gSPTransformVertex4(v, gSP.matrix.combined ); - for(int i = 0; i < 4; ++i) { - SPVertex & vtx = render.getVertex(v+i); - if (gDP.otherMode.depthSource == G_ZS_PRIM) - vtx.z = gDP.primDepth.z * vtx.w; - if (gSP.viewport.vscale[0] < 0) + if (gSP.viewport.vscale[0] < 0) { + for(int i = 0; i < 4; ++i) { + SPVertex & vtx = render.getVertex(v+i); vtx.x = -vtx.x; + } } if (gSP.matrix.billboard) @@ -550,9 +549,6 @@ void gSPProcessVertex(u32 v) float vPos[3] = {(float)vtx.x, (float)vtx.y, (float)vtx.z}; gSPTransformVertex( &vtx.x, gSP.matrix.combined ); - if (gDP.otherMode.depthSource == G_ZS_PRIM) - vtx.z = gDP.primDepth.z * vtx.w; - if (gSP.viewport.vscale[0] < 0) vtx.x = -vtx.x;