From 80e10d89f45003a5c33328f38ebcc5aedab6ffa8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Aug 2022 16:12:38 +0200 Subject: [PATCH] - added alignceilslope and alignflorslope variants receiving a position vector. --- source/core/gamefuncs.h | 10 +++++++++ source/games/sw/src/game.h | 4 ++-- source/games/sw/src/morph.cpp | 42 +++++++++-------------------------- source/games/sw/src/spike.cpp | 8 +++---- 4 files changed, 26 insertions(+), 38 deletions(-) diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index fdd14722e..78e7ee686 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -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())); } +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" diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 85048ed52..39da59c9e 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1945,8 +1945,8 @@ void SpikeAlign(DSWActor*); // spike.c short DoSectorObjectSetScale(short match); // 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_AlignFloorToPoint(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, const DVector3& pos); // morph.c void ScaleSectorObject(SECTOR_OBJECT* sop); // morph.c void MorphTornado(SECTOR_OBJECT* sop); // morph.c void MorphFloor(SECTOR_OBJECT* sop); // morph.c diff --git a/source/games/sw/src/morph.cpp b/source/games/sw/src/morph.cpp index fdf2a588d..5f4f2ac29 100644 --- a/source/games/sw/src/morph.cpp +++ b/source/games/sw/src/morph.cpp @@ -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; int j; @@ -462,12 +462,12 @@ void SOBJ_AlignFloorToPoint(SECTOR_OBJECT* sop, int x, int y, int z) if ((*sectp)->hasU() && ((*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; int j; @@ -477,23 +477,7 @@ void SOBJ_AlignCeilingToPoint(SECTOR_OBJECT* sop, int x, int y, int z) if ((*sectp)->hasU() && ((*sectp)->flags & SECTFU_SO_SLOPE_CEILING_TO_POINT)) { - alignceilslope(*sectp, x, y, z); - } - } -} - -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); + alignceilslope(*sectp, pos); } } } @@ -501,10 +485,6 @@ void SOBJ_AlignFloorCeilingToPoint(SECTOR_OBJECT* sop, int x, int y, int z) // moves center point around and aligns slope void SpikeFloor(SECTOR_OBJECT* sop) { - int mx, my; - int florz; - int x,y; - // z direction ASSERT(sop->op_main_sector != nullptr); sop->morph_z -= Z(sop->morph_z_speed); @@ -513,16 +493,13 @@ void SpikeFloor(SECTOR_OBJECT* sop) if (sop->morph_wall_point == nullptr) return; - // place at correct x,y offset from center - x = sop->int_pmid().X - sop->morph_xoff; - y = sop->int_pmid().Y - sop->morph_yoff; + DVector3 pos; - // move it from last x,y - mx = x; - my = y; + // place at correct x,y offset from center + pos.X = sop->pmid.X - sop->morph_xoff * inttoworld; + pos.Y = sop->pmid.Y - sop->morph_yoff * inttoworld; // bound the Z - florz = sop->op_main_sector->int_floorz(); #define MORPH_FLOOR_ZRANGE Z(300) @@ -536,8 +513,9 @@ void SpikeFloor(SECTOR_OBJECT* sop) sop->morph_z = -MORPH_FLOOR_ZRANGE; 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); } diff --git a/source/games/sw/src/spike.cpp b/source/games/sw/src/spike.cpp index 886ab96b1..5aa58df88 100644 --- a/source/games/sw/src/spike.cpp +++ b/source/games/sw/src/spike.cpp @@ -232,16 +232,16 @@ void SpikeAlign(DSWActor* actor) if ((int8_t)SP_TAG7(actor) < 0) { 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 - 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 { 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 - 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)); } }