From 8d35c5064aee66f1ec038ba0f751a72e59cbf67d Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sun, 19 Apr 2015 16:54:20 -0500 Subject: [PATCH] Fix slope generation Physics seem to work at least partially, but no rendering yet (not even in OGL) --- src/p_setup.c | 8 ++++++++ src/p_slopes.c | 16 ++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index f2b0c49d8..9ddd52b58 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -72,6 +72,10 @@ #include "hardware/hw_light.h" #endif +#ifdef ESLOPE +#include "p_slopes.h" +#endif + // // Map MD5, calculated on level load. // Sent to clients in PT_SERVERINFO. @@ -1166,6 +1170,10 @@ static void P_LoadLineDefs(lumpnum_t lumpnum) #ifdef POLYOBJECTS ld->polyobj = NULL; #endif + +#ifdef ESLOPE + P_MakeLineNormal(ld); +#endif } Z_Free(data); diff --git a/src/p_slopes.c b/src/p_slopes.c index c448b580c..23ba35f58 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -185,23 +185,27 @@ static float P_GetExtent(sector_t *sector, line_t *line, v3float_t *o, v2float_t for(i = 0; i < sector->linecount; i++) { line_t *li = sector->lines[i]; + vertex_t tempv; float dist; - + // Don't compare to the slope line. if(li == line) continue; - + // ZDoom code in P_AlignPlane // dist = fabs((double(line->v1->y) - vert->y) * line->dx - (double(line->v1->x) - vert->x) * line->dy); - dist = (float)fabs((FIXED_TO_FLOAT(li->v1->x) - o->x) * d->x + (FIXED_TO_FLOAT(li->v1->y) - o->y) * d->y); + //dist = (float)fabs((FIXED_TO_FLOAT(li->v1->x) - o->x) * d->x + (FIXED_TO_FLOAT(li->v1->y) - o->y) * d->y); + P_ClosestPointOnLine(li->v1->x, li->v1->y, line, &tempv); + dist = FIXED_TO_FLOAT(R_PointToDist2(tempv.x, tempv.y, line->v1->x, line->v1->y)); if(dist > fardist) fardist = dist; - dist = (float)fabs((FIXED_TO_FLOAT(li->v2->x) - o->x) * d->x + (FIXED_TO_FLOAT(li->v2->y) - o->y) * d->y); + // We shouldn't have to do this for v2... -Red + /*dist = (float)fabs((FIXED_TO_FLOAT(li->v2->x) - o->x) * d->x + (FIXED_TO_FLOAT(li->v2->y) - o->y) * d->y); if(dist > fardist) - fardist = dist; + fardist = dist;*/ } - + return fardist; }