Overhaul slope collision (NOT PHYSICS) to work almost perfectly

This commit is contained in:
RedEnchilada 2015-04-27 13:20:50 -05:00
parent 58dd6d42af
commit 6694480f68
5 changed files with 56 additions and 136 deletions

View file

@ -28,7 +28,7 @@
#include "hardware/hw3sound.h"
#endif
#ifdef ESLOPE
#ifdef SPRINGCLEAN// ESLOPE
#include "p_slopes.h"
#endif
@ -5611,12 +5611,8 @@ void A_MixUp(mobj_t *actor)
P_SetThingPosition(players[i].mo);
#ifdef ESLOPE
players[i].mo->floorz = (players[i].mo->subsector->sector->f_slope ?
P_GetZAt(players[i].mo->subsector->sector->f_slope, players[i].mo->x, players[i].mo->y) :
players[i].mo->subsector->sector->floorheight);
players[i].mo->ceilingz = (players[i].mo->subsector->sector->c_slope ?
P_GetZAt(players[i].mo->subsector->sector->c_slope, players[i].mo->x, players[i].mo->y) :
players[i].mo->subsector->sector->ceilingheight);
players[i].mo->floorz = P_GetFloorZ(players[i].mo, players[i].mo->subsector->sector, players[i].mo->x, players[i].mo->y, NULL);
players[i].mo->ceilingz = P_GetCeilingZ(players[i].mo, players[i].mo->subsector->sector, players[i].mo->x, players[i].mo->y, NULL);
#else
players[i].mo->floorz = players[i].mo->subsector->sector->floorheight;
players[i].mo->ceilingz = players[i].mo->subsector->sector->ceilingheight;

View file

@ -19,7 +19,7 @@
#include "z_zone.h"
#include "g_game.h"
#include "r_main.h"
#ifdef ESLOPE
#ifdef SPRINGCLEAN// ESLOPE
#include "p_slopes.h"
#endif
@ -1177,18 +1177,15 @@ void T_SpikeSector(levelspecthink_t *spikes)
if (affectsec == spikes->sector) // Applied to an actual sector
{
fixed_t affectpoint = affectsec->floorheight;
fixed_t affectfloor = P_GetFloorZ(thing, affectsec, thing->x, thing->y, NULL);
fixed_t affectceil = P_GetCeilingZ(thing, affectsec, thing->x, thing->y, NULL);
#ifdef ESLOPE
if (affectsec->f_slope)
affectpoint = P_GetZAt(affectsec->f_slope, thing->x, thing->y);
#endif
if (affectsec->flags & SF_FLIPSPECIAL_FLOOR)
{
if (!(thing->eflags & MFE_VERTICALFLIP) && thing->momz > 0)
continue;
if (thing->z == affectpoint)
if (thing->z == affectfloor)
dothepain = true;
}
@ -1197,7 +1194,7 @@ void T_SpikeSector(levelspecthink_t *spikes)
if ((thing->eflags & MFE_VERTICALFLIP) && thing->momz < 0)
continue;
if (thing->z + thing->height == affectsec->ceilingheight)
if (thing->z + thing->height == affectceil)
dothepain = true;
}
}

View file

@ -27,7 +27,7 @@
#include "r_splats.h"
#ifdef ESLOPE
#ifdef SPRINGCLEAN// ESLOPE
#include "p_slopes.h"
#endif
@ -125,7 +125,7 @@ void P_DoSpring(mobj_t *spring, mobj_t *object)
/*Someone want to make these work like bumpers?*/
return;
}
object->eflags |= MFE_SPRUNG; // apply this flag asap!
spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify
@ -1208,21 +1208,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
// that contains the point.
// Any contacted lines the step closer together
// will adjust them.
#ifdef ESLOPE
if (newsubsec->sector->f_slope)
{
tmfloorz = tmdropoffz = P_GetZAt(newsubsec->sector->f_slope, thing->x, thing->y);
}
else
#endif
tmfloorz = tmdropoffz = newsubsec->sector->floorheight;
#ifdef ESLOPE
if (newsubsec->sector->c_slope)
tmceilingz = P_GetZAt(newsubsec->sector->c_slope, thing->x, thing->y);
else
#endif
tmceilingz = newsubsec->sector->ceilingheight;
tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, thing->x, thing->y, NULL); //newsubsec->sector->floorheight;
tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, thing->x, thing->y, NULL); //newsubsec->sector->ceilingheight;
// Check list of fake floors and see if tmfloorz/tmceilingz need to be altered.
if (newsubsec->sector->ffloors)
@ -1535,7 +1522,7 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
fixed_t topheight = *rover->topheight;
fixed_t bottomheight = *rover->bottomheight;
/*#ifdef ESLOPE
if (rover->t_slope)
topheight = P_GetZAt(rover->t_slope, thiscam->x, thiscam->y);
@ -2033,7 +2020,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
// Link the thing into its new position
P_UnsetThingPosition(thing);
#ifdef ESLOPE
#ifdef SRPINGCLEAN// ESLOPE
// By virtue of being derived from SRB2 code, Kalaron's physics are GPL.
if (P_IsObjectOnSlope(thing, false))
{
@ -2112,32 +2099,9 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
}
#endif
// P_CheckPosition sets the tmfloorz with slopes, but after P_UnsetThingPosition, recheck the function here
// TODO: Make a function for floor/ceilingz auto check with slopes?
#ifdef ESLOPE
if (thing->subsector->sector->f_slope)
{
// TODO: Support a mobj's gravity for this too
if (P_GetZAt(thing->subsector->sector->f_slope, thing->x+thing->momx, thing->y+thing->momy) > P_GetZAt(thing->subsector->sector->f_slope, thing->x, thing->y))
thing->floorz = P_GetZAt(thing->subsector->sector->f_slope, thing->x+thing->momx, thing->y+thing->momy);
else
thing->floorz = P_GetZAt(thing->subsector->sector->f_slope, thing->x, thing->y);
}
else
#endif
thing->floorz = tmfloorz;
#ifdef ESLOPE
if (thing->subsector->sector->c_slope)
{
// SRB2CBTODO: Support a mobj's gravity for this too
if (P_GetZAt(thing->subsector->sector->c_slope, thing->x+thing->momx, thing->y+thing->momy) < P_GetZAt(thing->subsector->sector->c_slope, thing->x, thing->y))
thing->ceilingz = P_GetZAt(thing->subsector->sector->c_slope, thing->x, thing->y);
else
thing->ceilingz = P_GetZAt(thing->subsector->sector->c_slope, thing->x+thing->momx, thing->y+thing->momy);
}
else
#endif
thing->ceilingz = tmceilingz;
thing->floorz = tmfloorz;
thing->ceilingz = tmceilingz;
thing->x = x;
thing->y = y;
@ -2494,16 +2458,8 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle)
glidesector = R_PointInSubsector(player->mo->x + platx, player->mo->y + platy);
floorz = glidesector->sector->floorheight;
#ifdef ESLOPE
if (glidesector->sector->f_slope)
floorz = P_GetZAt(glidesector->sector->f_slope, player->mo->x + platx, player->mo->y + platy);
#endif
ceilingz = glidesector->sector->ceilingheight;
#ifdef ESLOPE
if (glidesector->sector->c_slope)
ceilingz = P_GetZAt(glidesector->sector->c_slope, player->mo->x + platx, player->mo->y + platy);
#endif
floorz = P_GetFloorZ(player->mo, glidesector->sector, player->mo->x + platx, player->mo->y + platy, NULL);
ceilingz = P_GetCeilingZ(player->mo, glidesector->sector, player->mo->x + platx, player->mo->y + platy, NULL);
if (glidesector->sector != player->mo->subsector->sector)
{
@ -2519,7 +2475,7 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle)
fixed_t topheight = *rover->topheight;
fixed_t bottomheight = *rover->bottomheight;
/*#ifdef ESLOPE
if (rover->t_slope)
topheight = P_GetZAt(rover->t_slope, player->mo->x, player->mo->y);
@ -4046,7 +4002,7 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
fixed_t topheight = *rover->topheight;
fixed_t bottomheight = *rover->bottomheight;
/*#ifdef ESLOPE
if (rover->t_slope)
topheight = P_GetZAt(rover->t_slope, x, y);

View file

@ -21,7 +21,7 @@
#include "p_maputl.h"
#include "p_polyobj.h"
#include "z_zone.h"
#ifdef ESLOPE
#ifdef SPRINGCLEAN// ESLOPE
#include "p_slopes.h"
#endif
@ -557,26 +557,36 @@ void P_LineOpening(line_t *linedef)
I_Assert(front != NULL);
I_Assert(back != NULL);
if (front->ceilingheight < back->ceilingheight)
{
opentop = front->ceilingheight;
highceiling = back->ceilingheight;
}
else
{
opentop = back->ceilingheight;
highceiling = front->ceilingheight;
}
{ // Set open and high/low values here
fixed_t frontheight, backheight;
if (front->floorheight > back->floorheight)
{
openbottom = front->floorheight;
lowfloor = back->floorheight;
}
else
{
openbottom = back->floorheight;
lowfloor = front->floorheight;
frontheight = P_GetCeilingZ(tmthing, front, tmthing->x, tmthing->y, linedef);
backheight = P_GetCeilingZ(tmthing, back, tmthing->x, tmthing->y, linedef);
if (frontheight < backheight)
{
opentop = frontheight;
highceiling = backheight;
}
else
{
opentop = backheight;
highceiling = frontheight;
}
frontheight = P_GetFloorZ(tmthing, front, tmthing->x, tmthing->y, linedef);
backheight = P_GetFloorZ(tmthing, back, tmthing->x, tmthing->y, linedef);
if (frontheight > backheight)
{
openbottom = frontheight;
lowfloor = backheight;
}
else
{
openbottom = backheight;
lowfloor = frontheight;
}
}
if (tmthing)
@ -627,32 +637,6 @@ void P_LineOpening(line_t *linedef)
openbottom = textop;
}
}
#ifdef ESLOPE
// I suspect the math here is wrong and we should be comparing the slope Zs
// if either are slopes.
// -- Fury
if (front->c_slope && front->ceilingheight < back->ceilingheight)
{
opentop = P_GetZAt(front->c_slope, tmthing->x, tmthing->y);
if (back->c_slope) highceiling = P_GetZAt(back->c_slope, tmthing->x, tmthing->y);
}
else if (back->c_slope && front->ceilingheight >= back->ceilingheight)
{
opentop = P_GetZAt(back->c_slope, tmthing->x, tmthing->y);
if (front->c_slope) highceiling = P_GetZAt(front->c_slope, tmthing->x, tmthing->y);
}
if (front->f_slope && front->floorheight < back->floorheight)
{
openbottom = P_GetZAt(front->f_slope, tmthing->x, tmthing->y);
if (back->f_slope) lowfloor = P_GetZAt(back->f_slope, tmthing->x, tmthing->y);
}
if (back->f_slope && front->floorheight >= back->floorheight)
{
openbottom = P_GetZAt(back->f_slope, tmthing->x, tmthing->y);
if (front->f_slope) lowfloor = P_GetZAt(back->f_slope, tmthing->x, tmthing->y);
}
#endif
// Check for fake floors in the sector.
if (front->ffloors || back->ffloors
@ -889,14 +873,9 @@ void P_SetThingPosition(mobj_t *thing)
ss = thing->subsector = R_PointInSubsector(thing->x, thing->y);
fixed_t tfloorz, tceilz;
tfloorz = ss->sector->floorheight;
tceilz = ss->sector->ceilingheight;
#ifdef ESLOPE
if (ss->sector->f_slope)
tfloorz = P_GetZAt(ss->sector->f_slope, thing->x, thing->y);
if (ss->sector->c_slope)
tceilz = P_GetZAt(ss->sector->c_slope, thing->x, thing->y);
#endif
tfloorz = P_GetFloorZ(thing, ss->sector, thing->x, thing->y, NULL);
tceilz = P_GetCeilingZ(thing, ss->sector, thing->x, thing->y, NULL);
if (!(thing->flags & MF_NOSECTOR))
{

View file

@ -4584,16 +4584,8 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector)
return;
}
fixed_t f_affectpoint = sector->floorheight;
fixed_t c_affectpoint = sector->ceilingheight;
#ifdef ESLOPE
if (sector->f_slope)
f_affectpoint = P_GetZAt(sector->f_slope, player->mo->x, player->mo->y);
if (sector->c_slope)
c_affectpoint = P_GetZAt(sector->c_slope, player->mo->x, player->mo->y);
#endif
fixed_t f_affectpoint = P_GetFloorZ(player->mo, sector, player->mo->x, player->mo->y, NULL);//sector->floorheight;
fixed_t c_affectpoint = P_GetCeilingZ(player->mo, sector, player->mo->x, player->mo->y, NULL);//sector->ceilingheight;
// Only go further if on the ground
if ((sector->flags & SF_FLIPSPECIAL_FLOOR) && !(sector->flags & SF_FLIPSPECIAL_CEILING) && player->mo->z != f_affectpoint)