20 #define AFFINE_SPANLET_SIZE 16
21 #define AFFINE_SPANLET_SIZE_BITS 4
152 int one_minus_alpha = 255 - alpha;
177 float frac, clipdist, *pclipnormal;
178 float *in, *instep, *outstep, *vert2;
180 clipdist = pclipplane->
dist;
181 pclipnormal = pclipplane->
normal;
195 for (i = 0; i < nump; i++, instep +=
sizeof(vec5_t) /
sizeof(
float)) {
196 dists[i] = DotProduct(instep, pclipnormal) - clipdist;
200 dists[nump] = dists[0];
201 memcpy(instep, in,
sizeof(vec5_t));
208 for (i = 0; i < nump; i++, instep +=
sizeof(vec5_t) /
sizeof(
float)) {
210 memcpy(outstep, instep,
sizeof(vec5_t));
211 outstep +=
sizeof(vec5_t) /
sizeof(
float);
215 if (dists[i] == 0 || dists[i + 1] == 0)
218 if ((dists[i] > 0) == (dists[i + 1] > 0))
222 frac = dists[i] / (dists[i] - dists[i + 1]);
224 vert2 = instep +
sizeof(vec5_t) /
sizeof(
float);
226 outstep[0] = instep[0] + frac * (vert2[0] - instep[0]);
227 outstep[1] = instep[1] + frac * (vert2[1] - instep[1]);
228 outstep[2] = instep[2] + frac * (vert2[2] - instep[2]);
229 outstep[3] = instep[3] + frac * (vert2[3] - instep[3]);
230 outstep[4] = instep[4] + frac * (vert2[4] - instep[4]);
232 outstep +=
sizeof(vec5_t) /
sizeof(
float);
245 fixed16_t snext, tnext;
246 float sdivz, tdivz, zi, z, du, dv, spancountminus1;
247 float sdivzspanletstepu, tdivzspanletstepu, zispanletstepu;
251 if (iswater & SURF_WARP)
253 else if (iswater & SURF_FLOWING)
271 count = pspan->
count;
277 du = (float)pspan->
u;
278 dv = (
float)pspan->
v;
284 z = (float)0x10000 / zi;
315 sdivz += sdivzspanletstepu;
316 tdivz += tdivzspanletstepu;
317 zi += zispanletstepu;
318 z = (float)0x10000 / zi;
348 z = (float)0x10000 / zi;
399 int i, v, itop, ibottom, lmaxindex;
402 float du, dv, vtop, vbottom, slope;
420 vbottom = ceil(pnext->
v);
422 if (vtop < vbottom) {
423 du = pnext->
u - pvert->
u;
424 dv = pnext->
v - pvert->
v;
427 u_step = (
int)(slope * 0x10000);
429 u = (
int)((pvert->
u + (slope * (vtop - pvert->
v))) * 0x10000) +
432 ibottom = (
int)vbottom;
434 for (v = itop; v < ibottom; v++) {
448 }
while (i != lmaxindex);
459 int i, v, itop, ibottom;
462 float du, dv, vtop, vbottom, slope, uvert, unext, vvert, vnext;
486 vbottom = ceil(vnext);
488 if (vtop < vbottom) {
504 u_step = (
int)(slope * 0x10000);
506 u = (
int)((uvert + (slope * (vtop - vvert))) * 0x10000) +
509 ibottom = (
int)vbottom;
511 for (v = itop; v < ibottom; v++) {
512 pspan->
count = (u >> 16) - pspan->
u;
539 vec3_t transformed, local;
546 }
else if (textured == 2) {
548 }
else if (alpha == 1) {
552 }
else if (isturbulent) {
562 for (i = 0; i < 4; i++) {
567 Com_Error(ERR_DROP,
"R_ClipAndDrawPoly: too many points: %d", nump);
573 for (i = 0; i < nump; i++) {
574 VectorSubtract(pv,
r_origin, local);
581 pout->
zi = 1.0 / transformed[2];
592 pv +=
sizeof(vec5_t) /
sizeof(vec_t);
608 msurfedge_t *surfedge;
611 float tmins[2] = { 0, 0 };
616 lnumverts = fa->numsurfedges;
619 Com_Error(ERR_DROP,
"R_BuildPolygonFromSurface: too many points: %d", lnumverts);
623 surfedge = fa->firstsurfedge;
624 for (i = 0; i < lnumverts; i++, surfedge++) {
625 vec = surfedge->edge->v[surfedge->vert]->point;
626 VectorCopy(vec, pverts[i]);
634 if (fa->drawflags & DSURF_PLANEBACK) {
638 if (fa->texinfo->c.flags & (SURF_WARP | SURF_FLOWING)) {
651 tmins[0] = fa->texturemins[0];
652 tmins[1] = fa->texturemins[1];
661 if (fa->texinfo->c.flags & SURF_FLOWING) {
673 vec3_t p_normal, p_saxis, p_taxis;
726 if (pverts->
v < ymin) {
731 if (pverts->
v > ymax) {
752 pverts[nump] = pverts[0];
777 if (s->texinfo->c.flags & SURF_TRANS66)
778 R_ClipAndDrawPoly(0.66f, (s->texinfo->c.flags & (SURF_WARP | SURF_FLOWING)), qtrue);
780 R_ClipAndDrawPoly(0.33f, (s->texinfo->c.flags & (SURF_WARP | SURF_FLOWING)), qtrue);
813 VectorSubtract(d,
c, s0);
814 VectorSubtract(
c, b, s1);
839 mspriteframe_t *frame;
857 frame->width - frame->origin_x,
right);
859 frame->height - frame->origin_y,
up);
861 -frame->origin_x, left);
863 -frame->origin_y, down);
879 pverts[1][3] = frame->width;
885 pverts[2][3] = frame->width;
886 pverts[2][4] = frame->height;
892 pverts[3][4] = frame->height;
899 if (frame->image->flags & IF_TRANSPARENT)