Various bouncing fixes

Fixed bounce flag checks being inversed on 3D floors. Decoupled wall bouncing flag from floor/ceiling flags since they relied on it in the case of hitting steep ramps. Fixed wall bounces that actually bounce off planes not returning the correct value.
This commit is contained in:
Boondorl 2024-11-26 23:43:21 -05:00 committed by Rachael Alexanderson
parent 0010f22faa
commit 72ed0c4377
2 changed files with 15 additions and 11 deletions

View file

@ -3552,7 +3552,9 @@ bool FSlide::BounceWall(AActor *mo)
double movelen; double movelen;
line_t *line; line_t *line;
if (!(mo->BounceFlags & BOUNCE_Walls)) // The plane bounce flags need to be checked here in case it hit a ramp while
// moving along the xy axes.
if (!(mo->BounceFlags & (BOUNCE_Walls | BOUNCE_Ceilings | BOUNCE_Floors)))
{ {
return false; return false;
} }
@ -3587,16 +3589,18 @@ bool FSlide::BounceWall(AActor *mo)
if (floordist <= ceildist) if (floordist <= ceildist)
{ {
NextLowestFloorAt(mo->Sector, mo->X(), mo->Y(), mo->Z(), 0, mo->MaxStepHeight, nullptr, &ff); NextLowestFloorAt(mo->Sector, mo->X(), mo->Y(), mo->Z(), 0, mo->MaxStepHeight, nullptr, &ff);
mo->FloorBounceMissile(ff != nullptr ? *ff->top.plane : mo->floorsector->floorplane, ff != nullptr); return !mo->FloorBounceMissile(ff != nullptr ? *ff->top.plane : mo->floorsector->floorplane, ff != nullptr);
return true;
} }
else else
{ {
NextHighestCeilingAt(mo->Sector, mo->X(), mo->Y(), mo->Z(), mo->Top(), 0, nullptr, &ff); NextHighestCeilingAt(mo->Sector, mo->X(), mo->Y(), mo->Z(), mo->Top(), 0, nullptr, &ff);
mo->FloorBounceMissile(ff != nullptr ? *ff->bottom.plane : mo->ceilingsector->ceilingplane, ff != nullptr); return !mo->FloorBounceMissile(ff != nullptr ? *ff->bottom.plane : mo->ceilingsector->ceilingplane, ff != nullptr);
return true;
} }
} }
if (!(mo->BounceFlags & BOUNCE_Walls))
return false;
line = bestslideline; line = bestslideline;
if (mo->flags & MF_MISSILE) if (mo->flags & MF_MISSILE)

View file

@ -1782,9 +1782,13 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
} }
} }
DVector3 norm = plane.Normal();
if (is3DFloor)
norm = -norm;
bool onsky; bool onsky;
if (plane.fC() < 0) if (norm.Z < 0)
{ // on ceiling { // on ceiling
if (!(BounceFlags & BOUNCE_Ceilings)) if (!(BounceFlags & BOUNCE_Ceilings))
return true; return true;
@ -1815,10 +1819,6 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
return true; return true;
} }
DVector3 norm = plane.Normal();
if (is3DFloor)
norm = -norm;
double dot = (Vel | norm) * 2; double dot = (Vel | norm) * 2;
if (BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF)) if (BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF))
@ -1846,7 +1846,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
// Set bounce state // Set bounce state
if (BounceFlags & BOUNCE_UseBounceState) if (BounceFlags & BOUNCE_UseBounceState)
{ {
FName names[2] = { NAME_Bounce, plane.fC() < 0 ? NAME_Ceiling : NAME_Floor }; FName names[2] = { NAME_Bounce, norm.Z < 0 ? NAME_Ceiling : NAME_Floor };
FState *bouncestate = FindState(2, names); FState *bouncestate = FindState(2, names);
if (bouncestate != nullptr) if (bouncestate != nullptr)
{ {