From fa24e37526b0b43173ad30746a520eb0854ee524 Mon Sep 17 00:00:00 2001 From: Sryder Date: Mon, 26 Nov 2018 00:17:34 +0000 Subject: [PATCH] Rotate All MD2s to match their standing slopes Needs to be tested in gravity flip Also flips the normal on linedef based slopes so that it's facing the correct direction Also makes it so slopelaunch doesn't always remove the standingslope (going down some slopes would cause it to be constantly unset and reset) --- src/hardware/hw_defs.h | 2 +- src/hardware/hw_main.c | 2 ++ src/hardware/hw_md2.c | 14 +++++++++++++- src/hardware/r_opengl/r_opengl.c | 3 ++- src/p_map.c | 2 +- src/p_slopes.c | 6 +++--- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 2d3468781..ece627d3c 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -104,7 +104,7 @@ typedef struct typedef struct { FLOAT x,y,z; // position - FLOAT anglex,angley; // aimingangle / viewangle + FLOAT anglex,angley,anglez; // aimingangle / viewangle FLOAT scalex,scaley,scalez; FLOAT fovxangle, fovyangle; UINT8 splitscreen; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 68915e97f..894a4a8c1 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5968,6 +5968,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) // It should replace all other gr_viewxxx when finished atransform.anglex = (float)(aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + atransform.anglez = 0.0f; if (*type == postimg_flip) atransform.flip = true; @@ -6230,6 +6231,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) // It should replace all other gr_viewxxx when finished atransform.anglex = (float)(aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + atransform.anglez = 0.0f; if (*type == postimg_flip) atransform.flip = true; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index c545cb806..2856cada3 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -963,7 +963,7 @@ spritemd2found: // (See this same define in k_kart.c!) #define SETBRIGHTNESS(brightness,r,g,b) \ brightness = (UINT8)(((1063*((UINT16)r)/5000) + (3576*((UINT16)g)/5000) + (361*((UINT16)b)/5000)) / 3) - + static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolors_t color) { UINT8 i; @@ -1389,6 +1389,18 @@ void HWR_DrawMD2(gr_vissprite_t *spr) p.angley = FIXED_TO_FLOAT(anglef); } p.anglex = 0.0f; + p.anglez = 0.0f; + if (spr->mobj->standingslope) + { + fixed_t tempz = spr->mobj->standingslope->normal.z; + fixed_t tempy = spr->mobj->standingslope->normal.y; + fixed_t tempx = spr->mobj->standingslope->normal.x; + fixed_t tempangle = AngleFixed(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); + p.anglez = FIXED_TO_FLOAT(tempangle); + tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy)); + p.anglex = FIXED_TO_FLOAT(tempangle); + } + color[0] = Surf.FlatColor.s.red; color[1] = Surf.FlatColor.s.green; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index ce5431585..5f2cd0322 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1962,8 +1962,9 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, pglTranslatef(pos->x, pos->z, pos->y); if (flipped) scaley = -scaley; - pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); + pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); pglRotatef(pos->anglex, -1.0f, 0.0f, 0.0f); + pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); val = *gl_cmd_buffer++; diff --git a/src/p_map.c b/src/p_map.c index ba6e64540..b289b3157 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1423,7 +1423,7 @@ static boolean PIT_CheckThing(mobj_t *thing) // Make sure they aren't able to damage you ANYWHERE along the Z axis, you have to be TOUCHING the person. && !(thing->z + thing->height < tmthing->z || thing->z > tmthing->z + tmthing->height)) { - + if (tmthing->scale > thing->scale + (mapheaderinfo[gamemap-1]->mobj_scale/8)) // SRB2kart - Handle squishes first! K_SquishPlayer(thing->player, tmthing); else if (thing->scale > tmthing->scale + (mapheaderinfo[gamemap-1]->mobj_scale/8)) diff --git a/src/p_slopes.c b/src/p_slopes.c index 9513cac05..ea85f797f 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -31,8 +31,8 @@ static UINT16 slopecount = 0; // Calculate line normal void P_CalculateSlopeNormal(pslope_t *slope) { slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); - slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.x); - slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.y); + slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), -slope->d.x); + slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), -slope->d.y); } // With a vertex slope that has its vertices set, configure relevant slope info @@ -812,10 +812,10 @@ void P_SlopeLaunch(mobj_t *mo) mo->momy = slopemom.y; mo->momz = slopemom.z; #endif - } //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; + } } // Function to help handle landing on slopes