Remove our shadows

This commit is contained in:
Sally Cochenour 2020-03-01 17:07:52 -05:00
parent 2c67c97c58
commit c17f4dcf15
4 changed files with 162 additions and 288 deletions

View file

@ -4345,6 +4345,167 @@ void K_RepairOrbitChain(mobj_t *orbit)
}
}
// Simplified version of a code bit in P_MobjFloorZ
static fixed_t K_BananaSlopeZ(pslope_t *slope, fixed_t x, fixed_t y, fixed_t radius, boolean ceiling)
{
fixed_t testx, testy;
if (slope->d.x < 0)
testx = radius;
else
testx = -radius;
if (slope->d.y < 0)
testy = radius;
else
testy = -radius;
if ((slope->zdelta > 0) ^ !!(ceiling))
{
testx = -testx;
testy = -testy;
}
testx += x;
testy += y;
return P_GetZAt(slope, testx, testy);
}
static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, fixed_t height, boolean flip, boolean player)
{
fixed_t newz;
sector_t *sec;
#ifdef ESLOPE
pslope_t *slope = NULL;
#endif
sec = R_PointInSubsector(x, y)->sector;
if (flip)
{
#ifdef ESLOPE
if (sec->c_slope)
{
slope = sec->c_slope;
newz = K_BananaSlopeZ(slope, x, y, radius, true);
}
else
#endif
newz = sec->ceilingheight;
}
else
{
#ifdef ESLOPE
if (sec->f_slope)
{
slope = sec->f_slope;
newz = K_BananaSlopeZ(slope, x, y, radius, false);
}
else
#endif
newz = sec->floorheight;
}
// Check FOFs for a better suited slope
if (sec->ffloors)
{
ffloor_t *rover;
for (rover = sec->ffloors; rover; rover = rover->next)
{
fixed_t top, bottom;
fixed_t d1, d2;
if (!(rover->flags & FF_EXISTS))
continue;
if ((!(((rover->flags & FF_BLOCKPLAYER && player)
|| (rover->flags & FF_BLOCKOTHERS && !player))
|| (rover->flags & FF_QUICKSAND))
|| (rover->flags & FF_SWIMMABLE)))
continue;
#ifdef ESLOPE
if (*rover->t_slope)
top = K_BananaSlopeZ(*rover->t_slope, x, y, radius, false);
else
#endif
top = *rover->topheight;
#ifdef ESLOPE
if (*rover->b_slope)
bottom = K_BananaSlopeZ(*rover->b_slope, x, y, radius, true);
else
#endif
bottom = *rover->bottomheight;
if (flip)
{
if (rover->flags & FF_QUICKSAND)
{
if (z < top && (z + height) > bottom)
{
if (newz > (z + height))
{
newz = (z + height);
slope = NULL;
}
}
continue;
}
d1 = (z + height) - (top + ((bottom - top)/2));
d2 = z - (top + ((bottom - top)/2));
if (bottom < newz && abs(d1) < abs(d2))
{
newz = bottom;
#ifdef ESLOPE
if (*rover->b_slope)
slope = *rover->b_slope;
#endif
}
}
else
{
if (rover->flags & FF_QUICKSAND)
{
if (z < top && (z + height) > bottom)
{
if (newz < z)
{
newz = z;
slope = NULL;
}
}
continue;
}
d1 = z - (bottom + ((top - bottom)/2));
d2 = (z + height) - (bottom + ((top - bottom)/2));
if (top > newz && abs(d1) < abs(d2))
{
newz = top;
#ifdef ESLOPE
if (*rover->t_slope)
slope = *rover->t_slope;
#endif
}
}
}
}
#if 0
mobj->standingslope = slope;
#endif
#ifdef HWRENDER
mobj->modeltilt = slope;
#endif
}
// Move the hnext chain!
static void K_MoveHeldObjects(player_t *player)
{
@ -4532,8 +4693,7 @@ static void K_MoveHeldObjects(player_t *player)
#ifdef ESLOPE
if (P_IsObjectOnGround(cur))
{
// Slope values are set in the function, but we DON'T want to use its return value.
P_CalculateShadowFloor(cur, cur->x, cur->y, cur->z,
K_CalculateBananaSlope(cur, cur->x, cur->y, cur->z,
cur->radius, cur->height, (cur->eflags & MFE_VERTICALFLIP), false);
}
#endif

View file

@ -228,8 +228,6 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state);
boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
//void P_RunShields(void);
void P_RunOverlays(void);
fixed_t P_CalculateShadowFloor(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, fixed_t height, boolean flip, boolean player);
void P_RunShadows(void);
void P_RunBattleOvertime(void);
void P_MobjThinker(mobj_t *mobj);
boolean P_RailThinker(mobj_t *mobj);

View file

@ -47,7 +47,6 @@ consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0
actioncache_t actioncachehead;
static mobj_t *overlaycap = NULL;
static mobj_t *shadowcap = NULL;
mobj_t *waypointcap = NULL;
void P_InitCachedActions(void)
@ -6200,287 +6199,6 @@ static void P_RemoveOverlay(mobj_t *thing)
}
}
// Simplified version of a code bit in P_MobjFloorZ
static fixed_t P_ShadowSlopeZ(pslope_t *slope, fixed_t x, fixed_t y, fixed_t radius, boolean ceiling)
{
fixed_t testx, testy;
if (slope->d.x < 0)
testx = radius;
else
testx = -radius;
if (slope->d.y < 0)
testy = radius;
else
testy = -radius;
if ((slope->zdelta > 0) ^ !!(ceiling))
{
testx = -testx;
testy = -testy;
}
testx += x;
testy += y;
return P_GetZAt(slope, testx, testy);
}
// Sets standingslope/modeltilt, returns z position for shadows; used also for stuff like bananas
// (I would've preferred to be able to return both the slope & z, but I'll take what I can get...)
fixed_t P_CalculateShadowFloor(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, fixed_t height, boolean flip, boolean player)
{
fixed_t newz;
sector_t *sec;
#ifdef ESLOPE
pslope_t *slope = NULL;
#endif
sec = R_PointInSubsector(x, y)->sector;
if (flip)
{
#ifdef ESLOPE
if (sec->c_slope)
{
slope = sec->c_slope;
newz = P_ShadowSlopeZ(slope, x, y, radius, true);
}
else
#endif
newz = sec->ceilingheight;
}
else
{
#ifdef ESLOPE
if (sec->f_slope)
{
slope = sec->f_slope;
newz = P_ShadowSlopeZ(slope, x, y, radius, false);
}
else
#endif
newz = sec->floorheight;
}
// Check FOFs for a better suited slope
if (sec->ffloors)
{
ffloor_t *rover;
for (rover = sec->ffloors; rover; rover = rover->next)
{
fixed_t top, bottom;
fixed_t d1, d2;
if (!(rover->flags & FF_EXISTS))
continue;
if ((!(((rover->flags & FF_BLOCKPLAYER && player)
|| (rover->flags & FF_BLOCKOTHERS && !player))
|| (rover->flags & FF_QUICKSAND))
|| (rover->flags & FF_SWIMMABLE)))
continue;
#ifdef ESLOPE
if (*rover->t_slope)
top = P_ShadowSlopeZ(*rover->t_slope, x, y, radius, false);
else
#endif
top = *rover->topheight;
#ifdef ESLOPE
if (*rover->b_slope)
bottom = P_ShadowSlopeZ(*rover->b_slope, x, y, radius, true);
else
#endif
bottom = *rover->bottomheight;
if (flip)
{
if (rover->flags & FF_QUICKSAND)
{
if (z < top && (z + height) > bottom)
{
if (newz > (z + height))
{
newz = (z + height);
slope = NULL;
}
}
continue;
}
d1 = (z + height) - (top + ((bottom - top)/2));
d2 = z - (top + ((bottom - top)/2));
if (bottom < newz && abs(d1) < abs(d2))
{
newz = bottom;
#ifdef ESLOPE
if (*rover->b_slope)
slope = *rover->b_slope;
#endif
}
}
else
{
if (rover->flags & FF_QUICKSAND)
{
if (z < top && (z + height) > bottom)
{
if (newz < z)
{
newz = z;
slope = NULL;
}
}
continue;
}
d1 = z - (bottom + ((top - bottom)/2));
d2 = (z + height) - (bottom + ((top - bottom)/2));
if (top > newz && abs(d1) < abs(d2))
{
newz = top;
#ifdef ESLOPE
if (*rover->t_slope)
slope = *rover->t_slope;
#endif
}
}
}
}
#if 0
mobj->standingslope = slope;
#endif
#ifdef HWRENDER
mobj->modeltilt = slope;
#endif
return newz;
}
void P_RunShadows(void)
{
mobj_t *mobj, *next, *dest;
for (mobj = shadowcap; mobj; mobj = next)
{
boolean flip;
fixed_t newz;
next = mobj->hnext;
P_SetTarget(&mobj->hnext, NULL);
if (!mobj->target || P_MobjWasRemoved(mobj->target))
{
mobj->flags2 |= MF2_DONTDRAW;
continue; // shouldn't you already be dead?
}
K_MatchGenericExtraFlags(mobj, mobj->target);
flip = (mobj->eflags & MFE_VERTICALFLIP);
newz = P_CalculateShadowFloor(mobj, mobj->target->x, mobj->target->y, mobj->target->z,
mobj->target->radius, mobj->target->height, flip, (mobj->target->player != NULL));
if (flip)
{
if ((mobj->target->z + mobj->target->height) > newz)
mobj->flags2 |= MF2_DONTDRAW;
}
else
{
if (mobj->target->z < newz)
mobj->flags2 |= MF2_DONTDRAW;
}
// First scale to the same radius
P_SetScale(mobj, FixedDiv(mobj->target->radius, mobj->info->radius));
dest = mobj->target;
if (dest->type == MT_THUNDERSHIELD)
dest = dest->target;
P_TeleportMove(mobj, dest->x, dest->y, mobj->target->z);
if ((flip && newz > (mobj->z + mobj->height)) || (!flip && newz < mobj->z))
{
INT32 i;
fixed_t prevz;
mobj->z = newz;
for (i = 0; i < MAXFFLOORS; i++)
{
prevz = mobj->z;
// Now scale again based on height difference
P_SetScale(mobj, FixedDiv(mobj->scale, max(FRACUNIT, ((mobj->target->z-mobj->z)/200)+FRACUNIT)));
// Check new position to see if you should still be on that ledge
P_TeleportMove(mobj, dest->x, dest->y, mobj->z);
mobj->z = newz;
if (mobj->z == prevz)
break;
}
}
if (mobj->target->type == MT_FLOATINGITEM)
P_SetScale(mobj, mobj->scale/3);
}
P_SetTarget(&shadowcap, NULL);
}
// called whenever shadows think
// It must be done this way so that level changes don't break when the shadowcap can't be reset
static void P_AddShadow(mobj_t *thing)
{
I_Assert(thing != NULL);
if (shadowcap == NULL)
P_SetTarget(&shadowcap, thing);
else {
mobj_t *mo;
for (mo = shadowcap; mo && mo->hnext; mo = mo->hnext)
;
I_Assert(mo != NULL);
I_Assert(mo->hnext == NULL);
P_SetTarget(&mo->hnext, thing);
}
P_SetTarget(&thing->hnext, NULL);
}
// Called only when MT_SHADOW (or anything else in the shadowcap list) is removed.
// Keeps the hnext list from corrupting.
static void P_RemoveShadow(mobj_t *thing)
{
mobj_t *mo;
if (shadowcap == thing)
{
P_SetTarget(&shadowcap, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
for (mo = shadowcap; mo; mo = mo->hnext)
if (mo->hnext == thing)
{
P_SetTarget(&mo->hnext, thing->hnext);
P_SetTarget(&thing->hnext, NULL);
return;
}
}
// SAL'S KART BATTLE MODE OVERTIME HANDLER
#define MAXPLANESPERSECTOR (MAXFFLOORS+1)*2
static void P_SpawnOvertimeParticles(fixed_t x, fixed_t y, fixed_t scale, mobjtype_t type, boolean ceiling)

View file

@ -658,8 +658,6 @@ void P_Ticker(boolean run)
//P_RunShields();
P_RunOverlays();
P_RunShadows();
P_UpdateSpecials();
P_RespawnSpecials();