mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 04:20:42 +00:00
- changed the pos vector of spritetype to floating point.
This commit is contained in:
parent
825d94f5a5
commit
02ae6476de
7 changed files with 51 additions and 66 deletions
|
@ -550,7 +550,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, z, coreactor_z)
|
|||
|
||||
void coreactor_setpos(DCoreActor* self, double x, double y, double z, int relink)
|
||||
{
|
||||
self->set_float_pos({ x, y, z });
|
||||
self->spr.pos = { x, y, z };
|
||||
// todo: SW needs to call updatesectorz here or have a separate function.
|
||||
if (relink) SetActor(self, self->int_pos());
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, setpos, coreactor_setpos)
|
|||
void coreactor_copypos(DCoreActor* self, DCoreActor* other, int relink)
|
||||
{
|
||||
if (!other) return;
|
||||
self->copy_pos(other);
|
||||
self->spr.pos = other->spr.pos;
|
||||
// todo: SW needs to call updatesectorz here or have a separate function.
|
||||
if (relink) SetActor(self, self->int_pos());
|
||||
}
|
||||
|
@ -585,7 +585,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, copypos, coreactor_setpos)
|
|||
|
||||
void coreactor_move(DCoreActor* self, double x, double y, double z, int relink)
|
||||
{
|
||||
self->add_float_pos({ x, y, z });
|
||||
self->spr.pos += { x, y, z };
|
||||
// todo: SW needs to call updatesectorz here or have a separate function.
|
||||
if (relink) SetActor(self, self->int_pos());
|
||||
}
|
||||
|
@ -603,27 +603,27 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, move, coreactor_move)
|
|||
|
||||
void coreactor_setz(DCoreActor* self, double z)
|
||||
{
|
||||
self->set_float_z(z);
|
||||
self->spr.pos.Z = z;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, setz, coreactor_setz)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DCoreActor);
|
||||
PARAM_FLOAT(z);
|
||||
self->set_float_z(z);
|
||||
coreactor_setz(self, z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void coreactor_addz(DCoreActor* self, double z)
|
||||
{
|
||||
self->add_float_z(z);
|
||||
self->spr.pos.Z += z;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, addz, coreactor_addz)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DCoreActor);
|
||||
PARAM_FLOAT(z);
|
||||
self->add_float_z(z);
|
||||
coreactor_addz(self, z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,93 +70,78 @@ public:
|
|||
return time;
|
||||
}
|
||||
|
||||
void copy_pos(const DCoreActor* other)
|
||||
{
|
||||
spr.__int_pos = other->spr.__int_pos;
|
||||
}
|
||||
|
||||
const vec3_t int_pos() const
|
||||
{
|
||||
return spr.__int_pos;
|
||||
return { int(spr.pos.X * worldtoint), int(spr.pos.Y * worldtoint), int(spr.pos.Z * zworldtoint) };
|
||||
}
|
||||
|
||||
void set_int_z(int z)
|
||||
{
|
||||
spr.__int_pos.Z = z;
|
||||
spr.pos.Z = z * zinttoworld;
|
||||
}
|
||||
|
||||
void add_int_z(int z)
|
||||
{
|
||||
spr.__int_pos.Z += z;
|
||||
spr.pos.Z += z * zinttoworld;
|
||||
}
|
||||
|
||||
void add_int_pos(const vec3_t& add)
|
||||
{
|
||||
spr.__int_pos += add;
|
||||
spr.pos += { add.X* inttoworld, add.Y* inttoworld, add.Z* zinttoworld };
|
||||
}
|
||||
|
||||
void set_int_pos(const vec3_t& add)
|
||||
{
|
||||
spr.__int_pos = add;
|
||||
spr.pos = { add.X* inttoworld, add.Y* inttoworld, add.Z* zinttoworld };
|
||||
}
|
||||
|
||||
void copy_int_xy(DCoreActor* other)
|
||||
void copyXY(DCoreActor* other)
|
||||
{
|
||||
spr.__int_pos.X = other->spr.__int_pos.X;
|
||||
spr.__int_pos.Y = other->spr.__int_pos.Y;
|
||||
spr.pos.X = other->spr.pos.X;
|
||||
spr.pos.Y = other->spr.pos.Y;
|
||||
}
|
||||
|
||||
void set_int_xy(int x, int y)
|
||||
{
|
||||
spr.__int_pos.X = x;
|
||||
spr.__int_pos.Y = y;
|
||||
spr.pos.X = x * inttoworld;
|
||||
spr.pos.Y = y * inttoworld;
|
||||
}
|
||||
|
||||
DVector3 float_pos() const
|
||||
{
|
||||
return { spr.__int_pos.X * inttoworld, spr.__int_pos.Y * inttoworld, spr.__int_pos.Z * zinttoworld };
|
||||
return spr.pos;
|
||||
}
|
||||
|
||||
void set_float_pos(const DVector3& pos)
|
||||
{
|
||||
spr.__int_pos = { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
|
||||
}
|
||||
|
||||
void add_float_pos(const DVector3& pos)
|
||||
{
|
||||
spr.__int_pos += { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
|
||||
}
|
||||
|
||||
void set_float_z(int z)
|
||||
{
|
||||
spr.__int_pos.Z = int(z * zworldtoint);
|
||||
spr.pos.Z = z;
|
||||
}
|
||||
|
||||
void add_float_z(int z)
|
||||
{
|
||||
spr.__int_pos.Z += int(z * zworldtoint);
|
||||
spr.pos.Z += z;
|
||||
}
|
||||
|
||||
|
||||
// Same as above but with invertex y and z axes to match the renderer's coordinate system.
|
||||
DVector3 render_pos() const
|
||||
{
|
||||
return { spr.__int_pos.X * inttoworld, -spr.__int_pos.Y * inttoworld, -spr.__int_pos.Z * zinttoworld };
|
||||
return { spr.pos.X, -spr.pos.Y, -spr.pos.Z };
|
||||
}
|
||||
|
||||
int32_t interpolatedx(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return interpolatedvalue(opos.X, spr.__int_pos.X, smoothratio, scale);
|
||||
return interpolatedvalue(opos.X, spr.int_pos().X, smoothratio, scale);
|
||||
}
|
||||
|
||||
int32_t interpolatedy(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return interpolatedvalue(opos.Y, spr.__int_pos.Y, smoothratio, scale);
|
||||
return interpolatedvalue(opos.Y, spr.int_pos().Y, smoothratio, scale);
|
||||
}
|
||||
|
||||
int32_t interpolatedz(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return interpolatedvalue(opos.Z, spr.__int_pos.Z, smoothratio, scale);
|
||||
return interpolatedvalue(opos.Z, spr.int_pos().Z, smoothratio, scale);
|
||||
}
|
||||
|
||||
vec2_t interpolatedvec2(double const smoothratio, int const scale = 16)
|
||||
|
@ -185,27 +170,27 @@ public:
|
|||
|
||||
void backupx()
|
||||
{
|
||||
opos.X = spr.__int_pos.X;
|
||||
opos.X = spr.int_pos().X;
|
||||
}
|
||||
|
||||
void backupy()
|
||||
{
|
||||
opos.Y = spr.__int_pos.Y;
|
||||
opos.Y = spr.int_pos().Y;
|
||||
}
|
||||
|
||||
void backupz()
|
||||
{
|
||||
opos.Z = spr.__int_pos.Z;
|
||||
opos.Z = spr.int_pos().Z;
|
||||
}
|
||||
|
||||
void backupvec2()
|
||||
{
|
||||
opos.vec2 = spr.__int_pos.vec2;
|
||||
opos.vec2 = spr.int_pos().vec2;
|
||||
}
|
||||
|
||||
void backuppos()
|
||||
{
|
||||
opos = spr.__int_pos;
|
||||
opos = spr.int_pos();
|
||||
}
|
||||
|
||||
void backupang()
|
||||
|
|
|
@ -557,7 +557,7 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
|
|||
{
|
||||
auto tspr = tsprites.newTSprite();
|
||||
|
||||
tspr->set_int_pos(actor->int_pos());
|
||||
tspr->pos = actor->spr.pos;
|
||||
tspr->cstat = actor->spr.cstat;
|
||||
tspr->picnum = actor->spr.picnum;
|
||||
tspr->shade = actor->spr.shade;
|
||||
|
|
|
@ -445,7 +445,7 @@ struct walltype
|
|||
|
||||
struct spritetypebase
|
||||
{
|
||||
vec3_t __int_pos;
|
||||
DVector3 pos;
|
||||
|
||||
sectortype* sectp;
|
||||
|
||||
|
@ -473,12 +473,12 @@ struct spritetypebase
|
|||
|
||||
void SetMapPos(int x, int y, int z)
|
||||
{
|
||||
__int_pos = { x, y, z };
|
||||
pos = { x * maptoworld, y * maptoworld, z * zmaptoworld };
|
||||
}
|
||||
|
||||
const vec3_t int_pos() const
|
||||
{
|
||||
return __int_pos;
|
||||
return { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -500,33 +500,33 @@ struct tspritetype : public spritetypebase
|
|||
DCoreActor* ownerActor;
|
||||
int time;
|
||||
|
||||
void set_int_pos(const vec3_t& pos)
|
||||
void set_int_pos(const vec3_t& ipos)
|
||||
{
|
||||
__int_pos = pos;
|
||||
pos = { ipos.X * inttoworld, ipos.Y * inttoworld, ipos.Z * zinttoworld };
|
||||
}
|
||||
void add_int_x(int x)
|
||||
{
|
||||
__int_pos.X += x;
|
||||
pos.X += x * inttoworld;
|
||||
}
|
||||
void set_int_x(int x)
|
||||
{
|
||||
__int_pos.X = x;
|
||||
pos.X = x * inttoworld;
|
||||
}
|
||||
void add_int_y(int x)
|
||||
{
|
||||
__int_pos.Y += x;
|
||||
pos.Y += x * inttoworld;
|
||||
}
|
||||
void set_int_y(int x)
|
||||
{
|
||||
__int_pos.Y = x;
|
||||
pos.Y = x * inttoworld;
|
||||
}
|
||||
void add_int_z(int x)
|
||||
{
|
||||
__int_pos.Z += x;
|
||||
pos.Z += x * zinttoworld;
|
||||
}
|
||||
void set_int_z(int x)
|
||||
{
|
||||
__int_pos.Z = x;
|
||||
pos.Z = x * zinttoworld;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -446,9 +446,9 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
|
|||
def = &zsp; // always delta against 0
|
||||
if (arc.BeginObject(key))
|
||||
{
|
||||
arc("x", c.__int_pos.X, def->__int_pos.X)
|
||||
("y", c.__int_pos.Y, def->__int_pos.Y)
|
||||
("z", c.__int_pos.Z, def->__int_pos.Z)
|
||||
arc("x", c.pos.X, def->pos.X)
|
||||
("y", c.pos.Y, def->pos.Y)
|
||||
("z", c.pos.Z, def->pos.Z)
|
||||
("cstat", c.cstat, def->cstat)
|
||||
("picnum", c.picnum, def->picnum)
|
||||
("shade", c.shade, def->shade)
|
||||
|
|
|
@ -36,7 +36,7 @@ void GameInterface::WarpToCoords(int x, int y, int z, int ang, int horz)
|
|||
PLAYER* pPlayer = &gPlayer[myconnectindex];
|
||||
VIEW* pView = &gPrevView[myconnectindex];
|
||||
|
||||
pPlayer->actor->copy_int_xy(gView->actor);
|
||||
pPlayer->actor->copyXY(gView->actor);
|
||||
pView->x = gView->actor->int_pos().X;
|
||||
pView->y = gView->actor->int_pos().Y;
|
||||
pPlayer->zView = pView->viewz = gView->zView = z;
|
||||
|
|
|
@ -110,15 +110,15 @@ static double getvalue(so_interp::interp_data& element)
|
|||
return SectorObject[index].pmid.Z;
|
||||
case soi_sprx:
|
||||
if (element.actorofang)
|
||||
return element.actorofang->float_pos().X;
|
||||
return element.actorofang->spr.pos.X;
|
||||
break;
|
||||
case soi_spry:
|
||||
if (element.actorofang)
|
||||
return element.actorofang->float_pos().Y;
|
||||
return element.actorofang->spr.pos.Y;
|
||||
break;
|
||||
case soi_sprz:
|
||||
if (element.actorofang)
|
||||
return element.actorofang->float_pos().Z;
|
||||
return element.actorofang->spr.pos.Z;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -157,15 +157,15 @@ static void setvalue(so_interp::interp_data& element, double value)
|
|||
break;
|
||||
case soi_sprx:
|
||||
if (element.actorofang)
|
||||
element.actorofang->add_float_pos({ value, 0, 0});
|
||||
element.actorofang->spr.pos.X = value;
|
||||
break;
|
||||
case soi_spry:
|
||||
if (element.actorofang)
|
||||
element.actorofang->add_float_pos({ 0, value, 0});
|
||||
element.actorofang->spr.pos.Y = value;
|
||||
break;
|
||||
case soi_sprz:
|
||||
if (element.actorofang)
|
||||
element.actorofang->add_float_pos({ 0, 0, value});
|
||||
element.actorofang->spr.pos.Z = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue