Merge branch 'sprite-projection-fixes' into 'next'
Sprite projection fixes See merge request STJr/SRB2!954
This commit is contained in:
commit
7722d41be6
|
@ -1346,7 +1346,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
{
|
{
|
||||||
mobj_t *oldthing = thing;
|
mobj_t *oldthing = thing;
|
||||||
fixed_t tr_x, tr_y;
|
fixed_t tr_x, tr_y;
|
||||||
fixed_t gxt, gyt;
|
|
||||||
fixed_t tx, tz;
|
fixed_t tx, tz;
|
||||||
fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!!
|
fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!!
|
||||||
|
|
||||||
|
@ -1359,7 +1358,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
#endif
|
#endif
|
||||||
size_t lump;
|
size_t lump;
|
||||||
|
|
||||||
size_t rot;
|
size_t frame, rot;
|
||||||
UINT16 flip;
|
UINT16 flip;
|
||||||
boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP));
|
boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP));
|
||||||
|
|
||||||
|
@ -1399,21 +1398,16 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
tr_x = thing->x - viewx;
|
tr_x = thing->x - viewx;
|
||||||
tr_y = thing->y - viewy;
|
tr_y = thing->y - viewy;
|
||||||
|
|
||||||
gxt = FixedMul(tr_x, viewcos);
|
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance
|
||||||
gyt = -FixedMul(tr_y, viewsin);
|
|
||||||
|
|
||||||
tz = gxt-gyt;
|
|
||||||
|
|
||||||
// thing is behind view plane?
|
// thing is behind view plane?
|
||||||
if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later
|
if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gxt = -FixedMul(tr_x, viewsin);
|
basetx = tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance
|
||||||
gyt = FixedMul(tr_y, viewcos);
|
|
||||||
basetx = tx = -(gyt + gxt);
|
|
||||||
|
|
||||||
// too far off the side?
|
// too far off the side?
|
||||||
if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later
|
if (!papersprite && abs(tx) > FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// aspect ratio stuff
|
// aspect ratio stuff
|
||||||
|
@ -1426,7 +1420,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
I_Error("R_ProjectSprite: invalid sprite number %d ", thing->sprite);
|
I_Error("R_ProjectSprite: invalid sprite number %d ", thing->sprite);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rot = thing->frame&FF_FRAMEMASK;
|
frame = thing->frame&FF_FRAMEMASK;
|
||||||
|
|
||||||
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
|
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
|
||||||
if (thing->skin && thing->sprite == SPR_PLAY)
|
if (thing->skin && thing->sprite == SPR_PLAY)
|
||||||
|
@ -1435,15 +1429,15 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2];
|
sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2];
|
||||||
#endif
|
#endif
|
||||||
if (rot >= sprdef->numframes) {
|
if (frame >= sprdef->numframes) {
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid skins[\"%s\"].sprites[%sSPR2_%s] frame %s\n"), ((skin_t *)thing->skin)->name, ((thing->sprite2 & FF_SPR2SUPER) ? "FF_SPR2SUPER|": ""), spr2names[(thing->sprite2 & ~FF_SPR2SUPER)], sizeu5(rot));
|
CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid skins[\"%s\"].sprites[%sSPR2_%s] frame %s\n"), ((skin_t *)thing->skin)->name, ((thing->sprite2 & FF_SPR2SUPER) ? "FF_SPR2SUPER|": ""), spr2names[(thing->sprite2 & ~FF_SPR2SUPER)], sizeu5(frame));
|
||||||
thing->sprite = states[S_UNKNOWN].sprite;
|
thing->sprite = states[S_UNKNOWN].sprite;
|
||||||
thing->frame = states[S_UNKNOWN].frame;
|
thing->frame = states[S_UNKNOWN].frame;
|
||||||
sprdef = &sprites[thing->sprite];
|
sprdef = &sprites[thing->sprite];
|
||||||
#ifdef ROTSPRITE
|
#ifdef ROTSPRITE
|
||||||
sprinfo = NULL;
|
sprinfo = NULL;
|
||||||
#endif
|
#endif
|
||||||
rot = thing->frame&FF_FRAMEMASK;
|
frame = thing->frame&FF_FRAMEMASK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1453,10 +1447,10 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
sprinfo = NULL;
|
sprinfo = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (rot >= sprdef->numframes)
|
if (frame >= sprdef->numframes)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid sprite frame %s/%s for %s\n"),
|
CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid sprite frame %s/%s for %s\n"),
|
||||||
sizeu1(rot), sizeu2(sprdef->numframes), sprnames[thing->sprite]);
|
sizeu1(frame), sizeu2(sprdef->numframes), sprnames[thing->sprite]);
|
||||||
if (thing->sprite == thing->state->sprite && thing->frame == thing->state->frame)
|
if (thing->sprite == thing->state->sprite && thing->frame == thing->state->frame)
|
||||||
{
|
{
|
||||||
thing->state->sprite = states[S_UNKNOWN].sprite;
|
thing->state->sprite = states[S_UNKNOWN].sprite;
|
||||||
|
@ -1465,11 +1459,11 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
thing->sprite = states[S_UNKNOWN].sprite;
|
thing->sprite = states[S_UNKNOWN].sprite;
|
||||||
thing->frame = states[S_UNKNOWN].frame;
|
thing->frame = states[S_UNKNOWN].frame;
|
||||||
sprdef = &sprites[thing->sprite];
|
sprdef = &sprites[thing->sprite];
|
||||||
rot = thing->frame&FF_FRAMEMASK;
|
frame = thing->frame&FF_FRAMEMASK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprframe = &sprdef->spriteframes[rot];
|
sprframe = &sprdef->spriteframes[frame];
|
||||||
|
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
if (!sprframe)
|
if (!sprframe)
|
||||||
|
@ -1523,7 +1517,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
{
|
{
|
||||||
rollangle = R_GetRollAngle(thing->rollangle);
|
rollangle = R_GetRollAngle(thing->rollangle);
|
||||||
if (!(sprframe->rotsprite.cached & (1<<rot)))
|
if (!(sprframe->rotsprite.cached & (1<<rot)))
|
||||||
R_CacheRotSprite(thing->sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip);
|
R_CacheRotSprite(thing->sprite, frame, sprinfo, sprframe, rot, flip);
|
||||||
rotsprite = sprframe->rotsprite.patch[rot][rollangle];
|
rotsprite = sprframe->rotsprite.patch[rot][rollangle];
|
||||||
if (rotsprite != NULL)
|
if (rotsprite != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1561,17 +1555,9 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
tr_x += FixedMul(offset, cosmul);
|
tr_x += FixedMul(offset, cosmul);
|
||||||
tr_y += FixedMul(offset, sinmul);
|
tr_y += FixedMul(offset, sinmul);
|
||||||
gxt = FixedMul(tr_x, viewcos);
|
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
|
||||||
gyt = -FixedMul(tr_y, viewsin);
|
|
||||||
tz = gxt-gyt;
|
|
||||||
yscale = FixedDiv(projectiony, tz);
|
|
||||||
//if (yscale < 64) return; // Fix some funky visuals
|
|
||||||
|
|
||||||
gxt = -FixedMul(tr_x, viewsin);
|
tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
|
||||||
gyt = FixedMul(tr_y, viewcos);
|
|
||||||
tx = -(gyt + gxt);
|
|
||||||
xscale = FixedDiv(projection, tz);
|
|
||||||
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
|
||||||
|
|
||||||
// Get paperoffset (offset) and paperoffset (distance)
|
// Get paperoffset (offset) and paperoffset (distance)
|
||||||
paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul);
|
paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul);
|
||||||
|
@ -1585,17 +1571,9 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
tr_x += FixedMul(offset2, cosmul);
|
tr_x += FixedMul(offset2, cosmul);
|
||||||
tr_y += FixedMul(offset2, sinmul);
|
tr_y += FixedMul(offset2, sinmul);
|
||||||
gxt = FixedMul(tr_x, viewcos);
|
tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
|
||||||
gyt = -FixedMul(tr_y, viewsin);
|
|
||||||
tz2 = gxt-gyt;
|
|
||||||
yscale2 = FixedDiv(projectiony, tz2);
|
|
||||||
//if (yscale2 < 64) return; // ditto
|
|
||||||
|
|
||||||
gxt = -FixedMul(tr_x, viewsin);
|
tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
|
||||||
gyt = FixedMul(tr_y, viewcos);
|
|
||||||
tx2 = -(gyt + gxt);
|
|
||||||
xscale2 = FixedDiv(projection, tz2);
|
|
||||||
x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS);
|
|
||||||
|
|
||||||
if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier
|
if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier
|
||||||
return;
|
return;
|
||||||
|
@ -1606,24 +1584,31 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz);
|
fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz);
|
||||||
tx += FixedDiv(tx2-tx, div);
|
tx += FixedDiv(tx2-tx, div);
|
||||||
tz = FixedMul(MINZ, this_scale);
|
tz = FixedMul(MINZ, this_scale);
|
||||||
yscale = FixedDiv(projectiony, tz);
|
|
||||||
xscale = FixedDiv(projection, tz);
|
|
||||||
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
|
||||||
}
|
}
|
||||||
else if (tz2 < FixedMul(MINZ, this_scale))
|
else if (tz2 < FixedMul(MINZ, this_scale))
|
||||||
{
|
{
|
||||||
fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2);
|
fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2);
|
||||||
tx2 += FixedDiv(tx-tx2, div);
|
tx2 += FixedDiv(tx-tx2, div);
|
||||||
tz2 = FixedMul(MINZ, this_scale);
|
tz2 = FixedMul(MINZ, this_scale);
|
||||||
yscale2 = FixedDiv(projectiony, tz2);
|
|
||||||
xscale2 = FixedDiv(projection, tz2);
|
|
||||||
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side?
|
||||||
|
return;
|
||||||
|
|
||||||
|
yscale = FixedDiv(projectiony, tz);
|
||||||
|
xscale = FixedDiv(projection, tz);
|
||||||
|
|
||||||
|
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
||||||
|
|
||||||
// off the right side?
|
// off the right side?
|
||||||
if (x1 > viewwidth)
|
if (x1 > viewwidth)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
yscale2 = FixedDiv(projectiony, tz2);
|
||||||
|
xscale2 = FixedDiv(projection, tz2);
|
||||||
|
|
||||||
|
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
|
||||||
|
|
||||||
// off the left side
|
// off the left side
|
||||||
if (x2 < 0)
|
if (x2 < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -1670,9 +1655,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
tr_x = thing->x - viewx;
|
tr_x = thing->x - viewx;
|
||||||
tr_y = thing->y - viewy;
|
tr_y = thing->y - viewy;
|
||||||
gxt = FixedMul(tr_x, viewcos);
|
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
|
||||||
gyt = -FixedMul(tr_y, viewsin);
|
|
||||||
tz = gxt-gyt;
|
|
||||||
linkscale = FixedDiv(projectiony, tz);
|
linkscale = FixedDiv(projectiony, tz);
|
||||||
|
|
||||||
if (tz < FixedMul(MINZ, this_scale))
|
if (tz < FixedMul(MINZ, this_scale))
|
||||||
|
@ -1872,7 +1855,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||||
{
|
{
|
||||||
fixed_t tr_x, tr_y;
|
fixed_t tr_x, tr_y;
|
||||||
fixed_t gxt, gyt;
|
|
||||||
fixed_t tx, tz;
|
fixed_t tx, tz;
|
||||||
fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!!
|
fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!!
|
||||||
|
|
||||||
|
@ -1893,21 +1875,16 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||||
tr_x = thing->x - viewx;
|
tr_x = thing->x - viewx;
|
||||||
tr_y = thing->y - viewy;
|
tr_y = thing->y - viewy;
|
||||||
|
|
||||||
gxt = FixedMul(tr_x, viewcos);
|
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance
|
||||||
gyt = -FixedMul(tr_y, viewsin);
|
|
||||||
|
|
||||||
tz = gxt - gyt;
|
|
||||||
|
|
||||||
// thing is behind view plane?
|
// thing is behind view plane?
|
||||||
if (tz < MINZ)
|
if (tz < MINZ)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gxt = -FixedMul(tr_x, viewsin);
|
tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance
|
||||||
gyt = FixedMul(tr_y, viewcos);
|
|
||||||
tx = -(gyt + gxt);
|
|
||||||
|
|
||||||
// too far off the side?
|
// too far off the side?
|
||||||
if (abs(tx) > tz<<2)
|
if (abs(tx) > FixedMul(tz, fovtan)<<2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// aspect ratio stuff :
|
// aspect ratio stuff :
|
||||||
|
|
Loading…
Reference in New Issue