--User changes

-Add backward compatibility option for the following variations: cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan, tanh.
 -Add the ability to re-order variations by dragging them in the Info tab.
This commit is contained in:
Person
2020-03-04 22:30:08 -08:00
parent c50568a98b
commit ea649bbda6
22 changed files with 1034 additions and 310 deletions

View File

@ -1,28 +1,25 @@
#include "EmberPch.h"
#include "EmberDefines.h"
#include "Isaac.h"
#include "Utils.h"
namespace EmberNs
{
template<> unique_ptr<QTIsaac<ISAAC_SIZE, ISAAC_INT>> QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand = unique_ptr<QTIsaac<ISAAC_SIZE, ISAAC_INT>>(new QTIsaac<ISAAC_SIZE, ISAAC_INT>());
template<> unique_ptr<recursive_mutex> QTIsaac<ISAAC_SIZE, ISAAC_INT>::s_CS = unique_ptr<recursive_mutex>(new recursive_mutex());
template EMBER_API class QTIsaac<ISAAC_SIZE, ISAAC_INT>;
bool Compat::m_Compat = false;
}
#include "Curves.h"
#include "Ember.h"
#include "Utils.h"
#include "Iterator.h"
#include "Palette.h"
#include "PaletteList.h"
#include "Point.h"
#include "VarFuncs.h"
#include "Variation.h"
#ifdef FLAM3_COMPAT
#include "Variations01_flam3_compat.h"//Do this instead if you want full compatibility with flam3.
#else
#include "Variations01.h"
#endif
#include "Variations01.h"
#include "Variations02.h"
#include "Variations03.h"
#include "Variations04.h"

View File

@ -44,7 +44,6 @@ namespace EmberNs
#define ISAAC_SIZE 4
#define MEMALIGN 32
#define DE_THRESH 100
#define MAX_VARS_PER_XFORM 8
#define DEG_2_RAD (M_PI / 180)
#define RAD_2_DEG (180 / M_PI)
#define DEG_2_RAD_T (T(M_PI) / T(180))

View File

@ -285,6 +285,16 @@ protected:
x(const x& other) = delete; \
const x& operator=(const x& other) = delete
/// <summary>
/// The calculations in some variations were changed from what they were in flam3/Apophysis to match Chaotica.
/// Some users prefer the old functionality, so provide an option to retain it.
/// </summary>
class EMBER_API Compat
{
public:
static bool m_Compat;
};
/// <summary>
/// Open a file in binary mode and read its entire contents into a vector of bytes. Optionally null terminate.
/// </summary>

File diff suppressed because it is too large Load Diff

View File

@ -268,16 +268,15 @@ public:
m_HasPost = false;
m_HasPreOrRegularVars = false;
m_ParentEmber = nullptr;
m_PreVariations.reserve(MAX_VARS_PER_XFORM);
m_Variations.reserve(MAX_VARS_PER_XFORM);
m_PostVariations.reserve(MAX_VARS_PER_XFORM);
m_PreVariations.reserve(8);
m_Variations.reserve(8);
m_PostVariations.reserve(8);
CacheColorVals();
count++;
}
/// <summary>
/// Add a pointer to a variation which will be deleted on destruction so the caller should not delete.
/// This checks if the total number of variations is less than or equal to MAX_VARS_PER_XFORM.
/// It also checks if the variation is already present, in which case it doesn't add.
/// If add, set all precalcs.
/// </summary>
@ -299,23 +298,63 @@ public:
else
vec = &m_Variations;
if (vec->size() < MAX_VARS_PER_XFORM)
vec->push_back(variation);
//Flatten must always be last.
for (size_t i = 0; i < vec->size(); i++)
{
vec->push_back(variation);
//Flatten must always be last.
for (size_t i = 0; i < vec->size(); i++)
if ((i != vec->size() - 1) && ((*vec)[i]->Name().find("flatten") != string::npos))
{
if ((i != vec->size() - 1) && ((*vec)[i]->Name().find("flatten") != string::npos))
{
std::swap((*vec)[i], (*vec)[vec->size() - 1]);
break;
}
std::swap((*vec)[i], (*vec)[vec->size() - 1]);
break;
}
SetPrecalcFlags();
return true;
}
SetPrecalcFlags();
return true;
}
return false;
}
/// <summary>
/// Insert a pointer to a variation, at the specified location, which will be deleted on destruction so the caller should not delete.
/// It also checks if the variation is already present, in which case it doesn't add.
/// If add, set all precalcs.
/// </summary>
/// <param name="variation">Pointer to a varation to add</param>
/// <param name="index">The index to insert at</param>
/// <returns>True if the successful, else false.</returns>
bool InsertVariation(Variation<T>* variation, size_t index)
{
if (variation && (GetVariationById(variation->VariationId()) == nullptr))
{
string name = variation->Name();
bool pre = name.find("pre_") == 0;
bool post = name.find("post_") == 0;
vector<Variation<T>*>* vec;
if (pre)
vec = &m_PreVariations;
else if (post)
vec = &m_PostVariations;
else
vec = &m_Variations;
vec->insert(vec->begin() + index, variation);
//Flatten must always be last.
for (size_t i = 0; i < vec->size(); i++)
{
if ((i != vec->size() - 1) && ((*vec)[i]->Name().find("flatten") != string::npos))
{
std::swap((*vec)[i], (*vec)[vec->size() - 1]);
break;
}
}
SetPrecalcFlags();
return true;
}
return false;
@ -443,6 +482,36 @@ public:
return found;
}
/// <summary>
/// Remove the variation with the matching ID, but instead of deleting it, return it.
/// Update precalcs if deletion successful.
/// </summary>
/// <param name="id">The ID to search for</param>
/// <returns>The variation if found, else nullptr.</returns>
Variation<T>* RemoveVariationById(eVariationId id)
{
bool found = false;
Variation<T>* var = nullptr;
AllVarsFunc([&](vector<Variation<T>*>& variations, bool & keepGoing)
{
for (size_t i = 0; i < variations.size(); i++)
{
if (variations[i] && variations[i]->VariationId() == id)
{
var = variations[i];
variations.erase(variations.begin() + i);
keepGoing = false;
break;
}
}
});
if (var)
SetPrecalcFlags();
return var;
}
/// <summary>
/// Delete the motion elements.
/// </summary>