+
+ n = minva * sin(perc * M_PI);
+ n = n * n;
+
+ num = 0;
+ for (col = 0, gx = 0; gx <= (w + gszw - 1); gx += gszw, col++)
+ {
+ for (gy = 0; gy <= (h + gszh - 1); gy += gszh)
+ {
+ Vertex2 vi;
+ Vertex3 vo, tvo1;
+
+ if (gx > w) vi.x = w;
+ else vi.x = gx;
+ if (gy > h) vi.y = h;
+ else vi.y = gy;
+ _deform_point(&vi, &vo, rho, theta, A);
+ tvo1 = tvol[col];
+ if (gy > h) tvo1.y = h;
+ else tvo1.y = gy;
+ _interp_point(&vo, &tvo1, &(tvo[num]), n);
+ num++;
+ }
+ }
+
+ jump = st->slices_h + 1;
+ for (col = 0, gx = 0; gx < w; gx += gszw, col++)
+ {
+ num = st->slices_h * col;
+ num2 = jump * col;
+
+ gw = gszw;
+ if ((gx + gw) > w) gw = w - gx;
+
+ for (row = 0, gy = 0; gy < h; gy += gszh, row++)
+ {
+ Vertex3 vo[4];
+
+ if (b > 0) nn = num + st->slices_h - row - 1;
+ else nn = num + row;
+
+ gh = gszh;
+ if ((gy + gh) > h) gh = h - gy;
+
+ vo[0] = tvo[num2 + row];
+ vo[1] = tvo[num2 + row + jump];
+ vo[2] = tvo[num2 + row + jump + 1];
+ vo[3] = tvo[num2 + row + 1];
+#define SWP(a, b) do {typeof(a) vt; vt = (a); (a) = (b); (b) = vt;} while (0)
+ if (b > 0)
+ {
+ SWP(vo[0], vo[3]);
+ SWP(vo[1], vo[2]);
+ vo[0].y = h - vo[0].y;
+ vo[1].y = h - vo[1].y;
+ vo[2].y = h - vo[2].y;
+ vo[3].y = h - vo[3].y;
+ }
+
+ // FRONT
+ sl = st->slices[nn];
+ if (!sl)
+ {
+ sl = _slice_new(st, st->front);
+ st->slices[nn] = sl;
+ }
+ _slice_xyz(st, sl,
+ vo[0].x, vo[0].y, vo[0].z,
+ vo[1].x, vo[1].y, vo[1].z,
+ vo[2].x, vo[2].y, vo[2].z,
+ vo[3].x, vo[3].y, vo[3].z);
+ if (b <= 0)
+ _slice_uv(st, sl,
+ gx, gy, gx + gw, gy,
+ gx + gw, gy + gh, gx, gy + gh);
+ else
+ _slice_uv(st, sl,
+ gx, h - (gy + gh), gx + gw, h - (gy + gh),
+ gx + gw, h - gy, gx, h - gy);
+
+ // BACK
+ sl = st->slices2[nn];
+ if (!sl)
+ {
+ sl = _slice_new(st, st->back);
+ st->slices2[nn] = sl;
+ }
+
+ _slice_xyz(st, sl,
+ vo[1].x, vo[1].y, vo[1].z,
+ vo[0].x, vo[0].y, vo[0].z,
+ vo[3].x, vo[3].y, vo[3].z,
+ vo[2].x, vo[2].y, vo[2].z);
+ if (st->backflip)
+ {
+ if (b <= 0)
+ _slice_uv(st, sl,
+ gx + gw, gy, gx, gy,
+ gx, gy + gh, gx + gw, gy + gh);
+ else
+ _slice_uv(st, sl,
+ gx + gw, h - (gy + gh), gx, h - (gy + gh),
+ gx, h - gy, gx + gw, h - gy);
+ }
+ else
+ {
+ if (b <= 0)
+ _slice_uv(st, sl,
+ w - (gx + gw), gy, w - (gx), gy,
+ w - (gx), gy + gh, w - (gx + gw), gy + gh);
+ else
+ _slice_uv(st, sl,
+ w - (gx + gw), h - (gy + gh), w - (gx), h - (gy + gh),
+ w - (gx), h - gy, w - (gx + gw), h - gy);
+ }
+ }
+ }
+
+ num = 0;
+ for (j = 0; j < st->slices_h; j++)
+ {
+ for (i = 0; i < st->slices_w; i++)
+ {
+ _slice_apply(st, st->slices[num], x, y, w, h, ox, oy, ow, oh);
+ _slice_apply(st, st->slices2[num], x, y, w, h, ox, oy, ow, oh);
+ _slice_light(st, st->slices[num], ox, oy, ow, oh);
+ _slice_light(st, st->slices2[num], ox, oy, ow, oh);
+ num++;
+ }
+ }
+
+ for (i = 0; i <= st->slices_w; i++)
+ {
+ num = i * st->slices_h;
+ for (j = 0; j <= st->slices_h; j++)
+ {
+ Slice *s[4];
+
+ s[0] = s[1] = s[2] = s[3] = NULL;
+ if ((i > 0) && (j > 0))
+ s[0] = st->slices[num - 1 - st->slices_h];
+ if ((i < st->slices_w) && (j > 0))
+ s[1] = st->slices[num - 1];
+ if ((i > 0) && (j < st->slices_h))
+ s[2] = st->slices[num - st->slices_h];
+ if ((i < st->slices_w) && (j < st->slices_h))
+ s[3] = st->slices[num];
+ if (st->dir == 0)
+ _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
+ s[2], 1, s[3], 0);
+ else if (st->dir == 1)
+ _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
+ s[2], 0, s[3], 1);
+ else if (st->dir == 2)
+ _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
+ s[2], 0, s[3], 1);
+ else if (st->dir == 3)
+ _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
+ s[2], 1, s[3], 0);
+ s[0] = s[1] = s[2] = s[3] = NULL;
+ if ((i > 0) && (j > 0))
+ s[0] = st->slices2[num - 1 - st->slices_h];
+ if ((i < st->slices_w) && (j > 0))
+ s[1] = st->slices2[num - 1];
+ if ((i > 0) && (j < st->slices_h))
+ s[2] = st->slices2[num - st->slices_h];
+ if ((i < st->slices_w) && (j < st->slices_h))
+ s[3] = st->slices2[num];
+ if (st->dir == 0)
+ _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
+ s[2], 0, s[3], 1);
+ else if (st->dir == 1)
+ _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
+ s[2], 1, s[3], 0);
+ else if (st->dir == 2)
+ _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
+ s[2], 1, s[3], 0);
+ else if (st->dir == 3)
+ _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
+ s[2], 0, s[3], 1);
+ num++;
+ }
+ }
+
+ num = 0;
+ for (i = 0; i < st->slices_w; i++)
+ {
+ for (j = 0; j < st->slices_h; j++)
+ {
+ _slice_3d(st, st->slices[num], ox, oy, ow, oh);
+ _slice_3d(st, st->slices2[num], ox, oy, ow, oh);
+ num++;
+ }
+ }
+
+ return 1;