bugfix: divPoly could produce an 8th point after several calls because some of the old clipPoly code on which it was based

can add the same point twice consecutively (interpolation+adding the point).
Rather than raising the buffer I rewrote divPoly to avoid adding the same point twice.
This commit is contained in:
axelrodR 2014-01-21 22:05:40 +02:00
parent f60468abcb
commit adcd4f472e

View File

@ -193,29 +193,40 @@ static void dividePoly(const float* in, int nin,
rcVcopy(out2 + n*3, out1 + m*3);
m++;
n++;
// add the i'th point to the right polygon. Do NOT add points that are on the dividing line
// since these were already added above
if (d[i] > 0)
{
rcVcopy(out1 + m*3, in + i*3);
m++;
}
else if (d[i] < 0)
{
rcVcopy(out2 + n*3, in + i*3);
n++;
}
}
if (inb)
else // same side
{
out1[m*3+0] = in[i*3+0];
out1[m*3+1] = in[i*3+1];
out1[m*3+2] = in[i*3+2];
m++;
if (d[i] != 0) // not on the line
continue;
// add the i'th point to the right polygon. Addition is done even for points on the dividing line
if (d[i] >= 0)
{
rcVcopy(out1 + m*3, in + i*3);
m++;
if (d[i] != 0)
continue;
}
rcVcopy(out2 + n*3, in + i*3);
n++;
}
// i-th point is on the other half plane or on the line
out2[n*3+0] = in[i*3+0];
out2[n*3+1] = in[i*3+1];
out2[n*3+2] = in[i*3+2];
n++;
}
*nout1 = m;
*nout2 = n;
}
static void rasterizeTri(const float* v0, const float* v1, const float* v2,
const unsigned char area, rcHeightfield& hf,
const float* bmin, const float* bmax,