From 0cc8fbdb4edcaba47191ec47327773ef76a251dc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 24 Oct 2017 20:45:55 +0100 Subject: [PATCH 1/2] Don't use interpolation code if the frame lasts instantaneously or infinitely Also removed the + 1 from newtime, since there was never really any need for it. It just offset the interpolation so it went like (1 -> 2] instead of [1 -> 2), so you never saw the base appearance for each frame except at the end of any frames interpolating to it Changed DrawMD2Ex's duration/tics type to INT32 so -1 comparisons work, probably want to change the signs elsewhere too but this is fine for now --- src/hardware/r_opengl/r_opengl.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e6ff83e8..e672da8d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1819,15 +1819,14 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) } } -static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) +static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, INT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) { INT32 val, count, pindex; GLfloat s, t; GLfloat ambient[4]; GLfloat diffuse[4]; - float pol; - UINT32 newtime; + float pol = 0.0f; float scalex = scale, scaley = scale, scalez = scale; // Because Otherwise, scaling the screen negatively vertically breaks the lighting @@ -1835,18 +1834,18 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration GLfloat LightPos[] = {0.0f, 1.0f, 0.0f, 0.0f}; #endif - if (duration == 0) - duration = 1; + if (duration != 0 && duration != -1 && tics != -1) // don't interpolate if instantaneous or infinite in length + { + UINT32 newtime = (duration - tics); // + 1; - newtime = (duration - tics) + 1; + pol = (newtime)/(float)duration; - pol = (newtime)/(float)duration; + if (pol > 1.0f) + pol = 1.0f; - if (pol > 1.0f) - pol = 1.0f; - - if (pol < 0.0f) - pol = 0.0f; + if (pol < 0.0f) + pol = 0.0f; + } if (color) { @@ -1940,7 +1939,7 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration pglTexCoord2f(s, t); - if (!nextframe) + if (!nextframe || pol == 0.0f) { pglNormal3f(frame->vertices[pindex].normal[0], frame->vertices[pindex].normal[1], From 2b1fb67a5fae0f5105bc18e83ed81b47ca062b9f Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 Oct 2017 19:12:51 +0000 Subject: [PATCH 2/2] DrawMD2i: change duration and tics to INT32, fix up any related code --- src/hardware/hw_drv.h | 2 +- src/hardware/hw_md2.c | 4 ++-- src/hardware/r_opengl/r_opengl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index e0c2f327..7672f47c 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -66,7 +66,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value); //Hurdler: added for new development EXPORT void HWRAPI(DrawMD2) (INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale); -EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color); +EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, INT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color); EXPORT void HWRAPI(SetTransform) (FTransform *ptransform); EXPORT INT32 HWRAPI(GetTextureUsed) (void); EXPORT INT32 HWRAPI(GetRenderVersion) (void); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 4ec2e346..f59c1d4f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1252,8 +1252,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr) { GLPatch_t *gpatch; INT32 *buff; - UINT32 durs = spr->mobj->state->tics; - UINT32 tics = spr->mobj->tics; + INT32 durs = spr->mobj->state->tics; + INT32 tics = spr->mobj->tics; md2_frame_t *curr, *next = NULL; const UINT8 flip = (UINT8)((spr->mobj->eflags & MFE_VERTICALFLIP) == MFE_VERTICALFLIP); spritedef_t *sprdef; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e672da8d..205b399b 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1989,7 +1989,7 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, // -----------------+ // HWRAPI DrawMD2 : Draw an MD2 model with glcommands // -----------------+ -EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) +EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, INT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) { DrawMD2Ex(gl_cmd_buffer, frame, duration, tics, nextframe, pos, scale, flipped, color); }