2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
d_sprite.c
|
|
|
|
|
2001-05-18 20:19:20 +00:00
|
|
|
software top-level rasterization driver module for drawing sprites
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-19 00:23:21 +00:00
|
|
|
#include "QF/render.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-16 06:58:55 +00:00
|
|
|
#include "d_local.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2001-08-16 06:58:55 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static int sprite_height;
|
|
|
|
static int minindex, maxindex;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-11 20:59:48 +00:00
|
|
|
#ifdef PIC
|
2001-05-25 14:57:31 +00:00
|
|
|
#undef USE_INTEL_ASM //XXX asm pic hack
|
2001-06-11 20:59:48 +00:00
|
|
|
#endif
|
2001-05-25 14:57:31 +00:00
|
|
|
|
2001-05-18 20:19:20 +00:00
|
|
|
|
2001-08-16 06:58:55 +00:00
|
|
|
#ifndef USE_INTEL_ASM
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2022-03-09 11:19:14 +00:00
|
|
|
D_SpriteDrawSpans (sspan_t *pspan)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int count, spancount, izistep;
|
|
|
|
int izi;
|
|
|
|
byte *pbase, *pdest;
|
|
|
|
fixed16_t s, t, snext, tnext, sstep, tstep;
|
|
|
|
float sdivz, tdivz, zi, z, du, dv, spancountminus1;
|
|
|
|
float sdivz8stepu, tdivz8stepu, zi8stepu;
|
|
|
|
byte btemp;
|
|
|
|
short *pz;
|
|
|
|
|
|
|
|
sstep = 0; // keep compiler happy
|
|
|
|
tstep = 0; // ditto
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
pbase = cacheblock;
|
|
|
|
|
|
|
|
sdivz8stepu = d_sdivzstepu * 8;
|
|
|
|
tdivz8stepu = d_tdivzstepu * 8;
|
|
|
|
zi8stepu = d_zistepu * 8;
|
|
|
|
|
2001-08-16 06:58:55 +00:00
|
|
|
// we count on FP exceptions being turned off to avoid range problems
|
2001-02-26 06:48:02 +00:00
|
|
|
izistep = (int) (d_zistepu * 0x8000 * 0x10000);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
do {
|
2022-03-24 03:22:27 +00:00
|
|
|
pdest = d_viewbuffer + (d_rowbytes * pspan->v) + pspan->u;
|
2022-03-21 14:11:09 +00:00
|
|
|
pz = d_zbuffer + (d_zwidth * pspan->v) + pspan->u;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
count = pspan->count;
|
|
|
|
|
|
|
|
if (count <= 0)
|
|
|
|
goto NextSpan;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// calculate the initial s/z, t/z, 1/z, s, and t and clamp
|
|
|
|
du = (float) pspan->u;
|
|
|
|
dv = (float) pspan->v;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
sdivz = d_sdivzorigin + dv * d_sdivzstepv + du * d_sdivzstepu;
|
|
|
|
tdivz = d_tdivzorigin + dv * d_tdivzstepv + du * d_tdivzstepu;
|
|
|
|
zi = d_ziorigin + dv * d_zistepv + du * d_zistepu;
|
|
|
|
z = (float) 0x10000 / zi; // prescale to 16.16 fixed-point
|
|
|
|
// we count on FP exceptions being turned off to avoid range problems
|
|
|
|
izi = (int) (zi * 0x8000 * 0x10000);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
s = (int) (sdivz * z) + sadjust;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (s > bbextents)
|
|
|
|
s = bbextents;
|
|
|
|
else if (s < 0)
|
|
|
|
s = 0;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
t = (int) (tdivz * z) + tadjust;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (t > bbextentt)
|
|
|
|
t = bbextentt;
|
|
|
|
else if (t < 0)
|
|
|
|
t = 0;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
do {
|
|
|
|
// calculate s and t at the far end of the span
|
2001-02-19 21:15:25 +00:00
|
|
|
if (count >= 8)
|
|
|
|
spancount = 8;
|
|
|
|
else
|
|
|
|
spancount = count;
|
|
|
|
|
|
|
|
count -= spancount;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (count) {
|
|
|
|
// calculate s/z, t/z, zi->fixed s and t at far end of span,
|
|
|
|
// calculate s and t steps across span by shifting
|
2001-02-19 21:15:25 +00:00
|
|
|
sdivz += sdivz8stepu;
|
|
|
|
tdivz += tdivz8stepu;
|
|
|
|
zi += zi8stepu;
|
2001-02-26 06:48:02 +00:00
|
|
|
z = (float) 0x10000 / zi; // prescale to 16.16 fixed-point
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
snext = (int) (sdivz * z) + sadjust;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (snext > bbextents)
|
|
|
|
snext = bbextents;
|
|
|
|
else if (snext < 8)
|
2001-05-18 20:19:20 +00:00
|
|
|
snext = 8; // prevent round-off error on <0
|
|
|
|
// steps from
|
|
|
|
// from causing overstepping & running off the
|
|
|
|
// edge of the texture
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
tnext = (int) (tdivz * z) + tadjust;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (tnext > bbextentt)
|
|
|
|
tnext = bbextentt;
|
|
|
|
else if (tnext < 8)
|
2001-02-26 06:48:02 +00:00
|
|
|
tnext = 8; // guard against round-off error on
|
2001-05-15 17:38:43 +00:00
|
|
|
// <0 steps
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
sstep = (snext - s) >> 3;
|
|
|
|
tstep = (tnext - t) >> 3;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-05-18 20:19:20 +00:00
|
|
|
// calculate s/z, t/z, zi->fixed s and t at last pixel in
|
|
|
|
// span (so can't step off polygon), clamp, calculate s and t
|
|
|
|
// steps across span by division, biasing steps low so we
|
|
|
|
// don't run off the texture
|
2001-02-26 06:48:02 +00:00
|
|
|
spancountminus1 = (float) (spancount - 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
sdivz += d_sdivzstepu * spancountminus1;
|
|
|
|
tdivz += d_tdivzstepu * spancountminus1;
|
|
|
|
zi += d_zistepu * spancountminus1;
|
2001-02-26 06:48:02 +00:00
|
|
|
z = (float) 0x10000 / zi; // prescale to 16.16 fixed-point
|
|
|
|
snext = (int) (sdivz * z) + sadjust;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (snext > bbextents)
|
|
|
|
snext = bbextents;
|
|
|
|
else if (snext < 8)
|
2001-05-15 17:38:43 +00:00
|
|
|
snext = 8; // prevent round-off error on <0 steps
|
2001-05-18 20:19:20 +00:00
|
|
|
// from from causing overstepping &
|
|
|
|
// running off the edge of the texture
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
tnext = (int) (tdivz * z) + tadjust;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (tnext > bbextentt)
|
|
|
|
tnext = bbextentt;
|
|
|
|
else if (tnext < 8)
|
2001-02-26 06:48:02 +00:00
|
|
|
tnext = 8; // guard against round-off error on
|
2001-05-15 17:38:43 +00:00
|
|
|
// <0 steps
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (spancount > 1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
sstep = (snext - s) / (spancount - 1);
|
|
|
|
tstep = (tnext - t) / (spancount - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
btemp = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (btemp != 255) {
|
|
|
|
if (*pz <= (izi >> 16)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
*pz = izi >> 16;
|
|
|
|
*pdest = btemp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
izi += izistep;
|
|
|
|
pdest++;
|
|
|
|
pz++;
|
|
|
|
s += sstep;
|
|
|
|
t += tstep;
|
|
|
|
} while (--spancount > 0);
|
|
|
|
|
|
|
|
s = snext;
|
|
|
|
t = tnext;
|
|
|
|
|
|
|
|
} while (count > 0);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
NextSpan:
|
2001-02-19 21:15:25 +00:00
|
|
|
pspan++;
|
|
|
|
|
|
|
|
} while (pspan->count != DS_SPAN_LIST_END);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-07-26 12:14:28 +00:00
|
|
|
D_SpriteScanLeftEdge (sspan_t *pspan)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, v, itop, ibottom, lmaxindex;
|
|
|
|
emitpoint_t *pvert, *pnext;
|
|
|
|
float du, dv, vtop, vbottom, slope;
|
|
|
|
fixed16_t u, u_step;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
i = minindex;
|
|
|
|
if (i == 0)
|
|
|
|
i = r_spritedesc.nump;
|
|
|
|
|
|
|
|
lmaxindex = maxindex;
|
|
|
|
if (lmaxindex == 0)
|
|
|
|
lmaxindex = r_spritedesc.nump;
|
|
|
|
|
|
|
|
vtop = ceil (r_spritedesc.pverts[i].v);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
pvert = &r_spritedesc.pverts[i];
|
|
|
|
pnext = pvert - 1;
|
|
|
|
|
|
|
|
vbottom = ceil (pnext->v);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (vtop < vbottom) {
|
2001-02-19 21:15:25 +00:00
|
|
|
du = pnext->u - pvert->u;
|
|
|
|
dv = pnext->v - pvert->v;
|
|
|
|
slope = du / dv;
|
2001-02-26 06:48:02 +00:00
|
|
|
u_step = (int) (slope * 0x10000);
|
|
|
|
// adjust u to ceil the integer portion
|
|
|
|
u = (int) ((pvert->u + (slope * (vtop - pvert->v))) * 0x10000) +
|
|
|
|
(0x10000 - 1);
|
|
|
|
itop = (int) vtop;
|
|
|
|
ibottom = (int) vbottom;
|
|
|
|
|
|
|
|
for (v = itop; v < ibottom; v++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
pspan->u = u >> 16;
|
|
|
|
pspan->v = v;
|
|
|
|
u += u_step;
|
|
|
|
pspan++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vtop = vbottom;
|
|
|
|
|
|
|
|
i--;
|
|
|
|
if (i == 0)
|
|
|
|
i = r_spritedesc.nump;
|
|
|
|
|
|
|
|
} while (i != lmaxindex);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-07-26 12:14:28 +00:00
|
|
|
D_SpriteScanRightEdge (sspan_t *pspan)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, v, itop, ibottom;
|
|
|
|
emitpoint_t *pvert, *pnext;
|
|
|
|
float du, dv, vtop, vbottom, slope, uvert, unext, vvert, vnext;
|
|
|
|
fixed16_t u, u_step;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
i = minindex;
|
|
|
|
|
|
|
|
vvert = r_spritedesc.pverts[i].v;
|
|
|
|
if (vvert < r_refdef.fvrecty_adj)
|
|
|
|
vvert = r_refdef.fvrecty_adj;
|
|
|
|
if (vvert > r_refdef.fvrectbottom_adj)
|
|
|
|
vvert = r_refdef.fvrectbottom_adj;
|
|
|
|
|
|
|
|
vtop = ceil (vvert);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
pvert = &r_spritedesc.pverts[i];
|
|
|
|
pnext = pvert + 1;
|
|
|
|
|
|
|
|
vnext = pnext->v;
|
|
|
|
if (vnext < r_refdef.fvrecty_adj)
|
|
|
|
vnext = r_refdef.fvrecty_adj;
|
|
|
|
if (vnext > r_refdef.fvrectbottom_adj)
|
|
|
|
vnext = r_refdef.fvrectbottom_adj;
|
|
|
|
|
|
|
|
vbottom = ceil (vnext);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (vtop < vbottom) {
|
2001-02-19 21:15:25 +00:00
|
|
|
uvert = pvert->u;
|
|
|
|
if (uvert < r_refdef.fvrectx_adj)
|
|
|
|
uvert = r_refdef.fvrectx_adj;
|
|
|
|
if (uvert > r_refdef.fvrectright_adj)
|
|
|
|
uvert = r_refdef.fvrectright_adj;
|
|
|
|
|
|
|
|
unext = pnext->u;
|
|
|
|
if (unext < r_refdef.fvrectx_adj)
|
|
|
|
unext = r_refdef.fvrectx_adj;
|
|
|
|
if (unext > r_refdef.fvrectright_adj)
|
|
|
|
unext = r_refdef.fvrectright_adj;
|
|
|
|
|
|
|
|
du = unext - uvert;
|
|
|
|
dv = vnext - vvert;
|
|
|
|
slope = du / dv;
|
2001-02-26 06:48:02 +00:00
|
|
|
u_step = (int) (slope * 0x10000);
|
|
|
|
// adjust u to ceil the integer portion
|
|
|
|
u = (int) ((uvert + (slope * (vtop - vvert))) * 0x10000) +
|
|
|
|
(0x10000 - 1);
|
|
|
|
itop = (int) vtop;
|
|
|
|
ibottom = (int) vbottom;
|
|
|
|
|
|
|
|
for (v = itop; v < ibottom; v++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
pspan->count = (u >> 16) - pspan->u;
|
|
|
|
u += u_step;
|
|
|
|
pspan++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vtop = vbottom;
|
|
|
|
vvert = vnext;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
if (i == r_spritedesc.nump)
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
} while (i != maxindex);
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
pspan->count = DS_SPAN_LIST_END; // mark the end of the span list
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-03-11 04:10:20 +00:00
|
|
|
D_SpriteCalculateGradients (const vec3_t relvieworg)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
vec3_t p_normal, p_saxis, p_taxis, p_temp1;
|
|
|
|
float distinv;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
TransformVector (r_spritedesc.vfwd, p_normal);
|
2001-02-19 21:15:25 +00:00
|
|
|
TransformVector (r_spritedesc.vright, p_saxis);
|
|
|
|
TransformVector (r_spritedesc.vup, p_taxis);
|
2007-03-10 12:00:59 +00:00
|
|
|
VectorNegate (p_taxis, p_taxis);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
distinv = 1.0 / (-DotProduct (relvieworg, r_spritedesc.vfwd));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
d_sdivzstepu = p_saxis[0] * xscaleinv;
|
|
|
|
d_tdivzstepu = p_taxis[0] * xscaleinv;
|
|
|
|
|
|
|
|
d_sdivzstepv = -p_saxis[1] * yscaleinv;
|
|
|
|
d_tdivzstepv = -p_taxis[1] * yscaleinv;
|
|
|
|
|
|
|
|
d_zistepu = p_normal[0] * xscaleinv * distinv;
|
|
|
|
d_zistepv = -p_normal[1] * yscaleinv * distinv;
|
|
|
|
|
|
|
|
d_sdivzorigin = p_saxis[2] - xcenter * d_sdivzstepu -
|
2001-02-26 06:48:02 +00:00
|
|
|
ycenter * d_sdivzstepv;
|
2001-02-19 21:15:25 +00:00
|
|
|
d_tdivzorigin = p_taxis[2] - xcenter * d_tdivzstepu -
|
2001-02-26 06:48:02 +00:00
|
|
|
ycenter * d_tdivzstepv;
|
2001-02-19 21:15:25 +00:00
|
|
|
d_ziorigin = p_normal[2] * distinv - xcenter * d_zistepu -
|
2001-02-26 06:48:02 +00:00
|
|
|
ycenter * d_zistepv;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-11 04:10:20 +00:00
|
|
|
TransformVector (relvieworg, p_temp1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
sadjust = ((fixed16_t) (DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5)) -
|
|
|
|
(-(cachewidth >> 1) << 16);
|
|
|
|
tadjust = ((fixed16_t) (DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5)) -
|
|
|
|
(-(sprite_height >> 1) << 16);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 17:38:43 +00:00
|
|
|
// -1 (-epsilon) so we never wander off the edge of the texture
|
2001-02-19 21:15:25 +00:00
|
|
|
bbextents = (cachewidth << 16) - 1;
|
|
|
|
bbextentt = (sprite_height << 16) - 1;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2022-03-11 04:10:20 +00:00
|
|
|
D_DrawSprite (const vec3_t relvieworg)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, nump;
|
|
|
|
float ymin, ymax;
|
|
|
|
emitpoint_t *pverts;
|
|
|
|
sspan_t spans[MAXHEIGHT + 1];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 17:38:43 +00:00
|
|
|
// find the top and bottom vertices, and make sure there's at least one
|
|
|
|
// scan to draw
|
2001-02-19 21:15:25 +00:00
|
|
|
ymin = 999999.9;
|
|
|
|
ymax = -999999.9;
|
|
|
|
pverts = r_spritedesc.pverts;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < r_spritedesc.nump; i++) {
|
|
|
|
if (pverts->v < ymin) {
|
2001-02-19 21:15:25 +00:00
|
|
|
ymin = pverts->v;
|
|
|
|
minindex = i;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (pverts->v > ymax) {
|
2001-02-19 21:15:25 +00:00
|
|
|
ymax = pverts->v;
|
|
|
|
maxindex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
pverts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ymin = ceil (ymin);
|
|
|
|
ymax = ceil (ymax);
|
|
|
|
|
|
|
|
if (ymin >= ymax)
|
2001-02-26 06:48:02 +00:00
|
|
|
return; // doesn't cross any scans at all
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cachewidth = r_spritedesc.pspriteframe->width;
|
|
|
|
sprite_height = r_spritedesc.pspriteframe->height;
|
2001-08-29 02:16:17 +00:00
|
|
|
cacheblock = &r_spritedesc.pspriteframe->pixels[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-15 17:38:43 +00:00
|
|
|
// copy the first vertex to the last vertex, so we don't have to deal with
|
|
|
|
// wrapping
|
2001-02-19 21:15:25 +00:00
|
|
|
nump = r_spritedesc.nump;
|
|
|
|
pverts = r_spritedesc.pverts;
|
|
|
|
pverts[nump] = pverts[0];
|
|
|
|
|
2022-03-11 04:10:20 +00:00
|
|
|
D_SpriteCalculateGradients (relvieworg);
|
2022-07-26 12:14:28 +00:00
|
|
|
D_SpriteScanLeftEdge (spans);
|
|
|
|
D_SpriteScanRightEdge (spans);
|
|
|
|
D_SpriteDrawSpans (spans);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|