diff --git a/src/am_map.cpp b/src/am_map.cpp index b0ae28a13..28bd27aff 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1974,8 +1974,8 @@ void AM_drawSubsectors() } else { - secx = FIXED2DBL(sec->soundorg[0]); - secy = FIXED2DBL(sec->soundorg[1]); + secx = FIXED2DBL(sec->centerspot.x); + secy = FIXED2DBL(sec->centerspot.y); } seczb = floorplane->ZatPoint(secx, secy); seczt = sec->ceilingplane.ZatPoint(secx, secy); diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index e30c76326..677694193 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1615,7 +1615,7 @@ void FParser::SF_FloorHeight(void) DFloorChanger * f = new DFloorChanger(§ors[i]); if (!f->Move( abs(dest - sectors[i].CenterFloor()), - sectors[i].floorplane.PointToDist (CenterSpot(§ors[i]), dest), + sectors[i].floorplane.PointToDist (sectors[i].centerspot, dest), crush? 10:-1, (dest > sectors[i].CenterFloor()) ? 1 : -1)) { @@ -1699,7 +1699,7 @@ void FParser::SF_MoveFloor(void) // Don't start a second thinker on the same floor if (sec->floordata) continue; - new DMoveFloor(sec,sec->floorplane.PointToDist(CenterSpot(sec),destheight), + new DMoveFloor(sec,sec->floorplane.PointToDist(sec->centerspot,destheight), destheight < sec->CenterFloor() ? -1:1,crush,platspeed); } } @@ -1763,7 +1763,7 @@ void FParser::SF_CeilingHeight(void) DCeilingChanger * c = new DCeilingChanger(§ors[i]); if (!c->Move( abs(dest - sectors[i].CenterCeiling()), - sectors[i].ceilingplane.PointToDist (CenterSpot(§ors[i]), dest), + sectors[i].ceilingplane.PointToDist (sectors[i].centerspot, dest), crush? 10:-1, (dest > sectors[i].CenterCeiling()) ? 1 : -1)) { @@ -1807,8 +1807,7 @@ public: m_Silent = silent; m_Type = DCeiling::ceilLowerByValue; // doesn't really matter as long as it's no special value m_Tag=tag; - vertex_t * spot=CenterSpot(sec); - m_TopHeight=m_BottomHeight=sec->ceilingplane.PointToDist(spot,destheight); + m_TopHeight=m_BottomHeight=sec->ceilingplane.PointToDist(sec->centerspot,destheight); m_Direction=destheight>sec->GetPlaneTexZ(sector_t::ceiling)? 1:-1; // Do not interpolate instant movement ceilings. diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index cec3b1c50..a11705152 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -476,13 +476,13 @@ void P_Recalculate3DFloors(sector_t * sector) while (oldlist.Size()) { pick=oldlist[0]; - fixed_t height=pick->top.plane->ZatPoint(CenterSpot(sector)); + fixed_t height=pick->top.plane->ZatPoint(sector->centerspot); // find highest starting ffloor - intersections are not supported! pickindex=0; for (j=1;jtop.plane->ZatPoint(CenterSpot(sector)); + fixed_t h2=oldlist[j]->top.plane->ZatPoint(sector->centerspot); if (h2>height) { @@ -493,7 +493,7 @@ void P_Recalculate3DFloors(sector_t * sector) } oldlist.Delete(pickindex); - fixed_t pick_bottom=pick->bottom.plane->ZatPoint(CenterSpot(sector)); + fixed_t pick_bottom=pick->bottom.plane->ZatPoint(sector->centerspot); if (pick->flags & FF_THISINSIDE) { @@ -607,7 +607,7 @@ void P_Recalculate3DFloors(sector_t * sector) if ( !(rover->flags & FF_EXISTS) || rover->flags & FF_NOSHADE ) continue; - fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); + fixed_t ff_top=rover->top.plane->ZatPoint(sector->centerspot); if (ff_top < minheight) break; // reached the floor if (ff_top < maxheight) { @@ -622,7 +622,7 @@ void P_Recalculate3DFloors(sector_t * sector) } else { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); if (ff_bottomflags&FF_DOUBLESHADOW) { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); if(ff_bottom < maxheight && ff_bottom>minheight) { newlight.caster = rover; @@ -736,11 +736,11 @@ lightlist_t * P_GetPlaneLight(sector_t * sector, secplane_t * plane, bool unders unsigned i; TArray &lightlist = sector->e->XFloor.lightlist; - fixed_t planeheight=plane->ZatPoint(CenterSpot(sector)); + fixed_t planeheight=plane->ZatPoint(sector->centerspot); if(underside) planeheight--; for(i = 1; i < lightlist.Size(); i++) - if (lightlist[i].plane.ZatPoint(CenterSpot(sector)) <= planeheight) + if (lightlist[i].plane.ZatPoint(sector->centerspot) <= planeheight) return &lightlist[i - 1]; return &lightlist[lightlist.Size() - 1]; @@ -1000,8 +1000,8 @@ CCMD (dump3df) for (unsigned int i = 0; i < ffloors.Size(); i++) { - fixed_t height=ffloors[i]->top.plane->ZatPoint(CenterSpot(sector)); - fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(CenterSpot(sector)); + fixed_t height=ffloors[i]->top.plane->ZatPoint(sector->centerspot); + fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(sector->centerspot); IGNORE_FORMAT_PRE Printf("FFloor %d @ top = %f (model = %d), bottom = %f (model = %d), flags = %B, alpha = %d %s %s\n", diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 51761d31b..fcfbb63d0 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -2,8 +2,6 @@ #define __SECTORE_H -#define CenterSpot(sec) (vertex_t*)&(sec)->soundorg[0] - // 3D floor flags. Most are the same as in Legacy but I added some for EDGE's and Vavoom's features as well. typedef enum { diff --git a/src/p_floor.cpp b/src/p_floor.cpp index d91c05170..86a54dc0d 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -343,16 +343,16 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, floor->m_Speed = height; case DFloor::floorLowerByValue: floor->m_Direction = -1; - newheight = sec->floorplane.ZatPoint (sec->soundorg[0], sec->soundorg[1]) - height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], newheight); + newheight = sec->CenterFloor() - height; + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); break; case DFloor::floorRaiseInstant: floor->m_Speed = height; case DFloor::floorRaiseByValue: floor->m_Direction = 1; - newheight = sec->floorplane.ZatPoint (sec->soundorg[0], sec->soundorg[1]) + height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], newheight); + newheight = sec->CenterFloor() + height; + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); break; case DFloor::floorMoveToValue: @@ -412,8 +412,8 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, case DFloor::floorLowerByTexture: floor->m_Direction = -1; - newheight = sec->floorplane.ZatPoint (sec->soundorg[0], sec->soundorg[1]) - sec->FindShortestTextureAround (); - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], newheight); + newheight = sec->CenterFloor() - sec->FindShortestTextureAround (); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); break; case DFloor::floorLowerToCeiling: @@ -429,14 +429,14 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, // since the code is identical to what was here. (Oddly // enough, BOOM preserved the code here even though it // also had this function.) - newheight = sec->floorplane.ZatPoint (sec->soundorg[0], sec->soundorg[1]) + sec->FindShortestTextureAround (); - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], newheight); + newheight = sec->CenterFloor() + sec->FindShortestTextureAround (); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); break; case DFloor::floorRaiseAndChange: floor->m_Direction = 1; - newheight = sec->floorplane.ZatPoint (sec->soundorg[0], sec->soundorg[1]) + height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], newheight); + newheight = sec->CenterFloor() + height; + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); if (line != NULL) { FTextureID oldpic = sec->GetTexture(sector_t::floor); @@ -619,8 +619,8 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, floor->m_Hexencrush = false; floor->m_Speed = speed; - height = sec->floorplane.ZatPoint (sec->soundorg[0], sec->soundorg[1]) + stairstep; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], height); + height = sec->CenterFloor() + stairstep; + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, height); texture = sec->GetTexture(sector_t::floor); osecnum = secnum; //jff 3/4/98 preserve loop index @@ -1037,15 +1037,15 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype, // [RH] elevate up by a specific amount case DElevator::elevateRaise: elevator->m_Direction = 1; - elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], floorheight + height); - elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->soundorg[0], sec->soundorg[1], ceilingheight + height); + elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, floorheight + height); + elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->centerspot, ceilingheight + height); break; // [RH] elevate down by a specific amount case DElevator::elevateLower: elevator->m_Direction = -1; - elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->soundorg[0], sec->soundorg[1], floorheight - height); - elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->soundorg[0], sec->soundorg[1], ceilingheight - height); + elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, floorheight - height); + elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->centerspot, ceilingheight - height); break; } } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 1af76d6d9..8a65c31b4 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3273,8 +3273,8 @@ FUNC(LS_GlassBreak) x = ln->v1->x + ln->dx/2; y = ln->v1->y + ln->dy/2; - x += (ln->frontsector->soundorg[0] - x) / 5; - y += (ln->frontsector->soundorg[1] - y) / 5; + x += (ln->frontsector->centerspot.x - x) / 5; + y += (ln->frontsector->centerspot.y - y) / 5; for (int i = 0; i < 7; ++i) { diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index b1cae3af9..8ac1759ed 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -144,15 +144,15 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed, if (floordist == 0) { newheight = (sector->CenterFloor () + sector->CenterCeiling ()) / 2; - m_FloorTarget = sector->floorplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight); - m_CeilingTarget = sector->ceilingplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight); + m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight); + m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight); floordist = newheight - sector->CenterFloor (); } else { newheight = sector->CenterFloor () + floordist; - m_FloorTarget = sector->floorplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight); - m_CeilingTarget = sector->ceilingplane.PointToDist (sector->soundorg[0], sector->soundorg[1], newheight); + m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight); + m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight); } ceilingdist = sector->CenterCeiling () - newheight; } @@ -168,8 +168,8 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed, } else { - newheight = sector->floorplane.ZatPoint (0, 0) - floordist; - m_FloorTarget = sector->floorplane.PointToDist (0, 0, newheight); + newheight = sector->CenterFloor() - floordist; + m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight); } if (ceilingdist == 0) { @@ -179,8 +179,8 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed, } else { - newheight = sector->ceilingplane.ZatPoint (0, 0) + ceilingdist; - m_CeilingTarget = sector->ceilingplane.PointToDist (0, 0, newheight); + newheight = sector->CenterCeiling() + ceilingdist; + m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight); } } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index b1cb43c25..e5da17126 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3221,9 +3221,9 @@ static void P_GroupLines (bool buildmap) } } - // set the soundorg to the middle of the bounding box - sector->soundorg[0] = bbox.Right()/2 + bbox.Left()/2; - sector->soundorg[1] = bbox.Top()/2 + bbox.Bottom()/2; + // set the center to the middle of the bounding box + sector->centerspot.x = bbox.Right()/2 + bbox.Left()/2; + sector->centerspot.y = bbox.Top()/2 + bbox.Bottom()/2; // For triangular sectors the above does not calculate good points unless the longest of the triangle's lines is perfectly horizontal and vertical if (sector->linecount == 3) @@ -3245,8 +3245,8 @@ static void P_GroupLines (bool buildmap) if (DMulScale32 (v->y - Triangle[0]->y, dx, Triangle[0]->x - v->x, dy) != 0) { - sector->soundorg[0] = Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3; - sector->soundorg[1] = Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3; + sector->centerspot.x = Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3; + sector->centerspot.y = Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3; break; } } diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index a95bd97a0..51e89ac9e 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1182,9 +1182,9 @@ void R_Subsector (subsector_t *sub) fakeFloor->validcount = validcount; R_3D_NewClip(); } - fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->soundorg[0], frontsector->soundorg[0]); + fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot); if (fakeHeight < viewz && - fakeHeight > frontsector->floorplane.ZatPoint(frontsector->soundorg[0], frontsector->soundorg[1])) + fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)) { fake3D = FAKE3D_FAKEFLOOR; tempsec = *fakeFloor->model; @@ -1244,9 +1244,9 @@ void R_Subsector (subsector_t *sub) fakeFloor->validcount = validcount; R_3D_NewClip(); } - fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->soundorg[0], frontsector->soundorg[1]); + fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot); if (fakeHeight > viewz && - fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->soundorg[0], frontsector->soundorg[1])) + fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)) { fake3D = FAKE3D_FAKECEILING; tempsec = *fakeFloor->model; diff --git a/src/r_defs.h b/src/r_defs.h index ab55201f9..a25179fb1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -340,6 +340,11 @@ struct secplane_t return -TMulScale16 (a, x, y, b, z, c); } + fixed_t PointToDist(fixedvec2 xy, fixed_t z) const + { + return -TMulScale16(a, xy.x, xy.y, b, z, c); + } + fixed_t PointToDist (const vertex_t *v, fixed_t z) const { return -TMulScale16 (a, v->x, b, v->y, z, c); @@ -825,8 +830,8 @@ struct sector_t } // Member variables - fixed_t CenterFloor () const { return floorplane.ZatPoint (soundorg[0], soundorg[1]); } - fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (soundorg[0], soundorg[1]); } + fixed_t CenterFloor () const { return floorplane.ZatPoint (centerspot); } + fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (centerspot); } // [RH] store floor and ceiling planes instead of heights secplane_t floorplane, ceilingplane; @@ -844,7 +849,7 @@ struct sector_t int sky; FNameNoInit SeqName; // Sound sequence name. Setting seqType non-negative will override this. - fixed_t soundorg[2]; // origin for any sounds played by the sector + fixedvec2 centerspot; // origin for any sounds played by the sector int validcount; // if == validcount, already checked AActor* thinglist; // list of mobjs in sector diff --git a/src/s_sound.cpp b/src/s_sound.cpp index e61a0f701..7db77375d 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -709,8 +709,8 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, } else { - x = sector->soundorg[0]; - z = sector->soundorg[1]; + x = sector->centerspot.x; + z = sector->centerspot.y; chanflags |= CHAN_LISTENERZ; } } @@ -776,8 +776,8 @@ static void CalcSectorSoundOrg(const sector_t *sec, int channum, fixed_t *x, fix } else { - *x = sec->soundorg[0]; - *y = sec->soundorg[1]; + *x = sec->centerspot.x; + *y = sec->centerspot.y; } // Set sound vertical position based on channel.