mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-17 19:31:01 +00:00
Merge pull request #927 from Azaezel/alpah402/lurkingLerps
use the templated mLerp
This commit is contained in:
commit
411572d204
7 changed files with 30 additions and 53 deletions
|
|
@ -236,7 +236,7 @@ void afxXM_Oscillate_rot::updateParams(F32 dt, F32 elapsed, afxXM_Params& params
|
|||
F32 wt_factor = calc_weight_factor(elapsed);
|
||||
|
||||
F32 t = mSin(db->speed*elapsed); // [-1,1]
|
||||
F32 theta = lerp((t+1)/2, db->min.x*wt_factor, db->max.x*wt_factor);
|
||||
F32 theta = mLerp(db->min.x*wt_factor, db->max.x*wt_factor, (t + 1) / 2);
|
||||
theta = mDegToRad(theta);
|
||||
|
||||
AngAxisF rot_aa(db->axis, theta);
|
||||
|
|
@ -258,7 +258,7 @@ void afxXM_Oscillate_scale::updateParams(F32 dt, F32 elapsed, afxXM_Params& para
|
|||
F32 wt_factor = calc_weight_factor(elapsed);
|
||||
|
||||
F32 t = mSin(db->speed*elapsed); // [-1,1]
|
||||
F32 s = lerp((t+1)/2, db->min.x*wt_factor, db->max.x*wt_factor);
|
||||
F32 s = mLerp( db->min.x*wt_factor, db->max.x*wt_factor, (t + 1) / 2);
|
||||
Point3F xm_scale = db->axis*s;
|
||||
|
||||
if (db->additive_scale)
|
||||
|
|
@ -280,7 +280,7 @@ void afxXM_Oscillate_position::updateParams(F32 dt, F32 elapsed, afxXM_Params& p
|
|||
F32 wt_factor = calc_weight_factor(elapsed);
|
||||
|
||||
F32 t = mSin(db->speed*elapsed); // [-1,1]
|
||||
Point3F offset = lerpV(t, db->min*wt_factor, db->max*wt_factor);
|
||||
Point3F offset = mLerp(db->min*wt_factor, db->max*wt_factor,t);
|
||||
|
||||
if (db->local_offset)
|
||||
{
|
||||
|
|
@ -304,7 +304,7 @@ void afxXM_Oscillate_position2::updateParams(F32 dt, F32 elapsed, afxXM_Params&
|
|||
F32 wt_factor = calc_weight_factor(elapsed);
|
||||
|
||||
F32 t = mSin(db->speed*elapsed); // [-1,1]
|
||||
Point3F offset = lerpV(t, db->min*wt_factor, db->max*wt_factor);
|
||||
Point3F offset = mLerp(db->min*wt_factor, db->max*wt_factor,t);
|
||||
|
||||
params.pos2 += offset;
|
||||
}
|
||||
|
|
@ -325,7 +325,7 @@ void afxXM_Oscillate::updateParams(F32 dt, F32 elapsed, afxXM_Params& params)
|
|||
|
||||
if (db->mask & POSITION)
|
||||
{
|
||||
Point3F offset = lerpV(t, db->min*wt_factor, db->max*wt_factor);
|
||||
Point3F offset = mLerp(db->min*wt_factor, db->max*wt_factor,t);
|
||||
if (db->local_offset)
|
||||
{
|
||||
params.ori.mulV(offset);
|
||||
|
|
@ -337,13 +337,13 @@ void afxXM_Oscillate::updateParams(F32 dt, F32 elapsed, afxXM_Params& params)
|
|||
|
||||
if (db->mask & POSITION2)
|
||||
{
|
||||
Point3F offset = lerpV(t, db->min*wt_factor, db->max*wt_factor);
|
||||
Point3F offset = mLerp(db->min*wt_factor, db->max*wt_factor, t);
|
||||
params.pos2 += offset;
|
||||
}
|
||||
|
||||
if (db->mask & SCALE)
|
||||
{
|
||||
F32 s = lerp((t+1)/2, db->min.x*wt_factor, db->max.x*wt_factor);
|
||||
F32 s = mLerp(db->min.x*wt_factor, db->max.x*wt_factor, (t + 1) / 2);
|
||||
Point3F xm_scale = db->axis*s;
|
||||
if (db->additive_scale)
|
||||
params.scale += xm_scale;
|
||||
|
|
@ -353,7 +353,7 @@ void afxXM_Oscillate::updateParams(F32 dt, F32 elapsed, afxXM_Params& params)
|
|||
|
||||
if (db->mask & ORIENTATION)
|
||||
{
|
||||
F32 theta = lerp((t+1)/2, db->min.x*wt_factor, db->max.x*wt_factor);
|
||||
F32 theta = mLerp(db->min.x*wt_factor, db->max.x*wt_factor, (t + 1) / 2);
|
||||
theta = mDegToRad(theta);
|
||||
AngAxisF rot_aa(db->axis, theta);
|
||||
MatrixF rot_xfm; rot_aa.setMatrix(&rot_xfm);
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ void afxXM_WaveBase::updateParams(F32 dt, F32 elapsed, afxXM_Params& params)
|
|||
else
|
||||
{
|
||||
F32 wt_factor = calc_weight_factor(elapsed);
|
||||
F32 final_t = afxXM_WaveInterp::lerp(wt_factor, db->off_duty_t, last_t);
|
||||
F32 final_t = mLerp(db->off_duty_t, last_t, wt_factor);
|
||||
interpolator->interpolate(final_t, params);
|
||||
}
|
||||
}
|
||||
|
|
@ -602,7 +602,7 @@ void afxXM_WaveRiderBase::updateParams(F32 dt, F32 elapsed, afxXM_Params& params
|
|||
else
|
||||
{
|
||||
F32 wt_factor = calc_weight_factor(elapsed);
|
||||
F32 final_t = afxXM_WaveInterp::lerp(wt_factor, db->off_duty_t, t);
|
||||
F32 final_t = mLerp(db->off_duty_t, t, wt_factor);
|
||||
interpolator->interpolate(final_t, params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,8 +84,6 @@ public:
|
|||
virtual ~afxXM_WaveInterp() { }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)=0;
|
||||
virtual void pulse()=0;
|
||||
|
||||
static inline F32 lerp(F32 t, F32 a, F32 b) { return a + t * (b - a); }
|
||||
};
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_Add(U32 o) : afxXM_WaveInterp_Scalar() { offset = o; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
*((F32*)(((char*)(¶ms)) + offset)) += lerp(t, mA, mB);
|
||||
*((F32*)(((char*)(¶ms)) + offset)) += mLerp(mA, mB,t);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_Mul(U32 o) : afxXM_WaveInterp_Scalar() { offset = o; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
*((F32*)(((char*)(¶ms)) + offset)) *= lerp(t, mA, mB);
|
||||
*((F32*)(((char*)(¶ms)) + offset)) *= mLerp(mA, mB,t);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_Rep(U32 o) : afxXM_WaveInterp_Scalar() { offset = o; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
*((F32*)(((char*)(¶ms)) + offset)) = lerp(t, mA, mB);
|
||||
*((F32*)(((char*)(¶ms)) + offset)) = mLerp(mA, mB,t);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_PointAdd(U32 o) : afxXM_WaveInterp_Scalar() { offset = o; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
F32 scalar_at_t = lerp(t, mA, mB);
|
||||
F32 scalar_at_t = mLerp(mA, mB,t);
|
||||
Point3F point_at_t(scalar_at_t, scalar_at_t, scalar_at_t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) += point_at_t;
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_PointMul(U32 o) : afxXM_WaveInterp_Scalar() { offset = o; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) *= lerp(t, mA, mB);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) *= mLerp(mA, mB,t);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_PointRep(U32 o) : afxXM_WaveInterp_Scalar() { offset = o; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
F32 scalar_at_t = lerp(t,mA, mB);
|
||||
F32 scalar_at_t = mLerp(mA, mB,t);
|
||||
Point3F point_at_t(scalar_at_t, scalar_at_t, scalar_at_t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) = point_at_t;
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_Axis_PointAdd(U32 o, Point3F ax) : afxXM_WaveInterp_Scalar() { offset = o; axis = ax; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
Point3F point_at_t = axis*lerp(t, mA, mB);
|
||||
Point3F point_at_t = axis* mLerp(mA, mB,t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) += point_at_t;
|
||||
}
|
||||
};
|
||||
|
|
@ -195,7 +195,7 @@ public:
|
|||
{
|
||||
Point3F local_axis(axis);
|
||||
params.ori.mulV(local_axis);
|
||||
Point3F point_at_t = local_axis*lerp(t, mA, mB);
|
||||
Point3F point_at_t = local_axis* mLerp(mA, mB,t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) += point_at_t;
|
||||
}
|
||||
};
|
||||
|
|
@ -211,7 +211,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_Axis_PointMul(U32 o, Point3F ax) : afxXM_WaveInterp_Scalar() { offset = o; axis = ax; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
Point3F point_at_t = axis*lerp(t, mA, mB);
|
||||
Point3F point_at_t = axis* mLerp(mA, mB,t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) *= point_at_t;
|
||||
}
|
||||
};
|
||||
|
|
@ -227,7 +227,7 @@ public:
|
|||
{
|
||||
Point3F local_axis(axis);
|
||||
params.ori.mulV(local_axis);
|
||||
Point3F point_at_t = local_axis*lerp(t, mA, mB);
|
||||
Point3F point_at_t = local_axis* mLerp(mA, mB,t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) *= point_at_t;
|
||||
}
|
||||
};
|
||||
|
|
@ -243,7 +243,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_Axis_PointRep(U32 o, Point3F ax) : afxXM_WaveInterp_Scalar() { offset = o; axis = ax; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
Point3F point_at_t = axis*lerp(t, mA, mB);
|
||||
Point3F point_at_t = axis* mLerp(mA, mB,t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) = point_at_t;
|
||||
}
|
||||
};
|
||||
|
|
@ -259,7 +259,7 @@ public:
|
|||
{
|
||||
Point3F local_axis(axis);
|
||||
params.ori.mulV(local_axis);
|
||||
Point3F point_at_t = local_axis*lerp(t, mA, mB);
|
||||
Point3F point_at_t = local_axis* mLerp(mA, mB,t);
|
||||
*((Point3F*)(((char*)(¶ms)) + offset)) = point_at_t;
|
||||
}
|
||||
};
|
||||
|
|
@ -272,7 +272,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_ColorAdd() : afxXM_WaveInterp_Scalar() { }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
F32 scalar_at_t = lerp(t, mA, mB);
|
||||
F32 scalar_at_t = mLerp(mA, mB,t);
|
||||
LinearColorF color_at_t(scalar_at_t, scalar_at_t, scalar_at_t, scalar_at_t);
|
||||
params.color += color_at_t;
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_ColorMul() : afxXM_WaveInterp_Scalar() { }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
params.color *= lerp(t, mA, mB);
|
||||
params.color *= mLerp(mA, mB,t);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_ColorRep() : afxXM_WaveInterp_Scalar() { }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
F32 scalar_at_t = lerp(t, mA, mB);
|
||||
F32 scalar_at_t = mLerp(mA, mB,t);
|
||||
params.color.set(scalar_at_t, scalar_at_t, scalar_at_t, scalar_at_t);
|
||||
}
|
||||
};
|
||||
|
|
@ -313,7 +313,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_OriMul(Point3F& ax) : afxXM_WaveInterp_Scalar() { axis = ax; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
F32 theta = mDegToRad(lerp(t, mA, mB));
|
||||
F32 theta = mDegToRad(mLerp(mA, mB,t));
|
||||
AngAxisF rot_aa(axis, theta);
|
||||
MatrixF rot_xfm; rot_aa.setMatrix(&rot_xfm);
|
||||
params.ori.mul(rot_xfm);
|
||||
|
|
@ -330,7 +330,7 @@ public:
|
|||
afxXM_WaveInterp_Scalar_OriRep(Point3F& ax) : afxXM_WaveInterp_Scalar() { axis = ax; }
|
||||
virtual void interpolate(F32 t, afxXM_Params& params)
|
||||
{
|
||||
F32 theta = mDegToRad(lerp(t, mA, mB));
|
||||
F32 theta = mDegToRad(mLerp(mA, mB,t));
|
||||
AngAxisF rot_aa(axis, theta);
|
||||
rot_aa.setMatrix(¶ms.ori);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,19 +169,6 @@ protected:
|
|||
public:
|
||||
/*C*/ afxXM_WeightedBase(afxXM_WeightedBaseData*, afxEffectWrapper*);
|
||||
virtual ~afxXM_WeightedBase() { }
|
||||
|
||||
F32 lerp(F32 t, F32 a, F32 b)
|
||||
{
|
||||
return a + t * (b - a);
|
||||
}
|
||||
|
||||
Point3F lerpV(F32 t, const Point3F& a, const Point3F& b)
|
||||
{
|
||||
return Point3F( a.x + t * (b.x - a.x),
|
||||
a.y + t * (b.y - a.y),
|
||||
a.z + t * (b.z - a.z) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
|
||||
|
|
|
|||
|
|
@ -88,13 +88,6 @@ U32 Noise2D::getSeed()
|
|||
return mSeed;
|
||||
}
|
||||
|
||||
|
||||
inline F32 Noise2D::lerp(F32 t, F32 a, F32 b)
|
||||
{
|
||||
return a + t * (b - a);
|
||||
}
|
||||
|
||||
|
||||
inline F32 Noise2D::curve(F32 t)
|
||||
{
|
||||
return t * t * (3.0f - 2.0f * t);
|
||||
|
|
@ -505,16 +498,16 @@ F32 Noise2D::getValue(F32 x, F32 y, S32 interval)
|
|||
F32 v = dot(mGradient[ b10 ], rx1,ry0);
|
||||
|
||||
// Interpolation along the X axis.
|
||||
F32 a = lerp(sx, u, v);
|
||||
F32 a = mLerp(u, v,sx);
|
||||
|
||||
u = dot(mGradient[ b01 ], rx0,ry1);
|
||||
v = dot(mGradient[ b11 ], rx1,ry1);
|
||||
|
||||
// Interpolation along the Y axis.
|
||||
F32 b = lerp(sx, u, v);
|
||||
F32 b = mLerp( u, v, sx);
|
||||
|
||||
// Final Interpolation
|
||||
return lerp(sy, a, b);
|
||||
return mLerp(a, b,sy);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ private:
|
|||
|
||||
MRandom mRandom;
|
||||
|
||||
F32 lerp(F32 t, F32 a, F32 b);
|
||||
F32 curve(F32 t);
|
||||
void setup(F32 t, S32 &b0, S32 &b1, F32 &r0, F32 &r1);
|
||||
F32 dot(const F32 *q, F32 rx, F32 ry);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue