- added alignceilslope and alignflorslope variants receiving a position vector.

This commit is contained in:
Christoph Oelckers 2022-08-21 16:12:38 +02:00
parent 98b06697f7
commit 80e10d89f4
4 changed files with 26 additions and 38 deletions

View file

@ -550,4 +550,14 @@ inline void alignflorslope(sectortype* sect, int x, int y, int z)
sect->setfloorslope(getslopeval(sect, x, y, z, sect->int_floorz())); sect->setfloorslope(getslopeval(sect, x, y, z, sect->int_floorz()));
} }
inline void alignceilslope(sectortype* sect, const DVector3& pos)
{
sect->setceilingslope(getslopeval(sect, pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint, sect->int_ceilingz()));
}
inline void alignflorslope(sectortype* sect, const DVector3& pos)
{
sect->setfloorslope(getslopeval(sect, pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint, sect->int_floorz()));
}
#include "updatesector.h" #include "updatesector.h"

View file

@ -1945,8 +1945,8 @@ void SpikeAlign(DSWActor*); // spike.c
short DoSectorObjectSetScale(short match); // morph.c short DoSectorObjectSetScale(short match); // morph.c
short DoSOevent(short match,short state); // morph.c short DoSOevent(short match,short state); // morph.c
void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop,int x,int y,int z); // morph.c void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop, const DVector3& pos); // morph.c
void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop,int x,int y,int z); // morph.c void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop, const DVector3& pos); // morph.c
void ScaleSectorObject(SECTOR_OBJECT* sop); // morph.c void ScaleSectorObject(SECTOR_OBJECT* sop); // morph.c
void MorphTornado(SECTOR_OBJECT* sop); // morph.c void MorphTornado(SECTOR_OBJECT* sop); // morph.c
void MorphFloor(SECTOR_OBJECT* sop); // morph.c void MorphFloor(SECTOR_OBJECT* sop); // morph.c

View file

@ -452,7 +452,7 @@ void MorphFloor(SECTOR_OBJECT* sop)
} }
} }
void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop, int x, int y, int z) void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop, const DVector3& pos)
{ {
sectortype* *sectp; sectortype* *sectp;
int j; int j;
@ -462,12 +462,12 @@ void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop, int x, int y, int z)
if ((*sectp)->hasU() && if ((*sectp)->hasU() &&
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT)) ((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
{ {
alignflorslope(*sectp, x, y, z); alignflorslope(*sectp, pos);
} }
} }
} }
void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop, int x, int y, int z) void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop, const DVector3& pos)
{ {
sectortype* *sectp; sectortype* *sectp;
int j; int j;
@ -477,23 +477,7 @@ void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop, int x, int y, int z)
if ((*sectp)->hasU() && if ((*sectp)->hasU() &&
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT)) ((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
{ {
alignceilslope(*sectp, x, y, z); alignceilslope(*sectp, pos);
}
}
}
void SOBJ_AlignFloorCeilingToPoint(SECTOR_OBJECT* sop, int x, int y, int z)
{
sectortype* *sectp;
int j;
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{
if ((*sectp)->hasU() &&
((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT))
{
alignflorslope(*sectp, x, y, z);
alignceilslope(*sectp, x, y, z);
} }
} }
} }
@ -501,10 +485,6 @@ void SOBJ_AlignFloorCeilingToPoint(SECTOR_OBJECT* sop, int x, int y, int z)
// moves center point around and aligns slope // moves center point around and aligns slope
void SpikeFloor(SECTOR_OBJECT* sop) void SpikeFloor(SECTOR_OBJECT* sop)
{ {
int mx, my;
int florz;
int x,y;
// z direction // z direction
ASSERT(sop->op_main_sector != nullptr); ASSERT(sop->op_main_sector != nullptr);
sop->morph_z -= Z(sop->morph_z_speed); sop->morph_z -= Z(sop->morph_z_speed);
@ -513,16 +493,13 @@ void SpikeFloor(SECTOR_OBJECT* sop)
if (sop->morph_wall_point == nullptr) if (sop->morph_wall_point == nullptr)
return; return;
// place at correct x,y offset from center DVector3 pos;
x = sop->int_pmid().X - sop->morph_xoff;
y = sop->int_pmid().Y - sop->morph_yoff;
// move it from last x,y // place at correct x,y offset from center
mx = x; pos.X = sop->pmid.X - sop->morph_xoff * inttoworld;
my = y; pos.Y = sop->pmid.Y - sop->morph_yoff * inttoworld;
// bound the Z // bound the Z
florz = sop->op_main_sector->int_floorz();
#define MORPH_FLOOR_ZRANGE Z(300) #define MORPH_FLOOR_ZRANGE Z(300)
@ -536,8 +513,9 @@ void SpikeFloor(SECTOR_OBJECT* sop)
sop->morph_z = -MORPH_FLOOR_ZRANGE; sop->morph_z = -MORPH_FLOOR_ZRANGE;
sop->morph_z_speed *= -1; sop->morph_z_speed *= -1;
} }
pos.Z = sop->op_main_sector->floorz + sop->morph_z * inttoworld;
SOBJ_AlignFloorToPoint(sop, mx, my, florz + sop->morph_z); SOBJ_AlignFloorToPoint(sop, pos);
} }

View file

@ -232,16 +232,16 @@ void SpikeAlign(DSWActor* actor)
if ((int8_t)SP_TAG7(actor) < 0) if ((int8_t)SP_TAG7(actor) < 0)
{ {
if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP)) if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP))
alignceilslope(actor->sector(), actor->int_pos().X, actor->int_pos().Y, actor->user.int_zclip()); alignceilslope(actor->sector(), DVector3(actor->spr.pos.XY(), actor->user.zclip));
else else
alignflorslope(actor->sector(), actor->int_pos().X, actor->int_pos().Y, actor->user.int_zclip()); alignflorslope(actor->sector(), DVector3(actor->spr.pos.XY(), actor->user.zclip));
} }
else else
{ {
if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP)) if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP))
SOBJ_AlignCeilingToPoint(&SectorObject[SP_TAG7(actor)], actor->int_pos().X, actor->int_pos().Y, actor->user.int_zclip()); SOBJ_AlignCeilingToPoint(&SectorObject[SP_TAG7(actor)], DVector3(actor->spr.pos.XY(), actor->user.zclip));
else else
SOBJ_AlignFloorToPoint(&SectorObject[SP_TAG7(actor)], actor->int_pos().X, actor->int_pos().Y, actor->user.int_zclip()); SOBJ_AlignFloorToPoint(&SectorObject[SP_TAG7(actor)], DVector3(actor->spr.pos.XY(), actor->user.zclip));
} }
} }