diff --git a/Builds/MSVC/Installer/FractoriumInstaller.wixproj b/Builds/MSVC/Installer/FractoriumInstaller.wixproj
index 8621975..8e366ed 100644
--- a/Builds/MSVC/Installer/FractoriumInstaller.wixproj
+++ b/Builds/MSVC/Installer/FractoriumInstaller.wixproj
@@ -6,7 +6,7 @@
3.7
{c8096c47-e358-438c-a520-146d46b0637d}
2.0
- Fractorium_21.21.4.1
+ Fractorium_22.21.4.2
Package
$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets
$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets
diff --git a/Builds/MSVC/Installer/Product.wxs b/Builds/MSVC/Installer/Product.wxs
index 3fb4f9d..ac5ca09 100644
--- a/Builds/MSVC/Installer/Product.wxs
+++ b/Builds/MSVC/Installer/Product.wxs
@@ -1,6 +1,6 @@
-
+
@@ -13,7 +13,7 @@
-
+
::ScaleXY(T amount)
template
void Affine2D::Rotate(T rad)
{
- m4T origMat4 = ToMat4ColMajor(true);//Must center and use column major for glm to work.
- m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
+ const m4T origMat4 = ToMat4ColMajor(true);//Must center and use column major for glm to work.
+ const m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
A(newMat4[0][0]);//Use direct assignments instead of constructor to skip assigning C and F.
B(newMat4[0][1]);
D(newMat4[1][0]);
@@ -234,8 +234,8 @@ void Affine2D::Rotate(T rad)
template
void Affine2D::RotateTrans(T rad)
{
- m4T origMat4 = TransToMat4ColMajor();//Only put translation in this matrix.
- m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
+ const m4T origMat4 = TransToMat4ColMajor();//Only put translation in this matrix.
+ const m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
C(newMat4[0][3]);//Use direct assignments instead of constructor to skip assigning A, B, D, E.
F(newMat4[1][3]);
}
@@ -257,7 +257,7 @@ void Affine2D::Translate(const v2T& v)
template
void Affine2D::RotateScaleXTo(const v2T& v)
{
- Affine2D rs = CalcRotateScale(X(), v);
+ const Affine2D rs = CalcRotateScale(X(), v);
X(rs.TransformNormal(X()));
Y(rs.TransformNormal(Y()));
}
@@ -269,7 +269,7 @@ void Affine2D::RotateScaleXTo(const v2T& v)
template
void Affine2D::RotateScaleYTo(const v2T& v)
{
- Affine2D rs = CalcRotateScale(Y(), v);
+ const Affine2D rs = CalcRotateScale(Y(), v);
X(rs.TransformNormal(X()));
Y(rs.TransformNormal(Y()));
}
@@ -281,7 +281,7 @@ void Affine2D::RotateScaleYTo(const v2T& v)
template
Affine2D Affine2D::Inverse() const
{
- T det = A() * E() - D() * B();
+ const T det = A() * E() - D() * B();
return Affine2D(E() / det, -D() / det,
-B() / det, A() / det,
(F() * B() - C() * E()) / det, (C() * D() - F() * A()) / det);
@@ -341,10 +341,10 @@ typename m2T Affine2D::ToMat2RowMajor() const
template
typename m4T Affine2D::ToMat4ColMajor(bool center) const
{
- m4T mat(A(), B(), 0, center ? 0 : C(), //Col0...
- D(), E(), 0, center ? 0 : F(), //1
- 0, 0, 1, 0, //2
- 0, 0, 0, 1);//3
+ const m4T mat(A(), B(), 0, center ? 0 : C(), //Col0...
+ D(), E(), 0, center ? 0 : F(), //1
+ 0, 0, 1, 0, //2
+ 0, 0, 0, 1);//3
return mat;
}
@@ -356,20 +356,20 @@ typename m4T Affine2D::ToMat4ColMajor(bool center) const
template
typename m4T Affine2D::ToMat4RowMajor(bool center) const
{
- m4T mat(A(), D(), 0, 0,
- B(), E(), 0, 0,
- 0, 0, 1, 0,
- center ? 0 : C(), center ? 0 : F(), 0, 1);
+ const m4T mat(A(), D(), 0, 0,
+ B(), E(), 0, 0,
+ 0, 0, 1, 0,
+ center ? 0 : C(), center ? 0 : F(), 0, 1);
return mat;
}
template
typename m4T Affine2D::TransToMat4ColMajor() const
{
- m4T mat(1, 0, 0, C(), //Col0...
- 0, 1, 0, F(), //1
- 0, 0, 1, 0, //2
- 0, 0, 0, 1);//3
+ const m4T mat(1, 0, 0, C(), //Col0...
+ 0, 1, 0, F(), //1
+ 0, 0, 1, 0, //2
+ 0, 0, 0, 1);//3
return mat;
}
@@ -436,7 +436,7 @@ Affine2D Affine2D::CalcRotateScale(const v2T& from, const v2T& to)
template
void Affine2D::CalcRSAC(const v2T& from, const v2T& to, T& a, T& c)
{
- T lsq = from.x * from.x + from.y * from.y;
+ const T lsq = from.x * from.x + from.y * from.y;
a = (from.y * to.y + from.x * to.x) / lsq;
c = (from.x * to.y - from.y * to.x) / lsq;
}
diff --git a/Source/Ember/Curves.h b/Source/Ember/Curves.h
index 1904b97..46efd5a 100644
--- a/Source/Ember/Curves.h
+++ b/Source/Ember/Curves.h
@@ -185,11 +185,11 @@ public:
if (i < 4)
{
m_Points[i].resize(5);
- m_Points[i][0] = v2T(0);
- m_Points[i][1] = v2T(T(0.25));
- m_Points[i][2] = v2T(T(0.50));
- m_Points[i][3] = v2T(T(0.75));
- m_Points[i][4] = v2T(1);
+ m_Points[i][0] = v2T{ 0 };
+ m_Points[i][1] = v2T{ static_cast(0.25) };
+ m_Points[i][2] = v2T{ static_cast(0.50) };
+ m_Points[i][3] = v2T{ static_cast(0.75) };
+ m_Points[i][4] = v2T{ 1 };
}
}
@@ -219,9 +219,9 @@ public:
}
if ((m_Points[i][0] != v2T(0)) ||
- (m_Points[i][1] != v2T(T(0.25))) ||
- (m_Points[i][2] != v2T(T(0.50))) ||
- (m_Points[i][3] != v2T(T(0.75))) ||
+ (m_Points[i][1] != v2T(static_cast(0.25))) ||
+ (m_Points[i][2] != v2T(static_cast(0.50))) ||
+ (m_Points[i][3] != v2T(static_cast(0.75))) ||
(m_Points[i][4] != v2T(1))
)
{
diff --git a/Source/Ember/DensityFilter.h b/Source/Ember/DensityFilter.h
index d71b0d1..a2b03db 100644
--- a/Source/Ember/DensityFilter.h
+++ b/Source/Ember/DensityFilter.h
@@ -52,7 +52,7 @@ public:
//Make sure the values make sense.
if (m_Curve <= 0.0)
- m_Curve = T(0.5);
+ m_Curve = static_cast(0.5);
if (m_MaxRad < m_MinRad)
m_MaxRad = m_MinRad + 1;
@@ -60,7 +60,7 @@ public:
//Ensure it's valid.
while (!Valid())
{
- m_Curve += T(0.1);
+ m_Curve += static_cast(0.1);
}
}
@@ -121,7 +121,7 @@ public:
//
// num filters = (de_max_width / de_min_width)^(1 / estimator_curve)
//
- decFilterCount = std::pow(finalMaxRad / finalMinRad, T(1.0) / m_Curve);
+ decFilterCount = std::pow(finalMaxRad / finalMinRad, static_cast(1) / m_Curve);
if (decFilterCount > 1e7)//Too many filters.
return false;
@@ -131,8 +131,8 @@ public:
//Condense the smaller kernels to save space.
if (intFilterCount > keepThresh)
{
- maxIndex = static_cast(ceil(DE_THRESH + std::pow(T(intFilterCount - DE_THRESH), m_Curve))) + 1;
- m_MaxFilteredCounts = static_cast(std::pow(T(maxIndex - DE_THRESH), T(1.0) / m_Curve)) + DE_THRESH;
+ maxIndex = static_cast(ceil(DE_THRESH + std::pow(static_cast(intFilterCount - DE_THRESH), m_Curve))) + 1;
+ m_MaxFilteredCounts = static_cast(std::pow(static_cast(maxIndex - DE_THRESH), static_cast(1) / m_Curve)) + DE_THRESH;
}
else
{
@@ -160,11 +160,11 @@ public:
//Calculate the filter width for this number of hits in a bin.
if (filterLoop < keepThresh)
{
- filterHeight = (finalMaxRad / std::pow(T(filterLoop + 1), m_Curve));
+ filterHeight = (finalMaxRad / std::pow(static_cast(filterLoop + 1), m_Curve));
}
else
{
- loopAdjust = std::pow(T(filterLoop - keepThresh), (T(1.0) / m_Curve)) + keepThresh;
+ loopAdjust = std::pow(static_cast(filterLoop - keepThresh), (static_cast(1) / m_Curve)) + keepThresh;
filterHeight = (finalMaxRad / std::pow(loopAdjust + 1, m_Curve));
}
@@ -182,7 +182,7 @@ public:
{
for (dek = -m_FilterWidth; dek <= m_FilterWidth; dek++)
{
- filterVal = std::sqrt(T(dej * dej + dek * dek)) / filterHeight;
+ filterVal = std::sqrt(static_cast(dej * dej + dek * dek)) / filterHeight;
//Only populate the coefs within this radius.
if (filterVal <= 1.0)
@@ -197,7 +197,7 @@ public:
{
for (dek = 0; dek <= dej; dek++)
{
- filterVal = std::sqrt(T(dej * dej + dek * dek)) / filterHeight;
+ filterVal = std::sqrt(static_cast(dej * dej + dek * dek)) / filterHeight;
//Only populate the coefs within this radius.
if (filterVal > 1.0)
@@ -258,7 +258,7 @@ public:
{
T finalMaxRad = m_MaxRad * m_Supersample + 1;
T finalMinRad = m_MinRad * m_Supersample + 1;
- return std::pow(finalMaxRad / finalMinRad, T(1.0) / m_Curve) <= 1e7;
+ return std::pow(finalMaxRad / finalMinRad, static_cast(1) / m_Curve) <= 1e7;
}
///
diff --git a/Source/Ember/Ember.h b/Source/Ember/Ember.h
index 28c82a8..abdf5ca 100644
--- a/Source/Ember/Ember.h
+++ b/Source/Ember/Ember.h
@@ -596,7 +596,7 @@ public:
for (auto& xform : m_Xforms) norm += xform.m_Weight;
- for (auto& weight : normalizedWeights) { weight = (norm == T(0) ? T(0) : m_Xforms[i].m_Weight / norm); i++; }
+ for (auto& weight : normalizedWeights) { weight = (norm == static_cast( 0 ) ? static_cast( 0 ) : m_Xforms[i].m_Weight / norm); i++; }
}
///
@@ -1082,8 +1082,8 @@ public:
/// The random context to use for generating random symmetry
void AddSymmetry(intmax_t sym, QTIsaac& rand)
{
- intmax_t k;
- size_t i, result = 0;
+ intmax_t k = 0;
+ size_t i = 0, result = 0;
T a;
if (sym == 0)
@@ -1101,9 +1101,9 @@ public:
if (rand.RandBit())
sym = symDistrib[rand.Rand(Vlen(symDistrib))];
else if (rand.Rand() & 31)
- sym = intmax_t(rand.Rand(13)) - 6;
+ sym = intmax_t{ rand.Rand(13) } - 6;
else
- sym = intmax_t(rand.Rand(51)) - 25;
+ sym = intmax_t{ rand.Rand(51) } - 25;
}
if (sym == 1 || sym == 0)
@@ -1132,7 +1132,7 @@ public:
sym = -sym;
}
- a = T(2 * M_PI / sym);
+ a = static_cast(2 * M_PI / sym);
for (k = 1; k < sym; k++)
{
@@ -1142,7 +1142,7 @@ public:
m_Xforms[i].m_Weight = 1;
m_Xforms[i].m_ColorSpeed = 0;
m_Xforms[i].m_Animate = 0;
- m_Xforms[i].m_ColorX = m_Xforms[i].m_ColorY = (sym < 3) ? 0 : (T(k - 1) / T(sym - 2));//Added Y.
+ m_Xforms[i].m_ColorX = m_Xforms[i].m_ColorY = (sym < 3) ? 0 : (static_cast(k - 1) / static_cast(sym - 2));//Added Y.
m_Xforms[i].m_Affine.A(Round6(std::cos(k * a)));
m_Xforms[i].m_Affine.D(Round6(std::sin(k * a)));
m_Xforms[i].m_Affine.B(Round6(-m_Xforms[i].m_Affine.D()));
@@ -1452,7 +1452,7 @@ public:
m_AffineInterp = eAffineInterp::AFFINE_INTERP_LOG;
m_TemporalFilterType = eTemporalFilterType::BOX_TEMPORAL_FILTER;
m_TemporalFilterWidth = 1;
- m_TemporalFilterExp = 0;
+ m_TemporalFilterExp = 1;
m_PaletteMode = ePaletteMode::PALETTE_LINEAR;
m_Interp = eInterp::EMBER_INTERP_SMOOTH;
}
@@ -1559,8 +1559,8 @@ public:
<< "Spatial Filter Type: " << m_SpatialFilterType << "\n"
<< "Spatial Filter Radius: " << m_SpatialFilterRadius << "\n"
<< "Temporal Filter Type: " << m_TemporalFilterType << "\n"
- << "Temporal Filter Exp: " << m_TemporalFilterExp << "\n"
<< "Temporal Filter Width: " << m_TemporalFilterWidth << "\n"
+ << "Temporal Filter Exp: " << m_TemporalFilterExp << "\n"
<< "Palette Mode: " << m_PaletteMode << "\n"
<< "Palette Interp: " << m_PaletteInterp << "\n"
<< "Palette Index: " << m_Palette.m_Index << "\n"
@@ -1738,7 +1738,7 @@ public:
//Only used if temporal filter type is exp, else unused.
//Xml field: "temporal_filter_exp".
- T m_TemporalFilterExp = 0;
+ T m_TemporalFilterExp = 1;
//The width of the temporal filter.
//Xml field: "temporal_filter_width".
diff --git a/Source/Ember/EmberDefines.h b/Source/Ember/EmberDefines.h
index eb63091..0ff6d6d 100644
--- a/Source/Ember/EmberDefines.h
+++ b/Source/Ember/EmberDefines.h
@@ -37,7 +37,7 @@ static void sincos(float x, float* s, float* c)
namespace EmberNs
{
-#define EMBER_VERSION "21.21.4.1"
+#define EMBER_VERSION "22.21.4.2"
//#define FLAM3_COMPAT 1//Uncomment this if you want full compatibility with flam3 regarding some of the trig-based variations in Variations01.h
#define EPS6 T(1e-6)
#define EPS std::numeric_limits::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way.
@@ -46,12 +46,12 @@ namespace EmberNs
#define DE_THRESH 100
#define DEG_2_RAD (M_PI / 180)
#define RAD_2_DEG (180 / M_PI)
-#define DEG_2_RAD_T (T(M_PI) / T(180))
-#define RAD_2_DEG_T (T(180) / T(M_PI))
-#define M_2PI (T(M_PI * 2))
-#define M_3PI (T(M_PI * 3))
-#define M_PI2 (T(M_PI_2))
-#define M_PI4 (T(M_PI_4))
+#define DEG_2_RAD_T (T{M_PI} / T{180})
+#define RAD_2_DEG_T (T{180} / T{M_PI})
+#define M_2PI (T{M_PI * 2})
+#define M_3PI (T{M_PI * 3})
+#define M_PI2 (T{M_PI_2})
+#define M_PI4 (T{M_PI_4})
#define M_SQRT3 T(1.7320508075688772935274463415059)
#define M_SQRT3_2 T(0.86602540378443864676372317075294)
#define M_SQRT3_3 T(0.57735026918962576450914878050196)
diff --git a/Source/Ember/EmberMotion.h b/Source/Ember/EmberMotion.h
index e841931..e0ecd49 100644
--- a/Source/Ember/EmberMotion.h
+++ b/Source/Ember/EmberMotion.h
@@ -70,7 +70,7 @@ public:
MotionParam& operator = (const MotionParam& other)
{
this->first = other.first;
- this->second = T(other.second);
+ this->second = static_cast(other.second);
return *this;
}
};
diff --git a/Source/Ember/EmberToXml.cpp b/Source/Ember/EmberToXml.cpp
index 4950c6d..977a1c4 100644
--- a/Source/Ember/EmberToXml.cpp
+++ b/Source/Ember/EmberToXml.cpp
@@ -53,7 +53,7 @@ bool EmberToXml::Save(const string& filename, C, Alloc>& embers, siz
if (f.is_open())
{
- auto prev = embers.begin();
+ const auto prev = embers.begin();
//Always ensure times make sense.
for (auto& ember : embers)
@@ -280,7 +280,7 @@ string EmberToXml::ToString(Ember& ember, const string& extraAttributes, s
os << ">\n";
os << std::uppercase;
- auto rows = ember.m_Palette.Size() / 8;
+ const auto rows = ember.m_Palette.Size() / 8;
for (i = 0; i < rows; i++)
{
@@ -289,9 +289,9 @@ string EmberToXml::ToString(Ember& ember, const string& extraAttributes, s
for (j = 0; j < 8; j++)
{
size_t idx = 8 * i + j;
- os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][0] * 255));
- os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][1] * 255));
- os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][2] * 255));
+ os << hex << setw(2) << setfill('0') << static_cast(std::rint(ember.m_Palette[idx][0] * 255));
+ os << hex << setw(2) << setfill('0') << static_cast(std::rint(ember.m_Palette[idx][1] * 255));
+ os << hex << setw(2) << setfill('0') << static_cast(std::rint(ember.m_Palette[idx][2] * 255));
}
os << "\n";
@@ -304,10 +304,10 @@ string EmberToXml::ToString(Ember& ember, const string& extraAttributes, s
{
for (i = 0; i < ember.m_Palette.Size(); i++)
{
- double r = ember.m_Palette[i][0] * 255;
- double g = ember.m_Palette[i][1] * 255;
- double b = ember.m_Palette[i][2] * 255;
- double a = ember.m_Palette[i][3] * 255;
+ const double r = ember.m_Palette[i][0] * 255;
+ const double g = ember.m_Palette[i][1] * 255;
+ const double b = ember.m_Palette[i][2] * 255;
+ const double a = ember.m_Palette[i][3] * 255;
os << " ";
//The original used a precision of 6 which is totally unnecessary, use 2.
@@ -463,7 +463,7 @@ xmlDocPtr EmberToXml::CreateNewEditdoc(Ember* parent0, Ember* parent1,
{
os << "" << comment << "";
s = os.str();
- commentDoc = xmlReadMemory(s.c_str(), int(s.length()), "comment.env", nullptr, XML_PARSE_NONET);
+ commentDoc = xmlReadMemory(s.c_str(), static_cast(s.length()), "comment.env", nullptr, XML_PARSE_NONET);
os.str("");
//Check for errors.
diff --git a/Source/Ember/Interpolate.h b/Source/Ember/Interpolate.h
index f5619e8..f74240a 100644
--- a/Source/Ember/Interpolate.h
+++ b/Source/Ember/Interpolate.h
@@ -1004,8 +1004,8 @@ public:
if (a.m_ColorSpeed < b.m_ColorSpeed) return false;
//Original did this every time, even though it's only needed if the color speeds are equal.
- m2T aMat2 = a.m_Affine.ToMat2ColMajor();
- m2T bMat2 = b.m_Affine.ToMat2ColMajor();
+ const auto aMat2 = a.m_Affine.ToMat2ColMajor();
+ const auto bMat2 = b.m_Affine.ToMat2ColMajor();
T ad = glm::determinant(aMat2);
T bd = glm::determinant(bMat2);
diff --git a/Source/Ember/Isaac.h b/Source/Ember/Isaac.h
index da1e8ce..f4ae104 100644
--- a/Source/Ember/Isaac.h
+++ b/Source/Ember/Isaac.h
@@ -32,11 +32,11 @@
///
#ifndef __ISAAC64
- typedef uint ISAAC_INT;
- const ISAAC_INT GOLDEN_RATIO = ISAAC_INT(0x9e3779b9);
+typedef uint ISAAC_INT;
+const ISAAC_INT GOLDEN_RATIO = ISAAC_INT{ 0x9e3779b9 };
#else
- typedef size_t ISAAC_INT;
- const ISAAC_INT GOLDEN_RATIO = ISAAC_INT(0x9e3779b97f4a7c13);
+typedef size_t ISAAC_INT;
+const ISAAC_INT GOLDEN_RATIO = ISAAC_INT{ 0x9e3779b97f4a7c13 };
#endif
namespace EmberNs
@@ -251,7 +251,7 @@ public:
#ifdef ISAAC_FLAM3_DEBUG
return ((Rand() & 0xfffffff) - 0x7ffffff) / (floatType)0x7ffffff;
#else
- return Frand(floatType(-1), floatType(1));
+ return Frand(floatType { -1 }, floatType { 1 });
#endif
}
diff --git a/Source/Ember/Palette.h b/Source/Ember/Palette.h
index 5d37307..b2a5ca3 100644
--- a/Source/Ember/Palette.h
+++ b/Source/Ember/Palette.h
@@ -278,12 +278,12 @@ public:
/// Frequency 1 - 10
void MakeAdjustedPalette(Palette& palette, int rot, T hue, T sat, T bright, T cont, uint blur, uint freq)
{
- T rgb[3], hsv[3];
+ T rgb[3] {}, hsv[3] {};
palette.m_Entries.resize(Size());
if (freq > 1)
{
- size_t n = Size() / freq;
+ const size_t n = Size() / freq;
for (size_t j = 0; j <= freq; j++)
{
diff --git a/Source/Ember/PaletteList.cpp b/Source/Ember/PaletteList.cpp
index a99da3a..74bff99 100644
--- a/Source/Ember/PaletteList.cpp
+++ b/Source/Ember/PaletteList.cpp
@@ -36,7 +36,7 @@ bool PaletteList::AddPaletteFile(const string& filename, const vector::AddEmptyPaletteFile(const string& filename)
{
if (!GetPaletteListByFullPath(filename))
{
- auto item = s_Palettes.insert(make_pair(filename, vector>()));
+ const auto item = s_Palettes.insert(make_pair(filename, vector>()));
Palette p;
p.m_Index = 0;
p.m_Name = "empty-default";
@@ -82,11 +82,11 @@ bool PaletteList::AddEmptyPaletteFile(const string& filename)
template
bool PaletteList::AddPaletteToFile(const string& filename, const Palette& palette)
{
- if (auto p = GetPaletteListByFullPathOrFilename(filename))
+ if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
p->push_back(palette);
p->back().m_Filename = make_shared(filename);//Ensure the filename matches because this could have been duplicated from another palette file.
- p->back().m_Index = int(p->size()) - 1;
+ p->back().m_Index = static_cast(p->size()) - 1;
Save(filename);
return true;
}
@@ -105,13 +105,13 @@ bool PaletteList::AddPaletteToFile(const string& filename, const Palette&
template
bool PaletteList::Replace(const string& filename, const Palette& palette)
{
- if (auto p = GetPaletteListByFullPathOrFilename(filename))
+ if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
for (auto& pal : *p)
{
if (pal.m_Name == palette.m_Name)
{
- auto index = pal.m_Index;
+ const auto index = pal.m_Index;
pal = palette;
pal.m_Index = index;
Save(filename);
@@ -134,7 +134,7 @@ bool PaletteList::Replace(const string& filename, const Palette& palette)
template
bool PaletteList::Replace(const string& filename, const Palette& palette, int index)
{
- if (auto p = GetPaletteListByFullPathOrFilename(filename))
+ if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
if (index < p->size())
{
@@ -160,7 +160,7 @@ bool PaletteList::Delete(const string& filename, int index)
{
int i = 0;
- if (auto p = GetPaletteListByFullPathOrFilename(filename))
+ if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
if (index < p->size())
{
@@ -188,13 +188,13 @@ template
bool PaletteList::Add(const string& filename, bool force)
{
bool added = true;
- bool contains = GetPaletteListByFullPathOrFilename(filename) != nullptr;
- auto filenameonly = GetFilename(filename);
+ const auto contains = GetPaletteListByFullPathOrFilename(filename) != nullptr;
+ const auto filenameonly = GetFilename(filename);
if (contains && !force)//Don't allow any palettes with the same name, even if they reside in different paths.
return false;
- auto palettes = s_Palettes.insert(make_pair(filename, vector>()));
+ const auto palettes = s_Palettes.insert(make_pair(filename, vector>()));
if (force || palettes.second)
{
@@ -203,12 +203,12 @@ bool PaletteList::Add(const string& filename, bool force)
if (ReadFile(filename.c_str(), buf))
{
- auto lower = ToLower(filename);
- auto pfilename = shared_ptr(new string(filename));
+ const auto lower = ToLower(filename);
+ const auto pfilename = shared_ptr(new string(filename));
if (EndsWith(lower, ".xml"))
{
- xmlDocPtr doc = xmlReadMemory(static_cast(buf.data()), int(buf.size()), filename.c_str(), nullptr, XML_PARSE_NONET);
+ const auto doc = xmlReadMemory(static_cast(buf.data()), static_cast(buf.size()), filename.c_str(), nullptr, XML_PARSE_NONET);
if (doc)
{
@@ -270,7 +270,7 @@ Palette* PaletteList::GetRandomPalette()
while (attempts < Size() * 10)
{
auto p = s_Palettes.begin();
- auto paletteFileIndex = QTIsaac::LockedRand(Size());
+ const auto paletteFileIndex = QTIsaac::LockedRand(Size());
size_t i = 0;
//Move p forward i elements.
@@ -282,7 +282,7 @@ Palette* PaletteList::GetRandomPalette()
if (i < Size())
{
- size_t paletteIndex = QTIsaac::LockedRand(p->second.size());
+ const size_t paletteIndex = QTIsaac::LockedRand(p->second.size());
if (paletteIndex < p->second.size() && !p->second[paletteIndex].IsEmpty())
return &p->second[paletteIndex];
@@ -303,7 +303,7 @@ Palette* PaletteList::GetRandomPalette()
template
Palette* PaletteList::GetPaletteByFilename(const string& filename, size_t i)
{
- if (auto palettes = GetPaletteListByFilename(filename))
+ if (const auto palettes = GetPaletteListByFilename(filename))
if (i < palettes->size())
return &(*palettes)[i];
@@ -319,7 +319,7 @@ Palette* PaletteList::GetPaletteByFilename(const string& filename, size_t
template
Palette* PaletteList::GetPaletteByFullPath(const string& filename, size_t i)
{
- if (auto palettes = GetPaletteListByFullPath(filename))
+ if (const auto palettes = GetPaletteListByFullPath(filename))
if (i < palettes->size())
return &(*palettes)[i];
@@ -335,7 +335,7 @@ Palette* PaletteList::GetPaletteByFullPath(const string& filename, size_t
template
Palette* PaletteList::GetPaletteByName(const string& filename, const string& name)
{
- if (auto palettes = GetPaletteListByFullPathOrFilename(filename))
+ if (const auto palettes = GetPaletteListByFullPathOrFilename(filename))
for (auto& palette : *palettes)
if (palette.m_Name == name)
return &palette;
@@ -351,7 +351,7 @@ Palette* PaletteList::GetPaletteByName(const string& filename, const strin
template
vector>* PaletteList::GetPaletteListByFilename(const string& filename)
{
- auto filenameonly = GetFilename(filename);
+ const auto filenameonly = GetFilename(filename);
for (auto& palettes : s_Palettes)
if (GetFilename(palettes.first) == filenameonly)
@@ -368,7 +368,7 @@ vector>* PaletteList::GetPaletteListByFilename(const string& filen
template
vector>* PaletteList::GetPaletteListByFullPath(const string& filename)
{
- auto palettes = s_Palettes.find(filename);
+ const auto palettes = s_Palettes.find(filename);
if (palettes != s_Palettes.end() && !palettes->second.empty())
return &palettes->second;
@@ -401,7 +401,7 @@ vector>* PaletteList::GetPaletteListByFullPathOrFilename(const str
template
string PaletteList::GetFullPathFromFilename(const string& filename)
{
- auto filenameonly = GetFilename(filename);
+ const auto filenameonly = GetFilename(filename);
for (auto& palettes : s_Palettes)
if (GetFilename(palettes.first) == filenameonly)
@@ -422,7 +422,7 @@ string PaletteList::GetFullPathFromFilename(const string& filename)
template
bool PaletteList::GetHueAdjustedPalette(const string& filename, size_t i, T hue, Palette& palette)
{
- if (auto unadjustedPal = GetPaletteByFullPath(filename, i))
+ if (const auto unadjustedPal = GetPaletteByFullPath(filename, i))
{
unadjustedPal->MakeHueAdjustedPalette(palette, hue);
return true;
@@ -508,7 +508,7 @@ const string& PaletteList::Name(size_t index)
template
bool PaletteList::IsModifiable(const string& filename)
{
- if (auto palFile = GetPaletteListByFullPathOrFilename(filename))
+ if (const auto palFile = GetPaletteListByFullPathOrFilename(filename))
for (auto& pal : *palFile)
if (pal.m_SourceColors.empty())
return false;
@@ -534,14 +534,14 @@ const map>>& PaletteList::Palettes() const
template
bool PaletteList::Save(const string& filename)
{
- auto fullpath = GetFullPathFromFilename(filename);
+ const auto fullpath = GetFullPathFromFilename(filename);
try
{
size_t index = 0;
ostringstream os;
- if (auto palFile = GetPaletteListByFullPathOrFilename(filename))
+ if (const auto palFile = GetPaletteListByFullPathOrFilename(filename))
{
ofstream f(fullpath);
os << "\n";
@@ -568,11 +568,11 @@ bool PaletteList::Save(const string& filename)
{
for (int j = 0; j < 8; j++)
{
- size_t idx = 8 * i + j;
+ const size_t idx = 8 * i + j;
os << "00";
- os << hex << setw(2) << setfill('0') << int(std::rint(pal[idx][0] * 255));
- os << hex << setw(2) << setfill('0') << int(std::rint(pal[idx][1] * 255));
- os << hex << setw(2) << setfill('0') << int(std::rint(pal[idx][2] * 255));
+ os << hex << setw(2) << setfill('0') << static_cast(std::rint(pal[idx][0] * 255));
+ os << hex << setw(2) << setfill('0') << static_cast(std::rint(pal[idx][1] * 255));
+ os << hex << setw(2) << setfill('0') << static_cast(std::rint(pal[idx][2] * 255));
}
os << "\n";
@@ -651,7 +651,7 @@ void PaletteList::ParsePalettes(xmlNode* node, const shared_ptr& file
ss.clear();//Reset and fill the string stream.
ss.str(tmpStr);
ss >> tmp;//Do the conversion.
- palette.m_Entries[colorCount][i] = T(tmp) / T(255);//Hex palette is [0..255], convert to [0..1].
+ palette.m_Entries[colorCount][i] = static_cast(tmp) / static_cast(255);//Hex palette is [0..255], convert to [0..1].
}
colorCount++;
@@ -659,12 +659,12 @@ void PaletteList::ParsePalettes(xmlNode* node, const shared_ptr& file
}
else if (!Compare(attr->name, "source_colors"))
{
- string s(val);
- auto vec1 = Split(s, ' ');
+ const string s(val);
+ const auto vec1 = Split(s, ' ');
for (auto& v : vec1)
{
- auto vec2 = Split(v, ',');
+ const auto vec2 = Split(v, ',');
if (vec2.size() == 4)
{
diff --git a/Source/Ember/Point.h b/Source/Ember/Point.h
index 15f11cb..76378dd 100644
--- a/Source/Ember/Point.h
+++ b/Source/Ember/Point.h
@@ -211,7 +211,7 @@ public:
r = 0;
g = 0;
b = 0;
- a = norm ? T(1) : T(255);
+ a = norm ? T{ 1 } : T{ 255 };
}
};
}
diff --git a/Source/Ember/Renderer.cpp b/Source/Ember/Renderer.cpp
index e5631df..f5bbf49 100644
--- a/Source/Ember/Renderer.cpp
+++ b/Source/Ember/Renderer.cpp
@@ -11,7 +11,7 @@ Renderer::Renderer()
{
//Use a very large number regardless of the size of the output pixels. This should be sufficient granularity, even though
//it's technically less than the number of distinct values representable by a 32-bit float.
- m_Csa.resize(size_t(CURVES_LENGTH));
+ m_Csa.resize(static_cast(CURVES_LENGTH));
//Ensure the renderer at least has sane values for the camera upon startup.
//This is needed because due to timing/threading disconnects, the GUI can use the camera
//values before the render has started, which will lead to corrupt values.
@@ -114,7 +114,7 @@ void Renderer::ComputeBounds()
template
void Renderer::ComputeQuality()
{
- m_Scale = std::pow(T(2.0), Zoom());
+ m_Scale = std::pow(static_cast(2), Zoom());
m_ScaledQuality = Quality() * SQR(m_Scale);
}
@@ -130,11 +130,11 @@ void Renderer::ComputeCamera()
m_PixelsPerUnitY = m_PixelsPerUnitX;
m_PixelsPerUnitX /= PixelAspectRatio();
T shift = 0;
- T t0 = T(m_GutterWidth) / (Supersample() * m_PixelsPerUnitX);
- T t1 = T(m_GutterWidth) / (Supersample() * m_PixelsPerUnitY);
+ T t0 = static_cast(m_GutterWidth) / (Supersample() * m_PixelsPerUnitX);
+ T t1 = static_cast(m_GutterWidth) / (Supersample() * m_PixelsPerUnitY);
//These go from ll to ur, moving from negative to positive.
- m_LowerLeftX = CenterX() - FinalRasW() / m_PixelsPerUnitX / T(2.0);
- m_LowerLeftY = CenterY() - FinalRasH() / m_PixelsPerUnitY / T(2.0);
+ m_LowerLeftX = CenterX() - FinalRasW() / m_PixelsPerUnitX / static_cast(2);
+ m_LowerLeftY = CenterY() - FinalRasH() / m_PixelsPerUnitY / static_cast(2);
m_UpperRightX = m_LowerLeftX + FinalRasW() / m_PixelsPerUnitX;
m_UpperRightY = m_LowerLeftY + FinalRasH() / m_PixelsPerUnitY;
T carLlX = m_LowerLeftX - t0;
@@ -258,7 +258,8 @@ bool Renderer::CreateDEFilter(bool& newAlloc)
(m_Ember.m_CurveDE != m_DensityFilter->Curve()) ||
(m_Ember.m_Supersample != m_DensityFilter->Supersample()))
{
- m_DensityFilter = make_unique>(bucketT(m_Ember.m_MinRadDE), bucketT(m_Ember.m_MaxRadDE), bucketT(m_Ember.m_CurveDE), m_Ember.m_Supersample);
+ m_DensityFilter = make_unique>(static_cast(m_Ember.m_MinRadDE), static_cast(m_Ember.m_MaxRadDE),
+ static_cast(m_Ember.m_CurveDE), m_Ember.m_Supersample);
newAlloc = true;
}
@@ -297,7 +298,8 @@ bool Renderer::CreateSpatialFilter(bool& newAlloc)
(m_PixelAspectRatio != m_SpatialFilter->PixelAspectRatio()))
{
m_SpatialFilter = unique_ptr>(
- SpatialFilterCreator::Create(m_Ember.m_SpatialFilterType, bucketT(m_Ember.m_SpatialFilterRadius), m_Ember.m_Supersample, bucketT(m_PixelAspectRatio)));
+ SpatialFilterCreator::Create(m_Ember.m_SpatialFilterType,
+ static_cast(m_Ember.m_SpatialFilterRadius), m_Ember.m_Supersample, static_cast(m_PixelAspectRatio)));
m_Ember.m_SpatialFilterRadius = m_SpatialFilter->FilterRadius();//It may have been changed internally if it was too small, so ensure they're synced.
newAlloc = true;
}
@@ -315,6 +317,7 @@ template
bool Renderer::CreateTemporalFilter(bool& newAlloc)
{
newAlloc = false;
+ //static int i = 0;
//Use intelligent testing so it isn't created every time a new ember is passed in.
if ((!m_TemporalFilter.get()) ||
@@ -326,6 +329,14 @@ bool Renderer::CreateTemporalFilter(bool& newAlloc)
m_TemporalFilter = unique_ptr>(
TemporalFilterCreator::Create(m_Ember.m_TemporalFilterType, m_Ember.m_TemporalSamples, m_Ember.m_TemporalFilterWidth, m_Ember.m_TemporalFilterExp));
newAlloc = true;
+ //auto name = TemporalFilterCreator::ToString(m_TemporalFilter->FilterType());
+ //ostringstream os;
+ //os << "./" << ++i << "_" << name << "_filter.txt";
+ //ofstream of (os.str());
+ //auto str = m_TemporalFilter->ToString();
+ //
+ //if (of.is_open())
+ // of << str;
}
return m_TemporalFilter.get() != nullptr;
@@ -421,7 +432,7 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, si
}
//Make sure values are within valid range.
- ClampGteRef(m_Ember.m_Supersample, size_t(1));
+ ClampGteRef(m_Ember.m_Supersample, static_cast(1));
//Make sure to get most recent update since loop won't be entered to call Interp().
//Vib, gam and background are normally summed for each temporal sample. However if iteration is skipped, make sure to get the latest.
@@ -442,7 +453,7 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, si
//it.Tic();
//Interpolate.
if (m_EmbersP->size() > 1)
- m_Interpolater.Interpolate(*m_EmbersP, T(time), 0, m_Ember);
+ m_Interpolater.Interpolate(*m_EmbersP, static_cast(time), 0, m_Ember);
//it.Toc("Interp 1");
@@ -480,7 +491,7 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, si
}
}
- deTime = T(time) + *m_TemporalFilter->Deltas();
+ deTime = static_cast(time) + *m_TemporalFilter->Deltas();
//Interpolate and get an ember for DE purposes.
//Additional interpolation will be done in the temporal samples loop.
@@ -506,7 +517,7 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, si
for (; (temporalSample < TemporalSamples()) && !m_Abort;)
{
T colorScalar = m_TemporalFilter->Filter()[temporalSample];
- T temporalTime = T(time) + m_TemporalFilter->Deltas()[temporalSample];
+ T temporalTime = static_cast(time) + m_TemporalFilter->Deltas()[temporalSample];
//Interpolate again.
//it.Tic();
@@ -573,9 +584,9 @@ eRenderStatus Renderer::Run(vector& finalImage, double time, si
{
m_Vibrancy += Vibrancy();
m_Gamma += Gamma();
- m_Background.r += bucketT(m_Ember.m_Background.r);
- m_Background.g += bucketT(m_Ember.m_Background.g);
- m_Background.b += bucketT(m_Ember.m_Background.b);
+ m_Background.r += static_cast(m_Ember.m_Background.r);
+ m_Background.g += static_cast(m_Ember.m_Background.g);
+ m_Background.b += static_cast(m_Ember.m_Background.b);
m_VibGamCount++;
m_LastIter = 0;
temporalSample++;
@@ -617,14 +628,14 @@ FilterAndAccum:
//to be very dark. Correct it by pretending the number of iters done is the exact quality desired and then scale according to that.
if (forceOutput)
{
- T quality = (T(m_Stats.m_Iters) / T(FinalDimensions())) * (m_Scale * m_Scale);
- m_K2 = bucketT((Supersample() * Supersample()) / (area * quality * m_TemporalFilter->SumFilt()));
+ T quality = (static_cast(m_Stats.m_Iters) / static_cast(FinalDimensions())) * (m_Scale * m_Scale);
+ m_K2 = static_cast((Supersample() * Supersample()) / (area * quality * m_TemporalFilter->SumFilt()));
}
else
- m_K2 = bucketT((Supersample() * Supersample()) / (area * m_ScaledQuality * m_TemporalFilter->SumFilt()));
+ m_K2 = static_cast((Supersample() * Supersample()) / (area * m_ScaledQuality * m_TemporalFilter->SumFilt()));
}
else
- m_K2 = bucketT(m_Ember.m_K2);
+ m_K2 = static_cast(m_Ember.m_K2);
if (!ResetBuckets(false, true))//Only the histogram was reset above, now reset the density filtering buffer.
{
@@ -692,7 +703,7 @@ AccumOnly:
//Make sure a filter has been created.
CreateSpatialFilter(newFilterAlloc);
- m_DensityFilterOffset = m_GutterWidth - size_t(Clamp((T(m_SpatialFilter->FinalFilterWidth()) - T(Supersample())) / 2, 0, T(m_GutterWidth)));
+ m_DensityFilterOffset = m_GutterWidth - static_cast(Clamp((static_cast(m_SpatialFilter->FinalFilterWidth()) - static_cast(Supersample())) / 2, 0, static_cast(m_GutterWidth)));
m_CurvesSet = m_Ember.m_Curves.CurvesSet();
ComputeCurves();//Color curves must be re-calculated as well.
@@ -747,7 +758,7 @@ EmberImageComments Renderer::ImageComments(const EmberStats& stats,
EmberImageComments comments;
ss.imbue(std::locale(""));
comments.m_Genome = m_EmberToXml.ToString(m_Ember, "", printEditDepth, false, hexPalette);
- ss << (double(stats.m_Badvals) / double(stats.m_Iters));//Percentage of bad values to iters.
+ ss << (static_cast(stats.m_Badvals) / static_cast(stats.m_Iters));//Percentage of bad values to iters.
comments.m_Badvals = ss.str(); ss.str("");
ss << stats.m_Iters;
comments.m_NumIters = ss.str(); ss.str("");//Total iters.
@@ -767,7 +778,7 @@ EmberImageComments Renderer::ImageComments(const EmberStats& stats,
template
void Renderer::MakeDmap(T colorScalar)
{
- m_Ember.m_Palette.template MakeDmap(m_Dmap, bucketT(colorScalar));
+ m_Ember.m_Palette.template MakeDmap(m_Dmap, static_cast(colorScalar));
}
///
@@ -778,8 +789,8 @@ void Renderer::MakeDmap(T colorScalar)
template
bool Renderer::Alloc(bool histOnly)
{
- bool b = true;
- bool lock =
+ auto b = true;
+ const auto lock =
(m_SuperSize != m_HistBuckets.size()) ||
(m_SuperSize != m_AccumulatorBuckets.size()) ||
(m_ThreadsToUse != m_Samples.size()) ||
@@ -888,14 +899,14 @@ bool Renderer::ResetBuckets(bool resetHist, bool resetAccum)
template
void Renderer::VectorizedLogScale(size_t row, size_t rowEnd)
{
- float k1 = float(m_K1);//All types must be float.
- float k2 = float(m_K2);
+ const auto k1 = static_cast(m_K1);//All types must be float.
+ const auto k2 = static_cast(m_K2);
auto* __restrict hist = m_HistBuckets.data();//Vectorizer can't tell these point to different locations.
auto* __restrict acc = m_AccumulatorBuckets.data();
for (size_t i = row; i < rowEnd; i++)
{
- float logScale = (k1 * std::log(1.0f + hist[i].a * k2)) / (hist[i].a + std::numeric_limits::epsilon());
+ const float logScale = (k1 * std::log(1.0f + hist[i].a * k2)) / (hist[i].a + std::numeric_limits::epsilon());
acc[i].r = hist[i].r * logScale;//Must break these out individually. Vectorizer can't reason about vec4's overloaded * operator.
acc[i].g = hist[i].g * logScale;
acc[i].b = hist[i].b * logScale;
@@ -919,7 +930,7 @@ eRenderStatus Renderer::LogScaleDensityFilter(bool forceOutput)
//Timing t(4);
//Original didn't parallelize this, doing so gives a 50-75% speedup.
//The value can be directly assigned, which is quicker than summing.
- parallel_for(startRow, endRow, size_t(1), [&](size_t j)
+ parallel_for(startRow, endRow, static_cast(1), [&](size_t j)
{
size_t row = j * m_SuperRasW;
size_t rowEnd = row + endCol;
@@ -931,7 +942,7 @@ eRenderStatus Renderer::LogScaleDensityFilter(bool forceOutput)
//Check for visibility first before doing anything else to avoid all possible unnecessary calculations.
if (m_HistBuckets[i].a != 0)
{
- bucketT logScale = (m_K1 * std::log(1 + m_HistBuckets[i].a * m_K2)) / m_HistBuckets[i].a;
+ const bucketT logScale = (m_K1 * std::log(1 + m_HistBuckets[i].a * m_K2)) / m_HistBuckets[i].a;
//Original did a temporary assignment, then *= logScale, then passed the result to bump_no_overflow().
//Combine here into one operation for a slight speedup.
//Vectorized version:
@@ -969,30 +980,30 @@ eRenderStatus Renderer::GaussianDensityFilter()
{
Timing totalTime, localTime;
bool scf = !(Supersample() & 1);
- intmax_t ss = Floor(Supersample() / T(2));
- T scfact = std::pow(Supersample() / (Supersample() + T(1)), T(2));
+ intmax_t ss = Floor(Supersample() / static_cast(2));
+ T scfact = std::pow(Supersample() / (Supersample() + static_cast(1)), static_cast(2));
size_t threads = m_ThreadsToUse;
size_t startRow = Supersample() - 1;
size_t endRow = m_SuperRasH - (Supersample() - 1);//Original did + which is most likely wrong.
intmax_t startCol = Supersample() - 1;
intmax_t endCol = m_SuperRasW - (Supersample() - 1);
- size_t chunkSize = size_t(ceil(double(endRow - startRow) / double(threads)));
+ size_t chunkSize = static_cast(std::ceil(static_cast(endRow - startRow) / static_cast(threads)));
//parallel_for scales very well, dividing the work almost perfectly among all processors.
- parallel_for(size_t(0), threads, size_t(1), [&] (size_t threadIndex)
+ parallel_for(static_cast(0), threads, static_cast(1), [&] (size_t threadIndex)
{
size_t pixelNumber = 0;
- int localStartRow = int(std::min(startRow + (threadIndex * chunkSize), endRow - 1));
- int localEndRow = int(std::min(localStartRow + chunkSize, endRow));
- size_t pixelsThisThread = size_t(localEndRow - localStartRow) * m_SuperRasW;
+ const auto localStartRow = static_cast(std::min(startRow + (threadIndex * chunkSize), endRow - 1));
+ const auto localEndRow = static_cast(std::min(localStartRow + chunkSize, endRow));
+ const size_t pixelsThisThread = static_cast(localEndRow - localStartRow) * m_SuperRasW;
double lastPercent = 0;
tvec4 logScaleBucket;
for (intmax_t j = localStartRow; (j < localEndRow) && !m_Abort; j++)
{
- 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();
+ const auto buckets = m_HistBuckets.data();
+ const auto bucketRowStart = buckets + (j * m_SuperRasW);//Pull out of inner loop for optimization.
+ const auto filterCoefs = m_DensityFilter->Coefs();
+ const auto filterWidths = m_DensityFilter->Widths();
for (intmax_t i = startCol; i < endCol; i++)
{
@@ -1005,7 +1016,7 @@ eRenderStatus Renderer::GaussianDensityFilter()
if (bucket->a == 0)
continue;
- bucketT cacheLog = (m_K1 * std::log(1 + bucket->a * m_K2)) / bucket->a;//Caching this calculation gives a 30% speedup.
+ const bucketT cacheLog = (m_K1 * std::log(1 + bucket->a * m_K2)) / bucket->a;//Caching this calculation gives a 30% speedup.
if (ss == 0)
{
@@ -1016,10 +1027,10 @@ eRenderStatus Renderer