diff --git a/source/core/actorlist.cpp b/source/core/actorlist.cpp index 2d24a1d54..0f85b3eb8 100644 --- a/source/core/actorlist.cpp +++ b/source/core/actorlist.cpp @@ -366,7 +366,7 @@ DCoreActor* InsertActor(PClass* type, sectortype* sector, int stat, bool tail) void DCoreActor::OnDestroy() { - FVector3 pos = GetSoundPos(int_pos()); + FVector3 pos = GetSoundPos(spr.pos); soundEngine->RelinkSound(SOURCE_Actor, this, nullptr, &pos); // also scan all other sounds if they have this actor as source. If so, null the source and stop looped sounds. @@ -530,7 +530,7 @@ void coreactor_setpos(DCoreActor* self, double x, double y, double z, int relink { 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()); + if (relink) SetActor(self, self->spr.pos); } DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, setpos, coreactor_setpos) @@ -549,7 +549,7 @@ void coreactor_copypos(DCoreActor* self, DCoreActor* other, int relink) if (!other) return; 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()); + if (relink) SetActor(self, self->spr.pos); } DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, copypos, coreactor_setpos) @@ -565,7 +565,7 @@ void coreactor_move(DCoreActor* self, double x, double y, double z, int relink) { 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()); + if (relink) SetActor(self, self->spr.pos); } DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, move, coreactor_move) diff --git a/source/core/automap.cpp b/source/core/automap.cpp index e7574662b..c50c1c189 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -607,7 +607,8 @@ void renderDrawMapView(int cposx, int cposy, int czoom, int cang) { auto A = *(DCoreActor**)a; auto B = *(DCoreActor**)b; - if (A->int_pos().Z != B->int_pos().Z) return B->int_pos().Z - A->int_pos().Z; + if (A->spr.pos.Z < B->spr.pos.Z) return 1; + if (A->spr.pos.Z > B->spr.pos.Z) return -1; return A->time - B->time; // ensures stable sort. }); diff --git a/source/core/interpolate.cpp b/source/core/interpolate.cpp index 68326475a..2fff15417 100644 --- a/source/core/interpolate.cpp +++ b/source/core/interpolate.cpp @@ -55,7 +55,7 @@ double Get(int index, DCoreActor* actor, int type) case Interp_Wall_PanX: return wall[index].xpan_; case Interp_Wall_PanY: return wall[index].ypan_; - case Interp_Sprite_Z: return !actor? 0 : actor->int_pos().Z; + case Interp_Sprite_Z: return !actor? 0 : actor->spr.pos.Z; default: return 0; } } @@ -79,7 +79,7 @@ void Set(int index, DCoreActor* actor, int type, double val) case Interp_Wall_PanX: wall[index].xpan_ = float(val); break; case Interp_Wall_PanY: wall[index].ypan_ = float(val); break; - case Interp_Sprite_Z: if (actor) actor->set_int_z(xs_CRoundToInt(val)); break; + case Interp_Sprite_Z: if (actor) actor->spr.pos.Z = val; break; } } diff --git a/source/core/raze_sound.h b/source/core/raze_sound.h index 819839a6e..9220cb52a 100644 --- a/source/core/raze_sound.h +++ b/source/core/raze_sound.h @@ -22,6 +22,10 @@ inline FVector3 GetSoundPos(const vec3_t& pos) return { pos.X * xmul, pos.Z * zmul, pos.Y * ymul }; } +inline FVector3 GetSoundPos(const DVector3& pos) +{ + return { float(pos.X), float(-pos.Z), float(-pos.Y) }; +} enum { diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index d639300f6..06761c83d 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -177,7 +177,7 @@ void HWFlat::MakeVertices(HWDrawInfo* di) auto svp = &di->SlopeSpriteVertices[svi]; auto& vpt = di->Viewpoint; - depth = (float)((Sprite->int_pos().X * (1/16.f) - vpt.Pos.X) * vpt.TanCos + (Sprite->int_pos().Y * (1 / -16.f) - vpt.Pos.Y) * vpt.TanSin); + depth = (float)((Sprite->pos.X - vpt.Pos.X) * vpt.TanCos + (-Sprite->pos.Y - vpt.Pos.Y) * vpt.TanSin); for (unsigned j = 0; j < 4; j++) { @@ -421,12 +421,12 @@ void HWFlat::ProcessFlatSprite(HWDrawInfo* di, tspritetype* sprite, sectortype* int tilenum = sprite->picnum; texture = tileGetTexture(tilenum); bool belowfloor = false; - if (sprite->int_pos().Z > sprite->sectp->int_floorz()) + if (sprite->pos.Z > sprite->sectp->floorz) { belowfloor = true; - sprite->set_int_z(sprite->sectp->int_floorz()); + sprite->pos.Z = sprite->sectp->floorz; } - z = sprite->int_pos().Z * (1 / -256.f); + z = -sprite->pos.Z; if (z == di->Viewpoint.Pos.Z) return; // looking right at the edge. dynlightindex = -1; diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index b893143de..00a4d3b0f 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -332,9 +332,9 @@ void HWSprite::Process(HWDrawInfo* di, tspritetype* spr, sectortype* sector, int SetSpriteTranslucency(spr, alpha, RenderStyle); - x = spr->int_pos().X * (1 / 16.f); - z = spr->int_pos().Z * (1 / -256.f); - y = spr->int_pos().Y * (1 / -16.f); + x = spr->pos.X; + z = -spr->pos.Z; + y = -spr->pos.Y; auto vp = di->Viewpoint; if ((vp.Pos.XY() - DVector2(x, y)).LengthSquared() < 0.125) return; @@ -395,9 +395,9 @@ void HWSprite::Process(HWDrawInfo* di, tspritetype* spr, sectortype* sector, int float viewvecX = vp.ViewVector.X; float viewvecY = vp.ViewVector.Y; - x = spr->int_pos().X * (1 / 16.f); - y = spr->int_pos().Y * (1 / -16.f); - z = spr->int_pos().Z * (1 / -256.f); + x = spr->pos.X; + y = -spr->pos.Y; + z = -spr->pos.Z; x1 = x - viewvecY * (xoff - (width * 0.5f)); x2 = x - viewvecY * (xoff + (width * 0.5f)); diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index c5ed8a7df..f6b9658c5 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -55,8 +55,8 @@ static walltype* IsOnWall(tspritetype* tspr, int height, DVector2& outpos) auto sect = tspr->sectp; - float tx = tspr->int_pos().X * (float)inttoworld; - float ty = tspr->int_pos().Y * (float)inttoworld; + double tx = tspr->pos.X; + double ty = tspr->pos.Y; for(auto& wal : wallsofsector(sect)) { @@ -1102,7 +1102,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec int HWWall::CheckWallSprite(tspritetype* spr, tspritetype* last) { // If the position changed we need to recalculate everything. - if (spr->int_pos().X != last->int_pos().X || spr->int_pos().Y != last->int_pos().Y || spr->sectp != last->sectp || spr->ang != last->ang) return 3; + if (spr->pos.XY() != last->pos.XY() || spr->sectp != last->sectp || spr->ang != last->ang) return 3; // if the horizontal orientation changes we need to recalculate the walls this attaches to, but not the positioning. if (spr->xrepeat != last->xrepeat || spr->xoffset != last->xoffset || spr->picnum != last->picnum || ((spr->cstat ^ last->cstat) & CSTAT_SPRITE_XFLIP)) return 2;