Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Jan 12, 2017
1 parent f4caf33 commit 55b7a00
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ void R_ProjectSprite(mobj_t *thing)
spritedef_t *sprdef;
spriteframe_t *sprframe;
int lump;
fixed_t width;

dboolean flip;

Expand All @@ -676,7 +677,6 @@ void R_ProjectSprite(mobj_t *thing)
int flags = thing->flags;
int flags2 = thing->flags2;
int frame = thing->frame;
int type = thing->type;

// transform the origin point
fixed_t tr_x;
Expand Down Expand Up @@ -757,6 +757,8 @@ void R_ProjectSprite(mobj_t *thing)
flip = (!!(sprframe->flip & 1) || (flags2 & MF2_MIRRORED));
}

width = spritewidth[lump];

if (thing->state->dehacked)
{
offset = spriteoffset[lump];
Expand All @@ -769,14 +771,14 @@ void R_ProjectSprite(mobj_t *thing)
}

// calculate edges of the shape
tx -= (flip ? spritewidth[lump] - offset : offset);
tx -= (flip ? width - offset : offset);
x1 = (centerxfrac + FRACUNIT / 2 + FixedMul(tx, xscale)) >> FRACBITS;

// off the right side?
if (x1 > viewwidth)
return;

x2 = ((centerxfrac + FRACUNIT / 2 + FixedMul(tx + spritewidth[lump], xscale)) >> FRACBITS) - 1;
x2 = ((centerxfrac + FRACUNIT / 2 + FixedMul(tx + width, xscale)) >> FRACBITS) - 1;

// off the left side
if (x2 < 0)
Expand All @@ -793,6 +795,7 @@ void R_ProjectSprite(mobj_t *thing)
// killough 4/11/98: improve sprite clipping for underwater/fake ceilings
heightsec = sector->heightsec;


if (heightsec != -1) // only clip things which are in special sectors
{
int phs = viewplayer->mo->subsector->sector->heightsec;
Expand All @@ -817,7 +820,7 @@ void R_ProjectSprite(mobj_t *thing)

vis->mobjflags = flags;
vis->mobjflags2 = flags2;
vis->type = type;
vis->type = thing->type;
vis->scale = xscale;
vis->gx = fx;
vis->gy = fy;
Expand Down Expand Up @@ -854,7 +857,7 @@ void R_ProjectSprite(mobj_t *thing)

if (flip)
{
vis->startfrac = spritewidth[lump] - 1;
vis->startfrac = width - 1;
vis->xiscale = -FixedDiv(FRACUNIT, xscale);
}
else
Expand Down Expand Up @@ -980,6 +983,7 @@ void R_ProjectShadow(mobj_t *thing)
spritedef_t *sprdef;
spriteframe_t *sprframe;
int lump;
fixed_t width;

dboolean flip;

Expand Down Expand Up @@ -1052,15 +1056,17 @@ void R_ProjectShadow(mobj_t *thing)
flip = (!!(sprframe->flip & 1) || (thing->flags2 & MF2_MIRRORED));
}

width = spritewidth[lump];

// calculate edges of the shape
tx -= (flip ? spritewidth[lump] - newspriteoffset[lump] : newspriteoffset[lump]);
tx -= (flip ? width - newspriteoffset[lump] : newspriteoffset[lump]);
x1 = (centerxfrac + FRACUNIT / 2 + FixedMul(tx, xscale)) >> FRACBITS;

// off the right side?
if (x1 > viewwidth)
return;

x2 = ((centerxfrac + FRACUNIT / 2 + FixedMul(tx + spritewidth[lump], xscale)) >> FRACBITS) - 1;
x2 = ((centerxfrac + FRACUNIT / 2 + FixedMul(tx + width, xscale)) >> FRACBITS) - 1;

// off the left side
if (x2 < 0)
Expand All @@ -1084,7 +1090,7 @@ void R_ProjectShadow(mobj_t *thing)

if (flip)
{
vis->startfrac = spritewidth[lump] - 1;
vis->startfrac = width - 1;
vis->xiscale = -FixedDiv(FRACUNIT, xscale);
}
else
Expand Down

0 comments on commit 55b7a00

Please sign in to comment.