mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-10 19:01:50 +00:00
Shadow optimisation
Done like Overlays, goes through a list of shadows ONLY
This commit is contained in:
parent
78e2021f4b
commit
eb909dabb3
1 changed files with 88 additions and 41 deletions
75
src/p_mobj.c
75
src/p_mobj.c
|
|
@ -47,6 +47,7 @@ consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0
|
||||||
actioncache_t actioncachehead;
|
actioncache_t actioncachehead;
|
||||||
|
|
||||||
static mobj_t *overlaycap = NULL;
|
static mobj_t *overlaycap = NULL;
|
||||||
|
static mobj_t *shadowcap = NULL;
|
||||||
|
|
||||||
void P_InitCachedActions(void)
|
void P_InitCachedActions(void)
|
||||||
{
|
{
|
||||||
|
|
@ -6246,21 +6247,17 @@ static void P_RemoveOverlay(mobj_t *thing)
|
||||||
|
|
||||||
void P_RunShadows(void)
|
void P_RunShadows(void)
|
||||||
{
|
{
|
||||||
thinker_t * th;
|
mobj_t *mobj;
|
||||||
mobj_t * mobj;
|
mobj_t *next;
|
||||||
|
|
||||||
for (th = thinkercap.next; th != &thinkercap; th = th->next)
|
for (mobj = shadowcap; mobj; mobj = next)
|
||||||
{
|
{
|
||||||
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
|
next = mobj->hnext;
|
||||||
continue;
|
P_SetTarget(&mobj->hnext, NULL);
|
||||||
|
|
||||||
mobj = (mobj_t *)th;
|
if (!mobj->target)
|
||||||
|
continue; // shouldn't you already be dead?
|
||||||
|
|
||||||
if (mobj->type != MT_SHADOW)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mobj->target)
|
|
||||||
{
|
|
||||||
if ((mobj->target->flags2 & MF2_DONTDRAW)
|
if ((mobj->target->flags2 & MF2_DONTDRAW)
|
||||||
|| (((mobj->target->eflags & MFE_VERTICALFLIP) && mobj->target->z+mobj->target->height > mobj->target->ceilingz)
|
|| (((mobj->target->eflags & MFE_VERTICALFLIP) && mobj->target->z+mobj->target->height > mobj->target->ceilingz)
|
||||||
|| (!(mobj->target->eflags & MFE_VERTICALFLIP) && mobj->target->z < mobj->target->floorz)))
|
|| (!(mobj->target->eflags & MFE_VERTICALFLIP) && mobj->target->z < mobj->target->floorz)))
|
||||||
|
|
@ -6297,10 +6294,48 @@ void P_RunShadows(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
P_SetTarget(&shadowcap, NULL);
|
||||||
{
|
}
|
||||||
P_KillMobj(mobj, NULL, 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6500,6 +6535,15 @@ void P_MobjThinker(mobj_t *mobj)
|
||||||
else
|
else
|
||||||
P_AddOverlay(mobj);
|
P_AddOverlay(mobj);
|
||||||
break;
|
break;
|
||||||
|
case MT_SHADOW:
|
||||||
|
if (!mobj->target)
|
||||||
|
{
|
||||||
|
P_RemoveMobj(mobj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
P_AddShadow(mobj);
|
||||||
|
break;
|
||||||
case MT_BLACKORB:
|
case MT_BLACKORB:
|
||||||
case MT_WHITEORB:
|
case MT_WHITEORB:
|
||||||
case MT_GREENORB:
|
case MT_GREENORB:
|
||||||
|
|
@ -9007,6 +9051,9 @@ void P_RemoveMobj(mobj_t *mobj)
|
||||||
if (mobj->type == MT_OVERLAY)
|
if (mobj->type == MT_OVERLAY)
|
||||||
P_RemoveOverlay(mobj);
|
P_RemoveOverlay(mobj);
|
||||||
|
|
||||||
|
if (mobj->type == MT_SHADOW)
|
||||||
|
P_RemoveShadow(mobj);
|
||||||
|
|
||||||
mobj->health = 0; // Just because
|
mobj->health = 0; // Just because
|
||||||
|
|
||||||
// unlink from sector and block lists
|
// unlink from sector and block lists
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue