From a3ecbbf6903b55d9dde22ca491dff6bd0e95e6f9 Mon Sep 17 00:00:00 2001 From: mfeemster Date: Tue, 12 Jan 2016 20:42:12 -0800 Subject: [PATCH] --User changes -Add post_smartcrop. --Bug fixes -Fix bug in crackle. -Wrong point assignment in hexaplay3D, hexnix3D. -Improper Z assignment in rblur. -Fix inconsistency with original in circlecrop. -Put EMBER_ROOT bakc to ./../../../ in default.pri. This is TBD. --Code changes -Convert all enums to class enum to be consistent with C++11 style. -Convert some if/else statements in filter classes to case statements. -Add overloaded stream operators to print various enums. -Optimize crob, nBlur. -Fix weird assignment statement in falloff3. -Cleanup in VarFuncs::SimplexNoise3D(). -Replace fabs() with std::abs(). -General cleanup. --- Builds/QtCreator/defaults.pri | 9 +- Data/Variations.xlsx | Bin 29029 -> 29043 bytes Source/Ember/Ember.cpp | 1 + Source/Ember/Utils.h | 2 +- Source/Ember/VarFuncs.h | 45 +- Source/Ember/Variation.h | 2 +- Source/Ember/VariationList.h | 1 + Source/Ember/Variations01.h | 24 +- Source/Ember/Variations02.h | 310 +----- Source/Ember/Variations03.h | 36 +- Source/Ember/Variations04.h | 646 +++++-------- Source/Ember/Variations05.h | 983 +++++++++----------- Source/Ember/Variations06.h | 777 ++++++++++++---- Source/Ember/VariationsDC.h | 10 +- Source/Ember/XmlToEmber.h | 26 +- Source/EmberCL/FunctionMapper.cpp | 35 +- Source/EmberCL/IterOpenCLKernelCreator.cpp | 3 - Source/EmberCL/OpenCLWrapper.cpp | 1 + Source/EmberTester/EmberTester.cpp | 16 +- Source/Fractorium/GLEmberController.cpp | 4 +- Source/Fractorium/GLWidget.cpp | 8 +- Source/Fractorium/VariationTreeWidgetItem.h | 9 +- 22 files changed, 1402 insertions(+), 1546 deletions(-) diff --git a/Builds/QtCreator/defaults.pri b/Builds/QtCreator/defaults.pri index 77861cd..8cd5335 100644 --- a/Builds/QtCreator/defaults.pri +++ b/Builds/QtCreator/defaults.pri @@ -11,7 +11,10 @@ unix|macx { } # When loaded by QtCreator -EMBER_ROOT = $$(PWD)/../../.. +#This cannot be this... +#EMBER_ROOT = $$(PWD)/../../.. +#It must be this... +EMBER_ROOT = ./../../../ # When compiling from project root autobuild { @@ -28,11 +31,11 @@ LOCAL_INCLUDE_DIR = $$(PWD)/../../include CONFIG(release, debug|release) { CONFIG += warn_off - DESTDIR = $$(PWD)/../../../Bin/release + DESTDIR = $$EMBER_ROOT/Bin/release } CONFIG(debug, debug|release) { - DESTDIR = $$(PWD)/../../../Bin/debug + DESTDIR = $$EMBER_ROOT/Bin/debug } macx { diff --git a/Data/Variations.xlsx b/Data/Variations.xlsx index 5ac3a17c7e6158cbf5b17b35568be52d4f9fc198..040dd5c280f173fcea73f28602ac246adb289110 100644 GIT binary patch delta 10002 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 diff --git a/Source/Ember/Ember.cpp b/Source/Ember/Ember.cpp index 9105f24..5b7ab1f 100644 --- a/Source/Ember/Ember.cpp +++ b/Source/Ember/Ember.cpp @@ -379,6 +379,7 @@ uint Timing::m_ProcessorCount; EXPORTPREPOSTREGVAR(BubbleT3D, T) \ EXPORTPREPOSTREGVAR(Synth, T) \ EXPORTPREPOSTREGVAR(Crackle, T) \ + template EMBER_API class PostSmartcropVariation; /*Only implemented as post.*/ \ EXPORTPREPOSTREGVAR(DCBubble, T) \ EXPORTPREPOSTREGVAR(DCCarpet, T) \ EXPORTPREPOSTREGVAR(DCCube, T) \ diff --git a/Source/Ember/Utils.h b/Source/Ember/Utils.h index dfc8af8..6f10e9c 100644 --- a/Source/Ember/Utils.h +++ b/Source/Ember/Utils.h @@ -704,7 +704,7 @@ static inline T Spread(T x, T y) template static inline T Powq4(T x, T y) { - return std::pow(std::fabs(x), y) * SignNz(x); + return std::pow(std::abs(x), y) * SignNz(x); } /// diff --git a/Source/Ember/VarFuncs.h b/Source/Ember/VarFuncs.h index a13a3e8..c621e6b 100644 --- a/Source/Ember/VarFuncs.h +++ b/Source/Ember/VarFuncs.h @@ -92,11 +92,11 @@ public: T t; // Temp double // Convert input co-ordinates ( x, y, z ) to // integer-based simplex grid ( i, j, k ) - T skewIn = (v.x + v.y + v.z) * T(0.3333); + T skewIn = (v.x + v.y + v.z) * T(0.333333); intmax_t i = Floor(v.x + skewIn); intmax_t j = Floor(v.y + skewIn); intmax_t k = Floor(v.z + skewIn); - t = (i + j + k) * T(0.16666); + t = (i + j + k) * T(0.1666666); // Cell origin co-ordinates in input space (x,y,z) T x0 = i - t; T y0 = j - t; @@ -154,17 +154,17 @@ public: // A step of 1i in (i,j,k) is a step of (1-T(0.16666), -T(0.16666), -T(0.16666)) in (x,y,z), // and this is similar for j and k . . . // Offsets for second corner in (x,y,z) coords - c[1].x = c[0].x - i1 + T(0.16666); - c[1].y = c[0].y - j1 + T(0.16666); - c[1].z = c[0].z - k1 + T(0.16666); + c[1].x = c[0].x - i1 + T(0.1666666); + c[1].y = c[0].y - j1 + T(0.1666666); + c[1].z = c[0].z - k1 + T(0.1666666); // Offsets for third corner in (x,y,z) coords - c[2].x = c[0].x - i2 + 2 * T(0.16666); - c[2].y = c[0].y - j2 + 2 * T(0.16666); - c[2].z = c[0].z - k2 + 2 * T(0.16666); + c[2].x = c[0].x - i2 + 2 * T(0.1666666); + c[2].y = c[0].y - j2 + 2 * T(0.1666666); + c[2].z = c[0].z - k2 + 2 * T(0.1666666); // Offsets for last corner in (x,y,z) coords - c[3].x = c[0].x - 1 + 3 * T(0.16666); - c[3].y = c[0].y - 1 + 3 * T(0.16666); - c[3].z = c[0].z - 1 + 3 * T(0.16666); + c[3].x = c[0].x - 1 + 3 * T(0.1666666); + c[3].y = c[0].y - 1 + 3 * T(0.1666666); + c[3].z = c[0].z - 1 + 3 * T(0.1666666); // Work out the hashed gradient indices of the four simplex corners int ii = i & 0x3ff; int jj = j & 0x3ff; @@ -175,9 +175,9 @@ public: gi[3] = m_P[ii + 1 + m_P[jj + 1 + m_P[kk + 1]]]; // Calculate the contribution from the four corners, and add to total - for (int corner = 0; corner < 4; corner++) + for (uint corner = 0u; corner < 4u; corner++) { - t = T(0.6) - c[corner].x * c[corner].x - c[corner].y * c[corner].y - c[corner].z * c[corner].z; + t = T(0.6) - Sqr(c[corner].x) - Sqr(c[corner].y) - Sqr(c[corner].z); if (t > 0) { @@ -202,13 +202,12 @@ public: /// T T PerlinNoise3D(v3T& v, T aScale, T fScale, int octaves) { - int i; T n = 0, a = 1; v3T u = v; - for (i = 0; i < octaves; i++) + for (int i = 0; i < octaves; i++) { - n += SimplexNoise3D(u) / a; + n += SimplexNoise3D(u) / Zeps(a); a *= aScale; u.x *= fScale; u.y *= fScale; @@ -253,22 +252,20 @@ public: { v2T pmq = p - q; - if (pmq.x == 0 || pmq.y == 0) + if (pmq.x == 0 && pmq.y == 0) return 1; - return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / (pmq.x * pmq.x + pmq.y * pmq.y); + return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / (SQR(pmq.x) + SQR(pmq.y)); } /// /// Unsure. /// - static T Voronoi(v2T* p, int n, int q, v2T& u) + static T Voronoi(v2T* p, int n, int q, const v2T& u) { - T ratio; - T ratiomax = TLOW; - int i; + T ratio, ratiomax = TLOW; - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { if (i != q) { @@ -293,7 +290,7 @@ private: m_P = InitInts(); m_Grad = InitGrad(); m_GlobalMap["NOISE_INDEX"] = make_pair(m_PFloats.data(), m_PFloats.size()); - m_GlobalMap["NOISE_POINTS"] = make_pair(static_cast(&(m_Grad[0].x)), SizeOf(m_Grad) / sizeof(T)); + m_GlobalMap["NOISE_POINTS"] = make_pair(static_cast(&(m_Grad[0].x)), SizeOf(m_Grad) / sizeof(T)); } /// diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h index 37218fe..f08c358 100644 --- a/Source/Ember/Variation.h +++ b/Source/Ember/Variation.h @@ -914,7 +914,7 @@ enum class eVariationId : et VAR_POST_SINUS_GRID, VAR_POST_SINUSOIDAL, VAR_POST_SINUSOIDAL3D, - //VAR_POST_SMARTCROP, + VAR_POST_SMARTCROP, VAR_POST_SPHERICAL, VAR_POST_SPHERICAL3D, VAR_POST_SPHERICALN, diff --git a/Source/Ember/VariationList.h b/Source/Ember/VariationList.h index 3b26a6a..8d17269 100644 --- a/Source/Ember/VariationList.h +++ b/Source/Ember/VariationList.h @@ -342,6 +342,7 @@ public: ADDPREPOSTREGVAR(BubbleT3D) ADDPREPOSTREGVAR(Synth) ADDPREPOSTREGVAR(Crackle) + m_Variations.push_back(new PostSmartcropVariation());//Post only //ADDPREPOSTREGVAR(LinearXZ) //ADDPREPOSTREGVAR(LinearYZ) //DC are special. diff --git a/Source/Ember/Variations01.h b/Source/Ember/Variations01.h index df97f28..7621c95 100644 --- a/Source/Ember/Variations01.h +++ b/Source/Ember/Variations01.h @@ -1659,7 +1659,7 @@ public: virtual void Precalc() override { m_Power = Zeps(m_Power); - m_Rn = fabs(m_Power); + m_Rn = std::abs(m_Power); m_Cn = m_Dist / m_Power / 2; } @@ -1770,7 +1770,7 @@ public: virtual void Precalc() override { - m_Rn = fabs(m_Power); + m_Rn = std::abs(m_Power); m_Cn = m_Dist / m_Power / 2; } @@ -2566,7 +2566,7 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T r = m_Weight / Zeps(fabs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y))); + T r = m_Weight / Zeps(std::abs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y))); helper.Out.x = helper.In.x * r; helper.Out.y = helper.In.y * r; helper.Out.z = m_Weight * helper.In.z; @@ -2706,9 +2706,9 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T theta = m_Pm4 * helper.m_PrecalcAtanyx + T(M_PI_4); - T t1 = fabs(std::cos(theta)); + T t1 = std::abs(std::cos(theta)); t1 = std::pow(t1, m_N2); - T t2 = fabs(std::sin(theta)); + T t2 = std::abs(std::sin(theta)); t2 = std::pow(t2, m_N3); T r = m_Weight * ((m_Rnd * rand.Frand01() + (1 - m_Rnd) * helper.m_PrecalcSqrtSumSquares) - m_Holes) * std::pow(t1 + t2, m_PNeg1N1) / helper.m_PrecalcSqrtSumSquares; @@ -3235,7 +3235,7 @@ public: } else { - if (fabs(offsetX) >= fabs(offsetY)) + if (std::abs(offsetX) >= std::abs(offsetY)) { if (offsetX >= 0.0) { @@ -3332,7 +3332,7 @@ public: { T wx = m_Weight * T(1.3029400317411197908970256609023);//This precision came from the original. T y2 = helper.In.y * 2; - T r = wx * std::sqrt(fabs(helper.In.y * helper.In.x) / Zeps(SQR(helper.In.x) + SQR(y2))); + T r = wx * std::sqrt(std::abs(helper.In.y * helper.In.x) / Zeps(SQR(helper.In.x) + SQR(y2))); helper.Out.x = r * helper.In.x; helper.Out.y = r * y2; helper.Out.z = m_Weight * helper.In.z; @@ -4263,9 +4263,9 @@ public: if (m_Damping == 0.0) t = m_Amplitude * std::cos(m_2PiFreq * helper.In.x) + m_Separation; else - t = m_Amplitude * std::exp(-fabs(helper.In.x) * m_Damping) * std::cos(m_2PiFreq * helper.In.x) + m_Separation; + t = m_Amplitude * std::exp(-std::abs(helper.In.x) * m_Damping) * std::cos(m_2PiFreq * helper.In.x) + m_Separation; - if (fabs(helper.In.y) <= t) + if (std::abs(helper.In.y) <= t) { helper.Out.x = m_Weight * helper.In.x; helper.Out.y = -(m_Weight * helper.In.y); @@ -4984,7 +4984,7 @@ public: virtual void Precalc() override { m_Cf = 1 - m_Angle * m_Count * T(M_1_PI) * T(0.5); - m_Rn = fabs(m_Power); + m_Rn = std::abs(m_Power); m_Cn = m_Dist / m_Power / 2; } @@ -5835,8 +5835,8 @@ public: { T s = std::sin(m_Freq * helper.In.x); T t = std::sin(m_Freq * helper.In.y); - T dy = helper.In.y + m_AugerWeight * (m_Scale * s / 2 + fabs(helper.In.y) * s); - T dx = helper.In.x + m_AugerWeight * (m_Scale * t / 2 + fabs(helper.In.x) * t); + T dy = helper.In.y + m_AugerWeight * (m_Scale * s / 2 + std::abs(helper.In.y) * s); + T dx = helper.In.x + m_AugerWeight * (m_Scale * t / 2 + std::abs(helper.In.x) * t); helper.Out.x = m_Weight * (helper.In.x + m_Symmetry * (dx - helper.In.x)); helper.Out.y = m_Weight * dy; helper.Out.z = m_Weight * helper.In.z; diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index af3f6ff..e193e26 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -18,7 +18,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T t = m_Weight / std::sqrt(helper.m_PrecalcSumSquares + 1); - helper.Out.x = helper.In.x * t; helper.Out.y = helper.In.y * t; helper.Out.z = t; @@ -28,7 +27,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t t = xform->m_VariationWeights[" << varIndex << "] / sqrt(precalcSumSquares + (real_t)(1.0));\n" << "\n" @@ -36,7 +34,6 @@ public: << "\t\tvOut.y = vIn.y * t;\n" << "\t\tvOut.z = t;\n" << "\t}\n"; - return ss.str(); } }; @@ -60,7 +57,7 @@ public: T theta = helper.m_PrecalcAtanyx; T t = (rand.Frand01() * m_Thickness) * (1 / std::cos(m_N * theta)) - m_Holes; - if (fabs(t) != 0) + if (std::abs(t) != 0) { helper.Out.x = m_Weight * t * std::cos(theta); helper.Out.y = m_Weight * t * std::sin(theta); @@ -83,7 +80,6 @@ public: string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string thickness = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string holes = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t theta = precalcAtanyx;\n" << "\t\treal_t t = (MwcNext01(mwc) * " << thickness << ") * (1 / cos(" << n << " * theta)) - " << holes << ";\n" @@ -101,7 +97,6 @@ public: << "\t\t\tvOut.z = 0;\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } @@ -109,7 +104,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_N, prefix + "epispiral_n", 6)); m_Params.push_back(ParamWithName(&m_Thickness, prefix + "epispiral_thickness")); @@ -162,20 +156,15 @@ public: { lx *= m_G2; ly *= m_G2; - T r = m_Rfactor / ((SQR(lx) + SQR(ly)) / 4 + 1); - lx *= r; ly *= r; r = (SQR(lx) + SQR(ly)) / m_R2; - T theta = m_BwrapsInnerTwist * (1 - r) + m_BwrapsOuterTwist * r; T s = std::sin(theta); T c = std::cos(theta); - vx = cx + c * lx + s * ly; vy = cy - s * lx + c * ly; - helper.Out.x = m_Weight * vx; helper.Out.y = m_Weight * vy; } @@ -198,7 +187,6 @@ public: string g2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string r2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rfactor = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tif (" << bwrapsCellsize << " == 0)\n" << "\t\t{\n" @@ -244,7 +232,6 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -267,7 +254,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_BwrapsCellsize, prefix + "bwraps_cellsize", 1)); m_Params.push_back(ParamWithName(&m_BwrapsSpace, prefix + "bwraps_space")); @@ -338,7 +324,6 @@ public: T val = T(M_PI_4) * perimeter / side - T(M_PI_4); T sina = std::sin(val); T cosa = std::cos(val); - helper.Out.x = r * cosa; helper.Out.y = r * sina; helper.Out.z = m_Weight * helper.In.z; @@ -350,7 +335,6 @@ public: intmax_t varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - ss << "\t{\n" << "\t\treal_t x = 2 * MwcNext01(mwc) - 1;\n" << "\t\treal_t y = 2 * MwcNext01(mwc) - 1;\n" @@ -392,7 +376,6 @@ public: << "\t\tvOut.y = r * sina;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } }; @@ -414,7 +397,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T z = 1 + m_BlurZoomLength * rand.Frand01(); - helper.Out.x = m_Weight * ((helper.In.x - m_BlurZoomX) * z + m_BlurZoomX); helper.Out.y = m_Weight * ((helper.In.y - m_BlurZoomY) * z - m_BlurZoomY); helper.Out.z = m_Weight * helper.In.z; @@ -429,7 +411,6 @@ public: string blurZoomLength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blurZoomX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blurZoomY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t z = 1 + " << blurZoomLength << " * MwcNext01(mwc);\n" << "\n" @@ -437,7 +418,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ((vIn.y - " << blurZoomY << ") * z - " << blurZoomY << ");\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -445,7 +425,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_BlurZoomLength, prefix + "blur_zoom_length")); m_Params.push_back(ParamWithName(&m_BlurZoomX, prefix + "blur_zoom_x")); @@ -476,7 +455,6 @@ public: { T x = T(Floor(helper.In.x * m_InvSize)); T y = T(Floor(helper.In.y * m_InvSize)); - helper.Out.x = m_V * (x + m_BlurPixelizeScale * (rand.Frand01() - T(0.5)) + T(0.5)); helper.Out.y = m_V * (y + m_BlurPixelizeScale * (rand.Frand01() - T(0.5)) + T(0.5)); helper.Out.z = m_Weight * helper.In.z; @@ -492,7 +470,6 @@ public: string blurPixelizeScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string v = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invSize = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = floor(vIn.x * " << invSize << ");\n" << "\t\treal_t y = floor(vIn.y * " << invSize << ");\n" @@ -501,7 +478,6 @@ public: << "\t\tvOut.y = " << v << " * (y + " << blurPixelizeScale << " * (MwcNext01(mwc) - (real_t)(0.5)) + (real_t)(0.5));\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -515,7 +491,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_BlurPixelizeSize, prefix + "blur_pixelize_size", T(0.1), eParamType::REAL, EPS)); m_Params.push_back(ParamWithName(&m_BlurPixelizeScale, prefix + "blur_pixelize_scale", 1)); @@ -590,11 +565,10 @@ public: string y1_ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string w = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string h = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = vIn.x;\n" << "\t\treal_t y = vIn.y;\n" - << "\n" + << "\n" << "\t\tif (((x < " << x0_ << ") || (x > " << x1_ << ") || (y < " << y0_ << ") || (y > " << y1_ << ")) && " << z << " != 0)\n" << "\t\t{\n" << "\t\t x = 0;\n" @@ -617,7 +591,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -653,7 +626,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X0, prefix + "crop_left", -1)); m_Params.push_back(ParamWithName(&m_Y0, prefix + "crop_top", -1)); @@ -737,7 +709,6 @@ public: string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string borderWidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string bcbw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tif ((vIn.x == 0) && (vIn.y == 0))\n" << "\t\t return;\n" @@ -767,20 +738,18 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { - m_Bcbw = fabs(m_BorderWidth); + m_Bcbw = std::abs(m_BorderWidth); } protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Scale, prefix + "bcircle_scale", 1)); m_Params.push_back(ParamWithName(&m_BorderWidth, prefix + "bcircle_borderwidth")); @@ -810,7 +779,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T r = m_BlurLinearLength * rand.Frand01(); - helper.Out.x = m_Weight * (helper.In.x + r * m_C); helper.Out.y = m_Weight * (helper.In.y + r * m_S); helper.Out.z = m_Weight * helper.In.z; @@ -826,7 +794,6 @@ public: string blurLinearAngle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = " << blurLinearLength << " * MwcNext01(mwc);\n" << "\n" @@ -834,7 +801,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + r * " << s << ");\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -847,7 +813,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_BlurLinearLength, prefix + "blur_linear_length")); m_Params.push_back(ParamWithName(&m_BlurLinearAngle, prefix + "blur_linear_angle", 0, eParamType::REAL_CYCLIC, 0, T(M_2PI))); @@ -890,13 +855,11 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string v = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. - ss << "\t{\n" << "\t\tvOut.x = " << v << " * (MwcNext01(mwc) - (real_t)(0.5));\n" << "\t\tvOut.y = " << v << " * (MwcNext01(mwc) - (real_t)(0.5));\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -909,7 +872,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_V, prefix + "blur_square_v"));//Precalcs only, no params. } @@ -993,12 +955,10 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\tvOut.x = vOut.y = 0;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - (real_t)(2.0));\n" << "\t}\n"; - return ss.str(); } }; @@ -1025,12 +985,10 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\tvOut.x = vOut.y = 0;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } }; @@ -1057,12 +1015,10 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\tvOut.x = vOut.y = 0;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "];\n" << "\t}\n"; - return ss.str(); } }; @@ -1098,7 +1054,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n"; if (m_VarType == eVariationType::VARTYPE_REG) @@ -1113,7 +1068,6 @@ public: ss << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n" << "\t}\n"; - return ss.str(); } }; @@ -1138,7 +1092,6 @@ public: T cosa = std::cos(angle); T sinb = std::sin(angle2); T cosb = std::cos(angle2); - helper.Out.x = r * sinb * cosa; helper.Out.y = r * sinb * sina; helper.Out.z = r * cosb; @@ -1148,7 +1101,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t angle = MwcNext01(mwc) * M_2PI;\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - (real_t)(2.0));\n" @@ -1162,7 +1114,6 @@ public: << "\t\tvOut.y = r * sinb * sina;\n" << "\t\tvOut.z = r * cosb;\n" << "\t}\n"; - return ss.str(); } }; @@ -1181,7 +1132,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T r2 = m_Weight / Zeps(helper.m_PrecalcSumSquares + SQR(helper.In.z)); - helper.Out.x = r2 * helper.In.x; helper.Out.y = r2 * helper.In.y; helper.Out.z = r2 * helper.In.z; @@ -1191,7 +1141,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t r2 = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares + SQR(vIn.z));\n" << "\n" @@ -1199,7 +1148,6 @@ public: << "\t\tvOut.y = r2 * vIn.y;\n" << "\t\tvOut.z = r2 * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -1227,7 +1175,6 @@ public: { T r2 = helper.m_PrecalcSumSquares + SQR(helper.In.z); T r = m_Weight / Zeps(r2 * m_C2 + m_C2x * helper.In.x - m_C2y * helper.In.y + m_C2z * helper.In.z + 1); - helper.Out.x = r * (helper.In.x + m_Cx * r2); helper.Out.y = r * (helper.In.y - m_Cy * r2); helper.Out.z = r * (helper.In.z + m_Cz * r2); @@ -1246,7 +1193,6 @@ public: string c2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(r2 * " << c2 << " + " << c2x << " * vIn.x - " << c2y << " * vIn.y + " << c2z << " * vIn.z + (real_t)(1.0));\n" @@ -1255,7 +1201,6 @@ public: << "\t\tvOut.y = r * (vIn.y - " << cy << " * r2);\n" << "\t\tvOut.z = r * (vIn.z + " << cz << " * r2);\n" << "\t}\n"; - return ss.str(); } @@ -1276,7 +1221,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Cx, prefix + "curl3D_cx")); m_Params.push_back(ParamWithName(&m_Cy, prefix + "curl3D_cy")); @@ -1318,7 +1262,6 @@ public: T sr = std::sin(temp); T cr = std::cos(temp); T vv = m_Weight * helper.m_PrecalcAtanxy / Zeps(m_Pi); - helper.Out.x = vv * sr; helper.Out.y = vv * cr; helper.Out.z = vv * (r * std::cos(helper.In.z)); @@ -1331,7 +1274,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = precalcSqrtSumSquares;\n" << "\t\treal_t temp = r * " << pi << ";\n" @@ -1343,7 +1285,6 @@ public: << "\t\tvOut.y = vv * cr;\n" << "\t\tvOut.z = vv * (r * cos(vIn.z));\n" << "\t}\n"; - return ss.str(); } @@ -1356,7 +1297,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Pi, prefix + "disc3d_pi", T(M_PI))); } @@ -1393,7 +1333,7 @@ public: } else { - if (fabs(offsetX) >= fabs(offsetY)) + if (std::abs(offsetX) >= std::abs(offsetY)) { if (offsetX >= 0) { @@ -1408,7 +1348,7 @@ public: } else { - if(offsetY >= 0) + if (offsetY >= 0) { helper.Out.y = m_Weight * (offsetY * m_AbsC + roundY + m_Cl); helper.Out.x = m_Weight * (offsetX * m_AbsC + roundX + offsetX / offsetY * m_Cl); @@ -1436,7 +1376,6 @@ public: string absc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cl = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t roundX = (real_t)(int)(vIn.x >= 0 ? (int)(vIn.x + (real_t)(0.5)) : (int)(vIn.x - (real_t)(0.5)));\n" << "\t\treal_t roundY = (real_t)(int)(vIn.y >= 0 ? (int)(vIn.y + (real_t)(0.5)) : (int)(vIn.y - (real_t)(0.5)));\n" @@ -1480,16 +1419,14 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { - T c = Zeps(fabs(m_C)); - T cl = Zeps(fabs(m_Left)); - T cr = Zeps(fabs(m_Right)); - + T c = Zeps(std::abs(m_C)); + T cl = Zeps(std::abs(m_Left)); + T cr = Zeps(std::abs(m_Right)); m_AbsC = c; m_Cl = c * cl; m_Cr = c + (c * cr); @@ -1499,7 +1436,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_C, prefix + "boarders2_c", T(0.5))); m_Params.push_back(ParamWithName(&m_Left, prefix + "boarders2_left", T(0.5))); @@ -1535,7 +1471,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T r = m_Weight * std::sqrt(helper.m_PrecalcSumSquares + std::sin(helper.m_PrecalcAtanyx * m_A) + 1); - helper.Out.x = r * helper.m_PrecalcCosa; helper.Out.y = r * helper.m_PrecalcSina; helper.Out.z = m_Weight * helper.In.z; @@ -1548,7 +1483,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * sqrt(precalcSumSquares + sin(precalcAtanyx * " << a << ") + 1);\n" << "\n" @@ -1556,7 +1490,6 @@ public: << "\t\tvOut.y = r * precalcSina;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -1564,7 +1497,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_A, prefix + "cardioid_a", 1)); } @@ -1592,7 +1524,6 @@ public: T dx, dy; T rnx = m_Rnd * rand.Frand01(); T rny = m_Rnd * rand.Frand01(); - int isXY = int(LRint(helper.In.x * m_Cs) + LRint(helper.In.y * m_Cs)); if (isXY & 1) @@ -1626,7 +1557,6 @@ public: string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ncx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ncy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t dx, dy;\n" << "\t\treal_t rnx = " << rnd << " * MwcNext01(mwc);\n" @@ -1649,7 +1579,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + dy);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -1671,7 +1600,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "checks_x", T(0.5))); m_Params.push_back(ParamWithName(&m_Y, prefix + "checks_y", T(0.5))); @@ -1715,8 +1643,8 @@ public: T side; T perimeter; T r, val; - T absx = fabs(helper.In.x); - T absy = fabs(helper.In.y); + T absx = std::abs(helper.In.x); + T absy = std::abs(helper.In.y); if (absx >= absy) { @@ -1752,7 +1680,6 @@ public: string index = ss2.str(); string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vvar4pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t side;\n" << "\t\treal_t perimeter;\n" @@ -1785,7 +1712,6 @@ public: << "\t\tvOut.y = r * sin(val);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -1798,7 +1724,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Hole, prefix + "circlize_hole")); m_Params.push_back(ParamWithName(true, &m_Vvar4Pi, prefix + "circlize_vvar4pi"));//Precalc. @@ -1827,8 +1752,8 @@ public: { T side; T perimeter; - T absx = fabs(helper.In.x); - T absy = fabs(helper.In.y); + T absx = std::abs(helper.In.x); + T absy = std::abs(helper.In.y); if (absx >= absy) { @@ -1851,7 +1776,6 @@ public: T r = m_Weight * (side + m_Hole); T val = T(M_PI_4) * perimeter / side - T(M_PI_4); - helper.Out.x = r * std::cos(val); helper.Out.y = r * std::sin(val); helper.Out.z = m_Weight * helper.In.z; @@ -1864,7 +1788,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t side;\n" << "\t\treal_t perimeter;\n" @@ -1897,7 +1820,6 @@ public: << "\t\tvOut.y = r * sin(val);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -1905,7 +1827,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Hole, prefix + "circlize2_hole")); } @@ -1936,7 +1857,6 @@ public: T by = Fabsmod(m_Fr * y); T oscnapx = Foscn(m_AmountX, m_Px); T oscnapy = Foscn(m_AmountY, m_Py); - helper.Out.x = -1 + m_Vv2 * Lerp(Lerp(x, Fosc(x, T(4), m_Px), oscnapx), Fosc(bx, T(4), m_Px), oscnapx);//Original did a direct assignment to outPoint, which is incompatible with Ember's design. helper.Out.y = -1 + m_Vv2 * Lerp(Lerp(y, Fosc(y, T(4), m_Py), oscnapy), Fosc(by, T(4), m_Py), oscnapy); helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; @@ -1959,7 +1879,6 @@ public: string py = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string fr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vv2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = (real_t)(0.5) * vIn.x + (real_t)(0.5);\n" << "\t\treal_t y = (real_t)(0.5) * vIn.y + (real_t)(0.5);\n" @@ -1972,7 +1891,6 @@ public: << "\t\tvOut.y = -1 + " << vv2 << " * Lerp(Lerp(y, Fosc(y, 4, " << py << "), oscnapy), Fosc(by, 4, " << py << "), oscnapy);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1983,11 +1901,11 @@ public: virtual void Precalc() override { - m_Ax = M_2PI * fabs(m_AmountX); - m_Ay = M_2PI * fabs(m_AmountY); + m_Ax = M_2PI * std::abs(m_AmountX); + m_Ay = M_2PI * std::abs(m_AmountY); m_Px = T(M_PI) * m_PhaseX; m_Py = T(M_PI) * m_PhaseY; - m_Fr = fabs(m_Repeat); + m_Fr = std::abs(m_Repeat); m_Vv2 = 2 * m_Weight; } @@ -1995,7 +1913,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Repeat, prefix + "coswrap_repeat", 1, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName(&m_AmountX, prefix + "coswrap_amount_x")); @@ -2043,7 +1960,6 @@ public: T s, c; T avgr = m_Weight * (std::sqrt(SQR(helper.In.y) + SQR(helper.In.x + 1)) / std::sqrt(SQR(helper.In.y) + SQR(helper.In.x - 1))); T avga = (atan2(helper.In.y, helper.In.x - 1) - atan2(helper.In.y, helper.In.x + 1)) / 2; - sincos(avga, &s, &c); helper.Out.x = avgr * c; helper.Out.y = avgr * s; @@ -2054,7 +1970,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t avgr = xform->m_VariationWeights[" << varIndex << "] * (sqrt(SQR(vIn.y) + SQR(vIn.x + 1)) / sqrt(SQR(vIn.y) + SQR(vIn.x - 1)));\n" << "\t\treal_t avga = (atan2(vIn.y, vIn.x - 1) - atan2(vIn.y, vIn.x + 1)) / 2;\n" @@ -2065,7 +1980,6 @@ public: << "\t\tvOut.y = avgr * s;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } }; @@ -2090,7 +2004,6 @@ public: T temp = helper.In.x * m_T + helper.In.y * m_K; T snv = std::sin(temp); T csv = std::cos(temp); - helper.Out.x = m_Weight * expor * csv; helper.Out.y = m_Weight * expor * snv; helper.Out.z = m_Weight * helper.In.z; @@ -2106,7 +2019,6 @@ public: string imag = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string t = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t expor = exp(vIn.x * " << k << " - vIn.y * " << t << ");\n" << "\t\treal_t temp = vIn.x * " << t << " + vIn.y * " << k << ";\n" @@ -2117,7 +2029,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * expor * snv;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -2131,7 +2042,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Real, prefix + "expo_real", -1)); m_Params.push_back(ParamWithName(&m_Imag, prefix + "expo_imaginary", 1)); @@ -2222,7 +2132,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_RootFace, prefix + "extrude_root_face", T(0.5))); } @@ -2247,7 +2156,6 @@ public: T c, s; T a = M_2PI / (helper.m_PrecalcSqrtSumSquares + 1); T r = (helper.m_PrecalcAtanyx * T(M_1_PI) + 1) * T(0.5); - sincos(a, &s, &c); helper.Out.x = m_Weight * r * c; helper.Out.y = m_Weight * r * s; @@ -2258,7 +2166,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t a = M_2PI / (precalcSqrtSumSquares + 1);\n" << "\t\treal_t r = (precalcAtanyx * M_1_PI + 1) * (real_t)(0.5);\n" @@ -2269,7 +2176,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * s;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } }; @@ -2292,14 +2198,11 @@ public: { T snum1, cnum1, snum2, cnum2; T temp = helper.In.y * m_NatLog; - sincos(temp, &snum1, &cnum1); temp = (helper.In.x * T(M_PI) + helper.In.y * m_NatLog) * -1; sincos(temp, &snum2, &cnum2); - T eradius1 = std::exp(helper.In.x * m_NatLog); T eradius2 = std::exp((helper.In.x * m_NatLog - helper.In.y * T(M_PI)) * -1); - helper.Out.x = m_Weight * (eradius1 * cnum1 - eradius2 * cnum2) * m_Five; helper.Out.y = m_Weight * (eradius1 * snum1 - eradius2 * snum2) * m_Five; helper.Out.z = m_Weight * helper.In.z; @@ -2313,7 +2216,6 @@ public: string index = ss2.str(); string five = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string natLog = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t temp = vIn.y * " << natLog << ";\n" << "\t\treal_t snum1 = sin(temp);\n" @@ -2328,7 +2230,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -2342,7 +2243,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_Five, prefix + "fibonacci_five"));//Precalcs only, no params. m_Params.push_back(ParamWithName(true, &m_NatLog, prefix + "fibonacci_nat_log")); @@ -2371,14 +2271,11 @@ public: { T snum1, cnum1, snum2, cnum2; T temp = helper.In.y * m_NatLog; - sincos(temp, &snum1, &cnum1); temp = (helper.In.x * T(M_PI) + helper.In.y * m_NatLog) * -1; sincos(temp, &snum2, &cnum2); - T eradius1 = m_Sc * std::exp(m_Sc2 * (helper.In.x * m_NatLog)); T eradius2 = m_Sc * std::exp(m_Sc2 * ((helper.In.x * m_NatLog - helper.In.y * T(M_PI)) * -1)); - helper.Out.x = m_Weight * (eradius1 * cnum1 - eradius2 * cnum2) * m_Five; helper.Out.y = m_Weight * (eradius1 * snum1 - eradius2 * snum2) * m_Five; helper.Out.z = m_Weight * helper.In.z; @@ -2394,7 +2291,6 @@ public: string sc2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string five = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string natLog = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t temp = vIn.y * " << natLog << ";\n" << "\t\treal_t snum1 = sin(temp);\n" @@ -2409,7 +2305,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -2423,7 +2318,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Sc, prefix + "fibonacci2_sc", 1)); m_Params.push_back(ParamWithName(&m_Sc2, prefix + "fibonacci2_sc2", 1)); @@ -2499,7 +2393,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string v2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. - ss << "\t{\n" << "\t\treal_t d, r = precalcSqrtSumSquares;\n" << "\n" @@ -2538,7 +2431,6 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -2551,7 +2443,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_V2, prefix + "glynnia_v2"));//Precalcs only, no params. } @@ -2642,7 +2533,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t x = LRint(vIn.x);\n" << "\t\treal_t y = LRint(vIn.y);\n" @@ -2708,7 +2598,6 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -2754,7 +2643,6 @@ public: string index = ss2.str(); string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string inside = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r, delta = pow(precalcAtanyx / (real_t)M_PI + 1, " << a << ");\n" << "\n" @@ -2767,7 +2655,6 @@ public: << "\t\tvOut.y = r * precalcSina;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -2775,7 +2662,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_A, prefix + "hole_a", 1)); m_Params.push_back(ParamWithName(&m_Inside, prefix + "hole_inside", 0, eParamType::INTEGER, 0, 1)); @@ -2807,7 +2693,6 @@ public: T c = m_Real * helper.In.x - m_Imag * helper.In.y + 1; T d = m_Real * helper.In.y + m_Imag * helper.In.x; T vr = m_Weight / (SQR(c) + SQR(d)); - helper.Out.x = vr * (a * c + b * d); helper.Out.y = vr * (b * c - a * d); helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; @@ -2824,7 +2709,6 @@ public: string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string real = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string imag = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t a = vIn.x + " << real << ";\n" << "\t\treal_t b = vIn.y - " << imag << ";\n" @@ -2836,7 +2720,6 @@ public: << "\t\tvOut.y = vr * (b * c - a * d);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -2860,7 +2743,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_P, prefix + "hypertile_p", 3, eParamType::INTEGER, 3, T(0x7fffffff))); m_Params.push_back(ParamWithName(&m_Q, prefix + "hypertile_q", 7, eParamType::INTEGER, 3, T(0x7fffffff))); @@ -2903,7 +2785,6 @@ public: T c = re * helper.In.x - im * helper.In.y + 1; T d = re * helper.In.y + im * helper.In.x; T vr = m_Weight / (SQR(c) + SQR(d)); - helper.Out.x = vr * (a * c + b * d); helper.Out.y = vr * (b * c - a * d); helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; @@ -2919,7 +2800,6 @@ public: string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t temp = MwcNext(mwc) * " << pa << ";\n" << "\t\treal_t sina = sin(temp);\n" @@ -2936,14 +2816,13 @@ public: << "\t\tvOut.y = vr * (b * c - a * d);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { T r2 = 1 - (std::cos(2 * T(M_PI) / m_P) - 1) / - (std::cos(2 * T(M_PI) / m_P) + std::cos(2 * T(M_PI) / m_Q)); + (std::cos(2 * T(M_PI) / m_P) + std::cos(2 * T(M_PI) / m_Q)); if (r2 > 0) m_R = 1 / std::sqrt(r2); @@ -2957,7 +2836,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_P, prefix + "hypertile1_p", 3, eParamType::INTEGER, 3, T(0x7fffffff))); m_Params.push_back(ParamWithName(&m_Q, prefix + "hypertile1_q", 7, eParamType::INTEGER, 3, T(0x7fffffff))); @@ -2998,7 +2876,6 @@ public: T temp = rand.Rand() * m_Pa; T sina = std::sin(temp); T cosa = std::cos(temp); - helper.Out.x = vr * (x * cosa + y * sina); helper.Out.y = vr * (y * cosa - x * sina); helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; @@ -3014,7 +2891,6 @@ public: string q = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t a = vIn.x + " << r << ";\n" << "\t\treal_t b = vIn.y;\n" @@ -3031,14 +2907,13 @@ public: << "\t\tvOut.y = vr * (y * cosa - x * sina);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { T r2 = 1 - (std::cos(2 * T(M_PI) / m_P) - 1) / - (std::cos(2 * T(M_PI) / m_P) + std::cos(2 * T(M_PI) / m_Q)); + (std::cos(2 * T(M_PI) / m_P) + std::cos(2 * T(M_PI) / m_Q)); if (r2 > 0) m_R = 1 / std::sqrt(r2); @@ -3052,7 +2927,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_P, prefix + "hypertile2_p", 3, eParamType::INTEGER, 3, T(0x7fffffff))); m_Params.push_back(ParamWithName(&m_Q, prefix + "hypertile2_q", 7, eParamType::INTEGER, 3, T(0x7fffffff))); @@ -3087,7 +2961,6 @@ public: T x2cx = m_C2x * helper.In.x; T y2cy = m_C2y * helper.In.y; T d = m_Weight / (m_C2 * r2 + x2cx - y2cy + 1); - helper.Out.x = d * (helper.In.x * m_S2x - m_Cx * ( y2cy - r2 - 1)); helper.Out.y = d * (helper.In.y * m_S2y + m_Cy * (-x2cx - r2 - 1)); helper.Out.z = d * (helper.In.z * m_S2z); @@ -3112,7 +2985,6 @@ public: string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r2 = precalcSumSquares + vIn.z;\n" << "\t\treal_t x2cx = " << c2x << " * vIn.x;\n" @@ -3123,7 +2995,6 @@ public: << "\t\tvOut.y = d * (vIn.y * " << s2y << " + " << cy << "* (-x2cx - r2 - 1));\n" << "\t\tvOut.z = d * (vIn.z * " << s2z << ");\n" << "\t}\n"; - return ss.str(); } @@ -3153,7 +3024,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_P, prefix + "hypertile3D_p", 3, eParamType::INTEGER, 3, T(0x7fffffff))); m_Params.push_back(ParamWithName(&m_Q, prefix + "hypertile3D_q", 7, eParamType::INTEGER, 3, T(0x7fffffff))); @@ -3211,7 +3081,6 @@ public: T x2cx = 2 * cx * helper.In.x; T y2cy = 2 * cy * helper.In.x; T d = m_Weight / (m_C2 * r2 + x2cx - y2cy + 1); - helper.Out.x = d * (helper.In.x * s2x - cx * ( y2cy - r2 - 1)); helper.Out.y = d * (helper.In.y * s2y + cy * (-x2cx - r2 - 1)); helper.Out.z = d * (helper.In.z * m_S2z); @@ -3229,7 +3098,6 @@ public: string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t temp = MwcNext(mwc) * " << pa << ";\n" << "\t\treal_t cx = " << r << " * cos(temp);\n" @@ -3245,7 +3113,6 @@ public: << "\t\tvOut.y = d * (vIn.y * s2y + cy * (-x2cx - r2 - 1));\n" << "\t\tvOut.z = d * (vIn.z * " << s2z << ");\n" << "\t}\n"; - return ss.str(); } @@ -3270,7 +3137,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_P, prefix + "hypertile3D1_p", 3, eParamType::INTEGER, 3, T(0x7fffffff))); m_Params.push_back(ParamWithName(&m_Q, prefix + "hypertile3D1_q", 7, eParamType::INTEGER, 3, T(0x7fffffff))); @@ -3313,7 +3179,6 @@ public: T temp = rand.Rand() * m_Pa; T sina = std::sin(temp); T cosa = std::cos(temp); - helper.Out.x = vr * (x * cosa + y * sina); helper.Out.y = vr * (y * cosa - x * sina); helper.Out.z = vr * (helper.In.z * m_S2z); @@ -3334,7 +3199,6 @@ public: string s2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n" << "\t\treal_t x2cx = " << c2x << " * vIn.x;\n" @@ -3349,7 +3213,6 @@ public: << "\t\tvOut.y = vr * (y * cosa - x * sina);\n" << "\t\tvOut.z = vr * (vIn.z * " << s2z << ");\n" << "\t}\n"; - return ss.str(); } @@ -3377,7 +3240,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_P, prefix + "hypertile3D2_p", 3, eParamType::INTEGER, 3, T(0x7fffffff))); m_Params.push_back(ParamWithName(&m_Q, prefix + "hypertile3D2_q", 7, eParamType::INTEGER, 3, T(0x7fffffff))); @@ -3422,7 +3284,6 @@ public: T s = std::sin(a); T c = std::cos(a); T r = helper.m_PrecalcAtanyx * m_V; - helper.Out.x = r * c; helper.Out.y = r * s; helper.Out.z = m_Weight * helper.In.z; @@ -3435,7 +3296,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string v = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. - ss << "\t{\n" << "\t\treal_t a = M_PI / (precalcSqrtSumSquares + 1);\n" << "\t\treal_t s = sin(a);\n" @@ -3446,7 +3306,6 @@ public: << "\t\tvOut.y = r * s;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3459,7 +3318,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_V, prefix + "idisc_v"));//Precalcs only, no params. } @@ -3490,7 +3348,6 @@ public: T sina = std::sin(angle); T cosa = std::cos(angle); T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn); - helper.Out.x = r * cosa; helper.Out.y = r * sina; helper.Out.z = m_Weight * helper.In.z; @@ -3512,7 +3369,6 @@ public: string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = " << a << " * vIn.x + " << b << " * vIn.y + " << e << ";\n" << "\t\treal_t y = " << c << " * vIn.x + " << d << " * vIn.y + " << f << ";\n" @@ -3525,7 +3381,6 @@ public: << "\t\tvOut.y = r * sina;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3542,7 +3397,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_A, prefix + "julian2_a", 1)); m_Params.push_back(ParamWithName(&m_B, prefix + "julian2_b")); @@ -3589,7 +3443,6 @@ public: T sina = std::sin(a); T cosa = std::cos(a); T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_HalfInvPower); - helper.Out.x = r * cosa; helper.Out.y = r * sina; helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; @@ -3606,7 +3459,6 @@ public: string halfInvPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invPower2Pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t a = precalcAtanyx * " << invPower << " + MwcNext(mwc) * " << invPower2Pi << ";\n" << "\t\treal_t sina = sin(a);\n" @@ -3617,7 +3469,6 @@ public: << "\t\tvOut.y = r * sina;\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -3632,7 +3483,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Power, prefix + "juliaq_power", 3, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName(&m_Divisor, prefix + "juliaq_divisor", 2, eParamType::INTEGER_NONZERO)); @@ -3672,7 +3522,6 @@ public: T re = r * cosa + 1; T im = r * sina; T r1 = m_Vp / (SQR(re) + SQR(im)); - helper.Out.x = r1 * (helper.In.x * re + helper.In.y * im); helper.Out.y = r1 * (helper.In.y * re - helper.In.x * im); helper.Out.z = m_Weight * helper.In.z; @@ -3689,7 +3538,6 @@ public: string cp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string p2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t angle = precalcAtanyx * " << power << ";\n" << "\t\treal_t sina = sin(angle);\n" @@ -3703,7 +3551,6 @@ public: << "\t\tvOut.y = r1 * (vIn.y * re - vIn.x * im);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3722,7 +3569,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_C, prefix + "murl_c")); m_Params.push_back(ParamWithName(&m_Power, prefix + "murl_power", 2, eParamType::INTEGER, 2, T(0x7fffffff))); @@ -3761,16 +3607,13 @@ public: T r = m_C * std::pow(helper.m_PrecalcSumSquares, m_P2); T re = r * cosa + 1; T im = r * sina; - r = std::pow(SQR(re) + SQR(im), m_InvP); angle = std::atan2(im, re) * m_InvP2; sina = std::sin(angle); cosa = std::cos(angle); re = r * cosa; im = r * sina; - T r1 = m_Vp / SQR(r); - helper.Out.x = r1 * (helper.In.x * re + helper.In.y * im); helper.Out.y = r1 * (helper.In.y * re - helper.In.x * im); helper.Out.z = m_Weight * helper.In.z; @@ -3788,7 +3631,6 @@ public: string invp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invp2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t angle = precalcAtanyx * " << power << ";\n" << "\t\treal_t sina = sin(angle);\n" @@ -3810,7 +3652,6 @@ public: << "\t\tvOut.y = r1 * (vIn.y * re - vIn.x * im);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3830,7 +3671,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_C, prefix + "murl2_c", 0, eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName(&m_Power, prefix + "murl2_power", 1, eParamType::INTEGER_NONZERO)); @@ -3871,7 +3711,6 @@ public: T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn) * ((m_IsOdd == 0) ? 1 : m_Parity); T sina = std::sin(angle) * r; T cosa = std::cos(angle) * r; - x = (m_IsOdd != 0) ? cosa : (m_Vvar2 * std::log(SQR(cosa) + SQR(sina))); y = (m_IsOdd != 0) ? sina : (m_Vvar * std::atan2(cosa, sina)); helper.Out.x = x; @@ -3893,7 +3732,6 @@ public: string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string isOdd = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = (" << isOdd << " != 0) ? vIn.x : " << vvar << " * precalcAtanxy;\n" << "\t\treal_t y = (" << isOdd << " != 0) ? vIn.y : " << vvar2 << " * log(precalcSumSquares);\n" @@ -3908,7 +3746,6 @@ public: << "\t\tvOut.y = y;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3926,7 +3763,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Parity, prefix + "npolar_parity", 0, eParamType::INTEGER)); m_Params.push_back(ParamWithName(&m_N, prefix + "npolar_n", 1, eParamType::INTEGER)); @@ -3968,10 +3804,9 @@ public: T r, a; T xo; T ro; - T c,s; + T c, s; T x, y, tc, ts; T theta; - r = helper.m_PrecalcSumSquares; if (r < 1) @@ -3983,7 +3818,6 @@ public: theta = atan2(T(1), ro); a = fmod(m_In * theta + atan2(helper.In.y, xo - helper.In.x) + theta, 2 * theta) - theta; sincos(a, &s, &c); - helper.Out.x = m_Weight * (xo - c * ro); helper.Out.y = m_Weight * s * ro; } @@ -3994,7 +3828,6 @@ public: theta = atan2(T(1), ro); a = fmod(m_In * theta + atan2(helper.In.y, xo + helper.In.x) + theta, 2 * theta) - theta; sincos(a, &s, &c); - helper.Out.x = -(m_Weight * (xo - c * ro)); helper.Out.y = m_Weight * s * ro; } @@ -4014,13 +3847,11 @@ public: theta = std::atan2(T(1), ro); a = fmod(m_Out * theta + atan2(y, xo - x) + theta, 2 * theta) - theta; sincos(a, &s, &c); - x = (xo - c * ro); y = s * ro; theta = std::atan2(y, x); sincos(theta, &ts, &tc); r = 1 / std::sqrt(SQR(x) + SQR(y)); - helper.Out.x = m_Weight * r * tc; helper.Out.y = m_Weight * r * ts; } @@ -4031,13 +3862,11 @@ public: theta = std::atan2(T(1), ro); a = fmod(m_Out * theta + std::atan2(y, xo + x) + theta, 2 * theta) - theta; sincos(a, &s, &c); - x = (xo - c * ro); y = s * ro; theta = std::atan2(y, x); sincos(theta, &ts, &tc); r = 1 / std::sqrt(SQR(x) + SQR(y)); - helper.Out.x = -(m_Weight * r * tc); helper.Out.y = m_Weight * r * ts; } @@ -4054,7 +3883,6 @@ public: string index = ss2.str(); string in = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string out = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r, a;\n" << "\t\treal_t xo;\n" @@ -4142,7 +3970,6 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -4150,7 +3977,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_In, prefix + "ortho_in", 0, eParamType::REAL_CYCLIC, T(-M_PI), T(M_PI))); m_Params.push_back(ParamWithName(&m_Out, prefix + "ortho_out", 0, eParamType::REAL_CYCLIC, T(-M_PI), T(M_PI))); @@ -4179,7 +4005,6 @@ public: { T x = m_C1x + (SQR(m_C1r) * (helper.In.x - m_C1x)) / (SQR(helper.In.x - m_C1x) + SQR(helper.In.y - m_C1y)); T y = m_C1y + (SQR(m_C1r) * (helper.In.y - m_C1y)) / (SQR(helper.In.x - m_C1x) + SQR(helper.In.y - m_C1y)); - helper.Out.x = m_C2x + (SQR(m_C2r) * (x - m_C2x)) / (SQR(x - m_C2x) + SQR(y - m_C2y)); helper.Out.y = m_C2y + (SQR(m_C2r) * (y - m_C2y)) / (SQR(x - m_C2x) + SQR(y - m_C2y)); helper.Out.z = m_Weight * helper.In.z; @@ -4201,7 +4026,6 @@ public: string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c1d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = " << c1x << " + (SQR(" << c1r << ") * (vIn.x - " << c1x << ")) / (SQR(vIn.x - " << c1x << ") + SQR(vIn.y - " << c1y << "));\n" << "\t\treal_t y = " << c1y << " + (SQR(" << c1r << ") * (vIn.y - " << c1y << ")) / (SQR(vIn.x - " << c1x << ") + SQR(vIn.y - " << c1y << "));\n" @@ -4210,7 +4034,6 @@ public: << "\t\tvOut.y = " << c2y << " + (SQR(" << c2r << ") * (y - " << c2y << ")) / (SQR(x - " << c2x << ") + SQR(y - " << c2y << "));\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -4218,7 +4041,6 @@ public: { m_C1d = std::sqrt(1 + SQR(m_C1r)); m_C2d = std::sqrt(1 + SQR(m_C2r)); - m_C1x = m_C1d * std::cos(fmod(m_C1a, T(M_PI))); m_C1y = m_C1d * std::sin(fmod(m_C1a, T(M_PI))); m_C2x = m_C2d * std::cos(fmod(m_C2a, T(M_PI))); @@ -4229,7 +4051,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_C1r, prefix + "poincare_c1r", 1)); m_Params.push_back(ParamWithName(&m_C1a, prefix + "poincare_c1a", -1, eParamType::REAL_CYCLIC, T(-M_PI), T(M_PI))); @@ -4278,7 +4099,6 @@ public: T z2cz = m_C2z * helper.In.z; T val = Zeps(m_C2 * r2 - x2cx - y2cy - z2cz + 1); T d = m_Weight / val; - helper.Out.x = d * (helper.In.x * m_S2x + m_Cx * (y2cy + z2cz - r2 - 1)); helper.Out.y = d * (helper.In.y * m_S2y + m_Cy * (x2cx + z2cz - r2 - 1)); helper.Out.z = d * (helper.In.z * m_S2z + m_Cz * (y2cy + x2cx - r2 - 1)); @@ -4303,7 +4123,6 @@ public: string s2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n" << "\t\treal_t x2cx = " << c2x << " * vIn.x;\n" @@ -4316,7 +4135,6 @@ public: << "\t\tvOut.y = d * (vIn.y * " << s2y << " + " << cy << " * (x2cx + z2cz - r2 - (real_t)(1.0)));\n" << "\t\tvOut.z = d * (vIn.z * " << s2z << " + " << cz << " * (y2cy + x2cx - r2 - (real_t)(1.0)));\n" << "\t}\n"; - return ss.str(); } @@ -4330,13 +4148,10 @@ public: m_Cx = -m_R * std::cos(m_A * T(M_PI_2)) * std::cos(m_B * T(M_PI_2)); m_Cy = m_R * std::sin(m_A * T(M_PI_2)) * std::cos(m_B * T(M_PI_2)); m_Cz = -m_R * std::sin(m_B * T(M_PI_2)); - m_C2 = SQR(m_Cx) + SQR(m_Cy) + SQR(m_Cz); - m_C2x = 2 * m_Cx; m_C2y = 2 * m_Cy; m_C2z = 2 * m_Cz; - m_S2x = SQR(m_Cx) - SQR(m_Cy) - SQR(m_Cz) + 1; m_S2y = SQR(m_Cy) - SQR(m_Cx) - SQR(m_Cz) + 1; m_S2z = SQR(m_Cz) - SQR(m_Cy) - SQR(m_Cx) + 1; @@ -4346,7 +4161,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_R, prefix + "poincare3D_r")); m_Params.push_back(ParamWithName(&m_A, prefix + "poincare3D_a")); @@ -4395,9 +4209,8 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T xp = std::pow(fabs(m_Weight) * fabs(helper.In.x), m_Powx);//Original did not fabs. - T yp = std::pow(fabs(m_Weight) * fabs(helper.In.y), m_Powy); - + T xp = std::pow(std::abs(m_Weight) * std::abs(helper.In.x), m_Powx);//Original did not fabs. + T yp = std::pow(std::abs(m_Weight) * std::abs(helper.In.y), m_Powy); helper.Out.x = xp * Sign(helper.In.x) + m_Lcx * helper.In.x + m_Scx; helper.Out.y = yp * Sign(helper.In.y) + m_Lcy * helper.In.y + m_Scy; helper.Out.z = m_Weight * helper.In.z; @@ -4415,7 +4228,6 @@ public: string lcy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t xp = pow(fabs(xform->m_VariationWeights[" << varIndex << "]) * fabs(vIn.x), " << powx << ");\n" << "\t\treal_t yp = pow(fabs(xform->m_VariationWeights[" << varIndex << "]) * fabs(vIn.y), " << powy << ");\n" @@ -4425,7 +4237,6 @@ public: << "\t\tvOut.y = yp * Sign(vIn.y) + " << lcy << " * vIn.y + " << scy << ";\n" << "\t\tvOut.z = zp;\n" << "\t}\n"; - return ss.str(); } @@ -4433,7 +4244,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Powx, prefix + "polynomial_powx", 1)); m_Params.push_back(ParamWithName(&m_Powy, prefix + "polynomial_powy", 1)); @@ -4476,10 +4286,8 @@ public: T c0 = helper.In.x * m_Vpi; T c1 = helper.In.y * m_Vpi; T sinc0, cosc0, sinc1, cosc1; - sincos(c0, &sinc0, &cosc0); sincos(c1, &sinc1, &cosc1); - helper.Out.x = cosc0 * -sinc1; helper.Out.y = sinc0 * cosc1; helper.Out.z = cosc1 * m_ZScale; @@ -4493,7 +4301,6 @@ public: string index = ss2.str(); string zscale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vpi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t c0 = vIn.x * " << vpi << ";\n" << "\t\treal_t c1 = vIn.y * " << vpi << ";\n" @@ -4507,7 +4314,6 @@ public: << "\t\tvOut.y = sinc0 * cosc1;\n" << "\t\tvOut.z = cosc1 * " << zscale << ";\n" << "\t}\n"; - return ss.str(); } @@ -4520,7 +4326,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_ZScale, prefix + "psphere_zscale")); m_Params.push_back(ParamWithName(true, &m_Vpi, prefix + "psphere_vpi"));//Precalc. @@ -4551,15 +4356,11 @@ public: T ysqr = helper.In.y * helper.In.y; T xcb = helper.In.x * helper.In.x * helper.In.x; T ycb = helper.In.y * helper.In.y * helper.In.y; - T tr = m_T3 * (xcb - 3 * helper.In.x * ysqr) + m_T2 * (xsqr - ysqr) + m_T1 * helper.In.x + m_Tc; T ti = m_T3 * (3 * xsqr * helper.In.y - ycb) + m_T2 * 2 * helper.In.x * helper.In.y + m_T1 * helper.In.y; - T br = m_B3 * (xcb - 3 * helper.In.x * ysqr) + m_B2 * (xsqr - ysqr) + m_B1 * helper.In.x + m_Bc; T bi = m_B3 * (3 * xsqr * helper.In.y - ycb) + m_B2 * 2 * helper.In.x * helper.In.y + m_B1 * helper.In.y; - T r3den = 1 / (br * br + bi * bi); - helper.Out.x = m_Weight * (tr * br + ti * bi) * r3den; helper.Out.y = m_Weight * (ti * br - tr * bi) * r3den; helper.Out.z = m_Weight * helper.In.z; @@ -4579,7 +4380,6 @@ public: string b2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string b1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string bc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t xsqr = vIn.x * vIn.x;\n" << "\t\treal_t ysqr = vIn.y * vIn.y;\n" @@ -4598,7 +4398,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (ti * br - tr * bi) * r3den;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -4606,7 +4405,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_T3, prefix + "rational3_t3", 1)); m_Params.push_back(ParamWithName(&m_T2, prefix + "rational3_t2")); @@ -4648,28 +4446,22 @@ public: //Align input x, y to given center and multiply with scale. T x = (helper.In.x * m_S) - m_CenterX; T y = (helper.In.y * m_S) + m_CenterY; - //Calculate distance from center but constrain it to EPS. T d = std::max(EPS, std::sqrt(SQR(x) * SQR(y))); - //Normalize x and y. T nx = x / d; T ny = y / d; - //Calculate cosine wave with given frequency, velocity //and phase based on the distance to center. T wave = std::cos(m_F * d - m_Vxp); - //Calculate the wave offsets T d1 = wave * m_Pxa + d; T d2 = wave * m_Pixa + d; - //We got two offsets, so we also got two new positions (u,v). T u1 = m_CenterX + nx * d1; T v1 = -m_CenterY + ny * d1; T u2 = m_CenterX + nx * d2; T v2 = -m_CenterY + ny * d2; - //Interpolate the two positions by the given phase and //invert the multiplication with scale from before. helper.Out.x = m_Weight * Lerp(u1, u2, m_P) * m_Is;//Original did a direct assignment to outPoint, which is incompatible with Ember's design. @@ -4698,7 +4490,6 @@ public: string vxp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pxa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pixa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = (vIn.x * " << s << ") - " << centerx << ";\n" << "\t\treal_t y = (vIn.y * " << s << ") + " << centery << ";\n" @@ -4722,7 +4513,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * Lerp(v1, v2, " << p << ") * " << is << ";\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -4738,7 +4528,6 @@ public: m_P = m_Phase * M_2PI - T(M_PI); m_S = Zeps(m_Scale);//Scale must not be zero. m_Is = 1 / m_S;//Need the inverse scale. - //Pre-multiply velocity + phase, phase + amplitude and (PI - phase) + amplitude. m_Vxp = m_Velocity * m_P; m_Pxa = m_P * m_A; @@ -4749,7 +4538,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Frequency, prefix + "ripple_frequency", 2)); m_Params.push_back(ParamWithName(&m_Velocity, prefix + "ripple_velocity", 1)); @@ -4806,7 +4594,6 @@ public: T c1 = m_Ay / (1 + std::exp(m_Sy * helper.In.y)); T x = (2 * (c0 - T(0.5))); T y = (2 * (c1 - T(0.5))); - helper.Out.x = m_Vv * x; helper.Out.y = m_Vv * y; helper.Out.z = m_Weight * helper.In.z; @@ -4825,7 +4612,6 @@ public: string ax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ay = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t c0 = " << ax << " / (1 + exp(" << sx << " * vIn.x));\n" << "\t\treal_t c1 = " << ay << " / (1 + exp(" << sy << " * vIn.y));\n" @@ -4836,7 +4622,6 @@ public: << "\t\tvOut.y = " << vv << " * y;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -4877,15 +4662,13 @@ public: m_Sx *= -5; m_Sy *= -5; - - m_Vv = fabs(m_Weight); + m_Vv = std::abs(m_Weight); } protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_ShiftX, prefix + "sigmoid_shiftx", 1)); m_Params.push_back(ParamWithName(&m_ShiftY, prefix + "sigmoid_shifty", 1)); @@ -4928,7 +4711,6 @@ public: T sy = -1 * std::cos(y * m_Fy); T tx = Lerp(helper.In.x, sx, m_Ax); T ty = Lerp(helper.In.y, sy, m_Ay); - helper.Out.x = m_Weight * tx; helper.Out.y = m_Weight * ty; helper.Out.z = m_Weight * helper.In.z; @@ -4948,7 +4730,6 @@ public: string fy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ay = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = vIn.x;\n" << "\t\treal_t y = vIn.y;\n" @@ -4962,7 +4743,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ty;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * tz;\n" << "\t}\n"; - return ss.str(); } @@ -4983,7 +4763,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_AmpX, prefix + "sinusgrid_ampx", T(0.5))); m_Params.push_back(ParamWithName(&m_AmpY, prefix + "sinusgrid_ampy", T(0.5))); @@ -5037,7 +4816,6 @@ public: divident = x2Plusy2; result /= divident; - helper.Out.x = m_Weight * helper.In.x + result; helper.Out.y = m_Weight * helper.In.y + result; helper.Out.z = m_Weight * helper.In.z; @@ -5050,7 +4828,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string distort = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = vIn.x * xform->m_VariationWeights[" << varIndex << "] * (real_t)(0.05);\n" << "\t\treal_t y = vIn.y * xform->m_VariationWeights[" << varIndex << "] * (real_t)(0.05);\n" @@ -5071,7 +4848,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y + result;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5079,7 +4855,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Distort, prefix + "stwin_distort", 1));//Original had a misspelling of swtin, which is incompatible with Ember's design. } @@ -5115,7 +4890,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "];\n" << "\n" @@ -5126,7 +4900,6 @@ public: << "\t\tvOut.y = r * vIn.y;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } }; @@ -5150,7 +4923,6 @@ public: T r = std::exp(helper.In.y); T s = std::sin(helper.In.x); T c = std::cos(helper.In.x); - helper.Out.x = m_Vvar2 * r * s; helper.Out.y = m_Vvar2 * r * c; helper.Out.z = m_Weight * helper.In.z; @@ -5163,7 +4935,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string vvar2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. - ss << "\t{\n" << "\t\treal_t r = exp(vIn.y);\n" << "\t\treal_t s = sin(vIn.x);\n" @@ -5173,7 +4944,6 @@ public: << "\t\tvOut.y = " << vvar2 << " * r * c;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5186,7 +4956,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_Vvar2, prefix + "unpolar_vvar_2"));//Precalcs only, no params. } @@ -5219,9 +4988,8 @@ public: T yn = r * sina; T siny = std::sin(m_FreqX * yn); T sinx = std::sin(m_FreqY * xn); - T dx = xn + T(0.5) * (m_ScaleX * siny + fabs(xn) * m_IncX * siny); - T dy = yn + T(0.5) * (m_ScaleY * sinx + fabs(yn) * m_IncY * sinx); - + T dx = xn + T(0.5) * (m_ScaleX * siny + std::abs(xn) * m_IncX * siny); + T dy = yn + T(0.5) * (m_ScaleY * sinx + std::abs(yn) * m_IncY * sinx); helper.Out.x = m_Weight * dx; helper.Out.y = m_Weight * dy; helper.Out.z = m_Weight * helper.In.z; @@ -5242,7 +5010,6 @@ public: string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t angle = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << power << ";\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSumSquares, " << cn << ");\n" @@ -5259,7 +5026,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * dy;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5268,8 +5034,7 @@ public: if (m_Power == 0) m_Power = 2; - m_AbsN = T(int(fabs(m_Power))); - + m_AbsN = T(int(std::abs(m_Power))); m_Cn = 1 / m_Power / 2; } @@ -5277,7 +5042,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_FreqX, prefix + "wavesn_freqx", 2)); m_Params.push_back(ParamWithName(&m_FreqY, prefix + "wavesn_freqy", 2)); @@ -5326,7 +5090,7 @@ public: T bx = 4 / r2_4; T by = m_Rat / r2_4; T x = m_Cosa * (bx * helper.In.x) - m_Sina * (by * helper.In.y); - T y = m_Sina * (bx * helper.In.x) + m_Cosa * (by *helper.In.y); + T y = m_Sina * (bx * helper.In.x) + m_Cosa * (by * helper.In.y); if (x > 0) { @@ -5353,7 +5117,6 @@ public: string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rat = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r2_4 = precalcSumSquares + 4;\n" << "\n" @@ -5378,14 +5141,12 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { T ang = T(M_PI_4) + (T(0.5) * T(M_PI_4) * m_Angle); - sincos(ang, &m_Sina, &m_Cosa); m_Rat = 6 + 2 * m_Ratio; } @@ -5394,7 +5155,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Angle, prefix + "xheart_angle")); m_Params.push_back(ParamWithName(&m_Ratio, prefix + "xheart_ratio")); @@ -5433,19 +5193,15 @@ public: T dot02 = m_A * helper.In.x + m_B * helper.In.y;//v0 * v2. T dot11 = SQR(m_C) + SQR(m_D);//v1 * v1. T dot12 = m_C * helper.In.x + m_D * helper.In.y;//v1 * v2. - //Compute inverse denomiator. T invDenom = 1 / (dot00 * dot11 - dot01 * dot01); - //Now we can pull [u,v] as the barycentric coordinates of the point //P in the triangle [A, B, C]. T u = (dot11 * dot02 - dot01 * dot12) * invDenom; T v = (dot00 * dot12 - dot01 * dot02) * invDenom; - // now combine with input T um = std::sqrt(SQR(u) + SQR(helper.In.x)) * Sign(u); T vm = std::sqrt(SQR(v) + SQR(helper.In.y)) * Sign(v); - helper.Out.x = m_Weight * um; helper.Out.y = m_Weight * vm; helper.Out.z = m_Weight * helper.In.z; @@ -5461,7 +5217,6 @@ public: string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t dot00 = SQR(" << a << ") + SQR(" << b << ");\n" << "\t\treal_t dot01 = " << a << " * " << c << " + " << b << " * " << d << ";\n" @@ -5478,7 +5233,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vm;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5491,7 +5245,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_A, prefix + "barycentroid_a", 1)); m_Params.push_back(ParamWithName(&m_B, prefix + "barycentroid_b")); @@ -5534,13 +5287,11 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string weight01 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tvOut.x = " << weight01 << " / tan(vIn.x) * cos(vIn.y);\n" << "\t\tvOut.y = " << weight01 << " / sin(vIn.x) * (-vIn.y);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5553,7 +5304,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_Weight01, prefix + "bisplit_weight01"));//Precalc only. } @@ -5579,7 +5329,6 @@ public: T sinx2 = SQR(sinx); T cosx = std::cos(helper.In.x); T coshy1 = std::cosh(helper.In.y) + 1; - helper.Out.x = m_Weight * sinx * coshy1 * sinx2; helper.Out.y = m_Weight * cosx * coshy1 * sinx2; helper.Out.z = m_Weight * helper.In.z; @@ -5589,7 +5338,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t sinx = sin(vIn.x);\n" << "\t\treal_t sinx2 = SQR(sinx);\n" @@ -5600,7 +5348,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cosx * coshy1 * sinx2;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5628,7 +5375,6 @@ public: T sinx2 = SQR(sinx); T cosx = std::cos(helper.In.x); T coshy1 = std::cosh(helper.In.y) + 1; - helper.Out.x = d * sinx * coshy1 * sinx2; helper.Out.y = d * cosx * coshy1 * sinx2; helper.Out.z = m_Weight * helper.In.z; @@ -5638,7 +5384,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] / precalcSumSquares;\n" << "\t\treal_t sinx = sin(vIn.x);\n" @@ -5650,7 +5395,6 @@ public: << "\t\tvOut.y = d * cosx * coshy1 * sinx2;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5690,7 +5434,6 @@ public: T lnr2 = std::log(helper.m_PrecalcSumSquares); T r = m_Weight * std::exp(m_HalfC * lnr2 - m_D * a); T temp = m_C * a + m_HalfD * lnr2 + m_Ang * rand.Rand(); - helper.Out.x = r * std::cos(temp); helper.Out.y = r * std::sin(temp); helper.Out.z = m_Weight * helper.In.z; @@ -5713,7 +5456,6 @@ public: string ang = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invSpread = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string fullSpread = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t a = precalcAtanyx;\n" << "\t\tint n = MwcNextRange(mwc, (uint)" << spread << ");\n" @@ -5734,7 +5476,6 @@ public: << "\t\tvOut.y = r * sin(temp);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -5753,7 +5494,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_R, prefix + "cpow2_r", 1)); m_Params.push_back(ParamWithName(&m_A, prefix + "cpow2_a")); diff --git a/Source/Ember/Variations03.h b/Source/Ember/Variations03.h index 94f93e0..12aa946 100644 --- a/Source/Ember/Variations03.h +++ b/Source/Ember/Variations03.h @@ -428,7 +428,7 @@ public: } else { - T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs(). + T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs(). if (rand.Frand01() > m_Contrast * std::pow(alpha, m_Pow)) { @@ -543,7 +543,7 @@ public: T val = DEG_2_RAD_T * m_Phi1; T sinPhi1 = std::sin(val); T cosPhi1 = std::cos(val); - m_Pow = fabs(m_Pow); + m_Pow = std::abs(m_Pow); m_X1 = m_Radius * cosPhi1; m_Y1 = m_Radius * sinPhi1; } @@ -610,7 +610,7 @@ public: } else { - T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs(). + T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs(). if (rand.Frand01() > m_Contrast * std::pow(alpha, m_Pow)) { @@ -696,7 +696,7 @@ public: virtual void Precalc() override { - m_Pow = fabs(m_Pow); + m_Pow = std::abs(m_Pow); m_Phi10 = T(M_PI) * m_Phi1 / 180; m_Phi20 = T(M_PI) * m_Phi2 / 180; m_Gamma = m_Thickness * (2 * m_Radius + m_Thickness) / Zeps(m_Radius + m_Thickness); @@ -769,7 +769,7 @@ public: } else { - T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs(). + T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs(). if (rand.Frand01() > m_Contrast * std::pow(alpha, m_Pow)) { @@ -1108,7 +1108,7 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T coeff = fabs(helper.In.z); + T coeff = std::abs(helper.In.z); if (coeff != 0 && m_Power != 1) coeff = std::exp(log(coeff) * m_Power); @@ -1492,7 +1492,7 @@ public: virtual void Precalc() override { - m_AbsN = fabs(m_N); + m_AbsN = std::abs(m_N); m_Cn = (1 / m_N - 1) / 2; } @@ -1565,7 +1565,7 @@ public: virtual void Precalc() override { - m_AbsN = fabs(m_N); + m_AbsN = std::abs(m_N); m_Cn = 1 / m_N / 2; } @@ -1609,8 +1609,8 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - helper.Out.x = SignNz(helper.In.x) * std::pow(fabs(helper.In.x), m_PowX) * m_Weight; - helper.Out.y = SignNz(helper.In.y) * std::pow(fabs(helper.In.y), m_PowY) * m_Weight; + helper.Out.x = SignNz(helper.In.x) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight; + helper.Out.y = SignNz(helper.In.y) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight; helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; } @@ -1665,9 +1665,9 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - helper.Out.x = T(helper.In.x < 0 ? -1 : 1) * std::pow(fabs(helper.In.x), m_PowX) * m_Weight; - helper.Out.y = T(helper.In.y < 0 ? -1 : 1) * std::pow(fabs(helper.In.y), m_PowY) * m_Weight; - helper.Out.z = T(helper.In.z < 0 ? -1 : 1) * std::pow(fabs(helper.In.z), m_PowZ) * m_Weight; + helper.Out.x = T(helper.In.x < 0 ? -1 : 1) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight; + helper.Out.y = T(helper.In.y < 0 ? -1 : 1) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight; + helper.Out.z = T(helper.In.z < 0 ? -1 : 1) * std::pow(std::abs(helper.In.z), m_PowZ) * m_Weight; } virtual string OpenCLString() const override @@ -2592,7 +2592,7 @@ public: virtual void Precalc() override { - if (fabs(m_Power) < 1) + if (std::abs(m_Power) < 1) m_Power = 1; } @@ -2951,7 +2951,7 @@ public: if (t < 0) t -= m_SizeDiv2; - t = fmod(fabs(t), m_Size); + t = fmod(std::abs(t), m_Size); if (t < m_SizeDiv2) a += m_Even; @@ -3556,15 +3556,15 @@ public: { T x, c2; - if (fabs(helper.In.y) <= m_Weight) + if (std::abs(helper.In.y) <= m_Weight) { c2 = std::sqrt(SQR(m_Weight) - SQR(helper.In.y)); - if (fabs(helper.In.x) <= c2) + if (std::abs(helper.In.x) <= c2) { x = helper.In.x + m_Shift * m_Weight; - if (fabs(x) >= c2) + if (std::abs(x) >= c2) helper.Out.x = -(m_Weight * helper.In.x); else helper.Out.x = m_Weight * x; diff --git a/Source/Ember/Variations04.h b/Source/Ember/Variations04.h index 7b41e94..b78bca4 100644 --- a/Source/Ember/Variations04.h +++ b/Source/Ember/Variations04.h @@ -23,9 +23,7 @@ public: T tmp = helper.m_PrecalcSumSquares + 1; T tmp2 = 2 * helper.In.x; T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); - ClampGteRef(xmax, -1); - T mu = std::acosh(xmax); T nu = std::acos(Clamp(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi. @@ -33,7 +31,6 @@ public: nu *= -1; nu = nu + mu * m_Out + m_In / mu; - helper.Out.x = m_Weight * std::cosh(mu) * std::cos(nu); helper.Out.y = m_Weight * std::sinh(mu) * std::sin(nu); helper.Out.z = m_Weight * helper.In.z; @@ -47,7 +44,6 @@ public: string index = ss2.str(); string in = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string out = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t tmp = precalcSumSquares + 1;\n" << "\t\treal_t tmp2 = 2 * vIn.x;\n" @@ -68,7 +64,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinh(mu) * sin(nu);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -81,7 +76,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_In, prefix + "eSwirl_in")); m_Params.push_back(ParamWithName(&m_Out, prefix + "eSwirl_out")); @@ -108,8 +102,8 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T x = fabs(helper.In.x); - T y = fabs(helper.In.y); + T x = std::abs(helper.In.x); + T y = std::abs(helper.In.y); T s; T p; T x2, y2; @@ -224,7 +218,6 @@ public: string space = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string in4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string out4 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = fabs(vIn.x);\n" << "\t\treal_t y = fabs(vIn.y);\n" @@ -330,7 +323,6 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -344,7 +336,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_SpinIn, prefix + "lazyTravis_spin_in", 1, eParamType::REAL_CYCLIC, 0, 2)); m_Params.push_back(ParamWithName(&m_SpinOut, prefix + "lazyTravis_spin_out", 0, eParamType::REAL_CYCLIC, 0, 2)); @@ -377,8 +368,8 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T x = fabs(helper.In.x); - T y = fabs(helper.In.y); + T x = std::abs(helper.In.x); + T y = std::abs(helper.In.y); T s; T p; @@ -440,7 +431,6 @@ public: string index = ss2.str(); string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t x = fabs(vIn.x);\n" << "\t\treal_t y = fabs(vIn.y);\n" @@ -496,7 +486,6 @@ public: << "\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -509,7 +498,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Power, prefix + "squish_power", 2, eParamType::INTEGER, 2, T(INT_MAX))); m_Params.push_back(ParamWithName(true, &m_InvPower, prefix + "squish_inv_power"));//Precalc. @@ -556,7 +544,6 @@ public: string index = ss2.str(); string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = precalcSqrtSumSquares;\n" << "\n" @@ -569,7 +556,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * precalcSina;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -582,7 +568,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Scale, prefix + "circus_scale", 1)); m_Params.push_back(ParamWithName(true, &m_InvScale, prefix + "circus_inv_power"));//Precalc. @@ -607,7 +592,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T d = Zeps(helper.m_PrecalcSumSquares); - helper.Out.x = (m_Weight / d) * (tanh(d) * (2 * helper.In.x)); helper.Out.y = (m_Weight / d) * (cos(d) * (2 * helper.In.y)); helper.Out.z = m_Weight * helper.In.z; @@ -617,7 +601,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t d = Zeps(precalcSumSquares);\n" << "\n" @@ -625,7 +608,6 @@ public: << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] / d) * (cos(d) * ((real_t)(2.0) * vIn.y));\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -649,7 +631,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T d = Zeps(helper.m_PrecalcSumSquares); - helper.Out.x = (m_Weight / 2) * (tanh(d) * (2 * helper.In.x)); helper.Out.y = (m_Weight / 2) * (cos(d) * (2 * helper.In.y)); helper.Out.z = m_Weight * helper.In.z; @@ -659,7 +640,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t d = Zeps(precalcSumSquares);\n" << "\n" @@ -667,7 +647,6 @@ public: << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] / (real_t)(2.0)) * (cos(d) * ((real_t)(2.0) * vIn.y));\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -718,7 +697,6 @@ public: string index = ss2.str(); string rxSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string rxCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t z = " << rxCos << " * vIn.z - " << rxSin << " * vIn.y;\n" << "\n"; @@ -726,19 +704,18 @@ public: if (m_VarType == eVariationType::VARTYPE_REG) { ss << - "\t\tvOut.x = 0;\n" - "\t\toutPoint->m_X = vIn.x;\n"; + "\t\tvOut.x = 0;\n" + "\t\toutPoint->m_X = vIn.x;\n"; } else { ss << - "\t\tvOut.x = vIn.x;\n"; + "\t\tvOut.x = vIn.x;\n"; } ss << "\t\tvOut.y = " << rxSin << " * vIn.z + " << rxCos << " * vIn.y;\n" << "\t\tvOut.z = z;\n" << "\t}\n"; - return ss.str(); } @@ -752,7 +729,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_RxSin, prefix + "rotate_x_sin"));//Precalcs only, no params. m_Params.push_back(ParamWithName(true, &m_RxCos, prefix + "rotate_x_cos"));//Original used a prefix of rx_, which is incompatible with Ember's design. @@ -803,25 +779,23 @@ public: string index = ss2.str(); string rySin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string ryCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tvOut.x = " << ryCos << " * vIn.x - " << rySin << " * vIn.z;\n"; if (m_VarType == eVariationType::VARTYPE_REG) { ss << - "\t\tvOut.y = 0;\n" - "\t\toutPoint->m_Y = vIn.y;\n"; + "\t\tvOut.y = 0;\n" + "\t\toutPoint->m_Y = vIn.y;\n"; } else { ss << - "\t\tvOut.y = vIn.y;\n"; + "\t\tvOut.y = vIn.y;\n"; } ss << "\t\tvOut.z = " << rySin << " * vIn.x + " << ryCos << " * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -835,7 +809,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_RySin, prefix + "rotate_y_sin"));//Precalcs only, no params. m_Params.push_back(ParamWithName(true, &m_RyCos, prefix + "rotate_y_cos"));//Original used a prefix of ry_, which is incompatible with Ember's design. @@ -885,7 +858,6 @@ public: string index = ss2.str(); string rzSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string rzCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tvOut.x = " << rzSin << " * vIn.y + " << rzCos << " * vIn.x;\n" << "\t\tvOut.y = " << rzCos << " * vIn.y - " << rzSin << " * vIn.x;\n"; @@ -893,17 +865,16 @@ public: if (m_VarType == eVariationType::VARTYPE_REG) { ss << - "\t\tvOut.z = 0;\n" - "\t\toutPoint->m_Z = vIn.z;\n"; + "\t\tvOut.z = 0;\n" + "\t\toutPoint->m_Z = vIn.z;\n"; } else { ss << - "\t\tvOut.z = vIn.z;\n"; + "\t\tvOut.z = vIn.z;\n"; } ss << "\t}\n"; - return ss.str(); } @@ -917,7 +888,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_RzSin, prefix + "rotate_z_sin"));//Precalcs only, no params. m_Params.push_back(ParamWithName(true, &m_RzCos, prefix + "rotate_z_cos")); @@ -944,7 +914,7 @@ public: { if (m_VarType == eVariationType::VARTYPE_REG) { - helper.Out.x = fabs(outPoint.m_X); + helper.Out.x = std::abs(outPoint.m_X); if (rand.RandBit()) helper.Out.x = -helper.Out.x; @@ -955,7 +925,7 @@ public: } else { - helper.Out.x = fabs(helper.In.x); + helper.Out.x = std::abs(helper.In.x); if (rand.RandBit()) helper.Out.x = -helper.Out.x; @@ -968,35 +938,33 @@ public: virtual string OpenCLString() const override { ostringstream ss; - ss << "\t{\n"; if (m_VarType == eVariationType::VARTYPE_REG) { ss << - "\t\tvOut.x = fabs(outPoint->m_X);\n" - "\n" - "\t\tif (MwcNext(mwc) & 1)\n" - "\t\t vOut.x = -vOut.x;\n" - "\n" - "\t\tvOut.y = 0;\n" - "\t\tvOut.z = 0;\n" - "\t\toutPoint->m_X = 0;\n"; + "\t\tvOut.x = fabs(outPoint->m_X);\n" + "\n" + "\t\tif (MwcNext(mwc) & 1)\n" + "\t\t vOut.x = -vOut.x;\n" + "\n" + "\t\tvOut.y = 0;\n" + "\t\tvOut.z = 0;\n" + "\t\toutPoint->m_X = 0;\n"; } else { ss << - "\t\tvOut.x = fabs(vIn.x);\n" - "\n" - "\t\tif (MwcNext(mwc) & 1)\n" - "\t\t vOut.x = -vOut.x;\n" - "\n" - "\t\tvOut.y = vIn.y;\n" - "\t\tvOut.z = vIn.z;\n"; + "\t\tvOut.x = fabs(vIn.x);\n" + "\n" + "\t\tif (MwcNext(mwc) & 1)\n" + "\t\t vOut.x = -vOut.x;\n" + "\n" + "\t\tvOut.y = vIn.y;\n" + "\t\tvOut.z = vIn.z;\n"; } ss << "\t}\n"; - return ss.str(); } }; @@ -1017,7 +985,7 @@ public: { if (m_VarType == eVariationType::VARTYPE_REG) { - helper.Out.y = fabs(outPoint.m_Y); + helper.Out.y = std::abs(outPoint.m_Y); if (rand.RandBit()) helper.Out.y = -helper.Out.y; @@ -1028,7 +996,7 @@ public: } else { - helper.Out.y = fabs(helper.In.y); + helper.Out.y = std::abs(helper.In.y); if (rand.RandBit()) helper.Out.y = -helper.Out.y; @@ -1041,35 +1009,33 @@ public: virtual string OpenCLString() const override { ostringstream ss; - ss << "\t{\n"; if (m_VarType == eVariationType::VARTYPE_REG) { ss << - "\t\tvOut.y = fabs(outPoint->m_Y);\n" - "\n" - "\t\tif (MwcNext(mwc) & 1)\n" - "\t\t vOut.y = -vOut.y;\n" - "\n" - "\t\tvOut.x = 0;\n" - "\t\tvOut.z = 0;\n" - "\t\toutPoint->m_Y = 0;\n"; + "\t\tvOut.y = fabs(outPoint->m_Y);\n" + "\n" + "\t\tif (MwcNext(mwc) & 1)\n" + "\t\t vOut.y = -vOut.y;\n" + "\n" + "\t\tvOut.x = 0;\n" + "\t\tvOut.z = 0;\n" + "\t\toutPoint->m_Y = 0;\n"; } else { ss << - "\t\tvOut.y = fabs(vIn.y);\n" - "\n" - "\t\tif (MwcNext(mwc) & 1)\n" - "\t\t vOut.y = -vOut.y;\n" - "\n" - "\t\tvOut.x = vIn.x;\n" - "\t\tvOut.z = vIn.z;\n"; + "\t\tvOut.y = fabs(vIn.y);\n" + "\n" + "\t\tif (MwcNext(mwc) & 1)\n" + "\t\t vOut.y = -vOut.y;\n" + "\n" + "\t\tvOut.x = vIn.x;\n" + "\t\tvOut.z = vIn.z;\n"; } ss << "\t}\n"; - return ss.str(); } }; @@ -1090,7 +1056,7 @@ public: { if (m_VarType == eVariationType::VARTYPE_REG) { - helper.Out.z = fabs(outPoint.m_Z); + helper.Out.z = std::abs(outPoint.m_Z); if (rand.RandBit()) helper.Out.z = -helper.Out.z; @@ -1101,7 +1067,7 @@ public: } else { - helper.Out.z = fabs(helper.In.z); + helper.Out.z = std::abs(helper.In.z); if (rand.RandBit()) helper.Out.z = -helper.Out.z; @@ -1114,35 +1080,33 @@ public: virtual string OpenCLString() const override { ostringstream ss; - ss << "\t{\n"; if (m_VarType == eVariationType::VARTYPE_REG) { ss << - "\t\tvOut.z = fabs(outPoint->m_Z);\n" - "\n" - "\t\tif (MwcNext(mwc) & 1)\n" - "\t\t vOut.z = -vOut.z;\n" - "\n" - "\t\tvOut.x = 0;\n" - "\t\tvOut.y = 0;\n" - "\t\toutPoint->m_Z = 0;\n"; + "\t\tvOut.z = fabs(outPoint->m_Z);\n" + "\n" + "\t\tif (MwcNext(mwc) & 1)\n" + "\t\t vOut.z = -vOut.z;\n" + "\n" + "\t\tvOut.x = 0;\n" + "\t\tvOut.y = 0;\n" + "\t\toutPoint->m_Z = 0;\n"; } else { ss << - "\t\tvOut.z = fabs(vIn.z);\n" - "\n" - "\t\tif (MwcNext(mwc) & 1)\n" - "\t\t vOut.z = -vOut.z;\n" - "\n" - "\t\tvOut.x = vIn.x;\n" - "\t\tvOut.y = vIn.y;\n"; + "\t\tvOut.z = fabs(vIn.z);\n" + "\n" + "\t\tif (MwcNext(mwc) & 1)\n" + "\t\t vOut.z = -vOut.z;\n" + "\n" + "\t\tvOut.x = vIn.x;\n" + "\t\tvOut.y = vIn.y;\n"; } ss << "\t}\n"; - return ss.str(); } }; @@ -1166,12 +1130,11 @@ public: T sx = helper.In.x - m_CenterX; T sy = helper.In.y - m_CenterY; T r = std::sqrt(SQR(sx) + SQR(sy)) - m_Offset; - r = r < 0 ? 0 : r; r *= m_S2; - helper.Out.x = m_Weight * (helper.In.x + (rand.Frand01() - T(0.5)) * r); helper.Out.y = m_Weight * (helper.In.y + (rand.Frand01() - T(0.5)) * r); + helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; } virtual string OpenCLString() const override @@ -1185,7 +1148,6 @@ public: string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t sx = vIn.x - " << centerX << ";\n" << "\t\treal_t sy = vIn.y - " << centerY << ";\n" @@ -1196,9 +1158,8 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + (MwcNext01(mwc) - (real_t)(0.5)) * r);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + (MwcNext01(mwc) - (real_t)(0.5)) * r);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"//WHY IS THIS DIFFERENT THAN THE CPU ONE?//TODO + << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1211,7 +1172,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Strength, prefix + "rblur_strength", 1)); m_Params.push_back(ParamWithName(&m_Offset, prefix + "rblur_offset", 1)); @@ -1244,11 +1204,9 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T jun = Zeps(fabs(m_N)); - - T a = (std::atan2(helper.In.y, std::pow(fabs(helper.In.x), m_Sep)) + M_2PI * Floor(rand.Frand01() * m_AbsN)) / jun; + T jun = Zeps(std::abs(m_N)); + T a = (std::atan2(helper.In.y, std::pow(std::abs(helper.In.x), m_Sep)) + M_2PI * Floor(rand.Frand01() * m_AbsN)) / jun; T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn * m_A); - helper.Out.x = r * std::cos(a) + m_B; helper.Out.y = r * std::sin(a) + m_B; helper.Out.z = m_Weight * helper.In.z;//Original did not multiply by weight. Do it here to be consistent with others. @@ -1266,7 +1224,6 @@ public: string sep = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t jun = Zeps(fabs(" << n << "));\n" << "\n" @@ -1277,7 +1234,6 @@ public: << "\t\tvOut.y = r * sin(a) + " << b << ";\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -1288,8 +1244,7 @@ public: virtual void Precalc() override { - T jun = Zeps(fabs(m_N)); - + T jun = Zeps(std::abs(m_N)); m_AbsN = abs(m_N); m_Cn = 1 / jun / 2; } @@ -1298,7 +1253,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_N, prefix + "juliaNab_n", 1)); m_Params.push_back(ParamWithName(&m_A, prefix + "juliaNab_a", 1)); @@ -1336,7 +1290,6 @@ public: T sqX = SQR(helper.In.x); T sqY = SQR(helper.In.y); T v = (sqX + sqY) * m_W;//Do not use precalcSumSquares here because its components are needed below. - helper.Out.x = m_Weight * std::sin(helper.In.x) * (sqX + m_W - v); helper.Out.y = m_Weight * std::sin(helper.In.y) * (sqY + m_W - v); helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; @@ -1349,7 +1302,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string w = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t sqX = SQR(vIn.x);\n" << "\t\treal_t sqY = SQR(vIn.y);\n" @@ -1359,7 +1311,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.y) * (sqY + " << w << " - v);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1367,7 +1318,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_W, prefix + "sintrange_w", 1)); } @@ -1395,7 +1345,6 @@ public: intmax_t l, k; int i, j, m, m1, n, n1; T r, rMin, offsetX, offsetY, x0 = 0, y0 = 0, x, y; - rMin = 20; m = int(Floor(helper.In.x / m_Step)); n = int(Floor(helper.In.y / m_Step)); @@ -1443,7 +1392,6 @@ public: string num = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string xSeed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ySeed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint i, j, l, k, m, m1, n, n1;\n" << "\t\treal_t r, rMin, offsetX, offsetY, x0 = (real_t)(0.0), y0 = (real_t)(0.0), x, y;\n" @@ -1483,7 +1431,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (" << m_k << " * (vIn.y - y0) + y0);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1506,7 +1453,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_K, prefix + "Voron_K", T(0.99))); m_Params.push_back(ParamWithName(&m_Step, prefix + "Voron_Step", T(0.25), eParamType::REAL_NONZERO)); @@ -1520,7 +1466,6 @@ private: { const T im = T(2147483647); const T am = (1 / im); - int n = x; n = (n << 13) ^ n; return ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) * am; @@ -1557,18 +1502,22 @@ public: a = (rand.Rand(ISAAC_INT(m_Slices)) + rand.Frand01() * m_XThickness) / m_Slices; r = (rand.Rand(ISAAC_INT(m_Slices)) + rand.Frand01() * m_YThickness) / m_Slices; break; + case 1: a = (rand.Rand(ISAAC_INT(m_Slices)) + rand.Frand01()) / m_Slices; r = (rand.Rand(ISAAC_INT(m_Slices)) + m_YThickness) / m_Slices; break; + case 2: a = (rand.Rand(ISAAC_INT(m_Slices)) + m_XThickness) / m_Slices; r = (rand.Rand(ISAAC_INT(m_Slices)) + rand.Frand01()) / m_Slices; break; + case 3: a = rand.Frand01(); r = (rand.Rand(ISAAC_INT(m_Slices)) + m_YThickness + rand.Frand01() * (1 - m_YThickness)) / m_Slices; break; + case 4: default: a = (rand.Rand(ISAAC_INT(m_Slices)) + m_XThickness + rand.Frand01() * (1 - m_XThickness)) / m_Slices; @@ -1593,7 +1542,6 @@ public: string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sinr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cosr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t a = 0, r = 0;\n" << "\n" @@ -1625,7 +1573,6 @@ public: << "\t\tvOut.y = -" << sinr << " * a + " << cosr << " * r;\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1639,7 +1586,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Slices, prefix + "waffle_slices", 6, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName(&m_XThickness, prefix + "waffle_xthickness", T(0.5))); @@ -1680,13 +1626,11 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) - (real_t)(0.5));\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) - (real_t)(0.5));\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) - (real_t)(0.5));\n" << "\t}\n"; - return ss.str(); } }; @@ -1708,7 +1652,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T pr1, r1, pr2, r2, rho1, phi1, sinr, sinp, cosr, cosp, msinr, msinp, mcosr, mcosp, temp; - rho1 = rand.Frand01() * m_Rho2Pi; phi1 = rand.Frand01() * m_Phi2Pi; @@ -1717,22 +1660,18 @@ public: sinr = std::sin(rho1); cosr = std::cos(rho1); - sinp = std::sin(phi1); cosp = std::cos(phi1); - temp = m_M4_1 * rho1; msinr = std::sin(temp); mcosr = std::cos(temp); - temp = m_M4_2 * phi1; msinp = std::sin(temp); mcosp = std::cos(temp); - - pr1 = m_An2_1 * std::pow(fabs(mcosr), m_N2_1) + m_Bn3_1 * std::pow(fabs(msinr), m_N3_1); - pr2 = m_An2_2 * std::pow(fabs(mcosp), m_N2_2) + m_Bn3_2 * std::pow(fabs(msinp), m_N3_2); - r1 = std::pow(fabs(pr1), m_N1_1) + m_Spiral * rho1; - r2 = std::pow(fabs(pr2), m_N1_2); + pr1 = m_An2_1 * std::pow(std::abs(mcosr), m_N2_1) + m_Bn3_1 * std::pow(std::abs(msinr), m_N3_1); + pr2 = m_An2_2 * std::pow(std::abs(mcosp), m_N2_2) + m_Bn3_2 * std::pow(std::abs(msinp), m_N3_2); + r1 = std::pow(std::abs(pr1), m_N1_1) + m_Spiral * rho1; + r2 = std::pow(std::abs(pr2), m_N1_2); if (int(m_Toroidmap) == 1) { @@ -1780,12 +1719,11 @@ public: string m4_2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rho2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string phi2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t pr1, r1, pr2, r2, rho1, phi1, sinr, sinp, cosr, cosp, msinr, msinp, mcosr, mcosp, temp;\n" << "\n" << "\t\trho1 = MwcNext01(mwc) * " << rho2pi << ";\n" - << "\t\tphi1 = MwcNext01(mwc) * " << phi2pi<< ";\n" + << "\t\tphi1 = MwcNext01(mwc) * " << phi2pi << ";\n" << "\n" << "\t\tif (MwcNext(mwc) & 1)\n" << "\t\t phi1 = -phi1;\n" @@ -1796,7 +1734,7 @@ public: << "\t\tsinp = sin(phi1);\n" << "\t\tcosp = cos(phi1);\n" << "\n" - << "\t\ttemp = " << m4_1<< " * rho1;\n" + << "\t\ttemp = " << m4_1 << " * rho1;\n" << "\t\tmsinr = sin(temp);\n" << "\t\tmcosr = cos(temp);\n" << "\n" @@ -1822,7 +1760,6 @@ public: << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * r2 * sinp;\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } @@ -1830,10 +1767,10 @@ public: { m_N1n_1 = (-1 / m_N1_1); m_N1n_2 = (-1 / m_N1_2); - m_An2_1 = std::pow(fabs(1 / m_A1), m_N2_1); - m_An2_2 = std::pow(fabs(1 / m_A2), m_N2_2); - m_Bn3_1 = std::pow(fabs(1 / m_B1), m_N3_1); - m_Bn3_2 = std::pow(fabs(1 / m_B2), m_N3_2); + m_An2_1 = std::pow(std::abs(1 / m_A1), m_N2_1); + m_An2_2 = std::pow(std::abs(1 / m_A2), m_N2_2); + m_Bn3_1 = std::pow(std::abs(1 / m_B1), m_N3_1); + m_Bn3_2 = std::pow(std::abs(1 / m_B2), m_N3_2); m_M4_1 = m_M1 / 4; m_M4_2 = m_M2 / 4; m_Rho2Pi = m_Rho * T(M_2_PI); @@ -1844,7 +1781,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Rho, prefix + "SuperShape3D_rho", T(9.9))); m_Params.push_back(ParamWithName(&m_Phi, prefix + "SuperShape3D_phi", T(2.5))); @@ -1920,11 +1856,9 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T t, rX, rY, rZ; - t = Zeps(helper.m_PrecalcSumSquares + SQR(helper.In.z)); rX = m_Weight / std::pow(t, m_StretchX); rY = m_Weight / std::pow(t, m_StretchY); - helper.Out.x = helper.In.x * rX; helper.Out.y = helper.In.y * rY; @@ -1946,7 +1880,6 @@ public: string stretchY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string stretchZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zOn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t t, rX, rY, rZ;\n" << "\n" @@ -1964,7 +1897,6 @@ public: << "\t\tvOut.z = vIn.z * rZ;\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } @@ -1977,7 +1909,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_StretchX, prefix + "sphyp3D_stretchX", 1)); m_Params.push_back(ParamWithName(&m_StretchY, prefix + "sphyp3D_stretchY", 1)); @@ -2008,45 +1939,49 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T xi = helper.In.x - m_X;//Original altered the input pointed to for reg, but not for pre/post. Don't do that here. + T xi = helper.In.x - m_X; T yi = helper.In.y - m_Y; + if (m_VarType == eVariationType::VARTYPE_REG)//Original altered the input pointed to for reg. + { + helper.m_TransX -= m_X; + helper.m_TransY -= m_Y; + helper.Out.z = m_Weight * helper.In.z;//Original only assigned z for reg. Will be summed. + } + else + { + helper.Out.z = helper.In.z;//Original did nothing with z for pre/post, so passthrough direct assign. + } + const T rad = std::sqrt(SQR(xi) + SQR(yi)); const T ang = std::atan2(yi, xi); const T rdc = m_Radius + (rand.Frand01() * T(0.5) * m_Ca); const T s = std::sin(ang); const T c = std::cos(ang); - const int esc = rad > m_Radius; const int cr0 = int(m_Zero); - if (cr0 && esc) + if (cr0 && esc) { - if (m_VarType == eVariationType::VARTYPE_PRE) - helper.m_TransX = helper.m_TransY = 0; - else - outPoint.m_X = outPoint.m_Y = 0; - helper.Out.x = helper.Out.y = 0; - helper.Out.z = m_Weight * helper.In.z; + + if (m_VarType == eVariationType::VARTYPE_REG) + outPoint.m_X = outPoint.m_Y = 0; } else if (cr0 && !esc) { helper.Out.x = m_Weight * xi + m_X; helper.Out.y = m_Weight * yi + m_Y; - helper.Out.z = m_Weight * helper.In.z; } else if (!cr0 && esc) { helper.Out.x = m_Weight * rdc * c + m_X; helper.Out.y = m_Weight * rdc * s + m_Y; - helper.Out.z = m_Weight * helper.In.z; } else if (!cr0 && !esc) { helper.Out.x = m_Weight * xi + m_X; helper.Out.y = m_Weight * yi + m_Y; - helper.Out.z = m_Weight * helper.In.z; } } @@ -2062,52 +1997,59 @@ public: string scatterArea = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zero = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ca = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" - << "\t\treal_t xi = vIn.x - " << x << ";\n" - << "\t\treal_t yi = vIn.y - " << y << ";\n" - << "\n" - << "\t\tconst real_t rad = sqrt(SQR(xi) + SQR(yi));\n" - << "\t\tconst real_t ang = atan2(yi, xi);\n" - << "\t\tconst real_t rdc = " << radius << " + (MwcNext01(mwc) * (real_t)(0.5) * " << ca << "); \n" - << "\t\tconst real_t s = sin(ang);\n" - << "\t\tconst real_t c = cos(ang);\n" - << "\n" - << "\t\tconst int esc = rad > " << radius << ";\n" - << "\t\tconst int cr0 = (int)" << zero << ";\n" - << "\n" - << "\t\tif (cr0 && esc)\n" - << "\t\t{\n"; + << "\t\treal_t xi = vIn.x - " << x << ";\n" + << "\t\treal_t yi = vIn.y - " << y << ";\n" + << "\n"; - if (m_VarType == eVariationType::VARTYPE_PRE) - ss << "\t\t transX = transY = 0;\n"; + if (m_VarType == eVariationType::VARTYPE_REG)//Original altered the input pointed to for reg. + { + ss + << "\t\ttransX -= " << x << ";\n" + << "\t\ttransY -= " << y << ";\n" + << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"; + } else + { + ss + << "\t\tvOut.z = vIn.z;\n"; + } + + ss + << "\t\tconst real_t rad = sqrt(SQR(xi) + SQR(yi));\n" + << "\t\tconst real_t ang = atan2(yi, xi);\n" + << "\t\tconst real_t rdc = " << radius << " + (MwcNext01(mwc) * (real_t)(0.5) * " << ca << "); \n" + << "\t\tconst real_t s = sin(ang);\n" + << "\t\tconst real_t c = cos(ang);\n" + << "\n" + << "\t\tconst int esc = rad > " << radius << ";\n" + << "\t\tconst int cr0 = (int)" << zero << ";\n" + << "\n" + << "\t\tif (cr0 && esc)\n" + << "\t\t{\n" + << "\t\t vOut.x = vOut.y = 0;\n"; + + if (m_VarType == eVariationType::VARTYPE_REG) ss << "\t\t outPoint->m_X = outPoint->m_Y = 0;\n"; - ss - << "\t\t vOut.x = vOut.y = 0;\n" - << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" - << "\t\t}\n" - << "\t\telse if (cr0 && !esc)\n" - << "\t\t{\n" - << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * xi + " << x << ";\n" - << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * yi + " << y << ";\n" - << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" - << "\t\t}\n" - << "\t\telse if (!cr0 && esc)\n" - << "\t\t{\n" - << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * rdc * c + " << x << ";\n" - << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * rdc * s + " << y << ";\n" - << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" - << "\t\t}\n" - << "\t\telse if (!cr0 && !esc)\n" - << "\t\t{\n" - << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * xi + " << x << ";\n" - << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * yi + " << y << ";\n" - << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" - << "\t\t}\n" - << "\t}\n"; - + ss + << "\t\t}\n" + << "\t\telse if (cr0 && !esc)\n" + << "\t\t{\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * xi + " << x << ";\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * yi + " << y << ";\n" + << "\t\t}\n" + << "\t\telse if (!cr0 && esc)\n" + << "\t\t{\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * rdc * c + " << x << ";\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * rdc * s + " << y << ";\n" + << "\t\t}\n" + << "\t\telse if (!cr0 && !esc)\n" + << "\t\t{\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * xi + " << x << ";\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * yi + " << y << ";\n" + << "\t\t}\n" + << "\t}\n"; return ss.str(); } @@ -2120,7 +2062,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Radius, prefix + "circlecrop_radius", 1)); m_Params.push_back(ParamWithName(&m_X, prefix + "circlecrop_x")); @@ -2162,7 +2103,6 @@ public: const T tempRand = T(int(rand.Frand01() * m_AbsN)); const T alpha = (std::atan2(y, x) + M_2PI * tempRand) / m_Power; const T gamma = radiusOut * helper.m_PrecalcSqrtSumSquares; - helper.Out.x = gamma * std::cos(alpha); helper.Out.y = gamma * std::sin(alpha); helper.Out.z = radiusOut * z; @@ -2184,7 +2124,6 @@ public: string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tconst real_t z = vIn.z / " << absn << ";\n" << "\t\tconst real_t radiusOut = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSumSquares + z * z, " << cn << ");\n" @@ -2198,13 +2137,12 @@ public: << "\t\tvOut.y = gamma * sin(alpha);\n" << "\t\tvOut.z = radiusOut * z;\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { - m_AbsN = fabs(m_Power); + m_AbsN = std::abs(m_Power); m_Cn = (m_Dist / m_Power - 1) / 2; } @@ -2212,7 +2150,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Dist, prefix + "julian3Dx_dist", 1)); m_Params.push_back(ParamWithName(&m_Power, prefix + "julian3Dx_power", 2, eParamType::INTEGER_NONZERO)); @@ -2258,7 +2195,6 @@ public: if (helper.In.x > 0 && helper.In.y > 0)//Quadrant IV: spherical. { T r = 1 / helper.m_PrecalcSqrtSumSquares; - helper.Out.x = m_Weight * r * std::cos(helper.m_PrecalcAtanyx); helper.Out.y = m_Weight * r * std::sin(helper.m_PrecalcAtanyx); } @@ -2269,7 +2205,6 @@ public: if (r2 < m_SqrWeight) { T r = m_Weight * std::sqrt(m_SqrWeight / r2 - 1); - helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; } @@ -2288,7 +2223,6 @@ public: if (r < m_Weight) { T a = std::atan2(y, x) + m_Spin + m_Twist * (m_Weight - r); - r *= m_Weight; helper.Out.x = r * std::cos(a) + m_X; helper.Out.y = r * std::sin(a) - m_Y; @@ -2321,62 +2255,60 @@ public: string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sqrWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" - << "\t\tif (vIn.x > 0 && vIn.y > 0)\n" - << "\t\t{\n" - << "\t\t real_t r = 1 / precalcSqrtSumSquares;\n" - << "\n" - << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * r * cos(precalcAtanyx);\n" - << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * r * sin(precalcAtanyx);\n" - << "\t\t}\n" - << "\t\telse if (vIn.x > 0 && vIn.y < 0)\n" - << "\t\t{\n" - << "\t\t real_t r2 = precalcSumSquares;\n" - << "\n" - << "\t\t if (r2 < " << sqrWeight << ")\n" - << "\t\t {\n" - << "\t\t real_t r = xform->m_VariationWeights[" << varIndex << "] * sqrt(" << sqrWeight << " / r2 - 1);\n" - << "\n" - << "\t\t vOut.x = r * vIn.x;\n" - << "\t\t vOut.y = r * vIn.y;\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;\n" - << "\t\t }\n" - << "\t\t}\n" - << "\t\telse if (vIn.x < 0 && vIn.y > 0)\n" - << "\t\t{\n" - << "\t\t real_t x = vIn.x - " << x << ";\n" - << "\t\t real_t y = vIn.y + " << y << ";\n" - << "\t\t real_t r = sqrt(SQR(x) + SQR(y));\n" - << "\n" - << "\t\t if (r < xform->m_VariationWeights[" << varIndex << "])\n" - << "\t\t {\n" - << "\t\t real_t a = atan2(y, x) + " << spin << " + " << twist << " * (xform->m_VariationWeights[" << varIndex << "] - r);\n" - << "\n" - << "\t\t r *= xform->m_VariationWeights[" << varIndex << "];\n" - << "\t\t vOut.x = r * cos(a) + " << x << ";\n" - << "\t\t vOut.y = r * sin(a) - " << y << ";\n" - << "\t\t }\n" - << "\t\t else\n" - << "\t\t {\n" - << "\t\t r = xform->m_VariationWeights[" << varIndex << "] * (1 + " << space << " / Zeps(r));\n" - << "\t\t vOut.x = r * x + " << x << ";\n" - << "\t\t vOut.y = r * y - " << y << ";\n" - << "\t\t }\n" - << "\t\t}\n" - << "\t\telse\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;\n" - << "\t\t}\n" - << "\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" - << "\t}\n"; - + << "\t\tif (vIn.x > 0 && vIn.y > 0)\n" + << "\t\t{\n" + << "\t\t real_t r = 1 / precalcSqrtSumSquares;\n" + << "\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * r * cos(precalcAtanyx);\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * r * sin(precalcAtanyx);\n" + << "\t\t}\n" + << "\t\telse if (vIn.x > 0 && vIn.y < 0)\n" + << "\t\t{\n" + << "\t\t real_t r2 = precalcSumSquares;\n" + << "\n" + << "\t\t if (r2 < " << sqrWeight << ")\n" + << "\t\t {\n" + << "\t\t real_t r = xform->m_VariationWeights[" << varIndex << "] * sqrt(" << sqrWeight << " / r2 - 1);\n" + << "\n" + << "\t\t vOut.x = r * vIn.x;\n" + << "\t\t vOut.y = r * vIn.y;\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;\n" + << "\t\t }\n" + << "\t\t}\n" + << "\t\telse if (vIn.x < 0 && vIn.y > 0)\n" + << "\t\t{\n" + << "\t\t real_t x = vIn.x - " << x << ";\n" + << "\t\t real_t y = vIn.y + " << y << ";\n" + << "\t\t real_t r = sqrt(SQR(x) + SQR(y));\n" + << "\n" + << "\t\t if (r < xform->m_VariationWeights[" << varIndex << "])\n" + << "\t\t {\n" + << "\t\t real_t a = atan2(y, x) + " << spin << " + " << twist << " * (xform->m_VariationWeights[" << varIndex << "] - r);\n" + << "\n" + << "\t\t r *= xform->m_VariationWeights[" << varIndex << "];\n" + << "\t\t vOut.x = r * cos(a) + " << x << ";\n" + << "\t\t vOut.y = r * sin(a) - " << y << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t r = xform->m_VariationWeights[" << varIndex << "] * (1 + " << space << " / Zeps(r));\n" + << "\t\t vOut.x = r * x + " << x << ";\n" + << "\t\t vOut.y = r * y - " << y << ";\n" + << "\t\t }\n" + << "\t\t}\n" + << "\t\telse\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;\n" + << "\t\t}\n" + << "\n" + << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t}\n"; return ss.str(); } @@ -2394,7 +2326,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Spin, prefix + "fourth_spin", T(M_PI), eParamType::REAL_CYCLIC, 0, M_2PI)); m_Params.push_back(ParamWithName(&m_Space, prefix + "fourth_space")); @@ -2448,7 +2379,6 @@ public: const T z3 = m_Bz; const T z4 = m_Cz; const T z5 = m_Dz; - T nt = t1 * t2 - x1 * x2 - y1 * y2 + t3; T nx = t1 * x2 + x1 * t2 - z1 * y2 + x3; T ny = t1 * y2 + y1 * t2 + z1 * x2 + y3; @@ -2458,7 +2388,6 @@ public: T dy = t4 * y2 + y4 * t2 + z4 * x2 + y5; T dz = z4 * t2 + x4 * y2 - y4 * x2 + z5; T ni = m_Weight / (SQR(dt) + SQR(dx) + SQR(dy) + SQR(dz)); - helper.Out.x = (nt * dt + nx * dx + ny * dy + nz * dz) * ni; helper.Out.y = (nx * dt - nt * dx - ny * dz + nz * dy) * ni; helper.Out.z = (ny * dt - nt * dy - nz * dx + nx * dz) * ni; @@ -2486,7 +2415,6 @@ public: string dx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string dy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string dz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tconst real_t t1 = " << at << ";\n" << "\t\tconst real_t t2 = vIn.x;\n" @@ -2522,7 +2450,6 @@ public: << "\t\tvOut.y = (nx * dt - nt * dx - ny * dz + nz * dy) * ni;\n" << "\t\tvOut.z = (ny * dt - nt * dy - nz * dx + nx * dz) * ni;\n" << "\t}\n"; - return ss.str(); } @@ -2530,7 +2457,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_At, prefix + "mobiq_at", 1)); m_Params.push_back(ParamWithName(&m_Ax, prefix + "mobiq_ax")); @@ -2589,7 +2515,6 @@ public: const T phi = std::acos(Clamp(helper.In.z / zr, -1, 1)); const T ps = std::sin(phi); const T pc = std::cos(phi); - helper.Out.x = m_Weight * std::cos(helper.m_PrecalcAtanyx) * ps * (zr + m_Radius); helper.Out.y = m_Weight * std::sin(helper.m_PrecalcAtanyx) * ps * (zr + m_Radius); helper.Out.z = m_Weight * pc * (zr + m_Radius); @@ -2602,7 +2527,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tconst real_t zr = Hypot(vIn.z, precalcSqrtSumSquares);\n" << "\t\tconst real_t phi = acos(clamp(vIn.z / zr, -(real_t)(1.0), (real_t)(1.0)));\n" @@ -2612,8 +2536,7 @@ public: << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cos(precalcAtanyx) * ps * (zr + " << radius << ");\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(precalcAtanyx) * ps * (zr + " << radius << ");\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * pc * (zr + " << radius << ");\n" - << "\t}\n"; - + << "\t}\n"; return ss.str(); } @@ -2626,7 +2549,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Radius, prefix + "spherivoid_radius")); } @@ -2652,16 +2574,15 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T r = m_Weight * (Sqr(helper.In.x - m_XOrigin) + - Sqr(helper.In.y - m_YOrigin) + - Sqr(helper.In.z - m_ZOrigin)) * - (rand.Frand01() + rand.Frand01() + rand.Frand01() + rand.Frand01() - 2); + Sqr(helper.In.y - m_YOrigin) + + Sqr(helper.In.z - m_ZOrigin)) * + (rand.Frand01() + rand.Frand01() + rand.Frand01() + rand.Frand01() - 2); T u = rand.Frand01() * M_2PI; T su = std::sin(u); T cu = std::cos(u); T v = rand.Frand01() * M_2PI; T sv = std::sin(v); T cv = std::cos(v); - helper.Out.x = m_X * r * sv * cu; helper.Out.y = m_Y * r * sv * su; helper.Out.z = m_Z * r * cv; @@ -2679,7 +2600,6 @@ public: string xOrigin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string yOrigin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zOrigin = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (Sqr(vIn.x - " << xOrigin << ") + \n" << "\t\t Sqr(vIn.y - " << yOrigin << ") + \n" @@ -2696,7 +2616,6 @@ public: << "\t\tvOut.y = " << y << " * r * sv * su;\n" << "\t\tvOut.z = " << z << " * r * cv;\n" << "\t}\n"; - return ss.str(); } @@ -2709,7 +2628,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "farblur_x", 1)); m_Params.push_back(ParamWithName(&m_Y, prefix + "farblur_y", 1)); @@ -2752,7 +2670,6 @@ public: const T im = Spread(m_C1 * y + m_C2x2 * x * y, m_Sy); T c = Zeps(Powq4c(SQR(re) + SQR(im), m_PowerInv)); const T r = m_Weight / c; - helper.Out.x = (x * re + y * im) * r; helper.Out.y = (y * re - x * im) * r; helper.Out.z = (z * m_Weight) / c; @@ -2774,7 +2691,6 @@ public: string c2x2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string dcAdjust = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string powerInv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tconst real_t x = Powq4c(vIn.x, " << power << ");\n" << "\t\tconst real_t y = Powq4c(vIn.y, " << power << ");\n" @@ -2791,7 +2707,6 @@ public: << "\t\tvOut.z = (z * xform->m_VariationWeights[" << varIndex << "]) / c;\n" << "\t\toutPoint->m_ColorX = clamp(outPoint->m_ColorX + " << dcAdjust << " * c, (real_t)(0.0), (real_t)(1.0));\n" << "\t}\n"; - return ss.str(); } @@ -2812,7 +2727,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Power, prefix + "curl_sp_pow", 1, eParamType::REAL_NONZERO)); m_Params.push_back(ParamWithName(&m_C1, prefix + "curl_sp_c1")); @@ -2853,8 +2767,7 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T r = std::sqrt(fabs(helper.m_PrecalcSumSquares + helper.In.z)); - + T r = std::sqrt(std::abs(helper.m_PrecalcSumSquares + helper.In.z)); r += m_Ar * std::sin(fma(m_Br, r, m_Cr)); if (r == 0) @@ -2863,12 +2776,9 @@ public: T temp = fma(m_At, std::sin(fma(m_Bt, r, m_Ct)), helper.m_PrecalcAtanyx); T st = std::sin(temp); T ct = std::cos(temp); - temp = fma(m_Ap, std::sin(fma(m_Bp, r, m_Cp)), std::acos(Clamp(helper.In.z / r, -1, 1))); - T sp = std::sin(temp); T cp = std::cos(temp); - helper.Out.x = r * ct * sp; helper.Out.y = r * st * sp; helper.Out.z = r * cp; @@ -2898,7 +2808,6 @@ public: string ar = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string br = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = sqrt(fabs(precalcSumSquares + vIn.z));\n" << "\n" @@ -2920,7 +2829,6 @@ public: << "\t\tvOut.y = r * st * sp;\n" << "\t\tvOut.z = r * cp;\n" << "\t}\n"; - return ss.str(); } @@ -2929,7 +2837,6 @@ public: T tx = m_ThetaPeriod == 0 ? 0 : (1 / m_ThetaPeriod); T px = m_PhiPeriod == 0 ? 0 : (1 / m_PhiPeriod); T rx = m_Rperiod == 0 ? 0 : (1 / m_Rperiod); - m_At = m_Weight * m_ThetaAmp; m_Bt = M_2PI * tx; m_Ct = m_ThetaPhase * tx; @@ -2945,7 +2852,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_ThetaPeriod, prefix + "heat_theta_period", 1)); m_Params.push_back(ParamWithName(&m_ThetaPhase, prefix + "heat_theta_phase")); @@ -3015,14 +2921,17 @@ public: fp1x = Sine(m_A1, m_B1, m_C1, m_P1, helper.In.x); fp1y = Sine(m_A1, m_B1, m_C1, m_P1, helper.In.y); break; + case 1: fp1x = Tri(m_A1, m_B1, m_C1, m_P1, helper.In.x); fp1y = Tri(m_A1, m_B1, m_C1, m_P1, helper.In.y); break; + case 2: fp1x = Squ(m_A1, m_B1, m_C1, m_P1, helper.In.x); fp1y = Squ(m_A1, m_B1, m_C1, m_P1, helper.In.y); break; + default: fp1x = Sine(m_A1, m_B1, m_C1, m_P1, helper.In.x); fp1y = Sine(m_A1, m_B1, m_C1, m_P1, helper.In.y); @@ -3035,14 +2944,17 @@ public: fp2x = Sine(m_A2, m_B2, m_C2, m_P2, helper.In.x); fp2y = Sine(m_A2, m_B2, m_C2, m_P2, helper.In.y); break; + case 1: fp2x = Tri(m_A2, m_B2, m_C2, m_P2, helper.In.x); fp2y = Tri(m_A2, m_B2, m_C2, m_P2, helper.In.y); break; + case 2: fp2x = Squ(m_A2, m_B2, m_C2, m_P2, helper.In.x); fp2y = Squ(m_A2, m_B2, m_C2, m_P2, helper.In.y); break; + default: fp2x = Sine(m_A2, m_B2, m_C2, m_P2, helper.In.x); fp2y = Sine(m_A2, m_B2, m_C2, m_P2, helper.In.y); @@ -3070,7 +2982,6 @@ public: string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string p2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string t2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t fp1x;\n" << "\t\treal_t fp1y;\n" @@ -3121,7 +3032,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (fp1y + fp2y);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -3149,7 +3059,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_A1, prefix + "interference2_a1", 1));//Original used a prefix of intrfr2_, which is incompatible with Ember's design. m_Params.push_back(ParamWithName(&m_B1, prefix + "interference2_b1", 1)); @@ -3166,12 +3075,12 @@ protected: private: inline static T Sine(T a, T b, T c, T p, T x) { - return a * std::pow(std::fabs(std::sin(b * x + c)), p);//Original did not fabs(). + return a * std::pow(std::abs(std::sin(b * x + c)), p);//Original did not fabs(). } inline static T Tri(T a, T b, T c, T p, T x) { - return a * 2 * std::pow(std::fabs(std::asin(std::cos(b * x + c - T(M_PI_2)))) * T(M_1_PI), p);//Original did not fabs(). + return a * 2 * std::pow(std::abs(std::asin(std::cos(b * x + c - T(M_PI_2)))) * T(M_1_PI), p);//Original did not fabs(). } inline static T Squ(T a, T b, T c, T p, T x) @@ -3210,7 +3119,6 @@ public: T sh = std::sinh(absV); T ch = std::cosh(absV); T d = m_Weight * c * sh / absV; - helper.Out.x = m_Weight * s * ch; helper.Out.y = d * helper.In.y; helper.Out.z = d * helper.In.z; @@ -3220,7 +3128,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t s = sin(vIn.x);\n" @@ -3233,7 +3140,6 @@ public: << "\t\tvOut.y = d * vIn.y;\n" << "\t\tvOut.z = d * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3262,7 +3168,6 @@ public: T sh = std::sinh(helper.In.x); T ch = std::cosh(helper.In.x); T d = m_Weight * ch * s / absV; - helper.Out.x = m_Weight * sh * c; helper.Out.y = d * helper.In.y; helper.Out.z = d * helper.In.z; @@ -3272,7 +3177,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t s = sin(absV);\n" @@ -3285,7 +3189,6 @@ public: << "\t\tvOut.y = d * vIn.y;\n" << "\t\tvOut.z = d * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3315,7 +3218,6 @@ public: T sh = std::sinh(absV); T ch = std::cosh(absV); T d = ni * s * sh / absV; - helper.Out.x = c * ch * ni; helper.Out.y = -(d * helper.In.y); helper.Out.z = -(d * helper.In.z); @@ -3325,7 +3227,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t ni = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + SQR(vIn.z));\n" @@ -3339,7 +3240,6 @@ public: << "\t\tvOut.y = -(d * vIn.y);\n" << "\t\tvOut.z = -(d * vIn.z);\n" << "\t}\n"; - return ss.str(); } @@ -3369,7 +3269,6 @@ public: T sh = std::sinh(helper.In.x); T ch = std::cosh(helper.In.x); T d = ni * sh * s / absV; - helper.Out.x = ch * c * ni; helper.Out.y = -(d * helper.In.y); helper.Out.z = -(d * helper.In.z); @@ -3379,7 +3278,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t ni = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + SQR(vIn.z));\n" @@ -3393,7 +3291,6 @@ public: << "\t\tvOut.y = -(d * vIn.y);\n" << "\t\tvOut.z = -(d * vIn.z);\n" << "\t}\n"; - return ss.str(); } @@ -3428,7 +3325,6 @@ public: T stcv = s * ch; T nstcv = -stcv; T ctcv = c * ch; - helper.Out.x = (stcv * ctcv + d * b * sysz) * ni; helper.Out.y = (nstcv * b * helper.In.y + d * helper.In.y * ctcv) * ni; helper.Out.z = (nstcv * b * helper.In.z + d * helper.In.z * ctcv) * ni; @@ -3438,7 +3334,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" << "\t\treal_t absV = sqrt(sysz);\n" @@ -3457,7 +3352,6 @@ public: << "\t\tvOut.y = (nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" << "\t\tvOut.z = (nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" << "\t}\n"; - return ss.str(); } }; @@ -3487,7 +3381,6 @@ public: T stcv = sh * c; T nstcv = -stcv; T ctcv = c * ch; - helper.Out.x = (stcv * ctcv + d * b * sysz) * ni; helper.Out.y = (nstcv * b * helper.In.y + d * helper.In.y * ctcv) * ni; helper.Out.z = (nstcv * b * helper.In.z + d * helper.In.z * ctcv) * ni; @@ -3497,7 +3390,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" << "\t\treal_t absV = sqrt(sysz);\n" @@ -3516,7 +3408,6 @@ public: << "\t\tvOut.y = (nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" << "\t\tvOut.z = (nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" << "\t}\n"; - return ss.str(); } }; @@ -3540,7 +3431,6 @@ public: T sh = std::sinh(absV); T ch = std::cosh(absV); T d = -m_Weight * s * sh / absV; - helper.Out.x = m_Weight * c * ch; helper.Out.y = d * helper.In.y; helper.Out.z = d * helper.In.z; @@ -3550,7 +3440,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t s = sin(vIn.x);\n" @@ -3563,7 +3452,6 @@ public: << "\t\tvOut.y = d * vIn.y;\n" << "\t\tvOut.z = d * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3592,7 +3480,6 @@ public: T sh = std::sinh(helper.In.x); T ch = std::cosh(helper.In.x); T d = -m_Weight * sh * s / absV; - helper.Out.x = m_Weight * c * ch; helper.Out.y = d * helper.In.y; helper.Out.z = d * helper.In.z; @@ -3602,7 +3489,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t s = sin(absV);\n" @@ -3615,7 +3501,6 @@ public: << "\t\tvOut.y = d * vIn.y;\n" << "\t\tvOut.z = d * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3650,7 +3535,6 @@ public: T stcv = s * ch; T nstcv = -stcv; T ctcv = c * ch; - helper.Out.x = (stcv * ctcv + d * b * sysz) * ni; helper.Out.y = -(nstcv * b * helper.In.y + d * helper.In.y * ctcv) * ni; helper.Out.z = -(nstcv * b * helper.In.z + d * helper.In.z * ctcv) * ni; @@ -3660,7 +3544,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" << "\t\treal_t absV = sqrt(sysz);\n" @@ -3679,7 +3562,6 @@ public: << "\t\tvOut.y = -(nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" << "\t\tvOut.z = -(nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" << "\t}\n"; - return ss.str(); } }; @@ -3709,7 +3591,6 @@ public: T stcv = sh * c; T nstcv = -stcv; T ctcv = ch * c; - helper.Out.x = (stcv * ctcv + d * b * sysz) * ni; helper.Out.y = -(nstcv * b * helper.In.y + d * helper.In.y * ctcv) * ni; helper.Out.z = -(nstcv * b * helper.In.z + d * helper.In.z * ctcv) * ni; @@ -3719,7 +3600,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n" << "\t\treal_t absV = sqrt(sysz);\n" @@ -3738,7 +3618,6 @@ public: << "\t\tvOut.y = -(nstcv * b * vIn.y + d * vIn.y * ctcv) * ni;\n" << "\t\tvOut.z = -(nstcv * b * vIn.z + d * vIn.z * ctcv) * ni;\n" << "\t}\n"; - return ss.str(); } }; @@ -3763,7 +3642,6 @@ public: T sh = std::sinh(absV); T ch = std::cosh(absV); T d = ni * c * sh / absV; - helper.Out.x = s * ch * ni; helper.Out.y = -(d * helper.In.y); helper.Out.z = -(d * helper.In.z); @@ -3773,7 +3651,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t ni = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + SQR(vIn.z));\n" @@ -3787,7 +3664,6 @@ public: << "\t\tvOut.y = -(d * vIn.y);\n" << "\t\tvOut.z = -(d * vIn.z);\n" << "\t}\n"; - return ss.str(); } @@ -3817,7 +3693,6 @@ public: T sh = std::sinh(helper.In.x); T ch = std::cosh(helper.In.x); T d = ni * ch * s / absV; - helper.Out.x = sh * c * ni; helper.Out.y = -(d * helper.In.y); helper.Out.z = -(d * helper.In.z); @@ -3827,7 +3702,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t ni = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + SQR(vIn.z));\n" @@ -3841,7 +3715,6 @@ public: << "\t\tvOut.y = -(d * vIn.y);\n" << "\t\tvOut.z = -(d * vIn.z);\n" << "\t}\n"; - return ss.str(); } @@ -3869,7 +3742,6 @@ public: T s = std::sin(absV); T c = std::cos(absV); T a = e * s / absV; - helper.Out.x = m_Weight * e * c; helper.Out.y = m_Weight * a * helper.In.y; helper.Out.z = m_Weight * a * helper.In.z; @@ -3879,7 +3751,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t e = exp(vIn.x);\n" @@ -3891,7 +3762,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * a * vIn.y;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * a * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -3919,7 +3789,6 @@ public: { T absV = Hypot(helper.In.y, helper.In.z); T c = m_Weight * std::atan2(absV, helper.In.x) / absV; - helper.Out.x = std::log(SQR(helper.In.x) + SQR(absV)) * m_Denom; helper.Out.y = c * helper.In.y; helper.Out.z = c * helper.In.z; @@ -3933,7 +3802,6 @@ public: string index = ss2.str(); string base = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string denom = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n" << "\t\treal_t c = xform->m_VariationWeights[" << varIndex << "] * atan2(absV, vIn.x) / absV;\n" @@ -3942,10 +3810,9 @@ public: << "\t\tvOut.y = c * vIn.y;\n" << "\t\tvOut.z = c * vIn.z;\n" << "\t}\n"; - return ss.str(); } - + virtual vector OpenCLGlobalFuncNames() const override { return vector { "Hypot" }; @@ -3960,7 +3827,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Base, prefix + "loq_base", T(M_E), eParamType::REAL, EPS, TMAX)); m_Params.push_back(ParamWithName(true, &m_Denom, prefix + "loq_denom"));//Precalc. @@ -3993,13 +3859,11 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSqrtSumSquares);\n" << "\t\tvOut.y = precalcAtanyx;\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -4028,7 +3892,6 @@ public: T sqx = SQR(helper.In.x); T sqy = SQR(helper.In.y); T xy = helper.In.x * helper.In.y; - helper.Out.x = (m_Q01 + m_Weight * m_Q02 * helper.In.x + m_Q03 * sqx) + (m_Q04 * xy + m_Q05 * helper.In.y + m_Q06 * sqy); helper.Out.y = (m_Q07 + m_Q08 * helper.In.x + m_Q09 * sqx) + @@ -4054,7 +3917,6 @@ public: string q10 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string q11 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string q12 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t sqx = SQR(vIn.x);\n" << "\t\treal_t sqy = SQR(vIn.y);\n" @@ -4066,7 +3928,6 @@ public: << "\t\t (" << q10 << " * xy + xform->m_VariationWeights[" << varIndex << "] * " << q11 << " * vIn.y + " << q12 << " * sqy);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -4074,7 +3935,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Q01, prefix + "q_ode01", 1)); m_Params.push_back(ParamWithName(&m_Q02, prefix + "q_ode02", -1)); @@ -4124,10 +3984,9 @@ public: T xx = (rand.Frand01() - T(0.5)) * 2; T yy = (rand.Frand01() - T(0.5)) * 2; T k = SignNz(yy); - T yymax = ((m_A * std::pow(fabs(xx), m_P) + k * m_B * std::sqrt(fabs(1 - SQR(xx)))) - m_A); - + T yymax = ((m_A * std::pow(std::abs(xx), m_P) + k * m_B * std::sqrt(std::abs(1 - SQR(xx)))) - m_A); //The function must be in a range 0-1 to work properly. - yymax /= Zeps(fabs(m_A) + fabs(m_B)); + yymax /= Zeps(std::abs(m_A) + std::abs(m_B)); //Quick and dirty way to force y to be in range without altering the density. if (k > 0) @@ -4155,7 +4014,6 @@ public: string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t xx = (MwcNext01(mwc) - (real_t)(0.5)) * 2;\n" << "\t\treal_t yy = (MwcNext01(mwc) - (real_t)(0.5)) * 2;\n" @@ -4179,7 +4037,6 @@ public: << "\t\tvOut.y = yy * xform->m_VariationWeights[" << varIndex << "];\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -4192,7 +4049,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_P, prefix + "blur_heart_p", T(0.5))); m_Params.push_back(ParamWithName(&m_A, prefix + "blur_heart_a", T(-T(0.6)))); @@ -4237,7 +4093,6 @@ public: int intx = int(Round(x)); int inty = int(Round(y)); int randiter; - r = x - intx; if (r < 0) @@ -4263,10 +4118,9 @@ public: { T xrand = Round(helper.In.x); T yrand = Round(helper.In.y); - xrand = xrand * m_Seed2; yrand = yrand * m_Seed2; - niter = xrand + yrand + xrand*yrand; + niter = xrand + yrand + xrand * yrand; randInt = (niter + seed) * m_Seed2 / 2; randInt = fmod((randInt * multiplier + offset), modBase); } @@ -4274,7 +4128,6 @@ public: { int xrand = int(Round(helper.In.x)); int yrand = int(Round(helper.In.y)); - seed = T(Floor(seed)); niter = T(abs(xrand + yrand + xrand * yrand)); randInt = seed + niter; @@ -4295,30 +4148,30 @@ public: { if (tileType < 1) { - r0 = std::pow((pow(fabs(x ), m_Exponent) + std::pow(fabs(y ), m_Exponent)), m_OneOverEx); - r1 = std::pow((pow(fabs(x - 1), m_Exponent) + std::pow(fabs(y - 1), m_Exponent)), m_OneOverEx); + r0 = std::pow((pow(std::abs(x), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); + r1 = std::pow((pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); } else { - r0 = std::pow((pow(fabs(x - 1), m_Exponent) + std::pow(fabs(y ), m_Exponent)), m_OneOverEx); - r1 = std::pow((pow(fabs(x ), m_Exponent) + std::pow(fabs(y - 1), m_Exponent)), m_OneOverEx); + r0 = std::pow((pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); + r1 = std::pow((pow(std::abs(x), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); } } else//Slow drawmode { if (tileType == 1) { - r0 = std::pow((std::pow(fabs(x ), m_Exponent) + std::pow(fabs(y ), m_Exponent)), m_OneOverEx); - r1 = std::pow((std::pow(fabs(x - 1), m_Exponent) + std::pow(fabs(y - 1), m_Exponent)), m_OneOverEx); + r0 = std::pow((std::pow(std::abs(x), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); + r1 = std::pow((std::pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); } else { - r0 = std::pow((std::pow(fabs(x - 1), m_Exponent) + std::pow(fabs(y ), m_Exponent)), m_OneOverEx); - r1 = std::pow((std::pow(fabs(x ), m_Exponent) + std::pow(fabs(y - 1), m_Exponent)), m_OneOverEx); + r0 = std::pow((std::pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); + r1 = std::pow((std::pow(std::abs(x), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); } } - r = fabs(r0 - T(0.5)) * m_OneOverRmax; + r = std::abs(r0 - T(0.5)) * m_OneOverRmax; if (r < 1) { @@ -4331,7 +4184,7 @@ public: helper.Out.y = 0; } - r = fabs(r1 - T(0.5)) * m_OneOverRmax; + r = std::abs(r1 - T(0.5)) * m_OneOverRmax; if (r < 1) { @@ -4359,7 +4212,6 @@ public: string seed2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string oneOverRmax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint extended = (int)" << extended << ";\n" << "\t\treal_t seed = " << absSeed << ";\n" @@ -4479,7 +4331,6 @@ public: << "\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -4491,7 +4342,7 @@ public: virtual void Precalc() override { m_OneOverEx = 1 / m_Exponent; - m_AbsSeed = fabs(m_Seed); + m_AbsSeed = std::abs(m_Seed); m_Seed2 = std::sqrt(Zeps(m_AbsSeed + (m_AbsSeed / 2))) / Zeps((m_AbsSeed * T(0.5))) * T(0.25); m_OneOverRmax = 1 / (T(0.5) * (std::pow(T(2), 1 / m_Exponent) - 1) * m_ArcWidth); m_Scale = (std::cos(-m_Rotation) - std::sin(-m_Rotation)) / m_Weight; @@ -4501,7 +4352,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Extended, prefix + "Truchet_extended", 0, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName(&m_Exponent, prefix + "Truchet_exponent", 2, eParamType::REAL_CYCLIC, T(0.001), 2)); @@ -4590,7 +4440,6 @@ public: string ay = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t oscX = GdoffsFosc(" << dx << ", 1);\n" << "\t\treal_t oscY = GdoffsFosc(" << dy << ", 1);\n" @@ -4614,7 +4463,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * outY;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -4634,11 +4482,10 @@ public: const T agdod = T(0.1); const T agdoa = 2; const T agdoc = 1; - m_Dx = m_DeltaX * agdod; m_Dy = m_DeltaY * agdod; - m_Ax = ((fabs(m_AreaX) < 0.1) ? T(0.1) : fabs(m_AreaX)) * agdoa; - m_Ay = ((fabs(m_AreaY) < 0.1) ? T(0.1) : fabs(m_AreaY)) * agdoa; + m_Ax = ((std::abs(m_AreaX) < 0.1) ? T(0.1) : std::abs(m_AreaX)) * agdoa; + m_Ay = ((std::abs(m_AreaY) < 0.1) ? T(0.1) : std::abs(m_AreaY)) * agdoa; m_Cx = m_CenterX * agdoc; m_Cy = m_CenterY * agdoc; m_B = m_Gamma * agdoa / (std::max(m_Ax, m_Ay)); @@ -4648,7 +4495,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_DeltaX, prefix + "gdoffs_delta_x", 0, eParamType::REAL, 0, 16)); m_Params.push_back(ParamWithName(&m_DeltaY, prefix + "gdoffs_delta_y", 0, eParamType::REAL, 0, 16)); @@ -4668,8 +4514,8 @@ protected: } private: - static inline T GdoffsFcip(T a) { return T((a < 0) ? -(int(fabs(a)) + 1) : 0) + ((a > 1) ? (int(a)) : 0); } - static inline T GdoffsFclp(T a) { return ((a < 0) ? -(fmod(fabs(a), T(1))) : fmod(fabs(a), T(1))); } + static inline T GdoffsFcip(T a) { return T((a < 0) ? -(int(std::abs(a)) + 1) : 0) + ((a > 1) ? (int(a)) : 0); } + static inline T GdoffsFclp(T a) { return ((a < 0) ? -(fmod(std::abs(a), T(1))) : fmod(std::abs(a), T(1))); } static inline T GdoffsFscl(T a) { return GdoffsFclp((a + 1) / 2); } static inline T GdoffsFosc(T p, T a) { return GdoffsFscl(-1 * std::cos(p * a * M_2PI)); } static inline T GdoffsFlip(T a, T b, T c) { return (c * (b - a) + a); } @@ -4720,7 +4566,6 @@ public: helper.Out.x = m_Weight * helper.In.x; helper.Out.y = m_Weight * helper.In.y; helper.Out.z = m_Weight * helper.In.z; - T t = m_Weight / Zeps((std::sqrt(SQR(helper.In.x)) + std::sqrt(helper.In.z) + std::sqrt(SQR(helper.In.y)) + std::sqrt(helper.In.z))); if (r >= 0) @@ -4762,7 +4607,6 @@ public: string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps((SQR(SQR(vIn.x)) + SQR(vIn.z) + SQR(SQR(vIn.y)) + SQR(vIn.z)));\n" << "\n" @@ -4809,7 +4653,6 @@ public: << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * (vIn.z - " << z << ");\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } @@ -4822,7 +4665,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "octagon_x"));//Original used a prefix of octa_, which is incompatible with Ember's design. m_Params.push_back(ParamWithName(&m_Y, prefix + "octagon_y")); @@ -4862,7 +4704,6 @@ public: { r *= m_R2 / m_R1; temp = atan2(helper.In.y, c1mx); - helper.Out.x = m_Weight * (r * std::cos(temp) - m_C2); helper.Out.y = m_Weight * r * std::sin(temp); } @@ -4881,7 +4722,6 @@ public: { r *= m_R1 / m_R2; temp = atan2(helper.In.y, c1mx); - helper.Out.x = m_Weight * (r * std::cos(temp) + m_C1); helper.Out.y = m_Weight * r * std::sin(temp); } @@ -4907,7 +4747,6 @@ public: string d2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r, temp, c1mx;\n" << "\n" @@ -4952,7 +4791,6 @@ public: << "\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -4966,7 +4804,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_R1, prefix + "trade_r1", 1, eParamType::REAL, EPS, TMAX)); m_Params.push_back(ParamWithName(&m_D1, prefix + "trade_d1", 1, eParamType::REAL, 0, TMAX)); @@ -5005,7 +4842,6 @@ public: T lnmod = m_Dist * T(0.5) * std::log(helper.m_PrecalcSumSquares); T temp = arg * m_ReInv + lnmod * m_Im100; T mod2 = std::exp(lnmod * m_ReInv - arg * m_Im100); - helper.Out.x = m_Weight * mod2 * std::cos(temp); helper.Out.y = m_Weight * mod2 * std::sin(temp); helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; @@ -5022,7 +4858,6 @@ public: string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string reInv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string im100 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t arg = precalcAtanyx + fmod((real_t)MwcNext(mwc), (real_t)(1 / " << reInv << ")) * M_2PI;\n" << "\t\treal_t lnmod = " << dist << " * (real_t)(0.5) * log(precalcSumSquares);\n" @@ -5033,7 +4868,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * mod2 * sin(temp);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -5047,7 +4881,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Re, prefix + "Juliac_re", 2)); m_Params.push_back(ParamWithName(&m_Im, prefix + "Juliac_im", 1)); @@ -5079,7 +4912,6 @@ public: { T r = rand.Frand01() * m_Weight * helper.m_PrecalcSqrtSumSquares; T sinr, cosr; - sincos(r, &sinr, &cosr); helper.Out.x = m_Weight * helper.In.x * (cosr + sinr); helper.Out.y = m_Weight * helper.In.x * (cosr - sinr); @@ -5090,7 +4922,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t r = MwcNext01(mwc) * xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n" << "\t\treal_t sinr = sin(r);\n" @@ -5100,7 +4931,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (cosr - sinr);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z * (sinr - cosr);\n" << "\t}\n"; - return ss.str(); } }; @@ -5122,7 +4952,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T r = helper.m_PrecalcSqrtSumSquares * (m_BlobLow + m_BlobDiff * (T(0.5) + T(0.5) * std::sin(m_BlobWaves * helper.m_PrecalcAtanxy))); - helper.Out.x = m_Weight * helper.m_PrecalcSina * r; helper.Out.y = m_Weight * helper.m_PrecalcCosa * r; helper.Out.z = m_Weight * std::sin(m_BlobWaves * helper.m_PrecalcAtanxy) * r; @@ -5138,7 +4967,6 @@ public: string blobHigh = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blobWaves = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blobDiff = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = precalcSqrtSumSquares * (" << blobLow << " + " << blobDiff << " * ((real_t)(0.5) + (real_t)(0.5) * sin(" << blobWaves << " * precalcAtanxy)));\n" << "\n" @@ -5146,7 +4974,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (precalcCosa * r);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (sin(" << blobWaves << " * precalcAtanxy) * r);\n" << "\t}\n"; - return ss.str(); } @@ -5166,7 +4993,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_BlobLow, prefix + "blob3D_low")); m_Params.push_back(ParamWithName(&m_BlobHigh, prefix + "blob3D_high", 1)); @@ -5206,12 +5032,9 @@ public: T ymax = T(0.5) * (std::sqrt(tmp + y2) + std::sqrt(tmp - y2)); T a = helper.In.x / Zeps(xmax); T b = SafeSqrt(1 - SQR(a)); - helper.Out.x = m_Vx * atan2(a, b) * r; - a = helper.In.y / Zeps(ymax); b = SafeSqrt(1 - SQR(a)); - helper.Out.y = m_Vy * atan2(a, b) * r; helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; } @@ -5228,7 +5051,6 @@ public: string v = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t t = Zeps((cos(vIn.x) + cos(vIn.y)) / " << mp << " + 1);\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / t;\n" @@ -5248,7 +5070,6 @@ public: << "\t\tvOut.y = " << vy << " * atan2(a, b) * r;\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -5268,7 +5089,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "blocky_x", 1)); m_Params.push_back(ParamWithName(&m_Y, prefix + "blocky_y", 1)); diff --git a/Source/Ember/Variations05.h b/Source/Ember/Variations05.h index 88ca26d..7ab5142 100644 --- a/Source/Ember/Variations05.h +++ b/Source/Ember/Variations05.h @@ -22,7 +22,6 @@ public: { T t = T(0.25) * (helper.m_PrecalcSumSquares + SQR(helper.In.z)) + 1; T r = m_Weight / t; - helper.Out.x = helper.In.x * r * m_X; helper.Out.y = helper.In.y * r * m_Y; @@ -43,7 +42,6 @@ public: string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t t = (real_t)(0.25) * (precalcSumSquares + SQR(vIn.z)) + 1;\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / t;\n" @@ -58,7 +56,6 @@ public: << "\n" << "\t\tvOut.z += vIn.z * r * " << z << ";\n" << "\t}\n"; - return ss.str(); } @@ -66,7 +63,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "bubble2_x", 1));//Original used a prefix of bubble_, which is incompatible with Ember's design. m_Params.push_back(ParamWithName(&m_Y, prefix + "bubble2_y", 1)); @@ -115,7 +111,6 @@ public: else { T z = v / u * (1 - m_K) + m_K; - x *= z; y *= z; } @@ -130,7 +125,6 @@ public: else { T z = v / u * (1 - m_K) + m_K; - x *= z; y *= z; } @@ -156,7 +150,6 @@ public: string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint m = (int)floor((real_t)(0.5) * vIn.x / " << sc << ");\n" << "\t\tint n = (int)floor((real_t)(0.5) * vIn.y / " << sc << ");\n" @@ -204,7 +197,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (y + (n * 2 + 1) * " << sc << ");\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -232,7 +224,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Sc, prefix + "CircleLinear_Sc", 1, eParamType::REAL_NONZERO)); m_Params.push_back(ParamWithName(&m_K, prefix + "CircleLinear_K", T(0.5))); @@ -249,7 +240,6 @@ private: { const T im = T(2147483647); const T am = (1 / im); - int n = x + y * 57; n = (n << 13) ^ n; return ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) * am; @@ -316,7 +306,6 @@ public: string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint m, n, iters = 0;\n" << "\t\treal_t x, y, u;\n" @@ -340,7 +329,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (y + (n * 2 + 1) * " << sc << ");\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -368,7 +356,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Sc, prefix + "CircleRand_Sc", 1, eParamType::REAL_NONZERO)); m_Params.push_back(ParamWithName(&m_Dens, prefix + "CircleRand_Dens", T(0.5))); @@ -382,7 +369,6 @@ private: { const T im = T(2147483647); const T am = (1 / im); - int n = x + y * 57; n = (n << 13) ^ n; return ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) * am; @@ -413,12 +399,9 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T ux, uy, u, x, y; - Trans(m_X, m_Y, helper.In.x, helper.In.y, &ux, &uy); - intmax_t m = Floor(T(0.5) * ux / m_Sc); intmax_t n = Floor(T(0.5) * uy / m_Sc); - x = ux - (m * 2 + 1) * m_Sc; y = uy - (n * 2 + 1) * m_Sc; u = Hypot(x, y); @@ -449,7 +432,6 @@ public: string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t ux, uy, u, x, y;\n" << "\n" @@ -476,7 +458,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * uy;\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -535,7 +516,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Sc, prefix + "CircleTrans1_Sc", 1, eParamType::REAL_NONZERO)); m_Params.push_back(ParamWithName(&m_Dens, prefix + "CircleTrans1_Dens", T(0.5))); @@ -549,7 +529,6 @@ private: { const T im = T(2147483647); const T am = (1 / im); - int n = x + y * 57; n = (n << 13) ^ n; return ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) * am; @@ -568,8 +547,8 @@ private: do { - x = fabs(m_X) * (1 - 2 * rand.Frand01()); - y = fabs(m_Y) * (1 - 2 * rand.Frand01()); + x = std::abs(m_X) * (1 - 2 * rand.Frand01()); + y = std::abs(m_Y) * (1 - 2 * rand.Frand01()); m = Floor(T(0.5) * x / m_Sc); n = Floor(T(0.5) * y / m_Sc); alpha = M_2PI * rand.Frand01(); @@ -613,7 +592,6 @@ public: T exnze, wynze, znxy; T lattd = m_Weight * T(0.5); T px, py, pz; - exnze = 1 - (m_SmoothStyle * (1 - (std::cos(std::atan2(helper.In.x, helper.In.z))))); wynze = 1 - (m_SmoothStyle * (1 - (std::sin(std::atan2(helper.In.y, helper.In.z))))); @@ -642,36 +620,43 @@ public: helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) + lattd; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) + lattd; break; + case 1 : helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) + lattd; helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) - lattd; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) + lattd; break; + case 2 : helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) + lattd; helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) + lattd; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) - lattd; break; + case 3 : helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) + lattd; helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) - lattd; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) - lattd; break; + case 4 : helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) - lattd; helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) + lattd; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) + lattd; break; + case 5 : helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) - lattd; helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) - lattd; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) + lattd; break; + case 6 : helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) - lattd; helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) + lattd; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) - lattd; break; + case 7 : default: helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) - lattd; @@ -692,7 +677,6 @@ public: string fill = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string smooth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string smoothStyle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint useNode = MwcNext(mwc) & 7;\n" << "\t\treal_t exnze, wynze, znxy;\n" @@ -710,80 +694,79 @@ public: if (m_VarType == eVariationType::VARTYPE_PRE) { ss << - "\t\tpx = vIn.x;\n" - "\t\tpy = vIn.y;\n" - "\t\tpz = vIn.z;\n"; + "\t\tpx = vIn.x;\n" + "\t\tpy = vIn.y;\n" + "\t\tpz = vIn.z;\n"; } else { ss << - "\t\tpx = outPoint->m_X;\n" - "\t\tpy = outPoint->m_Y;\n" - "\t\tpz = outPoint->m_Z;\n"; + "\t\tpx = outPoint->m_X;\n" + "\t\tpy = outPoint->m_Y;\n" + "\t\tpz = outPoint->m_Z;\n"; } ss << - "\t\tswitch (useNode)\n" - "\t\t{\n" - "\t\t case 0 :\n" - "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" - "\t\t break;\n" - "\t\t case 1 :\n" - "\t\t vOut.x = ((px - (" << smooth << " *(1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " *(1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " *(1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" - "\t\t break;\n" - "\t\t case 2 :\n" - "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" - "\t\t break;\n" - "\t\t case 3 :\n" - "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" - "\t\t break;\n" - "\t\t case 4 :\n" - "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" - "\t\t break;\n" - "\t\t case 5 :\n" - "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" - "\t\t break;\n" - "\t\t case 6 :\n" - "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" - "\t\t break;\n" - "\t\t case 7 :\n" - "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" - "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" - "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" - "\t\t break;\n" - "\t\t}\n" - "\t}\n"; - + "\t\tswitch (useNode)\n" + "\t\t{\n" + "\t\t case 0 :\n" + "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" + "\t\t break;\n" + "\t\t case 1 :\n" + "\t\t vOut.x = ((px - (" << smooth << " *(1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " *(1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " *(1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" + "\t\t break;\n" + "\t\t case 2 :\n" + "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" + "\t\t break;\n" + "\t\t case 3 :\n" + "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) + lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" + "\t\t break;\n" + "\t\t case 4 :\n" + "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" + "\t\t break;\n" + "\t\t case 5 :\n" + "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) + lattd;\n" + "\t\t break;\n" + "\t\t case 6 :\n" + "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) + lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" + "\t\t break;\n" + "\t\t case 7 :\n" + "\t\t vOut.x = ((px - (" << smooth << " * (1 - " << fill << ") * px * exnze)) + (vIn.x * " << smooth << " * " << fill << " * exnze)) - lattd;\n" + "\t\t vOut.y = ((py - (" << smooth << " * (1 - " << fill << ") * py * wynze)) + (vIn.y * " << smooth << " * " << fill << " * wynze)) - lattd;\n" + "\t\t vOut.z = ((pz - (" << smooth << " * (1 - " << fill << ") * pz * znxy)) + (vIn.z * " << smooth << " * " << fill << " * znxy)) - lattd;\n" + "\t\t break;\n" + "\t\t}\n" + "\t}\n"; return ss.str(); } virtual void Precalc() override { - if (fabs(m_Xpand) <= 1) + if (std::abs(m_Xpand) <= 1) m_Fill = m_Xpand * T(0.5); else m_Fill = std::sqrt(m_Xpand) * T(0.5); - if (fabs(m_Weight) <= T(0.5)) + if (std::abs(m_Weight) <= T(0.5)) m_Smooth = m_Weight * 2;//Causes full effect above m_Weight = 0.5. else m_Smooth = 1; - if (fabs(m_Style) <= 1) + if (std::abs(m_Style) <= 1) { m_SmoothStyle = m_Style; } @@ -800,7 +783,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Xpand, prefix + "cubic3D_xpand", T(0.25))); m_Params.push_back(ParamWithName(&m_Style, prefix + "cubic3D_style")); @@ -873,36 +855,43 @@ public: helper.Out.y = pyty * m_Fill * wynze + lattd; helper.Out.z = pztz * m_Fill * znxy + lattd; break; + case 1 : helper.Out.x = pxtx * m_Fill * exnze + lattd; helper.Out.y = pyty * m_Fill * wynze - lattd; helper.Out.z = pztz * m_Fill * znxy + lattd; break; + case 2 : helper.Out.x = pxtx * m_Fill * exnze + lattd; helper.Out.y = pyty * m_Fill * wynze + lattd; helper.Out.z = pztz * m_Fill * znxy - lattd; break; + case 3 : helper.Out.x = pxtx * m_Fill * exnze + lattd; helper.Out.y = pyty * m_Fill * wynze - lattd; helper.Out.z = pztz * m_Fill * znxy - lattd; break; + case 4 : helper.Out.x = pxtx * m_Fill * exnze - lattd; helper.Out.y = pyty * m_Fill * wynze + lattd; helper.Out.z = pztz * m_Fill * znxy + lattd; break; + case 5 : helper.Out.x = pxtx * m_Fill * exnze - lattd; helper.Out.y = pyty * m_Fill * wynze - lattd; helper.Out.z = pztz * m_Fill * znxy + lattd; break; + case 6 : helper.Out.x = pxtx * m_Fill * exnze - lattd; helper.Out.y = pyty * m_Fill * wynze + lattd; helper.Out.z = pztz * m_Fill * znxy - lattd; break; + case 7 : default: helper.Out.x = pxtx * m_Fill * exnze - lattd; @@ -921,7 +910,6 @@ public: string xpand = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string style = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string fill = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint useNode = MwcNext(mwc) & 7;\n" << "\t\treal_t exnze, wynze, znxy, px, py, pz, lattd = xform->m_VariationWeights[" << varIndex << "];\n" @@ -942,16 +930,16 @@ public: if (m_VarType == eVariationType::VARTYPE_PRE) { ss << - "\t\tpx = vIn.x;\n" - "\t\tpy = vIn.y;\n" - "\t\tpz = vIn.z;\n"; + "\t\tpx = vIn.x;\n" + "\t\tpy = vIn.y;\n" + "\t\tpz = vIn.z;\n"; } else { ss << - "\t\tpx = outPoint->m_X;\n" - "\t\tpy = outPoint->m_Y;\n" - "\t\tpz = outPoint->m_Z;\n"; + "\t\tpx = outPoint->m_X;\n" + "\t\tpy = outPoint->m_Y;\n" + "\t\tpz = outPoint->m_Z;\n"; } ss << "\t\treal_t pxtx = px + vIn.x;\n" @@ -1002,13 +990,12 @@ public: << "\t\t break;\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { - if (fabs(m_Xpand) <= 1) + if (std::abs(m_Xpand) <= 1) m_Fill = m_Xpand * T(0.5); else m_Fill = std::sqrt(m_Xpand) * T(0.5); @@ -1018,7 +1005,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Xpand, prefix + "cubicLattice_3D_xpand", T(0.2)));//Original used a prefix of cubic3D_, which is incompatible with Ember's design. m_Params.push_back(ParamWithName(&m_Style, prefix + "cubicLattice_3D_style", 1, eParamType::INTEGER, 1, 2)); @@ -1048,7 +1034,6 @@ public: T expnx = T(0.25) / expx; T boot = helper.In.z == 0 ? helper.m_PrecalcAtanyx : helper.In.z; T tmp = m_Weight / (expx + expnx - (std::cos(helper.In.y) * std::cos(boot))); - helper.Out.x = (expx - expnx) * tmp; helper.Out.y = std::sin(helper.In.y) * tmp; helper.Out.z = std::sin(boot) * tmp; @@ -1058,7 +1043,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t expx = exp(vIn.x) * (real_t)(0.5);\n" << "\t\treal_t expnx = (real_t)(0.25) / expx;\n" @@ -1069,7 +1053,6 @@ public: << "\t\tvOut.y = sin(vIn.y) * tmp;\n" << "\t\tvOut.z = sin(boot) * tmp;\n" << "\t}\n"; - return ss.str(); } }; @@ -1101,10 +1084,9 @@ public: T cv = std::cos(helper.In.y); T cucv = cu * cv; T sucv = su * cv; - T x = std::pow(fabs(cucv), m_XPow) + (cucv * m_XPow) + (T(0.25) * atOmegaX);//Must fabs first argument to pow, because negative values will return NaN. - T y = std::pow(fabs(sucv), m_YPow) + (sucv * m_YPow) + (T(0.25) * atOmegaY);//Original did not do this and would frequently return bad values. - T z = std::pow(fabs(sv), m_ZPow) + sv * m_ZPow; - + T x = std::pow(std::abs(cucv), m_XPow) + (cucv * m_XPow) + (T(0.25) * atOmegaX);//Must fabs first argument to pow, because negative values will return NaN. + T y = std::pow(std::abs(sucv), m_YPow) + (sucv * m_YPow) + (T(0.25) * atOmegaY);//Original did not do this and would frequently return bad values. + T z = std::pow(std::abs(sv), m_ZPow) + sv * m_ZPow; helper.Out.x = m_Weight * x; helper.Out.y = m_Weight * y; helper.Out.z = m_Weight * z; @@ -1119,7 +1101,6 @@ public: string xpow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ypow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zpow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t uu = SQR(vIn.x);\n" << "\t\treal_t vv = SQR(vIn.y);\n" @@ -1140,7 +1121,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y;\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * z;\n" << "\t}\n"; - return ss.str(); } @@ -1148,7 +1128,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_XPow, prefix + "ho_xpow", 3)); m_Params.push_back(ParamWithName(&m_YPow, prefix + "ho_ypow", 3)); @@ -1184,7 +1163,6 @@ public: T r2d = helper.m_PrecalcSumSquares; T r = m_Weight * std::pow(r2d + SQR(z), m_HalfInvPower); T rsss = r * helper.m_PrecalcSqrtSumSquares; - helper.Out.x = rsss * cosa; helper.Out.y = rsss * sina; helper.Out.z = r * z; @@ -1202,7 +1180,6 @@ public: string absInvPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string halfInvPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invPower2pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t temp = precalcAtanyx * " << invPower << " + MwcNext(mwc) * " << invPower2pi << ";\n" << "\t\treal_t sina = sin(temp);\n" @@ -1216,14 +1193,13 @@ public: << "\t\tvOut.y = rsss * sina;\n" << "\t\tvOut.z = r * z;\n" << "\t}\n"; - return ss.str(); } virtual void Precalc() override { m_InvPower = m_Divisor / m_Power; - m_AbsInvPower = fabs(m_InvPower); + m_AbsInvPower = std::abs(m_InvPower); m_HalfInvPower = T(0.5) * m_InvPower - T(0.5); m_InvPower2pi = M_2PI / m_Power; } @@ -1232,7 +1208,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Power, prefix + "julia3Dq_power", 3, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName(&m_Divisor, prefix + "julia3Dq_divisor", 2, eParamType::INTEGER_NONZERO)); @@ -1268,7 +1243,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T r = rand.Frand01() * m_Weight; - helper.Out.x = m_Ux * r; helper.Out.y = m_Uy * r; helper.Out.z = m_Uz * r; @@ -1285,7 +1259,6 @@ public: string ux = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string uy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string uz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r = MwcNext01(mwc) * xform->m_VariationWeights[" << varIndex << "];\n" << "\n" @@ -1293,7 +1266,6 @@ public: << "\t\tvOut.y = " << uy << " * r;\n" << "\t\tvOut.z = " << uz << " * r;\n" << "\t}\n"; - return ss.str(); } @@ -1303,9 +1275,7 @@ public: m_Ux = std::cos(m_Delta * T(M_PI)) * std::cos(m_Phi * T(M_PI)); m_Uy = std::sin(m_Delta * T(M_PI)) * std::cos(m_Phi * T(M_PI)); m_Uz = std::sin(m_Phi * T(M_PI)); - T r = std::sqrt(SQR(m_Ux) + SQR(m_Uy) + SQR(m_Uz)); - //Normalize. m_Ux /= r; m_Uy /= r; @@ -1316,7 +1286,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Delta, prefix + "line_delta")); m_Params.push_back(ParamWithName(&m_Phi, prefix + "line_phi")); @@ -1351,7 +1320,7 @@ public: { int i; T xrt = helper.In.x, yrt = helper.In.y, swp; - T r2 = xrt * m_Coss + fabs(yrt) * m_Sins; + T r2 = xrt * m_Coss + std::abs(yrt) * m_Sins; T circle = helper.m_PrecalcSqrtSumSquares; for (i = 0; i < m_Sides - 1; i++) @@ -1359,8 +1328,7 @@ public: swp = xrt * m_Cosa - yrt * m_Sina; yrt = xrt * m_Sina + yrt * m_Cosa; xrt = swp; - - r2 = std::max(r2, xrt * m_Coss + fabs(yrt) * m_Sins); + r2 = std::max(r2, xrt * m_Coss + std::abs(yrt) * m_Sins); } r2 = r2 * m_Cosc + circle * m_Sinc; @@ -1368,19 +1336,17 @@ public: if (i > 1) r2 = SQR(r2); else - r2 = fabs(r2) * r2; + r2 = std::abs(r2) * r2; if (r2 > 0 && (r2 < m_W2)) { - T r = m_Weight * std::sqrt(fabs(m_W2 / r2 - 1)); - + T r = m_Weight * std::sqrt(std::abs(m_W2 / r2 - 1)); helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; } else if (r2 < 0) { - T r = m_Weight / std::sqrt(fabs(m_W2 / r2) - 1); - + T r = m_Weight / std::sqrt(std::abs(m_W2 / r2) - 1); helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; } @@ -1409,7 +1375,6 @@ public: string coss = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sinc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cosc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint i;\n" << "\t\treal_t xrt = vIn.x, yrt = vIn.y, swp;\n" @@ -1454,7 +1419,6 @@ public: << "\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1463,7 +1427,6 @@ public: auto a = M_2PI / m_Sides; auto s = T(-M_PI_2) * m_Star; auto c = T(M_PI_2) * m_Circle; - m_W2 = SQR(m_Weight); sincos(a, &m_Sina, &m_Cosa); sincos(s, &m_Sins, &m_Coss); @@ -1474,7 +1437,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Sides, prefix + "loonie2_sides", 4, eParamType::INTEGER, 1, 50)); m_Params.push_back(ParamWithName(&m_Star, prefix + "loonie2_star", 0, eParamType::REAL, -1, 1)); @@ -1527,7 +1489,6 @@ public: if (r2 < m_W2) { T r = m_Weight * std::sqrt(m_W2 / r2 - 1); - helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; } @@ -1547,7 +1508,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string w2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t r2;\n" << "\n" @@ -1571,7 +1531,6 @@ public: << "\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1584,7 +1543,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_W2, prefix + "loonie3_w2"));//Precalc. } @@ -1616,7 +1574,6 @@ public: if (r2 < m_Vv) { T r = m_Weight * std::sqrt(m_Vv / r2 - 1); - helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; helper.Out.z = r * efTez * T(0.5); @@ -1636,7 +1593,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t kikr = precalcAtanyx;\n" << "\t\treal_t efTez = vIn.z == 0 ? kikr : vIn.z;\n" @@ -1657,7 +1613,6 @@ public: << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * efTez * (real_t)(0.5);\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } @@ -1670,7 +1625,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_Vv, prefix + "loonie_3D_vv"));//Precalcs only, no params. } @@ -1697,7 +1651,6 @@ public: { T t = helper.m_PrecalcSumSquares * T(0.25) + 1; T r = m_Weight / t; - helper.Out.x = helper.In.x * r * m_X; helper.Out.y = helper.In.y * r * m_Y; helper.Out.x += (1 - (m_Twist * SQR(helper.In.x)) + helper.In.y) * m_Weight;//The += is intentional. @@ -1715,7 +1668,6 @@ public: string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string tilt = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t t = precalcSumSquares * (real_t)(0.25) + 1;\n" << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / t;\n" @@ -1726,7 +1678,6 @@ public: << "\t\tvOut.y += " << tilt << " * vIn.x * xform->m_VariationWeights[" << varIndex << "];\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -1734,7 +1685,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "mcarpet_x")); m_Params.push_back(ParamWithName(&m_Y, prefix + "mcarpet_y")); @@ -1769,7 +1719,6 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T avgxy = (helper.In.x + helper.In.y) * T(0.5); - helper.Out.x = m_Weight * (helper.In.x + m_Scale * std::sin(helper.In.y * m_Freq)); helper.Out.y = m_Weight * (helper.In.y + m_Scale * std::sin(helper.In.x * m_Freq)); helper.Out.z = m_Weight * (helper.In.z + m_Scale * std::sin(avgxy * m_Freq));//Averages the XY to get Z. @@ -1783,7 +1732,6 @@ public: string index = ss2.str(); string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t avgxy = (vIn.x + vIn.y) * (real_t)(0.5);\n" << "\n" @@ -1791,7 +1739,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + " << scale << " * sin(vIn.x * " << freq << "));\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (vIn.z + " << scale << " * sin(avgxy * " << freq << "));\n" << "\t}\n"; - return ss.str(); } @@ -1799,7 +1746,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Freq, prefix + "waves2_3D_freq", 2)); m_Params.push_back(ParamWithName(&m_Scale, prefix + "waves2_3D_scale", 1)); @@ -1829,7 +1775,6 @@ public: int sl = int(rand.Frand01() * m_Slices + T(0.5)); T a = m_Rotation + M_2PI * (sl + rand.Frand01() * m_Thickness) / m_Slices; T r = m_Weight * rand.Frand01(); - helper.Out.x = r * std::cos(a); helper.Out.y = r * std::sin(a); helper.Out.z = m_Weight * std::sin(r); @@ -1844,7 +1789,6 @@ public: string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string thickness = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint sl = (int)(MwcNext01(mwc) * " << slices << " + (real_t)(0.5));\n" << "\t\treal_t a = " << rotation << " + M_2PI * (sl + MwcNext01(mwc) * " << thickness << ") / " << slices << ";\n" @@ -1854,7 +1798,6 @@ public: << "\t\tvOut.y = r * sin(a);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * sin(r);\n" << "\t}\n"; - return ss.str(); } @@ -1869,7 +1812,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Slices, prefix + "pie3D_slices", 6, eParamType::INTEGER_NONZERO, 1)); m_Params.push_back(ParamWithName(&m_Rotation, prefix + "pie3D_rotation", T(0.5), eParamType::REAL_CYCLIC, 0, M_2PI)); @@ -1927,7 +1869,6 @@ public: string stc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string hw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t otherZ, tempPZ = 0;\n" << "\t\treal_t tempTZ = vIn.z == 0 ? " << vv << " * " << stc << " * precalcAtanyx : vIn.z;\n"; @@ -1944,7 +1885,6 @@ public: << "\t\tvOut.y = " << hw << " * (vIn.y + " << y << " * sin(tan(" << c << " * vIn.x)));\n" << "\t\tvOut.z = tempPZ + " << vv << " * (" << z << " * " << stc << " * tempTZ);\n" << "\t}\n"; - return ss.str(); } @@ -1958,8 +1898,8 @@ public: m_SinTanC = std::sin(SafeTan(m_C)); m_HalfWeight = m_Weight * T(0.5); - if (fabs(m_Weight) <= 1) - m_Vv = fabs(m_Weight) * m_Weight;//Sqr(m_Weight) value retaining sign. + if (std::abs(m_Weight) <= 1) + m_Vv = std::abs(m_Weight) * m_Weight;//Sqr(m_Weight) value retaining sign. else m_Vv = m_Weight; } @@ -1976,7 +1916,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "popcorn2_3D_x", T(0.1))); m_Params.push_back(ParamWithName(&m_Y, prefix + "popcorn2_3D_y", T(0.1))); @@ -2019,13 +1958,11 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.y);\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (atan2(SQR(vIn.x), SQR(vIn.y)) * cos(vIn.z));\n" << "\t}\n"; - return ss.str(); } }; @@ -2049,7 +1986,6 @@ public: T t = helper.m_PrecalcSumSquares + SQR(helper.In.z); T r = 1 / (std::sqrt(t) * (t + m_InvWeight)); T z = helper.In.z == 0 ? helper.m_PrecalcAtanyx : helper.In.z; - helper.Out.x = helper.In.x * r; helper.Out.y = helper.In.y * r; helper.Out.z = z * r; @@ -2062,7 +1998,6 @@ public: ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t t = precalcSumSquares + SQR(vIn.z);\n" << "\t\treal_t r = 1 / (sqrt(t) * (t + " << invWeight << "));\n" @@ -2072,7 +2007,6 @@ public: << "\t\tvOut.y = vIn.y * r;\n" << "\t\tvOut.z = z * r;\n" << "\t}\n"; - return ss.str(); } @@ -2085,7 +2019,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(true, &m_InvWeight, prefix + "scry_3D_inv_weight"));//Precalcs only, no params. } @@ -2114,7 +2047,6 @@ public: const int ypos = helper.In.y < 0; const T xrng = helper.In.x / m_XDistance; const T yrng = helper.In.y / m_YDistance; - helper.Out.x = m_Xw * ((xrng - int(xrng)) * m_XWidth + int(xrng) + (T(0.5) - xpos) * m_1mX); helper.Out.y = m_Yw * ((yrng - int(yrng)) * m_YWidth + int(yrng) + (T(0.5) - ypos) * m_1mY); helper.Out.z = m_Weight * helper.In.z; @@ -2134,7 +2066,6 @@ public: string yw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string onemx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string onemy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tconst int xpos = vIn.x < 0;\n" << "\t\tconst int ypos = vIn.y < 0;\n" @@ -2145,7 +2076,6 @@ public: << "\t\tvOut.y = " << yw << " * ((yrng - (int)yrng) * " << ywidth << " + (int)yrng + ((real_t)(0.5) - ypos) * " << onemy << ");\n" << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" << "\t}\n"; - return ss.str(); } @@ -2161,7 +2091,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_XDistance, prefix + "shredlin_xdistance", 1, eParamType::REAL_NONZERO)); m_Params.push_back(ParamWithName(&m_XWidth, prefix + "shredlin_xwidth", T(0.5), eParamType::REAL, -1, 1)); @@ -2205,7 +2134,6 @@ public: T roundY = Rint(helper.In.y); T offsetX = helper.In.x - roundX; T offsetY = helper.In.y - roundY; - helper.Out.x = helper.In.x * b; helper.Out.y = helper.In.y * b; @@ -2216,7 +2144,7 @@ public: } else { - if (fabs(offsetX) >= fabs(offsetY)) + if (std::abs(offsetX) >= std::abs(offsetY)) { if (offsetX >= 0) { @@ -2259,7 +2187,6 @@ public: string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string px = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string py = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\treal_t b = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares * (real_t)(0.25) + 1);\n" << "\t\treal_t roundX = rint(vIn.x);\n" @@ -2309,7 +2236,6 @@ public: << "\t\tvOut.y += vIn.y * " << py << ";\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -2317,7 +2243,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_X, prefix + "SplitBrdr_x", T(0.25)));//Original used a prefix of splitb_, which is incompatible with Ember's design. m_Params.push_back(ParamWithName(&m_Y, prefix + "SplitBrdr_y", T(0.25))); @@ -2360,7 +2285,6 @@ public: { ostringstream ss; intmax_t varIndex = IndexInXform(); - ss << "\t{\n" << "\t\treal_t a = M_PI / (precalcSqrtSumSquares + 1);\n" << "\t\treal_t r = precalcAtanyx * M_1_PI;\n" @@ -2372,7 +2296,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * sin(a);\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } }; @@ -2399,7 +2322,6 @@ public: const T r = std::sqrt(Sqr(helper.In.x - m_X0) + Sqr(helper.In.y - m_Y0) + Sqr(helper.In.z - m_Z0)); const T rc = ((m_Invert != 0 ? std::max(1 - r, 0) : std::max(r, 0)) - m_MinDist) * m_InternalScatter;//Original called a macro named min, which internally performed max. const T rs = std::max(rc, 0); - T sigma, phi, rad, sigmas, sigmac, phis, phic; T scale, denom; @@ -2410,26 +2332,26 @@ public: helper.Out.y = m_Weight * (helper.In.y + m_MulY * ay * rs); helper.Out.z = m_Weight * (helper.In.z + m_MulZ * az * rs); break; + case 1://Radial. sigma = std::asin(r == 0 ? 0 : helper.In.z / r) + m_MulZ * az * rs; phi = helper.m_PrecalcAtanyx + m_MulY * ay * rs; rad = r + m_MulX * ax * rs; - sigmas = std::sin(sigma); sigmac = std::cos(sigma); phis = std::sin(phi); phic = std::cos(phi); - helper.Out.x = m_Weight * (rad * sigmac * phic); helper.Out.y = m_Weight * (rad * sigmac * phis); helper.Out.z = m_Weight * (rad * sigmas); break; + case 2://Box. default: scale = Clamp(rs, 0, T(0.9)) + T(0.1); denom = 1 / scale; helper.Out.x = m_Weight * Lerp(helper.In.x, floor(helper.In.x * denom) + scale * ax, m_MulX * rs) + m_MulX * std::pow(ax, m_BoxPow) * rs * denom;//m_BoxPow should be an integer value held in T, - helper.Out.y = m_Weight * Lerp(helper.In.y, floor(helper.In.y * denom) + scale * ay, m_MulY * rs) + m_MulY * std::pow(ay, m_BoxPow) * rs * denom;//so fabs() shouldn't be necessary. + helper.Out.y = m_Weight * Lerp(helper.In.y, floor(helper.In.y * denom) + scale * ay, m_MulY * rs) + m_MulY * std::pow(ay, m_BoxPow) * rs * denom;//so std::abs() shouldn't be necessary. helper.Out.z = m_Weight * Lerp(helper.In.z, floor(helper.In.z * denom) + scale * az, m_MulZ * rs) + m_MulZ * std::pow(az, m_BoxPow) * rs * denom; break; } @@ -2453,7 +2375,6 @@ public: string type = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string boxPow = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string internalScatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tconst real_t ax = MwcNext0505(mwc);\n" << "\t\tconst real_t ay = MwcNext0505(mwc);\n" @@ -2495,7 +2416,6 @@ public: << "\t\t break;\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } @@ -2513,7 +2433,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Scatter, prefix + "falloff_scatter", 1, eParamType::REAL, EPS, TMAX)); m_Params.push_back(ParamWithName(&m_MinDist, prefix + "falloff_mindist", T(0.5), eParamType::REAL, 0, TMAX)); @@ -2568,13 +2487,14 @@ public: switch (int(m_Type)) { case 0://Linear. - { - helper.Out.x = helper.In.x + m_MulX * random.x * dist; - helper.Out.y = helper.In.y + m_MulY * random.y * dist; - helper.Out.z = helper.In.z + m_MulZ * random.z * dist; - outPoint.m_ColorX = fabs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); - } - break; + { + helper.Out.x = helper.In.x + m_MulX * random.x * dist; + helper.Out.y = helper.In.y + m_MulY * random.y * dist; + helper.Out.z = helper.In.z + m_MulZ * random.z * dist; + outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); + } + break; + case 1://Radial. if (helper.In.x == 0 && helper.In.y == 0 && helper.In.z == 0) { @@ -2592,30 +2512,30 @@ public: const T sigmac = std::cos(sigma); const T phis = std::sin(phi); const T phic = std::cos(phi); - helper.Out.x = r * sigmac * phic; helper.Out.y = r * sigmac * phis; helper.Out.z = r * sigmas; - outPoint.m_ColorX = fabs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); + outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); } + break; + case 2://Gaussian. default: - { - const T sigma = dist * random.y * M_2PI; - const T phi = dist * random.z * T(M_PI); - const T rad = dist * random.x; - const T sigmas = std::sin(sigma); - const T sigmac = std::cos(sigma); - const T phis = std::sin(phi); - const T phic = std::cos(phi); - - helper.Out.x = helper.In.x + m_MulX * rad * sigmac * phic; - helper.Out.y = helper.In.y + m_MulY * rad * sigmac * phis; - helper.Out.z = helper.In.z + m_MulZ * rad * sigmas; - outPoint.m_ColorX = fabs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); - } - break; + { + const T sigma = dist * random.y * M_2PI; + const T phi = dist * random.z * T(M_PI); + const T rad = dist * random.x; + const T sigmas = std::sin(sigma); + const T sigmac = std::cos(sigma); + const T phis = std::sin(phi); + const T phic = std::cos(phi); + helper.Out.x = helper.In.x + m_MulX * rad * sigmac * phic; + helper.Out.y = helper.In.y + m_MulY * rad * sigmac * phis; + helper.Out.z = helper.In.z + m_MulZ * rad * sigmas; + outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); + } + break; } } @@ -2637,7 +2557,6 @@ public: string invert = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string type = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rMax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tconst real_t randx = MwcNext0505(mwc);\n" << "\t\tconst real_t randy = MwcNext0505(mwc);\n" @@ -2645,7 +2564,7 @@ public: << "\t\tconst real_t randc = MwcNext0505(mwc);\n" << "\t\tconst real_t distA = sqrt(Sqr(vIn.x - " << x0 << ") + Sqr(vIn.y - " << y0 << ") + Sqr(vIn.z - " << z0 << "));\n" << "\t\tconst real_t distB = " << invert << " != 0 ? max(1 - distA, (real_t)(0.0)) : max(distA, (real_t)(0.0));\n" - << "\t\tconst real_t dist = max((distB - " << minDist << ") * " << rMax<< ", (real_t)(0.0));\n" + << "\t\tconst real_t dist = max((distB - " << minDist << ") * " << rMax << ", (real_t)(0.0));\n" << "\n" << "\t\tswitch ((int)" << type << ")\n" << "\t\t{\n" @@ -2697,7 +2616,6 @@ public: << "\t\t }\n" << "\t\t}\n" << "\t}\n"; - return ss.str(); } @@ -2715,7 +2633,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Scatter, prefix + "falloff2_scatter", 1, eParamType::REAL, EPS, TMAX)); m_Params.push_back(ParamWithName(&m_MinDist, prefix + "falloff2_mindist", T(0.5), eParamType::REAL, 0, TMAX)); @@ -2770,9 +2687,10 @@ public: case 0://Circle. radius = std::sqrt(Sqr(helper.In.x - m_CenterX) + Sqr(helper.In.y - m_CenterY) + Sqr(helper.In.z - m_CenterZ)); break; + case 1://Square. default: - radius = std::max(fabs(helper.In.x - m_CenterX), std::max(fabs(helper.In.y - m_CenterY), (fabs(helper.In.z - m_CenterZ))));//Original called a macro named min, which internally performed max. + radius = std::max(std::abs(helper.In.x - m_CenterX), std::max(std::abs(helper.In.y - m_CenterY), (std::abs(helper.In.z - m_CenterZ))));//Original called a macro named min, which internally performed max. break; } @@ -2780,7 +2698,7 @@ public: switch (int(m_BlurType)) { - case 0://Gaussian. + case 0://Gaussian. { const T sigma = dist * random.y * M_2PI; const T phi = dist * random.z * T(M_PI); @@ -2789,46 +2707,46 @@ public: const T sigmac = std::cos(sigma); const T phis = std::sin(phi); const T phic = std::cos(phi); - helper.Out.x = helper.In.x + m_MulX * rad * sigmac * phic; helper.Out.y = helper.In.y + m_MulY * rad * sigmac * phis; helper.Out.z = helper.In.z + m_MulZ * rad * sigmas; - outPoint.m_ColorX = fabs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); + outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); } break; - case 1://Radial. - if (helper.In.x == 0 && helper.In.y == 0 && helper.In.z == 0) - { - helper.Out.x = helper.In.x; - helper.Out.y = helper.In.y; - helper.Out.z = helper.In.z; - } - else - { - const T rIn = std::sqrt(helper.m_PrecalcSumSquares + SQR(helper.In.z)); - const T sigma = std::asin(helper.In.z / rIn) + m_MulZ * random.z * dist; - const T phi = helper.m_PrecalcAtanyx + m_MulY * random.y * dist; - const T r = rIn + m_MulX * random.x * dist; - const T sigmas = std::sin(sigma); - const T sigmac = std::cos(sigma); - const T phis = std::sin(phi); - const T phic = std::cos(phi); - helper.Out.x = r * sigmac * phic; - helper.Out.y = r * sigmac * phis; - helper.Out.z = r * sigmas; - outPoint.m_ColorX = fabs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); - } - break; - case 2://Log. - default: + case 1://Radial. + if (helper.In.x == 0 && helper.In.y == 0 && helper.In.z == 0) + { + helper.Out.x = helper.In.x; + helper.Out.y = helper.In.y; + helper.Out.z = helper.In.z; + } + else + { + const T rIn = std::sqrt(helper.m_PrecalcSumSquares + SQR(helper.In.z)); + const T sigma = std::asin(helper.In.z / rIn) + m_MulZ * random.z * dist; + const T phi = helper.m_PrecalcAtanyx + m_MulY * random.y * dist; + const T r = rIn + m_MulX * random.x * dist; + const T sigmas = std::sin(sigma); + const T sigmac = std::cos(sigma); + const T phis = std::sin(phi); + const T phic = std::cos(phi); + helper.Out.x = r * sigmac * phic; + helper.Out.y = r * sigmac * phis; + helper.Out.z = r * sigmas; + outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + m_MulC * random.w * dist, T(1))); + } + + break; + + case 2://Log. + default: { const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (LogMap(dist) - dist); - - helper.Out.x = helper.In.x + LogMap(m_MulX) * LogScale(random.x) * coeff, - helper.Out.y = helper.In.y + LogMap(m_MulY) * LogScale(random.y) * coeff, - helper.Out.z = helper.In.z + LogMap(m_MulZ) * LogScale(random.z) * coeff, - outPoint.m_ColorX = fabs(fmod(outPoint.m_ColorX + LogMap(m_MulC) * LogScale(random.w) * coeff, T(1))); + helper.Out.x = helper.In.x + LogMap(m_MulX) * LogScale(random.x) * coeff; + helper.Out.y = helper.In.y + LogMap(m_MulY) * LogScale(random.y) * coeff; + helper.Out.z = helper.In.z + LogMap(m_MulZ) * LogScale(random.z) * coeff; + outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + LogMap(m_MulC) * LogScale(random.w) * coeff, T(1))); } break; } @@ -2854,81 +2772,79 @@ public: string centerZ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rMax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" - << "\t\tconst real_t randx = MwcNext0505(mwc);\n" - << "\t\tconst real_t randy = MwcNext0505(mwc);\n" - << "\t\tconst real_t randz = MwcNext0505(mwc);\n" - << "\t\tconst real_t randc = MwcNext0505(mwc);\n" - << "\t\treal_t radius;\n" - << "\n" - << "\t\tswitch ((int)" << blurShape << ")\n" - << "\t\t{\n" - << "\t\t case 0:\n" - << "\t\t radius = sqrt(Sqr(vIn.x - " << centerX << ") + Sqr(vIn.y - " << centerY << ") + Sqr(vIn.z - " << centerZ << "));\n" - << "\t\t break;\n" - << "\t\t case 1:\n" - << "\t\t radius = max(fabs(vIn.x - " << centerX << "), max(fabs(vIn.y - " << centerY << "), (fabs(vIn.z - " << centerZ << "))));\n" - << "\t\t break;\n" - << "\t\t}\n" - << "\n" - << "\t\tconst real_t dist = max(((" << invertDist << " != 0 ? max(1 - radius, (real_t)(0.0)) : max(radius, (real_t)(0.0))) - " << minDist << ") * " << rMax << ", (real_t)(0.0));\n" - << "\n" - << "\t\tswitch ((int)" << blurType << ")\n" - << "\t\t{\n" - << "\t\tcase 0:\n" - << "\t\t {\n" - << "\t\t real_t sigma = dist * randy * M_2PI;\n" - << "\t\t real_t phi = dist * randz * M_PI;\n" - << "\t\t real_t rad = dist * randx;\n" - << "\t\t real_t sigmas = sin(sigma);\n" - << "\t\t real_t sigmac = cos(sigma);\n" - << "\t\t real_t phis = sin(phi);\n" - << "\t\t real_t phic = cos(phi);\n" - << "\n" - << "\t\t vOut.x = vIn.x + " << mulX << " * rad * sigmac * phic;\n" - << "\t\t vOut.y = vIn.y + " << mulY << " * rad * sigmac * phis;\n" - << "\t\t vOut.z = vIn.z + " << mulZ << " * rad * sigmas;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" - << "\t\t }\n" - << "\t\t break;\n" - << "\t\tcase 1:\n" - << "\t\t if (vIn.x == 0 && vIn.y == 0 && vIn.z == 0)\n" - << "\t\t {\n" - << "\t\t vOut.x = vIn.x;\n" - << "\t\t vOut.y = vIn.y;\n" - << "\t\t vOut.z = vIn.z;\n" - << "\t\t }\n" - << "\t\t else\n" - << "\t\t {\n" - << "\t\t real_t rIn = sqrt(precalcSumSquares + SQR(vIn.z));\n" - << "\t\t real_t sigma = asin(vIn.z / rIn) + " << mulZ << " * randz * dist;\n" - << "\t\t real_t phi = precalcAtanyx + " << mulY << " * randy * dist;\n" - << "\t\t real_t r = rIn + " << mulX << " * randx * dist;\n" - << "\t\t real_t sigmas = sin(sigma);\n" - << "\t\t real_t sigmac = cos(sigma);\n" - << "\t\t real_t phis = sin(phi);\n" - << "\t\t real_t phic = cos(phi);\n" - << "\n" - << "\t\t vOut.x = r * sigmac * phic;\n" - << "\t\t vOut.y = r * sigmac * phis;\n" - << "\t\t vOut.z = r * sigmas;\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" - << "\t\t }\n" - << "\t\t break;\n" - << "\t\tcase 2:\n" - << "\t\t {\n" - << "\t\t real_t coeff = " << rMax << " <= EPS ? dist : dist + " << alpha << " * (LogMap(dist) - dist);\n" - << "\n" - << "\t\t vOut.x = vIn.x + LogMap(" << mulX << ") * LogScale(randx) * coeff,\n" - << "\t\t vOut.y = vIn.y + LogMap(" << mulY << ") * LogScale(randy) * coeff,\n" - << "\t\t vOut.z = vIn.z + LogMap(" << mulZ << ") * LogScale(randz) * coeff,\n" - << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + LogMap(" << mulC << ") * LogScale(randc) * coeff, (real_t)(1.0)));\n" - << "\t\t }\n" - << "\t\t break;\n" - << "\t\t}\n" - << "\t}\n"; - + << "\t\tconst real_t randx = MwcNext0505(mwc);\n" + << "\t\tconst real_t randy = MwcNext0505(mwc);\n" + << "\t\tconst real_t randz = MwcNext0505(mwc);\n" + << "\t\tconst real_t randc = MwcNext0505(mwc);\n" + << "\t\treal_t radius;\n" + << "\n" + << "\t\tswitch ((int)" << blurShape << ")\n" + << "\t\t{\n" + << "\t\t case 0:\n" + << "\t\t radius = sqrt(Sqr(vIn.x - " << centerX << ") + Sqr(vIn.y - " << centerY << ") + Sqr(vIn.z - " << centerZ << "));\n" + << "\t\t break;\n" + << "\t\t case 1:\n" + << "\t\t radius = max(fabs(vIn.x - " << centerX << "), max(fabs(vIn.y - " << centerY << "), (fabs(vIn.z - " << centerZ << "))));\n" + << "\t\t break;\n" + << "\t\t}\n" + << "\n" + << "\t\tconst real_t dist = max(((" << invertDist << " != 0 ? max(1 - radius, (real_t)(0.0)) : max(radius, (real_t)(0.0))) - " << minDist << ") * " << rMax << ", (real_t)(0.0));\n" + << "\n" + << "\t\tswitch ((int)" << blurType << ")\n" + << "\t\t{\n" + << "\t\tcase 0:\n" + << "\t\t {\n" + << "\t\t real_t sigma = dist * randy * M_2PI;\n" + << "\t\t real_t phi = dist * randz * M_PI;\n" + << "\t\t real_t rad = dist * randx;\n" + << "\t\t real_t sigmas = sin(sigma);\n" + << "\t\t real_t sigmac = cos(sigma);\n" + << "\t\t real_t phis = sin(phi);\n" + << "\t\t real_t phic = cos(phi);\n" + << "\n" + << "\t\t vOut.x = vIn.x + " << mulX << " * rad * sigmac * phic;\n" + << "\t\t vOut.y = vIn.y + " << mulY << " * rad * sigmac * phis;\n" + << "\t\t vOut.z = vIn.z + " << mulZ << " * rad * sigmas;\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" + << "\t\t }\n" + << "\t\t break;\n" + << "\t\tcase 1:\n" + << "\t\t if (vIn.x == 0 && vIn.y == 0 && vIn.z == 0)\n" + << "\t\t {\n" + << "\t\t vOut.x = vIn.x;\n" + << "\t\t vOut.y = vIn.y;\n" + << "\t\t vOut.z = vIn.z;\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t real_t rIn = sqrt(precalcSumSquares + SQR(vIn.z));\n" + << "\t\t real_t sigma = asin(vIn.z / rIn) + " << mulZ << " * randz * dist;\n" + << "\t\t real_t phi = precalcAtanyx + " << mulY << " * randy * dist;\n" + << "\t\t real_t r = rIn + " << mulX << " * randx * dist;\n" + << "\t\t real_t sigmas = sin(sigma);\n" + << "\t\t real_t sigmac = cos(sigma);\n" + << "\t\t real_t phis = sin(phi);\n" + << "\t\t real_t phic = cos(phi);\n" + << "\n" + << "\t\t vOut.x = r * sigmac * phic;\n" + << "\t\t vOut.y = r * sigmac * phis;\n" + << "\t\t vOut.z = r * sigmas;\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + " << mulC << " * randc * dist, (real_t)(1.0)));\n" + << "\t\t }\n" + << "\t\t break;\n" + << "\t\tcase 2:\n" + << "\t\t {\n" + << "\t\t real_t coeff = " << rMax << " <= EPS ? dist : dist + " << alpha << " * (LogMap(dist) - dist);\n" + << "\n" + << "\t\t vOut.x = vIn.x + LogMap(" << mulX << ") * LogScale(randx) * coeff;\n" + << "\t\t vOut.y = vIn.y + LogMap(" << mulY << ") * LogScale(randy) * coeff;\n" + << "\t\t vOut.z = vIn.z + LogMap(" << mulZ << ") * LogScale(randz) * coeff;\n" + << "\t\t outPoint->m_ColorX = fabs(fmod(outPoint->m_ColorX + LogMap(" << mulC << ") * LogScale(randc) * coeff, (real_t)(1.0)));\n" + << "\t\t }\n" + << "\t\t break;\n" + << "\t\t}\n" + << "\t}\n"; return ss.str(); } @@ -2946,7 +2862,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_BlurType, prefix + "falloff3_blur_type", 0, eParamType::INTEGER, 0, 3)); m_Params.push_back(ParamWithName(&m_BlurShape, prefix + "falloff3_blur_shape", 0, eParamType::INTEGER, 0, 1)); @@ -2999,10 +2914,8 @@ public: { intmax_t m, n; T alpha, beta, offsetAl, offsetBe, offsetGa, x, y; - //Transfer to trilinear coordinates, normalized to real distances from triangle sides. DirectTrilinear(helper.In.x, helper.In.y, alpha, beta); - m = Floor(alpha / m_S2a); offsetAl = alpha - m * m_S2a; n = Floor(beta / m_S2b); @@ -3025,7 +2938,6 @@ public: alpha += m * m_S2a; beta += n * m_S2b; - InverseTrilinear(alpha, beta, x, y, rand); helper.Out.x = m_Weight * x; helper.Out.y = m_Weight * y; @@ -3066,7 +2978,6 @@ public: string width3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" << "\t\tint m, n;\n" << "\t\treal_t alpha, beta, offsetAl, offsetBe, offsetGa, x, y;\n" @@ -3153,7 +3064,6 @@ public: << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y;\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; - return ss.str(); } @@ -3297,27 +3207,22 @@ public: T cr = T(0.047) + m_B; T ar = T(M_PI) - br - cr; T temp = ar / 2; - sincos(temp, &sinA2, &cosA2); temp = br / 2; sincos(temp, &sinB2, &cosB2); temp = cr / 2; sincos(temp, &sinC2, &cosC2); sincos(cr, &m_SinC, &m_CosC); - T a = m_Radius * (sinC2 / cosC2 + sinB2 / cosB2); T b = m_Radius * (sinC2 / cosC2 + sinA2 / cosA2); T c = m_Radius * (sinB2 / cosB2 + sinA2 / cosA2); - m_Width1 = 1 - m_Width; m_Width2 = 2 * m_Width; m_Width3 = 1 - m_Width * m_Width; s2 = m_Radius * (a + b + c); - m_Ha = s2 / a / 6; m_Hb = s2 / b / 6; m_Hc = s2 / c / 6; - m_Ab = a / b;// a div on b m_Ac = a / c; m_Ba = b / a; @@ -3334,7 +3239,7 @@ public: if (m_Power == 0) m_Power = 2; - m_AbsN = T(int(fabs(m_Power))); + m_AbsN = T(int(std::abs(m_Power))); m_Cn = m_Dist / m_Power / 2; } @@ -3342,7 +3247,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.push_back(ParamWithName(&m_Power, prefix + "xtrb_power", 2, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName(&m_Radius, prefix + "xtrb_radius", 1)); @@ -3387,7 +3291,6 @@ private: T iny = al - m_Radius; T angle = (atan2(iny, inx) + M_2PI * (rand.Rand(int(m_AbsN)))) / m_Power; T r = m_Weight * std::pow(SQR(inx) + SQR(iny), m_Cn); - x = r * std::cos(angle); y = r * std::sin(angle); } @@ -3566,25 +3469,25 @@ public: T boost;//Boost is the separation distance between the two planes. T sumX, sumY; - if (m_VarType == eVariationType::VARTYPE_PRE) - { - sumX = helper.In.x; - sumY = helper.In.y; - } - else + if (m_VarType == eVariationType::VARTYPE_REG) { sumX = outPoint.m_X; sumY = outPoint.m_Y; - outPoint.m_X = 0; + outPoint.m_X = 0;//Only need to clear regular, pre and post will overwrite by default. outPoint.m_Y = 0; } + else + { + sumX = helper.In.x; + sumY = helper.In.y; + } if (rand.Frand01() < T(0.5)) posNeg = -1; //Determine whether one or two major planes. int majplane = 1; - T abmajp = fabs(m_MajP); + T abmajp = std::abs(m_MajP); if (abmajp <= 1) { @@ -3597,6 +3500,7 @@ public: } //Creating Z factors relative to the planes. These will be added, whereas x and y will be assigned. + //Original does += z *, so using z on the right side of = is intentional. if (majplane == 2) helper.Out.z = helper.In.z * T(0.5) * m_ZLift + (posNeg * boost); else @@ -3629,18 +3533,17 @@ public: ss2 << "_" << XformIndexInEmber(); string index = ss2.str() + "]"; string stateIndex = ss2.str(); - string majp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string zlift = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string majp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string zlift = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string seg60xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6;//Precalc. string seg60yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6; string seg120xStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 3; string seg120yStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 3; - string halfScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string rswtch = "varState->" + m_Params[i++].Name() + stateIndex;//State. - string fcycle = "varState->" + m_Params[i++].Name() + stateIndex; - string bcycle = "varState->" + m_Params[i++].Name() + stateIndex; - + string halfScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rswtch = "varState->" + m_Params[i++].Name() + stateIndex;//State. + string fcycle = "varState->" + m_Params[i++].Name() + stateIndex; + string bcycle = "varState->" + m_Params[i++].Name() + stateIndex; ss << "\t{\n" << "\t\tif (" << fcycle << " > 5)\n" << "\t\t{\n" @@ -3661,63 +3564,62 @@ public: << "\t\treal_t boost;\n" << "\t\treal_t sumX, sumY;\n\n"; - if (m_VarType == eVariationType::VARTYPE_PRE) + if (m_VarType == eVariationType::VARTYPE_REG) { ss - << "\t\tsumX = vIn.x;\n" - << "\t\tsumY = vIn.y;\n"; + << "\t\tsumX = outPoint->m_X;\n" + << "\t\tsumY = outPoint->m_Y;\n" + << "\t\toutPoint->m_X = 0;\n" + << "\t\toutPoint->m_Y = 0;\n"; } else { ss - << "\t\tsumX = outPoint->m_X;\n" - << "\t\tsumY = outPoint->m_Y;\n" - << "\t\toutPoint->m_X = 0;\n" - << "\t\toutPoint->m_Y = 0;\n"; + << "\t\tsumX = vIn.x;\n" + << "\t\tsumY = vIn.y;\n"; } ss - << "\t\t\n" - << "\t\tif (MwcNext01(mwc) < 0.5)\n" - << "\t\t posNeg = -1;\n" - << "\n" - << "\t\tint majplane = 1;\n" - << "\t\treal_t abmajp = fabs(" << majp << ");\n" - << "\n" - << "\t\tif (abmajp <= 1)\n" - << "\t\t{\n" - << "\t\t majplane = 1;\n" - << "\t\t}\n" - << "\t\telse\n" - << "\t\t{\n" - << "\t\t majplane = 2;\n" - << "\t\t boost = (abmajp - 1) * 0.5;\n" - << "\t\t}\n" - << "\n" - << "\t\tif (majplane == 2)\n" - << "\t\t vOut.z = vIn.z * 0.5 * " << zlift << " + (posNeg * boost);\n" - << "\t\telse\n" - << "\t\t vOut.z = vIn.z * 0.5 * " << zlift << ";\n" - << "\n" - << "\t\tif (" << rswtch << " <= 1)\n" - << "\t\t{\n" - << "\t\t loc = (int)" << fcycle << ";\n" - << "\t\t tempx = parVars[" << seg60xStartIndex << " + loc];\n" - << "\t\t tempy = parVars[" << seg60yStartIndex << " + loc];\n" - << "\t\t " << fcycle << " = " << fcycle << " + 1;\n" - << "\t\t}\n" - << "\t\telse\n" - << "\t\t{\n" - << "\t\t loc = (int)" << bcycle << ";\n" - << "\t\t tempx = parVars[" << seg120xStartIndex << " + loc];\n" - << "\t\t tempy = parVars[" << seg120yStartIndex << " + loc];\n" - << "\t\t " << bcycle << " = " << bcycle << " + 1;\n" - << "\t\t}\n" - << "\n" - << "\t\tvOut.x = ((sumX + vIn.x) * " << halfScale << ") + (lrmaj * tempx);\n" - << "\t\tvOut.y = ((sumY + vIn.y) * " << halfScale << ") + (lrmaj * tempy);\n" - << "\t}\n"; - + << "\t\t\n" + << "\t\tif (MwcNext01(mwc) < 0.5)\n" + << "\t\t posNeg = -1;\n" + << "\n" + << "\t\tint majplane = 1;\n" + << "\t\treal_t abmajp = fabs(" << majp << ");\n" + << "\n" + << "\t\tif (abmajp <= 1)\n" + << "\t\t{\n" + << "\t\t majplane = 1;\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t majplane = 2;\n" + << "\t\t boost = (abmajp - 1) * 0.5;\n" + << "\t\t}\n" + << "\n" + << "\t\tif (majplane == 2)\n" + << "\t\t vOut.z = vIn.z * 0.5 * " << zlift << " + (posNeg * boost);\n" + << "\t\telse\n" + << "\t\t vOut.z = vIn.z * 0.5 * " << zlift << ";\n" + << "\n" + << "\t\tif (" << rswtch << " <= 1)\n" + << "\t\t{\n" + << "\t\t loc = (int)" << fcycle << ";\n" + << "\t\t tempx = parVars[" << seg60xStartIndex << " + loc];\n" + << "\t\t tempy = parVars[" << seg60yStartIndex << " + loc];\n" + << "\t\t " << fcycle << " = " << fcycle << " + 1;\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t loc = (int)" << bcycle << ";\n" + << "\t\t tempx = parVars[" << seg120xStartIndex << " + loc];\n" + << "\t\t tempy = parVars[" << seg120yStartIndex << " + loc];\n" + << "\t\t " << bcycle << " = " << bcycle << " + 1;\n" + << "\t\t}\n" + << "\n" + << "\t\tvOut.x = ((sumX + vIn.x) * " << halfScale << ") + (lrmaj * tempx);\n" + << "\t\tvOut.y = ((sumY + vIn.y) * " << halfScale << ") + (lrmaj * tempy);\n" + << "\t}\n"; return ss.str(); } @@ -3727,20 +3629,17 @@ public: ss2 << "_" << XformIndexInEmber(); string stateIndex = ss2.str(); string prefix = Prefix(); - //CPU sets fycle and bcycle to 0 at the beginning in Precalc(). //Set to random in OpenCL since a value can't be set once and kept between kernel launches without writing it back to an OpenCL buffer. ss << "\n\t\tvarState." << prefix << "hexaplay3D_rswtch" << stateIndex << " = trunc(MwcNext01(&mwc) * 3.0);"; ss << "\n\t\tvarState." << prefix << "hexaplay3D_fcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * 5.0);"; ss << "\n\t\tvarState." << prefix << "hexaplay3D_bcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * 2.0);"; - return ss.str(); } virtual void Precalc() override { T hlift = std::sin(T(M_PI) / 3); - m_RSwtch = std::trunc(QTIsaac::LockedFrand01() * 3);//Chooses 6 or 3 nodes. m_FCycle = 0; m_BCycle = 0; @@ -3750,18 +3649,15 @@ public: m_Seg60[3].x = -1; m_Seg60[4].x = T(-0.5); m_Seg60[5].x = T(0.5); - m_Seg60[0].y = 0; m_Seg60[1].y = hlift; m_Seg60[2].y = hlift; m_Seg60[3].y = 0; m_Seg60[4].y = -hlift; m_Seg60[5].y = -hlift; - m_Seg120[0].x = 1; m_Seg120[1].x = T(-0.5); m_Seg120[2].x = T(-0.5); - m_Seg120[0].y = 0; m_Seg120[1].y = hlift; m_Seg120[2].y = -hlift; @@ -3772,7 +3668,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.reserve(25); m_Params.push_back(ParamWithName(&m_MajP, prefix + "hexaplay3D_majp", 1, eParamType::REAL)); @@ -3855,30 +3750,26 @@ public: T gentleZ = 0; T sumX, sumY, sumZ; - if (m_VarType == eVariationType::VARTYPE_PRE) - { - sumX = helper.In.x; - sumY = helper.In.y; - sumZ = helper.In.z; - } - else + if (m_VarType == eVariationType::VARTYPE_REG) { sumX = outPoint.m_X; sumY = outPoint.m_Y; sumZ = outPoint.m_Z; outPoint.m_X = 0; - outPoint.m_Y = 0; - } - - if (fabs(m_Weight) <= 0.5) - { - smooth = m_Weight * 2; + outPoint.m_Y = 0;//Z is optionally cleared and assigned to below. } else { - smooth = 1; + sumX = helper.In.x; + sumY = helper.In.y; + sumZ = helper.In.z; } - + + if (std::abs(m_Weight) <= 0.5) + smooth = m_Weight * 2; + else + smooth = 1; + int posNeg = 1; int loc; T boost = 0; @@ -3887,12 +3778,10 @@ public: T tempx, tempy; if (rand.Frand01() < T(0.5)) - { posNeg = -1; - } int majplane = 0; - T abmajp = fabs(m_MajP); + T abmajp = std::abs(m_MajP); if (abmajp <= 1) { @@ -3909,7 +3798,7 @@ public: majplane = 2; boost = (abmajp - 2) * T(0.5); } - + if (majplane == 0) { helper.Out.z = smooth * helper.In.z * scale * m_ZLift; @@ -3917,18 +3806,12 @@ public: else if (majplane == 1 && m_MajP < 0) { if (m_MajP < -1 && m_MajP >= -2) - { gentleZ = (abmajp - 1); - } else - { gentleZ = 1; - } if (posNeg < 0) - { helper.Out.z = -2 * (sumZ * gentleZ); - } } if (majplane == 2 && m_MajP < 0) @@ -3937,18 +3820,16 @@ public: { helper.Out.z = (smooth * (helper.In.z * scale * m_ZLift + boost)); } - else//For this case when non-pre assign and zero out, for all others, sum as usual. + else//For this case when reg, assign and zero out. For all others, sum as usual. { helper.Out.z = (sumZ - (2 * smooth * sumZ)) + (smooth * posNeg * (helper.In.z * scale * m_ZLift + boost)); - if (m_VarType != eVariationType::VARTYPE_PRE) + if (m_VarType == eVariationType::VARTYPE_REG) outPoint.m_Z = 0; } } else - { helper.Out.z = smooth * (helper.In.z * scale * m_ZLift + (posNeg * boost)); - } if (m_RSwtch <= 1) { @@ -3971,7 +3852,6 @@ public: smRotyFP = (smooth * scale * sumY * tempx) + (smooth * scale * sumX * tempy); smRotxFT = (helper.In.x * smooth * scale * tempx) - (helper.In.y * smooth * scale * tempy); smRotyFT = (helper.In.y * smooth * scale * tempx) + (helper.In.x * smooth * scale * tempy); - helper.Out.x = sumX * (1 - smooth) + smRotxFP + smRotxFT + smooth * lrmaj * scale3 * tempx; helper.Out.y = sumY * (1 - smooth) + smRotyFP + smRotyFT + smooth * lrmaj * scale3 * tempy; } @@ -3983,7 +3863,6 @@ public: ss2 << "_" << XformIndexInEmber(); string index = ss2.str() + "]"; string stateIndex = ss2.str(); - string majp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zlift = "parVars[" + ToUpper(m_Params[i++].Name()) + index; @@ -3995,7 +3874,6 @@ public: string rswtch = "varState->" + m_Params[i++].Name() + stateIndex;//State. string fcycle = "varState->" + m_Params[i++].Name() + stateIndex; string bcycle = "varState->" + m_Params[i++].Name() + stateIndex; - ss << "\t{\n" << "\t\tif (" << fcycle << " > 5)\n" << "\t\t{\n" @@ -4018,132 +3896,119 @@ public: << "\t\treal_t gentleZ = 0;\n" << "\t\treal_t sumX, sumY, sumZ;\n\n"; - if (m_VarType == eVariationType::VARTYPE_PRE) - { - ss - << "\t\tsumX = vIn.x;\n" - << "\t\tsumY = vIn.y;\n" - << "\t\tsumZ = vIn.z;\n"; - } - else - { - ss - << "\t\tsumX = outPoint->m_X;\n" - << "\t\tsumY = outPoint->m_Y;\n" - << "\t\tsumZ = outPoint->m_Z;\n" - << "\t\toutPoint->m_X = 0;\n" - << "\t\toutPoint->m_Y = 0;\n"; - } + if (m_VarType == eVariationType::VARTYPE_REG) + { + ss + << "\t\tsumX = outPoint->m_X;\n" + << "\t\tsumY = outPoint->m_Y;\n" + << "\t\tsumZ = outPoint->m_Z;\n" + << "\t\toutPoint->m_X = 0;\n" + << "\t\toutPoint->m_Y = 0;\n"; + } + else + { + ss + << "\t\tsumX = vIn.x;\n" + << "\t\tsumY = vIn.y;\n" + << "\t\tsumZ = vIn.z;\n"; + } ss - << "\n" - << "\t\tif (fabs(lrmaj) <= 0.5)\n" - << "\t\t{\n" - << "\t\t smooth = lrmaj * 2;\n" - << "\t\t}\n" - << "\t\telse\n" - << "\t\t{\n" - << "\t\t smooth = 1;\n" - << "\t\t}\n" - << "\n" - << "\t\tint posNeg = 1;\n" - << "\t\tint loc;\n" - << "\t\treal_t boost = 0;\n" - << "\t\treal_t scale = " << scale << ";\n"//Temp will be used from here on. - << "\t\treal_t scale3;\n" - << "\t\treal_t tempx, tempy;\n" - << "\n" - << "\t\tif (MwcNext01(mwc) < 0.5)\n" - << "\t\t{\n" - << "\t\t posNeg = -1;\n" - << "\t\t}\n" - << "\n" - << "\t\tint majplane = 0;\n" - << "\t\treal_t abmajp = fabs(" << majp << ");\n" - << "\n" - << "\t\tif (abmajp <= 1)\n" - << "\t\t{\n" - << "\t\t majplane = 0;\n" - << "\t\t boost = 0;\n" - << "\t\t}\n" - << "\t\telse if (abmajp > 1 && abmajp < 2)\n" - << "\t\t{\n" - << "\t\t majplane = 1;\n" - << "\t\t boost = 0;\n" - << "\t\t}\n" - << "\t\telse\n" - << "\t\t{\n" - << "\t\t majplane = 2;\n" - << "\t\t boost = (abmajp - 2) * 0.5;\n" - << "\t\t}\n" - << "\n" - << "\t\tif (majplane == 0)\n" - << "\t\t{\n" - << "\t\t vOut.z = smooth * vIn.z * scale * " << zlift << ";\n" - << "\t\t}\n" - << "\t\telse if (majplane == 1 && " << majp << " < 0)\n" - << "\t\t{\n" - << "\t\t if (" << majp << " < -1 && " << majp << " >= -2)\n" - << "\t\t {\n" - << "\t\t gentleZ = (abmajp - 1);\n" - << "\t\t }\n" - << "\t\t else\n" - << "\t\t {\n" - << "\t\t gentleZ = 1;\n" - << "\t\t }\n" - << "\n" - << "\t\t if (posNeg < 0)\n" - << "\t\t {\n" - << "\t\t vOut.z = -2 * (sumZ * gentleZ);\n" - << "\t\t }\n" - << "\t\t}\n" - << "\n" - << "\t\tif (majplane == 2 && " << majp << " < 0)\n" - << "\t\t{\n" - << "\t\t if (posNeg > 0)\n" - << "\t\t {\n" - << "\t\t vOut.z = (smooth * (vIn.z * scale * " << zlift << " + boost));\n" - << "\t\t }\n" - << "\t\t else\n" - << "\t\t {\n" - << "\t\t vOut.z = (sumZ - (2 * smooth * sumZ)) + (smooth * posNeg * (vIn.z * scale * " << zlift << " + boost));\n"; + << "\n" + << "\t\tif (fabs(lrmaj) <= 0.5)\n" + << "\t\t smooth = lrmaj * 2;\n" + << "\t\telse\n" + << "\t\t smooth = 1;\n" + << "\n" + << "\t\tint posNeg = 1;\n" + << "\t\tint loc;\n" + << "\t\treal_t boost = 0;\n" + << "\t\treal_t scale = " << scale << ";\n"//Temp will be used from here on. + << "\t\treal_t scale3;\n" + << "\t\treal_t tempx, tempy;\n" + << "\n" + << "\t\tif (MwcNext01(mwc) < 0.5)\n" + << "\t\t posNeg = -1;\n" + << "\n" + << "\t\tint majplane = 0;\n" + << "\t\treal_t abmajp = fabs(" << majp << ");\n" + << "\n" + << "\t\tif (abmajp <= 1)\n" + << "\t\t{\n" + << "\t\t majplane = 0;\n" + << "\t\t boost = 0;\n" + << "\t\t}\n" + << "\t\telse if (abmajp > 1 && abmajp < 2)\n" + << "\t\t{\n" + << "\t\t majplane = 1;\n" + << "\t\t boost = 0;\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t majplane = 2;\n" + << "\t\t boost = (abmajp - 2) * 0.5;\n" + << "\t\t}\n" + << "\n" + << "\t\tif (majplane == 0)\n" + << "\t\t{\n" + << "\t\t vOut.z = smooth * vIn.z * scale * " << zlift << ";\n" + << "\t\t}\n" + << "\t\telse if (majplane == 1 && " << majp << " < 0)\n" + << "\t\t{\n" + << "\t\t if (" << majp << " < -1 && " << majp << " >= -2)\n" + << "\t\t gentleZ = (abmajp - 1);\n" + << "\t\t else\n" + << "\t\t gentleZ = 1;\n" + << "\n" + << "\t\t if (posNeg < 0)\n" + << "\t\t vOut.z = -2 * (sumZ * gentleZ);\n" + << "\t\t}\n" + << "\n" + << "\t\tif (majplane == 2 && " << majp << " < 0)\n" + << "\t\t{\n" + << "\t\t if (posNeg > 0)\n" + << "\t\t {\n" + << "\t\t vOut.z = (smooth * (vIn.z * scale * " << zlift << " + boost));\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.z = (sumZ - (2 * smooth * sumZ)) + (smooth * posNeg * (vIn.z * scale * " << zlift << " + boost));\n"; - if (m_VarType != eVariationType::VARTYPE_PRE) + if (m_VarType == eVariationType::VARTYPE_REG) ss << "\t\t outPoint->m_Z = 0;\n"; ss - << "\t\t }\n" - << "\t\t}\n" - << "\t\telse\n" - << "\t\t{\n" - << "\t\t vOut.z = smooth * (vIn.z * scale * " << zlift << " + (posNeg * boost));\n" - << "\t\t}\n" - << "\n" - << "\t\tif (" << rswtch << " <= 1)\n" - << "\t\t{\n" - << "\t\t loc = (int)(MwcNext01(mwc) * 6);\n" - << "\t\t tempx = parVars[" << seg60xStartIndex << " + loc];\n" - << "\t\t tempy = parVars[" << seg60yStartIndex << " + loc];\n" - << "\t\t scale3 = 1;\n" - << "\t\t " << fcycle << " = " << fcycle << " + 1;\n" - << "\t\t}\n" - << "\t\telse\n" - << "\t\t{\n" - << "\t\t loc = (int)(MwcNext01(mwc) * 3);\n" - << "\t\t tempx = parVars[" << seg120xStartIndex << " + loc];\n" - << "\t\t tempy = parVars[" << seg120yStartIndex << " + loc];\n" - << "\t\t scale3 = " << side3 << ";\n" - << "\t\t " << bcycle << " = " << bcycle << " + 1;\n" - << "\t\t}\n" - << "\n" - << "\t\tsmRotxFP = (smooth * scale * sumX * tempx) - (smooth * scale * sumY * tempy);\n" - << "\t\tsmRotyFP = (smooth * scale * sumY * tempx) + (smooth * scale * sumX * tempy);\n" - << "\t\tsmRotxFT = (vIn.x * smooth * scale * tempx) - (vIn.y * smooth * scale * tempy);\n" - << "\t\tsmRotyFT = (vIn.y * smooth * scale * tempx) + (vIn.x * smooth * scale * tempy);\n" - << "\t\tvOut.x = sumX * (1 - smooth) + smRotxFP + smRotxFT + smooth * lrmaj * scale3 * tempx;\n" - << "\t\tvOut.y = sumY * (1 - smooth) + smRotyFP + smRotyFT + smooth * lrmaj * scale3 * tempy;\n" - << "\t}\n"; - + << "\t\t }\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t vOut.z = smooth * (vIn.z * scale * " << zlift << " + (posNeg * boost));\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << rswtch << " <= 1)\n" + << "\t\t{\n" + << "\t\t loc = (int)(MwcNext01(mwc) * 6);\n" + << "\t\t tempx = parVars[" << seg60xStartIndex << " + loc];\n" + << "\t\t tempy = parVars[" << seg60yStartIndex << " + loc];\n" + << "\t\t scale3 = 1;\n" + << "\t\t " << fcycle << " = " << fcycle << " + 1;\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t loc = (int)(MwcNext01(mwc) * 3);\n" + << "\t\t tempx = parVars[" << seg120xStartIndex << " + loc];\n" + << "\t\t tempy = parVars[" << seg120yStartIndex << " + loc];\n" + << "\t\t scale3 = " << side3 << ";\n" + << "\t\t " << bcycle << " = " << bcycle << " + 1;\n" + << "\t\t}\n" + << "\n" + << "\t\tsmRotxFP = (smooth * scale * sumX * tempx) - (smooth * scale * sumY * tempy);\n" + << "\t\tsmRotyFP = (smooth * scale * sumY * tempx) + (smooth * scale * sumX * tempy);\n" + << "\t\tsmRotxFT = (vIn.x * smooth * scale * tempx) - (vIn.y * smooth * scale * tempy);\n" + << "\t\tsmRotyFT = (vIn.y * smooth * scale * tempx) + (vIn.x * smooth * scale * tempy);\n" + << "\t\tvOut.x = sumX * (1 - smooth) + smRotxFP + smRotxFT + smooth * lrmaj * scale3 * tempx;\n" + << "\t\tvOut.y = sumY * (1 - smooth) + smRotyFP + smRotyFT + smooth * lrmaj * scale3 * tempy;\n" + << "\t}\n"; return ss.str(); } @@ -4153,20 +4018,17 @@ public: ss2 << "_" << XformIndexInEmber(); string stateIndex = ss2.str(); string prefix = Prefix(); - //CPU sets fycle and bcycle to 0 at the beginning in Precalc(). //Set to random in OpenCL since a value can't be set once and kept between kernel launches without writing it back to an OpenCL buffer. ss << "\n\t\tvarState." << prefix << "hexnix3D_rswtch" << stateIndex << " = trunc(MwcNext01(&mwc) * 3.0);"; ss << "\n\t\tvarState." << prefix << "hexnix3D_fcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * 5.0);"; ss << "\n\t\tvarState." << prefix << "hexnix3D_bcycle" << stateIndex << " = trunc(MwcNext01(&mwc) * 2.0);"; - return ss.str(); } virtual void Precalc() override { T hlift = std::sin(T(M_PI) / 3); - m_RSwtch = std::trunc(QTIsaac::LockedFrand01() * 3);//Chooses 6 or 3 nodes. m_FCycle = 0; m_BCycle = 0; @@ -4176,18 +4038,15 @@ public: m_Seg60[3].x = -1; m_Seg60[4].x = T(-0.5); m_Seg60[5].x = T(0.5); - m_Seg60[0].y = 0; m_Seg60[1].y = -hlift; m_Seg60[2].y = -hlift; m_Seg60[3].y = 0; m_Seg60[4].y = hlift; m_Seg60[5].y = hlift; - m_Seg120[0].x = 0; m_Seg120[1].x = std::cos(7 * T(M_PI) / 6); m_Seg120[2].x = std::cos(11 * T(M_PI) / 6); - m_Seg120[0].y = -1; m_Seg120[1].y = T(0.5); m_Seg120[2].y = T(0.5); @@ -4197,7 +4056,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.reserve(25); m_Params.push_back(ParamWithName(&m_MajP, prefix + "hexnix3D_majp", 1, eParamType::REAL)); @@ -4257,7 +4115,6 @@ public: { v2T i; int c = 0, n = -1, j = 5; - i.x = helper.In.x + m_CenterX; i.y = helper.In.y + m_CenterY; @@ -4293,7 +4150,6 @@ public: ss2 << "_" << XformIndexInEmber(); string index = ss2.str() + "]"; string stateIndex = ss2.str(); - string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string centerx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; @@ -4301,7 +4157,6 @@ public: string dropoff = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pxStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 6;//Precalc. string pyStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; - ss << "\t{\n" << "\t\treal2 i;\n" << "\t\tint c = 0, n = -1, j = 5;\n" @@ -4327,22 +4182,21 @@ public: if (m_VarType == eVariationType::VARTYPE_REG) { ss - << "\t\tvOut.x = c != 0 ? outPoint->m_X + i.x * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n" - << "\t\tvOut.y = c != 0 ? outPoint->m_Y + i.y * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n" - << "\t\toutPoint->m_X = 0;\n" - << "\t\toutPoint->m_Y = 0;\n"; + << "\t\tvOut.x = c != 0 ? outPoint->m_X + i.x * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n" + << "\t\tvOut.y = c != 0 ? outPoint->m_Y + i.y * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n" + << "\t\toutPoint->m_X = 0;\n" + << "\t\toutPoint->m_Y = 0;\n"; } else { ss - << "\t\tvOut.x = c != 0 ? i.x * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n" - << "\t\tvOut.y = c != 0 ? i.y * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n"; + << "\t\tvOut.x = c != 0 ? i.x * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n" + << "\t\tvOut.y = c != 0 ? i.y * xform->m_VariationWeights[" << varIndex << "] : " << dropoff << ";\n"; } ss - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" - << "\t}\n"; - + << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t}\n"; return ss.str(); } @@ -4366,7 +4220,6 @@ protected: void Init() { string prefix = Prefix(); - m_Params.clear(); m_Params.reserve(17); m_Params.push_back(ParamWithName(&m_ScaleX, prefix + "hexcrop_scale_x", 1)); diff --git a/Source/Ember/Variations06.h b/Source/Ember/Variations06.h index 1b32cd8..7eb0f3f 100644 --- a/Source/Ember/Variations06.h +++ b/Source/Ember/Variations06.h @@ -745,10 +745,7 @@ public: m_HasStripes = 1; if (m_NumStripes < 0) - { m_NegStripes = 1; - //m_NumStripes *= -1; - } else m_NegStripes = 0; } @@ -758,7 +755,7 @@ public: m_NegStripes = 0; } - m_AbsStripes = std::fabs(m_NumStripes); + m_AbsStripes = std::abs(m_NumStripes); m_MidAngle = M_2PI / m_NumEdges; if (m_HasStripes == 1) @@ -780,18 +777,12 @@ public: if (m_AdjustToLinear == 1) { if (int(m_NumEdges) % 4 == 0) - { m_AdjustedWeight = m_Weight / (std::sqrt(2 - 2 * std::cos(m_MidAngle * (m_NumEdges / 2 - 1))) / 2); - } else - { m_AdjustedWeight = m_Weight / (std::sqrt(2 - 2 * std::cos(m_MidAngle * std::floor((m_NumEdges / 2)))) / 2); - } } else - { m_AdjustedWeight = m_Weight; - } if (m_CircumCircle == 1) { @@ -854,7 +845,7 @@ private: T angXY, angMem, angTmp; T ratioTmp, ratioTmpNum, ratioTmpDen; T xTmp, yTmp; - T ranTmp; + T ranTmp, x; int count; if (params.ExactCalc == 1) @@ -926,14 +917,15 @@ private: if (((count & 1) == 0) && (params.RatioStripes < 1)) { - if ((std::fabs(angXY - angTmp) > params.SpeedCalc2) && (count != params.MaxStripes)) + if ((std::abs(angXY - angTmp) > params.SpeedCalc2) && (count != params.MaxStripes)) { if ((angXY - angTmp) > params.SpeedCalc2) { ratioTmpNum = (angXY - (angTmp + params.SpeedCalc2)) * params.SpeedCalc2; ratioTmpDen = params.AngStart - params.SpeedCalc2; ratioTmp = ratioTmpNum / ratioTmpDen; - sincos((angMem - angXY + angTmp + ratioTmp), ¶ms.X, ¶ms.Y); + x = angMem - angXY + angTmp + ratioTmp; + sincos(x, ¶ms.X, ¶ms.Y); angXY = angTmp + ratioTmp; } @@ -942,7 +934,8 @@ private: ratioTmpNum = (angTmp - params.SpeedCalc2 - angXY) * params.SpeedCalc2; ratioTmpDen = params.AngStart - params.SpeedCalc2; ratioTmp = ratioTmpNum / ratioTmpDen; - sincos((angMem - angXY + angTmp - ratioTmp), ¶ms.X, ¶ms.Y); + x = angMem - angXY + angTmp - ratioTmp; + sincos(x, ¶ms.X, ¶ms.Y); angXY = angTmp - ratioTmp; } } @@ -954,7 +947,8 @@ private: ratioTmpNum = (angTmp - params.SpeedCalc2 - angXY) * params.SpeedCalc2; ratioTmpDen = params.AngStart - params.SpeedCalc2; ratioTmp = ratioTmpNum / ratioTmpDen; - sincos((angMem - angXY + angTmp - ratioTmp), ¶ms.X, ¶ms.Y); + x = angMem - angXY + angTmp - ratioTmp; + sincos(x, ¶ms.X, ¶ms.Y); angXY = angTmp - ratioTmp; } } @@ -1003,14 +997,15 @@ private: if (((count & 1) == 1) && (params.RatioStripes < 1)) { - if ((std::fabs(angXY - angTmp) > params.SpeedCalc2) && (count != params.MaxStripes)) + if ((std::abs(angXY - angTmp) > params.SpeedCalc2) && (count != params.MaxStripes)) { if ((angXY - angTmp) > params.SpeedCalc2) { ratioTmpNum = (angXY - (angTmp + params.SpeedCalc2)) * params.SpeedCalc2; ratioTmpDen = params.AngStart - params.SpeedCalc2; ratioTmp = ratioTmpNum / ratioTmpDen; - sincos((angMem - angXY + angTmp + ratioTmp), ¶ms.X, ¶ms.Y); + x = angMem - angXY + angTmp + ratioTmp; + sincos(x, ¶ms.X, ¶ms.Y); angXY = angTmp + ratioTmp; } @@ -1019,7 +1014,8 @@ private: ratioTmpNum = (angTmp - params.SpeedCalc2 - angXY) * params.SpeedCalc2; ratioTmpDen = params.AngStart - params.SpeedCalc2; ratioTmp = ratioTmpNum / ratioTmpDen; - sincos((angMem - angXY + angTmp - ratioTmp), ¶ms.X, ¶ms.Y); + x = angMem - angXY + angTmp - ratioTmp; + sincos(x, ¶ms.X, ¶ms.Y); angXY = angTmp - ratioTmp; } } @@ -1033,7 +1029,8 @@ private: ratioTmpNum = (angTmp - params.SpeedCalc2 - angXY) * params.SpeedCalc2; ratioTmpDen = params.AngStart - params.SpeedCalc2; ratioTmp = ratioTmpNum / ratioTmpDen; - sincos((angMem - angXY + angTmp - ratioTmp), ¶ms.X, ¶ms.Y); + x = angMem - angXY + angTmp - ratioTmp; + sincos(x, ¶ms.X, ¶ms.Y); angXY = angTmp - ratioTmp; } } @@ -1344,10 +1341,10 @@ public: virtual void Precalc() override { static const T DENOM_SQRT2 = T(0.707106781); - m_AbsS = std::fabs(m_S); - m_AbsT = std::fabs(m_T); + m_AbsS = std::abs(m_S); + m_AbsT = std::abs(m_T); m_St = m_AbsS * T(0.5) + m_AbsT; - m_TempRad = DENOM_SQRT2 * m_AbsS * std::fabs(m_Radius); + m_TempRad = DENOM_SQRT2 * m_AbsS * std::abs(m_Radius); m_A = { -T(0.5)* m_AbsS, T(0.5)* m_AbsS + m_AbsT }; m_B = { T(0.5)* m_AbsS, T(0.5)* m_AbsS + m_AbsT }; m_C = { m_AbsT, T(0.5)* m_AbsS }; @@ -1409,7 +1406,7 @@ private: int HitsSquareAroundOrigin(T a, v2T& p) { - return (std::fabs(p.x) <= a && std::fabs(p.y) <= a); + return (std::abs(p.x) <= a && std::abs(p.y) <= a); } int HitsCircleAroundOrigin(T radius, v2T& p, T& r) @@ -1481,6 +1478,12 @@ public: PARVARCOPY(CrobVariation) + /// + /// Functions the specified helper. + /// + /// The helper. + /// The out point. + /// The rand. virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T gradTmp, secTmp, xTmp, yTmp; @@ -1489,20 +1492,10 @@ public: { if (m_Blur == 0) { - if (m_VarType == eVariationType::VARTYPE_PRE)//Setting input point. + if (m_VarType == eVariationType::VARTYPE_REG) { - helper.m_TransX = 0; - helper.m_TransY = 0; - } - else if (m_VarType == eVariationType::VARTYPE_REG) - { - helper.In.x = 0; - helper.In.y = 0; - } - else - { - outPoint.m_X = 0; - outPoint.m_Y = 0; + helper.In.x = helper.m_TransX = 0;//This will not only overwrite the current output point running sum, but also set + helper.In.y = helper.m_TransY = 0;//the affine transformed point so that any future variation that uses it directly will get the updated value. } } else @@ -1541,40 +1534,16 @@ public: xTmp = m_Left + m_Right - xTmp; } - if (m_VarType == eVariationType::VARTYPE_PRE) + if (m_VarType == eVariationType::VARTYPE_REG) { - helper.m_TransX = xTmp; - helper.m_TransY = yTmp; - } - else if (m_VarType == eVariationType::VARTYPE_REG) - { - helper.In.x = xTmp; - helper.In.y = yTmp; - } - else - { - outPoint.m_X = xTmp; - outPoint.m_Y = yTmp; + helper.In.x = helper.m_TransX = xTmp;//This will not only overwrite the current output point running sum, but also set + helper.In.y = helper.m_TransY = yTmp;//the affine transformed point so that any future variation that uses it directly will get the updated value. } } } - if (m_VarType == eVariationType::VARTYPE_PRE) - { - helper.Out.x = helper.m_TransX; - helper.Out.y = helper.m_TransY; - } - else if (m_VarType == eVariationType::VARTYPE_REG) - { - helper.Out.x = helper.In.x; - helper.Out.y = helper.In.y; - } - else - { - helper.Out.x = outPoint.m_X; - helper.Out.y = outPoint.m_Y; - } - + helper.Out.x = xTmp; + helper.Out.y = yTmp; helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; } @@ -1620,23 +1589,11 @@ public: << "\t\t if (" << blur << " == 0)\n" << "\t\t {\n"; - if (m_VarType == eVariationType::VARTYPE_PRE) + if (m_VarType == eVariationType::VARTYPE_REG) { ss - << "\t\t transX = 0;\n" - << "\t\t transY = 0;\n"; - } - else if (m_VarType == eVariationType::VARTYPE_REG) - { - ss - << "\t\t vIn.x = 0;\n" - << "\t\t vIn.y = 0;\n"; - } - else - { - ss - << "\t\t outPoint->m_X = 0;\n" - << "\t\t outPoint->m_Y = 0;\n"; + << "\t\t vIn.x = transX = 0;\n" + << "\t\t vIn.y = transY = 0;\n"; } ss @@ -1676,50 +1633,19 @@ public: << "\t\t }\n" << "\n"; - if (m_VarType == eVariationType::VARTYPE_PRE) + if (m_VarType == eVariationType::VARTYPE_REG) { ss - << "\t\t transX = xTmp;\n" - << "\t\t transY = yTmp;\n"; - } - else if (m_VarType == eVariationType::VARTYPE_REG) - { - ss - << "\t\t vIn.x = xTmp;\n" - << "\t\t vIn.y = yTmp;\n"; - } - else - { - ss - << "\t\t outPoint->m_X = xTmp;\n" - << "\t\t outPoint->m_Y = yTmp;\n"; + << "\t\t vIn.x = transX = xTmp;\n" + << "\t\t vIn.y = transY = yTmp;\n"; } ss << "\t\t\t}\n" << "\t\t}\n" - << "\n"; - - if (m_VarType == eVariationType::VARTYPE_PRE) - { - ss - << "\t\tvOut.x = transX;\n" - << "\t\tvOut.y = transY;\n"; - } - else if (m_VarType == eVariationType::VARTYPE_REG) - { - ss - << "\t\tvOut.x = vIn.x;\n" - << "\t\tvOut.y = vIn.y;\n"; - } - else - { - ss - << "\t\tvOut.x = outPoint->m_X;\n" - << "\t\tvOut.y = outPoint->m_Y;\n"; - } - - ss + << "\n" + << "\t\tvOut.x = xTmp;\n" + << "\t\tvOut.y = yTmp;\n" << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" << "\t}\n"; return ss.str(); @@ -1751,8 +1677,8 @@ public: if (m_Blur != 0) m_Blur = 1; - m_XInterval = std::fabs(m_Right) - m_Left; - m_YInterval = std::fabs(m_Bottom) - m_Top; + m_XInterval = std::abs(m_Right) - m_Left; + m_YInterval = std::abs(m_Bottom) - m_Top; m_XInt2 = m_XInterval / 2; m_YInt2 = m_YInterval / 2; @@ -1889,7 +1815,7 @@ public: { T x = helper.In.x, y = helper.In.y, z = helper.In.z; T xTmp, yTmp, angTmp, angRot, fac; - T rad = helper.m_PrecalcSumSquares / 4 + 1; + T rad = Zeps(helper.m_PrecalcSumSquares / 4 + 1); T angXY, angZ; T c, s; angXY = std::atan2(x, y); @@ -1924,7 +1850,7 @@ public: } else { - angRot = (angXY - m_AngStrip1) / (m_AngStrip2 - m_AngStrip1); + angRot = (angXY - m_AngStrip1) / Zeps(m_AngStrip2 - m_AngStrip1); angRot = angXY - angRot * m_AngStrip1; sincos(angRot, &s, &c); xTmp = c * x - s * y; @@ -1976,9 +1902,9 @@ public: z = 2 / std::pow(rad, m_ExponentZ) - 1; if (m_ExponentZ <= 2) - angZ = T(M_PI) - std::acos((z / (Sqr(x) + Sqr(y) + Sqr(z)))); + angZ = T(M_PI) - std::acos((z / (SQR(x) + SQR(y) + SQR(z)))); else - angZ = T(M_PI) - std::atan2(Sqr(Sqr(x) + Sqr(y)), z); + angZ = T(M_PI) - std::atan2(Sqr(SQR(x) + SQR(y)), z); } else { @@ -2000,12 +1926,12 @@ public: } else { - angTmp = (T(M_PI) - angZ) / m_AngHoleComp * m_AngleHoleTemp - T(M_PI_2); + angTmp = (T(M_PI) - angZ) / Zeps(m_AngHoleComp * m_AngleHoleTemp - T(M_PI_2)); angZ -= T(M_PI_2); fac = std::cos(angTmp) / std::cos(angZ); - x = x * fac; - y = y * fac; - z = z * (std::sin(angTmp) / std::sin(angZ)); + x *= fac; + y *= fac; + z *= (std::sin(angTmp) / std::sin(angZ)); } } } @@ -2021,12 +1947,12 @@ public: } else { - angTmp = T(M_PI) - angZ / m_AngHoleComp * m_AngleHoleTemp - T(M_PI_2); + angTmp = T(M_PI) - angZ / Zeps(m_AngHoleComp * m_AngleHoleTemp - T(M_PI_2)); angZ -= T(M_PI_2); fac = std::cos(angTmp) / std::cos(angZ); - x = x * fac; - y = y * fac; - z = z * (std::sin(angTmp) / std::sin(angZ)); + x *= fac; + y *= fac; + z *= (std::sin(angTmp) / std::sin(angZ)); } } } @@ -2044,19 +1970,15 @@ public: else { if (angZ > m_AngleHoleTemp) - { angTmp = (T(M_PI) - angZ) / m_AngHoleComp * (T(M_PI) - 2 * m_AngHoleComp) + m_AngHoleComp - T(M_PI_2); - } else - { angTmp = T(M_PI_2) - (angZ / m_AngHoleComp * (T(M_PI) - 2 * m_AngHoleComp) + m_AngHoleComp); - } angZ -= T(M_PI_2); fac = std::cos(angTmp) / std::cos(angZ); - x = x * fac; - y = y * fac; - z = z * (std::sin(angTmp) / std::sin(angZ)); + x *= fac; + y *= fac; + z *= (std::sin(angTmp) / std::sin(angZ)); } } } @@ -2091,7 +2013,7 @@ public: ss << "\t{\n" "\t\treal_t x = vIn.x, y = vIn.y, z = vIn.z;\n" "\t\treal_t xTmp, yTmp, angTmp, angRot, fac;\n" - "\t\treal_t rad = precalcSumSquares / 4 + 1;\n" + "\t\treal_t rad = Zeps(precalcSumSquares / 4 + 1);\n" "\t\treal_t angXY, angZ;\n" "\t\treal_t c, s;\n" "\t\t\n" @@ -2127,7 +2049,7 @@ public: "\t\t }\n" "\t\t else\n" "\t\t {\n" - "\t\t angRot = (angXY - " << angStrip1 << ") / (" << angStrip2 << " - " << angStrip1 << ");\n" + "\t\t angRot = (angXY - " << angStrip1 << ") / Zeps(" << angStrip2 << " - " << angStrip1 << ");\n" "\t\t angRot = angXY - angRot * " << angStrip1 << ";\n" "\t\t s = sincos(angRot, &c);\n" "\t\t xTmp = c * x - s * y;\n" @@ -2179,9 +2101,9 @@ public: "\t\t z = 2 / pow(rad, " << exponentZ << ") - 1;\n" "\t\t\n" "\t\t if (" << exponentZ << " <= 2)\n" - "\t\t angZ = M_PI - acos((z / (Sqr(x) + Sqr(y) + Sqr(z))));\n" + "\t\t angZ = M_PI - acos((z / (SQR(x) + SQR(y) + SQR(z))));\n" "\t\t else\n" - "\t\t angZ = M_PI - atan2(Sqr(Sqr(x) + Sqr(y)), z);\n" + "\t\t angZ = M_PI - atan2(Sqr(SQR(x) + SQR(y)), z);\n" "\t\t}\n" "\t\telse\n" "\t\t{\n" @@ -2203,12 +2125,12 @@ public: "\t\t }\n" "\t\t else\n" "\t\t {\n" - "\t\t angTmp = (M_PI - angZ) / " << angHoleComp << " * " << angHoleTemp << " - M_PI_2;\n" + "\t\t angTmp = (M_PI - angZ) / Zeps(" << angHoleComp << " * " << angHoleTemp << " - M_PI_2);\n" "\t\t angZ -= M_PI_2;\n" "\t\t fac = cos(angTmp) / cos(angZ);\n" - "\t\t x = x * fac;\n" - "\t\t y = y * fac;\n" - "\t\t z = z * (sin(angTmp) / sin(angZ));\n" + "\t\t x *= fac;\n" + "\t\t y *= fac;\n" + "\t\t z *= (sin(angTmp) / sin(angZ));\n" "\t\t }\n" "\t\t }\n" "\t\t }\n" @@ -2224,12 +2146,12 @@ public: "\t\t }\n" "\t\t else\n" "\t\t {\n" - "\t\t angTmp = M_PI - angZ / " << angHoleComp << " * " << angHoleTemp << " - M_PI_2;\n" + "\t\t angTmp = M_PI - angZ / Zeps(" << angHoleComp << " * " << angHoleTemp << " - M_PI_2);\n" "\t\t angZ -= M_PI_2;\n" "\t\t fac = cos(angTmp) / cos(angZ);\n" - "\t\t x = x * fac;\n" - "\t\t y = y * fac;\n" - "\t\t z = z * (sin(angTmp) / sin(angZ));\n" + "\t\t x *= fac;\n" + "\t\t y *= fac;\n" + "\t\t z *= (sin(angTmp) / sin(angZ));\n" "\t\t }\n" "\t\t }\n" "\t\t }\n" @@ -2247,19 +2169,15 @@ public: "\t\t else\n" "\t\t {\n" "\t\t if (angZ > " << angHoleTemp << ")\n" - "\t\t {\n" "\t\t angTmp = (M_PI - angZ) / " << angHoleComp << " * (M_PI - 2 * " << angHoleComp << ") + " << angHoleComp << " - M_PI_2;\n" - "\t\t }\n" "\t\t else\n" - "\t\t {\n" "\t\t angTmp = M_PI_2 - (angZ / " << angHoleComp << " * (M_PI - 2 * " << angHoleComp << ") + " << angHoleComp << ");\n" - "\t\t }\n" - "\t\t\n" + "\n" "\t\t angZ -= M_PI_2;\n" "\t\t fac = cos(angTmp) / cos(angZ);\n" - "\t\t x = x * fac;\n" - "\t\t y = y * fac;\n" - "\t\t z = z * (sin(angTmp) / sin(angZ));\n" + "\t\t x *= fac;\n" + "\t\t y *= fac;\n" + "\t\t z *= (sin(angTmp) / sin(angZ));\n" "\t\t }\n" "\t\t }\n" "\t\t}\n" @@ -2273,14 +2191,14 @@ public: virtual vector OpenCLGlobalFuncNames() const override { - return vector { "Sqr" }; + return vector { "Sqr", "Zeps" }; } virtual void Precalc() override { if (m_NumberStripes < 0) { - m_AbsNumberStripes = std::fabs(m_NumberStripes); + m_AbsNumberStripes = std::abs(m_NumberStripes); m_InvStripes = 1; } else @@ -2295,13 +2213,13 @@ public: m_AngStrip2 = 2 * m_AngStrip; sincos(m_AngStrip, &m_S, &m_C); ClampRef(m_RatioStripes, T(0.01), T(1.99)); - m_AngStrip1 = m_RatioStripes * m_AngStrip; + m_AngStrip1 = Zeps(m_RatioStripes * m_AngStrip); } if (m_SymmetryZ == 1) { if (m_AngleHole < 0) - m_AngleHoleTemp = std::fabs(m_AngleHole); + m_AngleHoleTemp = std::abs(m_AngleHole); else if (m_AngleHole > T(179.9)) m_AngleHoleTemp = T(179.9); else @@ -2312,7 +2230,7 @@ public: if (m_AngleHoleTemp < 0) { - m_AngleHoleTemp = std::fabs(m_AngleHole); + m_AngleHoleTemp = std::abs(m_AngleHole); m_InvHole = 1; m_AngleHoleTemp = (m_AngleHoleTemp / 360 * M_2PI) / 2; } @@ -3520,7 +3438,7 @@ private: // Control points are (0,0), (m,m) and (1,m) t = x; // Special case when m == 0.5 - if (std::fabs(m - T(0.5)) > 1e-10) + if (std::abs(m - T(0.5)) > 1e-10) t = (-1 * m + std::sqrt(m * m + (1 - 2 * m) * x)) / (1 - 2 * m); return a * (x + (m - 1) * t * t); @@ -3533,7 +3451,7 @@ private: // Control points are (0,0), (iM,iM) and (1,m) t = x; // Special case when m == 2 - if (std::fabs(m - 2) > 1e-10) + if (std::abs(m - 2) > 1e-10) t = (-1 * iM + std::sqrt(iM * iM + (1 - 2 * iM) * x)) / (1 - 2 * iM); return a * (x + (m - 1) * t * t); @@ -3650,12 +3568,11 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - int di, dj; int i = 0; T l, r, trgL; v2T u, dO; glm::ivec2 cv; - v2T p[VORONOI_MAXPOINTS]; + v2T p[VORONOI_MAXPOINTS] = { v2T(0), v2T(0), v2T(0), v2T(0), v2T(0), v2T(0), v2T(0), v2T(0), v2T(0), v2T(0) }; if (m_CellSize == 0) return; @@ -3667,9 +3584,9 @@ public: cv.x = int(std::floor(u.x / m_HalfCellSize)); cv.y = int(std::floor(u.y / m_HalfCellSize)); - for (di = -1; di < 2; di++) + for (int di = -1; di < 2; di++) { - for (dj = -1; dj < 2; dj++) + for (int dj = -1; dj < 2; dj++) { CachedPosition(m_C, cv.x + di, cv.y + dj, m_Z, m_HalfCellSize, m_Distort, p[i]); i++; @@ -3677,16 +3594,16 @@ public: } int q = m_VarFuncs->Closest(p, 9, u); - glm::ivec2 offset[9] = { { -1, -1 }, { -1, 0 }, { -1, 1 }, + static glm::ivec2 offset[9] = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 0 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } }; cv += offset[q]; i = 0; - for (di = -1; di < 2; di++) + for (int di = -1; di < 2; di++) { - for (dj = -1; dj < 2; dj++) + for (int dj = -1; dj < 2; dj++) { CachedPosition(m_C, cv.x + di, cv.y + dj, m_Z, m_HalfCellSize, m_Distort, p[i]); i++; @@ -3695,7 +3612,7 @@ public: l = m_VarFuncs->Voronoi(p, 9, 4, u); dO = u - p[4]; - trgL = std::pow(Zeps(l), m_Power) * m_Scale; + trgL = std::pow(std::abs(Zeps(l)), m_Power) * m_Scale; r = trgL / Zeps(l); dO *= r; dO += p[4]; @@ -3793,7 +3710,7 @@ public: << "\n" << "\t\tl = Voronoi(p, 9, 4, &u);\n" << "\t\tdO = u - p[4];\n" - << "\t\ttrgL = pow(Zeps(l), " << power << ") * " << scale << ";\n" + << "\t\ttrgL = pow(fabs(Zeps(l)), " << power << ") * " << scale << ";\n" << "\t\tr = trgL / Zeps(l);\n" << "\t\tdO *= r;\n" << "\t\tdO += p[4];\n" @@ -3806,11 +3723,10 @@ public: virtual void Precalc() override { - int x, y; m_HalfCellSize = Zeps(m_CellSize / 2); - for (x = -CACHE_NUM; x <= CACHE_NUM; x++) - for (y = -CACHE_NUM; y <= CACHE_NUM; y++) + for (int x = -CACHE_NUM; x <= CACHE_NUM; x++) + for (int y = -CACHE_NUM; y <= CACHE_NUM; y++) Position(x, y, m_Z, m_HalfCellSize, m_Distort, m_C[x + CACHE_NUM][y + CACHE_NUM]); } @@ -3863,6 +3779,513 @@ private: std::shared_ptr> m_VarFuncs; }; +/// +/// post_smartcrop. +/// This variation is special in that it only exists as a post_. +/// +template +class EMBER_API PostSmartcropVariation : public ParametricVariation +{ +public: + PostSmartcropVariation(T weight = 1.0) : ParametricVariation("post_smartcrop", eVariationId::VAR_POST_SMARTCROP, weight, true) + { + m_AssignType = eVariationAssignType::ASSIGNTYPE_SET; + m_VarType = eVariationType::VARTYPE_POST;//Very special usage, post only. + Init(); + } + + PARVARCOPY(PostSmartcropVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + bool lastPart = true; + T xi, yi, zi; + int iMode = int(m_Mode); + + //Extremely strange usage, where a post variation wants the original affine transformed points. + if (m_Static > 1) + { + xi = helper.In.x; + yi = helper.In.y; + zi = helper.In.z; + } + else + { + xi = helper.m_TransX; + yi = helper.m_TransY; + zi = helper.m_TransZ; + } + + T ang = std::atan2(yi, xi); + T rad = std::sqrt(SQR(xi) + SQR(yi)); + + if (m_Radial) + { + T edge = m_Edge * (rand.Frand01() - T(0.5)); + T xang = ang / M_2PI + 1 + edge; + xang = (xang - int(xang)) * M_2PI; + + if (int(xang > m_WorkPower) == iMode) + { + if (m_Cropmode == 2) + { + if (m_Static > 1 || m_Static == -1) + { + helper.Out.x = m_X;//This is post only with an assign type of SET, so no need to set m_* to 0 after these (or any other) direct assignments. + helper.Out.y = m_Y; + helper.Out.z = m_Z; + } + else + { + helper.Out.x = helper.In.x + m_X;//Original specifically summed the running sum point. + helper.Out.y = helper.In.y + m_Y; + helper.Out.z = helper.In.z + m_Z; + } + + outPoint.m_ColorX = m_C; + } + else + { + T x, s, c; + x = ((int)(rand.Frand01() * 2)) ? m_WorkPower + (rand.Frand01() * m_Scatter + m_Offset + edge) * T(M_PI) : -(rand.Frand01() * m_Scatter + m_Offset + edge) * T(M_PI); + sincos(x, &s, &c); + + if (m_Static > 1 || m_Static == -1) + { + helper.Out.x = m_Weight * rad * c; + helper.Out.y = m_Weight * rad * s; + helper.Out.z = m_Weight * zi; + } + else + { + helper.Out.x = helper.In.x + (m_Weight * rad * c);//Original specifically summed the running sum point. + helper.Out.y = helper.In.y + (m_Weight * rad * s); + helper.Out.z = helper.In.z + (m_Weight * zi); + } + } + + lastPart = false; + } + } + else + { + T coeff; + + if (m_Distortion == 0) + { + coeff = 1; + } + else + { + T xang = (ang + T(M_PI)) / m_Alpha; + xang = xang - int(xang); + xang = (xang < T(0.5)) ? xang : 1 - xang; + coeff = 1 / std::cos(xang * m_Alpha); + + if (m_Roundstr != 0) + { + T wwidth = ((m_Roundwidth != 1) ? std::exp(std::log(xang * 2) * m_Roundwidth) : (xang * 2)) * m_RoundCoeff; + coeff = abs((1 - wwidth) * coeff + wwidth); + } + + if (m_Distortion != 1) + coeff = std::exp(std::log(coeff) * m_Distortion); + } + + T xr = coeff * ((m_Edge != 0) ? m_WorkRadius + m_Edge * (rand.Frand01() - T(0.5)) : m_WorkRadius); + + if ((rad > xr) == iMode) + { + if (m_Cropmode) + { + if (m_Cropmode == 2) + { + if (m_Static > 1 || m_Static == -1) + { + helper.Out.x = m_X; + helper.Out.y = m_Y; + helper.Out.z = m_Z; + } + else + { + helper.Out.x = helper.In.x + m_X;//Original specifically summed the running sum point. + helper.Out.y = helper.In.y + m_Y; + helper.Out.z = helper.In.z + m_Z; + } + + outPoint.m_ColorX = m_C; + } + else + { + T rdc = (m_Cropmode == -1) ? rad : xr + coeff * (rand.Frand01() * m_Scatter + m_Offset); + T x, s, c; + x = ang + m_WorkRotation; + sincos(x, &s, &c); + + if (m_Static > 1 || m_Static == -1) + { + helper.Out.x = m_Weight * rdc * c; + helper.Out.y = m_Weight * rdc * s; + helper.Out.z = m_Weight * zi; + } + else + { + helper.Out.x = helper.In.x + (m_Weight * rdc * c); + helper.Out.y = helper.In.y + (m_Weight * rdc * s); + helper.Out.z = helper.In.z + (m_Weight * zi); + } + } + } + else + { + if (m_Static > 1 || m_Static == -1) + { + helper.Out.x = 0; + helper.Out.y = 0; + helper.Out.z = 0; + } + } + + lastPart = false; + } + } + + if (lastPart) + { + if (m_Static == 3) + { + m_X = m_Weight * helper.m_TransX;//Another case where it wants the original affine transformed points. + m_Y = m_Weight * helper.m_TransY; + m_Z = m_Weight * helper.m_TransZ; + } + else + { + m_X = m_Weight * xi; + m_Y = m_Weight * yi; + m_Z = m_Weight * zi; + } + + if (m_Cropmode == 2) + m_C = outPoint.m_ColorX; + + if (m_Static > 0) + { + helper.Out.x = m_X; + helper.Out.y = m_Y; + helper.Out.z = m_Z; + } + else + { + helper.Out.x = helper.In.x + m_X;//Original specifically summed the running sum point. + helper.Out.y = helper.In.y + m_Y; + helper.Out.z = helper.In.z + m_Z; + } + } + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber(); + string index = ss2.str() + "]"; + string stateIndex = ss2.str(); + string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string radius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string roundstr = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string roundwidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string distortion = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string edge = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cropmode = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string staticc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string mode = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string radial = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string workradius = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string workpower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string roundcoeff = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string workrotation = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string x = "varState->" + m_Params[i++].Name() + stateIndex;//State. + string y = "varState->" + m_Params[i++].Name() + stateIndex; + string z = "varState->" + m_Params[i++].Name() + stateIndex; + string c = "varState->" + m_Params[i++].Name() + stateIndex; + ss << "\t{\n" + << "\t\tint lastPart = 1;\n" + << "\t\treal_t xi, yi, zi;\n" + << "\t\tint iMode = (int)" << mode << ";\n" + << "\n" + << "\t\tif (" << staticc << " > 1)\n" + << "\t\t{\n" + << "\t\t xi = vIn.x;\n" + << "\t\t yi = vIn.y;\n" + << "\t\t zi = vIn.z;\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t xi = transX;\n" + << "\t\t yi = transY;\n" + << "\t\t zi = transZ;\n" + << "\t\t}\n" + << "\n" + << "\t\treal_t ang = atan2(yi, xi);\n" + << "\t\treal_t rad = sqrt(SQR(xi) + SQR(yi));\n" + << "\n" + << "\t\tif (" << radial << ")\n" + << "\t\t{\n" + << "\t\t real_t edge = " << edge << " * (MwcNext01(mwc) - 0.5);\n" + << "\t\t real_t xang = ang / M_2PI + 1 + edge;\n" + << "\t\t xang = (xang - (int)xang) * M_2PI;\n" + << "\n" + << "\t\t if ((int)(xang > " << workpower << ") == iMode)\n" + << "\t\t {\n" + << "\t\t if (" << cropmode << " == 2)\n" + << "\t\t {\n" + << "\t\t if (" << staticc << " > 1 || " << staticc << " == -1)\n" + << "\t\t {\n" + << "\t\t vOut.x = " << x << ";\n" + << "\t\t vOut.y = " << y << ";\n" + << "\t\t vOut.z = " << z << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.x = vIn.x + " << x << ";\n" + << "\t\t vOut.y = vIn.y + " << y << ";\n" + << "\t\t vOut.z = vIn.z + " << z << ";\n" + << "\t\t }\n" + << "\n" + << "\t\t outPoint->m_ColorX = " << c << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t real_t x, s, c;\n" + << "\t\t x = ((int)(MwcNext01(mwc) * 2)) ? " << workpower << " + (MwcNext01(mwc) * " << scatter << " + " << offset << " + edge) * M_PI : -(MwcNext01(mwc) * " << scatter << " + " << offset << " + edge) * M_PI;\n" + << "\t\t s = sincos(x, &c);\n" + << "\n" + << "\t\t if (" << staticc << " > 1 || " << staticc << " == -1)\n" + << "\t\t {\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * rad * c;\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * rad * s;\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * zi;\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.x = vIn.x + (xform->m_VariationWeights[" << varIndex << "] * rad * c);\n" + << "\t\t vOut.y = vIn.y + (xform->m_VariationWeights[" << varIndex << "] * rad * s);\n" + << "\t\t vOut.z = vIn.z + (xform->m_VariationWeights[" << varIndex << "] * zi);\n" + << "\t\t }\n" + << "\t\t }\n" + << "\n" + << "\t\t lastPart = 0;\n" + << "\t\t }\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t real_t coeff;\n" + << "\n" + << "\t\t if (" << distortion << " == 0)\n" + << "\t\t {\n" + << "\t\t coeff = 1;\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t real_t xang = (ang + M_PI) / " << alpha << ";\n" + << "\t\t xang = xang - (int)xang;\n" + << "\t\t xang = (xang < 0.5) ? xang : 1 - xang;\n" + << "\t\t coeff = 1 / cos(xang * " << alpha << ");\n" + << "\n" + << "\t\t if (" << roundstr << " != 0)\n" + << "\t\t {\n" + << "\t\t real_t wwidth = ((" << roundwidth << " != 1) ? exp(log(xang * 2) * " << roundwidth << ") : (xang * 2)) * " << roundcoeff << ";\n" + << "\t\t coeff = fabs((1 - wwidth) * coeff + wwidth);\n" + << "\t\t }\n" + << "\n" + << "\t\t if (" << distortion << " != 1)\n" + << "\t\t coeff = exp(log(coeff) * " << distortion << ");\n" + << "\t\t }\n" + << "\n" + << "\t\t real_t xr = coeff * ((" << edge << " != 0) ? " << workradius << " + " << edge << " * (MwcNext01(mwc) - 0.5) : " << workradius << ");\n" + << "\n" + << "\t\t if ((int)(rad > xr) == iMode)\n" + << "\t\t {\n" + << "\t\t if (" << cropmode << ")\n" + << "\t\t {\n" + << "\t\t if (" << cropmode << " == 2)\n" + << "\t\t {\n" + << "\t\t if (" << staticc << " > 1 || " << staticc << " == -1)\n" + << "\t\t {\n" + << "\t\t vOut.x = " << x << ";\n" + << "\t\t vOut.y = " << y << ";\n" + << "\t\t vOut.z = " << z << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.x = vIn.x + " << x << ";\n" + << "\t\t vOut.y = vIn.y + " << y << ";\n" + << "\t\t vOut.z = vIn.z + " << z << ";\n" + << "\t\t }\n" + << "\n" + << "\t\t outPoint->m_ColorX = " << c << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t real_t rdc = (" << cropmode << " == -1) ? rad : xr + coeff * (MwcNext01(mwc) * " << scatter << " + " << offset << ");\n" + << "\t\t real_t x, s, c;\n" + << "\t\t x = ang + " << workrotation << ";\n" + << "\t\t s = sincos(x, &c);\n" + << "\n" + << "\t\t if (" << staticc << " > 1 || " << staticc << " == -1)\n" + << "\t\t {\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * rdc * c;\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * rdc * s;\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * zi;\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.x = vIn.x + (xform->m_VariationWeights[" << varIndex << "] * rdc * c);\n" + << "\t\t vOut.y = vIn.y + (xform->m_VariationWeights[" << varIndex << "] * rdc * s);\n" + << "\t\t vOut.z = vIn.z + (xform->m_VariationWeights[" << varIndex << "] * zi);\n" + << "\t\t }\n" + << "\t\t }\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t if (" << staticc << " > 1 || " << staticc << " == -1)\n" + << "\t\t {\n" + << "\t\t vOut.x = 0;\n" + << "\t\t vOut.y = 0;\n" + << "\t\t vOut.z = 0;\n" + << "\t\t }\n" + << "\t\t }\n" + << "\n" + << "\t\t lastPart = 0;\n" + << "\t\t }\n" + << "\t\t}\n" + << "\n" + << "\t\tif (lastPart)\n" + << "\t\t{\n" + << "\t\t if (" << staticc << " == 3)\n" + << "\t\t {\n" + << "\t\t " << x << " = xform->m_VariationWeights[" << varIndex << "] * transX;\n" + << "\t\t " << y << " = xform->m_VariationWeights[" << varIndex << "] * transY;\n" + << "\t\t " << z << " = xform->m_VariationWeights[" << varIndex << "] * transZ;\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t " << x << " = xform->m_VariationWeights[" << varIndex << "] * xi;\n" + << "\t\t " << y << " = xform->m_VariationWeights[" << varIndex << "] * yi;\n" + << "\t\t " << z << " = xform->m_VariationWeights[" << varIndex << "] * zi;\n" + << "\t\t }\n" + << "\n" + << "\t\t if (" << cropmode << " == 2)\n" + << "\t\t " << c << " = outPoint->m_ColorX;\n" + << "\n" + << "\t\t if (" << staticc << " > 0)\n" + << "\t\t {\n" + << "\t\t vOut.x = " << x << ";\n" + << "\t\t vOut.y = " << y << ";\n" + << "\t\t vOut.z = " << z << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.x = vIn.x + " << x << ";\n" + << "\t\t vOut.y = vIn.y + " << y << ";\n" + << "\t\t vOut.z = vIn.z + " << z << ";\n" + << "\t\t }\n" + << "\t\t}\n" + << "\t}\n"; + return ss.str(); + } + + virtual string StateInitOpenCLString() const override + { + ostringstream ss, ss2; + ss2 << "_" << XformIndexInEmber(); + string stateIndex = ss2.str(); + string prefix = Prefix(); + ss << "\n\t\tvarState." << prefix << "smartcrop_x" << stateIndex << " = 0;"; + ss << "\n\t\tvarState." << prefix << "smartcrop_y" << stateIndex << " = 0;"; + ss << "\n\t\tvarState." << prefix << "smartcrop_z" << stateIndex << " = 0;"; + ss << "\n\t\tvarState." << prefix << "smartcrop_c" << stateIndex << " = 0;"; + return ss.str(); + } + + virtual void Precalc() override + { + m_Mode = T(((m_Power > 0) == (m_Radius > 0)) ? 1 : 0); + m_WorkRadius = std::abs(m_Radius); + m_WorkPower = std::abs(Zeps(m_Power)); + + if (m_WorkPower < 2) + { + m_WorkPower = m_WorkPower * T(M_PI); + m_Radial = 1; + } + else + { + m_Radial = 0; + m_Alpha = M_2PI / m_WorkPower; + m_RoundCoeff = m_Roundstr / Zeps(std::sin(m_Alpha / 2)) / m_WorkPower * 2; + m_WorkRotation = m_Rotation * m_Alpha; + } + + m_X = m_Y = m_Z = m_C = 0; + } +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Power , prefix + "smartcrop_power", 4)); //Original used a prefix of scrop_, which is incompatible with Ember's design. + m_Params.push_back(ParamWithName(&m_Radius , prefix + "smartcrop_radius", 1)); + m_Params.push_back(ParamWithName(&m_Roundstr , prefix + "smartcrop_roundstr")); + m_Params.push_back(ParamWithName(&m_Roundwidth, prefix + "smartcrop_roundwidth", 1)); + m_Params.push_back(ParamWithName(&m_Distortion, prefix + "smartcrop_distortion", 1)); + m_Params.push_back(ParamWithName(&m_Edge , prefix + "smartcrop_edge")); + m_Params.push_back(ParamWithName(&m_Scatter , prefix + "smartcrop_scatter")); + m_Params.push_back(ParamWithName(&m_Offset , prefix + "smartcrop_offset")); + m_Params.push_back(ParamWithName(&m_Rotation , prefix + "smartcrop_rotation")); + m_Params.push_back(ParamWithName(&m_Cropmode , prefix + "smartcrop_cropmode", 1, eParamType::INTEGER, -1, 2)); + m_Params.push_back(ParamWithName(&m_Static , prefix + "smartcrop_static", 1, eParamType::INTEGER, -1, 3)); + m_Params.push_back(ParamWithName(true, &m_Mode, prefix + "smartcrop_mode"));//Precalc. + m_Params.push_back(ParamWithName(true, &m_Radial, prefix + "smartcrop_radial")); + m_Params.push_back(ParamWithName(true, &m_WorkRadius, prefix + "smartcrop_work_radius")); + m_Params.push_back(ParamWithName(true, &m_WorkPower, prefix + "smartcrop_work_power")); + m_Params.push_back(ParamWithName(true, &m_Alpha, prefix + "smartcrop_alpha")); + m_Params.push_back(ParamWithName(true, &m_RoundCoeff, prefix + "smartcrop_round_coeff")); + m_Params.push_back(ParamWithName(true, &m_WorkRotation, prefix + "smartcrop_work_rotation")); + m_Params.push_back(ParamWithName(true, true, &m_X, prefix + "smartcrop_x"));//State. + m_Params.push_back(ParamWithName(true, true, &m_Y, prefix + "smartcrop_y")); + m_Params.push_back(ParamWithName(true, true, &m_Z, prefix + "smartcrop_z")); + m_Params.push_back(ParamWithName(true, true, &m_C, prefix + "smartcrop_c")); + } +private: + T m_Power; + T m_Radius; + T m_Roundstr; + T m_Roundwidth; + T m_Distortion; + T m_Edge; + T m_Scatter; + T m_Offset; + T m_Rotation; + T m_Cropmode; + T m_Static; + T m_Mode;//Precalc. + T m_Radial; + T m_WorkRadius; + T m_WorkPower; + T m_Alpha; + T m_RoundCoeff; + T m_WorkRotation; + T m_X;//State. + T m_Y; + T m_Z; + T m_C; +}; + MAKEPREPOSTPARVAR(Hexes, hexes, HEXES) MAKEPREPOSTPARVAR(Nblur, nBlur, NBLUR) MAKEPREPOSTPARVAR(Octapol, octapol, OCTAPOL) diff --git a/Source/Ember/VariationsDC.h b/Source/Ember/VariationsDC.h index ed51647..476b27b 100644 --- a/Source/Ember/VariationsDC.h +++ b/Source/Ember/VariationsDC.h @@ -42,7 +42,7 @@ public: T tempX = helper.Out.x + sumX; T tempY = helper.Out.y + sumY; - outPoint.m_ColorX = fmod(fabs(m_Bdcs * (Sqr(tempX + m_CenterX) + Sqr(tempY + m_CenterY))), T(1.0)); + outPoint.m_ColorX = fmod(std::abs(m_Bdcs * (Sqr(tempX + m_CenterX) + Sqr(tempY + m_CenterY))), T(1.0)); } virtual string OpenCLString() const override @@ -141,7 +141,7 @@ public: helper.Out.x = m_Weight * (m_Xform->m_Affine.A() * x + m_Xform->m_Affine.B() * y + m_Xform->m_Affine.E()); helper.Out.y = m_Weight * (m_Xform->m_Affine.C() * x + m_Xform->m_Affine.D() * y + m_Xform->m_Affine.F()); helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; - outPoint.m_ColorX = fmod(fabs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0)); + outPoint.m_ColorX = fmod(std::abs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0)); } virtual string OpenCLString() const override @@ -415,7 +415,7 @@ public: T tempX = helper.Out.x + sumX; T tempY = helper.Out.y + sumY; - outPoint.m_ColorX = fmod(fabs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + 1)), T(1.0)); + outPoint.m_ColorX = fmod(std::abs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + 1)), T(1.0)); } virtual string OpenCLString() const override @@ -715,7 +715,7 @@ public: T tempX = helper.Out.x + sumX; T tempY = helper.Out.y + sumY; - outPoint.m_ColorX = fmod(fabs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + T(1.0))), T(1.0)); + outPoint.m_ColorX = fmod(std::abs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + T(1.0))), T(1.0)); } virtual string OpenCLString() const override @@ -885,7 +885,7 @@ public: helper.Out.x = m_Weight * (ox + u * xx + v * yx); helper.Out.y = m_Weight * (oy + u * xy + v * yy); helper.Out.z = m_Weight * helper.In.z; - outPoint.m_ColorX = fmod(fabs(u + v), T(1.0)); + outPoint.m_ColorX = fmod(std::abs(u + v), T(1.0)); } virtual string OpenCLString() const override diff --git a/Source/Ember/XmlToEmber.h b/Source/Ember/XmlToEmber.h index df43a39..5c08d84 100644 --- a/Source/Ember/XmlToEmber.h +++ b/Source/Ember/XmlToEmber.h @@ -174,6 +174,17 @@ public: m_BadParamNames["exponentZ"] = "bubbleT3D_exponentZ"; m_BadParamNames["_symmetryZ"] = "bubbleT3D_symmetryZ"; m_BadParamNames["_modusBlur"] = "bubbleT3D_modusBlur"; + m_BadParamNames["post_scrop_power"] = "post_smartcrop_power"; + m_BadParamNames["post_scrop_radius"] = "post_smartcrop_radius"; + m_BadParamNames["post_scrop_roundstr"] = "post_smartcrop_roundstr"; + m_BadParamNames["post_scrop_roundwidth"] = "post_smartcrop_roundwidth"; + m_BadParamNames["post_scrop_distortion"] = "post_smartcrop_distortion"; + m_BadParamNames["post_scrop_edge"] = "post_smartcrop_edge"; + m_BadParamNames["post_scrop_scatter"] = "post_smartcrop_scatter"; + m_BadParamNames["post_scrop_offset"] = "post_smartcrop_offset"; + m_BadParamNames["post_scrop_rotation"] = "post_smartcrop_rotation"; + m_BadParamNames["post_scrop_cropmode"] = "post_smartcrop_cropmode"; + m_BadParamNames["post_scrop_static"] = "post_smartcrop_static"; m_FlattenNames.reserve(24); m_FlattenNames.push_back("pre_crop"); m_FlattenNames.push_back("pre_falloff2"); @@ -201,7 +212,7 @@ public: m_FlattenNames.push_back("curl3D_cz"); //This is a vector of the param names as they are in the legacy, badly named flam3/Apophysis code. vector badParams; - badParams.reserve(6); + badParams.reserve(11); badParams.push_back("bwraps7_cellsize"); badParams.push_back("bwraps7_space"); badParams.push_back("bwraps7_gain"); @@ -245,6 +256,19 @@ public: badParams.push_back("post_dcztransl_clamp"); m_BadVariationNames.push_back(make_pair(make_pair(string("post_dcztransl"), string("post_dc_ztransl")), badParams)); badParams.clear(); + badParams.push_back("post_scrop_power"); + badParams.push_back("post_scrop_radius"); + badParams.push_back("post_scrop_roundstr"); + badParams.push_back("post_scrop_roundwidth"); + badParams.push_back("post_scrop_distortion"); + badParams.push_back("post_scrop_edge"); + badParams.push_back("post_scrop_scatter"); + badParams.push_back("post_scrop_offset"); + badParams.push_back("post_scrop_rotation"); + badParams.push_back("post_scrop_cropmode"); + badParams.push_back("post_scrop_static"); + m_BadVariationNames.push_back(make_pair(make_pair(string("post_scrop"), string("post_smartcrop")), badParams)); + badParams.clear(); m_BadVariationNames.push_back(make_pair(make_pair(string("pre_blur"), string("pre_gaussian_blur")), badParams));//No other special params for these. m_BadVariationNames.push_back(make_pair(make_pair(string("pre_spin_z"), string("pre_rotate_z")), badParams)); m_BadVariationNames.push_back(make_pair(make_pair(string("post_spin_z"), string("post_rotate_z")), badParams)); diff --git a/Source/EmberCL/FunctionMapper.cpp b/Source/EmberCL/FunctionMapper.cpp index 2da374d..77068a3 100644 --- a/Source/EmberCL/FunctionMapper.cpp +++ b/Source/EmberCL/FunctionMapper.cpp @@ -120,15 +120,12 @@ FunctionMapper::FunctionMapper() m_GlobalMap["Vratio"] = "inline real_t Vratio(real2* p, real2* q, real2* u)\n" "{\n" - " real_t pmQx, pmQy;\n" + " real2 pmq = *p - *q;\n" "\n" - " pmQx = (*p).x - (*q).x;\n" - " pmQy = (*p).y - (*q).y;\n" - "\n" - " if (pmQx == 0 && pmQy == 0)\n" + " if (pmq.x == 0 && pmq.y == 0)\n" " return 1.0;\n" "\n" - " return 2 * (((*u).x - (*q).x) * pmQx + ((*u).y - (*q).y) * pmQy) / (pmQx * pmQx + pmQy * pmQy);\n" + " return 2 * (((*u).x - (*q).x) * pmq.x + ((*u).y - (*q).y) * pmq.y) / (SQR(pmq.x) + SQR(pmq.y));\n" "}\n"; m_GlobalMap["Closest"] = "inline int Closest(real2* p, int n, real2* u)\n" @@ -177,11 +174,11 @@ FunctionMapper::FunctionMapper() " real_t n = 0;\n" " int gi[4];\n" " real_t t;\n" - " real_t skewIn = ((*v).x + (*v).y + (*v).z) * 0.3333;\n" + " real_t skewIn = ((*v).x + (*v).y + (*v).z) * 0.333333;\n" " int i = (int)floor((*v).x + skewIn);\n" " int j = (int)floor((*v).y + skewIn);\n" " int k = (int)floor((*v).z + skewIn);\n" - " t = (i + j + k) * 0.16666;\n" + " t = (i + j + k) * 0.1666666;\n" " real_t x0 = i - t;\n" " real_t y0 = j - t;\n" " real_t z0 = k - t;\n" @@ -228,15 +225,15 @@ FunctionMapper::FunctionMapper() " }\n" " }\n" "\n" - " c[1].x = c[0].x - i1 + 0.16666;\n" - " c[1].y = c[0].y - j1 + 0.16666;\n" - " c[1].z = c[0].z - k1 + 0.16666;\n" - " c[2].x = c[0].x - i2 + 2 * 0.16666;\n" - " c[2].y = c[0].y - j2 + 2 * 0.16666;\n" - " c[2].z = c[0].z - k2 + 2 * 0.16666;\n" - " c[3].x = c[0].x - 1 + 3 * 0.16666;\n" - " c[3].y = c[0].y - 1 + 3 * 0.16666;\n" - " c[3].z = c[0].z - 1 + 3 * 0.16666;\n" + " c[1].x = c[0].x - i1 + 0.1666666;\n" + " c[1].y = c[0].y - j1 + 0.1666666;\n" + " c[1].z = c[0].z - k1 + 0.1666666;\n" + " c[2].x = c[0].x - i2 + 2 * 0.1666666;\n" + " c[2].y = c[0].y - j2 + 2 * 0.1666666;\n" + " c[2].z = c[0].z - k2 + 2 * 0.1666666;\n" + " c[3].x = c[0].x - 1 + 3 * 0.1666666;\n" + " c[3].y = c[0].y - 1 + 3 * 0.1666666;\n" + " c[3].z = c[0].z - 1 + 3 * 0.1666666;\n" " int ii = i & 0x3ff;\n" " int jj = j & 0x3ff;\n" " int kk = k & 0x3ff;\n" @@ -246,7 +243,7 @@ FunctionMapper::FunctionMapper() " gi[3] = (int)p[ii + 1 + (int)p[jj + 1 + (int)p[kk + 1]]];\n" " for (uint corner = 0; corner < 4; corner++)\n" " {\n" - " t = 0.6 - c[corner].x * c[corner].x - c[corner].y * c[corner].y - c[corner].z * c[corner].z;\n" + " t = 0.6 - Sqr(c[corner].x) - Sqr(c[corner].y) - Sqr(c[corner].z);\n" "\n" " if (t > 0)\n" " {\n" @@ -267,7 +264,7 @@ FunctionMapper::FunctionMapper() "\n" " for (i = 0; i < octaves; i++)\n" " {\n" - " n += SimplexNoise3D(&u, p, grad) / a;\n" + " n += SimplexNoise3D(&u, p, grad) / Zeps(a);\n" " a *= aScale;\n" " u.x *= fScale;\n" " u.y *= fScale;\n" diff --git a/Source/EmberCL/IterOpenCLKernelCreator.cpp b/Source/EmberCL/IterOpenCLKernelCreator.cpp index 502c77d..b26a9cd 100644 --- a/Source/EmberCL/IterOpenCLKernelCreator.cpp +++ b/Source/EmberCL/IterOpenCLKernelCreator.cpp @@ -651,11 +651,8 @@ void IterOpenCLKernelCreator::ParVarIndexDefines(const Ember& ember, pair< { for (auto l = 0; l < elements; l++) params.second.push_back(*(parVar->Params()[k].Param() + l)); - - //params.second.push_back(parVar->Params()[k].ParamVal()); } - //size++; size += elements; } } diff --git a/Source/EmberCL/OpenCLWrapper.cpp b/Source/EmberCL/OpenCLWrapper.cpp index 6ed2e07..05e8cd9 100644 --- a/Source/EmberCL/OpenCLWrapper.cpp +++ b/Source/EmberCL/OpenCLWrapper.cpp @@ -979,6 +979,7 @@ bool OpenCLWrapper::CreateSPK(const string& name, const string& program, const s //err = spk.m_Program.build(m_DeviceVec, "-cl-single-precision-constant"); //err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant"); //err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-no-signed-zeros -cl-fast-relaxed-math -cl-single-precision-constant");//This can cause some rounding. + //err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-no-signed-zeros -cl-single-precision-constant -cl-denorms-are-zero"); //err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant"); if (m_Info->CheckCL(err, "cl::Program::build()")) diff --git a/Source/EmberTester/EmberTester.cpp b/Source/EmberTester/EmberTester.cpp index 6dc2139..4d19eeb 100644 --- a/Source/EmberTester/EmberTester.cpp +++ b/Source/EmberTester/EmberTester.cpp @@ -1445,9 +1445,9 @@ void TestVarsSimilar() varComp->Precalc(); varComp->Func(helper, pComp, rand); v4T varCompOut = helper.Out; - xdiff += fabs(varOut.x - varCompOut.x); - ydiff += fabs(varOut.y - varCompOut.y); - zdiff += fabs(varOut.z - varCompOut.z); + xdiff += std::abs(varOut.x - varCompOut.x); + ydiff += std::abs(varOut.y - varCompOut.y); + zdiff += std::abs(varOut.z - varCompOut.z); } sum = (xdiff + ydiff + zdiff) / iters; @@ -1578,9 +1578,9 @@ void TestCpuGpuResults(size_t platform, size_t device) renderer.WritePoints(points); renderer.Iterate(1, 0, 1); renderer.ReadPoints(points); - T xdiff = fabs(p2.m_X - points[0].m_X); - T ydiff = fabs(p2.m_Y - points[0].m_Y); - T zdiff = fabs(p2.m_Z - points[0].m_Z); + T xdiff = std::abs(p2.m_X - points[0].m_X); + T ydiff = std::abs(p2.m_Y - points[0].m_Y); + T zdiff = std::abs(p2.m_Z - points[0].m_Z); if (xdiff > thresh || ydiff > thresh || zdiff > thresh) { @@ -1744,7 +1744,7 @@ void TestCross(T x, T y, T weight) T outX = x * r; T outY = y * r; cout << "First way, outX, outY == " << outX << ", " << outY << endl; - r = fabs((x - y) * (x + y) + EPS); + r = std::abs((x - y) * (x + y) + EPS); if (r < 0) r = -r; @@ -2015,7 +2015,7 @@ int _tmain(int argc, _TCHAR* argv[]) //cout << pow(-1, 5.1) << endl; /* for (i = 0; i < 2500000000; i++) { - double d = fabs(RandD(rand)); + double d = std::abs(RandD(rand)); if (d >= 0.5) cout << d << endl; diff --git a/Source/Fractorium/GLEmberController.cpp b/Source/Fractorium/GLEmberController.cpp index 0c81d17..71efbcf 100644 --- a/Source/Fractorium/GLEmberController.cpp +++ b/Source/Fractorium/GLEmberController.cpp @@ -224,8 +224,8 @@ void GLEmberController::QueryMatrices(bool print) if (renderer) { - double unitX = fabs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0; - double unitY = fabs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0; + double unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0; + double unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0; m_GL->glMatrixMode(GL_PROJECTION); m_GL->glPushMatrix(); m_GL->glLoadIdentity(); diff --git a/Source/Fractorium/GLWidget.cpp b/Source/Fractorium/GLWidget.cpp index ed384b8..14c655f 100644 --- a/Source/Fractorium/GLWidget.cpp +++ b/Source/Fractorium/GLWidget.cpp @@ -222,8 +222,8 @@ void GLWidget::paintGL() //Affine drawing. bool pre = m_Fractorium->ui.PreAffineGroupBox->isChecked(); bool post = m_Fractorium->ui.PostAffineGroupBox->isChecked(); - float unitX = fabs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f; - float unitY = fabs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f; + float unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f; + float unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f; glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -840,8 +840,8 @@ bool GLEmberController::SizesMatch() void GLWidget::DrawGrid() { RendererBase* renderer = m_Fractorium->m_Controller->Renderer(); - float unitX = fabs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f; - float unitY = fabs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f; + float unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f; + float unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f; float rad = std::max(unitX, unitY); float xLow = floor(-unitX); float xHigh = ceil(unitX); diff --git a/Source/Fractorium/VariationTreeWidgetItem.h b/Source/Fractorium/VariationTreeWidgetItem.h index 2ac3b88..e84c48e 100644 --- a/Source/Fractorium/VariationTreeWidgetItem.h +++ b/Source/Fractorium/VariationTreeWidgetItem.h @@ -57,13 +57,12 @@ private: double weight1 = 0, weight2 = 0; VariationTreeWidgetItem* varItemWidget; VariationTreeDoubleSpinBox* spinBox1, *spinBox2; - auto itemWidget1 = treeWidget()->itemWidget(const_cast(this), 1);//Get the widget for the second column. - + if ((spinBox1 = dynamic_cast(itemWidget1)))//Cast the widget to the VariationTreeDoubleSpinBox type. { auto itemWidget2 = treeWidget()->itemWidget(const_cast(&other), 1);//Get the widget for the second column of the widget item passed in. - + if ((spinBox2 = dynamic_cast(itemWidget2)))//Cast the widget to the VariationTreeDoubleSpinBox type. { if (spinBox1->IsParam() || spinBox2->IsParam())//Do not sort params, their order will always remain the same. @@ -83,11 +82,11 @@ private: if (IsNearZero(weight1) && IsNearZero(weight2)) return index1 > index2; else - return fabs(weight1) < fabs(weight2); + return std::abs(weight1) < fabs(weight2); } } } - + return false; }