Add new 'motion_offset' parameter to motion elements

This commit is contained in:
Simon Detheridge
2015-07-06 15:05:43 +01:00
parent efb39f8160
commit 3fa59be990
5 changed files with 22 additions and 5 deletions

View File

@ -165,6 +165,7 @@ public:
m_Wind[1] = T(xform.m_Wind[1]);
m_MotionFreq = xform.m_MotionFreq;
m_MotionFunc = xform.m_MotionFunc;
m_MotionOffset = xform.m_MotionOffset;
ClearAndDeleteVariations();
@ -234,6 +235,7 @@ public:
m_Wind[0] = 0;
m_Wind[1] = 0;
m_MotionFreq = 0;
m_MotionOffset = 0;
}
else
{
@ -262,6 +264,7 @@ public:
m_Wind[0] = EMPTYFIELD;
m_Wind[1] = EMPTYFIELD;
m_MotionFreq = EMPTYFIELD;
m_MotionOffset = EMPTYFIELD;
}
m_MotionFunc = MOTION_SIN;
@ -716,7 +719,7 @@ public:
do \
{ \
if (currentMot.x != EMPTYFIELD) \
x += currentMot.x * Interpolater<T>::MotionFuncs(func, freq * blend); \
x += currentMot.x * Interpolater<T>::MotionFuncs(func, freq * (blend + offset)); \
} while (0)
/// <summary>
@ -733,6 +736,7 @@ public:
Xform<T>& currentMot = xform.m_Motion[i];
T freq = currentMot.m_MotionFreq;
eMotion func = currentMot.m_MotionFunc;
T offset = currentMot.m_MotionOffset;
//Clamp these to the appropriate range after all are applied.
APPMOT(m_Weight);
@ -753,13 +757,13 @@ public:
if (!var)//It wasn't present, so add it and set the weight.
{
Variation<T>* newVar = motVar->Copy();
newVar->m_Weight = motVar->m_Weight * Interpolater<T>::MotionFuncs(func, freq * blend);
newVar->m_Weight = motVar->m_Weight * Interpolater<T>::MotionFuncs(func, freq * (blend + offset));
AddVariation(newVar);
var = newVar;//Use this below for params.
}
else//It was present, so apply the motion func to the weight.
{
var->m_Weight += motVar->m_Weight * Interpolater<T>::MotionFuncs(func, freq * blend);
var->m_Weight += motVar->m_Weight * Interpolater<T>::MotionFuncs(func, freq * (blend + offset));
}
//At this point, we've added if needed, or just applied the motion func to the weight.
@ -773,7 +777,7 @@ public:
for (size_t k = 0; k < motParVar->ParamCount(); k++)
{
if (!motParams[k].IsPrecalc())
*(params[k].Param()) += motParams[k].ParamVal() * Interpolater<T>::MotionFuncs(func, freq * blend);
*(params[k].Param()) += motParams[k].ParamVal() * Interpolater<T>::MotionFuncs(func, freq * (blend + offset));
}
}
}
@ -1157,6 +1161,7 @@ public:
ss << "Wind: " << m_Wind[0] << ", " << m_Wind[1] << endl;
ss << "Motion Frequency: " << m_MotionFreq << endl;
ss << "Motion Func: " << m_MotionFunc << endl;
ss << "Motion Offset: " << m_MotionOffset << endl;
const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{
@ -1233,6 +1238,7 @@ public:
T m_Wind[2];
eMotion m_MotionFunc;
T m_MotionFreq;
T m_MotionOffset;
vector<Xform<T>> m_Motion;
string m_Name;