From 6653b9697f6de62a06eeb3a7809076499f2f7c6a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 19 Dec 2018 00:17:51 -0500 Subject: [PATCH] Hide/add Kart FTransform mirror and anglez behind ifdef --- src/hardware/hw_defs.h | 11 +++++++++++ src/hardware/hw_md2.c | 7 ++++++- src/hardware/r_opengl/r_opengl.c | 22 ++++++++++++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index ece627d3..fc6ae348 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -101,15 +101,26 @@ typedef struct //Hurdler: Transform (coords + angles) //BP: transform order : scale(rotation_x(rotation_y(translation(v)))) + +// Kart features +#define USE_FTRANSFORM_ANGLEZ +#define USE_FTRANSFORM_MIRROR + typedef struct { FLOAT x,y,z; // position +#ifdef USE_FTRANSFORM_ANGLEZ FLOAT anglex,angley,anglez; // aimingangle / viewangle +#else + FLOAT anglex,angley; // aimingangle / viewangle +#endif FLOAT scalex,scaley,scalez; FLOAT fovxangle, fovyangle; UINT8 splitscreen; boolean flip; // screenflip +#ifdef USE_FTRANSFORM_MIRROR boolean mirror; // SRB2Kart: Encore Mode +#endif } FTransform; // Transformed vector, as passed to HWR API diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 6cba468e..10e2847f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1048,6 +1048,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr) p.angley = FIXED_TO_FLOAT(anglef); } p.anglex = 0.0f; +#ifdef USE_FTRANSFORM_ANGLEZ + // Slope rotation from Kart p.anglez = 0.0f; if (spr->mobj->standingslope) { @@ -1059,6 +1061,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr) tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy)); p.anglex = FIXED_TO_FLOAT(tempangle); } +#endif color[0] = Surf.FlatColor.s.red; color[1] = Surf.FlatColor.s.green; @@ -1069,7 +1072,9 @@ void HWR_DrawMD2(gr_vissprite_t *spr) finalscale *= FIXED_TO_FLOAT(spr->mobj->scale); p.flip = atransform.flip; - p.mirror = atransform.mirror; +#ifdef USE_FTRANSFORM_MIRROR + p.mirror = atransform.mirror; // from Kart +#endif HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, color); } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e29c6a38..5f21ec7e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1971,6 +1971,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 pglEnable(GL_CULL_FACE); +#ifdef USE_FTRANSFORM_MIRROR // flipped is if the object is flipped // pos->flip is if the screen is flipped vertically // pos->mirror is if the screen is flipped horizontally @@ -1982,6 +1983,17 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 else pglCullFace(GL_BACK); } +#else + // pos->flip is if the screen is flipped too + if (flipped != pos->flip) // If either are active, but not both, invert the model's culling + { + pglCullFace(GL_FRONT); + } + else + { + pglCullFace(GL_BACK); + } +#endif #ifndef KOS_GL_COMPATIBILITY pglLightfv(GL_LIGHT0, GL_POSITION, LightPos); @@ -2006,7 +2018,9 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 pglTranslatef(pos->x, pos->z, pos->y); if (flipped) scaley = -scaley; - pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); +#ifdef USE_FTRANSFORM_ANGLEZ + pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); // rotate by slope from Kart +#endif pglRotatef(pos->anglex, -1.0f, 0.0f, 0.0f); pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); @@ -2182,9 +2196,13 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) // keep a trace of the transformation for md2 memcpy(&md2_transform, stransform, sizeof (md2_transform)); +#ifdef USE_FTRANSFORM_MIRROR + // mirroring from Kart if (stransform->mirror) pglScalef(-stransform->scalex, stransform->scaley, -stransform->scalez); - else if (stransform->flip) + else +#endif + if (stransform->flip) pglScalef(stransform->scalex, -stransform->scaley, -stransform->scalez); else pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez);