Hide/add Kart FTransform mirror and anglez behind ifdef

This commit is contained in:
mazmazz 2018-12-19 00:17:51 -05:00
parent 3af4faf19d
commit c39e8bfa0f
3 changed files with 47 additions and 8 deletions

View file

@ -101,15 +101,26 @@ typedef struct
//Hurdler: Transform (coords + angles) //Hurdler: Transform (coords + angles)
//BP: transform order : scale(rotation_x(rotation_y(translation(v)))) //BP: transform order : scale(rotation_x(rotation_y(translation(v))))
// Kart features
//#define USE_FTRANSFORM_ANGLEZ
//#define USE_FTRANSFORM_MIRROR
typedef struct typedef struct
{ {
FLOAT x,y,z; // position FLOAT x,y,z; // position
#ifdef USE_FTRANSFORM_ANGLEZ
FLOAT anglex,angley,anglez; // aimingangle / viewangle FLOAT anglex,angley,anglez; // aimingangle / viewangle
#else
FLOAT anglex,angley; // aimingangle / viewangle
#endif
FLOAT scalex,scaley,scalez; FLOAT scalex,scaley,scalez;
FLOAT fovxangle, fovyangle; FLOAT fovxangle, fovyangle;
UINT8 splitscreen; UINT8 splitscreen;
boolean flip; // screenflip boolean flip; // screenflip
#ifdef USE_FTRANSFORM_MIRROR
boolean mirror; // SRB2Kart: Encore Mode boolean mirror; // SRB2Kart: Encore Mode
#endif
} FTransform; } FTransform;
// Transformed vector, as passed to HWR API // Transformed vector, as passed to HWR API

View file

@ -1080,6 +1080,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
p.angley = FIXED_TO_FLOAT(anglef); p.angley = FIXED_TO_FLOAT(anglef);
} }
p.anglex = 0.0f; p.anglex = 0.0f;
#ifdef USE_FTRANSFORM_ANGLEZ
// Slope rotation from Kart
p.anglez = 0.0f; p.anglez = 0.0f;
if (spr->mobj->standingslope) if (spr->mobj->standingslope)
{ {
@ -1091,6 +1093,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy)); tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy));
p.anglex = FIXED_TO_FLOAT(tempangle); p.anglex = FIXED_TO_FLOAT(tempangle);
} }
#endif
color[0] = Surf.FlatColor.s.red; color[0] = Surf.FlatColor.s.red;
color[1] = Surf.FlatColor.s.green; color[1] = Surf.FlatColor.s.green;
@ -1101,7 +1104,9 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
finalscale *= FIXED_TO_FLOAT(spr->mobj->scale); finalscale *= FIXED_TO_FLOAT(spr->mobj->scale);
p.flip = atransform.flip; 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); HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, color);
} }

View file

@ -112,10 +112,10 @@ static GLint viewport[4];
// These need to start at 0 and be set to their number, and be reset to 0 when deleted so that intel GPUs // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that intel GPUs
// can know when the textures aren't there, as textures are always considered resident in their virtual memory // can know when the textures aren't there, as textures are always considered resident in their virtual memory
// TODO: Store them in a more normal way // TODO: Store them in a more normal way
#define SCRTEX_SCREENTEXTURE 65535 #define SCRTEX_SCREENTEXTURE 4294967295U
#define SCRTEX_STARTSCREENWIPE 65534 #define SCRTEX_STARTSCREENWIPE 4294967294U
#define SCRTEX_ENDSCREENWIPE 65533 #define SCRTEX_ENDSCREENWIPE 4294967293U
#define SCRTEX_FINALSCREENTEXTURE 65532 #define SCRTEX_FINALSCREENTEXTURE 4294967292U
static GLuint screentexture = 0; static GLuint screentexture = 0;
static GLuint startScreenWipe = 0; static GLuint startScreenWipe = 0;
static GLuint endScreenWipe = 0; static GLuint endScreenWipe = 0;
@ -1971,6 +1971,19 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
pglEnable(GL_CULL_FACE); 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
// XOR all the flips together to figure out what culling to use!
{
boolean reversecull = (flipped ^ pos->flip ^ pos->mirror);
if (reversecull)
pglCullFace(GL_FRONT);
else
pglCullFace(GL_BACK);
}
#else
// pos->flip is if the screen is flipped too // 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 if (flipped != pos->flip) // If either are active, but not both, invert the model's culling
{ {
@ -1980,6 +1993,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
{ {
pglCullFace(GL_BACK); pglCullFace(GL_BACK);
} }
#endif
#ifndef KOS_GL_COMPATIBILITY #ifndef KOS_GL_COMPATIBILITY
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos); pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
@ -2004,8 +2018,11 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
pglTranslatef(pos->x, pos->z, pos->y); pglTranslatef(pos->x, pos->z, pos->y);
if (flipped) if (flipped)
scaley = -scaley; scaley = -scaley;
pglRotatef(pos->angley, 0.0f, -1.0f, 0.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->anglex, -1.0f, 0.0f, 0.0f);
pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f);
pglScalef(scalex, scaley, scalez); pglScalef(scalex, scaley, scalez);
@ -2172,13 +2189,19 @@ EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration,
// -----------------+ // -----------------+
EXPORT void HWRAPI(SetTransform) (FTransform *stransform) EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
{ {
static INT32 special_splitscreen; static boolean special_splitscreen;
pglLoadIdentity(); pglLoadIdentity();
if (stransform) if (stransform)
{ {
// keep a trace of the transformation for md2 // keep a trace of the transformation for md2
memcpy(&md2_transform, stransform, sizeof (md2_transform)); 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
#endif
if (stransform->flip) if (stransform->flip)
pglScalef(stransform->scalex, -stransform->scaley, -stransform->scalez); pglScalef(stransform->scalex, -stransform->scaley, -stransform->scalez);
else else
@ -2190,7 +2213,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
pglMatrixMode(GL_PROJECTION); pglMatrixMode(GL_PROJECTION);
pglLoadIdentity(); pglLoadIdentity();
special_splitscreen = (stransform->splitscreen && stransform->fovxangle == 90.0f); special_splitscreen = (stransform->splitscreen == 1 && stransform->fovxangle == 90.0f);
if (special_splitscreen) if (special_splitscreen)
GLPerspective(53.13l, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5) GLPerspective(53.13l, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5)
else else