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)
This commit is contained in:
Sryder 2018-11-26 00:17:34 +00:00
parent 92d5a6b8fb
commit 683ebec120
6 changed files with 22 additions and 7 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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++;

View File

@ -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))

View File

@ -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