Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lerp issues and eliminate flerp in favor of std::lerp #2712

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions indra/llmath/llmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,6 @@ inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
}

using std::lerp;
// Even though there's now a std::lerp() function that appears to do the same
// as this function, in some cases MSVC likes this one better: some calls to
// std::lerp() produce fatal argument conversion warnings.
inline F32 flerp(F32 a, F32 b, F32 u)
{
return a + ((b - a) * u);
}

inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
{
Expand Down Expand Up @@ -490,7 +483,7 @@ inline U32 get_next_power_two(U32 val, U32 max_power_two)
//get the gaussian value given the linear distance from axis x and guassian value o
inline F32 llgaussian(F32 x, F32 o)
{
return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2.f*o*o));
}

//helper function for removing outliers
Expand Down
28 changes: 14 additions & 14 deletions indra/llmath/llvolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,9 +1294,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);


pt->mPos.set(0 + flerp(0,params.getShear().mV[0],s)
+ flerp(-skew ,skew, t) * 0.5f,
c + flerp(0,params.getShear().mV[1],s),
pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
hole_y * lerp(taper_y_begin, taper_y_end, t),
Expand Down Expand Up @@ -1327,9 +1327,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
s = sin(ang)*lerp(radius_start, radius_end, t);

pt->mPos.set(0 + flerp(0,params.getShear().mV[0],s)
+ flerp(-skew ,skew, t) * 0.5f,
c + flerp(0,params.getShear().mV[1],s),
pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
c + lerp(0.f,params.getShear().mV[1],s),
s);

pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
Expand All @@ -1354,9 +1354,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
s = sin(ang)*lerp(radius_start, radius_end, t);

pt->mPos.set(0 + flerp(0,params.getShear().mV[0],s)
+ flerp(-skew ,skew, t) * 0.5f,
c + flerp(0,params.getShear().mV[1],s),
pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
hole_y * lerp(taper_y_begin, taper_y_end, t),
Expand Down Expand Up @@ -1494,8 +1494,8 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
for (S32 i=0;i<np;i++)
{
F32 t = lerp(params.getBegin(),params.getEnd(),(F32)i * mStep);
mPath[i].mPos.set(flerp(0,params.getShear().mV[0],t),
flerp(0,params.getShear().mV[1],t),
mPath[i].mPos.set(lerp(0.f,params.getShear().mV[0],t),
lerp(0.f,params.getShear().mV[1],t),
t - 0.5f);
LLQuaternion quat;
quat.setQuat(lerp(F_PI * params.getTwistBegin(),F_PI * params.getTwist(),t),0,0,1);
Expand Down Expand Up @@ -1559,10 +1559,10 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
{
F32 t = (F32)i * mStep;
mPath[i].mPos.set(0,
flerp(0, -sin(F_PI*params.getTwist()*t)*0.5f,t),
lerp(0.f, -sin(F_PI*params.getTwist()*t)*0.5f,t),
lerp(-0.5f, cos(F_PI*params.getTwist()*t)*0.5f,t));
mPath[i].mScale.set(flerp(1,params.getScale().mV[0],t),
flerp(1,params.getScale().mV[1],t), 0,1);
mPath[i].mScale.set(lerp(1.f,params.getScale().mV[0],t),
lerp(1.f,params.getScale().mV[1],t), 0.f, 1.f);
mPath[i].mTexT = t;
LLQuaternion quat;
quat.setQuat(F_PI * params.getTwist() * t,1,0,0);
Expand Down
2 changes: 1 addition & 1 deletion indra/newview/llpanelprimmediacontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ void LLPanelPrimMediaControls::draw()
else if(mFadeTimer.getStarted())
{
F32 time = mFadeTimer.getElapsedTimeF32();
alpha *= llmax(flerp(1.0, 0.0, time / mControlFadeTime), 0.0f);
alpha *= llmax(lerp(1.0f, 0.0f, time / mControlFadeTime), 0.0f);

if(time >= mControlFadeTime)
{
Expand Down
Loading