From 85f5cb20e6b88aa6ee26b75de186d6e669f92e49 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sun, 26 Jul 2020 21:25:11 +0300 Subject: [PATCH] Fix sector flat alignment issues in OpenGL --- src/hardware/hw_main.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0d7404c77..f73125e6e 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -491,7 +491,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool if (angle) // Only needs to be done if there's an altered angle { - angle = (InvAngle(angle)+ANGLE_180)>>ANGLETOFINESHIFT; + angle = (InvAngle(angle))>>ANGLETOFINESHIFT; // This needs to be done so that it scrolls in a different direction after rotation like software /*tempxsow = FLOAT_TO_FIXED(scrollx); @@ -525,8 +525,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool {\ tempxsow = FLOAT_TO_FIXED(vert->s);\ tempytow = FLOAT_TO_FIXED(vert->t);\ - if (texflat)\ - tempytow = -tempytow;\ vert->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ vert->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ }\ @@ -2769,13 +2767,13 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatwidth; scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatheight; - angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT; + angle = FOFsector->floorpic_angle; } else // it's a ceiling { scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatwidth; scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatheight; - angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT; + angle = FOFsector->ceilingpic_angle; } } else if (gl_frontsector) @@ -2784,23 +2782,25 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatwidth; scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatheight; - angle = gl_frontsector->floorpic_angle>>ANGLETOFINESHIFT; + angle = gl_frontsector->floorpic_angle; } else // it's a ceiling { scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatwidth; scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatheight; - angle = gl_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; + angle = gl_frontsector->ceilingpic_angle; } } if (angle) // Only needs to be done if there's an altered angle { + angle = (InvAngle(angle))>>ANGLETOFINESHIFT; + // This needs to be done so that it scrolls in a different direction after rotation like software - tempxs = FLOAT_TO_FIXED(scrollx); + /*tempxs = FLOAT_TO_FIXED(scrollx); tempyt = FLOAT_TO_FIXED(scrolly); scrollx = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle)))); + scrolly = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle))));*/ // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does @@ -2830,10 +2830,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { tempxs = FLOAT_TO_FIXED(v3d->s); tempyt = FLOAT_TO_FIXED(v3d->t); - if (texflat) - tempyt = -tempyt; v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxs, FINECOSINE(angle)) - FixedMul(tempyt, FINESINE(angle)))); - v3d->t = (FIXED_TO_FLOAT(-FixedMul(tempxs, FINESINE(angle)) - FixedMul(tempyt, FINECOSINE(angle)))); + v3d->t = (FIXED_TO_FLOAT(FixedMul(tempxs, FINESINE(angle)) + FixedMul(tempyt, FINECOSINE(angle)))); } v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x);