From 1078be3c3065c01067fec5f12b462b5d8ae2360e Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Mon, 6 Apr 2015 11:22:27 -0500 Subject: [PATCH 1/2] Insert polyobject planes into their proper spot in the draw list; replace related hack with other hacks --- src/p_polyobj.h | 2 ++ src/r_bsp.c | 6 ++++-- src/r_things.c | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 71cf965e..3d6576cc 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -100,6 +100,8 @@ typedef struct polyobj_s UINT8 isBad; // a bad polyobject: should not be rendered/manipulated INT32 translucency; // index to translucency tables + struct visplane_s *visplane; // polyobject's visplane, for ease of putting into the list later + // these are saved for netgames, so do not let Lua touch these! INT32 spawnflags; // Flags the polyobject originally spawned with } polyobj_t; diff --git a/src/r_bsp.c b/src/r_bsp.c index e967e28c..fb25b8e4 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -978,11 +978,12 @@ static void R_Subsector(size_t num) polysec->floorpic_angle-po->angle, NULL, NULL); - ffloor[numffloors].plane->polyobj = po; + //ffloor[numffloors].plane->polyobj = po; ffloor[numffloors].height = polysec->floorheight; ffloor[numffloors].polyobj = po; // ffloor[numffloors].ffloor = rover; + po->visplane = ffloor[numffloors].plane; numffloors++; } @@ -1014,11 +1015,12 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, polysec->lightlevel, xoff, yoff, polysec->ceilingpic_angle-po->angle, NULL, NULL); - ffloor[numffloors].plane->polyobj = po; + //ffloor[numffloors].plane->polyobj = po; ffloor[numffloors].polyobj = po; ffloor[numffloors].height = polysec->ceilingheight; // ffloor[numffloors].ffloor = rover; + po->visplane = ffloor[numffloors].plane; numffloors++; } diff --git a/src/r_things.c b/src/r_things.c index d64b6bd1..f1b2e719 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1682,6 +1682,19 @@ static void R_CreateDrawNodes(void) } if (ds->maskedtexturecol) { +#ifdef POLYOBJECTS_PLANES + // Check for a polyobject plane, but only if this is a front line + if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) { + // Put it in! + + entry = R_CreateDrawNode(&nodehead); + entry->plane = ds->curline->polyseg->visplane; + entry->seg = ds; + ds->curline->polyseg->visplane->polyobj = ds->curline->polyseg; + ds->curline->polyseg->visplane = NULL; + } +#endif + entry = R_CreateDrawNode(&nodehead); entry->seg = ds; } @@ -1698,7 +1711,7 @@ static void R_CreateDrawNodes(void) plane = ds->ffloorplanes[p]; R_PlaneBounds(plane); - if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low) + if (plane->low < con_clipviewtop || plane->high > vid.height || plane->high > plane->low || plane->polyobj) { ds->ffloorplanes[p] = NULL; continue; @@ -1809,7 +1822,7 @@ static void R_CreateDrawNodes(void) } else if (r2->seg) { -#ifdef POLYOBJECTS_PLANES +#if 0 //#ifdef POLYOBJECTS_PLANES if (r2->seg->curline->polyseg && rover->mobj && P_MobjInsidePolyobj(r2->seg->curline->polyseg, rover->mobj)) { // Determine if we need to sort in front of the polyobj, based on the planes. This fixes the issue where // polyobject planes render above the object standing on them. (A bit hacky... but it works.) -Red From 210279625a3b96250196ee7186372b9b8f8aa982 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Mon, 6 Apr 2015 11:23:08 -0500 Subject: [PATCH 2/2] Extra tiny logic fixes; swinging chains are smoother, and polyobjects can follow single-waypoint sequences --- src/p_enemy.c | 4 ++-- src/p_polyobj.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index ee244d3c..8b7af931 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -5024,7 +5024,7 @@ void A_MaceRotate(mobj_t *actor) actor->movecount += actor->target->lastlook; actor->movecount &= FINEMASK; - actor->threshold = FixedMul(FINECOSINE(actor->movecount), actor->target->lastlook); + actor->threshold = FixedMul(FINECOSINE(actor->movecount), actor->target->lastlook << FRACBITS); v[0] = FRACUNIT; v[1] = 0; @@ -5032,7 +5032,7 @@ void A_MaceRotate(mobj_t *actor) v[3] = FRACUNIT; // Calculate the angle matrixes for the link. - res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->threshold << FRACBITS))); + res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->threshold))); M_Memcpy(&v, res, sizeof(v)); res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT)); M_Memcpy(&v, res, sizeof(v)); diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bec59ae2..759eac37 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -2491,6 +2491,10 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) return 0; } + // Hotfix to not crash on single-waypoint sequences -Red + if (!last) + last = first; + // Set diffx, diffy, diffz // Put these at 0 for now...might not be needed after all. th->diffx = 0;//first->x - po->centerPt.x;