--User changes
-Support 4k monitors, and in general, properly scale any monitor that is not HD. -Allow for a spatial filter of radius zero, which means do not use a spatial filter. -Add new variations: concentric, cpow3, helicoid, helix, rand_cubes, sphereblur. -Use a new method for computing elliptic which is more precise. Developed by Discord user Claude. -Remove the 8 variation per xform limitation on the GPU. -Allow for loading the last flame file on startup, rather than randoms. -Use two different default quality values in the interactive renderer, one each for CPU and GPU. -Creating linked xforms was using non-standard behavior. Make it match Apo and also support creating multiple linked xforms at once. --Bug fixes -No variations in an xform used to have the same behavior as a single linear variation with weight 1. While sensible, this breaks backward compatibility. No variations now sets the output point to zeroes. -Prevent crashing the program when adjusting a value on the main window while a final render is in progress. -The xaos table was inverted. --Code changes -Convert projects to Visual Studio 2017. -Change bad vals from +- 1e10 to +-1e20. -Reintroduce the symmetry tag in xforms for legacy support in programs that do not use color_speed. -Compiler will not let us use default values in templated member functions anymore.
This commit is contained in:
@@ -181,6 +181,19 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reserve the underlying xforms vector to contain the specified capacity.
|
||||
/// This should be called at the start of scenarios where xforms are added and their pointers
|
||||
/// are used in the process. That way no resizing takes place and the pointers remain valid.
|
||||
/// No action is taken if i is less than the existing capacity.
|
||||
/// </summary>
|
||||
/// <param name="i">The capacity to reserve</param>
|
||||
void Reserve(size_t i)
|
||||
{
|
||||
if (i > m_Xforms.capacity())
|
||||
m_Xforms.reserve(i);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a copy of a new xform to the xforms vector.
|
||||
/// </summary>
|
||||
@@ -201,6 +214,7 @@ public:
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
Xform<T> xform;
|
||||
xform.AddVariation(m_VariationList->GetVariationCopy(eVariationId::VAR_LINEAR));
|
||||
AddXform(xform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ static void sincos(float x, float* s, float* c)
|
||||
|
||||
namespace EmberNs
|
||||
{
|
||||
#define EMBER_VERSION "1.0.0.6"
|
||||
#define EMBER_VERSION "1.0.0.7"
|
||||
#define EPS6 T(1e-6)
|
||||
#define EPS std::numeric_limits<T>::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way.
|
||||
#define ISAAC_SIZE 4
|
||||
@@ -60,7 +60,7 @@ namespace EmberNs
|
||||
#define XC(c) (reinterpret_cast<const xmlChar*>(c))
|
||||
#define CX(c) (reinterpret_cast<char*>(c))
|
||||
#define CCX(c) (reinterpret_cast<const char*>(c))
|
||||
#define BadVal(x) (((x) != (x)) || ((x) > 1e10) || ((x) < -1e10))
|
||||
#define BadVal(x) (((x) != (x)) || ((x) > 1e20) || ((x) < -1e20))
|
||||
#define Vlen(x) (sizeof(x) / sizeof(*x))
|
||||
#define SQR(x) ((x) * (x))
|
||||
#define CUBE(x) ((x) * (x) * (x))
|
||||
@@ -72,17 +72,17 @@ namespace EmberNs
|
||||
#define CURVES_LENGTH_M1 65535.0f
|
||||
#define ONE_OVER_CURVES_LENGTH_M1 1.525902189669e-5f
|
||||
#define EMPTYFIELD -9999
|
||||
typedef std::chrono::high_resolution_clock Clock;
|
||||
typedef std::chrono::duration<double, std::ratio<1, 1000>> DoubleMs;
|
||||
typedef std::chrono::time_point<Clock, DoubleMs> DoubleMsTimePoint;
|
||||
static inline DoubleMsTimePoint NowMsD() { return time_point_cast<DoubleMs>(Clock::now()); }
|
||||
static inline size_t NowMs() { return duration_cast<milliseconds>(Clock::now().time_since_epoch()).count(); }
|
||||
typedef uint et;
|
||||
typedef std::lock_guard <std::recursive_mutex> rlg;
|
||||
|
||||
/// <summary>
|
||||
/// Thin wrapper around getting the current time in milliseconds.
|
||||
/// </summary>
|
||||
typedef std::chrono::high_resolution_clock Clock;
|
||||
typedef std::chrono::duration<double, std::ratio<1, 1000>> DoubleMs;
|
||||
typedef std::chrono::time_point<Clock, DoubleMs> DoubleMsTimePoint;
|
||||
static inline DoubleMsTimePoint NowMsD() { return time_point_cast<DoubleMs>(Clock::now()); }
|
||||
static inline size_t NowMs() { return duration_cast<milliseconds>(Clock::now().time_since_epoch()).count(); }
|
||||
|
||||
#ifndef byte
|
||||
typedef unsigned char byte;
|
||||
|
||||
@@ -500,7 +500,8 @@ string EmberToXml<T>::ToString(Xform<T>& xform, size_t xformCount, bool isFinal,
|
||||
|
||||
if (!doMotion || xform.m_ColorSpeed != EMPTYFIELD) os << "color_speed=\"" << xform.m_ColorSpeed << "\" ";
|
||||
|
||||
//os << "symmetry=\"" << fabs(xform.m_ColorSpeed - 1) * 2 << "\" ";//Legacy support.
|
||||
//Legacy support.
|
||||
os << "symmetry=\"" << 1 - (xform.m_ColorSpeed * 2) << "\" ";
|
||||
|
||||
if (!doMotion)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
bool Save(const string& filename, Ember<T>& ember, size_t printEditDepth, bool doEdits, bool hexPalette, bool append = false, bool start = false, bool finish = false);
|
||||
template <typename Alloc, template <typename, typename> class C>
|
||||
bool Save(const string& filename, C<Ember<T>, Alloc>& embers, size_t printEditDepth, bool doEdits, bool hexPalette, bool append = false, bool start = false, bool finish = false);
|
||||
bool Save(const string& filename, C<Ember<T>, Alloc>& embers, size_t printEditDepth, bool doEdits, bool hexPalette, bool append, bool start, bool finish);
|
||||
string ToString(Ember<T>& ember, const string& extraAttributes, size_t printEditDepth, bool doEdits, bool hexPalette = true);
|
||||
xmlDocPtr CreateNewEditdoc(Ember<T>* parent0, Ember<T>* parent1, const string& action, const string& nick, const string& url, const string& id, const string& comment, intmax_t sheepGen = 0, intmax_t sheepId = 0);
|
||||
|
||||
|
||||
@@ -806,6 +806,12 @@ bool Renderer<T, bucketT>::Alloc(bool histOnly)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_StandardIterator.get())
|
||||
m_StandardIterator = make_unique<StandardIterator<T>>();
|
||||
|
||||
if (!m_XaosIterator.get())
|
||||
m_XaosIterator = make_unique<XaosIterator<T>>();
|
||||
|
||||
if (lock)
|
||||
LeaveResize();
|
||||
|
||||
|
||||
@@ -107,6 +107,14 @@ public:
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!m_FilterRadius)
|
||||
{
|
||||
m_Filter.resize(1);
|
||||
m_Filter[0] = 1;
|
||||
m_FinalFilterWidth = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
T fw = T(2.0) * m_Support * m_Supersample * m_FilterRadius / m_PixelAspectRatio;
|
||||
T adjust, ii, jj;
|
||||
int fwidth = int(fw) + 1;
|
||||
|
||||
@@ -186,6 +186,21 @@ public:
|
||||
return static_cast<double>(temp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Integer hash function from http://burtleburtle.net/bob/hash/integer.html
|
||||
/// </summary>
|
||||
/// <param name="a">The value to hash</param>
|
||||
/// <returns>The hashed value</returns>
|
||||
static T Hash(int a)
|
||||
{
|
||||
a = (a ^ 61) ^ (a >> 16);
|
||||
a = a + (a << 3);
|
||||
a = a ^ (a >> 4);
|
||||
a = a * 0x27d4eb2d;
|
||||
a = a ^ (a >> 15);
|
||||
return (T)a / std::numeric_limits<int>::max();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve information about a piece of shared data by looking
|
||||
/// up its name.
|
||||
|
||||
@@ -39,12 +39,16 @@ enum class eVariationAssignType : et
|
||||
ASSIGNTYPE_SUM
|
||||
};
|
||||
|
||||
#define WEIGHT_PREFIX "parVars[WEIGHT_"
|
||||
|
||||
/// <summary>
|
||||
/// Complete list of every variation class ID.
|
||||
/// </summary>
|
||||
enum class eVariationId : et
|
||||
{
|
||||
VAR_ARCH,
|
||||
//VAR_ARCSINH,
|
||||
//VAR_ARCTANH,
|
||||
VAR_AUGER ,
|
||||
VAR_BARYCENTROID,
|
||||
VAR_BCIRCLE ,
|
||||
@@ -90,6 +94,7 @@ enum class eVariationId : et
|
||||
VAR_CIRCLIZE2 ,
|
||||
VAR_CIRCUS,
|
||||
VAR_COLLIDEOSCOPE,
|
||||
VAR_CONCENTRIC ,
|
||||
VAR_CONIC ,
|
||||
VAR_COS ,
|
||||
VAR_COS_WRAP ,
|
||||
@@ -103,6 +108,7 @@ enum class eVariationId : et
|
||||
VAR_COTQ ,
|
||||
VAR_CPOW ,
|
||||
VAR_CPOW2 ,
|
||||
VAR_CPOW3 ,
|
||||
VAR_CRACKLE ,
|
||||
VAR_CRESCENTS ,
|
||||
VAR_CROB ,
|
||||
@@ -180,6 +186,8 @@ enum class eVariationId : et
|
||||
VAR_HANDKERCHIEF,
|
||||
VAR_HEART ,
|
||||
VAR_HEAT,
|
||||
VAR_HELICOID,
|
||||
VAR_HELIX,
|
||||
VAR_HEMISPHERE ,
|
||||
VAR_HEXAPLAY3D ,
|
||||
VAR_HEXCROP ,
|
||||
@@ -275,6 +283,7 @@ enum class eVariationId : et
|
||||
VAR_PSPHERE ,
|
||||
VAR_Q_ODE,
|
||||
VAR_RADIAL_BLUR ,
|
||||
VAR_RAND_CUBES ,
|
||||
VAR_RATIONAL3 ,
|
||||
VAR_RAYS ,
|
||||
VAR_RBLUR,
|
||||
@@ -309,6 +318,7 @@ enum class eVariationId : et
|
||||
VAR_SINUSOIDAL ,
|
||||
VAR_SINUSOIDAL3D,
|
||||
//VAR_SMARTCROP ,
|
||||
VAR_SPHEREBLUR ,
|
||||
VAR_SPHERICAL ,
|
||||
VAR_SPHERICAL3D ,
|
||||
VAR_SPHERICALN ,
|
||||
@@ -376,6 +386,8 @@ enum class eVariationId : et
|
||||
VAR_ZTRANSLATE,
|
||||
|
||||
VAR_PRE_ARCH,
|
||||
//VAR_PRE_ARCSINH,
|
||||
//VAR_PRE_ARCTANH,
|
||||
VAR_PRE_AUGER,
|
||||
VAR_PRE_BARYCENTROID,
|
||||
VAR_PRE_BCIRCLE,
|
||||
@@ -421,6 +433,7 @@ enum class eVariationId : et
|
||||
VAR_PRE_CIRCLIZE2,
|
||||
VAR_PRE_CIRCUS,
|
||||
VAR_PRE_COLLIDEOSCOPE,
|
||||
VAR_PRE_CONCENTRIC,
|
||||
VAR_PRE_CONIC,
|
||||
VAR_PRE_COS,
|
||||
VAR_PRE_COS_WRAP,
|
||||
@@ -434,6 +447,7 @@ enum class eVariationId : et
|
||||
VAR_PRE_COTQ,
|
||||
VAR_PRE_CPOW,
|
||||
VAR_PRE_CPOW2,
|
||||
VAR_PRE_CPOW3,
|
||||
VAR_PRE_CRACKLE,
|
||||
VAR_PRE_CRESCENTS,
|
||||
VAR_PRE_CROB,
|
||||
@@ -511,6 +525,8 @@ enum class eVariationId : et
|
||||
VAR_PRE_HANDKERCHIEF,
|
||||
VAR_PRE_HEART,
|
||||
VAR_PRE_HEAT,
|
||||
VAR_PRE_HELICOID,
|
||||
VAR_PRE_HELIX,
|
||||
VAR_PRE_HEMISPHERE,
|
||||
VAR_PRE_HEXAPLAY3D,
|
||||
VAR_PRE_HEXCROP,
|
||||
@@ -606,6 +622,7 @@ enum class eVariationId : et
|
||||
VAR_PRE_PSPHERE,
|
||||
VAR_PRE_Q_ODE,
|
||||
VAR_PRE_RADIAL_BLUR,
|
||||
VAR_PRE_RAND_CUBES,
|
||||
VAR_PRE_RATIONAL3,
|
||||
VAR_PRE_RAYS,
|
||||
VAR_PRE_RBLUR,
|
||||
@@ -640,6 +657,7 @@ enum class eVariationId : et
|
||||
VAR_PRE_SINUSOIDAL,
|
||||
VAR_PRE_SINUSOIDAL3D,
|
||||
//VAR_PRE_SMARTCROP,
|
||||
VAR_PRE_SPHEREBLUR,
|
||||
VAR_PRE_SPHERICAL,
|
||||
VAR_PRE_SPHERICAL3D,
|
||||
VAR_PRE_SPHERICALN,
|
||||
@@ -707,6 +725,8 @@ enum class eVariationId : et
|
||||
VAR_PRE_ZTRANSLATE,
|
||||
|
||||
VAR_POST_ARCH,
|
||||
//VAR_POST_ARCSINH,
|
||||
//VAR_POST_ARCTANH,
|
||||
VAR_POST_AUGER,
|
||||
VAR_POST_BARYCENTROID,
|
||||
VAR_POST_BCIRCLE,
|
||||
@@ -752,6 +772,7 @@ enum class eVariationId : et
|
||||
VAR_POST_CIRCLIZE2,
|
||||
VAR_POST_CIRCUS,
|
||||
VAR_POST_COLLIDEOSCOPE,
|
||||
VAR_POST_CONCENTRIC,
|
||||
VAR_POST_CONIC,
|
||||
VAR_POST_COS,
|
||||
VAR_POST_COS_WRAP,
|
||||
@@ -765,6 +786,7 @@ enum class eVariationId : et
|
||||
VAR_POST_COTQ,
|
||||
VAR_POST_CPOW,
|
||||
VAR_POST_CPOW2,
|
||||
VAR_POST_CPOW3,
|
||||
VAR_POST_CRACKLE,
|
||||
VAR_POST_CRESCENTS,
|
||||
VAR_POST_CROB,
|
||||
@@ -842,6 +864,8 @@ enum class eVariationId : et
|
||||
VAR_POST_HANDKERCHIEF,
|
||||
VAR_POST_HEART,
|
||||
VAR_POST_HEAT,
|
||||
VAR_POST_HELICOID,
|
||||
VAR_POST_HELIX,
|
||||
VAR_POST_HEMISPHERE,
|
||||
VAR_POST_HEXAPLAY3D,
|
||||
VAR_POST_HEXCROP,
|
||||
@@ -937,6 +961,7 @@ enum class eVariationId : et
|
||||
VAR_POST_PSPHERE,
|
||||
VAR_POST_Q_ODE,
|
||||
VAR_POST_RADIAL_BLUR,
|
||||
VAR_POST_RAND_CUBES,
|
||||
VAR_POST_RATIONAL3,
|
||||
VAR_POST_RAYS,
|
||||
VAR_POST_RBLUR,
|
||||
@@ -971,6 +996,7 @@ enum class eVariationId : et
|
||||
VAR_POST_SINUSOIDAL,
|
||||
VAR_POST_SINUSOIDAL3D,
|
||||
VAR_POST_SMARTCROP,
|
||||
VAR_POST_SPHEREBLUR,
|
||||
VAR_POST_SPHERICAL,
|
||||
VAR_POST_SPHERICAL3D,
|
||||
VAR_POST_SPHERICALN,
|
||||
@@ -1472,6 +1498,11 @@ protected:
|
||||
return m_VarType == eVariationType::VARTYPE_REG ? "0;\n" : (m_PrePostAssignType == eVariationAssignType::ASSIGNTYPE_SET ? "vIn.z;\n" : "0;\n");
|
||||
}
|
||||
|
||||
string WeightDefineString() const
|
||||
{
|
||||
return WEIGHT_PREFIX + std::to_string(XformIndexInEmber()) + "_" + std::to_string(IndexInXform()) + "]";
|
||||
}
|
||||
|
||||
Xform<T>* m_Xform;//The parent Xform that this variation is a child of.
|
||||
eVariationId m_VariationId;//The unique ID of this variation.
|
||||
string m_Name;//The unique name of this variation.
|
||||
|
||||
@@ -351,6 +351,11 @@ VariationList<T>::VariationList()
|
||||
ADDPREPOSTREGVAR(Waves2Radial)
|
||||
ADDPREPOSTREGVAR(Panorama1)
|
||||
ADDPREPOSTREGVAR(Panorama2)
|
||||
ADDPREPOSTREGVAR(Helicoid)
|
||||
ADDPREPOSTREGVAR(Helix)
|
||||
ADDPREPOSTREGVAR(Sphereblur)
|
||||
ADDPREPOSTREGVAR(Cpow3)
|
||||
ADDPREPOSTREGVAR(Concentric)
|
||||
//ADDPREPOSTREGVAR(LinearXZ)
|
||||
//ADDPREPOSTREGVAR(LinearYZ)
|
||||
//DC are special.
|
||||
@@ -363,6 +368,7 @@ VariationList<T>::VariationList()
|
||||
ADDPREPOSTREGVAR(DCPerlin)
|
||||
ADDPREPOSTREGVAR(DCTriangle)
|
||||
ADDPREPOSTREGVAR(DCZTransl)
|
||||
ADDPREPOSTREGVAR(RandCubes)
|
||||
|
||||
for (auto var : m_Variations) const_cast<Variation<T>*>(var)->Precalc();//Modify once here, then const after this.
|
||||
|
||||
|
||||
+602
-456
File diff suppressed because it is too large
Load Diff
+492
-428
File diff suppressed because it is too large
Load Diff
+399
-346
File diff suppressed because it is too large
Load Diff
+420
-367
File diff suppressed because it is too large
Load Diff
+392
-363
File diff suppressed because it is too large
Load Diff
+514
-500
File diff suppressed because it is too large
Load Diff
+709
-237
File diff suppressed because it is too large
Load Diff
+225
-125
@@ -51,18 +51,19 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string weight = WeightDefineString();
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string bdcs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string bdcs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t r = precalcSumSquares;\n"
|
||||
<< "\t\treal_t r4_1 = Zeps(r / 4 + 1);\n"
|
||||
<< "\t\tr4_1 = xform->m_VariationWeights[" << varIndex << "] / r4_1;\n"
|
||||
<< "\t\tr4_1 = " << weight << " / r4_1;\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = r4_1 * vIn.x;\n"
|
||||
<< "\t\tvOut.y = r4_1 * vIn.y;\n"
|
||||
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (2 / r4_1 - 1);\n"
|
||||
<< "\t\tvOut.z = " << weight << " * (2 / r4_1 - 1);\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t sumX, sumY;\n\n";
|
||||
|
||||
@@ -105,7 +106,7 @@ protected:
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_CenterX, prefix + "dc_bubble_centerx"));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_CenterY, prefix + "dc_bubble_centery"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_bubble_scale", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_bubble_scale", 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Bdcs, prefix + "dc_bubble_bdcs"));//Precalc.
|
||||
}
|
||||
|
||||
@@ -150,8 +151,9 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string weight = WeightDefineString();
|
||||
string origin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string h = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string h = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
ss << "\t{\n"
|
||||
<< "\t\tint x0 = (MwcNext(mwc) & 1) ? -1 : 1;\n"
|
||||
<< "\t\tint y0 = (MwcNext(mwc) & 1) ? -1 : 1;\n"
|
||||
@@ -160,8 +162,8 @@ public:
|
||||
<< "\t\treal_t x0_xor_y0 = (real_t)(x0 ^ y0);\n"
|
||||
<< "\t\treal_t h = -" << h << " + (1 - x0_xor_y0) * " << h << ";\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (xform->m_A * x + xform->m_B * y + xform->m_E);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (xform->m_C * x + xform->m_D * y + xform->m_F);\n"
|
||||
<< "\t\tvOut.x = " << weight << " * (xform->m_A * x + xform->m_B * y + xform->m_E);\n"
|
||||
<< "\t\tvOut.y = " << weight << " * (xform->m_C * x + xform->m_D * y + xform->m_F);\n"
|
||||
<< "\t\tvOut.z = " << DefaultZCl()
|
||||
<< "\t\toutPoint->m_ColorX = fmod(fabs(outPoint->m_ColorX * (real_t)(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * (real_t)(0.5)), (real_t)(1.0));\n"
|
||||
<< "\t}\n";
|
||||
@@ -260,15 +262,16 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string cubeC1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string cubeC2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC5 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC6 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeX = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeY = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string weight = WeightDefineString();
|
||||
string cubeC1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string cubeC2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC5 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeC6 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeX = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeY = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cubeZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string clampC1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string clampC2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string clampC3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
@@ -285,9 +288,9 @@ public:
|
||||
<< "\t\tswitch (i)\n"
|
||||
<< "\t\t{\n"
|
||||
<< "\t\t case 0:\n"
|
||||
<< "\t\t x = xform->m_VariationWeights[" << varIndex << "] * (j ? -1 : 1);\n"
|
||||
<< "\t\t y = xform->m_VariationWeights[" << varIndex << "] * p;\n"
|
||||
<< "\t\t z = xform->m_VariationWeights[" << varIndex << "] * q;\n"
|
||||
<< "\t\t x = " << weight << " * (j ? -1 : 1);\n"
|
||||
<< "\t\t y = " << weight << " * p;\n"
|
||||
<< "\t\t z = " << weight << " * q;\n"
|
||||
<< "\n"
|
||||
<< "\t\t if (j)\n"
|
||||
<< "\t\t outPoint->m_ColorX = " << clampC1 << ";\n"
|
||||
@@ -296,9 +299,9 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\t break;\n"
|
||||
<< "\t\t case 1:\n"
|
||||
<< "\t\t x =xform->m_VariationWeights[" << varIndex << "] * p;\n"
|
||||
<< "\t\t y =xform->m_VariationWeights[" << varIndex << "] * (j ? -1 : 1);\n"
|
||||
<< "\t\t z =xform->m_VariationWeights[" << varIndex << "] * q;\n"
|
||||
<< "\t\t x =" << weight << " * p;\n"
|
||||
<< "\t\t y =" << weight << " * (j ? -1 : 1);\n"
|
||||
<< "\t\t z =" << weight << " * q;\n"
|
||||
<< "\n"
|
||||
<< "\t\t if (j)\n"
|
||||
<< "\t\t outPoint->m_ColorX = " << clampC3 << ";\n"
|
||||
@@ -307,9 +310,9 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\t break;\n"
|
||||
<< "\t\t case 2:\n"
|
||||
<< "\t\t x = xform->m_VariationWeights[" << varIndex << "] * p;\n"
|
||||
<< "\t\t y = xform->m_VariationWeights[" << varIndex << "] * q;\n"
|
||||
<< "\t\t z = xform->m_VariationWeights[" << varIndex << "] * (j ? -1 : 1);\n"
|
||||
<< "\t\t x = " << weight << " * p;\n"
|
||||
<< "\t\t y = " << weight << " * q;\n"
|
||||
<< "\t\t z = " << weight << " * (j ? -1 : 1);\n"
|
||||
<< "\n"
|
||||
<< "\t\t if (j)\n"
|
||||
<< "\t\t outPoint->m_ColorX = " << clampC5 << ";\n"
|
||||
@@ -347,9 +350,9 @@ protected:
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeC4, prefix + "dc_cube_c4"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeC5, prefix + "dc_cube_c5"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeC6, prefix + "dc_cube_c6"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeX, prefix + "dc_cube_x", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeY, prefix + "dc_cube_y", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeZ, prefix + "dc_cube_z", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeX, prefix + "dc_cube_x", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeY, prefix + "dc_cube_y", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_DcCubeZ, prefix + "dc_cube_z", 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_ClampC1, prefix + "dc_cube_clamp_c1"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_ClampC2, prefix + "dc_cube_clamp_c2"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_ClampC3, prefix + "dc_cube_clamp_c3"));
|
||||
@@ -424,24 +427,25 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string weight = WeightDefineString();
|
||||
string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string blur = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string ldcs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string ldca = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string blur = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string ldcs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string ldca = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t temp = MwcNext(mwc) * M_2PI;\n"
|
||||
<< "\t\treal_t sr = sin(temp);\n"
|
||||
<< "\t\treal_t cr = cos(temp);\n"
|
||||
<< "\t\treal_t r = " << blur << " * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - 2);\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x + r * sr)* " << x << ";\n"
|
||||
<< "\t\tvOut.x = " << weight << " * sin(vIn.x + r * sr)* " << x << ";\n"
|
||||
<< "\t\tvOut.y = r + vIn.y * " << y << ";\n"
|
||||
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * cos(vIn.x + r * cr);\n"
|
||||
<< "\t\tvOut.z = " << weight << " * cos(vIn.x + r * cr);\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t sumX, sumY;\n\n";
|
||||
|
||||
@@ -480,11 +484,11 @@ protected:
|
||||
string prefix = Prefix();
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Offset, prefix + "dc_cylinder_offset"));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Angle, prefix + "dc_cylinder_angle"));//Original used a prefix of dc_cyl_, which is incompatible with Ember's design.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_cylinder_scale", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_X, prefix + "dc_cylinder_x", T(0.125)));//Original used a prefix of cyl_, which is incompatible with Ember's design.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "dc_cylinder_y", T(0.125)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Blur, prefix + "dc_cylinder_blur", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Angle, prefix + "dc_cylinder_angle"));//Original used a prefix of dc_cyl_, which is incompatible with Ember's design.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_cylinder_scale", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_X, prefix + "dc_cylinder_x", T(0.125)));//Original used a prefix of cyl_, which is incompatible with Ember's design.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "dc_cylinder_y", T(0.125)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Blur, prefix + "dc_cylinder_blur", 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Sina, prefix + "dc_cylinder_sina"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Cosa, prefix + "dc_cylinder_cosa"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Ldcs, prefix + "dc_cylinder_ldcs"));
|
||||
@@ -596,6 +600,7 @@ public:
|
||||
{
|
||||
ostringstream ss;
|
||||
intmax_t varIndex = IndexInXform();
|
||||
string weight = WeightDefineString();
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t x = LRint(vIn.x);\n"
|
||||
<< "\t\treal_t y = LRint(vIn.y);\n"
|
||||
@@ -607,14 +612,14 @@ public:
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t if (-y >= x)\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + 1);\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\t vOut.x = " << weight << " * (vIn.x + 1);\n"
|
||||
<< "\t\t vOut.y = " << weight << " * vIn.y;\n"
|
||||
<< "\t\t c += (real_t)(0.25);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + 1);\n"
|
||||
<< "\t\t vOut.x = " << weight << " * vIn.x;\n"
|
||||
<< "\t\t vOut.y = " << weight << " * (vIn.y + 1);\n"
|
||||
<< "\t\t c += (real_t)(0.75);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t }\n"
|
||||
@@ -622,14 +627,14 @@ public:
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t if (y <= x)\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + 1);\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\t vOut.x = " << weight << " * (vIn.x + 1);\n"
|
||||
<< "\t\t vOut.y = " << weight << " * vIn.y;\n"
|
||||
<< "\t\t c += (real_t)(0.25);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y - 1);\n"
|
||||
<< "\t\t vOut.x = " << weight << " * vIn.x;\n"
|
||||
<< "\t\t vOut.y = " << weight << " * (vIn.y - 1);\n"
|
||||
<< "\t\t c += (real_t)(0.75);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t }\n"
|
||||
@@ -640,14 +645,14 @@ public:
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t if (y >= x)\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x - 1);\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\t vOut.x = " << weight << " * (vIn.x - 1);\n"
|
||||
<< "\t\t vOut.y = " << weight << " * vIn.y;\n"
|
||||
<< "\t\t c += (real_t)(0.25);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + 1);\n"
|
||||
<< "\t\t vOut.x = " << weight << " * vIn.x;\n"
|
||||
<< "\t\t vOut.y = " << weight << " * (vIn.y + 1);\n"
|
||||
<< "\t\t c += (real_t)(0.75);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t }\n"
|
||||
@@ -655,14 +660,14 @@ public:
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t if (y > -x)\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x - 1);\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\t vOut.x = " << weight << " * (vIn.x - 1);\n"
|
||||
<< "\t\t vOut.y = " << weight << " * vIn.y;\n"
|
||||
<< "\t\t c += (real_t)(0.25);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y - 1);\n"
|
||||
<< "\t\t vOut.x = " << weight << " * vIn.x;\n"
|
||||
<< "\t\t vOut.y = " << weight << " * (vIn.y - 1);\n"
|
||||
<< "\t\t c += (real_t)(0.75);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t }\n"
|
||||
@@ -724,17 +729,18 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string weight = WeightDefineString();
|
||||
string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string ldcs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string ldca = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string ldcs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string ldca = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
|
||||
<< "\t\tvOut.x = " << weight << " * vIn.x;\n"
|
||||
<< "\t\tvOut.y = " << weight << " * vIn.y;\n"
|
||||
<< "\t\tvOut.z = " << weight << " * vIn.z;\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t sumX, sumY;\n\n";
|
||||
|
||||
@@ -773,8 +779,8 @@ protected:
|
||||
string prefix = Prefix();
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Offset, prefix + "dc_linear_offset"));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Angle, prefix + "dc_linear_angle"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_linear_scale", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Angle, prefix + "dc_linear_angle"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_linear_scale", 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Ldcs, prefix + "dc_linear_ldcs"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Ldca, prefix + "dc_linear_ldca"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Sina, prefix + "dc_linear_sina"));
|
||||
@@ -894,9 +900,10 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string weight = WeightDefineString();
|
||||
string scatterArea = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string zeroEdges = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string zeroEdges = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
ss << "\t{\n"
|
||||
<< "\t\tconst real_t\n"
|
||||
<< "\t\txx = xform->m_A, xy = xform->m_B,\n"
|
||||
@@ -969,9 +976,9 @@ public:
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (ox + u * xx + v * yx);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (oy + u * xy + v * yy);\n"
|
||||
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
|
||||
<< "\t\tvOut.x = " << weight << " * (ox + u * xx + v * yx);\n"
|
||||
<< "\t\tvOut.y = " << weight << " * (oy + u * xy + v * yy);\n"
|
||||
<< "\t\tvOut.z = " << weight << " * vIn.z;\n"
|
||||
<< "\t\toutPoint->m_ColorX = fmod(fabs(u + v), (real_t)(1.0));\n"
|
||||
<< "\t}\n";
|
||||
return ss.str();
|
||||
@@ -988,8 +995,8 @@ protected:
|
||||
string prefix = Prefix();
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_ScatterArea, prefix + "dc_triangle_scatter_area", 0, eParamType::REAL, -1, 1));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_ZeroEdges, prefix + "dc_triangle_zero_edges", 0, eParamType::INTEGER, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_A, prefix + "dc_triangle_a"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(&m_ZeroEdges, prefix + "dc_triangle_zero_edges", 0, eParamType::INTEGER, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_A, prefix + "dc_triangle_a"));//Precalc.
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1036,27 +1043,28 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string x1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string factor = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string weight = WeightDefineString();
|
||||
string x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Params.
|
||||
string x1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string factor = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string overwrite = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
|
||||
string clamp = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x0_ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x1_ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x1_m_x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string clamp = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x0_ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x1_ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x1_m_x0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t zf = " << factor << " * (outPoint->m_ColorX - " << x0_ << ") / " << x1_m_x0 << ";\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (" << clamp << " != 0)\n"
|
||||
<< "\t\t zf = zf < 0 ? 0 : zf > 1 ? 1 : zf;\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\tvOut.x = " << weight << " * vIn.x;\n"
|
||||
<< "\t\tvOut.y = " << weight << " * vIn.y;\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (" << overwrite << " == 0)\n"
|
||||
<< "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z * zf;\n"
|
||||
<< "\t\t vOut.z = " << weight << " * vIn.z * zf;\n"
|
||||
<< "\t\telse\n"
|
||||
<< "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * zf;\n"
|
||||
<< "\t\t vOut.z = " << weight << " * zf;\n"
|
||||
<< "\t}\n";
|
||||
return ss.str();
|
||||
}
|
||||
@@ -1073,13 +1081,13 @@ protected:
|
||||
{
|
||||
string prefix = Prefix();
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_X0, prefix + "dc_ztransl_x0", 0, eParamType::REAL, 0, 1));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_X1, prefix + "dc_ztransl_x1", 1, eParamType::REAL, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Factor, prefix + "dc_ztransl_factor", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_X0, prefix + "dc_ztransl_x0", 0, eParamType::REAL, 0, 1));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_X1, prefix + "dc_ztransl_x1", 1, eParamType::REAL, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Factor, prefix + "dc_ztransl_factor", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Overwrite, prefix + "dc_ztransl_overwrite", 1, eParamType::INTEGER, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Clamp, prefix + "dc_ztransl_clamp", 0, eParamType::INTEGER, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_X0_, prefix + "dc_ztransl_x0_"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_X1_, prefix + "dc_ztransl_x1_"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Clamp, prefix + "dc_ztransl_clamp", 0, eParamType::INTEGER, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_X0_, prefix + "dc_ztransl_x0_"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_X1_, prefix + "dc_ztransl_x1_"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_X1_m_x0, prefix + "dc_ztransl_x1_m_x0"));
|
||||
}
|
||||
|
||||
@@ -1262,22 +1270,23 @@ public:
|
||||
ostringstream ss, ss2;
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber();
|
||||
string weight = WeightDefineString();
|
||||
string index = ss2.str() + "]";
|
||||
string shape = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string map = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string selectCentre = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string selectRange = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string centre = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string range = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string edge = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string octaves = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string amps = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string freqs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string shape = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string map = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string selectCentre = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string selectRange = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string centre = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string range = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string edge = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string octaves = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string amps = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string freqs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string selectBailout = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string notchBottom = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string notchTop = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string notchBottom = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string notchTop = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal4 v;\n"
|
||||
<< "\t\treal_t vx, vy, col, r, theta, s, c, p, e;\n"
|
||||
@@ -1393,8 +1402,8 @@ public:
|
||||
<< "\t\t}\n"
|
||||
<< "\t\twhile ((e < " << notchBottom << " || e > " << notchTop << ") && t++ < iBailout); \n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vx; \n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vy; \n"
|
||||
<< "\t\tvOut.x = " << weight << " * vx; \n"
|
||||
<< "\t\tvOut.y = " << weight << " * vy; \n"
|
||||
<< "\t\tvOut.z = " << DefaultZCl()
|
||||
<< "\t\tcol = " << centre << " + " << range << " * p; \n"
|
||||
<< "\t\toutPoint->m_ColorX = col - floor(col); \n"
|
||||
@@ -1417,21 +1426,21 @@ protected:
|
||||
string prefix = Prefix();
|
||||
m_Params.clear();
|
||||
m_Params.reserve(15);
|
||||
m_Params.push_back(ParamWithName<T>(&m_Shape, prefix + "dc_perlin_shape", 0, eParamType::INTEGER, 0, 2));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Map, prefix + "dc_perlin_map", 0, eParamType::INTEGER, 0, 5));
|
||||
m_Params.push_back(ParamWithName<T>(&m_SelectCentre, prefix + "dc_perlin_select_centre", 0, eParamType::REAL, -1, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_SelectRange, prefix + "dc_perlin_select_range", 1, eParamType::REAL, T(0.1), 2));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Centre, prefix + "dc_perlin_centre", T(0.25)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Range, prefix + "dc_perlin_range", T(0.25)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Edge, prefix + "dc_perlin_edge"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_perlin_scale", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Octaves, prefix + "dc_perlin_octaves", 2, eParamType::INTEGER, 1, 5));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Amps, prefix + "dc_perlin_amps", 2));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Freqs, prefix + "dc_perlin_freqs", 2));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Z, prefix + "dc_perlin_z"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Shape, prefix + "dc_perlin_shape", 0, eParamType::INTEGER, 0, 2));//Params.
|
||||
m_Params.push_back(ParamWithName<T>(&m_Map, prefix + "dc_perlin_map", 0, eParamType::INTEGER, 0, 5));
|
||||
m_Params.push_back(ParamWithName<T>(&m_SelectCentre, prefix + "dc_perlin_select_centre", 0, eParamType::REAL, -1, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_SelectRange, prefix + "dc_perlin_select_range", 1, eParamType::REAL, T(0.1), 2));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Centre, prefix + "dc_perlin_centre", T(0.25)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Range, prefix + "dc_perlin_range", T(0.25)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Edge, prefix + "dc_perlin_edge"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "dc_perlin_scale", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Octaves, prefix + "dc_perlin_octaves", 2, eParamType::INTEGER, 1, 5));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Amps, prefix + "dc_perlin_amps", 2));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Freqs, prefix + "dc_perlin_freqs", 2));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Z, prefix + "dc_perlin_z"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_SelectBailout, prefix + "dc_perlin_select_bailout", 10, eParamType::INTEGER, 2, 1000));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_NotchBottom, prefix + "dc_perlin_notch_bottom"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_NotchTop, prefix + "dc_perlin_notch_top"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_NotchTop, prefix + "dc_perlin_notch_top"));
|
||||
}
|
||||
private:
|
||||
T m_Shape;//Params.
|
||||
@@ -1452,6 +1461,96 @@ private:
|
||||
shared_ptr<VarFuncs<T>> m_VarFuncs = VarFuncs<T>::Instance();
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// randCubes.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class RandCubesVariation : public ParametricVariation<T>
|
||||
{
|
||||
public:
|
||||
RandCubesVariation(T weight = 1.0) : ParametricVariation<T>("randCubes", eVariationId::VAR_RAND_CUBES, weight)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
PARVARCOPY(RandCubesVariation)
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
auto blockx = Floor<T>(std::log(rand.Frand01<T>()) * (rand.RandBit() ? m_Spread : -m_Spread));
|
||||
auto blocky = Floor<T>(std::log(rand.Frand01<T>()) * (rand.RandBit() ? m_Spread : -m_Spread));
|
||||
T z = VarFuncs<T>::Hash(int(blockx * m_Seed)) + VarFuncs<T>::Hash(int(blockx + blocky * m_Seed)); //random height for each block
|
||||
|
||||
if (m_VarType == eVariationType::VARTYPE_REG)
|
||||
{
|
||||
outPoint.m_X = 0;//This variation intentionally assigns instead of summing.
|
||||
outPoint.m_Y = 0;
|
||||
outPoint.m_Z = 0;
|
||||
}
|
||||
|
||||
helper.Out.x = (blockx * m_Density + rand.Frand01<T>()) * m_BlockSize;
|
||||
helper.Out.y = (blocky * m_Density + rand.Frand01<T>()) * m_BlockSize;
|
||||
helper.Out.z = m_BlockHeight * z * std::pow(rand.Frand01<T>(), T(0.125)); //fade out down
|
||||
outPoint.m_ColorX = z / 2;//block height -> palette location
|
||||
}
|
||||
|
||||
virtual string OpenCLString() const override
|
||||
{
|
||||
ostringstream ss, ss2;
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string weight = WeightDefineString();
|
||||
string blocksize = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string blockheight = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string spread = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string density = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t blockx = floor(log(MwcNext01(mwc)) * ((MwcNext(mwc) & 1) ? " << spread << " : -" << spread << "));\n"
|
||||
<< "\t\treal_t blocky = floor(log(MwcNext01(mwc)) * ((MwcNext(mwc) & 1) ? " << spread << " : -" << spread << "));\n"
|
||||
<< "\t\treal_t z = Hash(blockx * " << seed << ") + Hash(blockx + blocky * " << seed << ");\n";
|
||||
|
||||
if (m_VarType == eVariationType::VARTYPE_REG)
|
||||
{
|
||||
ss << "\t\toutPoint->m_X = 0;\n"
|
||||
<< "\t\toutPoint->m_Y = 0;\n"
|
||||
<< "\t\toutPoint->m_Z = 0;\n";
|
||||
}
|
||||
|
||||
ss << "\t\tvOut.x = (blockx * " << density << " + MwcNext01(mwc)) * " << blocksize << ";\n"
|
||||
<< "\t\tvOut.y = (blocky * " << density << " + MwcNext01(mwc)) * " << blocksize << ";\n"
|
||||
<< "\t\tvOut.z = " << blockheight << " * z * pow(MwcNext01(mwc), 0.125);\n"
|
||||
<< "\t\toutPoint->m_ColorX = z / 2;\n"
|
||||
<< "\t}\n";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
virtual vector<string> OpenCLGlobalFuncNames() const override
|
||||
{
|
||||
return vector<string> { "Hash" };
|
||||
}
|
||||
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlockSize, prefix + "randCubes_blockSize", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlockHeight, prefix + "randCubes_blockHeight", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Spread, prefix + "randCubes_spread", 3));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Seed, prefix + "randCubes_seed", 1, eParamType::INTEGER));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Density, prefix + "randCubes_density", 1));
|
||||
}
|
||||
|
||||
private:
|
||||
T m_BlockSize;
|
||||
T m_BlockHeight;
|
||||
T m_Spread;
|
||||
T m_Seed;
|
||||
T m_Density;
|
||||
};
|
||||
|
||||
MAKEPREPOSTPARVAR(DCBubble, dc_bubble, DC_BUBBLE)
|
||||
MAKEPREPOSTPARVAR(DCCarpet, dc_carpet, DC_CARPET)
|
||||
MAKEPREPOSTPARVARASSIGN(DCCube, dc_cube, DC_CUBE, eVariationAssignType::ASSIGNTYPE_SUM)
|
||||
@@ -1461,4 +1560,5 @@ MAKEPREPOSTPARVAR(DCLinear, dc_linear, DC_LINEAR)
|
||||
MAKEPREPOSTPARVAR(DCTriangle, dc_triangle, DC_TRIANGLE)
|
||||
MAKEPREPOSTPARVAR(DCZTransl, dc_ztransl, DC_ZTRANSL)
|
||||
MAKEPREPOSTPARVAR(DCPerlin, dc_perlin, DC_PERLIN)
|
||||
MAKEPREPOSTPARVAR(RandCubes, randCubes, RAND_CUBES)
|
||||
}
|
||||
|
||||
+8
-10
@@ -656,9 +656,9 @@ public:
|
||||
{
|
||||
//There are no variations, so the affine transformed points can be assigned directly to the output points.
|
||||
T inX = inPoint->m_X;
|
||||
outPoint->m_X = (m_Affine.A() * inX) + (m_Affine.B() * inPoint->m_Y) + m_Affine.C();
|
||||
outPoint->m_Y = (m_Affine.D() * inX) + (m_Affine.E() * inPoint->m_Y) + m_Affine.F();
|
||||
outPoint->m_Z = inPoint->m_Z;
|
||||
outPoint->m_X = 0;//(m_Affine.A() * inX) + (m_Affine.B() * inPoint->m_Y) + m_Affine.C();
|
||||
outPoint->m_Y = 0;//(m_Affine.D() * inX) + (m_Affine.E() * inPoint->m_Y) + m_Affine.F();
|
||||
outPoint->m_Z = 0;//inPoint->m_Z;
|
||||
}
|
||||
|
||||
//Apply post variations, these will modify outPoint.
|
||||
@@ -917,17 +917,15 @@ public:
|
||||
|
||||
if (shouldFlatten)//Flatten was not present and neither was any variation name or parameter in the list.
|
||||
{
|
||||
auto var = vl->GetVariationCopy(eVariationId::VAR_FLATTEN);
|
||||
auto varflatten = vl->GetVariationCopy(eVariationId::VAR_FLATTEN);
|
||||
|
||||
if (AddVariation(var))
|
||||
if (!AddVariation(varflatten))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete var;
|
||||
delete varflatten;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+28
-11
@@ -45,7 +45,7 @@ XmlToEmber<T>::XmlToEmber()
|
||||
if (!m_Init)
|
||||
{
|
||||
//This list is for variation params which are incorrect, but their parent variation name may or may not be correct.
|
||||
//This has some overlap with the list below since some of these have parent variation names that are incorrect.
|
||||
//This has some overlap with the list below since some of these have parent variation names that are also incorrect.
|
||||
m_BadParamNames = unordered_map<string, string>
|
||||
{
|
||||
{ "swtin_distort", "stwin_distort" }, //stwin.
|
||||
@@ -163,7 +163,16 @@ XmlToEmber<T>::XmlToEmber()
|
||||
{ "w2r_distance", "waves2_radial_distance" },
|
||||
{ "tf_exponent", "Truchet_fill_exponent" },
|
||||
{ "tf_arc_width", "Truchet_fill_arc_width" },
|
||||
{ "tf_seed", "Truchet_fill_seed" }
|
||||
{ "tf_seed", "Truchet_fill_seed" },
|
||||
{ "blockSize", "randCubes_blockSize" },
|
||||
{ "blockHeight", "randCubes_blockHeight" },
|
||||
{ "spread", "randCubes_spread" },
|
||||
{ "seed", "randCubes_seed" },
|
||||
{ "density", "randCubes_density" },
|
||||
{ "radius", "concentric_radius" },
|
||||
//{ "density", "concentric_density" },//Can't have two, which means you can never properly paste from Apophysis with both of these in one xform.
|
||||
{ "R_blur", "concentric_R_blur" },
|
||||
{ "Z_blur", "concentric_Z_blur" }
|
||||
};
|
||||
m_FlattenNames =
|
||||
{
|
||||
@@ -191,6 +200,7 @@ XmlToEmber<T>::XmlToEmber()
|
||||
"post_rotate_x",
|
||||
"post_rotate_y",
|
||||
"curl3D_cz",
|
||||
"flatten"//Of course don't flatten if it's already present.
|
||||
};
|
||||
//This is a vector of the incorrect variation names and their param names as they are in the legacy, badly named flam3/Apophysis code.
|
||||
vector<string> badParams =
|
||||
@@ -284,7 +294,6 @@ template <typename T>
|
||||
template <typename Alloc, template <typename, typename> class C>
|
||||
bool XmlToEmber<T>::Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& embers, bool useDefaults)
|
||||
{
|
||||
char* bn;
|
||||
const char* xmlPtr;
|
||||
const char* loc = __FUNCTION__;
|
||||
size_t emberSize;
|
||||
@@ -298,16 +307,17 @@ bool XmlToEmber<T>::Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& e
|
||||
xmlPtr = CX(&buf[0]);
|
||||
bufSize = strlen(xmlPtr);
|
||||
//embers.reserve(bufSize / 2500);//The Xml text for an ember is around 2500 bytes, but can be much more. Pre-allocate to aovid unnecessary resizing.
|
||||
doc = xmlReadMemory(xmlPtr, int(bufSize), filename, "ISO-8859-1", XML_PARSE_HUGE);
|
||||
int flags = XML_PARSE_HUGE;// | XML_PARSE_RECOVER;
|
||||
doc = xmlReadMemory(xmlPtr, int(bufSize), filename, "ISO-8859-1", flags);
|
||||
//t.Toc("xmlReadMemory");
|
||||
|
||||
if (doc == nullptr)
|
||||
{
|
||||
doc = xmlReadMemory(xmlPtr, int(bufSize), filename, "UTF-8", XML_PARSE_HUGE);
|
||||
doc = xmlReadMemory(xmlPtr, int(bufSize), filename, "UTF-8", flags);
|
||||
|
||||
if (doc == nullptr)
|
||||
{
|
||||
doc = xmlReadMemory(xmlPtr, int(bufSize), filename, "UTF-16", XML_PARSE_HUGE);
|
||||
doc = xmlReadMemory(xmlPtr, int(bufSize), filename, "UTF-16", flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,8 +331,7 @@ bool XmlToEmber<T>::Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& e
|
||||
rootnode = xmlDocGetRootElement(doc);
|
||||
//Scan for <flame> nodes, starting with this node.
|
||||
//t.Tic();
|
||||
bn = basename(const_cast<char*>(filename));
|
||||
ScanForEmberNodes(rootnode, bn, embers, useDefaults);
|
||||
ScanForEmberNodes(rootnode, filename, embers, useDefaults);
|
||||
xmlFreeDoc(doc);
|
||||
emberSize = embers.size();
|
||||
auto first = embers.begin();
|
||||
@@ -345,6 +354,11 @@ bool XmlToEmber<T>::Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& e
|
||||
secondToLast->m_Interp = eInterp::EMBER_INTERP_LINEAR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddToReport(string(loc) + " : Error parsing xml file " + string(filename) + ", no flames present.");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Finally, ensure that consecutive 'rotate' parameters never exceed
|
||||
//a difference of more than 180 degrees (+/-) for interpolation.
|
||||
@@ -438,7 +452,7 @@ bool XmlToEmber<T>::Aton(const char* str, valT& val)
|
||||
/// <param name="useDefaults">True to use defaults if they are not present in the file, else false to use invalid values as placeholders to indicate the values were not present.</param>
|
||||
template <typename T>
|
||||
template <typename Alloc, template <typename, typename> class C>
|
||||
void XmlToEmber<T>::ScanForEmberNodes(xmlNode* curNode, char* parentFile, C<Ember<T>, Alloc>& embers, bool useDefaults)
|
||||
void XmlToEmber<T>::ScanForEmberNodes(xmlNode* curNode, const char* parentFile, C<Ember<T>, Alloc>& embers, bool useDefaults)
|
||||
{
|
||||
bool parseEmberSuccess;
|
||||
xmlNodePtr thisNode = nullptr;
|
||||
@@ -1025,6 +1039,7 @@ bool XmlToEmber<T>::ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber
|
||||
}
|
||||
}
|
||||
|
||||
//If new_linear == 0, manually add a linear
|
||||
if (!fromEmber && !newLinear)
|
||||
currentEmber.Flatten(m_FlattenNames);
|
||||
|
||||
@@ -1107,7 +1122,7 @@ bool XmlToEmber<T>::ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion,
|
||||
xform.m_Name = string(attStr);
|
||||
std::replace(xform.m_Name.begin(), xform.m_Name.end(), ' ', '_');
|
||||
}
|
||||
else if (!Compare(curAtt->name, "symmetry"))//Legacy support.
|
||||
else if (!fromEmber && !Compare(curAtt->name, "symmetry"))//Legacy support.
|
||||
{
|
||||
//Deprecated, set both color_speed and animate to this value.
|
||||
//Huh? Either set it or not?
|
||||
@@ -1284,6 +1299,8 @@ bool XmlToEmber<T>::ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion,
|
||||
if (Aton(attStr, val))
|
||||
{
|
||||
parVar->SetParamVal(name, val);
|
||||
//if (!parVar->SetParamVal(name, val))
|
||||
// AddToReport(string(loc) + " : Failed to set parametric variation parameter " + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1382,7 +1399,7 @@ bool XmlToEmber<T>::XmlContainsTag(xmlAttrPtr att, const char* name)
|
||||
/// <param name="chan">The number of channels in each color</param>
|
||||
/// <returns>True if there were no errors, else false.</returns>
|
||||
template <typename T>
|
||||
bool XmlToEmber<T>::ParseHexColors(char* colstr, Ember<T>& ember, size_t numColors, intmax_t chan)
|
||||
bool XmlToEmber<T>::ParseHexColors(const char* colstr, Ember<T>& ember, size_t numColors, intmax_t chan)
|
||||
{
|
||||
stringstream ss, temp(colstr); ss >> std::hex;
|
||||
string s1, s;
|
||||
|
||||
@@ -47,23 +47,23 @@ class EMBER_API XmlToEmber : public EmberReport
|
||||
public:
|
||||
XmlToEmber();
|
||||
template <typename Alloc, template <typename, typename> class C>
|
||||
bool Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& embers, bool useDefaults = true);
|
||||
bool Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& embers, bool useDefaults);
|
||||
template <typename Alloc, template <typename, typename> class C>
|
||||
bool Parse(const char* filename, C<Ember<T>, Alloc>& embers, bool useDefaults = true);
|
||||
bool Parse(const char* filename, C<Ember<T>, Alloc>& embers, bool useDefaults);
|
||||
template <typename valT>
|
||||
bool Aton(const char* str, valT& val);
|
||||
static vector<string> m_FlattenNames;
|
||||
|
||||
private:
|
||||
template <typename Alloc, template <typename, typename> class C>
|
||||
void ScanForEmberNodes(xmlNode* curNode, char* parentFile, C<Ember<T>, Alloc>& embers, bool useDefaults);
|
||||
void ScanForEmberNodes(xmlNode* curNode, const char* parentFile, C<Ember<T>, Alloc>& embers, bool useDefaults);
|
||||
bool ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber);
|
||||
bool AttToEmberMotionFloat(xmlAttrPtr att, const char* attStr, eEmberMotionParam param, EmberMotion<T>& motion);
|
||||
bool ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion, bool fromEmber);
|
||||
static string GetCorrectedParamName(const unordered_map<string, string>& names, const char* name);
|
||||
static string GetCorrectedVariationName(vector<pair<pair<string, string>, vector<string>>>& vec, xmlAttrPtr att);
|
||||
static bool XmlContainsTag(xmlAttrPtr att, const char* name);
|
||||
bool ParseHexColors(char* colstr, Ember<T>& ember, size_t numColors, intmax_t chan);
|
||||
bool ParseHexColors(const char* colstr, Ember<T>& ember, size_t numColors, intmax_t chan);
|
||||
template <typename valT>
|
||||
bool ParseAndAssign(const xmlChar* name, const char* attStr, const char* str, valT& val, bool& b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user