- all repeats in SW’s draw code

This commit is contained in:
Christoph Oelckers 2022-10-07 19:44:37 +02:00
parent 509d56d042
commit abf5c9feee
2 changed files with 26 additions and 37 deletions

View file

@ -526,7 +526,7 @@ struct spritetypebase
yrepeat = uint8_t(yrepeat * y); yrepeat = uint8_t(yrepeat * y);
} }
void CopyScale(spritetypebase* other) void CopyScale(const spritetypebase* other)
{ {
xrepeat = other->xrepeat; xrepeat = other->xrepeat;
yrepeat = other->yrepeat; yrepeat = other->yrepeat;

View file

@ -283,8 +283,8 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, double viewz)
int ground_dist = 0; int ground_dist = 0;
int view_dist = 0; int view_dist = 0;
double loz; double loz;
int xrepeat; DVector2 scale;
int yrepeat;
if (!ownerActor->hasU()) return; if (!ownerActor->hasU()) return;
@ -300,16 +300,15 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, double viewz)
tsp->sectp = sect; tsp->sectp = sect;
if ((tsp->yrepeat >> 2) > 4) if (tsp->ScaleY() > 0.25)
{ {
int sizey = MulScale(tileHeight(tsp->picnum), tsp->yrepeat, 6); double sizey = tileHeight(tsp->picnum) * tsp->ScaleY();
yrepeat = (tsp->yrepeat >> 2) - (sizey / 64) * 2; scale.Y = (tsp->ScaleY() * 0.25) - (sizey / 2048.);
xrepeat = tsp->xrepeat; scale.X = tsp->ScaleX();
} }
else else
{ {
yrepeat = tsp->yrepeat; scale = tsp->Scale();
xrepeat = tsp->xrepeat;
} }
loz = ownerActor->user.loz; loz = ownerActor->user.loz;
@ -347,13 +346,10 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, double viewz)
// make shadow smaller depending on height from ground // make shadow smaller depending on height from ground
ground_dist = int(abs(loz - GetSpriteZOfBottom(tsp)) * (1./16)); ground_dist = int(abs(loz - GetSpriteZOfBottom(tsp)) * (1./16));
xrepeat = max(xrepeat - ground_dist - view_dist, 4); double scaleofs = (ground_dist - view_dist) * REPEAT_SCALE;
yrepeat = max(yrepeat - ground_dist - view_dist, 4); scale.X = clamp(scale.X + scaleofs, 0.0625, 4.);
xrepeat = min(xrepeat, 255); scale.Y = clamp(scale.Y + scaleofs, 0.0625, 4.);
yrepeat = min(yrepeat, 255); tSpr->SetScale(scale);
tSpr->xrepeat = uint8_t(xrepeat);
tSpr->yrepeat = uint8_t(yrepeat);
if (tilehasmodelorvoxel(tsp->picnum,tsp->pal)) if (tilehasmodelorvoxel(tsp->picnum,tsp->pal))
{ {
@ -385,7 +381,8 @@ void DoMotionBlur(tspriteArray& tsprites, tspritetype const * const tsp)
auto ownerActor = static_cast<DSWActor*>(tsp->ownerActor); auto ownerActor = static_cast<DSWActor*>(tsp->ownerActor);
DVector3 npos(0, 0, 0), dpos(0, 0, 0); DVector3 npos(0, 0, 0), dpos(0, 0, 0);
int i; int i;
int xrepeat, yrepeat, repeat_adj = 0; double repeat_adj = 0;
DVector2 scale;
double z_amt_per_pixel; double z_amt_per_pixel;
auto angle = tsp->angle + DAngle180; auto angle = tsp->angle + DAngle180;
@ -407,8 +404,7 @@ void DoMotionBlur(tspriteArray& tsprites, tspritetype const * const tsp)
dpos.XY() = npos.XY() = angle.ToVector() * ownerActor->user.motion_blur_dist; dpos.XY() = npos.XY() = angle.ToVector() * ownerActor->user.motion_blur_dist;
dpos.Z = npos.Z = z_amt_per_pixel * ownerActor->user.motion_blur_dist * (1./16); dpos.Z = npos.Z = z_amt_per_pixel * ownerActor->user.motion_blur_dist * (1./16);
xrepeat = tsp->xrepeat; scale = tsp->Scale();
yrepeat = tsp->yrepeat;
switch ((ownerActor->user.Flags2 & SPR2_BLUR_TAPER)) switch ((ownerActor->user.Flags2 & SPR2_BLUR_TAPER))
{ {
@ -416,10 +412,10 @@ void DoMotionBlur(tspriteArray& tsprites, tspritetype const * const tsp)
repeat_adj = 0; repeat_adj = 0;
break; break;
case SPR2_BLUR_TAPER_SLOW: case SPR2_BLUR_TAPER_SLOW:
repeat_adj = xrepeat / (ownerActor->user.motion_blur_num*2); repeat_adj = scale.X / (ownerActor->user.motion_blur_num*2);
break; break;
case SPR2_BLUR_TAPER_FAST: case SPR2_BLUR_TAPER_FAST:
repeat_adj = xrepeat / ownerActor->user.motion_blur_num; repeat_adj = scale.X / ownerActor->user.motion_blur_num;
break; break;
} }
@ -432,11 +428,10 @@ void DoMotionBlur(tspriteArray& tsprites, tspritetype const * const tsp)
tSpr->pos += dpos; tSpr->pos += dpos;
dpos += npos; dpos += npos;
tSpr->xrepeat = uint8_t(xrepeat); tSpr->SetScale(scale);
tSpr->yrepeat = uint8_t(yrepeat);
xrepeat -= repeat_adj; scale.X -= repeat_adj;
yrepeat -= repeat_adj; scale.Y -= repeat_adj;
} }
} }
@ -546,8 +541,7 @@ DSWActor* CopySprite(spritetypebase const* tsp, sectortype* newsector)
actorNew->spr.cstat = tsp->cstat; actorNew->spr.cstat = tsp->cstat;
actorNew->spr.picnum = tsp->picnum; actorNew->spr.picnum = tsp->picnum;
actorNew->spr.pal = tsp->pal; actorNew->spr.pal = tsp->pal;
actorNew->spr.xrepeat = tsp->xrepeat; actorNew->spr.CopyScale(tsp);
actorNew->spr.yrepeat = tsp->yrepeat;
actorNew->spr.xoffset = tsp->xoffset; actorNew->spr.xoffset = tsp->xoffset;
actorNew->spr.yoffset = tsp->yoffset; actorNew->spr.yoffset = tsp->yoffset;
actorNew->spr.angle = tsp->angle; actorNew->spr.angle = tsp->angle;
@ -618,7 +612,7 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& viewpos, doub
int newshade=0; int newshade=0;
const int DART_PIC = 2526; const int DART_PIC = 2526;
const int DART_REPEAT = 16; const double DART_REPEAT = 0.25;
ang = NORM_ANGLE(ang + 12); ang = NORM_ANGLE(ang + 12);
@ -686,16 +680,11 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& viewpos, doub
DoShadows(tsprites, tsp, viewpos.Z); DoShadows(tsprites, tsp, viewpos.Z);
} }
//#define UK_VERSION 1
//#define DART_REPEAT 6
//#define DART_PIC 2233
if (sw_darts) if (sw_darts)
if (tActor->user.ID == 1793 || tsp->picnum == 1793) if (tActor->user.ID == 1793 || tsp->picnum == 1793)
{ {
tsp->picnum = 2519; tsp->picnum = 2519;
tsp->xrepeat = 27; tsp->SetScale(0.421875, 0.453125);
tsp->yrepeat = 29;
} }
if (tActor->user.ID == STAR1) if (tActor->user.ID == STAR1)
@ -705,7 +694,7 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& viewpos, doub
tsp->picnum = DART_PIC; tsp->picnum = DART_PIC;
tsp->angle -= DAngle90 + mapangle(24); tsp->angle -= DAngle90 + mapangle(24);
tsp->xrepeat = tsp->yrepeat = DART_REPEAT; tsp->SetScale(DART_REPEAT, DART_REPEAT);
tsp->cstat |= (CSTAT_SPRITE_ALIGNMENT_WALL); tsp->cstat |= (CSTAT_SPRITE_ALIGNMENT_WALL);
} }
else else
@ -769,7 +758,7 @@ static void analyzesprites(tspriteArray& tsprites, const DVector3& viewpos, doub
{ {
tsp->picnum = DART_PIC; tsp->picnum = DART_PIC;
tsp->angle -= DAngle90; tsp->angle -= DAngle90;
tsp->xrepeat = tsp->yrepeat = DART_REPEAT; tsp->SetScale(DART_REPEAT, DART_REPEAT);
tsp->cstat |= (CSTAT_SPRITE_ALIGNMENT_WALL); tsp->cstat |= (CSTAT_SPRITE_ALIGNMENT_WALL);
} }