64void Q3PatchTesselateFloat(
int numcomponents,
int outputstride,
float *outputvertices,
int patchwidth,
int patchheight,
int inputstride,
float *patchvertices,
int tesselationwidth,
int tesselationheight)
67 float px, py, *
v,
a,
b, c, *cp[3][3], temp[3][64];
68 int xmax =
max(1, 2*tesselationwidth);
69 int ymax =
max(1, 2*tesselationheight);
74 for (k = 0;k < patchheight-1;k += 2)
76 for (l = 0;l < patchwidth-1;l += 2)
81 cp[
y][
x] = (
float *)((
unsigned char *)patchvertices + ((k+
y)*patchwidth+(l+
x)) * inputstride);
83 for (
y = 0;
y <= ymax;
y++)
87 py = (
float)
y / (
float)ymax;
89 a = ((1.0f - py) * (1.0f - py));
90 b = ((1.0f - py) * (2.0f * py));
92 for (component = 0;component < numcomponents;component++)
94 temp[0][component] = cp[0][0][component] *
a + cp[1][0][component] *
b + cp[2][0][component] * c;
95 temp[1][component] = cp[0][1][component] *
a + cp[1][1][component] *
b + cp[2][1][component] * c;
96 temp[2][component] = cp[0][2][component] *
a + cp[1][2][component] *
b + cp[2][2][component] * c;
99 v = (
float *)((
unsigned char *)outputvertices + ((k * ymax / 2 +
y) * outputwidth + l * xmax / 2) * outputstride);
101 for (
x = 0;
x <= xmax;
x++)
107 a = ((1.0f -
px) * (1.0f -
px));
108 b = ((1.0f -
px) * (2.0f *
px));
110 for (component = 0;component < numcomponents;component++)
111 v[component] = temp[0][component] *
a + temp[1][component] *
b + temp[2][component] * c;
115 v = (
float *)((
unsigned char *)
v + outputstride);
122 printf(
"vertices[%i][%i] =\n{\n", (patchheight-1)*tesselationheight+1, (patchwidth-1)*tesselationwidth+1);
123 for (
y = 0;
y < (patchheight-1)*tesselationheight+1;
y++)
125 for (
x = 0;
x < (patchwidth-1)*tesselationwidth+1;
x++)
128 for (component = 0;component < numcomponents;component++)
129 printf(
"%f ", outputvertices[(
y*((patchwidth-1)*tesselationwidth+1)+
x)*numcomponents+component]);
164 float quartercurvearea = 0;
166 for (c = 0;c < components;c++)
168 deviation = control[c] * 0.5f -
a[c] * 0.25f -
b[c] * 0.25f;
169 quartercurvearea += deviation*deviation;
173 return quartercurvearea * quartercurvearea * 64.0;
215 float aa = 0, bb = 0, ab = 0;
216 for (c = 0;c < components;c++)
218 float xa =
a[c] - control[c];
219 float xb =
b[c] - control[c];
227 return aa * bb - ab * ab;
236 float squared3xcurvearea, largestsquared3xcurvearea;
237 largestsquared3xcurvearea = 0;
238 for (
y = 0;
y < patchheight;
y++)
240 for (
x = 0;
x < patchwidth-1;
x += 2)
242 patch = in + ((
y * patchwidth) +
x) * components;
243 squared3xcurvearea =
Squared3xCurveArea(&patch[0], &patch[components], &patch[2*components], components);
244 if (largestsquared3xcurvearea < squared3xcurvearea)
245 largestsquared3xcurvearea = squared3xcurvearea;
256 float squared3xcurvearea, largestsquared3xcurvearea;
257 largestsquared3xcurvearea = 0;
258 for (
y = 0;
y < patchheight-1;
y += 2)
260 for (
x = 0;
x < patchwidth;
x++)
262 patch = in + ((
y * patchwidth) +
x) * components;
263 squared3xcurvearea =
Squared3xCurveArea(&patch[0], &patch[patchwidth*components], &patch[2*patchwidth*components], components);
264 if (largestsquared3xcurvearea < squared3xcurvearea)
265 largestsquared3xcurvearea = squared3xcurvearea;
336 struct {
int id1,id2;} commonverts[8];
337 int i, j, k, side1, side2, *tess1, *tess2;
338 int dist1 = 0, dist2 = 0;
339 qbool modified =
false;
342 commonverts[0].id1 = 0;
343 commonverts[1].id1 = patch1->
xsize-1;
344 commonverts[2].id1 = patch1->
xsize*(patch1->
ysize-1);
345 commonverts[3].id1 = patch1->
xsize*patch1->
ysize-1;
350 commonverts[4].id2 = 0;
351 commonverts[5].id2 = patch2->
xsize-1;
352 commonverts[6].id2 = patch2->
xsize*(patch2->
ysize-1);
353 commonverts[7].id2 = patch2->
xsize*patch2->
ysize-1;
360 side1 =
GetSide(commonverts[
i].id1,commonverts[j].id1,patch1->
xsize,patch1->
ysize,&dist1);
361 side2 =
GetSide(commonverts[
i].id2,commonverts[j].id2,patch2->
xsize,patch2->
ysize,&dist2);
377 if (*tess1 != *tess2)
void Q3PatchTesselateFloat(int numcomponents, int outputstride, float *outputvertices, int patchwidth, int patchheight, int inputstride, float *patchvertices, int tesselationwidth, int tesselationheight)