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:
parent
f60468abcb
commit
adcd4f472e
@ -193,29 +193,40 @@ static void dividePoly(const float* in, int nin,
|
|||||||
rcVcopy(out2 + n*3, out1 + m*3);
|
rcVcopy(out2 + n*3, out1 + m*3);
|
||||||
m++;
|
m++;
|
||||||
n++;
|
n++;
|
||||||
}
|
// add the i'th point to the right polygon. Do NOT add points that are on the dividing line
|
||||||
if (inb)
|
// since these were already added above
|
||||||
|
if (d[i] > 0)
|
||||||
{
|
{
|
||||||
out1[m*3+0] = in[i*3+0];
|
rcVcopy(out1 + m*3, in + i*3);
|
||||||
out1[m*3+1] = in[i*3+1];
|
|
||||||
out1[m*3+2] = in[i*3+2];
|
|
||||||
m++;
|
m++;
|
||||||
if (d[i] != 0) // not on the line
|
}
|
||||||
|
else if (d[i] < 0)
|
||||||
|
{
|
||||||
|
rcVcopy(out2 + n*3, in + i*3);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // same side
|
||||||
|
{
|
||||||
|
// 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
rcVcopy(out2 + n*3, in + i*3);
|
||||||
// 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++;
|
n++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*nout1 = m;
|
*nout1 = m;
|
||||||
*nout2 = n;
|
*nout2 = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void rasterizeTri(const float* v0, const float* v1, const float* v2,
|
static void rasterizeTri(const float* v0, const float* v1, const float* v2,
|
||||||
const unsigned char area, rcHeightfield& hf,
|
const unsigned char area, rcHeightfield& hf,
|
||||||
const float* bmin, const float* bmax,
|
const float* bmin, const float* bmax,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user