--User changes

-Add new variations: bubbleT3D, crob, hexaplay3D, hexcrop, hexes, hexnix3D, loonie2, loonie3, nBlur, octapol and synth.
 -Allow for pre/post versions of dc_bubble, dc_cylinder and dc_linear whereas before they were omitted.
 -When saving a file with multiple embers in it, detect if time values are all the same and if so, start them at zero and increment by 1 for each ember.
 -Allow for numerous quality increases to be coalesced into one. It will pick up at the end of the current render.
 -Show selection highlight on variations tree in response to mouse hover. This makes it easier to see for which variation or param the current mouse wheel action will apply.
 -Make default temporal samples be 100, whereas before it was 1000 which was overkill.
 -Require the shift key to be held with delete for deleting an ember to prevent it from triggering when the user enters delete in the edit box.
  -This wasn't otherwise fixable without writing a lot more code.

--Bug fixes
 -EmberGenome was crashing when generating a sequence from a source file with more than 2 embers in it.
 -EmberGenome was improperly handling the first frame of a merge after the last frame of the loop.
  -These bugs were due to a previous commit. Revert parts of that commit.
 -Prevent a zoom value of less than 0 when reading from xml.
 -Slight optimization of the crescents, and mask variations, if the compiler wasn't doing it already.
 -Unique file naming was broken because it was looking for _# and the default names ended with -#.
 -Disallow renaming of an ember in the library tree to an empty string.
 -Severe bug that prevented some variations from being read correctly from params generated outside this program.
 -Severe OpenCL randomization bug. The first x coordinates of the first points in the first kernel call of the first ember of a render since the OpenCL renderer object was created were not random and were mostly -1.
 -Severe bug when populating xform selection distributions that could sometimes cause a crash due to roundoff error. Fix by using double.
 -Limit the max number of variations in a random ember to MAX_CL_VARS, which is 8. This ensures they'll look the same on CPU and GPU.
 -Prevent user from saving stylesheet to default.qss, it's a special reserved filename.

--Code changes
 -Generalize using the running sum output point inside of a variation for all cases: pre, reg and post.
 -Allow for array variables in variations where the address of each element is stored in m_Params.
 -Qualify all math functions with std::
 -No longer use our own Clamp() in OpenCL, instead use the standard clamp().
 -Redesign how functions are used in the variations OpenCL code.
 -Add tests to EmberTester to verify some of the new functionality.
 -Place more const and override qualifiers on functions where appropriate.
 -Add a global rand with a lock to be used very sparingly.
 -Use a map instead of a vector for bad param names in Xml parsing.
 -Prefix affine interpolation mode defines with "AFFINE_" to make their purpose more clear.
 -Allow for variations that change state during iteration by sending a separate copy of the ember to each rendering thread.
 -Implement this same functionality with a local struct in OpenCL. It's members are the total of all variables that need to change state within an ember.
 -Add Contains() function to Utils.h.
 -EmberRender: print names of kernels being printed with --dump_kernel option.
 -Clean up EmberTester to handle some of the recent changes.
 -Fix various casts.
 -Replace % 2 with & 1, even though the compiler was likely doing this already.
 -Add new file Variations06.h to accommodate new variations.
 -General cleanup.
This commit is contained in:
mfeemster
2015-11-22 14:15:07 -08:00
parent 04e72c27de
commit 330074cfb2
62 changed files with 8176 additions and 1877 deletions

View File

@ -185,8 +185,9 @@ public:
/// <param name="useVars">The variations to use if the mutation mode is random</param>
/// <param name="sym">The type of symmetry to add if random specified. If 0, it will be added randomly.</param>
/// <param name="speed">The speed to multiply the pre affine transforms by if the mutate mode is MUTATE_ALL_COEFS, else ignored.</param>
/// <param name="maxVars">The maximum number of variations to allow in any single xform in the ember.</param>
/// <returns>A string describing what was done</returns>
string Mutate(Ember<T>& ember, eMutateMode mode, vector<eVariationId>& useVars, intmax_t sym, T speed)
string Mutate(Ember<T>& ember, eMutateMode mode, vector<eVariationId>& useVars, intmax_t sym, T speed, size_t maxVars)
{
bool done = false;
size_t modXform;
@ -224,7 +225,7 @@ public:
do
{
//Create a random flame, and use the variations to replace those in the original.
Random(mutation, useVars, sym, ember.TotalXformCount());
Random(mutation, useVars, sym, ember.TotalXformCount(), maxVars);
for (size_t i = 0; i < ember.TotalXformCount(); i++)
{
@ -255,7 +256,7 @@ public:
else if (mode == MUTATE_ONE_XFORM_COEFS)
{
//Generate a 2-xform random.
Random(mutation, useVars, sym, 2);
Random(mutation, useVars, sym, 2, maxVars);
//Which xform to mutate?
modXform = m_Rand.Rand() % ember.TotalXformCount();
@ -305,10 +306,10 @@ public:
T f = T(M_PI) * m_Rand.Frand11<T>();
T ra, rb, rd, re;
ra = (xform->m_Affine.A() * cos(f) + xform->m_Affine.B() * -sin(f));
rd = (xform->m_Affine.A() * sin(f) + xform->m_Affine.D() * cos(f));
rb = (xform->m_Affine.B() * cos(f) + xform->m_Affine.E() * -sin(f));
re = (xform->m_Affine.B() * sin(f) + xform->m_Affine.E() * cos(f));
ra = (xform->m_Affine.A() * std::cos(f) + xform->m_Affine.B() * -std::sin(f));
rd = (xform->m_Affine.A() * std::sin(f) + xform->m_Affine.D() * std::cos(f));
rb = (xform->m_Affine.B() * std::cos(f) + xform->m_Affine.E() * -std::sin(f));
re = (xform->m_Affine.B() * std::sin(f) + xform->m_Affine.E() * std::cos(f));
xform->m_Affine.A(ra);
xform->m_Affine.B(rb);
@ -317,10 +318,10 @@ public:
f *= -1;
ra = (xform->m_Post.A() * cos(f) + xform->m_Post.B() * -sin(f));
rd = (xform->m_Post.A() * sin(f) + xform->m_Post.D() * cos(f));
rb = (xform->m_Post.B() * cos(f) + xform->m_Post.E() * -sin(f));
re = (xform->m_Post.B() * sin(f) + xform->m_Post.E() * cos(f));
ra = (xform->m_Post.A() * std::cos(f) + xform->m_Post.B() * -std::sin(f));
rd = (xform->m_Post.A() * std::sin(f) + xform->m_Post.D() * std::cos(f));
rb = (xform->m_Post.B() * std::cos(f) + xform->m_Post.E() * -std::sin(f));
re = (xform->m_Post.B() * std::sin(f) + xform->m_Post.E() * std::cos(f));
xform->m_Post.A(ra);
xform->m_Post.B(rb);
@ -408,7 +409,7 @@ public:
else if (mode == MUTATE_ALL_COEFS)
{
os << "mutate all coefs";
Random(mutation, useVars, sym, ember.TotalXformCount());
Random(mutation, useVars, sym, ember.TotalXformCount(), maxVars);
//Change all the coefs by a fraction of the random.
for (size_t x = 0; x < ember.TotalXformCount(); x++)
@ -599,11 +600,12 @@ public:
/// Thin wrapper around Random() that passes an empty vector for useVars, a random value for symmetry and 0 for max xforms.
/// </summary>
/// <param name="ember">The newly created random ember</param>
void Random(Ember<T>& ember)
/// <param name="maxVars">The maximum number of variations to allow in any single xform in the ember.</param>
void Random(Ember<T>& ember, size_t maxVars)
{
vector<eVariationId> useVars;
Random(ember, useVars, static_cast<intmax_t>(m_Rand.Frand<T>(-2, 2)), 0);
Random(ember, useVars, static_cast<intmax_t>(m_Rand.Frand<T>(-2, 2)), 0, maxVars);
}
/// <summary>
@ -613,7 +615,8 @@ public:
/// <param name="useVars">A list of variations to use. If empty, any variation can be used.</param>
/// <param name="sym">The symmetry type to use from -2 to 2</param>
/// <param name="specXforms">The number of xforms to use. If 0, a quasi random count is used.</param>
void Random(Ember<T>& ember, vector<eVariationId>& useVars, intmax_t sym, size_t specXforms)
/// <param name="maxVars">The maximum number of variations to allow in any single xform in the ember.</param>
void Random(Ember<T>& ember, vector<eVariationId>& useVars, intmax_t sym, size_t specXforms, size_t maxVars)
{
bool postid, addfinal = false;
int var, samed, multid, samepost;
@ -705,11 +708,13 @@ public:
if (var > -1)
{
xform->AddVariation(m_VariationList.GetVariation(var)->Copy());//Use only one variation specified for all xforms.
if (xform->TotalVariationCount() < maxVars)
xform->AddVariation(m_VariationList.GetVariation(var)->Copy());//Use only one variation specified for all xforms.
}
else if (multid && var == -1)
{
xform->AddVariation(m_VariationList.GetVariation(m_Rand.Rand() % varCount)->Copy());//Choose a random var for this xform.
if (xform->TotalVariationCount() < maxVars)
xform->AddVariation(m_VariationList.GetVariation(m_Rand.Rand() % varCount)->Copy());//Choose a random var for this xform.
}
else
{
@ -719,7 +724,8 @@ public:
Xform<T>* prevXform = ember.GetXform(i - 1);
for (j = 0; j < prevXform->TotalVariationCount(); j++)
xform->AddVariation(prevXform->GetVariation(j)->Copy());
if (xform->TotalVariationCount() < maxVars)
xform->AddVariation(prevXform->GetVariation(j)->Copy());
}
else
{
@ -735,21 +741,24 @@ public:
//the probability that multiple vars are used.
for (j = 0; j < n; j++)
{
if (var != -2)
if (xform->TotalVariationCount() < maxVars)
{
//Pick a random variation and use a random weight from 0-1.
Variation<T>* v = m_VariationList.GetVariationCopy(static_cast<size_t>(m_Rand.Rand() % varCount), m_Rand.Frand<T>(T(0.001), 1));
if (var != -2)
{
//Pick a random variation and use a random weight from 0-1.
Variation<T>* v = m_VariationList.GetVariationCopy(static_cast<size_t>(m_Rand.Rand() % varCount), m_Rand.Frand<T>(T(0.001), 1));
if (v && !xform->AddVariation(v))
delete v;//It already existed and therefore was not added.
}
else
{
//Pick a random variation from the suppled IDs and use a random weight from 0-1.
Variation<T>* v = m_VariationList.GetVariationCopy(useVars[m_Rand.Rand() % useVars.size()], m_Rand.Frand<T>(T(0.001), 1));
if (v && !xform->AddVariation(v))
delete v;//It already existed and therefore was not added.
}
else
{
//Pick a random variation from the suppled IDs and use a random weight from 0-1.
Variation<T>* v = m_VariationList.GetVariationCopy(useVars[m_Rand.Rand() % useVars.size()], m_Rand.Frand<T>(T(0.001), 1));
if (v && !xform->AddVariation(v))
delete v;
if (v && !xform->AddVariation(v))
delete v;
}
}
}
@ -770,15 +779,18 @@ public:
//the probability that multiple vars are used.
for (j = 0; j < n; j++)
{
if (var != -2)
if (xform->TotalVariationCount() < maxVars)
{
//Pick a random variation and use a random weight from 0-1.
xform->AddVariation(m_VariationList.GetVariationCopy(static_cast<size_t>(m_Rand.Rand() % varCount), m_Rand.Frand<T>(T(0.001), 1)));
}
else
{
//Pick a random variation from the suppled IDs and use a random weight from 0-1.
xform->AddVariation(m_VariationList.GetVariationCopy(useVars[m_Rand.Rand() % useVars.size()], m_Rand.Frand<T>(T(0.001), 1)));
if (var != -2)
{
//Pick a random variation and use a random weight from 0-1.
xform->AddVariation(m_VariationList.GetVariationCopy(static_cast<size_t>(m_Rand.Rand() % varCount), m_Rand.Frand<T>(T(0.001), 1)));
}
else
{
//Pick a random variation from the suppled IDs and use a random weight from 0-1.
xform->AddVariation(m_VariationList.GetVariationCopy(useVars[m_Rand.Rand() % useVars.size()], m_Rand.Frand<T>(T(0.001), 1)));
}
}
}
@ -1240,8 +1252,8 @@ public:
{
T r[2];
T th = by * 2 * T(M_PI) / 360;
T c = cos(th);
T s = -sin(th);
T c = std::cos(th);
T s = -std::sin(th);
newCenterX -= oldCenterX;
newCenterY -= oldCenterY;