mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- Use tests less prone to overflow on very steep slopes when detecting which side of a plane
the camera is on. Mostly, this means testing the distance of the camera to the plane rather than computing the plane's Z at the camera and comparing that with the camera's Z. SVN r4220 (trunk)
This commit is contained in:
parent
c069295f19
commit
a50e670c0c
6 changed files with 30 additions and 24 deletions
|
@ -348,7 +348,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
|
|||
int realgibhealth = realthis->GibHealth();
|
||||
if (realthis->health >= realgibhealth)
|
||||
{
|
||||
realthis->health = realgibhealth -1; // if morphed was gibbed, so must original be (where allowed)
|
||||
realthis->health = realgibhealth -1; // if morphed was gibbed, so must original be (where allowed)l
|
||||
}
|
||||
}
|
||||
realthis->Die(source, inflictor, dmgflags);
|
||||
|
|
|
@ -346,7 +346,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
|
|||
{
|
||||
sector_t *heightsec = viewsector->heightsec;
|
||||
bool underwater = r_fakingunderwater ||
|
||||
(heightsec && viewz <= heightsec->floorplane.ZatPoint (viewx, viewy));
|
||||
(heightsec && heightsec->floorplane.PointOnSide(viewx, viewy, viewz) <= 0);
|
||||
bool doorunderwater = false;
|
||||
int diffTex = (s->MoreFlags & SECF_CLIPFAKEPLANES);
|
||||
|
||||
|
@ -405,9 +405,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
|
|||
}
|
||||
}
|
||||
|
||||
// fixed_t refflorz = s->floorplane.ZatPoint (viewx, viewy);
|
||||
fixed_t refceilz = s->ceilingplane.ZatPoint (viewx, viewy);
|
||||
// fixed_t orgflorz = sec->floorplane.ZatPoint (viewx, viewy);
|
||||
fixed_t orgceilz = sec->ceilingplane.ZatPoint (viewx, viewy);
|
||||
|
||||
#if 1
|
||||
|
@ -482,7 +480,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
|
|||
}
|
||||
FakeSide = FAKED_BelowFloor;
|
||||
}
|
||||
else if (heightsec && viewz >= heightsec->ceilingplane.ZatPoint (viewx, viewy) &&
|
||||
else if (heightsec && heightsec->ceilingplane.PointOnSide(viewx, viewy, viewz) <= 0 &&
|
||||
orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY))
|
||||
{ // Above-ceiling hack
|
||||
tempsec->ceilingplane = s->ceilingplane;
|
||||
|
@ -1084,7 +1082,7 @@ void R_Subsector (subsector_t *sub)
|
|||
basecolormap = frontsector->ColorMap;
|
||||
}
|
||||
|
||||
ceilingplane = frontsector->ceilingplane.ZatPoint (viewx, viewy) > viewz ||
|
||||
ceilingplane = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz) > 0 ||
|
||||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum ||
|
||||
(frontsector->CeilingSkyBox != NULL && frontsector->CeilingSkyBox->bAlways) ||
|
||||
(frontsector->heightsec &&
|
||||
|
@ -1123,7 +1121,7 @@ void R_Subsector (subsector_t *sub)
|
|||
// killough 3/7/98: Add (x,y) offsets to flats, add deep water check
|
||||
// killough 3/16/98: add floorlightlevel
|
||||
// killough 10/98: add support for skies transferred from sidedefs
|
||||
floorplane = frontsector->floorplane.ZatPoint (viewx, viewy) < viewz || // killough 3/7/98
|
||||
floorplane = frontsector->floorplane.PointOnSide(viewx, viewy, viewz) > 0 || // killough 3/7/98
|
||||
frontsector->GetTexture(sector_t::floor) == skyflatnum ||
|
||||
(frontsector->FloorSkyBox != NULL && frontsector->FloorSkyBox->bAlways) ||
|
||||
(frontsector->heightsec &&
|
||||
|
|
|
@ -212,10 +212,16 @@ struct secplane_t
|
|||
|
||||
fixed_t a, b, c, d, ic;
|
||||
|
||||
// Returns < 0 : behind; == 0 : on; > 0 : in front
|
||||
int PointOnSide (fixed_t x, fixed_t y, fixed_t z) const
|
||||
{
|
||||
return TMulScale16(a,x, b,y, c,z) + d;
|
||||
}
|
||||
|
||||
// Returns the value of z at (0,0) This is used by the 3D floor code which does not handle slopes
|
||||
fixed_t Zat0 () const
|
||||
{
|
||||
return ic < 0? d:-d;
|
||||
return ic < 0 ? d : -d;
|
||||
}
|
||||
|
||||
// Returns the value of z at (x,y)
|
||||
|
|
|
@ -1697,7 +1697,7 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
|
|||
plane_sz[0] = -plane_sz[0];
|
||||
}
|
||||
|
||||
planelightfloat = (r_TiltVisibility * lxscale * lyscale) / (float)(abs(pl->height.ZatPoint (viewx, viewy) - viewz));
|
||||
planelightfloat = (r_TiltVisibility * lxscale * lyscale) / (fabs(pl->height.ZatPoint(FIXED2DBL(viewx), FIXED2DBL(viewy)) - FIXED2DBL(viewz))) / 65536.0;
|
||||
|
||||
if (pl->height.c > 0)
|
||||
planelightfloat = -planelightfloat;
|
||||
|
|
|
@ -2242,10 +2242,10 @@ void R_NewWall (bool needlights)
|
|||
// killough 3/7/98: add deep water check
|
||||
if (frontsector->GetHeightSec() == NULL)
|
||||
{
|
||||
if (frontsector->floorplane.ZatPoint (viewx, viewy) >= viewz) // above view plane
|
||||
if (frontsector->floorplane.PointOnSide(viewx, viewy, viewz) <= 0) // above view plane
|
||||
markfloor = false;
|
||||
if (frontsector->ceilingplane.ZatPoint (viewx, viewy) <= viewz &&
|
||||
frontsector->GetTexture(sector_t::ceiling) != skyflatnum) // below view plane
|
||||
if (frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz) <= 0 &&
|
||||
frontsector->GetTexture(sector_t::ceiling) != skyflatnum) // below view plane
|
||||
markceiling = false;
|
||||
}
|
||||
|
||||
|
@ -2394,13 +2394,13 @@ void R_StoreWallRange (int start, int stop)
|
|||
ds_p->silhouette = 0;
|
||||
|
||||
if (rw_frontfz1 > rw_backfz1 || rw_frontfz2 > rw_backfz2 ||
|
||||
backsector->floorplane.ZatPoint (viewx, viewy) > viewz)
|
||||
backsector->floorplane.PointOnSide(viewx, viewy, viewz) < 0)
|
||||
{
|
||||
ds_p->silhouette = SIL_BOTTOM;
|
||||
}
|
||||
|
||||
if (rw_frontcz1 < rw_backcz1 || rw_frontcz2 < rw_backcz2 ||
|
||||
backsector->ceilingplane.ZatPoint (viewx, viewy) < viewz)
|
||||
backsector->ceilingplane.PointOnSide(viewx, viewy, viewz) < 0)
|
||||
{
|
||||
ds_p->silhouette |= SIL_TOP;
|
||||
}
|
||||
|
|
|
@ -849,15 +849,17 @@ void R_SetupFrame (AActor *actor)
|
|||
TArray<lightlist_t> &lightlist = viewsector->e->XFloor.lightlist;
|
||||
if (lightlist.Size() > 0)
|
||||
{
|
||||
for(unsigned int i=0;i<lightlist.Size();i++)
|
||||
for(unsigned int i = 0; i < lightlist.Size(); i++)
|
||||
{
|
||||
fixed_t lightbottom;
|
||||
if (i<lightlist.Size()-1)
|
||||
lightbottom = lightlist[i+1].plane.ZatPoint(viewx, viewy);
|
||||
else
|
||||
lightbottom = viewsector->floorplane.ZatPoint(viewx, viewy);
|
||||
|
||||
if (lightbottom < viewz)
|
||||
secplane_t *plane;
|
||||
int viewside;
|
||||
plane = (i < lightlist.Size()-1) ? &lightlist[i+1].plane : &viewsector->floorplane;
|
||||
viewside = plane->PointOnSide(viewx, viewy, viewz);
|
||||
// Reverse the direction of the test if the plane was downward facing.
|
||||
// We want to know if the view is above it, whatever its orientation may be.
|
||||
if (plane->c < 0)
|
||||
viewside = -viewside;
|
||||
if (viewside > 0)
|
||||
{
|
||||
// 3d floor 'fog' is rendered as a blending value
|
||||
PalEntry blendv = lightlist[i].blend;
|
||||
|
@ -874,9 +876,9 @@ void R_SetupFrame (AActor *actor)
|
|||
const sector_t *s = viewsector->GetHeightSec();
|
||||
if (s != NULL)
|
||||
{
|
||||
newblend = viewz < s->floorplane.ZatPoint (viewx, viewy)
|
||||
newblend = s->floorplane.PointOnSide(viewx, viewy, viewz) < 0
|
||||
? s->bottommap
|
||||
: viewz > s->ceilingplane.ZatPoint (viewx, viewy)
|
||||
: s->ceilingplane.PointOnSide(viewx, viewy, viewz) < 0
|
||||
? s->topmap
|
||||
: s->midmap;
|
||||
if (APART(newblend) == 0 && newblend >= numfakecmaps)
|
||||
|
|
Loading…
Reference in a new issue