diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index d948179f9..9e3c9683e 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -2623,11 +2623,7 @@ static T interpolate(const float ratio, const T& x0, const T& x1) } //http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/as6/discussion.shtml -#ifdef OPTIMIZED_CLIPPING_METHOD template static FORCEINLINE VERT clipPoint(bool hirez, const VERT *inside, const VERT *outside) -#else -static FORCEINLINE VERT clipPoint(const VERT *inside, const VERT *outside, int coord, int which) -#endif { VERT ret; const float coord_inside = inside->coord[coord]; @@ -2661,8 +2657,6 @@ static FORCEINLINE VERT clipPoint(const VERT *inside, const VERT *outside, int c return ret; } -#ifdef OPTIMIZED_CLIPPING_METHOD - #define MAX_SCRATCH_CLIP_VERTS (4*6 + 40) static VERT scratchClipVerts [MAX_SCRATCH_CLIP_VERTS]; static int numScratchClipVerts = 0; @@ -2827,106 +2821,3 @@ void GFX3D_Clipper::clipPolyVsPlane(const int coord, int which) assert(0); } -#else // if not OPTIMIZED_CLIPPING_METHOD: - -FORCEINLINE void GFX3D_Clipper::clipSegmentVsPlane(VERT** verts, const int coord, int which) -{ - const bool out0 = (which == -1) ? (verts[0]->coord[coord] < -verts[0]->coord[3]) : (verts[0]->coord[coord] > verts[0]->coord[3]); - const bool out1 = (which == -1) ? (verts[1]->coord[coord] < -verts[1]->coord[3]) : (verts[1]->coord[coord] > verts[1]->coord[3]); - - //CONSIDER: should we try and clip things behind the eye? does this code even successfully do it? not sure. - //if(coord==2 && which==1) { - // out0 = verts[0]->coord[2] < 0; - // out1 = verts[1]->coord[2] < 0; - //} - - //both outside: insert no points - if (out0 && out1) - { - CLIPLOG(" both outside\n"); - } - - //both inside: insert the first point - if (!out0 && !out1) - { - CLIPLOG(" both inside\n"); - outClippedPoly.clipVerts[outClippedPoly.type++] = *verts[1]; - } - - //exiting volume: insert the clipped point and the first (interior) point - if (!out0 && out1) - { - CLIPLOG(" exiting\n"); - outClippedPoly.clipVerts[outClippedPoly.type++] = clipPoint(verts[0],verts[1], coord, which); - } - - //entering volume: insert clipped point - if (out0 && !out1) - { - CLIPLOG(" entering\n"); - outClippedPoly.clipVerts[outClippedPoly.type++] = clipPoint(verts[1],verts[0], coord, which); - outClippedPoly.clipVerts[outClippedPoly.type++] = *verts[1]; - } -} - -FORCEINLINE void GFX3D_Clipper::clipPolyVsPlane(const int coord, int which) -{ - outClippedPoly.type = 0; - CLIPLOG2("Clipping coord %d against %f\n",coord,x); - for (size_t i = 0; i < tempClippedPoly.type; i++) - { - VERT *testverts[2] = { &tempClippedPoly.clipVerts[i], &tempClippedPoly.clipVerts[(i+1)%tempClippedPoly.type] }; - clipSegmentVsPlane(testverts, coord, which); - } - - //this doesnt seem to help any. leaving it until i decide to get rid of it - //int j = index_start_table[tempClippedPoly.type-3]; - //for(int i=0;i T _max(T a, T b, T c, T d) { return max(_max(a,b,d),c); } static u8 modulate_table[64][64]; static u8 decal_table[32][64][64]; -static u8 index_lookup_table[65]; -static u8 index_start_table[8]; ////optimized float floor useful in limited cases ////from http://www.stereopsis.com/FPU.html#convert @@ -1266,21 +1264,6 @@ Render3DError SoftRasterizerRenderer::InitTables() } } - //these tables are used to increment through vert lists without having to do wrapping logic/math - u8 idx = 0; - for (u8 i = 3; i <= 8; i++) - { - index_start_table[i-3] = idx; - for (u8 j = 0; j < i; j++) - { - u8 a = j; - u8 b = j+1; - if (b == i) b = 0; - index_lookup_table[idx++] = a; - index_lookup_table[idx++] = b; - } - } - needTableInit = false; }