From 185bd2f15d4400d7bbcee836fe52d1e2c7b6d3e5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Aug 2010 07:05:31 +0000 Subject: [PATCH] - backported some 3D floor changes from GZDoom. SVN r2517 (trunk) --- src/p_3dfloors.cpp | 27 +++++++++++++++++++++++++++ src/p_3dfloors.h | 4 ++++ src/p_map.cpp | 10 ++++++++-- src/p_mobj.cpp | 30 ++++++++---------------------- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index b9b82a566..390fc23cf 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -680,5 +680,32 @@ void P_Spawn3DFloors (void) } +//========================================================================== +// +// Returns a 3D floorplane appropriate for the given coordinates +// +//========================================================================== + +secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z) +{ + secplane_t retplane = sector->floorplane; + if (sector->e) // apparently this can be called when the data is already gone + { + for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) + { + F3DFloor * rover= sector->e->XFloor.ffloors[i]; + if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; + + if (rover->top.plane->ZatPoint(x, y) == z) + { + retplane = *rover->top.plane; + if (retplane.c<0) retplane.FlipVert(); + break; + } + } + } + return retplane; +} + #endif \ No newline at end of file diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index dfaf5a5eb..4cdb14506 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -125,6 +125,8 @@ struct FLineOpening; void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx, fixed_t refy); + +secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z); #else @@ -156,6 +158,8 @@ struct FLineOpening; inline void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx, fixed_t refy) {} +//secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z){return sector->floorplane;} + #endif diff --git a/src/p_map.cpp b/src/p_map.cpp index f8c267070..2d105c284 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -655,8 +655,14 @@ bool PIT_CheckLine (line_t *ld, const FBoundingBox &box, FCheckPosition &tm) if (!(tm.thing->flags & MF_DROPOFF) && !(tm.thing->flags & (MF_NOGRAVITY|MF_NOCLIP))) { - if (ld->frontsector->floorplane.c < STEEPSLOPE || - ld->backsector->floorplane.c < STEEPSLOPE) + secplane_t frontplane = ld->frontsector->floorplane; + secplane_t backplane = ld->backsector->floorplane; +#ifdef _3DFLOORS + // Check 3D floors as well + frontplane = P_FindFloorPlane(ld->frontsector, tm.thing->x, tm.thing->y, tm.thing->floorz); + backplane = P_FindFloorPlane(ld->backsector, tm.thing->x, tm.thing->y, tm.thing->floorz); +#endif + if (frontplane.c < STEEPSLOPE || backplane.c < STEEPSLOPE) { const msecnode_t *node = tm.thing->touching_sectorlist; bool allow = false; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 39a56eced..f52067ba2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3178,41 +3178,27 @@ void AActor::Tick () velz <= 0 && floorz == z) { - const secplane_t * floorplane = &floorsector->floorplane; - static secplane_t copyplane; + secplane_t floorplane = floorsector->floorplane; #ifdef _3DFLOORS // Check 3D floors as well - if (floorsector->e) // apparently this can be called when the data is already gone- - for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) - { - F3DFloor * rover= floorsector->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - - if (rover->top.plane->ZatPoint(x, y) == floorz) - { - copyplane = *rover->top.plane; - if (copyplane.c<0) copyplane.FlipVert(); - floorplane = ©plane; - break; - } - } + floorplane = P_FindFloorPlane(floorsector, x, y, floorz); #endif - if (floorplane->c < STEEPSLOPE && - floorplane->ZatPoint (x, y) <= floorz) + if (floorplane.c < STEEPSLOPE && + floorplane.ZatPoint (x, y) <= floorz) { const msecnode_t *node; bool dopush = true; - if (floorplane->c > STEEPSLOPE*2/3) + if (floorplane.c > STEEPSLOPE*2/3) { for (node = touching_sectorlist; node; node = node->m_tnext) { const sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - if (floorplane->ZatPoint (x, y) >= z - MaxStepHeight) + if (floorplane.ZatPoint (x, y) >= z - MaxStepHeight) { dopush = false; break; @@ -3222,8 +3208,8 @@ void AActor::Tick () } if (dopush) { - velx += floorplane->a; - vely += floorplane->b; + velx += floorplane.a; + vely += floorplane.b; } } }