From fede16ce68f3d9a21cf529396bf22e7914daecd5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 13:15:02 +0200 Subject: [PATCH] - fixed PointOnSide checks. - optimized some ZatPoint calls for floating point planes. --- src/p_maputl.h | 8 ++++---- src/r_things.cpp | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/p_maputl.h b/src/p_maputl.h index e075f5f6d..d53ab49a7 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -38,12 +38,12 @@ struct intercept_t inline int P_PointOnLineSidePrecise(double x, double y, const line_t *line) { - return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > EQUAL_EPSILON; + return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > -EQUAL_EPSILON; } inline int P_PointOnLineSidePrecise(const DVector2 &pt, const line_t *line) { - return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > EQUAL_EPSILON; + return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > -EQUAL_EPSILON; } inline int P_PointOnLineSide (double x, double y, const line_t *line) @@ -73,12 +73,12 @@ inline int P_PointOnLineSide(const DVector2 & p, const line_t *line) inline int P_PointOnDivlineSide(double x, double y, const divline_t *line) { - return (y - line->y) * line->dx + (line->x - x) * line->dy > EQUAL_EPSILON; + return (y - line->y) * line->dx + (line->x - x) * line->dy > -EQUAL_EPSILON; } inline int P_PointOnDivlineSide(const DVector2 &pos, const divline_t *line) { - return (pos.Y - line->y) * line->dx + (line->x - pos.X) * line->dy > EQUAL_EPSILON; + return (pos.Y - line->y) * line->dx + (line->x - pos.X) * line->dy > -EQUAL_EPSILON; } //========================================================================== diff --git a/src/r_things.cpp b/src/r_things.cpp index 7eb1095da..465b6c30f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -728,7 +728,6 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling) { - fixed_t fx, fy, fz; fixed_t tr_x; fixed_t tr_y; @@ -768,9 +767,9 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor // [RH] Interpolate the sprite's position to make it look smooth DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - fx = FLOAT2FIXED(pos.X); - fy = FLOAT2FIXED(pos.Y); - fz = FLOAT2FIXED(pos.Z + thing->GetBobOffset(r_TicFracF)); + const fixed_t fx = FLOAT2FIXED(pos.X); + const fixed_t fy = FLOAT2FIXED(pos.Y); + fixed_t fz = FLOAT2FIXED(pos.Z + thing->GetBobOffset(r_TicFracF)); tex = NULL; voxel = NULL; @@ -937,19 +936,19 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor { if (fakeside == FAKED_AboveCeiling) { - if (gzt < heightsec->ceilingplane.ZatPointFixed(fx, fy)) + if (gzt < heightsec->ceilingplane.ZatPointFixed(pos)) return; } else if (fakeside == FAKED_BelowFloor) { - if (gzb >= heightsec->floorplane.ZatPointFixed(fx, fy)) + if (gzb >= heightsec->floorplane.ZatPointFixed(pos)) return; } else { - if (gzt < heightsec->floorplane.ZatPointFixed(fx, fy)) + if (gzt < heightsec->floorplane.ZatPointFixed(pos)) return; - if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPointFixed(fx, fy)) + if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPointFixed(pos)) return; } }