06/09/2017

--User changes
 -dark.qss is now per-OS.
 -Properly set/reload palette when coming from the palette editor. The latter must be done if they've modified the current palette even if they've clicked cancel.

--Bug fixes
 -Make the following variations safer by using Zeps(): conic, bipolar, edisc, whorl, tan, csc, cot, tanh, sech, csch, coth, auger, bwraps, hypertile3d, hypertile3d1, ortho, poincare, rational3, barycentroid, sschecks, cscq, cschq, scry_3D, splitbrdr, hexcrop, nblur, crob.
 -Fix bug enabling/disabling overwrite button in palette editor.
 -Small optimization for gdoffs, use precalcAtanYX.
 -Properly propagate z through circlesplit, cylinder2 and tile_log variations.
 -Some values in truchet_fill could've been NaN.

--Code changes
 -Make most installation files read only.
 -Qualify many calls with std:: to ensure they're not colliding with glm::
 -Use auto in more places.
This commit is contained in:
Person
2017-06-09 19:38:06 -07:00
parent 11ca4f9000
commit c4e891b18c
30 changed files with 2453 additions and 978 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ public:
}
//Allocate the memory for these filters and the hit/width lookup array.
rowSize = static_cast<int>(2 * ceil(finalMaxRad) - 1);
rowSize = static_cast<int>(2 * std::ceil(finalMaxRad) - 1);
m_FilterWidth = (rowSize - 1) / 2;
m_KernelSize = (m_FilterWidth + 1) * (2 + m_FilterWidth) / 2;
m_Coefs.resize(maxIndex * m_KernelSize);
+5 -5
View File
@@ -634,7 +634,7 @@ public:
t = xform->m_Post.m_Mat[col][2];
}
cxAng[k][col] = atan2(c1[1], c1[0]);
cxAng[k][col] = std::atan2(c1[1], c1[0]);
cxMag[k][col] = std::sqrt(c1[0] * c1[0] + c1[1] * c1[1]);
if (cxMag[k][col] == 0)
@@ -722,7 +722,7 @@ public:
{
c1[0] = embers[k].GetXform(xfi)->m_Affine.m_Mat[0][col];//A,D then B,E.
c1[1] = embers[k].GetXform(xfi)->m_Affine.m_Mat[1][col];
cxang[k][col] = atan2(c1[1], c1[0]);
cxang[k][col] = std::atan2(c1[1], c1[0]);
}
}
@@ -774,7 +774,7 @@ public:
{
for (i = 0; i < size; i++)
{
if (log(cxMag[i][col]) < -10)
if (std::log(cxMag[i][col]) < -10)
accmode[col] = 1;//Mode set to linear interp.
}
}
@@ -926,8 +926,8 @@ public:
if (bd < 0) return true;
ad = atan2(a.m_Affine.A(), a.m_Affine.D());
bd = atan2(b.m_Affine.A(), b.m_Affine.D());
ad = std::atan2(a.m_Affine.A(), a.m_Affine.D());
bd = std::atan2(b.m_Affine.A(), b.m_Affine.D());
}
return ad > bd;
+5 -6
View File
@@ -919,18 +919,17 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
for (intmax_t j = localStartRow; (j < localEndRow) && !m_Abort; j++)
{
size_t bucketRowStart = j * m_SuperRasW;//Pull out of inner loop for optimization.
const tvec4<bucketT, glm::defaultp>* bucket;
const tvec4<bucketT, glm::defaultp>* buckets = m_HistBuckets.data();
const bucketT* filterCoefs = m_DensityFilter->Coefs();
const bucketT* filterWidths = m_DensityFilter->Widths();
auto buckets = m_HistBuckets.data();
auto bucketRowStart = buckets + (j * m_SuperRasW);//Pull out of inner loop for optimization.
auto filterCoefs = m_DensityFilter->Coefs();
auto filterWidths = m_DensityFilter->Widths();
for (intmax_t i = startCol; i < endCol; i++)
{
intmax_t ii, jj, arrFilterWidth;
size_t filterSelectInt, filterCoefIndex;
T filterSelect = 0;
bucket = buckets + bucketRowStart + i;
auto bucket = bucketRowStart + i;
//Don't do anything if there's no hits here. Must also put this first to avoid dividing by zero below.
if (bucket->a == 0)
+1 -1
View File
@@ -684,7 +684,7 @@ static inline void ClampGte0Ref(T& val)
template <typename T>
static inline T Round(T r)
{
return (r > 0) ? static_cast<T>(Floor<T>(r + T(0.5))) : ceil(r - T(0.5));
return (r > 0) ? static_cast<T>(Floor<T>(r + T(0.5))) : std::ceil(r - T(0.5));
}
/// <summary>
+3 -3
View File
@@ -1226,10 +1226,10 @@ public:
}
if (m_NeedPrecalcAtanXY)
iteratorHelper.m_PrecalcAtanxy = atan2(iteratorHelper.In.x, iteratorHelper.In.y);
iteratorHelper.m_PrecalcAtanxy = std::atan2(iteratorHelper.In.x, iteratorHelper.In.y);
if (m_NeedPrecalcAtanYX)
iteratorHelper.m_PrecalcAtanyx = atan2(iteratorHelper.In.y, iteratorHelper.In.x);
iteratorHelper.m_PrecalcAtanyx = std::atan2(iteratorHelper.In.y, iteratorHelper.In.x);
}
/// <summary>
@@ -2328,4 +2328,4 @@ protected:
\
PREPOSTPARVARCOPY(Post##varName##Variation, varName##Variation) \
};
}
}
+126 -59
View File
@@ -2883,9 +2883,10 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T ct = helper.In.x / helper.m_PrecalcSqrtSumSquares;
T z = Zeps(helper.m_PrecalcSqrtSumSquares);
T ct = helper.In.x / z;
T r = m_Weight * (rand.Frand01<T>() - m_Holes) *
m_Eccentricity / (1 + m_Eccentricity * ct) / helper.m_PrecalcSqrtSumSquares;
m_Eccentricity / (1 + m_Eccentricity * ct) / z;
helper.Out.x = r * helper.In.x;
helper.Out.y = r * helper.In.y;
helper.Out.z = DefaultZ(helper);
@@ -2900,8 +2901,9 @@ public:
string eccentricity = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string holes = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t z = Zeps(precalcSqrtSumSquares);\n"
<< "\t\treal_t ct = vIn.x / precalcSqrtSumSquares;\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) - " << holes << ") * " << eccentricity << " / (1 + " << eccentricity << " * ct) / precalcSqrtSumSquares;\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) - " << holes << ") * " << eccentricity << " / (1 + " << eccentricity << " * ct) / z;\n"
<< "\n"
<< "\t\tvOut.x = r * vIn.x;\n"
<< "\t\tvOut.y = r * vIn.y;\n"
@@ -2910,6 +2912,11 @@ public:
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
m_Eccentricity = rand.Frand01<T>();
@@ -3096,7 +3103,7 @@ public:
const T x2y2 = helper.m_PrecalcSumSquares;
const T t = x2y2 + 1;
const T x2 = 2 * helper.In.x;
T y = T(0.5) * atan2(2 * helper.In.y, x2y2 - 1) + m_S;
T y = T(0.5) * std::atan2(2 * helper.In.y, x2y2 - 1) + m_S;
if (y > T(M_PI_2))
y = -T(M_PI_2) + fmod(y + T(M_PI_2), T(M_PI));
@@ -3123,7 +3130,7 @@ public:
}
else
{
helper.Out.x = m_V4 * std::log((t + x2) / (t - x2));
helper.Out.x = m_V4 * std::log((t + x2) / Zeps(t - x2));
helper.Out.y = m_V * y;
helper.Out.z = m_Weight * helper.In.z;
}
@@ -3176,7 +3183,7 @@ public:
ss << "\t\telse\n"
<< "\t\t{\n"
<< "\t\t vOut.x = (" << v4 << " * log((t + x2) / (t - x2)));\n"
<< "\t\t vOut.x = (" << v4 << " * log((t + x2) / Zeps(t - x2)));\n"
<< "\t\t vOut.y = (" << v << " * y);\n"
<< "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t\t}\n"
@@ -3196,6 +3203,11 @@ public:
m_Shift = 2 * rand.Frand01<T>() - 1;
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
virtual bool SetParamVal(const char* name, T val) override
{
if (!_stricmp(name, "bipolar_shift"))
@@ -3394,8 +3406,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T invCellSize = 1 / m_Size;
T x = floor(helper.In.x * invCellSize);//Calculate input cell. Note that int cast is omitted here. See below.
T y = floor(helper.In.y * invCellSize);
T x = std::floor(helper.In.x * invCellSize);//Calculate input cell. Note that int cast is omitted here. See below.
T y = std::floor(helper.In.y * invCellSize);
T dx = helper.In.x - x * m_Size;//Offset from cell origin.
T dy = helper.In.y - y * m_Size;
@@ -3696,14 +3708,14 @@ public:
T tmp2 = 2 * helper.In.x;
T r1 = std::sqrt(tmp + tmp2);
T r2 = std::sqrt(tmp - tmp2);
T xmax = (r1 + r2) * T(0.5);
T xmax = Zeps((r1 + r2) * T(0.5));
T a1 = std::log(xmax + std::sqrt(xmax - 1));
T a2 = -std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));
T w = m_Weight / T(11.57034632);//This is an interesting magic number.
T snv, csv, snhu, cshu;
sincos(a1, &snv, &csv);
snhu = sinh(a2);
cshu = cosh(a2);
snhu = std::sinh(a2);
cshu = std::cosh(a2);
if (helper.In.y > 0.0)
snv = -snv;
@@ -3722,7 +3734,7 @@ public:
<< "\t\treal_t tmp2 = (real_t)(2.0) * vIn.x;\n"
<< "\t\treal_t r1 = sqrt(tmp + tmp2);\n"
<< "\t\treal_t r2 = sqrt(tmp - tmp2);\n"
<< "\t\treal_t xmax = (r1 + r2) * (real_t)(0.5);\n"
<< "\t\treal_t xmax = Zeps((r1 + r2) * (real_t)(0.5));\n"
<< "\t\treal_t a1 = log(xmax + sqrt(xmax - (real_t)(1.0)));\n"
<< "\t\treal_t a2 = -acos(clamp(vIn.x / xmax, -(real_t)(1.0), (real_t)(1.0)));\n"
<< "\t\treal_t w = xform->m_VariationWeights[" << varIndex << "] / (real_t)(11.57034632);\n"
@@ -3738,6 +3750,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -3774,7 +3791,7 @@ public:
else
ssx = std::sqrt(ssx);
helper.Out.x = w * atan2(a, b);
helper.Out.x = w * std::atan2(a, b);
if (helper.In.y > 0)
helper.Out.y = w * std::log(xmax + ssx);
@@ -3997,7 +4014,7 @@ public:
if (r < m_Weight)
{
T a = atan2(y, x) + m_Spin + m_Twist * (m_Weight - r);
T a = std::atan2(y, x) + m_Spin + m_Twist * (m_Weight - r);
helper.Out.x = m_Weight * (r * std::cos(a) + m_X);//Fix to make it colapse to 0 when weight is 0.//SMOULDER
helper.Out.y = m_Weight * (r * std::sin(a) - m_Y);
}
@@ -4657,12 +4674,12 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
if (cos(helper.In.y * m_YAng) >= 0)
if (std::cos(helper.In.y * m_YAng) >= 0)
helper.Out.x = m_Weight * helper.In.x;
else
helper.Out.x = -(m_Weight * helper.In.x);
if (cos(helper.In.x * m_XAng) >= 0)
if (std::cos(helper.In.x * m_XAng) >= 0)
helper.Out.y = m_Weight * helper.In.y;
else
helper.Out.y = -(m_Weight * helper.In.y);
@@ -5151,7 +5168,7 @@ public:
if (r < m_Weight)
a = helper.m_PrecalcAtanyx + m_Inside / (m_Weight - r);
else
a = helper.m_PrecalcAtanyx + m_Outside / (m_Weight - r);
a = helper.m_PrecalcAtanyx + m_Outside / Zeps(m_Weight - r);
helper.Out.x = m_Weight * r * std::cos(a);
helper.Out.y = m_Weight * r * std::sin(a);
@@ -5173,7 +5190,7 @@ public:
<< "\t\tif (r < xform->m_VariationWeights[" << varIndex << "])\n"
<< "\t\t a = precalcAtanyx + " << inside << " / (xform->m_VariationWeights[" << varIndex << "] - r);\n"
<< "\t\telse\n"
<< "\t\t a = precalcAtanyx + " << outside << " / (xform->m_VariationWeights[" << varIndex << "] - r);\n"
<< "\t\t a = precalcAtanyx + " << outside << " / Zeps(xform->m_VariationWeights[" << varIndex << "] - r);\n"
<< "\n"
<< "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * r * cos(a));\n"
<< "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] * r * sin(a));\n"
@@ -5182,6 +5199,11 @@ public:
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
m_Inside = rand.Frand01<T>();
@@ -5378,8 +5400,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
helper.Out.x = m_Weight * std::sin(helper.In.x) * cosh(helper.In.y);
helper.Out.y = m_Weight * std::cos(helper.In.x) * sinh(helper.In.y);
helper.Out.x = m_Weight * std::sin(helper.In.x) * std::cosh(helper.In.y);
helper.Out.y = m_Weight * std::cos(helper.In.x) * std::sinh(helper.In.y);
helper.Out.z = DefaultZ(helper);
}
@@ -5410,8 +5432,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
//clamp fabs x and y to 7.104760e+002 for cosh, and |x| 7.104760e+002 for sinh
helper.Out.x = m_Weight * std::cos(helper.In.x) * cosh(helper.In.y);
helper.Out.y = -(m_Weight * std::sin(helper.In.x) * sinh(helper.In.y));
helper.Out.x = m_Weight * std::cos(helper.In.x) * std::cosh(helper.In.y);
helper.Out.y = -(m_Weight * std::sin(helper.In.x) * std::sinh(helper.In.y));
helper.Out.z = DefaultZ(helper);
}
@@ -5443,9 +5465,9 @@ public:
{
T tansin, tancos, tansinh, tancosh, tanden;
sincos(2 * helper.In.x, &tansin, &tancos);
tansinh = sinh(2 * helper.In.y);
tancosh = cosh(2 * helper.In.y);
tanden = 1 / (tancos + tancosh);
tansinh = std::sinh(2 * helper.In.y);
tancosh = std::cosh(2 * helper.In.y);
tanden = 1 / Zeps(tancos + tancosh);
helper.Out.x = m_Weight * tanden * tansin;
helper.Out.y = m_Weight * tanden * tansinh;
helper.Out.z = DefaultZ(helper);
@@ -5460,7 +5482,7 @@ public:
<< "\t\treal_t tancos = cos((real_t)(2.0) * vIn.x);\n"
<< "\t\treal_t tansinh = sinh((real_t)(2.0) * vIn.y);\n"
<< "\t\treal_t tancosh = cosh((real_t)(2.0) * vIn.y);\n"
<< "\t\treal_t tanden = (real_t)(1.0) / (tancos + tancosh);\n"
<< "\t\treal_t tanden = (real_t)(1.0) / Zeps(tancos + tancosh);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * tanden * tansin;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * tanden * tansinh;\n"
@@ -5468,6 +5490,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5485,9 +5512,9 @@ public:
{
T secsin, seccos, secsinh, seccosh, secden;
sincos(helper.In.x, &secsin, &seccos);
secsinh = sinh(helper.In.y);
seccosh = cosh(helper.In.y);
secden = 2 / (cos(2 * helper.In.x) + cosh(2 * helper.In.y));
secsinh = std::sinh(helper.In.y);
seccosh = std::cosh(helper.In.y);
secden = 2 / Zeps(std::cos(2 * helper.In.x) + std::cosh(2 * helper.In.y));
helper.Out.x = m_Weight * secden * seccos * seccosh;
helper.Out.y = m_Weight * secden * secsin * secsinh;
helper.Out.z = DefaultZ(helper);
@@ -5502,7 +5529,7 @@ public:
<< "\t\treal_t seccos = cos(vIn.x);\n"
<< "\t\treal_t secsinh = sinh(vIn.y);\n"
<< "\t\treal_t seccosh = cosh(vIn.y);\n"
<< "\t\treal_t secden = (real_t)(2.0) / (cos((real_t)(2.0) * vIn.x) + cosh((real_t)(2.0) * vIn.y));\n"
<< "\t\treal_t secden = (real_t)(2.0) / Zeps(cos((real_t)(2.0) * vIn.x) + cosh((real_t)(2.0) * vIn.y));\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * secden * seccos * seccosh;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * secden * secsin * secsinh;\n"
@@ -5510,6 +5537,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5529,7 +5561,7 @@ public:
sincos(helper.In.x, &cscsin, &csccos);
cscsinh = std::sinh(helper.In.y);
csccosh = std::cosh(helper.In.y);
cscden = 2 / (std::cosh(2 * helper.In.y) - std::cos(2 * helper.In.x));
cscden = 2 / Zeps(std::cosh(2 * helper.In.y) - std::cos(2 * helper.In.x));
helper.Out.x = m_Weight * cscden * cscsin * csccosh;
helper.Out.y = -(m_Weight * cscden * csccos * cscsinh);
helper.Out.z = DefaultZ(helper);
@@ -5544,7 +5576,7 @@ public:
<< "\t\treal_t csccos = cos(vIn.x);\n"
<< "\t\treal_t cscsinh = sinh(vIn.y);\n"
<< "\t\treal_t csccosh = cosh(vIn.y);\n"
<< "\t\treal_t cscden = (real_t)(2.0) / (cosh((real_t)(2.0) * vIn.y) - cos((real_t)(2.0) * vIn.x));\n"
<< "\t\treal_t cscden = (real_t)(2.0) / Zeps(cosh((real_t)(2.0) * vIn.y) - cos((real_t)(2.0) * vIn.x));\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cscden * cscsin * csccosh;\n"
<< "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * cscden * csccos * cscsinh);\n"
@@ -5552,6 +5584,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5569,9 +5606,9 @@ public:
{
T cotsin, cotcos, cotsinh, cotcosh, cotden;
sincos(2 * helper.In.x, &cotsin, &cotcos);
cotsinh = sinh(2 * helper.In.y);
cotcosh = cosh(2 * helper.In.y);
cotden = 1 / (cotcosh - cotcos);
cotsinh = std::sinh(2 * helper.In.y);
cotcosh = std::cosh(2 * helper.In.y);
cotden = 1 / Zeps(cotcosh - cotcos);
helper.Out.x = m_Weight * cotden * cotsin;
helper.Out.y = m_Weight * cotden * -1 * cotsinh;
helper.Out.z = DefaultZ(helper);
@@ -5586,7 +5623,7 @@ public:
<< "\t\treal_t cotcos = cos((real_t)(2.0) * vIn.x);\n"
<< "\t\treal_t cotsinh = sinh((real_t)(2.0) * vIn.y);\n"
<< "\t\treal_t cotcosh = cosh((real_t)(2.0) * vIn.y);\n"
<< "\t\treal_t cotden = (real_t)(1.0) / (cotcosh - cotcos);\n"
<< "\t\treal_t cotden = (real_t)(1.0) / Zeps(cotcosh - cotcos);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cotden * cotsin;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cotden * -1 * cotsinh;\n"
@@ -5594,6 +5631,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5611,8 +5653,8 @@ public:
{
T sinhsin, sinhcos, sinhsinh, sinhcosh;
sincos(helper.In.y, &sinhsin, &sinhcos);
sinhsinh = sinh(helper.In.x);
sinhcosh = cosh(helper.In.x);
sinhsinh = std::sinh(helper.In.x);
sinhcosh = std::cosh(helper.In.x);
helper.Out.x = m_Weight * sinhsinh * sinhcos;
helper.Out.y = m_Weight * sinhcosh * sinhsin;
helper.Out.z = DefaultZ(helper);
@@ -5651,8 +5693,8 @@ public:
{
T coshsin, coshcos, coshsinh, coshcosh;
sincos(helper.In.y, &coshsin, &coshcos);
coshsinh = sinh(helper.In.x);
coshcosh = cosh(helper.In.x);
coshsinh = std::sinh(helper.In.x);
coshcosh = std::cosh(helper.In.x);
helper.Out.x = m_Weight * coshcosh * coshcos;
helper.Out.y = m_Weight * coshsinh * coshsin;
helper.Out.z = DefaultZ(helper);
@@ -5691,9 +5733,9 @@ public:
{
T tanhsin, tanhcos, tanhsinh, tanhcosh, tanhden;
sincos(2 * helper.In.y, &tanhsin, &tanhcos);
tanhsinh = sinh(2 * helper.In.x);
tanhcosh = cosh(2 * helper.In.x);
tanhden = 1 / (tanhcos + tanhcosh);
tanhsinh = std::sinh(2 * helper.In.x);
tanhcosh = std::cosh(2 * helper.In.x);
tanhden = 1 / Zeps(tanhcos + tanhcosh);
helper.Out.x = m_Weight * tanhden * tanhsinh;
helper.Out.y = m_Weight * tanhden * tanhsin;
helper.Out.z = DefaultZ(helper);
@@ -5708,7 +5750,7 @@ public:
<< "\t\treal_t tanhcos = cos((real_t)(2.0) * vIn.y);\n"
<< "\t\treal_t tanhsinh = sinh((real_t)(2.0) * vIn.x);\n"
<< "\t\treal_t tanhcosh = cosh((real_t)(2.0) * vIn.x);\n"
<< "\t\treal_t tanhden = (real_t)(1.0) / (tanhcos + tanhcosh);\n"
<< "\t\treal_t tanhden = (real_t)(1.0) / Zeps(tanhcos + tanhcosh);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * tanhden * tanhsinh;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * tanhden * tanhsin;\n"
@@ -5716,6 +5758,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5733,9 +5780,9 @@ public:
{
T sechsin, sechcos, sechsinh, sechcosh, sechden;
sincos(helper.In.y, &sechsin, &sechcos);
sechsinh = sinh(helper.In.x);
sechcosh = cosh(helper.In.x);
sechden = 2 / (cos(2 * helper.In.y) + cosh(2 * helper.In.x));
sechsinh = std::sinh(helper.In.x);
sechcosh = std::cosh(helper.In.x);
sechden = 2 / Zeps(std::cos(2 * helper.In.y) + std::cosh(2 * helper.In.x));
helper.Out.x = m_Weight * sechden * sechcos * sechcosh;
helper.Out.y = -(m_Weight * sechden * sechsin * sechsinh);
helper.Out.z = DefaultZ(helper);
@@ -5750,7 +5797,7 @@ public:
<< "\t\treal_t sechcos = cos(vIn.y);\n"
<< "\t\treal_t sechsinh = sinh(vIn.x);\n"
<< "\t\treal_t sechcosh = cosh(vIn.x);\n"
<< "\t\treal_t sechden = (real_t)(2.0) / (cos((real_t)(2.0) * vIn.y) + cosh((real_t)(2.0) * vIn.x));\n"
<< "\t\treal_t sechden = (real_t)(2.0) / Zeps(cos((real_t)(2.0) * vIn.y) + cosh((real_t)(2.0) * vIn.x));\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sechden * sechcos * sechcosh;\n"
<< "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * sechden * sechsin * sechsinh);\n"
@@ -5758,6 +5805,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5777,7 +5829,7 @@ public:
sincos(helper.In.y, &cschsin, &cschcos);
cschsinh = std::sinh(helper.In.x);
cschcosh = std::cosh(helper.In.x);
cschden = 2 / (std::cosh(2 * helper.In.x) - std::cos(2 * helper.In.y));
cschden = 2 / Zeps(std::cosh(2 * helper.In.x) - std::cos(2 * helper.In.y));
helper.Out.x = m_Weight * cschden * cschsinh * cschcos;
helper.Out.y = -(m_Weight * cschden * cschcosh * cschsin);
helper.Out.z = DefaultZ(helper);
@@ -5792,7 +5844,7 @@ public:
<< "\t\treal_t cschcos = cos(vIn.y);\n"
<< "\t\treal_t cschsinh = sinh(vIn.x);\n"
<< "\t\treal_t cschcosh = cosh(vIn.x);\n"
<< "\t\treal_t cschden = (real_t)(2.0) / (cosh((real_t)(2.0) * vIn.x) - cos((real_t)(2.0) * vIn.y));\n"
<< "\t\treal_t cschden = (real_t)(2.0) / Zeps(cosh((real_t)(2.0) * vIn.x) - cos((real_t)(2.0) * vIn.y));\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cschden * cschsinh * cschcos;\n"
<< "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * cschden * cschcosh * cschsin);\n"
@@ -5800,6 +5852,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5817,9 +5874,9 @@ public:
{
T cothsin, cothcos, cothsinh, cothcosh, cothden;
sincos(2 * helper.In.y, &cothsin, &cothcos);
cothsinh = sinh(2 * helper.In.x);
cothcosh = cosh(2 * helper.In.x);
cothden = 1 / (cothcosh - cothcos);
cothsinh = std::sinh(2 * helper.In.x);
cothcosh = std::cosh(2 * helper.In.x);
cothden = 1 / Zeps(cothcosh - cothcos);
helper.Out.x = m_Weight * cothden * cothsinh;
helper.Out.y = m_Weight * cothden * cothsin;
helper.Out.z = DefaultZ(helper);
@@ -5834,7 +5891,7 @@ public:
<< "\t\treal_t cothcos = cos((real_t)(2.0) * vIn.y);\n"
<< "\t\treal_t cothsinh = sinh((real_t)(2.0) * vIn.x);\n"
<< "\t\treal_t cothcosh = cosh((real_t)(2.0) * vIn.x);\n"
<< "\t\treal_t cothden = (real_t)(1.0) / (cothcosh - cothcos);\n"
<< "\t\treal_t cothden = (real_t)(1.0) / Zeps(cothcosh - cothcos);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cothden * cothsinh;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cothden * cothsin;\n"
@@ -5842,6 +5899,11 @@ public:
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
};
/// <summary>
@@ -5862,8 +5924,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 + std::abs(helper.In.y) * s);
T dx = helper.In.x + m_AugerWeight * (m_Scale * t / 2 + std::abs(helper.In.x) * t);
T dy = helper.In.y + m_AugerWeight * (m_Scale * s / Zeps(2 + std::abs(helper.In.y) * s));
T dx = helper.In.x + m_AugerWeight * (m_Scale * t / Zeps(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;
@@ -5882,8 +5944,8 @@ public:
ss << "\t{\n"
<< "\t\treal_t s = sin(" << freq << " * vIn.x);\n"
<< "\t\treal_t t = sin(" << freq << " * vIn.y);\n"
<< "\t\treal_t dy = vIn.y + " << augerWeight << " * (" << scale << " * s / (real_t)(2.0) + fabs(vIn.y) * s);\n"
<< "\t\treal_t dx = vIn.x + " << augerWeight << " * (" << scale << " * t / (real_t)(2.0) + fabs(vIn.x) * t);\n"
<< "\t\treal_t dy = vIn.y + " << augerWeight << " * (" << scale << " * s / Zeps((real_t)(2.0) + fabs(vIn.y) * s));\n"
<< "\t\treal_t dx = vIn.x + " << augerWeight << " * (" << scale << " * t / Zeps((real_t)(2.0) + fabs(vIn.x) * t));\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + " << symmetry << " * (dx - vIn.x));\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * dy;\n"
@@ -5900,6 +5962,11 @@ public:
m_Scale = rand.Frand01<T>();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -5943,7 +6010,7 @@ public:
frac = 1;
T avgr = m_Weight * (m_Spr * std::sqrt(std::sqrt(yy + SQR(xpw)) / frac));
T avga = (atan2(helper.In.y, xmw) - atan2(helper.In.y, xpw)) * T(0.5);
T avga = (std::atan2(helper.In.y, xmw) - std::atan2(helper.In.y, xpw)) * T(0.5);
helper.Out.x = avgr * std::cos(avga);
helper.Out.y = avgr * std::sin(avga);
helper.Out.z = helper.In.z;//Apo does not use weight, sums only z. Sum here for reg, else assign.
+66 -31
View File
@@ -155,7 +155,7 @@ public:
{
lx *= m_G2;
ly *= m_G2;
T r = m_Rfactor / ((SQR(lx) + SQR(ly)) / 4 + 1);
T r = m_Rfactor / Zeps((SQR(lx) + SQR(ly)) / 4 + 1);
lx *= r;
ly *= r;
r = (SQR(lx) + SQR(ly)) / m_R2;
@@ -211,7 +211,7 @@ public:
<< "\t\t lx *= " << g2 << ";\n"
<< "\t\t ly *= " << g2 << ";\n"
<< "\n"
<< "\t\t real_t r = " << rfactor << " / ((SQR(lx) + SQR(ly)) / 4 + 1);\n"
<< "\t\t real_t r = " << rfactor << " / Zeps((SQR(lx) + SQR(ly)) / 4 + 1);\n"
<< "\n"
<< "\t\t lx *= r;\n"
<< "\t\t ly *= r;\n"
@@ -245,10 +245,15 @@ public:
else
maxBubble *= (1 / (SQR(maxBubble) / 4 + 1));
m_R2 = SQR(radius);
m_R2 = Zeps(SQR(radius));
m_Rfactor = radius / maxBubble;
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -1957,7 +1962,7 @@ 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;
T avga = (atan2(helper.In.y, helper.In.x - 1) - std::atan2(helper.In.y, helper.In.x + 1)) / 2;
sincos(avga, &s, &c);
helper.Out.x = avgr * c;
helper.Out.y = avgr * s;
@@ -2033,7 +2038,7 @@ public:
virtual void Precalc() override
{
m_K = T(0.5) * std::log(Zeps(SQR(m_Real) + SQR(m_Imag)));//Original used 1e-300, which isn't representable with a float.
m_T = atan2(m_Imag, m_Real);
m_T = std::atan2(m_Imag, m_Real);
}
protected:
@@ -2958,7 +2963,7 @@ public:
T r2 = helper.m_PrecalcSumSquares + helper.In.z;
T x2cx = m_C2x * helper.In.x;
T y2cy = m_C2y * helper.In.y;
T d = m_Weight / (m_C2 * r2 + x2cx - y2cy + 1);
T d = m_Weight / Zeps(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);
@@ -2987,7 +2992,7 @@ public:
<< "\t\treal_t r2 = precalcSumSquares + vIn.z;\n"
<< "\t\treal_t x2cx = " << c2x << " * vIn.x;\n"
<< "\t\treal_t y2cy = " << c2y << " * vIn.y;\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] / (" << c2 << " * r2 + x2cx - y2cy + 1);\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] / Zeps(" << c2 << " * r2 + x2cx - y2cy + 1);\n"
<< "\n"
<< "\t\tvOut.x = d * (vIn.x * " << s2x << " - " << cx << "* ( y2cy - r2 - 1));\n"
<< "\t\tvOut.y = d * (vIn.y * " << s2y << " + " << cy << "* (-x2cx - r2 - 1));\n"
@@ -3018,6 +3023,11 @@ public:
m_S2z = 1 - SQR(m_Cy) - SQR(m_Cx);
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -3078,7 +3088,7 @@ public:
T r2 = helper.m_PrecalcSumSquares + SQR(helper.In.z);
T x2cx = 2 * cx * helper.In.x;
T y2cy = 2 * cy * helper.In.x;
T d = m_Weight / (m_C2 * r2 + x2cx - y2cy + 1);
T d = m_Weight / Zeps(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);
@@ -3105,7 +3115,7 @@ public:
<< "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n"
<< "\t\treal_t x2cx = 2 * cx * vIn.x;\n"
<< "\t\treal_t y2cy = 2 * cy * vIn.x;\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] / (" << c2 << " * r2 + x2cx - y2cy + 1);\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] / Zeps(" << c2 << " * r2 + x2cx - y2cy + 1);\n"
<< "\n"
<< "\t\tvOut.x = d * (vIn.x * s2x - cx * ( y2cy - r2 - 1));\n"
<< "\t\tvOut.y = d * (vIn.y * s2y + cy * (-x2cx - r2 - 1));\n"
@@ -3131,6 +3141,11 @@ public:
m_S2z = 1 - m_C2;
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -3811,10 +3826,10 @@ public:
{
if (helper.In.x >= 0)
{
xo = (r + 1) / (2 * helper.In.x);
xo = (r + 1) / Zeps(2 * helper.In.x);
ro = std::sqrt(SQR(helper.In.x - xo) + SQR(helper.In.y));
theta = atan2(T(1), ro);
a = fmod(m_In * theta + atan2(helper.In.y, xo - helper.In.x) + theta, 2 * theta) - theta;
theta = std::atan2(T(1), ro);
a = fmod(m_In * theta + std::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;
@@ -3823,8 +3838,8 @@ public:
{
xo = - (r + 1) / (2 * helper.In.x);
ro = std::sqrt(SQR(-helper.In.x - xo) + SQR(helper.In.y));
theta = atan2(T(1), ro);
a = fmod(m_In * theta + atan2(helper.In.y, xo + helper.In.x) + theta, 2 * theta) - theta;
theta = std::atan2(T(1), ro);
a = fmod(m_In * theta + std::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;
@@ -3840,10 +3855,10 @@ public:
if (x >= 0)
{
xo = (SQR(x) + SQR(y) + 1) / (2 * x);
xo = (SQR(x) + SQR(y) + 1) / Zeps(2 * x);
ro = std::sqrt(SQR(x - xo) + SQR(y));
theta = std::atan2(T(1), ro);
a = fmod(m_Out * theta + atan2(y, xo - x) + theta, 2 * theta) - theta;
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;
@@ -3895,7 +3910,7 @@ public:
<< "\t\t{\n"
<< "\t\t if (vIn.x >= 0)\n"
<< "\t\t {\n"
<< "\t\t xo = (r + 1) / (2 * vIn.x);\n"
<< "\t\t xo = (r + 1) / Zeps(2 * vIn.x);\n"
<< "\t\t ro = sqrt(SQR(vIn.x - xo) + SQR(vIn.y));\n"
<< "\t\t theta = atan2(1, ro);\n"
<< "\t\t a = fmod(" << in << " * theta + atan2(vIn.y, xo - vIn.x) + theta, 2 * theta) - theta;\n"
@@ -3928,7 +3943,7 @@ public:
<< "\n"
<< "\t\t if (x >= 0)\n"
<< "\t\t {\n"
<< "\t\t xo = (SQR(x) + SQR(y) + 1) / (2 * x);\n"
<< "\t\t xo = (SQR(x) + SQR(y) + 1) / Zeps(2 * x);\n"
<< "\t\t ro = sqrt(SQR(x - xo) + SQR(y));\n"
<< "\t\t theta = atan2(1 , ro);\n"
<< "\t\t a = fmod(" << out << " * theta + atan2(y, xo - x) + theta, 2 * theta) - theta;\n"
@@ -3971,6 +3986,11 @@ public:
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -4001,10 +4021,10 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
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));
T x = m_C1x + (SQR(m_C1r) * (helper.In.x - m_C1x)) / Zeps(Sqr(helper.In.x - m_C1x) + Sqr(helper.In.y - m_C1y));
T y = m_C1y + (SQR(m_C1r) * (helper.In.y - m_C1y)) / Zeps(Sqr(helper.In.x - m_C1x) + Sqr(helper.In.y - m_C1y));
helper.Out.x = m_C2x + (SQR(m_C2r) * (x - m_C2x)) / Zeps(Sqr(x - m_C2x) + Sqr(y - m_C2y));
helper.Out.y = m_C2y + (SQR(m_C2r) * (y - m_C2y)) / Zeps(Sqr(x - m_C2x) + Sqr(y - m_C2y));
helper.Out.z = DefaultZ(helper);
}
@@ -4025,11 +4045,11 @@ public:
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"
<< "\t\treal_t x = " << c1x << " + (SQR(" << c1r << ") * (vIn.x - " << c1x << ")) / Zeps(Sqr(vIn.x - " << c1x << ") + Sqr(vIn.y - " << c1y << "));\n"
<< "\t\treal_t y = " << c1y << " + (SQR(" << c1r << ") * (vIn.y - " << c1y << ")) / Zeps(Sqr(vIn.x - " << c1x << ") + Sqr(vIn.y - " << c1y << "));\n"
<< "\n"
<< "\t\tvOut.x = " << c2x << " + (SQR(" << c2r << ") * (x - " << c2x << ")) / (SQR(x - " << c2x << ") + SQR(y - " << c2y << "));\n"
<< "\t\tvOut.y = " << c2y << " + (SQR(" << c2r << ") * (y - " << c2y << ")) / (SQR(x - " << c2x << ") + SQR(y - " << c2y << "));\n"
<< "\t\tvOut.x = " << c2x << " + (SQR(" << c2r << ") * (x - " << c2x << ")) / Zeps(Sqr(x - " << c2x << ") + Sqr(y - " << c2y << "));\n"
<< "\t\tvOut.y = " << c2y << " + (SQR(" << c2r << ") * (y - " << c2y << ")) / Zeps(Sqr(x - " << c2x << ") + Sqr(y - " << c2y << "));\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
@@ -4045,6 +4065,11 @@ public:
m_C2y = m_C2d * std::sin(fmod(m_C2a, T(M_PI)));
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Sqr", "Zeps" };
}
protected:
void Init()
{
@@ -4358,7 +4383,7 @@ public:
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);
T r3den = 1 / Zeps(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 = DefaultZ(helper);
@@ -4390,7 +4415,7 @@ public:
<< "\t\treal_t br = " << b3 << " * (xcb - 3 * vIn.x * ysqr) + " << b2 << " * (xsqr - ysqr) + " << b1 << " * vIn.x + " << bc << ";\n"
<< "\t\treal_t bi = " << b3 << " * (3 * xsqr * vIn.y - ycb) + " << b2 << " * 2 * vIn.x * vIn.y + " << b1 << " * vIn.y;\n"
<< "\n"
<< "\t\treal_t r3den = 1 / (br * br + bi * bi);\n"
<< "\t\treal_t r3den = 1 / Zeps(br * br + bi * bi);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (tr * br + ti * bi) * r3den;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (ti * br - tr * bi) * r3den;\n"
@@ -4399,6 +4424,11 @@ public:
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -4663,6 +4693,11 @@ public:
m_Vv = std::abs(m_Weight);
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -5192,7 +5227,7 @@ public:
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);
T invDenom = 1 / Zeps(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;
@@ -5221,7 +5256,7 @@ public:
<< "\t\treal_t dot02 = " << a << " * vIn.x + " << b << " * vIn.y;\n"
<< "\t\treal_t dot11 = SQR(" << c << ") + SQR(" << d << ");\n"
<< "\t\treal_t dot12 = " << c << " * vIn.x + " << d << " * vIn.y;\n"
<< "\t\treal_t invDenom = (real_t)(1.0) / (dot00 * dot11 - dot01 * dot01);\n"
<< "\t\treal_t invDenom = (real_t)(1.0) / Zeps(dot00 * dot11 - dot01 * dot01);\n"
<< "\t\treal_t u = (dot11 * dot02 - dot01 * dot12) * invDenom;\n"
<< "\t\treal_t v = (dot00 * dot12 - dot01 * dot02) * invDenom;\n"
<< "\t\treal_t um = sqrt(SQR(u) + SQR(vIn.x)) * Sign(u);\n"
@@ -5236,7 +5271,7 @@ public:
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Sign" };
return vector<string> { "Sign", "Zeps" };
}
protected:
+11 -11
View File
@@ -20,9 +20,9 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T temp = 1 / Zeps(cos(helper.In.y)) + m_Effect * T(M_PI);
helper.Out.x = m_Weight * (tanh(helper.In.x) * temp);
helper.Out.y = m_Weight * (tanh(helper.In.y) * temp);
T temp = 1 / Zeps(std::cos(helper.In.y)) + m_Effect * T(M_PI);
helper.Out.x = m_Weight * (std::tanh(helper.In.x) * temp);
helper.Out.y = m_Weight * (std::tanh(helper.In.y) * temp);
helper.Out.z = DefaultZ(helper);
}
@@ -1111,7 +1111,7 @@ public:
T coeff = std::abs(helper.In.z);
if (coeff != 0 && m_Power != 1)
coeff = std::exp(log(coeff) * m_Power);
coeff = std::exp(std::log(coeff) * m_Power);
helper.Out.x = m_Weight * (helper.m_TransX + helper.In.x * coeff);
helper.Out.y = m_Weight * (helper.m_TransY + helper.In.y * coeff);
@@ -2258,7 +2258,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T dx, dy, r = m_Weight / (helper.m_PrecalcSumSquares + EPS);
T dx, dy, r = m_Weight / Zeps(helper.m_PrecalcSumSquares);
int isXY = int(VarFuncs<T>::LRint(helper.In.x * m_InvSize) + VarFuncs<T>::LRint(helper.In.y * m_InvSize));
if (isXY & 1)
@@ -2289,7 +2289,7 @@ public:
string rand = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string invSize = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
ss << "\t{\n"
<< "\t\treal_t dx, dy, r = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + EPS);\n"
<< "\t\treal_t dx, dy, r = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares);\n"
<< "\t\tint isXY = LRint(vIn.x * " << invSize << ") + LRint(vIn.y * " << invSize << ");\n"
<< "\n"
<< "\t\tif (isXY & 1)\n"
@@ -2312,12 +2312,12 @@ public:
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "LRint" };
return vector<string> { "LRint", "Zeps" };
}
virtual void Precalc() override
{
m_InvSize = 1 / (m_Size + EPS);
m_InvSize = 1 / Zeps(m_Size);
}
protected:
@@ -3468,8 +3468,8 @@ public:
sigma = alt * m_PiCn + fmod(sigma - m_CaCn, m_PiCn);
T temp = std::cosh(tau) - std::cos(sigma);
helper.Out.x = m_Weight * sinh(tau) / temp;
helper.Out.y = m_Weight * sin(sigma) / temp;
helper.Out.x = m_Weight * std::sinh(tau) / temp;
helper.Out.y = m_Weight * std::sin(sigma) / temp;
helper.Out.z = DefaultZ(helper);
}
@@ -3791,7 +3791,7 @@ public:
}
helper.Out.x = m_Weight * xmax * std::cos(nu);
helper.Out.y = m_Weight * std::sqrt(xmax - 1) * std::sqrt(xmax + 1) * sin(nu);
helper.Out.y = m_Weight * std::sqrt(xmax - 1) * std::sqrt(xmax + 1) * std::sin(nu);
helper.Out.z = DefaultZ(helper);
}
+12 -12
View File
@@ -592,8 +592,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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.x = (m_Weight / d) * (std::tanh(d) * (2 * helper.In.x));
helper.Out.y = (m_Weight / d) * (std::cos(d) * (2 * helper.In.y));
helper.Out.z = DefaultZ(helper);
}
@@ -631,8 +631,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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.x = (m_Weight / 2) * (std::tanh(d) * (2 * helper.In.x));
helper.Out.y = (m_Weight / 2) * (std::cos(d) * (2 * helper.In.y));
helper.Out.z = DefaultZ(helper);
}
@@ -3664,7 +3664,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T ni = m_Weight / Zeps(helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(helper.In.x);
T c = std::cos(helper.In.x);
T sh = std::sinh(absV);
@@ -3681,7 +3681,7 @@ public:
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"
<< "\t\treal_t ni = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares + SQR(vIn.z));\n"
<< "\t\treal_t s = sin(vIn.x);\n"
<< "\t\treal_t c = cos(vIn.x);\n"
<< "\t\treal_t sh = sinh(absV);\n"
@@ -3715,7 +3715,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T ni = m_Weight / Zeps(helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(absV);
T c = std::cos(absV);
T sh = std::sinh(helper.In.x);
@@ -3732,7 +3732,7 @@ public:
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"
<< "\t\treal_t ni = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares + SQR(vIn.z));\n"
<< "\t\treal_t s = sin(absV);\n"
<< "\t\treal_t c = cos(absV);\n"
<< "\t\treal_t sh = sinh(vIn.x);\n"
@@ -4731,7 +4731,7 @@ public:
if (r <= m_R1)
{
r *= m_R2 / m_R1;
temp = atan2(helper.In.y, c1mx);
temp = std::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);
}
@@ -4749,7 +4749,7 @@ public:
if (r <= m_R2)
{
r *= m_R1 / m_R2;
temp = atan2(helper.In.y, c1mx);
temp = std::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);
}
@@ -5060,10 +5060,10 @@ public:
T ymax = T(0.5) * (std::sqrt(tmp + y2) + std::sqrt(tmp - y2));
T a = helper.In.x / Zeps(xmax);
T b = VarFuncs<T>::SafeSqrt(1 - SQR(a));
helper.Out.x = m_Vx * atan2(a, b) * r;
helper.Out.x = m_Vx * std::atan2(a, b) * r;
a = helper.In.y / Zeps(ymax);
b = VarFuncs<T>::SafeSqrt(1 - SQR(a));
helper.Out.y = m_Vy * atan2(a, b) * r;
helper.Out.y = m_Vy * std::atan2(a, b) * r;
helper.Out.z = DefaultZ(helper);
}
+32 -17
View File
@@ -1086,8 +1086,8 @@ public:
T uu = SQR(helper.In.x);
T vv = SQR(helper.In.y);
T ww = SQR(helper.In.z);
T atOmegaX = atan2(vv, ww);
T atOmegaY = atan2(uu, ww);
T atOmegaX = std::atan2(vv, ww);
T atOmegaY = std::atan2(uu, ww);
T su = std::sin(helper.In.x);
T cu = std::cos(helper.In.x);
T sv = std::sin(helper.In.y);
@@ -1994,7 +1994,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T t = helper.m_PrecalcSumSquares + SQR(helper.In.z);
T r = 1 / (std::sqrt(t) * (t + m_InvWeight));
T r = 1 / Zeps(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;
@@ -2010,7 +2010,7 @@ public:
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"
<< "\t\treal_t r = 1 / Zeps(sqrt(t) * (t + " << invWeight << "));\n"
<< "\t\treal_t z = vIn.z == 0 ? precalcAtanyx : vIn.z;\n"
<< "\n"
<< "\t\tvOut.x = vIn.x * r;\n"
@@ -2025,6 +2025,11 @@ public:
m_InvWeight = 1 / Zeps(m_Weight);
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -2159,12 +2164,12 @@ public:
if (offsetX >= 0)
{
helper.Out.x += m_Weight * (offsetX * T(0.5) + roundX + m_X);
helper.Out.y += m_Weight * (offsetY * T(0.5) + roundY + m_Y * offsetY / offsetX);
helper.Out.y += m_Weight * (offsetY * T(0.5) + roundY + m_Y * offsetY / Zeps(offsetX));
}
else
{
helper.Out.x += m_Weight * (offsetX * T(0.5) + roundX - m_Y);
helper.Out.y += m_Weight * (offsetY * T(0.5) + roundY - m_Y * offsetY / offsetX);
helper.Out.y += m_Weight * (offsetY * T(0.5) + roundY - m_Y * offsetY / Zeps(offsetX));
}
}
else
@@ -2172,12 +2177,12 @@ public:
if (offsetY >= 0)
{
helper.Out.y += m_Weight * (offsetY * T(0.5) + roundY + m_Y);
helper.Out.x += m_Weight * (offsetX * T(0.5) + roundX + offsetX / offsetY * m_Y);
helper.Out.x += m_Weight * (offsetX * T(0.5) + roundX + offsetX / Zeps(offsetY) * m_Y);
}
else
{
helper.Out.y += m_Weight * (offsetY * T(0.5) + roundY - m_Y);
helper.Out.x += m_Weight * (offsetX * T(0.5) + roundX - offsetX / offsetY * m_X);
helper.Out.x += m_Weight * (offsetX * T(0.5) + roundX - offsetX / Zeps(offsetY) * m_X);
}
}
}
@@ -2219,12 +2224,12 @@ public:
<< "\t\t if (offsetX >= 0)\n"
<< "\t\t {\n"
<< "\t\t vOut.x += xform->m_VariationWeights[" << varIndex << "] * (offsetX * (real_t)(0.5) + roundX + " << x << ");\n"
<< "\t\t vOut.y += xform->m_VariationWeights[" << varIndex << "] * (offsetY * (real_t)(0.5) + roundY + " << y << " * offsetY / offsetX);\n"
<< "\t\t vOut.y += xform->m_VariationWeights[" << varIndex << "] * (offsetY * (real_t)(0.5) + roundY + " << y << " * offsetY / Zeps(offsetX));\n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t vOut.x += xform->m_VariationWeights[" << varIndex << "] * (offsetX * (real_t)(0.5) + roundX - " << y << ");\n"
<< "\t\t vOut.y += xform->m_VariationWeights[" << varIndex << "] * (offsetY * (real_t)(0.5) + roundY - " << y << " * offsetY / offsetX);\n"
<< "\t\t vOut.y += xform->m_VariationWeights[" << varIndex << "] * (offsetY * (real_t)(0.5) + roundY - " << y << " * offsetY / Zeps(offsetX));\n"
<< "\t\t }\n"
<< "\t\t }\n"
<< "\t\t else\n"
@@ -2232,12 +2237,12 @@ public:
<< "\t\t if (offsetY >= 0)\n"
<< "\t\t {\n"
<< "\t\t vOut.y += xform->m_VariationWeights[" << varIndex << "] * (offsetY * (real_t)(0.5) + roundY + " << y << ");\n"
<< "\t\t vOut.x += xform->m_VariationWeights[" << varIndex << "] * (offsetX * (real_t)(0.5) + roundX + offsetX / offsetY * " << y << ");\n"
<< "\t\t vOut.x += xform->m_VariationWeights[" << varIndex << "] * (offsetX * (real_t)(0.5) + roundX + offsetX / Zeps(offsetY) * " << y << ");\n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t vOut.y += xform->m_VariationWeights[" << varIndex << "] * (offsetY * (real_t)(0.5) + roundY - " << y << ");\n"
<< "\t\t vOut.x += xform->m_VariationWeights[" << varIndex << "] * (offsetX * (real_t)(0.5) + roundX - offsetX / offsetY * " << x << ");\n"
<< "\t\t vOut.x += xform->m_VariationWeights[" << varIndex << "] * (offsetX * (real_t)(0.5) + roundX - offsetX / Zeps(offsetY) * " << x << ");\n"
<< "\t\t }\n"
<< "\t\t }\n"
<< "\t\t}\n"
@@ -2249,6 +2254,11 @@ public:
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
@@ -2360,9 +2370,9 @@ public:
default:
scale = Clamp<T>(rs, 0, T(0.9)) + T(0.1);
denom = 1 / scale;
helper.Out.x = m_Weight * Lerp<T>(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<T>(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<T>(helper.In.z, floor(helper.In.z * denom) + scale * az, m_MulZ * rs) + m_MulZ * std::pow(az, m_BoxPow) * rs * denom;
helper.Out.x = m_Weight * Lerp<T>(helper.In.x, std::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<T>(helper.In.y, std::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<T>(helper.In.z, std::floor(helper.In.z * denom) + scale * az, m_MulZ * rs) + m_MulZ * std::pow(az, m_BoxPow) * rs * denom;
break;
}
}
@@ -4131,7 +4141,7 @@ public:
while (++n < 6)
{
if ((m_P[n].y <= i.y && i.y < m_P[j].y) || (m_P[j].y <= i.y && i.y < m_P[n].y))
if (i.x < (m_P[j].x - m_P[n].x) * (i.y - m_P[n].y) / (m_P[j].y - m_P[n].y) + m_P[n].x)
if (i.x < (m_P[j].x - m_P[n].x) * (i.y - m_P[n].y) / Zeps(m_P[j].y - m_P[n].y) + m_P[n].x)
c ^= 1;
j = n;
@@ -4182,7 +4192,7 @@ public:
<< "\t\t int ynoff = " << pyStartIndex << " + n;\n"
<< "\n"
<< "\t\t if ((parVars[ynoff] <= i.y && i.y < parVars[yjoff]) || (parVars[yjoff] <= i.y && i.y < parVars[ynoff]))\n"
<< "\t\t if (i.x < (parVars[xjoff] - parVars[xnoff]) * (i.y - parVars[ynoff]) / (parVars[yjoff] - parVars[ynoff]) + parVars[xnoff])\n"
<< "\t\t if (i.x < (parVars[xjoff] - parVars[xnoff]) * (i.y - parVars[ynoff]) / Zeps(parVars[yjoff] - parVars[ynoff]) + parVars[xnoff])\n"
<< "\t\t c ^= 1;\n"
<< "\n"
<< "\t\t j = n;\n"
@@ -4226,6 +4236,11 @@ public:
m_P[5].y = T(0.0000000000000000000000000000000) * m_ScaleY;
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
+11 -6
View File
@@ -783,9 +783,9 @@ 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);
m_AdjustedWeight = m_Weight / Zeps(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);
m_AdjustedWeight = m_Weight / Zeps(std::sqrt(2 - 2 * std::cos(m_MidAngle * std::floor((m_NumEdges / 2)))) / 2);
}
else
m_AdjustedWeight = m_Weight;
@@ -1515,7 +1515,7 @@ public:
yTmp = m_Top + rand.Frand01<T>() * m_YInt2;
xTmp = m_Right - pow(rand.Frand01<T>(), m_DirectBlur) * m_RatioBlur * m_MinInt2;
}
while ((yTmp - m_Y0c) / (xTmp - m_X0c) < -1);
while ((yTmp - m_Y0c) / Zeps(xTmp - m_X0c) < -1);
if (secTmp < m_SetProbH)
xTmp = m_Left + m_Right - xTmp;
@@ -1529,7 +1529,7 @@ public:
{
xTmp = m_Right - rand.Frand01<T>() * m_XInt2;
yTmp = m_Top + std::pow(rand.Frand01<T>(), m_DirectBlur) * m_RatioBlur * m_MinInt2;
gradTmp = (yTmp - m_Y0c) / (xTmp - m_X0c);
gradTmp = (yTmp - m_Y0c) / Zeps(xTmp - m_X0c);
}
while ((gradTmp <= 0) && (gradTmp > -1));
@@ -1614,7 +1614,7 @@ public:
<< "\t\t {\n"
<< "\t\t yTmp = " << top << " + MwcNext01(mwc) * " << yInt2 << ";\n"
<< "\t\t xTmp = " << right << " - pow(MwcNext01(mwc), " << directBlur << ") * " << ratioBlur << " * " << minInt2 << ";\n"
<< "\t\t } while ((yTmp - " << y0c << ") / (xTmp - " << x0c << ") < -1);\n"
<< "\t\t } while ((yTmp - " << y0c << ") / Zeps(xTmp - " << x0c << ") < -1);\n"
<< "\n"
<< "\t\t if (secTmp < " << setProbH << ")\n"
<< "\t\t xTmp = " << left << " + " << right << " - xTmp;\n"
@@ -1628,7 +1628,7 @@ public:
<< "\t\t {\n"
<< "\t\t xTmp = " << right << " - MwcNext01(mwc) * " << xInt2 << ";\n"
<< "\t\t yTmp = " << top << " + pow(MwcNext01(mwc), " << directBlur << ") * " << ratioBlur << " * " << minInt2 << ";\n"
<< "\t\t gradTmp = (yTmp - " << y0c << ") / (xTmp - " << x0c << ");\n"
<< "\t\t gradTmp = (yTmp - " << y0c << ") / Zeps(xTmp - " << x0c << ");\n"
<< "\t\t } while ((gradTmp <= 0) && (gradTmp > -1));\n"
<< "\n"
<< "\t\t if (secTmp > " << setProbH << ")\n"
@@ -1737,6 +1737,11 @@ public:
}
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected:
void Init()
{
+10 -4
View File
@@ -957,7 +957,7 @@ template <typename T>
class CircleSplitVariation : public ParametricVariation<T>
{
public:
CircleSplitVariation(T weight = 1.0) : ParametricVariation<T>("circlesplit", eVariationId::VAR_CIRCLESPLIT, weight, true, true)
CircleSplitVariation(T weight = 1.0) : ParametricVariation<T>("circlesplit", eVariationId::VAR_CIRCLESPLIT, weight, true, true, false, false, true)
{
Init();
}
@@ -975,7 +975,7 @@ public:
}
else
{
T a = std::atan2(helper.In.y, helper.In.x);
T a = helper.m_PrecalcAtanyx;
T len = helper.m_PrecalcSqrtSumSquares + m_Split;
x1 = std::cos(a) * len;
y1 = std::sin(a) * len;
@@ -983,6 +983,7 @@ public:
helper.Out.x = m_Weight * x1;
helper.Out.y = m_Weight * y1;
helper.Out.z = DefaultZ(helper);
}
virtual string OpenCLString() const override
@@ -1003,13 +1004,14 @@ public:
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t\treal_t a = (real_t)atan2(vIn.y, vIn.x);\n"
<< "\t\t\treal_t a = precalcAtanyx;\n"
<< "\t\t\treal_t len = precalcSqrtSumSquares + " << cs_split << ";\n"
<< "\t\t\tx1 = cos(a) * len;\n"
<< "\t\t\ty1 = sin(a) * len;\n"
<< "\t\t}"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * x1;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y1;\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
}
@@ -1045,6 +1047,7 @@ public:
{
helper.Out.x = m_Weight * (helper.In.x / Zeps(std::sqrt(SQR(helper.In.x) + 1)));
helper.Out.y = m_Weight * helper.In.y;
helper.Out.z = DefaultZ(helper);
}
virtual string OpenCLString() const override
@@ -1055,6 +1058,7 @@ public:
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x / Zeps(sqrt(SQR(vIn.x) + (real_t)1.0)));\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
}
@@ -1086,6 +1090,7 @@ public:
T temp = Round(std::log(rand.Frand01<T>()) * (rand.Rand() & 1 ? m_Spread : -m_Spread));
helper.Out.x = m_Weight * (helper.In.x + temp);
helper.Out.y = m_Weight * helper.In.y;
helper.Out.z = DefaultZ(helper);
}
virtual string OpenCLString() const override
@@ -1100,6 +1105,7 @@ public:
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + temp);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
}
@@ -1341,7 +1347,7 @@ public:
m_FinalExponent = m_Exponent > T(2) ? T(2) : (m_Exponent < T(0.001) ? T(0.001) : m_Exponent);
m_OneOverEx = T(1) / m_FinalExponent;
m_Width = m_ArcWidth > T(1) ? T(1) : (m_ArcWidth < T(0.001) ? T(0.001) : m_ArcWidth);
m_Seed2 = std::sqrt(m_Seed * T(1.5)) / (m_Seed * T(0.5)) * T(0.25);
m_Seed2 = std::sqrt(m_Seed * T(1.5)) / Zeps(m_Seed * T(0.5)) * T(0.25);
m_Rmax = T(0.5) * (std::pow(T(2), m_OneOverEx) - T(1)) * m_Width;
m_Scale = T(1) / m_Weight;
}
+2 -2
View File
@@ -866,10 +866,10 @@ public:
}
if (m_NeedPrecalcAtanXY)
helper.m_PrecalcAtanxy = atan2(helper.m_TransX, helper.m_TransY);
helper.m_PrecalcAtanxy = std::atan2(helper.m_TransX, helper.m_TransY);
if (m_NeedPrecalcAtanYX)
helper.m_PrecalcAtanyx = atan2(helper.m_TransY, helper.m_TransX);
helper.m_PrecalcAtanyx = std::atan2(helper.m_TransY, helper.m_TransX);
}
/// <summary>
+2 -2
View File
@@ -128,7 +128,7 @@ double DEOpenCLKernelCreator::SolveMaxDERad(double desiredFilterSize, double ss)
return desiredFilterSize;
//The final size doesn't fit, so scale the original down until it fits.
return floor((MaxDEFilterSize() - (ss - 1.0)) / ss);
return std::floor((MaxDEFilterSize() - (ss - 1.0)) / ss);
}
/// <summary>
@@ -139,7 +139,7 @@ double DEOpenCLKernelCreator::SolveMaxDERad(double desiredFilterSize, double ss)
/// <returns>The maximum filter box size allowed</returns>
uint DEOpenCLKernelCreator::SolveMaxBoxSize(uint localMem)
{
return uint(floor(std::sqrt(floor(localMem / 16.0))));//Divide by 16 because each element is float4.
return uint(std::floor(std::sqrt(Floor(localMem / 16.0))));//Divide by 16 because each element is float4.
}
/// <summary>
+10
View File
@@ -389,4 +389,14 @@ const string* FunctionMapper::GetGlobalFunc(const string& func)
else
return nullptr;
}
/// <summary>
/// Get a copy of the function map.
/// This is useful only for debugging/testing.
/// </summary>
/// <returns>A copy of the function map</returns>
const std::unordered_map<string, string> FunctionMapper::GetGlobalMapCopy()
{
return s_GlobalMap;
}
}
+1
View File
@@ -14,6 +14,7 @@ class EMBERCL_API FunctionMapper
public:
FunctionMapper();
static const string* GetGlobalFunc(const string& func);
static const std::unordered_map<string, string> GetGlobalMapCopy();
private:
static std::unordered_map<string, string> s_GlobalMap;
+55 -24
View File
@@ -1035,19 +1035,36 @@ bool TestConstants()
return success;
}
void TestFuncs()
{
//auto vlf(VariationList<float>::Instance());
//vector<string> stringVec;
//stringVec.push_back("/ (");
////stringVec.push_back("log(");
//for (size_t i = 0; i < vlf->Size(); i++)
//{
// auto var = vlf->GetVariation(i);
// if (SearchVar(var, stringVec, false))
// {
// cout << var->Name() << endl;
// }
//}
}
bool TestGlobalFuncs()
{
bool success = true;
auto vlf(VariationList<float>::Instance());
vector<string> funcs;
FunctionMapper mapper;
auto funcmap = mapper.GetGlobalMapCopy();
for (size_t i = 0; i < vlf->Size(); i++)
{
auto var = vlf->GetVariation(i);
funcs = var->OpenCLGlobalFuncNames();
for (auto& func : funcs)
for (auto& func : funcs)//Test if the functions the variation says it requires actually exist.
{
if (!mapper.GetGlobalFunc(func))
{
@@ -1059,6 +1076,23 @@ bool TestGlobalFuncs()
//cout << "Variation " << var->Name() << " used valid global funcion " << func << endl;
}
}
auto str = var->OpenCLString();
auto vec = var->OpenCLGlobalFuncNames();
for (auto& func : funcmap)//Test if the functions the variation uses are actually included in those it says are required.
{
if (Find(str, func.first + "("))
{
if (!Contains(vec, func.first))
{
cout << "Variation " << var->Name() << " used global funcion " << func.first << ", but it's not found in its global func name vector: " << endl;
for (auto& v : vec)
cout << v << endl;
}
}
}
}
return success;
@@ -1221,11 +1255,11 @@ void TestVarTime()
helper.m_Color.x = p.m_ColorX = rand.Frand01<T>();
p.m_Opacity = rand.Frand01<T>();
helper.m_PrecalcSumSquares = SQR(helper.m_TransX) + SQR(helper.m_TransY);
helper.m_PrecalcSqrtSumSquares = sqrt(helper.m_PrecalcSumSquares);
helper.m_PrecalcSqrtSumSquares = std::sqrt(helper.m_PrecalcSumSquares);
helper.m_PrecalcSina = helper.m_TransX / helper.m_PrecalcSqrtSumSquares;
helper.m_PrecalcCosa = helper.m_TransY / helper.m_PrecalcSqrtSumSquares;
helper.m_PrecalcAtanxy = atan2(helper.m_TransX, helper.m_TransY);
helper.m_PrecalcAtanyx = atan2(helper.m_TransY, helper.m_TransX);
helper.m_PrecalcAtanxy = std::atan2(helper.m_TransX, helper.m_TransY);
helper.m_PrecalcAtanyx = std::atan2(helper.m_TransY, helper.m_TransX);
var->Random(rand);
t.Tic();
var->Func(helper, p, rand);
@@ -1288,8 +1322,6 @@ void TestOperations()
{
cout << "Variation " << varVec[i]->Name() << " contained MwcNext(mwc) %. Use MwcNextRange() instead." << endl;
}
stringVec.clear();
}
template <typename T>
@@ -1347,11 +1379,11 @@ void TestVarsSimilar()
p.m_Opacity = rand.Frand01<T>();
pComp = p;
helper.m_PrecalcSumSquares = SQR(helper.m_TransX) + SQR(helper.m_TransY);
helper.m_PrecalcSqrtSumSquares = sqrt(helper.m_PrecalcSumSquares);
helper.m_PrecalcSqrtSumSquares = std::sqrt(helper.m_PrecalcSumSquares);
helper.m_PrecalcSina = helper.m_TransX / helper.m_PrecalcSqrtSumSquares;
helper.m_PrecalcCosa = helper.m_TransY / helper.m_PrecalcSqrtSumSquares;
helper.m_PrecalcAtanxy = atan2(helper.m_TransX, helper.m_TransY);
helper.m_PrecalcAtanyx = atan2(helper.m_TransY, helper.m_TransX);
helper.m_PrecalcAtanxy = std::atan2(helper.m_TransX, helper.m_TransY);
helper.m_PrecalcAtanyx = std::atan2(helper.m_TransY, helper.m_TransX);
if (parVar)
{
@@ -1641,10 +1673,10 @@ void TestRandomAccess(size_t vsize, size_t ipp, bool cache)
v4T v4(rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
int index = rand.Rand((ISAAC_INT)vsize);
v4T v42 = vdata[index];
v4.x = log(v4.x);
v4.y = sqrt(v4.y);
v4.z = sin(v4.z);
v4.w = cos(v4.w);
v4.x = std::log(v4.x);
v4.y = std::sqrt(v4.y);
v4.z = std::sin(v4.z);
v4.w = std::cos(v4.w);
v4 += T(1.234);
v4 *= T(55.55);
v4 /= T(0.0045);
@@ -1657,10 +1689,10 @@ void TestRandomAccess(size_t vsize, size_t ipp, bool cache)
{
v4T v4(rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
int index = rand.Rand((ISAAC_INT)vsize);
v4.x = log(v4.x);
v4.y = sqrt(v4.y);
v4.z = sin(v4.z);
v4.w = cos(v4.w);
v4.x = std::log(v4.x);
v4.y = std::sqrt(v4.y);
v4.z = std::sin(v4.z);
v4.w = std::cos(v4.w);
v4 += T(1.234);
v4 *= T(55.55);
v4 /= T(0.0045);
@@ -1673,7 +1705,7 @@ template <typename T>
void TestCross(T x, T y, T weight)
{
T s = x * x - y * y;
T r = weight * sqrt(1 / (s * s + EPS));
T r = weight * std::sqrt(1 / (s * s + EPS));
T outX = x * r;
T outY = y * r;
cout << "First way, outX, outY == " << outX << ", " << outY << endl;
@@ -1931,9 +1963,8 @@ int _tmain(int argc, _TCHAR* argv[])
vector<Ember<double>> dv;
list<Ember<float>> fl;
list<Ember<double>> dl;
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
/* string line = "title=\"cj_aerie\" smooth=no", delim = " =\"";
/* TestFuncs();
string line = "title=\"cj_aerie\" smooth=no", delim = " =\"";
auto vec = Split(line, delim, true);
for (auto& s : vec) cout << s << endl;
@@ -1958,9 +1989,9 @@ int _tmain(int argc, _TCHAR* argv[])
TestRotate<double>();
return 1;
*/
MakeTestAllVarsRegPrePostComboFile("testallvarsout.flame");
return 0;
/*
//MakeTestAllVarsRegPrePostComboFile("testallvarsout.flame");
/* return 0;
TestThreadedKernel();
@@ -481,8 +481,8 @@ int FinalRenderEmberController<T>::ProgressFunc(Ember<T>& ember, void* foo, doub
{
static int count = 0;
size_t strip = *(reinterpret_cast<size_t*>(FirstOrDefaultRenderer()->m_ProgressParameter));
double fracPerStrip = ceil(100.0 / m_GuiState.m_Strips);
double stripsfrac = ceil(fracPerStrip * strip) + ceil(fraction / m_GuiState.m_Strips);
double fracPerStrip = std::ceil(100.0 / m_GuiState.m_Strips);
double stripsfrac = std::ceil(fracPerStrip * strip) + std::ceil(fraction / m_GuiState.m_Strips);
int intFract = int(stripsfrac);
if (stage == 0)
+12 -12
View File
@@ -319,6 +319,7 @@ void FractoriumEmberController<T>::PaletteEditorButtonClicked()
{
size_t i = 0;
auto ed = m_Fractorium->m_PaletteEditor;
Palette<float> edPal;
Palette<float> prevPal = m_TempPalette;
ed->SetPalette(m_TempPalette);
map<size_t, float> colorIndices;
@@ -327,28 +328,27 @@ void FractoriumEmberController<T>::PaletteEditorButtonClicked()
colorIndices[i++] = xform->m_ColorX;
ed->SetColorIndices(colorIndices);
ed->SetPaletteFile(m_CurrentPaletteFilePath);
if (ed->exec() == QDialog::Accepted)
{
if (!m_Fractorium->PaletteChanged())//If the clicked ok, but never synced, set the palette now.
SetBasePaletteAndAdjust(ed->GetPalette(int(256)));
{
edPal = ed->GetPalette(int(256));
SetBasePaletteAndAdjust(edPal);
if (edPal.m_Filename.get() && !edPal.m_Filename->empty())
m_Fractorium->SetPaletteFileComboIndex(*edPal.m_Filename);
}
}
else if (m_Fractorium->PaletteChanged())//They clicked cancel, but synced at least once, restore the previous palette.
{
SetBasePaletteAndAdjust(prevPal);
}
//If the palette was modifiable, and any palette was changed at least once
if (m_Fractorium->m_PaletteFileChanged && m_PaletteList->IsModifiable(m_CurrentPaletteFilePath))
{
if (!::FillPaletteTable(m_CurrentPaletteFilePath, m_Fractorium->ui.PaletteListTable, m_PaletteList))
{
vector<string> errors = m_PaletteList->ErrorReport();
m_Fractorium->ErrorReportToQTextEdit(errors, m_Fractorium->ui.InfoFileOpeningTextEdit);
m_Fractorium->ShowCritical("Palette Read Error", "Could not re-load modified palette file, all images will be black. See info tab for details.");
m_PaletteList->ClearErrorReport();
}
}
//Whether the current palette file was changed or not, if it's modifiable then reload it just to be safe.
if (m_PaletteList->IsModifiable(m_CurrentPaletteFilePath))
m_Fractorium->OnPaletteFilenameComboChanged(QString::fromStdString(m_CurrentPaletteFilePath));
}
/// <summary>
+9 -9
View File
@@ -259,21 +259,21 @@ void FractoriumEmberController<T>::AffineSetHelper(double d, int index, bool pre
{
case 0:
case 3:
affine.A(cos(spinners[0]->value() * DEG_2_RAD) * spinners[3]->value());
affine.D(sin(spinners[0]->value() * DEG_2_RAD) * spinners[3]->value());
affine.A(std::cos(spinners[0]->value() * DEG_2_RAD) * spinners[3]->value());
affine.D(std::sin(spinners[0]->value() * DEG_2_RAD) * spinners[3]->value());
break;
case 1:
case 4:
affine.B(cos(spinners[1]->value() * DEG_2_RAD) * spinners[4]->value());
affine.E(sin(spinners[1]->value() * DEG_2_RAD) * spinners[4]->value());
affine.B(std::cos(spinners[1]->value() * DEG_2_RAD) * spinners[4]->value());
affine.E(std::sin(spinners[1]->value() * DEG_2_RAD) * spinners[4]->value());
break;
case 2:
case 5:
default:
affine.C(cos(spinners[2]->value() * DEG_2_RAD) * spinners[5]->value());
affine.F(sin(spinners[2]->value() * DEG_2_RAD) * spinners[5]->value());
affine.C(std::cos(spinners[2]->value() * DEG_2_RAD) * spinners[5]->value());
affine.F(std::sin(spinners[2]->value() * DEG_2_RAD) * spinners[5]->value());
break;
}
}
@@ -623,9 +623,9 @@ void FractoriumEmberController<T>::FillAffineWithXform(Xform<T>* xform, bool pre
if (m_Fractorium->ui.PolarAffineCheckBox->isChecked())
{
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[0]->SetValueStealth(RAD_2_DEG * std::atan2(affine.D(), affine.A()));
spinners[1]->SetValueStealth(RAD_2_DEG * std::atan2(affine.E(), affine.B()));
spinners[2]->SetValueStealth(RAD_2_DEG * std::atan2(affine.F(), affine.C()));
spinners[3]->SetValueStealth(VarFuncs<T>::Hypot(affine.D(), affine.A()));
spinners[4]->SetValueStealth(VarFuncs<T>::Hypot(affine.E(), affine.B()));
spinners[5]->SetValueStealth(VarFuncs<T>::Hypot(affine.F(), affine.C()));
+4 -4
View File
@@ -860,10 +860,10 @@ void GLEmberController<T>::DrawGrid()
double scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
float unitX = (std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f) / scale;
float unitY = (std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f) / scale;
float xLow = floor(-unitX);
float xHigh = ceil(unitX);
float yLow = floor(-unitY);
float yHigh = ceil(unitY);
float xLow = std::floor(-unitX);
float xHigh = std::ceil(unitX);
float yLow = std::floor(-unitY);
float yHigh = std::ceil(unitY);
float alpha = 0.25f;
Affine2D<T> temp;
m4T mat = (temp * scale).ToMat4RowMajor();
+5 -2
View File
@@ -70,8 +70,11 @@
<height>16777215</height>
</size>
</property>
<property name="font">
</property>
<property name="font">
<font>
<kerning>true</kerning>
</font>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
@@ -105,18 +105,18 @@ ColorTriangle::ColorTriangle(QWidget* parent)
void ColorTriangle::Polish()
{
outerRadius = CalcOuterRadius();//Matt
penWidth = (int) floor(outerRadius / 50.0);
ellipseSize = (int) floor(outerRadius / 12.5);
penWidth = (int)Floor(outerRadius / 50.0);
ellipseSize = (int) Floor(outerRadius / 12.5);
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
pa = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 10.0))));
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (std::cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 10.0))));
// Find the current position of the selector
selectorPos = PointFromColor(curColor);
update();
@@ -182,7 +182,7 @@ void ColorTriangle::GenBackground()
for (int f = 0; f <= 5760; f += 20)
{
int value = int((0.5 + cos(((f - 1800) / 5760.0) * TWOPI) / 2) * 255.0);
int value = int((0.5 + std::cos(((f - 1800) / 5760.0) * TWOPI) / 2) * 255.0);
color.setHsv(int((f / 5760.0) * 360.0), 128 + (255 - value) / 2, 255 - (255 - value) / 4);
p.setPen(QPen(color, penThickness));
p.drawArc(innerRadiusRect, 1440 - f, 20);
@@ -237,14 +237,14 @@ void ColorTriangle::mouseMoveEvent(QMouseEvent* e)
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
pa = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 10.0))));
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (std::cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 10.0))));
selectorPos = PointFromColor(curColor);
}
else
@@ -331,14 +331,14 @@ void ColorTriangle::mousePressEvent(QMouseEvent* e)
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
pa = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 10.0))));
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (std::cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 10.0))));
selectorPos = PointFromColor(curColor);
emit ColorChanged(curColor);
}
@@ -477,18 +477,18 @@ void ColorTriangle::keyPressEvent(QKeyEvent* e)
void ColorTriangle::resizeEvent(QResizeEvent*)
{
outerRadius = CalcOuterRadius();//Matt
penWidth = (int) floor(outerRadius / 50.0);
ellipseSize = (int) floor(outerRadius / 12.5);
penWidth = (int)Floor(outerRadius / 50.0);
ellipseSize = (int)Floor(outerRadius / 12.5);
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
pa = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 10.0))));
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(b) * (outerRadius - (outerRadius / 5.0))));
pc = QPointF(cx + (std::cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(c) * (outerRadius - (outerRadius / 5.0))));
pd = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 10.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 10.0))));
// Find the current position of the selector
selectorPos = PointFromColor(curColor);
mustGenerateBackground = true;
@@ -614,10 +614,10 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
QVarLengthArray<DoubleColor, 2000> rightColors;
QVarLengthArray<double, 2000> leftX;
QVarLengthArray<double, 2000> rightX;
leftColors.resize(int(floor(p3->point.y() + 1)));
rightColors.resize(int(floor(p3->point.y() + 1)));
leftX.resize(int(floor(p3->point.y() + 1)));
rightX.resize(int(floor(p3->point.y() + 1)));
leftColors.resize(int(Floor(p3->point.y() + 1)));
rightColors.resize(int(Floor(p3->point.y() + 1)));
leftX.resize(int(Floor(p3->point.y() + 1)));
rightX.resize(int(Floor(p3->point.y() + 1)));
// Scan longy - find all left and right colors and X-values for
// the tallest edge (p1-p3).
DoubleColor source;
@@ -634,8 +634,8 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
r = source.r;
g = source.g;
b = source.b;
y1 = (int) floor(p1->point.y());
y2 = (int) floor(p3->point.y());
y1 = (int)Floor(p1->point.y());
y2 = (int)Floor(p3->point.y());
// Find slopes (notice that if the y dists are 0, we don't care
// about the slopes)
xdelta = p1p3ydist == 0.0 ? 0.0 : p1p3xdist / p1p3ydist;
@@ -672,8 +672,8 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
r = source.r;
g = source.g;
b = source.b;
y1 = (int) floor(p1->point.y());
y2 = (int) floor(p2->point.y());
y1 = (int)Floor(p1->point.y());
y2 = (int)Floor(p2->point.y());
// Find slopes (notice that if the y dists are 0, we don't care
// about the slopes)
xdelta = p1p2ydist == 0.0 ? 0.0 : p1p2xdist / p1p2ydist;
@@ -709,8 +709,8 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
r = source.r;
g = source.g;
b = source.b;
y1 = (int) floor(p2->point.y());
y2 = (int) floor(p3->point.y());
y1 = (int)Floor(p2->point.y());
y2 = (int)Floor(p3->point.y());
// Find slopes (notice that if the y dists are 0, we don't care
// about the slopes)
xdelta = p2p3ydist == 0.0 ? 0.0 : p2p3xdist / p2p3ydist;
@@ -740,14 +740,14 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
// Inner loop. For each y in the left map of x-values, draw one
// line from left to right.
const int p3yfloor = int(floor(p3->point.y()));
const int p3yfloor = int(Floor(p3->point.y()));
for (int y = int(floor(p1->point.y())); y < p3yfloor; ++y)
for (int y = int(Floor(p1->point.y())); y < p3yfloor; ++y)
{
double lx = leftX[y];
double rx = rightX[y];
int lxi = (int) floor(lx);
int rxi = (int) floor(rx);
int lxi = (int)Floor(lx);
int rxi = (int)Floor(rx);
DoubleColor rc = rightColors[y];
DoubleColor lc = leftColors[y];
// if the xdist is 0, don't draw anything.
@@ -809,10 +809,10 @@ void ColorTriangle::Color(const QColor& col)
double cy = (double) contentsRect().center().y();
double innerRadius = outerRadius - (outerRadius / 5.0);
double pointerRadius = outerRadius - (outerRadius / 10.0);
pa = QPointF(cx + (cos(a) * innerRadius), cy - (sin(a) * innerRadius));
pb = QPointF(cx + (cos(b) * innerRadius), cy - (sin(b) * innerRadius));
pc = QPointF(cx + (cos(c) * innerRadius), cy - (sin(c) * innerRadius));
pd = QPointF(cx + (cos(a) * pointerRadius), cy - (sin(a) * pointerRadius));
pa = QPointF(cx + (std::cos(a) * innerRadius), cy - (std::sin(a) * innerRadius));
pb = QPointF(cx + (std::cos(b) * innerRadius), cy - (std::sin(b) * innerRadius));
pc = QPointF(cx + (std::cos(c) * innerRadius), cy - (std::sin(c) * innerRadius));
pd = QPointF(cx + (std::cos(a) * pointerRadius), cy - (std::sin(a) * pointerRadius));
selectorPos = PointFromColor(curColor);
update();
emit ColorChanged(curColor);
@@ -862,7 +862,7 @@ double ColorTriangle::AngleAt(const QPointF& pos, const QRect& rect) const
if (mouserad == 0.0)
return 0.0;
double angle = acos(mousexdist / mouserad);
double angle = std::acos(mousexdist / mouserad);
if (mouseydist >= 0)
angle = TWOPI - angle;
@@ -899,8 +899,8 @@ inline double vprod(double x1, double y1, double x2, double y2)
/*! \internal
Returns true if the point cos(p),sin(p) is on the arc between
cos(a1),sin(a1) and cos(a2),sin(a2); otherwise returns false.
Returns true if the point std::cos(p),sin(p) is on the arc between
cos(a1),sin(a1) and std::cos(a2),sin(a2); otherwise returns false.
*/
bool angleBetweenAngles(double p, double a1, double a2)
{
@@ -936,18 +936,18 @@ static bool pointAbovePoint(double x, double y, double px, double py,
{
bool result = false;
if (floor(ax) > floor(bx))
if (Floor(ax) > Floor(bx))
{
if (floor(ay) < floor(by))
if (Floor(ay) < Floor(by))
{
// line is draw upright-to-downleft
if (floor(x) < floor(px) || floor(y) < floor(py))
if (Floor(x) < Floor(px) || Floor(y) < Floor(py))
result = true;
}
else if (floor(ay) > floor(by))
else if (Floor(ay) > Floor(by))
{
// line is draw downright-to-upleft
if (floor(x) > floor(px) || floor(y) < floor(py))
if (Floor(x) > Floor(px) || Floor(y) < Floor(py))
result = true;
}
else
@@ -956,18 +956,18 @@ static bool pointAbovePoint(double x, double y, double px, double py,
if (y < ay) result = true;
}
}
else if (floor(ax) < floor(bx))
else if (Floor(ax) < Floor(bx))
{
if (floor(ay) < floor(by))
if (Floor(ay) < Floor(by))
{
// line is draw upleft-to-downright
if (floor(x) < floor(px) || floor(y) > floor(py))
if (Floor(x) < Floor(px) || Floor(y) > Floor(py))
result = true;
}
else if (floor(ay) > floor(by))
else if (Floor(ay) > Floor(by))
{
// line is draw downleft-to-upright
if (floor(x) > floor(px) || floor(y) > floor(py))
if (Floor(x) > Floor(px) || Floor(y) > Floor(py))
result = true;
}
else
@@ -980,11 +980,11 @@ static bool pointAbovePoint(double x, double y, double px, double py,
else
{
// line is vertical
if (floor(ay) < floor(by))
if (Floor(ay) < Floor(by))
{
if (x < ax) result = true;
}
else if (floor(ay) > floor(by))
else if (Floor(ay) > Floor(by))
{
if (x > ax) result = true;
}
@@ -1029,7 +1029,7 @@ static int pointInLine(double x, double y, double ax, double ay,
// line is draw downright-to-upleft
// If the line is flat, only use the x coordinate.
if (floor(ay) == floor(by))
if (Floor(ay) == Floor(by))
{
// if (x is to the right of the rightmost point,
// return -1. otherwise if x is to the left of the
@@ -1074,7 +1074,7 @@ static int pointInLine(double x, double y, double ax, double ay,
// line is draw downleft-to-upright
// If the line is flat, only use the x coordinate.
if (floor(ay) == floor(by))
if (Floor(ay) == Floor(by))
{
if (x <= ax)
return -1;
@@ -1128,7 +1128,7 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
double v2yA = b.point.y() - a.point.y();
double vpA = vprod(v1xA, v1yA, v2xA, v2yA);
double cosA = vpA / (vlen(v1xA, v1yA) * vlen(v2xA, v2yA));
double alphaA = acos(cosA);
double alphaA = std::acos(cosA);
// Let v1B be the vector from x to b.
// Let v2B be the vector from b to c.
double v1xB = x - b.point.x();
@@ -1137,7 +1137,7 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
double v2yB = c.point.y() - b.point.y();
double vpB = vprod(v1xB, v1yB, v2xB, v2yB);
double cosB = vpB / (vlen(v1xB, v1yB) * vlen(v2xB, v2yB));
double alphaB = acos(cosB);
double alphaB = std::acos(cosB);
// Let v1C be the vector from x to c.
// Let v2C be the vector from c back to a.
double v1xC = x - c.point.x();
@@ -1146,7 +1146,7 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
double v2yC = a.point.y() - c.point.y();
double vpC = vprod(v1xC, v1yC, v2xC, v2yC);
double cosC = vpC / (vlen(v1xC, v1yC) * vlen(v2xC, v2yC));
double alphaC = acos(cosC);
double alphaC = std::acos(cosC);
// Find the radian angles between the (1,0) vector and the points
// A, B, C and (x,y). Use this information to determine which of
// the edges we should project (x,y) onto.
@@ -1164,8 +1164,8 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
// perpendicular projection from (x,y) onto a-b.
double pdist = std::sqrt(qsqr(x - a.point.x()) + qsqr(y - a.point.y()));
// the length of all edges is always > 0
double p0x = a.point.x() + ((b.point.x() - a.point.x()) / vlen(v2xB, v2yB)) * cos(alphaA) * pdist;
double p0y = a.point.y() + ((b.point.y() - a.point.y()) / vlen(v2xB, v2yB)) * cos(alphaA) * pdist;
double p0x = a.point.x() + ((b.point.x() - a.point.x()) / vlen(v2xB, v2yB)) * std::cos(alphaA) * pdist;
double p0y = a.point.y() + ((b.point.y() - a.point.y()) / vlen(v2xB, v2yB)) * std::cos(alphaA) * pdist;
// If (x,y) is above the a-b line, which basically means it's
// outside the triangle, then return its projection onto a-b.
@@ -1188,8 +1188,8 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
// If (x,y) is in the b-c area, project onto the b-c vector.
double pdist = std::sqrt(qsqr(x - b.point.x()) + qsqr(y - b.point.y()));
// the length of all edges is always > 0
double p0x = b.point.x() + ((c.point.x() - b.point.x()) / vlen(v2xC, v2yC)) * cos(alphaB) * pdist;
double p0y = b.point.y() + ((c.point.y() - b.point.y()) / vlen(v2xC, v2yC)) * cos(alphaB) * pdist;
double p0x = b.point.x() + ((c.point.x() - b.point.x()) / vlen(v2xC, v2yC)) * std::cos(alphaB) * pdist;
double p0y = b.point.y() + ((c.point.y() - b.point.y()) / vlen(v2xC, v2yC)) * std::cos(alphaB) * pdist;
if (pointAbovePoint(x, y, p0x, p0y, b.point.x(), b.point.y(), c.point.x(), c.point.y()))
{
@@ -1208,8 +1208,8 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
// If (x,y) is in the c-a area, project onto the c-a vector.
double pdist = std::sqrt(qsqr(x - c.point.x()) + qsqr(y - c.point.y()));
// the length of all edges is always > 0
double p0x = c.point.x() + ((a.point.x() - c.point.x()) / vlen(v2xA, v2yA)) * cos(alphaC) * pdist;
double p0y = c.point.y() + ((a.point.y() - c.point.y()) / vlen(v2xA, v2yA)) * cos(alphaC) * pdist;
double p0x = c.point.x() + ((a.point.x() - c.point.x()) / vlen(v2xA, v2yA)) * std::cos(alphaC) * pdist;
double p0y = c.point.y() + ((a.point.y() - c.point.y()) / vlen(v2xA, v2yA)) * std::cos(alphaC) * pdist;
if (pointAbovePoint(x, y, p0x, p0y, c.point.x(), c.point.y(), a.point.x(), a.point.y()))
{
@@ -1310,12 +1310,12 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
double cy = (double) contentsRect().center().y();
// Find the a, b and c from their angles, the center of the rect
// and the radius of the hue gradient donut.
QPointF pa(cx + (cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(a) * (outerRadius - (outerRadius / 5.0))));
QPointF pb(cx + (cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(b) * (outerRadius - (outerRadius / 5.0))));
QPointF pc(cx + (cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (sin(c) * (outerRadius - (outerRadius / 5.0))));
QPointF pa(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
QPointF pb(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(b) * (outerRadius - (outerRadius / 5.0))));
QPointF pc(cx + (std::cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(c) * (outerRadius - (outerRadius / 5.0))));
// Find the hue value from the angle of the 'a' point.
double angle = a - M_PI / 2.0;
@@ -1325,7 +1325,7 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
// Create the color of the 'a' corner point. We know that b is
// black and c is white.
QColor color;
color.setHsv(360 - (int) floor(hue), 255, 255);
color.setHsv(360 - (int)Floor(hue), 255, 255);
// See also drawTrigon(), which basically does exactly the same to
// determine all colors in the trigon.
Vertex aa(color, pa);
@@ -1371,7 +1371,7 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
{
leftx = p1->point.x();
if (floor(p1p2ydist) != 0.0)
if (Floor(p1p2ydist) != 0.0)
{
leftx += (p1p2xdist * (p.y() - p1->point.y())) / p1p2ydist;
}
@@ -1384,7 +1384,7 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
{
leftx = p2->point.x();
if (floor(p2p3ydist) != 0.0)
if (Floor(p2p3ydist) != 0.0)
{
leftx += (p2p3xdist * (p.y() - p2->point.y())) / p2p3ydist;
}
@@ -1406,7 +1406,7 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
{
rightx = p1->point.x();
if (floor(p1p2ydist) != 0.0)
if (Floor(p1p2ydist) != 0.0)
{
rightx += (p1p2xdist * (p.y() - p1->point.y())) / p1p2ydist;
}
@@ -1419,7 +1419,7 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
{
rightx = p2->point.x();
if (floor(p2p3ydist) != 0.0)
if (Floor(p2p3ydist) != 0.0)
{
rightx += (p2p3xdist * (p.y() - p2->point.y())) / p2p3ydist;
}
@@ -1437,7 +1437,7 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
if (firstshorty)
{
if (floor(p1p2ydist) != 0.0)
if (Floor(p1p2ydist) != 0.0)
{
rshort = p2->color.r * (p.y() - p1->point.y()) / p1p2ydist;
gshort = p2->color.g * (p.y() - p1->point.y()) / p1p2ydist;
@@ -1482,7 +1482,7 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
}
else
{
if (floor(p2p3ydist) != 0.0)
if (Floor(p2p3ydist) != 0.0)
{
rshort = p3->color.r * (p.y() - p2->point.y()) / p2p3ydist;
gshort = p3->color.g * (p.y() - p2->point.y()) / p2p3ydist;
@@ -1582,9 +1582,9 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
// Now floor the color components and fit them into proper
// boundaries. This again is to compensate for the error caused by
// loss of precision.
int ri = (int) floor(r);
int gi = (int) floor(g);
int bi = (int) floor(b);
int ri = (int)Floor(r);
int gi = (int)Floor(g);
int bi = (int)Floor(b);
if (ri < 0) ri = 0;
else if (ri > 255) ri = 255;
@@ -112,7 +112,7 @@ void PaletteEditor::SetPalette(const Palette<float>& palette)
/// Return a temporary copy of the xform color indices as a map.
/// The keys are the xform indices, and the values are the color indices.
/// </summary>
/// <param name="palette">The color indices</param>
/// <returns>The color indices</returns>
map<size_t, float> PaletteEditor::GetColorIndices() const
{
return m_GradientColorView->GetColorIndices();
@@ -122,12 +122,32 @@ map<size_t, float> PaletteEditor::GetColorIndices() const
/// Assign the values of the xform color indices to the arrows.
/// This will clear out any existing values first.
/// </summary>
/// <param name="palette">The color indices to assign</param>
/// <param name="indices">The color indices to assign</param>
void PaletteEditor::SetColorIndices(const map<size_t, float>& indices)
{
m_GradientColorView->SetColorIndices(indices);
}
/// <summary>
/// Return the filename of the currently selected palette.
/// Note this will only be filled in if the user has clicked in the palette
/// table at least once.
/// </summary>
/// <returns>The palette filename</returns>
string PaletteEditor::GetPaletteFile() const
{
return m_CurrentPaletteFilePath;
}
/// <summary>
/// Set the selected palette file in the combo box.
/// </summary>
/// <param name="filename">The filename of the palette file to set to the current one</param>
void PaletteEditor::SetPaletteFile(const string& filename)
{
ui->PaletteFilenameCombo->setCurrentText(QString::fromStdString(GetFilename(filename)));
}
/// <summary>
/// Add a new arrow using the current color.
/// Called when the Add Color button is clicked.
@@ -574,7 +594,8 @@ void PaletteEditor::EnablePaletteControls()
{
auto& palette = m_GradientColorView->GetPalette(256);
bool b = !palette.m_SourceColors.empty();
ui->OverwritePaletteButton->setEnabled(b);
bool any = m_PaletteList->IsModifiable(m_CurrentPaletteFilePath);//At least one in the file is not fixed.
ui->OverwritePaletteButton->setEnabled(b && any);
ui->AddColorButton->setEnabled(b);
ui->DistributeColorsButton->setEnabled(b);
ui->AutoDistributeCheckBox->setEnabled(b);
@@ -34,6 +34,8 @@ public:
void SetPalette(const Palette<float>& palette);
map<size_t, float> GetColorIndices() const;
void SetColorIndices(const map<size_t, float>& indices);
string GetPaletteFile() const;
void SetPaletteFile(const string& filename);
Q_SIGNALS:
void PaletteChanged();