mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-01 05:46:06 -04:00
--User changes
-Allow locking of the scale at which affine circles are displayed. -Allow user to toggle whether xform will be animated when generating sequences. Also show the animate value when loading. --Code changes -More conversion to C++11 style code. -Add another value to the eXformUpdate enum called UPDATE_CURRENT_AND_SELECTED in anticipation of future work. -Remove some old #defines.
This commit is contained in:
@ -112,6 +112,22 @@ typename v2T Affine2D<T>::operator * (const v2T& v)
|
||||
return TransformVector(v);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a copy of the object with all values A-F scaled by the specified amount.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount to scale by</param>
|
||||
/// <returns>A new Affine2D which a scaled copy of this instance</returns>
|
||||
template <typename T>
|
||||
Affine2D<T> Affine2D<T>:: operator * (const T& t)
|
||||
{
|
||||
return Affine2D<T>(A() * t,
|
||||
D() * t,
|
||||
B() * t,
|
||||
E() * t,
|
||||
C() * t,
|
||||
F() * t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make this affine transform the identity matrix.
|
||||
/// A and E = 1, all else 0.
|
||||
@ -172,6 +188,21 @@ bool Affine2D<T>::IsEmpty() const
|
||||
(IsClose<T>(F(), EMPTYFIELD));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scales all values A-F by the specified amount.
|
||||
/// </summary>
|
||||
/// <param name="amount">The amount to scale by</param>
|
||||
template <typename T>
|
||||
void Affine2D<T>::Scale(T amount)
|
||||
{
|
||||
A(A() * amount);
|
||||
B(B() * amount);
|
||||
C(C() * amount);
|
||||
D(D() * amount);
|
||||
E(E() * amount);
|
||||
F(F() * amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotate this affine transform around its origin by the specified angle in degrees.
|
||||
/// </summary>
|
||||
@ -181,7 +212,6 @@ void Affine2D<T>::Rotate(T angle)
|
||||
{
|
||||
m4T origMat4 = ToMat4ColMajor(true);//Must center and use column major for glm to work.
|
||||
m4T newMat4 = glm::rotate(origMat4, angle * DEG_2_RAD_T, v3T(0, 0, 1));//Assuming only rotating around z.
|
||||
|
||||
A(newMat4[0][0]);//Use direct assignments instead of constructor to skip assigning C and F.
|
||||
B(newMat4[0][1]);
|
||||
D(newMat4[1][0]);
|
||||
@ -206,7 +236,6 @@ template <typename T>
|
||||
void Affine2D<T>::RotateScaleXTo(const v2T& v)
|
||||
{
|
||||
Affine2D<T> rs = CalcRotateScale(X(), v);
|
||||
|
||||
X(rs.TransformNormal(X()));
|
||||
Y(rs.TransformNormal(Y()));
|
||||
}
|
||||
@ -219,7 +248,6 @@ template <typename T>
|
||||
void Affine2D<T>::RotateScaleYTo(const v2T& v)
|
||||
{
|
||||
Affine2D<T> rs = CalcRotateScale(Y(), v);
|
||||
|
||||
X(rs.TransformNormal(X()));
|
||||
Y(rs.TransformNormal(Y()));
|
||||
}
|
||||
@ -232,10 +260,9 @@ template <typename T>
|
||||
Affine2D<T> Affine2D<T>::Inverse() const
|
||||
{
|
||||
T det = A() * E() - D() * B();
|
||||
|
||||
return Affine2D<T>(E() / det, -D() / det,
|
||||
-B() / det, A() / det,
|
||||
(F() * B() - C() * E()) / det, (C() * D() - F() * A()) / det);
|
||||
-B() / det, A() / det,
|
||||
(F() * B() - C() * E()) / det, (C() * D() - F() * A()) / det);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -294,9 +321,8 @@ typename m4T Affine2D<T>::ToMat4ColMajor(bool center) const
|
||||
{
|
||||
m4T mat(A(), B(), 0, center ? 0 : C(), //Col0...
|
||||
D(), E(), 0, center ? 0 : F(), //1
|
||||
0, 0, 1, 0, //2
|
||||
0, 0, 0, 1);//3
|
||||
|
||||
0, 0, 1, 0, //2
|
||||
0, 0, 0, 1);//3
|
||||
return mat;
|
||||
}
|
||||
|
||||
@ -310,9 +336,8 @@ typename m4T Affine2D<T>::ToMat4RowMajor(bool center) const
|
||||
{
|
||||
m4T mat(A(), D(), 0, 0,
|
||||
B(), E(), 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 1, 0,
|
||||
center ? 0 : C(), center ? 0 : F(), 0, 1);
|
||||
|
||||
return mat;
|
||||
}
|
||||
|
||||
@ -351,7 +376,6 @@ template <typename T>
|
||||
Affine2D<T> Affine2D<T>::CalcRotateScale(const v2T& from, const v2T& to)
|
||||
{
|
||||
T a, c;
|
||||
|
||||
CalcRSAC(from, to, a, c);
|
||||
return Affine2D<T>(a, c, -c, a, 0, 0);
|
||||
}
|
||||
@ -368,7 +392,6 @@ template <typename T>
|
||||
void Affine2D<T>::CalcRSAC(const v2T& from, const v2T& to, T& a, T& c)
|
||||
{
|
||||
T lsq = from.x * from.x + from.y * from.y;
|
||||
|
||||
a = (from.y * to.y + from.x * to.x) / lsq;
|
||||
c = (from.x * to.y - from.y * to.x) / lsq;
|
||||
}
|
||||
|
@ -64,17 +64,19 @@ public:
|
||||
D(T(affine.D()));
|
||||
E(T(affine.E()));
|
||||
F(T(affine.F()));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator == (const Affine2D<T>& affine);
|
||||
v2T operator * (const v2T& v);
|
||||
Affine2D<T> operator * (const T& t);
|
||||
|
||||
void MakeID();
|
||||
bool IsID() const;
|
||||
bool IsZero() const;
|
||||
bool IsEmpty() const;
|
||||
void Scale(T amount);
|
||||
Affine2D<T> ScaleCopy(T amount);
|
||||
void Rotate(T angle);
|
||||
void Translate(const v2T& v);
|
||||
void RotateScaleXTo(const v2T& v);
|
||||
|
@ -314,8 +314,6 @@ public:
|
||||
/// <returns>True if success, else false.</returns>
|
||||
bool DeleteXform(size_t i)
|
||||
{
|
||||
Xform<T>* xform;
|
||||
|
||||
if (i < XformCount())
|
||||
{
|
||||
m_Xforms.erase(m_Xforms.begin() + i);
|
||||
@ -323,7 +321,7 @@ public:
|
||||
//Now shuffle xaos values from i on back by 1 for every xform.
|
||||
for (size_t x1 = 0; x1 < XformCount(); x1++)
|
||||
{
|
||||
if ((xform = GetXform(x1)))
|
||||
if (auto xform = GetXform(x1))
|
||||
{
|
||||
for (size_t x2 = i + 1; x2 <= XformCount(); x2++)//Iterate from the position after the deletion index up to the old count.
|
||||
xform->SetXaos(x2 - 1, xform->Xaos(x2));
|
||||
@ -463,7 +461,7 @@ public:
|
||||
{
|
||||
for (size_t i = 0; i < TotalXformCount(); i++)
|
||||
{
|
||||
Xform<T>* xform = GetTotalXform(i);
|
||||
auto xform = GetTotalXform(i);
|
||||
xform->CacheColorVals();
|
||||
xform->SetPrecalcFlags();
|
||||
}
|
||||
@ -824,7 +822,7 @@ public:
|
||||
//This includes all xforms plus final.
|
||||
for (size_t i = 0; i < totalXformCount; i++)
|
||||
{
|
||||
Xform<T>* thisXform = GetTotalXform(i);
|
||||
auto thisXform = GetTotalXform(i);
|
||||
|
||||
if (size == 2 && stagger > 0 && thisXform != &m_FinalXform)
|
||||
{
|
||||
@ -845,7 +843,7 @@ public:
|
||||
|
||||
for (size_t k = 0; k < size; k++)//For each ember in the list.
|
||||
{
|
||||
Xform<T>* tempXform = embers[k].GetTotalXform(i);//Xform in this position in this ember, including final.
|
||||
auto tempXform = embers[k].GetTotalXform(i);//Xform in this position in this ember, including final.
|
||||
|
||||
if (tempXform)
|
||||
{
|
||||
@ -904,7 +902,7 @@ public:
|
||||
{
|
||||
if (i < embers[k].TotalXformCount())//Xform in this position in this ember.
|
||||
{
|
||||
Xform<T>* tempXform = embers[k].GetTotalXform(i);
|
||||
auto tempXform = embers[k].GetTotalXform(i);
|
||||
allID &= tempXform->m_Post.IsID();
|
||||
}
|
||||
}
|
||||
@ -931,7 +929,7 @@ public:
|
||||
|
||||
for (size_t k = 0; k < size; k++)
|
||||
{
|
||||
Xform<T>* tempXform = embers[k].GetTotalXform(i);//Xform in this position in this ember.
|
||||
auto tempXform = embers[k].GetTotalXform(i);//Xform in this position in this ember.
|
||||
|
||||
if (tempXform)
|
||||
{
|
||||
@ -971,7 +969,7 @@ public:
|
||||
//Now fill them with interpolated values.
|
||||
for (size_t j = 0; j < size; j++)//For each ember in the list.
|
||||
{
|
||||
Xform<T>* tempXform = embers[j].GetXform(i);
|
||||
auto tempXform = embers[j].GetXform(i);
|
||||
|
||||
for (size_t k = 0; k < XformCount(); k++)//For each xaos entry in this xform's xaos array, sum it with the same entry in all of the embers multiplied by the coef for that ember.
|
||||
{
|
||||
|
@ -41,7 +41,6 @@ public:
|
||||
bool aligned = true;
|
||||
bool currentFinal, final = sourceEmbers[0].UseFinalXform();
|
||||
size_t i, xf, currentCount, maxCount = sourceEmbers[0].XformCount();
|
||||
Xform<T>* destXform;
|
||||
Xform<T>* destOtherXform;
|
||||
|
||||
//Determine the max number of xforms present in sourceEmbers.
|
||||
@ -84,7 +83,7 @@ public:
|
||||
|
||||
for (xf = 0; xf < maxCount; xf++)//This will include both normal xforms and the final.
|
||||
{
|
||||
destXform = destEmbers[i].GetTotalXform(xf, final);
|
||||
auto destXform = destEmbers[i].GetTotalXform(xf, final);
|
||||
|
||||
//Ensure every parametric variation contained in every xform at either position i - 1 or i + 1 is also contained in the dest xform.
|
||||
if (i > 0)
|
||||
@ -607,7 +606,7 @@ public:
|
||||
//Keep translation linear.
|
||||
zlm[0] = zlm[1] = 0;
|
||||
|
||||
if (Xform<T>* xform = embers[k].GetTotalXform(xfi))
|
||||
if (auto xform = embers[k].GetTotalXform(xfi))
|
||||
{
|
||||
for (col = 0; col < 2; col++)
|
||||
{
|
||||
@ -650,7 +649,7 @@ public:
|
||||
{
|
||||
for (k = 1; k < size; k++)
|
||||
{
|
||||
if (Xform<T>* xform = embers[k].GetTotalXform(xfi))
|
||||
if (auto xform = embers[k].GetTotalXform(xfi))
|
||||
{
|
||||
//Adjust angles differently if an asymmetric case.
|
||||
if (xform->m_Wind[col] > 0 && cflag == 0)
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
{
|
||||
size_t i;
|
||||
size_t distribCount = ember.XaosPresent() ? ember.XformCount() + 1 : 1;
|
||||
const Xform<T>* xforms = ember.Xforms();
|
||||
auto xforms = ember.Xforms();
|
||||
|
||||
if (m_XformDistributions.size() < CHOOSE_XFORM_GRAIN * distribCount)
|
||||
m_XformDistributions.resize(CHOOSE_XFORM_GRAIN * distribCount);
|
||||
@ -306,7 +306,7 @@ public:
|
||||
{
|
||||
size_t i, badVals = 0;
|
||||
Point<T> tempPoint, p1;
|
||||
Xform<T>* xforms = ember.NonConstXforms();
|
||||
auto xforms = ember.NonConstXforms();
|
||||
|
||||
if (ember.ProjBits())
|
||||
{
|
||||
@ -473,7 +473,7 @@ public:
|
||||
size_t lastXformUsed = 0;
|
||||
size_t badVals = 0;
|
||||
Point<T> tempPoint, p1;
|
||||
Xform<T>* xforms = ember.NonConstXforms();
|
||||
auto xforms = ember.NonConstXforms();
|
||||
|
||||
if (ember.ProjBits())
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ public:
|
||||
//First clear out any xforms that are not the final, and have a density of less than 0.001.
|
||||
for (i = 0; i < ember.XformCount(); i++)
|
||||
{
|
||||
Xform<T>* xform = ember.GetXform(i);
|
||||
auto xform = ember.GetXform(i);
|
||||
|
||||
if (xform->m_Weight < T(0.001))
|
||||
{
|
||||
@ -131,7 +131,7 @@ public:
|
||||
//Now consider all xforms, including final.
|
||||
for (i = 0; i < ember.TotalXformCount(); i++)
|
||||
{
|
||||
Xform<T>* xform = ember.GetTotalXform(i);
|
||||
auto xform = ember.GetTotalXform(i);
|
||||
|
||||
do
|
||||
{
|
||||
@ -223,8 +223,8 @@ public:
|
||||
|
||||
for (size_t i = 0; i < ember.TotalXformCount(); i++)
|
||||
{
|
||||
Xform<T>* xform1 = ember.GetTotalXform(i);
|
||||
Xform<T>* xform2 = mutation.GetTotalXform(i);
|
||||
auto xform1 = ember.GetTotalXform(i);
|
||||
auto xform2 = mutation.GetTotalXform(i);
|
||||
|
||||
if (xform1 && xform2)
|
||||
{
|
||||
@ -254,8 +254,8 @@ public:
|
||||
Random(mutation, useVars, sym, 2, maxVars);
|
||||
//Which xform to mutate?
|
||||
modXform = m_Rand.Rand() % ember.TotalXformCount();
|
||||
Xform<T>* xform1 = ember.GetTotalXform(modXform);
|
||||
Xform<T>* xform2 = mutation.GetTotalXform(0);
|
||||
auto xform1 = ember.GetTotalXform(modXform);
|
||||
auto xform2 = mutation.GetTotalXform(0);
|
||||
os << "mutate xform " << modXform << " coefs";
|
||||
|
||||
//If less than 3 xforms, then change only the translation part.
|
||||
@ -285,7 +285,7 @@ public:
|
||||
for (size_t i = 0; i < ember.TotalXformCount(); i++)
|
||||
{
|
||||
bool copy = (i > 0) && same;
|
||||
Xform<T>* xform = ember.GetTotalXform(i);
|
||||
auto xform = ember.GetTotalXform(i);
|
||||
|
||||
if (copy)//Copy the post from the first xform to the rest of them.
|
||||
{
|
||||
@ -400,8 +400,8 @@ public:
|
||||
//Change all the coefs by a fraction of the random.
|
||||
for (size_t x = 0; x < ember.TotalXformCount(); x++)
|
||||
{
|
||||
Xform<T>* xform1 = ember.GetTotalXform(x);
|
||||
Xform<T>* xform2 = mutation.GetTotalXform(x);
|
||||
auto xform1 = ember.GetTotalXform(x);
|
||||
auto xform2 = mutation.GetTotalXform(x);
|
||||
|
||||
for (glm::length_t i = 0; i < 2; i++)
|
||||
for (glm::length_t j = 0; j < 3; j++)
|
||||
@ -498,7 +498,7 @@ public:
|
||||
{
|
||||
if (i < ember1.XformCount() && ember1.GetXform(i)->m_Weight > 0)
|
||||
{
|
||||
Xform<T>* xform = emberOut.GetXform(i);
|
||||
auto xform = emberOut.GetXform(i);
|
||||
*xform = *ember1.GetXform(i);
|
||||
os << " 1";
|
||||
got1 = 1;
|
||||
@ -513,7 +513,7 @@ public:
|
||||
{
|
||||
if (i < ember0.XformCount() && ember0.GetXform(i)->m_Weight > 0)
|
||||
{
|
||||
Xform<T>* xform = emberOut.GetXform(i);
|
||||
auto xform = emberOut.GetXform(i);
|
||||
*xform = *ember0.GetXform(i);
|
||||
os << " 0";
|
||||
got0 = 1;
|
||||
@ -654,7 +654,7 @@ public:
|
||||
//Loop over xforms.
|
||||
for (i = 0; i < ember.TotalXformCount(); i++)
|
||||
{
|
||||
Xform<T>* xform = ember.GetTotalXform(i);
|
||||
auto xform = ember.GetTotalXform(i);
|
||||
xform->m_Weight = T(1) / ember.TotalXformCount();
|
||||
xform->m_ColorX = m_Rand.Frand01<T>();//Original pingponged between 0 and 1, which gives bad coloring. Ember does random instead.
|
||||
xform->m_ColorY = m_Rand.Frand01<T>();//Will need to update this if 2D coordinates are ever supported.
|
||||
@ -699,7 +699,7 @@ public:
|
||||
if (samed && i > 0)
|
||||
{
|
||||
//Copy the same variations from the previous xform.
|
||||
Xform<T>* prevXform = ember.GetXform(i - 1);
|
||||
auto prevXform = ember.GetXform(i - 1);
|
||||
|
||||
for (j = 0; j < prevXform->TotalVariationCount(); j++)
|
||||
if (xform->TotalVariationCount() < maxVars)
|
||||
@ -893,10 +893,6 @@ public:
|
||||
/// <param name="changePalette">Change palette if true, else don't</param>
|
||||
void ChangeColors(Ember<T>& ember, bool changePalette)
|
||||
{
|
||||
size_t i;
|
||||
Xform<T>* xform0;
|
||||
Xform<T>* xform1;
|
||||
|
||||
if (changePalette)
|
||||
{
|
||||
if (m_PaletteList.Size())
|
||||
@ -910,14 +906,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ember.TotalXformCount(); i++)
|
||||
for (size_t i = 0; i < ember.TotalXformCount(); i++)
|
||||
{
|
||||
ember.GetTotalXform(i)->m_ColorX = m_Rand.Frand01<T>();
|
||||
ember.GetTotalXform(i)->m_ColorY = m_Rand.Frand01<T>();
|
||||
}
|
||||
|
||||
xform0 = RandomXform(ember, -1);
|
||||
xform1 = RandomXform(ember, ember.GetXformIndex(xform0));
|
||||
auto xform0 = RandomXform(ember, -1);
|
||||
auto xform1 = RandomXform(ember, ember.GetXformIndex(xform0));
|
||||
|
||||
if (xform0 && (m_Rand.Rand() & 1))
|
||||
{
|
||||
@ -949,7 +945,7 @@ public:
|
||||
|
||||
if (i != excluded)
|
||||
{
|
||||
Xform<T>* xform = ember.GetTotalXform(i);
|
||||
auto xform = ember.GetTotalXform(i);
|
||||
|
||||
if (xform->m_Weight > 0)
|
||||
return xform;
|
||||
@ -975,8 +971,8 @@ public:
|
||||
//the result xforms before rotate is called.
|
||||
for (size_t i = 0; i < ember.TotalXformCount(); i++)
|
||||
{
|
||||
Xform<T>* xform1 = ember.GetTotalXform(i);
|
||||
Xform<T>* xform2 = rotated.GetTotalXform(i);
|
||||
auto xform1 = ember.GetTotalXform(i);
|
||||
auto xform2 = rotated.GetTotalXform(i);
|
||||
|
||||
if (!xform1->m_Motion.empty())
|
||||
xform2->ApplyMotion(*xform1, blend);
|
||||
@ -1009,7 +1005,7 @@ public:
|
||||
|
||||
for (i = 0; i < embers[si].TotalXformCount(); i++)
|
||||
{
|
||||
Xform<T>* xform = embers[si].GetTotalXform(i);
|
||||
auto xform = embers[si].GetTotalXform(i);
|
||||
|
||||
if (!xform->m_Motion.empty())
|
||||
xform->ApplyMotion(*(prealign[si].GetTotalXform(i)), blend);//Apply motion parameters to result.xform[i] using blend parameter.
|
||||
|
Reference in New Issue
Block a user