diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index b8c9b6c42..1edf0f0b2 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -143,7 +143,7 @@ public: commandCursor = 0; size = 0; - // A “command without parameters” is one of the four following commands: + // A "command without parameters" is one of the four following commands: // - PushMatrix // - LoadIdentity // - End @@ -2833,71 +2833,3 @@ void GFX3D_Clipper::clipPoly(POLY* poly, VERT** verts) } #endif - -// "Workaround" for line poly -bool gfx3d_IsLinePoly(POLY *poly) -{ - if(!CommonSettings.GFX3D_LineHack) return false; - - int type = poly->type; - VERT *vert1, *vert2; - - if (type <= 2) - return true; - else if (type > 10) - return false; - - // Method 1: - // Castlevania Portrait of Ruin - trajectory of ricochet - bool duplicatedVert[10]; - for(int i = 0; i < type; i++) - duplicatedVert[i] = false; - for(int i = 0; i < type - 1; i++) - { - vert1 = &gfx3d.vertlist->list[poly->vertIndexes[i]]; - for(int j = i + 1; j < type; j++) - { - vert2 = &gfx3d.vertlist->list[poly->vertIndexes[j]]; - if (vert1->x == vert2->x && vert1->y == vert2->y - //&& vert1->z == vert2->z - ) - { - duplicatedVert[j] = true; - } - } - } - int vertCount = type; - for(int i = 0; i < type; i++) - { - if (duplicatedVert[i]) - vertCount--; - } - if (vertCount <= 2) - return true; - - // Method 2: - // Castlevania Portrait of Ruin - warp stone - bool horizontalLine = true; - bool verticalLine = true; - vert1 = &gfx3d.vertlist->list[poly->vertIndexes[0]]; - for(int i = 1; i < type && (horizontalLine || verticalLine); i++) - { - vert2 = &gfx3d.vertlist->list[poly->vertIndexes[i]]; - if (vert1->coord[0] != vert2->coord[0]) - { - verticalLine = false; - } - if (vert1->coord[1] != vert2->coord[1]) - { - horizontalLine = false; - } - - //the Z is different, and this method isn't even meant to catch that - //if (vert1->coord[2] != vert2->coord[2]) - // return false; - } - if (horizontalLine || verticalLine) - return true; - - return false; -} diff --git a/desmume/src/gfx3d.h b/desmume/src/gfx3d.h index 731f8a030..90b64f241 100644 --- a/desmume/src/gfx3d.h +++ b/desmume/src/gfx3d.h @@ -447,6 +447,4 @@ bool gfx3d_loadstate(EMUFILE* is, int size); void gfx3d_ClearStack(); -bool gfx3d_IsLinePoly(POLY *poly); - #endif //_GFX3D_H_ diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index d61ccb245..644a150ab 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -200,6 +200,11 @@ struct edge_fx_fl { float curr, step, stepExtra; FORCEINLINE void doStep() { curr += step; } FORCEINLINE void doStepExtra() { curr += stepExtra; } + FORCEINLINE void initialize(float value) { + curr = value; + step = 0; + stepExtra = 0; + } FORCEINLINE void initialize(float top, float bottom, float dx, float dy, long XStep, float XPrestep, float YPrestep) { dx = 0; dy *= (bottom-top); @@ -265,8 +270,18 @@ FORCEINLINE edge_fx_fl::edge_fx_fl(int Top, int Bottom, VERT** verts, bool& fail } else { - memset(this, 0, sizeof(*this)); - this->verts = verts; + // even if Width == 0 && Height == 0, give some info for pixel poly + // example: Castlevania Portrait of Ruin, warp stone + XStep = 1; + Numerator = 0; + Denominator = 1; + ErrorTerm = 0; + invw.initialize(1/verts[Top]->w); + u.initialize(verts[Top]->u); + v.initialize(verts[Top]->v); + z.initialize(verts[Top]->z); + for(int i=0;i<3;i++) + color[i].initialize(verts[Top]->fcolor[i]); } } @@ -1045,7 +1060,7 @@ public: polyAttr.backfacing = engine->polyBackfacing[i]; - shape_engine(type,!polyAttr.backfacing, gfx3d_IsLinePoly(poly)); + shape_engine(type,!polyAttr.backfacing, (poly->vtxFormat & 4) && CommonSettings.GFX3D_LineHack); } }