2 //**************************************************************************
4 //** r_things.c : Heretic 2 : Raven Software, Corp.
11 //**************************************************************************
22 void R_DrawColumn (void);
23 void R_DrawFuzzColumn (void);
24 void R_DrawAltFuzzColumn(void);
25 //void R_DrawTranslatedAltFuzzColumn(void);
38 Sprite rotation 0 is facing the viewer, rotation 1 is one angle turn CLOCKWISE around the axis.
39 This is not the same as the angle, which increases counter clockwise
40 (protractor). There was a lot of stuff grabbed wrong, so I changed it...
45 fixed_t pspritescale, pspriteiscale;
47 lighttable_t **spritelights;
49 // constant arrays used for psprite clipping and initializing clipping
50 short negonearray[SCREENWIDTH];
51 short screenheightarray[SCREENWIDTH];
53 boolean LevelUseFullBright;
55 ===============================================================================
57 INITIALIZATION FUNCTIONS
59 ===============================================================================
62 // variables used to look up and range check thing_t sprites patches
66 spriteframe_t sprtemp[30];
77 = Local function for R_InitSprites
81 void R_InstallSpriteLump (int lump, unsigned frame, unsigned rotation, boolean flipped)
85 if (frame >= 30 || rotation > 8)
86 I_Error ("R_InstallSpriteLump: Bad frame characters in lump %i", lump);
88 if ((int)frame > maxframe)
93 // the lump should be used for all rotations
94 if (sprtemp[frame].rotate == false)
95 I_Error ("R_InitSprites: Sprite %s frame %c has multip rot=0 lump"
96 , spritename, 'A'+frame);
97 if (sprtemp[frame].rotate == true)
98 I_Error ("R_InitSprites: Sprite %s frame %c has rotations and a rot=0 lump"
99 , spritename, 'A'+frame);
101 sprtemp[frame].rotate = false;
102 for (r=0 ; r<8 ; r++)
104 sprtemp[frame].lump[r] = lump - firstspritelump;
105 sprtemp[frame].flip[r] = (byte)flipped;
110 // the lump is only used for one rotation
111 if (sprtemp[frame].rotate == false)
112 I_Error ("R_InitSprites: Sprite %s frame %c has rotations and a rot=0 lump"
113 , spritename, 'A'+frame);
115 sprtemp[frame].rotate = true;
117 rotation--; // make 0 based
118 if (sprtemp[frame].lump[rotation] != -1)
119 I_Error ("R_InitSprites: Sprite %s : %c : %c has two lumps mapped to it"
120 ,spritename, 'A'+frame, '1'+rotation);
122 sprtemp[frame].lump[rotation] = lump - firstspritelump;
123 sprtemp[frame].flip[rotation] = (byte)flipped;
131 = Pass a null terminated list of sprite names (4 chars exactly) to be used
132 = Builds the sprite rotation matrixes to account for horizontally flipped
133 = sprites. Will report an error if the lumps are inconsistant
135 Only called at startup
137 = Sprite lump names are 4 characters for the actor, a letter for the frame,
138 = and a number for the rotation, A sprite that is flippable will have an
139 = additional letter/number appended. The rotation character can be 0 to
140 = signify no rotations
144 void R_InitSpriteDefs (char **namelist)
147 int i, l, intname, frame, rotation;
150 // count the number of sprite names
152 while (*check != NULL)
154 numsprites = check-namelist;
159 sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL);
161 start = firstspritelump-1;
162 end = lastspritelump+1;
164 // scan all the lump names for each of the names, noting the highest
166 // Just compare 4 characters as ints
167 for (i=0 ; i<numsprites ; i++)
169 spritename = namelist[i];
170 memset (sprtemp,-1, sizeof(sprtemp));
173 intname = *(int *)namelist[i];
176 // scan the lumps, filling in the frames for whatever is found
178 for (l=start+1 ; l<end ; l++)
179 if (*(int *)lumpinfo[l].name == intname)
181 frame = lumpinfo[l].name[4] - 'A';
182 rotation = lumpinfo[l].name[5] - '0';
183 R_InstallSpriteLump (l, frame, rotation, false);
184 if (lumpinfo[l].name[6])
186 frame = lumpinfo[l].name[6] - 'A';
187 rotation = lumpinfo[l].name[7] - '0';
188 R_InstallSpriteLump (l, frame, rotation, true);
193 // check the frames that were found for completeness
198 sprites[i].numframes = 0;
201 I_Error ("R_InitSprites: No lumps found for sprite %s"
206 for (frame = 0 ; frame < maxframe ; frame++)
208 switch ((int)sprtemp[frame].rotate)
210 case -1: // no rotations were found for that frame at all
211 I_Error ("R_InitSprites: No patches found for %s frame %c"
212 , namelist[i], frame+'A');
213 case 0: // only the first rotation is needed
216 case 1: // must have all 8 frames
217 for (rotation=0 ; rotation<8 ; rotation++)
218 if (sprtemp[frame].lump[rotation] == -1)
219 I_Error ("R_InitSprites: Sprite %s frame %c is missing rotations"
220 , namelist[i], frame+'A');
225 // allocate space for the frames present and copy sprtemp to it
227 sprites[i].numframes = maxframe;
228 sprites[i].spriteframes =
229 Z_Malloc (maxframe * sizeof(spriteframe_t), PU_STATIC, NULL);
230 memcpy (sprites[i].spriteframes, sprtemp, maxframe*sizeof(spriteframe_t));
237 ===============================================================================
241 ===============================================================================
244 vissprite_t vissprites[MAXVISSPRITES], *vissprite_p;
253 = Called at program start
257 void R_InitSprites (char **namelist)
261 for (i=0 ; i<SCREENWIDTH ; i++)
266 R_InitSpriteDefs (namelist);
275 = Called at frame start
279 void R_ClearSprites (void)
281 vissprite_p = vissprites;
293 vissprite_t overflowsprite;
295 vissprite_t *R_NewVisSprite (void)
297 if (vissprite_p == &vissprites[MAXVISSPRITES])
298 return &overflowsprite;
300 return vissprite_p-1;
310 = Used for sprites and masked mid textures
317 fixed_t sprtopscreen;
318 fixed_t sprbotscreen;
320 void R_DrawMaskedColumn (column_t *column, signed int baseclip)
322 int topscreen, bottomscreen;
323 fixed_t basetexturemid;
325 basetexturemid = dc_texturemid;
327 for ( ; column->topdelta != 0xff ; )
329 // calculate unclipped screen coordinates for post
330 topscreen = sprtopscreen + spryscale*column->topdelta;
331 bottomscreen = topscreen + spryscale*column->length;
332 dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS;
333 dc_yh = (bottomscreen-1)>>FRACBITS;
335 if (dc_yh >= mfloorclip[dc_x])
336 dc_yh = mfloorclip[dc_x]-1;
337 if (dc_yl <= mceilingclip[dc_x])
338 dc_yl = mceilingclip[dc_x]+1;
340 if(dc_yh >= baseclip && baseclip != -1)
345 dc_source = (byte *)column + 3;
346 dc_texturemid = basetexturemid - (column->topdelta<<FRACBITS);
347 // dc_source = (byte *)column + 3 - column->topdelta;
348 colfunc (); // either R_DrawColumn or R_DrawFuzzColumn
350 column = (column_t *)( (byte *)column + column->length + 4);
353 dc_texturemid = basetexturemid;
362 = mfloorclip and mceilingclip should also be set
366 void R_DrawVisSprite (vissprite_t *vis, int x1, int x2)
375 patch = W_CacheLumpNum(vis->patch+firstspritelump, PU_CACHE);
377 dc_colormap = vis->colormap;
380 // colfunc = fuzzcolfunc; // NULL colormap = shadow draw
382 if(vis->mobjflags&(MF_SHADOW|MF_ALTSHADOW))
384 if(vis->mobjflags&MF_TRANSLATION)
386 colfunc = R_DrawTranslatedFuzzColumn;
387 dc_translation = translationtables-256
388 +vis->class*((MAXPLAYERS-1)*256)+
389 ((vis->mobjflags&MF_TRANSLATION)>>(MF_TRANSSHIFT-8));
391 else if(vis->mobjflags&MF_SHADOW)
392 { // Draw using shadow column function
393 colfunc = fuzzcolfunc;
397 colfunc = R_DrawAltFuzzColumn;
400 else if(vis->mobjflags&MF_TRANSLATION)
402 // Draw using translated column function
403 colfunc = R_DrawTranslatedColumn;
404 dc_translation = translationtables-256
405 +vis->class*((MAXPLAYERS-1)*256)+
406 ((vis->mobjflags&MF_TRANSLATION)>>(MF_TRANSSHIFT-8));
409 dc_iscale = abs(vis->xiscale)>>detailshift;
410 dc_texturemid = vis->texturemid;
411 frac = vis->startfrac;
412 spryscale = vis->scale;
414 sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale);
416 // check to see if vissprite is a weapon
419 dc_texturemid += FixedMul(((centery-viewheight/2)<<FRACBITS),
421 sprtopscreen += (viewheight/2-centery)<<FRACBITS;
424 if(vis->floorclip && !vis->psprite)
426 sprbotscreen = sprtopscreen+FixedMul(patch->height<<FRACBITS,
428 baseclip = (sprbotscreen-FixedMul(vis->floorclip,
429 spryscale))>>FRACBITS;
436 for (dc_x=vis->x1 ; dc_x<=vis->x2 ; dc_x++, frac += vis->xiscale)
438 texturecolumn = frac>>FRACBITS;
440 if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
441 I_Error ("R_DrawSpriteRange: bad texturecolumn");
443 column = (column_t *) ((byte *)patch +
444 LONG(patch->columnofs[texturecolumn]));
445 R_DrawMaskedColumn (column, baseclip);
448 colfunc = basecolfunc;
459 = Generates a vissprite for a thing if it might be visible
464 void R_ProjectSprite (mobj_t *thing)
472 spriteframe_t *sprframe;
485 float sinrv, cosrv, thangle; // rv = real value
488 if(thing->flags2&MF2_DONTDRAW)
489 { // Never make a vissprite when MF2_DONTDRAW is flagged.
494 // transform the origin point
496 trx = thing->x - viewx;
497 try = thing->y - viewy;
499 gxt = FixedMul(trx,viewcos);
500 gyt = -FixedMul(try,viewsin);
505 tz = -tz; // Make it positive. The clipper will handle backside.
510 return; // thing is behind view plane
512 xscale = FixedDiv(projection, tz);
514 gxt = -FixedMul(trx,viewsin);
515 gyt = FixedMul(try,viewcos);
520 return; // too far off the side
524 // decide which patch to use for sprite reletive to player
527 if ((unsigned)thing->sprite >= numsprites)
528 I_Error ("R_ProjectSprite: invalid sprite number %i ",thing->sprite);
530 sprdef = &sprites[thing->sprite];
532 if ( (thing->frame&FF_FRAMEMASK) >= sprdef->numframes )
533 I_Error ("R_ProjectSprite: invalid sprite frame %i : %i "
534 ,thing->sprite, thing->frame);
536 sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK];
538 if (sprframe->rotate)
539 { // choose a different rotation based on player view
540 ang = R_PointToAngle (thing->x, thing->y);
541 rot = (ang-thing->angle+(unsigned)(ANG45/2)*9)>>29;
542 lump = sprframe->lump[rot];
543 flip = (boolean)sprframe->flip[rot];
546 { // use single rotation for all views
547 lump = sprframe->lump[0];
548 flip = (boolean)sprframe->flip[0];
552 // calculate edges of the shape
555 v1[VX] = FIX2FLT(thing->x);
556 v1[VY] = FIX2FLT(thing->y);
557 //thangle = BANG2RAD(bamsAtan2((v1[VY]-FIX2FLT(viewy))*10,
558 //(v1[VX]-FIX2FLT(viewx))*10)) - PI/2;
559 thangle = BANG2RAD(bamsAtan2(FIX2FLT(try)*10, FIX2FLT(trx)*10)) - PI/2;
560 sinrv = sin(thangle);
561 cosrv = cos(thangle);
562 v1[VX] -= cosrv*(spriteoffset[lump]>>FRACBITS);
563 v1[VY] -= sinrv*(spriteoffset[lump]>>FRACBITS);
564 v2[VX] = v1[VX] + cosrv*(spritewidth[lump]>>FRACBITS);
565 v2[VY] = v1[VY] + sinrv*(spritewidth[lump]>>FRACBITS);
567 // Check for visibility.
568 if(!C_CheckViewRelSeg(v1[VX], v1[VY], v2[VX], v2[VY]))
569 //if(!C_IsAngleVisible(RAD2BANG(thangle+PI/2)))
570 return; // Isn't visible.
572 tx -= spriteoffset[lump];
573 x1 = (centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS;
575 return; // off the right side
576 tx += spritewidth[lump];
577 x2 = ((centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS) - 1;
579 return; // off the left side
584 // store information in a vissprite
586 vis = R_NewVisSprite ();
587 vis->mobjflags = thing->flags;
588 vis->psprite = false;
589 vis->scale = xscale<<detailshift;
593 vis->gzt = thing->z + spritetopoffset[lump];
596 vis->secfloor = FIX2FLT(thing->subsector->sector->floorheight);
597 vis->secceil = FIX2FLT(thing->subsector->sector->ceilingheight);
600 if(thing->flags&MF_TRANSLATION)
604 vis->class = thing->player->class;
608 vis->class = thing->special1;
616 vis->floorclip = thing->floorclip;
617 vis->texturemid = vis->gzt-viewz-vis->floorclip;
620 // The start and end vertices.
621 vis->v1[VX] = v1[VX];
622 vis->v1[VY] = v1[VY];
623 vis->v2[VX] = v2[VX];
624 vis->v2[VY] = v2[VY];
627 vis->x1 = x1 < 0 ? 0 : x1;
628 vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
629 iscale = FixedDiv (FRACUNIT, xscale);
632 vis->startfrac = spritewidth[lump]-1;
633 vis->xiscale = -iscale;
638 vis->xiscale = iscale;
641 vis->startfrac += vis->xiscale*(vis->x1-x1);
647 // if (thing->flags & MF_SHADOW)
648 // vis->colormap = NULL; // shadow draw
652 if( thing->frame & FF_FULLBRIGHT )
654 vis->lightlevel = -1;
657 { // diminished light
658 vis->lightlevel = thing->subsector->sector->lightlevel;
662 vis->colormap = fixedcolormap; // fixed map
663 else if(LevelUseFullBright && thing->frame&FF_FULLBRIGHT)
664 vis->colormap = colormaps; // full bright
666 { // diminished light
667 index = xscale>>(LIGHTSCALESHIFT-detailshift);
668 if (index >= MAXLIGHTSCALE)
669 index = MAXLIGHTSCALE-1;
670 vis->colormap = spritelights[index];
679 ========================
683 ========================
686 void R_AddSprites (sector_t *sec)
691 if (sec->validcount == validcount)
692 return; // already added
694 sec->validcount = validcount;
696 lightnum = (sec->lightlevel >> LIGHTSEGSHIFT)+extralight;
698 spritelights = scalelight[0];
699 else if (lightnum >= LIGHTLEVELS)
700 spritelights = scalelight[LIGHTLEVELS-1];
702 spritelights = scalelight[lightnum];
705 for (thing = sec->thinglist ; thing ; thing = thing->snext)
706 R_ProjectSprite (thing);
711 ========================
715 ========================
718 // Y-adjustment values for full screen (4 weapons)
719 int PSpriteSY[NUMCLASSES][NUMWEAPONS] =
721 { 0, -12*FRACUNIT, -10*FRACUNIT, 10*FRACUNIT }, // Fighter
722 { -8*FRACUNIT, 10*FRACUNIT, 10*FRACUNIT, 0 }, // Cleric
723 { 9*FRACUNIT, 20*FRACUNIT, 20*FRACUNIT, 20*FRACUNIT }, // Mage
724 { 10*FRACUNIT, 10*FRACUNIT, 10*FRACUNIT, 10*FRACUNIT } // Pig
727 void R_DrawPSprite (pspdef_t *psp)
735 spriteframe_t *sprframe;
742 vissprite_t *vis, avis;
748 // decide which patch to use
751 if ( (unsigned)psp->state->sprite >= numsprites)
752 I_Error ("R_ProjectSprite: invalid sprite number %i "
753 , psp->state->sprite);
755 sprdef = &sprites[psp->state->sprite];
757 if ( (psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes)
758 I_Error ("R_ProjectSprite: invalid sprite frame %i : %i "
759 , psp->state->sprite, psp->state->frame);
761 sprframe = &sprdef->spriteframes[ psp->state->frame & FF_FRAMEMASK ];
763 lump = sprframe->lump[0];
764 flip = (boolean)sprframe->flip[0];
767 // calculate edges of the shape
769 tx = psp->sx-160*FRACUNIT;
771 tx -= spriteoffset[lump];
774 tempangle = ((centerxfrac/1024)*(viewangleoffset>>ANGLETOFINESHIFT));
780 x1 = (centerxfrac + FixedMul (tx,pspritescale)+tempangle ) >>FRACBITS;
783 // Set the OpenGL color & alpha.
786 if( viewplayer->powers[pw_invulnerability] &&
787 viewplayer->class == PCLASS_CLERIC )
789 //vis->colormap = spritelights[MAXLIGHTSCALE-1];
790 if(viewplayer->powers[pw_invulnerability] > 4*32)
792 if(viewplayer->mo->flags2&MF2_DONTDRAW)
793 { // don't draw the psprite
794 //vis->mobjflags |= MF_SHADOW;
797 else if(viewplayer->mo->flags&MF_SHADOW)
799 //vis->mobjflags |= MF_ALTSHADOW;
803 else if(viewplayer->powers[pw_invulnerability]&8)
805 //vis->mobjflags |= MF_SHADOW;
809 else if(fixedcolormap)
812 //vis->colormap = fixedcolormap;
815 else if(psp->state->frame & FF_FULLBRIGHT)
818 //vis->colormap = colormaps;
824 //vis->colormap = spritelights[MAXLIGHTSCALE-1];
825 light = viewplayer->mo->subsector->sector->lightlevel / 255.0;
828 // do some OpenGL rendering, oh yeah
830 y = -(spritetopoffset[lump]>>FRACBITS)+(psp->sy>>FRACBITS);
831 if(viewheight == SCREENHEIGHT)
833 y += PSpriteSY[viewplayer->class][players[consoleplayer].readyweapon]
839 light += .1f; // Add some extra light.
840 OGL_SetColorAndAlpha(light, light, light, alpha);
841 OGL_DrawPSprite(x1, y, 1, flip, lump);
846 return; // off the right side
847 tx += spritewidth[lump];
848 x2 = ((centerxfrac + FixedMul (tx, pspritescale)+tempangle ) >>FRACBITS) - 1;
850 return; // off the left side
853 // store information in a vissprite
859 vis->texturemid = (BASEYCENTER<<FRACBITS)+FRACUNIT/2
860 -(psp->sy-spritetopoffset[lump]);
861 if(viewheight == SCREENHEIGHT)
863 vis->texturemid -= PSpriteSY[viewplayer->class]
864 [players[consoleplayer].readyweapon];
866 vis->x1 = x1 < 0 ? 0 : x1;
867 vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
868 vis->scale = pspritescale<<detailshift;
871 vis->xiscale = -pspriteiscale;
872 vis->startfrac = spritewidth[lump]-1;
876 vis->xiscale = pspriteiscale;
880 vis->startfrac += vis->xiscale*(vis->x1-x1);
883 if(viewplayer->powers[pw_invulnerability] && viewplayer->class
886 vis->colormap = spritelights[MAXLIGHTSCALE-1];
887 if(viewplayer->powers[pw_invulnerability] > 4*32)
889 if(viewplayer->mo->flags2&MF2_DONTDRAW)
890 { // don't draw the psprite
891 vis->mobjflags |= MF_SHADOW;
893 else if(viewplayer->mo->flags&MF_SHADOW)
895 vis->mobjflags |= MF_ALTSHADOW;
898 else if(viewplayer->powers[pw_invulnerability]&8)
900 vis->mobjflags |= MF_SHADOW;
903 else if(fixedcolormap)
906 vis->colormap = fixedcolormap;
908 else if(psp->state->frame & FF_FULLBRIGHT)
911 vis->colormap = colormaps;
916 vis->colormap = spritelights[MAXLIGHTSCALE-1];
918 R_DrawVisSprite(vis, vis->x1, vis->x2);
923 ========================
925 = R_DrawPlayerSprites
927 ========================
930 void R_DrawPlayerSprites (void)
938 lightnum = (viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT)
941 spritelights = scalelight[0];
942 else if (lightnum >= LIGHTLEVELS)
943 spritelights = scalelight[LIGHTLEVELS-1];
945 spritelights = scalelight[lightnum];
947 // clip to screen bounds
950 mfloorclip = screenheightarray;
951 mceilingclip = negonearray;
955 // add all active psprites
957 for (i=0, psp=viewplayer->psprites ; i<NUMPSPRITES ; i++,psp++)
965 ========================
969 ========================
972 vissprite_t vsprsortedhead;
974 void R_SortVisSprites (void)
977 vissprite_t *ds, *best;
978 vissprite_t unsorted;
981 count = vissprite_p - vissprites;
983 unsorted.next = unsorted.prev = &unsorted;
987 for (ds=vissprites ; ds<vissprite_p ; ds++)
992 vissprites[0].prev = &unsorted;
993 unsorted.next = &vissprites[0];
994 (vissprite_p-1)->next = &unsorted;
995 unsorted.prev = vissprite_p-1;
998 // pull the vissprites out by scale
1000 best = 0; // shut up the compiler warning
1001 vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead;
1002 for (i=0 ; i<count ; i++)
1005 for (ds=unsorted.next ; ds!= &unsorted ; ds=ds->next)
1007 if (ds->scale < bestscale)
1009 bestscale = ds->scale;
1013 best->next->prev = best->prev;
1014 best->prev->next = best->next;
1015 best->next = &vsprsortedhead;
1016 best->prev = vsprsortedhead.prev;
1017 vsprsortedhead.prev->next = best;
1018 vsprsortedhead.prev = best;
1026 ========================
1030 ========================
1033 void R_DrawSprite (vissprite_t *spr)
1036 short clipbot[SCREENWIDTH], cliptop[SCREENWIDTH];
1038 fixed_t scale, lowscale;
1041 for (x = spr->x1 ; x<=spr->x2 ; x++)
1042 clipbot[x] = cliptop[x] = -2;
1045 // scan drawsegs from end to start for obscuring segs
1046 // the first drawseg that has a greater scale is the clip seg
1048 for (ds=ds_p-1 ; ds >= drawsegs ; ds--)
1051 // determine if the drawseg obscures the sprite
1053 if (ds->x1 > spr->x2 || ds->x2 < spr->x1 ||
1054 (!ds->silhouette && !ds->maskedtexturecol) )
1055 continue; // doesn't cover sprite
1057 r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1;
1058 r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2;
1059 if (ds->scale1 > ds->scale2)
1061 lowscale = ds->scale2;
1066 lowscale = ds->scale1;
1070 if (scale < spr->scale || ( lowscale < spr->scale
1071 && !R_PointOnSegSide (spr->gx, spr->gy, ds->curline) ) )
1073 if (ds->maskedtexturecol) // masked mid texture
1074 R_RenderMaskedSegRange (ds, r1, r2);
1075 continue; // seg is behind sprite
1079 // clip this piece of the sprite
1081 silhouette = ds->silhouette;
1082 if (spr->gz >= ds->bsilheight)
1083 silhouette &= ~SIL_BOTTOM;
1084 if (spr->gzt <= ds->tsilheight)
1085 silhouette &= ~SIL_TOP;
1087 if (silhouette == 1)
1089 for (x=r1 ; x<=r2 ; x++)
1090 if (clipbot[x] == -2)
1091 clipbot[x] = ds->sprbottomclip[x];
1093 else if (silhouette == 2)
1095 for (x=r1 ; x<=r2 ; x++)
1096 if (cliptop[x] == -2)
1097 cliptop[x] = ds->sprtopclip[x];
1099 else if (silhouette == 3)
1101 for (x=r1 ; x<=r2 ; x++)
1103 if (clipbot[x] == -2)
1104 clipbot[x] = ds->sprbottomclip[x];
1105 if (cliptop[x] == -2)
1106 cliptop[x] = ds->sprtopclip[x];
1113 // all clipping has been performed, so draw the sprite
1116 // check for unclipped columns
1117 for (x = spr->x1 ; x<=spr->x2 ; x++)
1119 if (clipbot[x] == -2)
1120 clipbot[x] = viewheight;
1121 if (cliptop[x] == -2)
1125 mfloorclip = clipbot;
1126 mceilingclip = cliptop;
1127 R_DrawVisSprite (spr, spr->x1, spr->x2);
1133 ========================
1137 ========================
1140 void R_DrawMasked (void)
1145 extern boolean willRenderSprites;
1147 if( willRenderSprites )
1151 if( vissprite_p > vissprites )
1153 // draw all vissprites back to front
1154 glDepthMask(GL_FALSE);
1156 for( spr = vsprsortedhead.next; spr != &vsprsortedhead;
1159 //R_DrawSprite (spr);
1160 R_RenderSprite(spr);
1163 glDepthMask(GL_TRUE);
1169 R_SortVisSprites ();
1171 if (vissprite_p > vissprites)
1173 // draw all vissprites back to front
1175 for (spr = vsprsortedhead.next ; spr != &vsprsortedhead
1181 // render any remaining masked mid textures
1183 for (ds=ds_p-1 ; ds >= drawsegs ; ds--)
1184 if (ds->maskedtexturecol)
1185 R_RenderMaskedSegRange (ds, ds->x1, ds->x2);
1188 // draw the psprites on top of everything
1190 // Added for the sideviewing with an external device
1191 if (viewangleoffset <= 1024<<ANGLETOFINESHIFT || viewangleoffset >=
1192 -1024<<ANGLETOFINESHIFT)
1193 { // don't draw on side views
1194 R_DrawPlayerSprites ();
1197 // if (!viewangleoffset) // don't draw on side views
1198 // R_DrawPlayerSprites ();