diff --git a/Builds/MSVC/Installer/FractoriumInstaller.wixproj b/Builds/MSVC/Installer/FractoriumInstaller.wixproj
index 266e05e..9c895b1 100644
--- a/Builds/MSVC/Installer/FractoriumInstaller.wixproj
+++ b/Builds/MSVC/Installer/FractoriumInstaller.wixproj
@@ -6,7 +6,7 @@
3.7
{c8096c47-e358-438c-a520-146d46b0637d}
2.0
- Fractorium_Beta_0.9.9.4
+ Fractorium_Beta_0.9.9.5
Package
$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets
$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets
diff --git a/Builds/MSVC/Installer/Product.wxs b/Builds/MSVC/Installer/Product.wxs
index d438391..0176d82 100644
--- a/Builds/MSVC/Installer/Product.wxs
+++ b/Builds/MSVC/Installer/Product.wxs
@@ -1,6 +1,6 @@
-
+
@@ -13,7 +13,7 @@
-
+
::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way.
#define ISAAC_SIZE 4
diff --git a/Source/Ember/VarFuncs.h b/Source/Ember/VarFuncs.h
index c2cdfa4..99d0884 100644
--- a/Source/Ember/VarFuncs.h
+++ b/Source/Ember/VarFuncs.h
@@ -16,6 +16,176 @@ template
class EMBER_API VarFuncs : public Singleton>
{
public:
+ ///
+ /// Return -1 if the value is less than 0, 1 if it's greater and
+ /// 0 if it's equal to 0.
+ ///
+ /// The value to inspect
+ /// -1, 0 or 1
+ static inline T Sign(T v)
+ {
+ return (v < 0) ? static_cast(-1) : (v > 0) ? static_cast(1) : static_cast(0);
+ }
+
+ ///
+ /// Return -1 if the value is less than 0, 1 if it's greater.
+ /// This differs from Sign() in that it doesn't return 0.
+ ///
+ /// The value to inspect
+ /// -1 or 1
+ static inline T SignNz(T v)
+ {
+ return (v < 0) ? static_cast(-1) : static_cast(1);
+ }
+
+ ///
+ /// Thin wrapper around a call to modf that discards the integer portion
+ /// and returns the signed fractional portion.
+ ///
+ /// The value to retrieve the signed fractional portion of.
+ /// The signed fractional portion of v.
+ static inline T Fabsmod(T v)
+ {
+ T dummy;
+ return modf(v, &dummy);
+ }
+
+ ///
+ /// Unsure.
+ ///
+ /// Unsure.
+ /// Unsure.
+ /// Unsure.
+ /// Unsure.
+ static inline T Fosc(T p, T amp, T ph)
+ {
+ return T(0.5) - std::cos(p * amp + ph) * T(0.5);
+ }
+
+ ///
+ /// Unsure.
+ ///
+ /// Unsure.
+ /// Unsure.
+ /// Unsure.
+ static inline T Foscn(T p, T ph)
+ {
+ return T(0.5) - std::cos(p + ph) * T(0.5);
+ }
+
+ ///
+ /// Log scale from Apophysis.
+ ///
+ /// The value to log scale
+ /// The log scaled value
+ static inline T LogScale(T x)
+ {
+ return x == 0 ? 0 : std::log((fabs(x) + 1) * T(M_E)) * SignNz(x) / T(M_E);
+ }
+
+ ///
+ /// Log map from Apophysis.
+ ///
+ /// The value to log map
+ /// The log mapped value
+ static inline T LogMap(T x)
+ {
+ return x == 0 ? 0 : (T(M_E) + std::log(x * T(M_E))) * T(0.25) * SignNz(x);
+ }
+
+ ///
+ /// Taking the square root of numbers close to zero is dangerous. If x is negative
+ /// due to floating point errors, it can return NaN results.
+ ///
+ static inline T SafeSqrt(T x)
+ {
+ if (x <= 0)
+ return 0;
+
+ return std::sqrt(x);
+ }
+
+ ///
+ /// If r < EPS, return 1 / r.
+ /// Else, return q / r.
+ ///
+ /// The numerator
+ /// The denominator
+ /// The quotient
+ static inline T SafeDivInv(T q, T r)
+ {
+ if (r < EPS)
+ return 1 / r;
+
+ return q / r;
+ }
+
+ ///
+ /// Return the hypotenuse of the passed in values.
+ ///
+ /// The x distance
+ /// The y distance
+ /// The hypotenuse
+ static inline T Hypot(T x, T y)
+ {
+ return std::sqrt(SQR(x) + SQR(y));
+ }
+
+ ///
+ /// Spread the values.
+ ///
+ /// The x distance
+ /// The y distance
+ /// The spread
+ static inline T Spread(T x, T y)
+ {
+ return Hypot(x, y) * ((x) > 0 ? T(1) : T(-1));
+ }
+
+ ///
+ /// Unsure.
+ ///
+ /// The x distance
+ /// The y distance
+ /// The powq4
+ static inline T Powq4(T x, T y)
+ {
+ return std::pow(std::abs(x), y) * SignNz(x);
+ }
+
+ ///
+ /// Unsure.
+ ///
+ /// The x distance
+ /// The y distance
+ /// The powq4c
+ static inline T Powq4c(T x, T y)
+ {
+ return y == 1 ? x : Powq4(x, y);
+ }
+
+ ///
+ /// Special rounding for certain variations, gotten from Apophysis.
+ ///
+ /// The value to round
+ /// The rounded value
+ static inline float LRint(float x)
+ {
+ int temp = (x >= 0 ? static_cast(x + 0.5f) : static_cast(x - 0.5f));
+ return static_cast(temp);
+ }
+
+ ///
+ /// Special rounding for certain variations, gotten from Apophysis.
+ ///
+ /// The value to round
+ /// The rounded value
+ static inline double LRint(double x)
+ {
+ glm::int64_t temp = (x >= 0 ? static_cast(x + 0.5) : static_cast(x - 0.5));
+ return static_cast(temp);
+ }
+
///
/// Retrieve information about a piece of shared data by looking
/// up its name.
diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h
index 2edcfe5..8c0e4c2 100644
--- a/Source/Ember/Variation.h
+++ b/Source/Ember/Variation.h
@@ -1688,7 +1688,7 @@ public:
T vd = std::max(std::min(val, m_Max), m_Min);
if (IsNearZero(vd))
- *m_Param = EPS * SignNz(vd);
+ *m_Param = EPS * VarFuncs::SignNz(vd);
else
*m_Param = vd;
@@ -1707,7 +1707,7 @@ public:
int vi = int(std::max(std::min(T(Floor(val + T(0.5))), m_Max), m_Min));
if (vi == 0)
- vi = int(SignNz(val));
+ vi = int(VarFuncs::SignNz(val));
*m_Param = T(vi);
break;
diff --git a/Source/Ember/Variations01.h b/Source/Ember/Variations01.h
index b1de7d7..fe4b077 100644
--- a/Source/Ember/Variations01.h
+++ b/Source/Ember/Variations01.h
@@ -3200,7 +3200,7 @@ public:
{
if (!_stricmp(name, "bipolar_shift"))
{
- T temp = Fabsmod(T(0.5) * (val + 1));
+ T temp = VarFuncs::Fabsmod(T(0.5) * (val + 1));
m_Shift = 2 * temp - 1;
Precalc();
return true;
@@ -3902,7 +3902,7 @@ public:
{
if (!_stricmp(name, "escher_beta"))
{
- m_Beta = Fabsmod((val + T(M_PI)) / (2 * T(M_PI))) * 2 * T(M_PI) - T(M_PI);
+ m_Beta = VarFuncs::Fabsmod((val + T(M_PI)) / (2 * T(M_PI))) * 2 * T(M_PI) - T(M_PI);
Precalc();
return true;
}
@@ -4056,7 +4056,7 @@ public:
{
if (!_stricmp(name, "lazysusan_spin"))
{
- m_Spin = Fabsmod(val / T(M_2PI)) * T(M_2PI);
+ m_Spin = VarFuncs::Fabsmod(val / T(M_2PI)) * T(M_2PI);
this->Precalc();
return true;
}
diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h
index 314cce1..e384116 100644
--- a/Source/Ember/Variations02.h
+++ b/Source/Ember/Variations02.h
@@ -1523,7 +1523,7 @@ 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));
+ int isXY = int(VarFuncs::LRint(helper.In.x * m_Cs) + VarFuncs::LRint(helper.In.y * m_Cs));
if (isXY & 1)
{
@@ -1852,12 +1852,12 @@ public:
{
T x = T(0.5) * helper.In.x + T(0.5);
T y = T(0.5) * helper.In.y + T(0.5);
- T bx = Fabsmod(m_Fr * x);
- 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);
+ T bx = VarFuncs::Fabsmod(m_Fr * x);
+ T by = VarFuncs::Fabsmod(m_Fr * y);
+ T oscnapx = VarFuncs::Foscn(m_AmountX, m_Px);
+ T oscnapy = VarFuncs::Foscn(m_AmountY, m_Py);
+ helper.Out.x = -1 + m_Vv2 * Lerp(Lerp(x, VarFuncs::Fosc(x, T(4), m_Px), oscnapx), VarFuncs::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, VarFuncs::Fosc(y, T(4), m_Py), oscnapy), VarFuncs::Fosc(by, T(4), m_Py), oscnapy);
helper.Out.z = DefaultZ(helper);
}
@@ -2463,8 +2463,8 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T x = LRint(helper.In.x);
- T y = LRint(helper.In.y);
+ T x = VarFuncs::LRint(helper.In.x);
+ T y = VarFuncs::LRint(helper.In.y);
if (y <= 0)
{
@@ -4210,8 +4210,8 @@ public:
{
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.x = xp * VarFuncs::Sign(helper.In.x) + m_Lcx * helper.In.x + m_Scx;
+ helper.Out.y = yp * VarFuncs::Sign(helper.In.y) + m_Lcy * helper.In.y + m_Scy;
helper.Out.z = m_Weight * helper.In.z;
}
@@ -5199,8 +5199,8 @@ public:
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);
+ T um = std::sqrt(SQR(u) + SQR(helper.In.x)) * VarFuncs::Sign(u);
+ T vm = std::sqrt(SQR(v) + SQR(helper.In.y)) * VarFuncs::Sign(v);
helper.Out.x = m_Weight * um;
helper.Out.y = m_Weight * vm;
helper.Out.z = m_Weight * helper.In.z;
diff --git a/Source/Ember/Variations03.h b/Source/Ember/Variations03.h
index 2b932e8..bc90c5f 100644
--- a/Source/Ember/Variations03.h
+++ b/Source/Ember/Variations03.h
@@ -1609,8 +1609,8 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- 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.x = VarFuncs::SignNz(helper.In.x) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight;
+ helper.Out.y = VarFuncs::SignNz(helper.In.y) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = DefaultZ(helper);
}
@@ -2259,7 +2259,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
T dx, dy, r = m_Weight / (helper.m_PrecalcSumSquares + EPS);
- int isXY = int(LRint(helper.In.x * m_InvSize) + LRint(helper.In.y * m_InvSize));
+ int isXY = int(VarFuncs::LRint(helper.In.x * m_InvSize) + VarFuncs::LRint(helper.In.y * m_InvSize));
if (isXY & 1)
{
@@ -3761,7 +3761,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);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::SafeSqrt(tmp - tmp2)) * T(0.5);
int alt;
if (xmax < 1)
@@ -3911,7 +3911,7 @@ public:
T tmp = r2 + 1;
T tmp2 = 2 * x;
- T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::SafeSqrt(tmp - tmp2)) * T(0.5);
ClampGteRef(xmax, 1);
T mu = std::acosh(xmax);
T nu = std::acos(Clamp(x / xmax, -1, 1));//-Pi < nu < Pi.
@@ -4015,7 +4015,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);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::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.
@@ -4110,7 +4110,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);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::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.
@@ -4214,7 +4214,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);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::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.
@@ -4303,7 +4303,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);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::SafeSqrt(tmp - tmp2)) * T(0.5);
if (xmax < 1)
xmax = 1;
@@ -4383,7 +4383,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);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::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.
diff --git a/Source/Ember/Variations04.h b/Source/Ember/Variations04.h
index bc7b829..108c423 100644
--- a/Source/Ember/Variations04.h
+++ b/Source/Ember/Variations04.h
@@ -22,7 +22,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);
+ T xmax = (VarFuncs::SafeSqrt(tmp + tmp2) + VarFuncs::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.
@@ -2519,7 +2519,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- const T zr = Hypot(helper.In.z, helper.m_PrecalcSqrtSumSquares);
+ const T zr = VarFuncs::Hypot(helper.In.z, helper.m_PrecalcSqrtSumSquares);
const T phi = std::acos(Clamp(helper.In.z / zr, -1, 1));
const T ps = std::sin(phi);
const T pc = std::cos(phi);
@@ -2670,13 +2670,13 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- const T x = Powq4c(helper.In.x, m_Power);
- const T y = Powq4c(helper.In.y, m_Power);
- const T z = Powq4c(helper.In.z, m_Power);
+ const T x = VarFuncs::Powq4c(helper.In.x, m_Power);
+ const T y = VarFuncs::Powq4c(helper.In.y, m_Power);
+ const T z = VarFuncs::Powq4c(helper.In.z, m_Power);
const T d = SQR(x) - SQR(y);
- const T re = Spread(m_C1 * x + m_C2 * d, m_Sx) + 1;
- 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 re = VarFuncs::Spread(m_C1 * x + m_C2 * d, m_Sx) + 1;
+ const T im = VarFuncs::Spread(m_C1 * y + m_C2x2 * x * y, m_Sy);
+ T c = Zeps(VarFuncs::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;
@@ -3121,7 +3121,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T s = std::sin(helper.In.x);
T c = std::cos(helper.In.x);
T sh = std::sinh(absV);
@@ -3170,7 +3170,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T s = std::sin(absV);
T c = std::cos(absV);
T sh = std::sinh(helper.In.x);
@@ -3219,7 +3219,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(-helper.In.x);
T c = std::cos(-helper.In.x);
@@ -3270,7 +3270,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(absV);
T c = std::cos(absV);
@@ -3433,7 +3433,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T s = std::sin(helper.In.x);
T c = std::cos(helper.In.x);
T sh = std::sinh(absV);
@@ -3482,7 +3482,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T s = std::sin(absV);
T c = std::cos(absV);
T sh = std::sinh(helper.In.x);
@@ -3643,7 +3643,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(helper.In.x);
T c = std::cos(helper.In.x);
@@ -3694,7 +3694,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(absV);
T c = std::cos(absV);
@@ -3745,7 +3745,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::Hypot(helper.In.y, helper.In.z);
T e = std::exp(helper.In.x);
T s = std::sin(absV);
T c = std::cos(absV);
@@ -3795,7 +3795,7 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T absV = Hypot(helper.In.y, helper.In.z);
+ T absV = VarFuncs::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;
@@ -3991,7 +3991,7 @@ public:
{
T xx = (rand.Frand01() - T(0.5)) * 2;
T yy = (rand.Frand01() - T(0.5)) * 2;
- T k = SignNz(yy);
+ T k = VarFuncs::SignNz(yy);
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(std::abs(m_A) + std::abs(m_B));
@@ -5039,10 +5039,10 @@ public:
T xmax = T(0.5) * (std::sqrt(tmp + x2) + std::sqrt(tmp - x2));
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));
+ T b = VarFuncs::SafeSqrt(1 - SQR(a));
helper.Out.x = m_Vx * atan2(a, b) * r;
a = helper.In.y / Zeps(ymax);
- b = SafeSqrt(1 - SQR(a));
+ b = VarFuncs::SafeSqrt(1 - SQR(a));
helper.Out.y = m_Vy * atan2(a, b) * r;
helper.Out.z = DefaultZ(helper);
}
diff --git a/Source/Ember/Variations05.h b/Source/Ember/Variations05.h
index 1948f6e..a0b2c7e 100644
--- a/Source/Ember/Variations05.h
+++ b/Source/Ember/Variations05.h
@@ -95,7 +95,7 @@ public:
int n = int(Floor(T(0.5) * helper.In.y / m_Sc));
T x = helper.In.x - (m * 2 + 1) * m_Sc;
T y = helper.In.y - (n * 2 + 1) * m_Sc;
- T u = Zeps(Hypot(x, y));
+ T u = Zeps(VarFuncs::Hypot(x, y));
T v = (T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3)) * m_Sc;
T z1 = DiscreteNoise2(int(m + m_Seed), n);
@@ -283,7 +283,7 @@ public:
n = Floor(T(0.5) * y / m_Sc);
x -= (m * 2 + 1) * m_Sc;
y -= (n * 2 + 1) * m_Sc;
- u = Hypot(x, y);
+ u = VarFuncs::Hypot(x, y);
if (++iters > 10)
break;
@@ -404,7 +404,7 @@ public:
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);
+ u = VarFuncs::Hypot(x, y);
if ((DiscreteNoise2(int(m + m_Seed), int(n)) > m_Dens) || (u > (T(0.3) + T(0.7) * DiscreteNoise2(int(m + 10), int(n + 3))) * m_Sc))
{
@@ -512,6 +512,11 @@ public:
return vector { "Hypot" };
}
+ virtual void Precalc() override
+ {
+ m_Sc = Zeps(m_Sc);
+ }
+
protected:
void Init()
{
@@ -2742,11 +2747,11 @@ public:
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 = std::abs(fmod(outPoint.m_ColorX + LogMap(m_MulC) * LogScale(random.w) * coeff, T(1)));
+ const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (VarFuncs::LogMap(dist) - dist);
+ helper.Out.x = helper.In.x + VarFuncs::LogMap(m_MulX) * VarFuncs::LogScale(random.x) * coeff;
+ helper.Out.y = helper.In.y + VarFuncs::LogMap(m_MulY) * VarFuncs::LogScale(random.y) * coeff;
+ helper.Out.z = helper.In.z + VarFuncs::LogMap(m_MulZ) * VarFuncs::LogScale(random.z) * coeff;
+ outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + VarFuncs::LogMap(m_MulC) * VarFuncs::LogScale(random.w) * coeff, T(1)));
}
break;
}
diff --git a/Source/Ember/Variations07.h b/Source/Ember/Variations07.h
index a4ea759..e9cc08f 100644
--- a/Source/Ember/Variations07.h
+++ b/Source/Ember/Variations07.h
@@ -108,14 +108,14 @@ public:
T CsX = 1;
T CsY = 1;
T jcbSn = 0, jcbCn, jcbDn;
- CsX = SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.x)));
+ CsX = VarFuncs::SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.x)));
CsX = CsX * m_Six + m_Scaleinfx;
- CsY = SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.y)));
+ CsY = VarFuncs::SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.y)));
CsY = CsY * m_Siy + m_Scaleinfy;
if (m_Pwx >= 0 && m_Pwx < 1e-4)
{
- m_VarFuncs->JacobiElliptic(helper.In.y * m_Freqx, m_Jacok, jcbSn, jcbCn, jcbDn);
+ VarFuncs::JacobiElliptic(helper.In.y * m_Freqx, m_Jacok, jcbSn, jcbCn, jcbDn);
helper.Out.x = m_Weight * (helper.In.x + CsX * jcbSn);
}
else if (m_Pwx < 0 && m_Pwx > -1e-4)
@@ -126,11 +126,11 @@ public:
helper.Out.x = m_Weight * (helper.In.x + CsX * T(j1(helper.In.y * m_Freqx)));//This is not implemented in OpenCL.
#endif
else
- helper.Out.x = m_Weight * (helper.In.x + CsX * std::sin(SignNz(helper.In.y) * std::pow(Zeps(std::abs(helper.In.y)), m_Pwx) * m_Freqx));
+ helper.Out.x = m_Weight * (helper.In.x + CsX * std::sin(VarFuncs::SignNz(helper.In.y) * std::pow(Zeps(std::abs(helper.In.y)), m_Pwx) * m_Freqx));
if (m_Pwy >= 0 && m_Pwy < 1e-4)
{
- m_VarFuncs->JacobiElliptic(helper.In.x * m_Freqy, m_Jacok, jcbSn, jcbCn, jcbDn);
+ VarFuncs::JacobiElliptic(helper.In.x * m_Freqy, m_Jacok, jcbSn, jcbCn, jcbDn);
helper.Out.y = m_Weight * (helper.In.y + CsY * jcbSn);
}
else if (m_Pwy < 0 && m_Pwy > -1e-4)
@@ -141,7 +141,7 @@ public:
helper.Out.y = m_Weight * (helper.In.y + CsY * T(j1(helper.In.x * m_Freqy)));
#endif
else
- helper.Out.y = m_Weight * (helper.In.y + CsY * std::sin(SignNz(helper.In.x) * std::pow(Zeps(std::abs(helper.In.x)), m_Pwy) * m_Freqy));
+ helper.Out.y = m_Weight * (helper.In.y + CsY * std::sin(VarFuncs::SignNz(helper.In.x) * std::pow(Zeps(std::abs(helper.In.x)), m_Pwy) * m_Freqy));
helper.Out.z = DefaultZ(helper);
}
@@ -213,7 +213,6 @@ protected:
void Init()
{
string prefix = Prefix();
- m_VarFuncs = VarFuncs::Instance();
m_Params.clear();
m_Params.push_back(ParamWithName(&m_Freqx, prefix + "waves2b_freqx", 2));
m_Params.push_back(ParamWithName(&m_Freqy, prefix + "waves2b_freqy", 2));
@@ -242,7 +241,6 @@ private:
T m_Jacok;
T m_Six;//Precalc.
T m_Siy;
- shared_ptr> m_VarFuncs;
};
///
@@ -264,8 +262,8 @@ public:
T snx, cnx, dnx;
T sny, cny, dny;
T numX, numY, denom;
- m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
- m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
+ VarFuncs::JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
+ VarFuncs::JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
numX = cnx * cny;
numY = -dnx * snx * dny * sny;
denom = SQR(snx) * SQR(sny) * m_K + SQR(cny);
@@ -308,14 +306,12 @@ protected:
void Init()
{
string prefix = Prefix();
- m_VarFuncs = VarFuncs::Instance();
m_Params.clear();
m_Params.push_back(ParamWithName(&m_K, prefix + "jac_cn_k", T(0.5), eParamType::REAL, -1, 1));
}
private:
T m_K;
- shared_ptr> m_VarFuncs;
};
///
@@ -337,8 +333,8 @@ public:
T snx, cnx, dnx;
T sny, cny, dny;
T numX, numY, denom;
- m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
- m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
+ VarFuncs::JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
+ VarFuncs::JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
numX = dnx * cny * dny;
numY = -cnx * snx * sny * m_K;
denom = SQR(snx) * SQR(sny) * m_K + SQR(cny);
@@ -381,14 +377,12 @@ protected:
void Init()
{
string prefix = Prefix();
- m_VarFuncs = VarFuncs::Instance();
m_Params.clear();
m_Params.push_back(ParamWithName(&m_K, prefix + "jac_dn_k", T(0.5), eParamType::REAL, -1, 1));
}
private:
T m_K;
- shared_ptr> m_VarFuncs;
};
///
@@ -410,8 +404,8 @@ public:
T snx, cnx, dnx;
T sny, cny, dny;
T numX, numY, denom;
- m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
- m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
+ VarFuncs::JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
+ VarFuncs::JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
numX = snx * dny;
numY = cnx * dnx * cny * sny;
denom = SQR(snx) * SQR(sny) * m_K + SQR(cny);
@@ -454,14 +448,12 @@ protected:
void Init()
{
string prefix = Prefix();
- m_VarFuncs = VarFuncs::Instance();
m_Params.clear();
m_Params.push_back(ParamWithName(&m_K, prefix + "jac_sn_k", T(0.5), eParamType::REAL, -1, 1));
}
private:
T m_K;
- shared_ptr> m_VarFuncs;
};
///
diff --git a/Source/Ember/VariationsDC.h b/Source/Ember/VariationsDC.h
index 4311e51..72e7da6 100644
--- a/Source/Ember/VariationsDC.h
+++ b/Source/Ember/VariationsDC.h
@@ -517,8 +517,8 @@ public:
virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override
{
- T x = LRint(helper.In.x);
- T y = LRint(helper.In.y);
+ T x = VarFuncs::LRint(helper.In.x);
+ T y = VarFuncs::LRint(helper.In.y);
T c = outPoint.m_ColorX;
if (y <= 0)
diff --git a/Source/Fractorium/FractoriumXformsAffine.cpp b/Source/Fractorium/FractoriumXformsAffine.cpp
index e984de3..94e8fe6 100644
--- a/Source/Fractorium/FractoriumXformsAffine.cpp
+++ b/Source/Fractorium/FractoriumXformsAffine.cpp
@@ -602,9 +602,9 @@ void FractoriumEmberController::FillAffineWithXform(Xform* xform, bool pre
spinners[0]->SetValueStealth(RAD_2_DEG * atan2(affine.D(), affine.A()));
spinners[1]->SetValueStealth(RAD_2_DEG * atan2(affine.E(), affine.B()));
spinners[2]->SetValueStealth(RAD_2_DEG * atan2(affine.F(), affine.C()));
- spinners[3]->SetValueStealth(Hypot(affine.D(), affine.A()));
- spinners[4]->SetValueStealth(Hypot(affine.E(), affine.B()));
- spinners[5]->SetValueStealth(Hypot(affine.F(), affine.C()));
+ spinners[3]->SetValueStealth(VarFuncs::Hypot(affine.D(), affine.A()));
+ spinners[4]->SetValueStealth(VarFuncs::Hypot(affine.E(), affine.B()));
+ spinners[5]->SetValueStealth(VarFuncs::Hypot(affine.F(), affine.C()));
}
else
{