diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e3f56f831..b74bd71ea 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3624,10 +3624,6 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) { - fixed_t thingxpos = thing->x + thing->sprxoff; - fixed_t thingypos = thing->y + thing->spryoff; - fixed_t thingzpos = thing->z + thing->sprzoff; - patch_t *gpatch; FOutVector shadowVerts[4]; FSurfaceInfo sSurf; @@ -3644,7 +3640,19 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) fixed_t slopez; pslope_t *groundslope; - // hitlag vibrating + fixed_t interpx = thing->x; + fixed_t interpy = thing->y; + fixed_t interpz = thing->z; + + // do interpolation + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); + interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); + interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); + } + + // hitlag vibrating (todo: interp somehow?) if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = thing->hitlag * (FRACUNIT / 10); @@ -3654,14 +3662,19 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) mul = -mul; } - thingxpos += FixedMul(thing->momx, mul); - thingypos += FixedMul(thing->momy, mul); - thingzpos += FixedMul(thing->momz, mul); + interpx += FixedMul(thing->momx, mul); + interpy += FixedMul(thing->momy, mul); + interpz += FixedMul(thing->momz, mul); } + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + groundz = R_GetShadowZ(thing, &groundslope); - floordiff = abs((flip < 0 ? thing->height : 0) + thingzpos - groundz); + floordiff = abs((flip < 0 ? thing->height : 0) + interpz - groundz); alpha = floordiff / (4*FRACUNIT) + 75; if (alpha >= 255) return; @@ -3675,8 +3688,8 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height); fscale = FIXED_TO_FLOAT(scalemul); - fx = FIXED_TO_FLOAT(thingxpos); - fy = FIXED_TO_FLOAT(thingypos); + fx = FIXED_TO_FLOAT(interpx); + fy = FIXED_TO_FLOAT(interpy); // 3--2 // | /| @@ -5067,9 +5080,9 @@ static void HWR_ProjectSprite(mobj_t *thing) dispoffset = thing->info->dispoffset; - interpx = thing->x + thing->sprxoff; - interpy = thing->y + thing->spryoff; - interpz = thing->z + thing->sprzoff; + interpx = thing->x; + interpy = thing->y; + interpz = thing->z; interpangle = mobjangle; if (cv_frameinterpolation.value == 1 && !paused) @@ -5095,6 +5108,11 @@ static void HWR_ProjectSprite(mobj_t *thing) interpz += FixedMul(thing->momz, mul); } + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + this_scale = FIXED_TO_FLOAT(thing->scale); spritexscale = FIXED_TO_FLOAT(thing->spritexscale); spriteyscale = FIXED_TO_FLOAT(thing->spriteyscale); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 4b8d1de6f..70c064081 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1355,10 +1355,6 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // Look at HWR_ProjectSprite for more { - fixed_t thingxpos = spr->mobj->x + spr->mobj->sprxoff; - fixed_t thingypos = spr->mobj->y + spr->mobj->spryoff; - fixed_t thingzpos = spr->mobj->z + spr->mobj->sprzoff; - patch_t *gpatch, *blendgpatch; GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; INT32 durs = spr->mobj->state->tics; @@ -1371,6 +1367,18 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) INT32 mod; float finalscale; + fixed_t interpx = spr->mobj->x; + fixed_t interpy = spr->mobj->y; + fixed_t interpz = spr->mobj->z; + + // do interpolation + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = spr->mobj->old_x + FixedMul(rendertimefrac, spr->mobj->x - spr->mobj->old_x); + interpy = spr->mobj->old_y + FixedMul(rendertimefrac, spr->mobj->y - spr->mobj->old_y); + interpz = spr->mobj->old_z + FixedMul(rendertimefrac, spr->mobj->z - spr->mobj->old_z); + } + // hitlag vibrating if (spr->mobj->hitlag > 0 && (spr->mobj->eflags & MFE_DAMAGEHITLAG)) { @@ -1381,11 +1389,16 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) mul = -mul; } - thingxpos += FixedMul(spr->mobj->momx, mul); - thingypos += FixedMul(spr->mobj->momy, mul); - thingzpos += FixedMul(spr->mobj->momz, mul); + interpx += FixedMul(spr->mobj->momx, mul); + interpy += FixedMul(spr->mobj->momy, mul); + interpy += FixedMul(spr->mobj->momz, mul); } + // sprite offset + interpx += spr->mobj->sprxoff; + interpy += spr->mobj->spryoff; + interpz += spr->mobj->sprzoff; + // Apparently people don't like jump frames like that, so back it goes //if (tics > durs) //durs = tics; @@ -1605,13 +1618,13 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) #endif //Hurdler: it seems there is still a small problem with mobj angle - p.x = FIXED_TO_FLOAT(thingxpos); - p.y = FIXED_TO_FLOAT(thingypos) + md2->offset; + p.x = FIXED_TO_FLOAT(interpx); + p.y = FIXED_TO_FLOAT(interpy) + md2->offset; if (flip) p.z = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height); else - p.z = FIXED_TO_FLOAT(thingzpos); + p.z = FIXED_TO_FLOAT(interpz); if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) sprdef = &((skin_t *)spr->mobj->skin)->sprites[spr->mobj->sprite2]; @@ -1631,7 +1644,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } else { - const fixed_t anglef = AngleFixed((R_PointToAngle(thingxpos, thingypos))-ANGLE_180); + const fixed_t anglef = AngleFixed((R_PointToAngle(interpx, interpy))-ANGLE_180); p.angley = FIXED_TO_FLOAT(anglef); } diff --git a/src/r_things.c b/src/r_things.c index 6c9693d14..6d9cca7a4 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1363,10 +1363,6 @@ static void R_ProjectSprite(mobj_t *thing) { mobj_t *oldthing = thing; - //const fixed_t oldthingxpos = oldthing->x + oldthing->sprxoff; - //const fixed_t oldthingypos = oldthing->y + oldthing->spryoff; - //const fixed_t oldthingzpos = oldthing->z + oldthing->sprzoff; - fixed_t tr_x, tr_y; fixed_t tx, tz; fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! @@ -1432,9 +1428,9 @@ static void R_ProjectSprite(mobj_t *thing) #endif // uncapped/interpolation - fixed_t interpx = thing->x + thing->sprxoff; - fixed_t interpy = thing->y + thing->spryoff; - fixed_t interpz = thing->z + thing->sprzoff; + fixed_t interpx = thing->x; + fixed_t interpy = thing->y; + fixed_t interpz = thing->z; angle_t interpangle = thing->angle; // use player drawangle if player @@ -1471,6 +1467,11 @@ static void R_ProjectSprite(mobj_t *thing) interpz += FixedMul(thing->momz, mul); } + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + // transform the origin point tr_x = interpx - viewx; tr_y = interpy - viewy; @@ -1782,6 +1783,26 @@ static void R_ProjectSprite(mobj_t *thing) interpy = thing->old_y + FixedMul(thing->y - thing->old_y, rendertimefrac); } + // hitlag vibrating (todo: interp somehow?) + if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) + { + fixed_t mul = thing->hitlag * (FRACUNIT / 10); + + if (leveltime & 1) + { + mul = -mul; + } + + interpx += FixedMul(thing->momx, mul); + interpy += FixedMul(thing->momy, mul); + interpz += FixedMul(thing->momz, mul); + } + + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + if (! R_ThingVisible(thing)) return;