From 4a19bac74827714345fd403de9c6897166f2edea Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 19 Jul 2009 08:23:14 +0000 Subject: [PATCH] gfx3d: i've realized that the poly sorting must happen after clipping. there is no way to do this now, so to approximate really well, it, we will perspective divide the y values. fixes island of happiness shop menus. --- desmume/src/gfx3d.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index e95fa31dd..c914cb010 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -2396,15 +2396,21 @@ static void gfx3d_doFlush() //find the min and max y values for each poly. //TODO - this could be a small waste of time if we are manual sorting the translucent polys + //TODO - this _MUST_ be moved later in the pipeline, after clipping. + //the w-division here is just an approximation to fix the shop in harvest moon island of happiness for(int i=0; ilist[i]; - float verty = 0.0f; - poly.miny = poly.maxy = vertlist->list[poly.vertIndexes[0]].y; + float verty = vertlist->list[poly.vertIndexes[0]].y; + float vertw = vertlist->list[poly.vertIndexes[0]].w; + verty = (verty+vertw)/(2*vertw); + poly.miny = poly.maxy = (verty+vertw)/(2*vertw); for(int j=1; jlist[poly.vertIndexes[j]].y; + vertw = vertlist->list[poly.vertIndexes[j]].w; + verty = (verty+vertw)/(2*vertw); poly.miny = min(poly.miny, verty); poly.maxy = max(poly.maxy, verty); }