--User changes

-Add post_smartcrop.

--Bug fixes
 -Fix bug in crackle.
 -Wrong point assignment in hexaplay3D, hexnix3D.
 -Improper Z assignment in rblur.
 -Fix inconsistency with original in circlecrop.
 -Put EMBER_ROOT bakc to ./../../../ in default.pri. This is TBD.

--Code changes
 -Convert all enums to class enum to be consistent with C++11 style.
 -Convert some if/else statements in filter classes to case statements.
 -Add overloaded stream operators to print various enums.
 -Optimize crob, nBlur.
 -Fix weird assignment statement in falloff3.
 -Cleanup in VarFuncs::SimplexNoise3D().
 -Replace fabs() with std::abs().
 -General cleanup.
This commit is contained in:
mfeemster 2016-01-12 20:42:12 -08:00
parent a8688e87b5
commit a3ecbbf690
22 changed files with 1402 additions and 1546 deletions

View File

@ -11,7 +11,10 @@ unix|macx {
}
# When loaded by QtCreator
EMBER_ROOT = $$(PWD)/../../..
#This cannot be this...
#EMBER_ROOT = $$(PWD)/../../..
#It must be this...
EMBER_ROOT = ./../../../
# When compiling from project root
autobuild {
@ -28,11 +31,11 @@ LOCAL_INCLUDE_DIR = $$(PWD)/../../include
CONFIG(release, debug|release) {
CONFIG += warn_off
DESTDIR = $$(PWD)/../../../Bin/release
DESTDIR = $$EMBER_ROOT/Bin/release
}
CONFIG(debug, debug|release) {
DESTDIR = $$(PWD)/../../../Bin/debug
DESTDIR = $$EMBER_ROOT/Bin/debug
}
macx {

Binary file not shown.

View File

@ -379,6 +379,7 @@ uint Timing::m_ProcessorCount;
EXPORTPREPOSTREGVAR(BubbleT3D, T) \
EXPORTPREPOSTREGVAR(Synth, T) \
EXPORTPREPOSTREGVAR(Crackle, T) \
template EMBER_API class PostSmartcropVariation<T>; /*Only implemented as post.*/ \
EXPORTPREPOSTREGVAR(DCBubble, T) \
EXPORTPREPOSTREGVAR(DCCarpet, T) \
EXPORTPREPOSTREGVAR(DCCube, T) \

View File

@ -704,7 +704,7 @@ static inline T Spread(T x, T y)
template <typename T>
static inline T Powq4(T x, T y)
{
return std::pow(std::fabs(x), y) * SignNz(x);
return std::pow(std::abs(x), y) * SignNz(x);
}
/// <summary>

View File

@ -92,11 +92,11 @@ public:
T t; // Temp double
// Convert input co-ordinates ( x, y, z ) to
// integer-based simplex grid ( i, j, k )
T skewIn = (v.x + v.y + v.z) * T(0.3333);
T skewIn = (v.x + v.y + v.z) * T(0.333333);
intmax_t i = Floor<T>(v.x + skewIn);
intmax_t j = Floor<T>(v.y + skewIn);
intmax_t k = Floor<T>(v.z + skewIn);
t = (i + j + k) * T(0.16666);
t = (i + j + k) * T(0.1666666);
// Cell origin co-ordinates in input space (x,y,z)
T x0 = i - t;
T y0 = j - t;
@ -154,17 +154,17 @@ public:
// A step of 1i in (i,j,k) is a step of (1-T(0.16666), -T(0.16666), -T(0.16666)) in (x,y,z),
// and this is similar for j and k . . .
// Offsets for second corner in (x,y,z) coords
c[1].x = c[0].x - i1 + T(0.16666);
c[1].y = c[0].y - j1 + T(0.16666);
c[1].z = c[0].z - k1 + T(0.16666);
c[1].x = c[0].x - i1 + T(0.1666666);
c[1].y = c[0].y - j1 + T(0.1666666);
c[1].z = c[0].z - k1 + T(0.1666666);
// Offsets for third corner in (x,y,z) coords
c[2].x = c[0].x - i2 + 2 * T(0.16666);
c[2].y = c[0].y - j2 + 2 * T(0.16666);
c[2].z = c[0].z - k2 + 2 * T(0.16666);
c[2].x = c[0].x - i2 + 2 * T(0.1666666);
c[2].y = c[0].y - j2 + 2 * T(0.1666666);
c[2].z = c[0].z - k2 + 2 * T(0.1666666);
// Offsets for last corner in (x,y,z) coords
c[3].x = c[0].x - 1 + 3 * T(0.16666);
c[3].y = c[0].y - 1 + 3 * T(0.16666);
c[3].z = c[0].z - 1 + 3 * T(0.16666);
c[3].x = c[0].x - 1 + 3 * T(0.1666666);
c[3].y = c[0].y - 1 + 3 * T(0.1666666);
c[3].z = c[0].z - 1 + 3 * T(0.1666666);
// Work out the hashed gradient indices of the four simplex corners
int ii = i & 0x3ff;
int jj = j & 0x3ff;
@ -175,9 +175,9 @@ public:
gi[3] = m_P[ii + 1 + m_P[jj + 1 + m_P[kk + 1]]];
// Calculate the contribution from the four corners, and add to total
for (int corner = 0; corner < 4; corner++)
for (uint corner = 0u; corner < 4u; corner++)
{
t = T(0.6) - c[corner].x * c[corner].x - c[corner].y * c[corner].y - c[corner].z * c[corner].z;
t = T(0.6) - Sqr(c[corner].x) - Sqr(c[corner].y) - Sqr(c[corner].z);
if (t > 0)
{
@ -202,13 +202,12 @@ public:
/// <returns>T</returns>
T PerlinNoise3D(v3T& v, T aScale, T fScale, int octaves)
{
int i;
T n = 0, a = 1;
v3T u = v;
for (i = 0; i < octaves; i++)
for (int i = 0; i < octaves; i++)
{
n += SimplexNoise3D(u) / a;
n += SimplexNoise3D(u) / Zeps(a);
a *= aScale;
u.x *= fScale;
u.y *= fScale;
@ -253,22 +252,20 @@ public:
{
v2T pmq = p - q;
if (pmq.x == 0 || pmq.y == 0)
if (pmq.x == 0 && pmq.y == 0)
return 1;
return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / (pmq.x * pmq.x + pmq.y * pmq.y);
return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / (SQR(pmq.x) + SQR(pmq.y));
}
/// <summary>
/// Unsure.
/// </summary>
static T Voronoi(v2T* p, int n, int q, v2T& u)
static T Voronoi(v2T* p, int n, int q, const v2T& u)
{
T ratio;
T ratiomax = TLOW;
int i;
T ratio, ratiomax = TLOW;
for (i = 0; i < n; i++)
for (int i = 0; i < n; i++)
{
if (i != q)
{
@ -293,7 +290,7 @@ private:
m_P = InitInts();
m_Grad = InitGrad();
m_GlobalMap["NOISE_INDEX"] = make_pair(m_PFloats.data(), m_PFloats.size());
m_GlobalMap["NOISE_POINTS"] = make_pair(static_cast<T*>(&(m_Grad[0].x)), SizeOf(m_Grad) / sizeof(T));
m_GlobalMap["NOISE_POINTS"] = make_pair(static_cast<T*>(&(m_Grad[0].x)), SizeOf(m_Grad) / sizeof(T));
}
/// <summary>

View File

@ -914,7 +914,7 @@ enum class eVariationId : et
VAR_POST_SINUS_GRID,
VAR_POST_SINUSOIDAL,
VAR_POST_SINUSOIDAL3D,
//VAR_POST_SMARTCROP,
VAR_POST_SMARTCROP,
VAR_POST_SPHERICAL,
VAR_POST_SPHERICAL3D,
VAR_POST_SPHERICALN,

View File

@ -342,6 +342,7 @@ public:
ADDPREPOSTREGVAR(BubbleT3D)
ADDPREPOSTREGVAR(Synth)
ADDPREPOSTREGVAR(Crackle)
m_Variations.push_back(new PostSmartcropVariation<T>());//Post only
//ADDPREPOSTREGVAR(LinearXZ)
//ADDPREPOSTREGVAR(LinearYZ)
//DC are special.

View File

@ -1659,7 +1659,7 @@ public:
virtual void Precalc() override
{
m_Power = Zeps(m_Power);
m_Rn = fabs(m_Power);
m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2;
}
@ -1770,7 +1770,7 @@ public:
virtual void Precalc() override
{
m_Rn = fabs(m_Power);
m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2;
}
@ -2566,7 +2566,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T r = m_Weight / Zeps(fabs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y)));
T r = m_Weight / Zeps(std::abs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y)));
helper.Out.x = helper.In.x * r;
helper.Out.y = helper.In.y * r;
helper.Out.z = m_Weight * helper.In.z;
@ -2706,9 +2706,9 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T theta = m_Pm4 * helper.m_PrecalcAtanyx + T(M_PI_4);
T t1 = fabs(std::cos(theta));
T t1 = std::abs(std::cos(theta));
t1 = std::pow(t1, m_N2);
T t2 = fabs(std::sin(theta));
T t2 = std::abs(std::sin(theta));
t2 = std::pow(t2, m_N3);
T r = m_Weight * ((m_Rnd * rand.Frand01<T>() + (1 - m_Rnd) * helper.m_PrecalcSqrtSumSquares) - m_Holes)
* std::pow(t1 + t2, m_PNeg1N1) / helper.m_PrecalcSqrtSumSquares;
@ -3235,7 +3235,7 @@ public:
}
else
{
if (fabs(offsetX) >= fabs(offsetY))
if (std::abs(offsetX) >= std::abs(offsetY))
{
if (offsetX >= 0.0)
{
@ -3332,7 +3332,7 @@ public:
{
T wx = m_Weight * T(1.3029400317411197908970256609023);//This precision came from the original.
T y2 = helper.In.y * 2;
T r = wx * std::sqrt(fabs(helper.In.y * helper.In.x) / Zeps(SQR(helper.In.x) + SQR(y2)));
T r = wx * std::sqrt(std::abs(helper.In.y * helper.In.x) / Zeps(SQR(helper.In.x) + SQR(y2)));
helper.Out.x = r * helper.In.x;
helper.Out.y = r * y2;
helper.Out.z = m_Weight * helper.In.z;
@ -4263,9 +4263,9 @@ public:
if (m_Damping == 0.0)
t = m_Amplitude * std::cos(m_2PiFreq * helper.In.x) + m_Separation;
else
t = m_Amplitude * std::exp(-fabs(helper.In.x) * m_Damping) * std::cos(m_2PiFreq * helper.In.x) + m_Separation;
t = m_Amplitude * std::exp(-std::abs(helper.In.x) * m_Damping) * std::cos(m_2PiFreq * helper.In.x) + m_Separation;
if (fabs(helper.In.y) <= t)
if (std::abs(helper.In.y) <= t)
{
helper.Out.x = m_Weight * helper.In.x;
helper.Out.y = -(m_Weight * helper.In.y);
@ -4984,7 +4984,7 @@ public:
virtual void Precalc() override
{
m_Cf = 1 - m_Angle * m_Count * T(M_1_PI) * T(0.5);
m_Rn = fabs(m_Power);
m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2;
}
@ -5835,8 +5835,8 @@ public:
{
T s = std::sin(m_Freq * helper.In.x);
T t = std::sin(m_Freq * helper.In.y);
T dy = helper.In.y + m_AugerWeight * (m_Scale * s / 2 + fabs(helper.In.y) * s);
T dx = helper.In.x + m_AugerWeight * (m_Scale * t / 2 + fabs(helper.In.x) * t);
T dy = helper.In.y + m_AugerWeight * (m_Scale * s / 2 + std::abs(helper.In.y) * s);
T dx = helper.In.x + m_AugerWeight * (m_Scale * t / 2 + std::abs(helper.In.x) * t);
helper.Out.x = m_Weight * (helper.In.x + m_Symmetry * (dx - helper.In.x));
helper.Out.y = m_Weight * dy;
helper.Out.z = m_Weight * helper.In.z;

File diff suppressed because it is too large Load Diff

View File

@ -428,7 +428,7 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs().
if (rand.Frand01<T>() > m_Contrast * std::pow(alpha, m_Pow))
{
@ -543,7 +543,7 @@ public:
T val = DEG_2_RAD_T * m_Phi1;
T sinPhi1 = std::sin(val);
T cosPhi1 = std::cos(val);
m_Pow = fabs(m_Pow);
m_Pow = std::abs(m_Pow);
m_X1 = m_Radius * cosPhi1;
m_Y1 = m_Radius * sinPhi1;
}
@ -610,7 +610,7 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs().
if (rand.Frand01<T>() > m_Contrast * std::pow(alpha, m_Pow))
{
@ -696,7 +696,7 @@ public:
virtual void Precalc() override
{
m_Pow = fabs(m_Pow);
m_Pow = std::abs(m_Pow);
m_Phi10 = T(M_PI) * m_Phi1 / 180;
m_Phi20 = T(M_PI) * m_Phi2 / 180;
m_Gamma = m_Thickness * (2 * m_Radius + m_Thickness) / Zeps(m_Radius + m_Thickness);
@ -769,7 +769,7 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs().
if (rand.Frand01<T>() > m_Contrast * std::pow(alpha, m_Pow))
{
@ -1108,7 +1108,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T coeff = fabs(helper.In.z);
T coeff = std::abs(helper.In.z);
if (coeff != 0 && m_Power != 1)
coeff = std::exp(log(coeff) * m_Power);
@ -1492,7 +1492,7 @@ public:
virtual void Precalc() override
{
m_AbsN = fabs(m_N);
m_AbsN = std::abs(m_N);
m_Cn = (1 / m_N - 1) / 2;
}
@ -1565,7 +1565,7 @@ public:
virtual void Precalc() override
{
m_AbsN = fabs(m_N);
m_AbsN = std::abs(m_N);
m_Cn = 1 / m_N / 2;
}
@ -1609,8 +1609,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
helper.Out.x = SignNz<T>(helper.In.x) * std::pow(fabs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = SignNz<T>(helper.In.y) * std::pow(fabs(helper.In.y), m_PowY) * m_Weight;
helper.Out.x = SignNz<T>(helper.In.x) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = SignNz<T>(helper.In.y) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z;
}
@ -1665,9 +1665,9 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
helper.Out.x = T(helper.In.x < 0 ? -1 : 1) * std::pow(fabs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = T(helper.In.y < 0 ? -1 : 1) * std::pow(fabs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = T(helper.In.z < 0 ? -1 : 1) * std::pow(fabs(helper.In.z), m_PowZ) * m_Weight;
helper.Out.x = T(helper.In.x < 0 ? -1 : 1) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = T(helper.In.y < 0 ? -1 : 1) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = T(helper.In.z < 0 ? -1 : 1) * std::pow(std::abs(helper.In.z), m_PowZ) * m_Weight;
}
virtual string OpenCLString() const override
@ -2592,7 +2592,7 @@ public:
virtual void Precalc() override
{
if (fabs(m_Power) < 1)
if (std::abs(m_Power) < 1)
m_Power = 1;
}
@ -2951,7 +2951,7 @@ public:
if (t < 0)
t -= m_SizeDiv2;
t = fmod(fabs(t), m_Size);
t = fmod(std::abs(t), m_Size);
if (t < m_SizeDiv2)
a += m_Even;
@ -3556,15 +3556,15 @@ public:
{
T x, c2;
if (fabs(helper.In.y) <= m_Weight)
if (std::abs(helper.In.y) <= m_Weight)
{
c2 = std::sqrt(SQR(m_Weight) - SQR(helper.In.y));
if (fabs(helper.In.x) <= c2)
if (std::abs(helper.In.x) <= c2)
{
x = helper.In.x + m_Shift * m_Weight;
if (fabs(x) >= c2)
if (std::abs(x) >= c2)
helper.Out.x = -(m_Weight * helper.In.x);
else
helper.Out.x = m_Weight * x;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ public:
T tempX = helper.Out.x + sumX;
T tempY = helper.Out.y + sumY;
outPoint.m_ColorX = fmod(fabs(m_Bdcs * (Sqr<T>(tempX + m_CenterX) + Sqr<T>(tempY + m_CenterY))), T(1.0));
outPoint.m_ColorX = fmod(std::abs(m_Bdcs * (Sqr<T>(tempX + m_CenterX) + Sqr<T>(tempY + m_CenterY))), T(1.0));
}
virtual string OpenCLString() const override
@ -141,7 +141,7 @@ public:
helper.Out.x = m_Weight * (m_Xform->m_Affine.A() * x + m_Xform->m_Affine.B() * y + m_Xform->m_Affine.E());
helper.Out.y = m_Weight * (m_Xform->m_Affine.C() * x + m_Xform->m_Affine.D() * y + m_Xform->m_Affine.F());
helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z;
outPoint.m_ColorX = fmod(fabs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0));
outPoint.m_ColorX = fmod(std::abs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0));
}
virtual string OpenCLString() const override
@ -415,7 +415,7 @@ public:
T tempX = helper.Out.x + sumX;
T tempY = helper.Out.y + sumY;
outPoint.m_ColorX = fmod(fabs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + 1)), T(1.0));
outPoint.m_ColorX = fmod(std::abs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + 1)), T(1.0));
}
virtual string OpenCLString() const override
@ -715,7 +715,7 @@ public:
T tempX = helper.Out.x + sumX;
T tempY = helper.Out.y + sumY;
outPoint.m_ColorX = fmod(fabs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + T(1.0))), T(1.0));
outPoint.m_ColorX = fmod(std::abs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + T(1.0))), T(1.0));
}
virtual string OpenCLString() const override
@ -885,7 +885,7 @@ public:
helper.Out.x = m_Weight * (ox + u * xx + v * yx);
helper.Out.y = m_Weight * (oy + u * xy + v * yy);
helper.Out.z = m_Weight * helper.In.z;
outPoint.m_ColorX = fmod(fabs(u + v), T(1.0));
outPoint.m_ColorX = fmod(std::abs(u + v), T(1.0));
}
virtual string OpenCLString() const override

View File

@ -174,6 +174,17 @@ public:
m_BadParamNames["exponentZ"] = "bubbleT3D_exponentZ";
m_BadParamNames["_symmetryZ"] = "bubbleT3D_symmetryZ";
m_BadParamNames["_modusBlur"] = "bubbleT3D_modusBlur";
m_BadParamNames["post_scrop_power"] = "post_smartcrop_power";
m_BadParamNames["post_scrop_radius"] = "post_smartcrop_radius";
m_BadParamNames["post_scrop_roundstr"] = "post_smartcrop_roundstr";
m_BadParamNames["post_scrop_roundwidth"] = "post_smartcrop_roundwidth";
m_BadParamNames["post_scrop_distortion"] = "post_smartcrop_distortion";
m_BadParamNames["post_scrop_edge"] = "post_smartcrop_edge";
m_BadParamNames["post_scrop_scatter"] = "post_smartcrop_scatter";
m_BadParamNames["post_scrop_offset"] = "post_smartcrop_offset";
m_BadParamNames["post_scrop_rotation"] = "post_smartcrop_rotation";
m_BadParamNames["post_scrop_cropmode"] = "post_smartcrop_cropmode";
m_BadParamNames["post_scrop_static"] = "post_smartcrop_static";
m_FlattenNames.reserve(24);
m_FlattenNames.push_back("pre_crop");
m_FlattenNames.push_back("pre_falloff2");
@ -201,7 +212,7 @@ public:
m_FlattenNames.push_back("curl3D_cz");
//This is a vector of the param names as they are in the legacy, badly named flam3/Apophysis code.
vector<string> badParams;
badParams.reserve(6);
badParams.reserve(11);
badParams.push_back("bwraps7_cellsize");
badParams.push_back("bwraps7_space");
badParams.push_back("bwraps7_gain");
@ -245,6 +256,19 @@ public:
badParams.push_back("post_dcztransl_clamp");
m_BadVariationNames.push_back(make_pair(make_pair(string("post_dcztransl"), string("post_dc_ztransl")), badParams));
badParams.clear();
badParams.push_back("post_scrop_power");
badParams.push_back("post_scrop_radius");
badParams.push_back("post_scrop_roundstr");
badParams.push_back("post_scrop_roundwidth");
badParams.push_back("post_scrop_distortion");
badParams.push_back("post_scrop_edge");
badParams.push_back("post_scrop_scatter");
badParams.push_back("post_scrop_offset");
badParams.push_back("post_scrop_rotation");
badParams.push_back("post_scrop_cropmode");
badParams.push_back("post_scrop_static");
m_BadVariationNames.push_back(make_pair(make_pair(string("post_scrop"), string("post_smartcrop")), badParams));
badParams.clear();
m_BadVariationNames.push_back(make_pair(make_pair(string("pre_blur"), string("pre_gaussian_blur")), badParams));//No other special params for these.
m_BadVariationNames.push_back(make_pair(make_pair(string("pre_spin_z"), string("pre_rotate_z")), badParams));
m_BadVariationNames.push_back(make_pair(make_pair(string("post_spin_z"), string("post_rotate_z")), badParams));

View File

@ -120,15 +120,12 @@ FunctionMapper::FunctionMapper()
m_GlobalMap["Vratio"] =
"inline real_t Vratio(real2* p, real2* q, real2* u)\n"
"{\n"
" real_t pmQx, pmQy;\n"
" real2 pmq = *p - *q;\n"
"\n"
" pmQx = (*p).x - (*q).x;\n"
" pmQy = (*p).y - (*q).y;\n"
"\n"
" if (pmQx == 0 && pmQy == 0)\n"
" if (pmq.x == 0 && pmq.y == 0)\n"
" return 1.0;\n"
"\n"
" return 2 * (((*u).x - (*q).x) * pmQx + ((*u).y - (*q).y) * pmQy) / (pmQx * pmQx + pmQy * pmQy);\n"
" return 2 * (((*u).x - (*q).x) * pmq.x + ((*u).y - (*q).y) * pmq.y) / (SQR(pmq.x) + SQR(pmq.y));\n"
"}\n";
m_GlobalMap["Closest"] =
"inline int Closest(real2* p, int n, real2* u)\n"
@ -177,11 +174,11 @@ FunctionMapper::FunctionMapper()
" real_t n = 0;\n"
" int gi[4];\n"
" real_t t;\n"
" real_t skewIn = ((*v).x + (*v).y + (*v).z) * 0.3333;\n"
" real_t skewIn = ((*v).x + (*v).y + (*v).z) * 0.333333;\n"
" int i = (int)floor((*v).x + skewIn);\n"
" int j = (int)floor((*v).y + skewIn);\n"
" int k = (int)floor((*v).z + skewIn);\n"
" t = (i + j + k) * 0.16666;\n"
" t = (i + j + k) * 0.1666666;\n"
" real_t x0 = i - t;\n"
" real_t y0 = j - t;\n"
" real_t z0 = k - t;\n"
@ -228,15 +225,15 @@ FunctionMapper::FunctionMapper()
" }\n"
" }\n"
"\n"
" c[1].x = c[0].x - i1 + 0.16666;\n"
" c[1].y = c[0].y - j1 + 0.16666;\n"
" c[1].z = c[0].z - k1 + 0.16666;\n"
" c[2].x = c[0].x - i2 + 2 * 0.16666;\n"
" c[2].y = c[0].y - j2 + 2 * 0.16666;\n"
" c[2].z = c[0].z - k2 + 2 * 0.16666;\n"
" c[3].x = c[0].x - 1 + 3 * 0.16666;\n"
" c[3].y = c[0].y - 1 + 3 * 0.16666;\n"
" c[3].z = c[0].z - 1 + 3 * 0.16666;\n"
" c[1].x = c[0].x - i1 + 0.1666666;\n"
" c[1].y = c[0].y - j1 + 0.1666666;\n"
" c[1].z = c[0].z - k1 + 0.1666666;\n"
" c[2].x = c[0].x - i2 + 2 * 0.1666666;\n"
" c[2].y = c[0].y - j2 + 2 * 0.1666666;\n"
" c[2].z = c[0].z - k2 + 2 * 0.1666666;\n"
" c[3].x = c[0].x - 1 + 3 * 0.1666666;\n"
" c[3].y = c[0].y - 1 + 3 * 0.1666666;\n"
" c[3].z = c[0].z - 1 + 3 * 0.1666666;\n"
" int ii = i & 0x3ff;\n"
" int jj = j & 0x3ff;\n"
" int kk = k & 0x3ff;\n"
@ -246,7 +243,7 @@ FunctionMapper::FunctionMapper()
" gi[3] = (int)p[ii + 1 + (int)p[jj + 1 + (int)p[kk + 1]]];\n"
" for (uint corner = 0; corner < 4; corner++)\n"
" {\n"
" t = 0.6 - c[corner].x * c[corner].x - c[corner].y * c[corner].y - c[corner].z * c[corner].z;\n"
" t = 0.6 - Sqr(c[corner].x) - Sqr(c[corner].y) - Sqr(c[corner].z);\n"
"\n"
" if (t > 0)\n"
" {\n"
@ -267,7 +264,7 @@ FunctionMapper::FunctionMapper()
"\n"
" for (i = 0; i < octaves; i++)\n"
" {\n"
" n += SimplexNoise3D(&u, p, grad) / a;\n"
" n += SimplexNoise3D(&u, p, grad) / Zeps(a);\n"
" a *= aScale;\n"
" u.x *= fScale;\n"
" u.y *= fScale;\n"

View File

@ -651,11 +651,8 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(const Ember<T>& ember, pair<
{
for (auto l = 0; l < elements; l++)
params.second.push_back(*(parVar->Params()[k].Param() + l));
//params.second.push_back(parVar->Params()[k].ParamVal());
}
//size++;
size += elements;
}
}

View File

@ -979,6 +979,7 @@ bool OpenCLWrapper::CreateSPK(const string& name, const string& program, const s
//err = spk.m_Program.build(m_DeviceVec, "-cl-single-precision-constant");
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant");
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-no-signed-zeros -cl-fast-relaxed-math -cl-single-precision-constant");//This can cause some rounding.
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-no-signed-zeros -cl-single-precision-constant -cl-denorms-are-zero");
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant");
if (m_Info->CheckCL(err, "cl::Program::build()"))

View File

@ -1445,9 +1445,9 @@ void TestVarsSimilar()
varComp->Precalc();
varComp->Func(helper, pComp, rand);
v4T varCompOut = helper.Out;
xdiff += fabs(varOut.x - varCompOut.x);
ydiff += fabs(varOut.y - varCompOut.y);
zdiff += fabs(varOut.z - varCompOut.z);
xdiff += std::abs(varOut.x - varCompOut.x);
ydiff += std::abs(varOut.y - varCompOut.y);
zdiff += std::abs(varOut.z - varCompOut.z);
}
sum = (xdiff + ydiff + zdiff) / iters;
@ -1578,9 +1578,9 @@ void TestCpuGpuResults(size_t platform, size_t device)
renderer.WritePoints(points);
renderer.Iterate(1, 0, 1);
renderer.ReadPoints(points);
T xdiff = fabs(p2.m_X - points[0].m_X);
T ydiff = fabs(p2.m_Y - points[0].m_Y);
T zdiff = fabs(p2.m_Z - points[0].m_Z);
T xdiff = std::abs(p2.m_X - points[0].m_X);
T ydiff = std::abs(p2.m_Y - points[0].m_Y);
T zdiff = std::abs(p2.m_Z - points[0].m_Z);
if (xdiff > thresh || ydiff > thresh || zdiff > thresh)
{
@ -1744,7 +1744,7 @@ void TestCross(T x, T y, T weight)
T outX = x * r;
T outY = y * r;
cout << "First way, outX, outY == " << outX << ", " << outY << endl;
r = fabs((x - y) * (x + y) + EPS);
r = std::abs((x - y) * (x + y) + EPS);
if (r < 0)
r = -r;
@ -2015,7 +2015,7 @@ int _tmain(int argc, _TCHAR* argv[])
//cout << pow(-1, 5.1) << endl;
/* for (i = 0; i < 2500000000; i++)
{
double d = fabs(RandD(rand));
double d = std::abs(RandD(rand));
if (d >= 0.5)
cout << d << endl;

View File

@ -224,8 +224,8 @@ void GLEmberController<T>::QueryMatrices(bool print)
if (renderer)
{
double unitX = fabs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0;
double unitY = fabs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0;
double unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0;
double unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0;
m_GL->glMatrixMode(GL_PROJECTION);
m_GL->glPushMatrix();
m_GL->glLoadIdentity();

View File

@ -222,8 +222,8 @@ void GLWidget::paintGL()
//Affine drawing.
bool pre = m_Fractorium->ui.PreAffineGroupBox->isChecked();
bool post = m_Fractorium->ui.PostAffineGroupBox->isChecked();
float unitX = fabs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f;
float unitY = fabs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f;
float unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f;
float unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f;
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
@ -840,8 +840,8 @@ bool GLEmberController<T>::SizesMatch()
void GLWidget::DrawGrid()
{
RendererBase* renderer = m_Fractorium->m_Controller->Renderer();
float unitX = fabs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f;
float unitY = fabs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f;
float unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f;
float unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f;
float rad = std::max(unitX, unitY);
float xLow = floor(-unitX);
float xHigh = ceil(unitX);

View File

@ -57,13 +57,12 @@ private:
double weight1 = 0, weight2 = 0;
VariationTreeWidgetItem* varItemWidget;
VariationTreeDoubleSpinBox* spinBox1, *spinBox2;
auto itemWidget1 = treeWidget()->itemWidget(const_cast<VariationTreeWidgetItem*>(this), 1);//Get the widget for the second column.
if ((spinBox1 = dynamic_cast<VariationTreeDoubleSpinBox*>(itemWidget1)))//Cast the widget to the VariationTreeDoubleSpinBox type.
{
auto itemWidget2 = treeWidget()->itemWidget(const_cast<QTreeWidgetItem*>(&other), 1);//Get the widget for the second column of the widget item passed in.
if ((spinBox2 = dynamic_cast<VariationTreeDoubleSpinBox*>(itemWidget2)))//Cast the widget to the VariationTreeDoubleSpinBox type.
{
if (spinBox1->IsParam() || spinBox2->IsParam())//Do not sort params, their order will always remain the same.
@ -83,11 +82,11 @@ private:
if (IsNearZero(weight1) && IsNearZero(weight2))
return index1 > index2;
else
return fabs(weight1) < fabs(weight2);
return std::abs(weight1) < fabs(weight2);
}
}
}
return false;
}