- use a float vector to store the scale.

This commit is contained in:
Christoph Oelckers 2022-10-07 23:18:36 +02:00
parent 2df12e7961
commit 4aa765675e
7 changed files with 20 additions and 38 deletions

View file

@ -510,8 +510,7 @@ DEFINE_FIELD_NAMED(DCoreActor, spr.pal, pal)
DEFINE_FIELD_NAMED(DCoreActor, spr.clipdist, intclipdist)
DEFINE_FIELD_NAMED(DCoreActor, clipdist, clipdist)
DEFINE_FIELD_NAMED(DCoreActor, spr.blend, blend)
DEFINE_FIELD_NAMED(DCoreActor, spr.xrepeat, xrepeat)
DEFINE_FIELD_NAMED(DCoreActor, spr.yrepeat, yrepeat)
DEFINE_FIELD_NAMED(DCoreActor, spr.scale, scale)
DEFINE_FIELD_NAMED(DCoreActor, spr.xoffset, xoffset)
DEFINE_FIELD_NAMED(DCoreActor, spr.yoffset, yoffset)
DEFINE_FIELD_NAMED(DCoreActor, spr.intowner, owner)

View file

@ -450,6 +450,7 @@ struct spritetypebase
sectortype* sectp;
DAngle angle;
DVector2 scale;
ESpriteFlags cstat;
int16_t picnum;
@ -468,8 +469,6 @@ struct spritetypebase
uint8_t pal;
uint8_t clipdist;
uint8_t blend;
uint8_t xrepeat;
uint8_t yrepeat;
int8_t xoffset;
int8_t yoffset;
@ -480,71 +479,58 @@ struct spritetypebase
void SetScale(double x, double y)
{
xrepeat = uint8_t(x * scaletoint);
yrepeat = uint8_t(y * scaletoint);
scale = { x, y };
}
void SetScale(const DVector2& p)
{
xrepeat = uint8_t(p.X * scaletoint);
yrepeat = uint8_t(p.Y * scaletoint);
scale = p;
}
void SetScaleX(double x)
{
xrepeat = uint8_t(x * scaletoint);
scale.X = x;
}
void SetScaleY(double y)
{
yrepeat = uint8_t(y * scaletoint);
scale.Y = y;
}
void AddScaleX(double x)
{
xrepeat += uint8_t(x * scaletoint);
scale.X += x;
}
void AddScaleY(double y)
{
yrepeat += uint8_t(y * scaletoint);
scale.Y += y;
}
void MultScale(double x)
{
xrepeat = uint8_t(xrepeat * x);
yrepeat = uint8_t(yrepeat * x);
scale *= x;
}
void MultScaleX(double x)
{
xrepeat = uint8_t(xrepeat * x);
}
void MultScaleY(double y)
{
yrepeat = uint8_t(yrepeat * y);
}
void CopyScale(const spritetypebase* other)
{
xrepeat = other->xrepeat;
yrepeat = other->yrepeat;
scale = other->scale;
}
DVector2 Scale() const
{
return DVector2(ScaleX(), ScaleY());
return scale;
}
double ScaleX() const
{
return xrepeat * inttoscale;
return scale.X;
}
double ScaleY() const
{
return yrepeat * inttoscale;
return scale.Y;
}
};

View file

@ -455,8 +455,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
("pal", c.pal, def->pal)
("clipdist", c.clipdist, def->clipdist)
("blend", c.blend, def->blend)
("xrepeat", c.xrepeat, def->xrepeat)
("yrepeat", c.yrepeat, def->yrepeat)
("xrepeat", c.scale.X, def->scale.X)
("yrepeat", c.scale.Y, def->scale.Y)
("xoffset", c.xoffset, def->xoffset)
("yoffset", c.yoffset, def->yoffset)
("statnum", c.statnum)

View file

@ -96,8 +96,7 @@ DEFINE_FIELD_X(tspritetype, tspritetype, shade)
DEFINE_FIELD_X(tspritetype, tspritetype, pal)
DEFINE_FIELD_X(tspritetype, tspritetype, clipdist)
DEFINE_FIELD_X(tspritetype, tspritetype, blend)
DEFINE_FIELD_X(tspritetype, tspritetype, xrepeat)
DEFINE_FIELD_X(tspritetype, tspritetype, yrepeat)
DEFINE_FIELD_X(tspritetype, tspritetype, scale)
DEFINE_FIELD_X(tspritetype, tspritetype, xoffset)
DEFINE_FIELD_X(tspritetype, tspritetype, yoffset)
DEFINE_FIELD_X(tspritetype, tspritetype, ownerActor)

View file

@ -384,8 +384,8 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
}
pNSprite->shade = 127;
pNSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT;
pNSprite->xrepeat = pTSprite->xrepeat;
pNSprite->yrepeat = pTSprite->yrepeat>>2;
pNSprite->scale.X = pTSprite->scale.X;
pNSprite->scale.Y = pTSprite->scale.Y * 0.25;
pNSprite->picnum = pTSprite->picnum;
if (!VanillaMode() && (pTSprite->type == kThingDroppedLifeLeech)) // fix shadow for thrown lifeleech
pNSprite->picnum = 800;

View file

@ -20,8 +20,7 @@ class CoreActor native
native uint8 pal;
native uint8 intclipdist;
native uint8 blend;
//native uint8 xrepeat;
//native uint8 yrepeat;
native Vector2 scale;
native int8 xoffset;
native int8 yoffset;
native int16 owner;

View file

@ -291,8 +291,7 @@ struct tspritetype native
native uint8 pal;
native uint8 clipdist;
native uint8 blend;
//native uint8 xrepeat;
//native uint8 yrepeat;
native Vector2 scale;
native int8 xoffset;
native int8 yoffset;
native CoreActor ownerActor;