mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-24 21:31:46 +00:00
Merge branch 'fix-1261' into 'next'
Fix #1261 Closes #1261 See merge request STJr/SRB2!2479
This commit is contained in:
commit
62af0a8231
4 changed files with 80 additions and 1 deletions
|
@ -21,6 +21,32 @@ void DVector3_Load(dvector3_t *vec, double x, double y, double z)
|
|||
vec->z = z;
|
||||
}
|
||||
|
||||
void DVector3_Copy(dvector3_t *a_o, const dvector3_t *a_i)
|
||||
{
|
||||
memcpy(a_o, a_i, sizeof(dvector3_t));
|
||||
}
|
||||
|
||||
void DVector3_Add(const dvector3_t *a_i, const dvector3_t *a_c, dvector3_t *a_o)
|
||||
{
|
||||
a_o->x = a_i->x + a_c->x;
|
||||
a_o->y = a_i->y + a_c->y;
|
||||
a_o->z = a_i->z + a_c->z;
|
||||
}
|
||||
|
||||
void DVector3_Subtract(const dvector3_t *a_i, const dvector3_t *a_c, dvector3_t *a_o)
|
||||
{
|
||||
a_o->x = a_i->x - a_c->x;
|
||||
a_o->y = a_i->y - a_c->y;
|
||||
a_o->z = a_i->z - a_c->z;
|
||||
}
|
||||
|
||||
void DVector3_Multiply(const dvector3_t *a_i, double a_c, dvector3_t *a_o)
|
||||
{
|
||||
a_o->x = a_i->x * a_c;
|
||||
a_o->y = a_i->y * a_c;
|
||||
a_o->z = a_i->z * a_c;
|
||||
}
|
||||
|
||||
double DVector3_Magnitude(const dvector3_t *a_normal)
|
||||
{
|
||||
double xs = a_normal->x * a_normal->x;
|
||||
|
|
|
@ -19,6 +19,10 @@ typedef struct
|
|||
} dvector3_t;
|
||||
|
||||
void DVector3_Load(dvector3_t *vec, double x, double y, double z);
|
||||
void DVector3_Copy(dvector3_t *a_o, const dvector3_t *a_i);
|
||||
void DVector3_Add(const dvector3_t *a_i, const dvector3_t *a_c, dvector3_t *a_o);
|
||||
void DVector3_Subtract(const dvector3_t *a_i, const dvector3_t *a_c, dvector3_t *a_o);
|
||||
void DVector3_Multiply(const dvector3_t *a_i, double a_c, dvector3_t *a_o);
|
||||
double DVector3_Magnitude(const dvector3_t *a_normal);
|
||||
double DVector3_Normalize(dvector3_t *a_normal);
|
||||
void DVector3_Negate(dvector3_t *a_o);
|
||||
|
|
48
src/r_fps.c
48
src/r_fps.c
|
@ -120,6 +120,19 @@ static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixe
|
|||
return out;
|
||||
}
|
||||
|
||||
static double R_LerpDouble(double from, double to, double frac)
|
||||
{
|
||||
return from + (frac * (to - from));
|
||||
}
|
||||
|
||||
static dvector3_t *R_LerpDVector3(const dvector3_t *from, const dvector3_t *to, double frac, dvector3_t *out)
|
||||
{
|
||||
DVector3_Subtract(to, from, out);
|
||||
DVector3_Multiply(out, frac, out);
|
||||
DVector3_Add(from, out, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
// recalc necessary stuff for mouseaiming
|
||||
// slopes are already calculated for the full possible view (which is 4*viewheight).
|
||||
// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out)
|
||||
|
@ -497,6 +510,14 @@ void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope)
|
|||
FV2_Copy(&interp->dynslope.bakd, &slope->d);
|
||||
|
||||
interp->dynslope.oldzdelta = interp->dynslope.bakzdelta = slope->zdelta;
|
||||
|
||||
DVector3_Copy(&interp->dynslope.oldorigin, &slope->dorigin);
|
||||
DVector3_Copy(&interp->dynslope.bakorigin, &slope->dorigin);
|
||||
|
||||
DVector3_Copy(&interp->dynslope.oldnormdir, &slope->dnormdir);
|
||||
DVector3_Copy(&interp->dynslope.baknormdir, &slope->dnormdir);
|
||||
|
||||
interp->dynslope.olddzdelta = interp->dynslope.bakdzdelta = slope->dzdelta;
|
||||
}
|
||||
|
||||
void R_InitializeLevelInterpolators(void)
|
||||
|
@ -561,6 +582,21 @@ static void UpdateLevelInterpolatorState(levelinterpolator_t *interp)
|
|||
FV3_Copy(&interp->dynslope.bako, &interp->dynslope.slope->o);
|
||||
FV2_Copy(&interp->dynslope.bakd, &interp->dynslope.slope->d);
|
||||
interp->dynslope.bakzdelta = interp->dynslope.slope->zdelta;
|
||||
|
||||
DVector3_Copy(&interp->dynslope.oldorigin, &interp->dynslope.bakorigin);
|
||||
DVector3_Copy(&interp->dynslope.oldnormdir, &interp->dynslope.baknormdir);
|
||||
interp->dynslope.olddzdelta = interp->dynslope.bakdzdelta;
|
||||
|
||||
if (interp->dynslope.slope->moved)
|
||||
{
|
||||
P_CalculateSlopeVectors(interp->dynslope.slope);
|
||||
|
||||
interp->dynslope.slope->moved = false;
|
||||
}
|
||||
|
||||
DVector3_Copy(&interp->dynslope.bakorigin, &interp->dynslope.slope->dorigin);
|
||||
DVector3_Copy(&interp->dynslope.baknormdir, &interp->dynslope.slope->dnormdir);
|
||||
interp->dynslope.bakdzdelta = interp->dynslope.slope->dzdelta;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -646,7 +682,13 @@ void R_ApplyLevelInterpolators(fixed_t frac)
|
|||
R_LerpVector3(&interp->dynslope.oldo, &interp->dynslope.bako, frac, &interp->dynslope.slope->o);
|
||||
R_LerpVector2(&interp->dynslope.oldd, &interp->dynslope.bakd, frac, &interp->dynslope.slope->d);
|
||||
interp->dynslope.slope->zdelta = R_LerpFixed(interp->dynslope.oldzdelta, interp->dynslope.bakzdelta, frac);
|
||||
interp->dynslope.slope->moved = true;
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
double dfrac = FixedToDouble(frac);
|
||||
R_LerpDVector3(&interp->dynslope.oldorigin, &interp->dynslope.bakorigin, dfrac, &interp->dynslope.slope->dorigin);
|
||||
R_LerpDVector3(&interp->dynslope.oldnormdir, &interp->dynslope.baknormdir, dfrac, &interp->dynslope.slope->dnormdir);
|
||||
interp->dynslope.slope->dzdelta = R_LerpDouble(interp->dynslope.olddzdelta, interp->dynslope.bakdzdelta, dfrac);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -704,6 +746,10 @@ void R_RestoreLevelInterpolators(void)
|
|||
FV3_Copy(&interp->dynslope.slope->o, &interp->dynslope.bako);
|
||||
FV2_Copy(&interp->dynslope.slope->d, &interp->dynslope.bakd);
|
||||
interp->dynslope.slope->zdelta = interp->dynslope.bakzdelta;
|
||||
|
||||
DVector3_Copy(&interp->dynslope.slope->dorigin, &interp->dynslope.bakorigin);
|
||||
DVector3_Copy(&interp->dynslope.slope->dnormdir, &interp->dynslope.baknormdir);
|
||||
interp->dynslope.slope->dzdelta = interp->dynslope.bakdzdelta;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,9 @@ typedef struct levelinterpolator_s {
|
|||
vector3_t oldo, bako;
|
||||
vector2_t oldd, bakd;
|
||||
fixed_t oldzdelta, bakzdelta;
|
||||
dvector3_t oldorigin, bakorigin;
|
||||
dvector3_t oldnormdir, baknormdir;
|
||||
double olddzdelta, bakdzdelta;
|
||||
} dynslope;
|
||||
};
|
||||
} levelinterpolator_t;
|
||||
|
|
Loading…
Reference in a new issue