- FindSector variants with vectors

This commit is contained in:
Christoph Oelckers 2022-08-22 18:27:03 +02:00
parent f41c78d622
commit 139969d017
5 changed files with 16 additions and 8 deletions

View file

@ -4564,7 +4564,7 @@ static Collision MoveThing(DBloodActor* actor)
else else
{ {
assert(pSector); assert(pSector);
FindSector(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z, &pSector); FindSector(actor->spr.pos, &pSector);
} }
actor->add_int_z(actor->vel.Z >> 8); actor->add_int_z(actor->vel.Z >> 8);
@ -4746,7 +4746,7 @@ void MoveDude(DBloodActor* actor)
if (pPlayer && gNoClip) if (pPlayer && gNoClip)
{ {
actor->add_int_pos({ actor->vel.X >> 12, actor->vel.Y >> 12, 0 }); actor->add_int_pos({ actor->vel.X >> 12, actor->vel.Y >> 12, 0 });
if (!FindSector(actor->int_pos().X, actor->int_pos().Y, &pSector)) if (!FindSector(actor->spr.pos.XY(), &pSector))
pSector = actor->sector(); pSector = actor->sector();
} }
else else
@ -4830,7 +4830,7 @@ void MoveDude(DBloodActor* actor)
else else
{ {
assert(pSector); assert(pSector);
FindSector(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z, &pSector); FindSector(actor->spr.pos, &pSector);
} }
XSECTOR* pXSector = pSector->hasX() ? &pSector->xs() : nullptr; XSECTOR* pXSector = pSector->hasX() ? &pSector->xs() : nullptr;

View file

@ -293,7 +293,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
int y = MulScale(nLen, Sin(nAng), 30); int y = MulScale(nLen, Sin(nAng), 30);
pNSprite->set_int_pos({ pTSprite->int_pos().X + x, pTSprite->int_pos().Y + y, pTSprite->int_pos().Z }); pNSprite->set_int_pos({ pTSprite->int_pos().X + x, pTSprite->int_pos().Y + y, pTSprite->int_pos().Z });
assert(pSector); assert(pSector);
FindSector(pNSprite->int_pos().X, pNSprite->int_pos().Y, pNSprite->int_pos().Z, &pSector); FindSector(pNSprite->pos, &pSector);
pNSprite->sectp = pSector; pNSprite->sectp = pSector;
pNSprite->ownerActor = pTSprite->ownerActor; pNSprite->ownerActor = pTSprite->ownerActor;
pNSprite->picnum = pTSprite->picnum; pNSprite->picnum = pTSprite->picnum;

View file

@ -142,7 +142,7 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, sectortype* pSector, int x, int y, int
if (pSector == nullptr) if (pSector == nullptr)
return nullptr; return nullptr;
auto pSector2 = pSector; auto pSector2 = pSector;
if (!FindSector(x, y, z, &pSector2)) if (!FindSector(pos, &pSector2))
return nullptr; return nullptr;
if (adult_lockout && gGameOptions.nGameType <= 0) if (adult_lockout && gGameOptions.nGameType <= 0)
{ {
@ -271,7 +271,7 @@ void fxSpawnBlood(DBloodActor* actor, int)
if (!actor->insector()) if (!actor->insector())
return; return;
auto pSector = actor->sector(); auto pSector = actor->sector();
if (!FindSector(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z, &pSector)) if (!FindSector(actor->spr.pos, &pSector))
return; return;
if (adult_lockout && gGameOptions.nGameType <= 0) if (adult_lockout && gGameOptions.nGameType <= 0)
return; return;
@ -297,7 +297,7 @@ void fxSpawnPodStuff(DBloodActor* actor, int)
if (!actor->insector()) if (!actor->insector())
return; return;
auto pSector = actor->sector(); auto pSector = actor->sector();
if (!FindSector(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z, &pSector)) if (!FindSector(actor->spr.pos, &pSector))
return; return;
if (adult_lockout && gGameOptions.nGameType <= 0) if (adult_lockout && gGameOptions.nGameType <= 0)
return; return;

View file

@ -34,6 +34,14 @@ enum {
bool FindSector(int nX, int nY, int nZ, sectortype** ppSector); bool FindSector(int nX, int nY, int nZ, sectortype** ppSector);
bool FindSector(int nX, int nY, sectortype** ppSector); bool FindSector(int nX, int nY, sectortype** ppSector);
inline bool FindSector(const DVector3& pos, sectortype** ppSector)
{
return FindSector(int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint), ppSector);
}
inline bool FindSector(const DVector2& pos, sectortype** ppSector)
{
return FindSector(int(pos.X * worldtoint), int(pos.Y * worldtoint), ppSector);
}
bool CheckProximity(DBloodActor* pSprite, const DVector3& pos, sectortype* pSector, int nDist); bool CheckProximity(DBloodActor* pSprite, const DVector3& pos, sectortype* pSector, int nDist);
bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist); bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist);

View file

@ -1699,7 +1699,7 @@ void debrisMove(int listIndex)
} }
} }
else if (!FindSector(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z, &pSector)) else if (!FindSector(actor->spr.pos, &pSector))
{ {
return; return;
} }