mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
-fix some bugs, handle occurences in recently changed code
This commit is contained in:
parent
99188b52e9
commit
ad9931081e
7 changed files with 52 additions and 26 deletions
|
@ -616,7 +616,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
|
|||
case CSTAT_SPRITE_ALIGNMENT_FACING:
|
||||
if (p1.X >= clipMin.X && p1.X <= clipMax.X && p1.Y >= clipMin.Y && p1.Y <= clipMax.Y)
|
||||
{
|
||||
int32_t height, daz = int_pos().Z + actor->GetOffsetAndHeight(height);
|
||||
int32_t height, daz = actor->int_pos().Z + actor->GetOffsetAndHeight(height);
|
||||
|
||||
if (pos->Z > daz-height-flordist && pos->Z < daz+ceildist)
|
||||
{
|
||||
|
@ -1166,7 +1166,7 @@ void getzrange(const vec3_t& pos, sectortype* sect, int32_t* ceilz, CollisionBas
|
|||
int32_t k = walldist+(actor->spr.clipdist<<2)+1;
|
||||
if ((abs(v1.X-pos.X) <= k) && (abs(v1.Y-pos.Y) <= k))
|
||||
{
|
||||
daz = int_pos().Z + actor->GetOffsetAndHeight(k);
|
||||
daz = actor->int_pos().Z + actor->GetOffsetAndHeight(k);
|
||||
daz2 = daz - k;
|
||||
clipyou = 1;
|
||||
}
|
||||
|
|
|
@ -528,18 +528,18 @@ DEFINE_FIELD_NAMED(DCoreActor, spritesetindex, spritesetpic)
|
|||
DEFINE_ACTION_FUNCTION(DCoreActor, pos)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DCoreActor);
|
||||
ACTION_RETURN_VEC3(DVector3(self->spr.pos.X * (1 / 16.), self->spr.pos.Y * (1 / 16.), self->spr.pos.Z * (1 / 256.)));
|
||||
ACTION_RETURN_VEC3(self->float_pos());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DCoreActor, xy)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DCoreActor);
|
||||
ACTION_RETURN_VEC2(DVector2(self->spr.pos.X * (1 / 16.), self->spr.pos.Y * (1 / 16.)));
|
||||
ACTION_RETURN_VEC2(self->float_pos().XY());
|
||||
}
|
||||
|
||||
double coreactor_z(DCoreActor* self)
|
||||
{
|
||||
return self->spr.zvel * zinttoworld;
|
||||
return self->float_pos().Z;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, z, coreactor_z)
|
||||
|
@ -550,11 +550,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, z, coreactor_z)
|
|||
|
||||
void coreactor_setpos(DCoreActor* self, double x, double y, double z, int relink)
|
||||
{
|
||||
self->spr.pos.X = int(x * worldtoint);
|
||||
self->spr.pos.Y = int(y * worldtoint);
|
||||
self->spr.pos.Z = int(z * zworldtoint);
|
||||
self->set_float_pos({ x, y, z });
|
||||
// todo: SW needs to call updatesectorz here or have a separate function.
|
||||
if (relink) SetActor(self, self->spr.pos);
|
||||
if (relink) SetActor(self, self->int_pos());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, setpos, coreactor_setpos)
|
||||
|
@ -571,9 +569,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, setpos, coreactor_setpos)
|
|||
void coreactor_copypos(DCoreActor* self, DCoreActor* other, int relink)
|
||||
{
|
||||
if (!other) return;
|
||||
self->spr.pos = other->spr.pos;
|
||||
self->copy_pos(other);
|
||||
// todo: SW needs to call updatesectorz here or have a separate function.
|
||||
if (relink) SetActor(self, self->spr.pos);
|
||||
if (relink) SetActor(self, self->int_pos());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, copypos, coreactor_setpos)
|
||||
|
@ -587,11 +585,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, copypos, coreactor_setpos)
|
|||
|
||||
void coreactor_move(DCoreActor* self, double x, double y, double z, int relink)
|
||||
{
|
||||
self->spr.pos.X += int(x * 16);
|
||||
self->spr.pos.Y += int(y * 16);
|
||||
self->spr.pos.Z += int(z * 256);
|
||||
self->add_float_pos({ x, y, z });
|
||||
// todo: SW needs to call updatesectorz here or have a separate function.
|
||||
if (relink) SetActor(self, self->spr.pos);
|
||||
if (relink) SetActor(self, self->int_pos());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, move, coreactor_move)
|
||||
|
@ -607,27 +603,27 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, move, coreactor_move)
|
|||
|
||||
void coreactor_setz(DCoreActor* self, double z)
|
||||
{
|
||||
self->spr.pos.Z = int(z * 256);
|
||||
self->set_float_z(z);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, setz, coreactor_setz)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DCoreActor);
|
||||
PARAM_FLOAT(z);
|
||||
self->spr.pos.Z = int(z * 256);
|
||||
self->set_float_z(z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void coreactor_addz(DCoreActor* self, double z)
|
||||
{
|
||||
self->spr.pos.Z += int(z * 256);
|
||||
self->add_float_z(z);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, addz, coreactor_addz)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DCoreActor);
|
||||
PARAM_FLOAT(z);
|
||||
self->spr.pos.Z = int(z * 256);
|
||||
self->add_float_z(z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,11 @@ public:
|
|||
return time;
|
||||
}
|
||||
|
||||
void copy_pos(const DCoreActor* other)
|
||||
{
|
||||
spr.pos = other->spr.pos;
|
||||
}
|
||||
|
||||
const vec3_t int_pos() const
|
||||
{
|
||||
return spr.pos;
|
||||
|
@ -112,6 +117,33 @@ public:
|
|||
return { spr.pos.X * inttoworld, spr.pos.Y * inttoworld, spr.pos.Z * zinttoworld };
|
||||
}
|
||||
|
||||
void set_float_pos(const DVector3& pos)
|
||||
{
|
||||
spr.pos = { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
|
||||
}
|
||||
|
||||
void add_float_pos(const DVector3& pos)
|
||||
{
|
||||
spr.pos += { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
|
||||
}
|
||||
|
||||
void set_float_z(int z)
|
||||
{
|
||||
spr.pos.Z = int(z * zworldtoint);
|
||||
}
|
||||
|
||||
void add_float_z(int z)
|
||||
{
|
||||
spr.pos.Z += int(z * zworldtoint);
|
||||
}
|
||||
|
||||
|
||||
// Same as above but with invertex y and z axes to match the renderer's coordinate system.
|
||||
DVector3 render_pos() const
|
||||
{
|
||||
return { spr.pos.X * inttoworld, -spr.pos.Y * inttoworld, -spr.pos.Z * zinttoworld };
|
||||
}
|
||||
|
||||
int32_t interpolatedx(double const smoothratio, int const scale = 16)
|
||||
{
|
||||
return interpolatedvalue(opos.X, spr.pos.X, smoothratio, scale);
|
||||
|
|
|
@ -557,7 +557,7 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
|
|||
{
|
||||
auto tspr = tsprites.newTSprite();
|
||||
|
||||
tspr->pos = actor->spr.pos;
|
||||
tspr->pos = actor->int_pos();
|
||||
tspr->cstat = actor->spr.cstat;
|
||||
tspr->picnum = actor->spr.picnum;
|
||||
tspr->shade = actor->spr.shade;
|
||||
|
|
|
@ -676,7 +676,7 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal)
|
|||
if ((actor->spr.cstat & CSTAT_SPRITE_INVISIBLE) || actor->spr.xrepeat == 0 || actor->spr.yrepeat == 0) // skip invisible sprites
|
||||
continue;
|
||||
|
||||
int sx = actor->spr.pos.X - iview.X, sy = actor->spr.pos.Y - int(iview.Y);
|
||||
int sx = actor->int_pos().X - iview.X, sy = actor->int_pos().Y - int(iview.Y);
|
||||
|
||||
// this checks if the sprite is it behind the camera, which will not work if the pitch is high enough to necessitate a FOV of more than 180°.
|
||||
//if ((actor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) || (hw_models && tile2model[actor->spr.picnum].modelid >= 0) || ((sx * gcosang) + (sy * gsinang) > 0))
|
||||
|
|
|
@ -670,7 +670,7 @@ bool HWLineToSpritePortal::Setup(HWDrawInfo* di, FRenderState& rstate, Clipper*
|
|||
di->mClipPortal = this;
|
||||
|
||||
auto srccenter = (WallStart(origin) + WallEnd(origin)) / 2;
|
||||
DVector2 destcenter ={ camera->spr.pos.X / 16.f, camera->spr.pos.Y / -16.f };
|
||||
DVector2 destcenter = camera->render_pos().XY();
|
||||
DVector2 npos = vp.Pos - srccenter + destcenter;
|
||||
|
||||
double origx = vp.Pos.X;
|
||||
|
|
|
@ -89,9 +89,7 @@ void BuildRat(DExhumedActor* pActor, int x, int y, int z, sectortype* pSector, i
|
|||
ChangeActorStat(pActor, 108);
|
||||
}
|
||||
|
||||
pActor->spr.pos.X = x;
|
||||
pActor->spr.pos.Y = y;
|
||||
pActor->spr.pos.Z = z;
|
||||
pActor->set_int_pos({ x, y, z });
|
||||
pActor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;
|
||||
pActor->spr.shade = -12;
|
||||
pActor->spr.xoffset = 0;
|
||||
|
|
Loading…
Reference in a new issue