--Code changes

-Modernize some C++ code.
This commit is contained in:
Person 2021-04-19 21:53:25 -06:00
parent 8086cfa731
commit a726b99dea
7 changed files with 110 additions and 110 deletions

View File

@ -58,12 +58,12 @@ public:
template <typename U> template <typename U>
Affine2D<T>& operator = (const Affine2D<U>& affine) Affine2D<T>& operator = (const Affine2D<U>& affine)
{ {
A(T(affine.A())); A(static_cast<T>(affine.A()));
B(T(affine.B())); B(static_cast<T>(affine.B()));
C(T(affine.C())); C(static_cast<T>(affine.C()));
D(T(affine.D())); D(static_cast<T>(affine.D()));
E(T(affine.E())); E(static_cast<T>(affine.E()));
F(T(affine.F())); F(static_cast<T>(affine.F()));
return *this; return *this;
} }

View File

@ -107,45 +107,45 @@ public:
m_FinalRasH = ember.m_FinalRasH; m_FinalRasH = ember.m_FinalRasH;
m_OrigFinalRasW = ember.m_OrigFinalRasW; m_OrigFinalRasW = ember.m_OrigFinalRasW;
m_OrigFinalRasH = ember.m_OrigFinalRasH; m_OrigFinalRasH = ember.m_OrigFinalRasH;
m_OrigPixPerUnit = T(ember.m_OrigPixPerUnit); m_OrigPixPerUnit = static_cast<T>(ember.m_OrigPixPerUnit);
m_RandPointRange = T(ember.m_RandPointRange); m_RandPointRange = static_cast<T>(ember.m_RandPointRange);
m_SubBatchSize = ember.m_SubBatchSize; m_SubBatchSize = ember.m_SubBatchSize;
m_FuseCount = ember.m_FuseCount; m_FuseCount = ember.m_FuseCount;
m_Supersample = ember.m_Supersample; m_Supersample = ember.m_Supersample;
m_TemporalSamples = ember.m_TemporalSamples; m_TemporalSamples = ember.m_TemporalSamples;
m_Symmetry = ember.m_Symmetry; m_Symmetry = ember.m_Symmetry;
m_Quality = T(ember.m_Quality); m_Quality = static_cast<T>(ember.m_Quality);
m_PixelsPerUnit = T(ember.m_PixelsPerUnit); m_PixelsPerUnit = static_cast<T>(ember.m_PixelsPerUnit);
m_Zoom = T(ember.m_Zoom); m_Zoom = static_cast<T>(ember.m_Zoom);
m_CamZPos = T(ember.m_CamZPos); m_CamZPos = static_cast<T>(ember.m_CamZPos);
m_CamPerspective = T(ember.m_CamPerspective); m_CamPerspective = static_cast<T>(ember.m_CamPerspective);
m_CamYaw = T(ember.m_CamYaw); m_CamYaw = static_cast<T>(ember.m_CamYaw);
m_CamPitch = T(ember.m_CamPitch); m_CamPitch = static_cast<T>(ember.m_CamPitch);
m_CamDepthBlur = T(ember.m_CamDepthBlur); m_CamDepthBlur = static_cast<T>(ember.m_CamDepthBlur);
m_BlurCurve = T(ember.m_BlurCurve); m_BlurCurve = static_cast<T>(ember.m_BlurCurve);
m_CamMat = ember.m_CamMat; m_CamMat = ember.m_CamMat;
m_CenterX = T(ember.m_CenterX); m_CenterX = static_cast<T>(ember.m_CenterX);
m_CenterY = T(ember.m_CenterY); m_CenterY = static_cast<T>(ember.m_CenterY);
m_RotCenterY = T(ember.m_RotCenterY); m_RotCenterY = static_cast<T>(ember.m_RotCenterY);
m_Rotate = T(ember.m_Rotate); m_Rotate = static_cast<T>(ember.m_Rotate);
m_Brightness = T(ember.m_Brightness); m_Brightness = static_cast<T>(ember.m_Brightness);
m_Gamma = T(ember.m_Gamma); m_Gamma = static_cast<T>(ember.m_Gamma);
m_Vibrancy = T(ember.m_Vibrancy); m_Vibrancy = static_cast<T>(ember.m_Vibrancy);
m_GammaThresh = T(ember.m_GammaThresh); m_GammaThresh = static_cast<T>(ember.m_GammaThresh);
m_HighlightPower = T(ember.m_HighlightPower); m_HighlightPower = static_cast<T>(ember.m_HighlightPower);
m_K2 = T(ember.m_K2); m_K2 = static_cast<T>(ember.m_K2);
m_Time = T(ember.m_Time); m_Time = static_cast<T>(ember.m_Time);
m_Background = ember.m_Background; m_Background = ember.m_Background;
m_Interp = ember.m_Interp; m_Interp = ember.m_Interp;
m_AffineInterp = ember.m_AffineInterp; m_AffineInterp = ember.m_AffineInterp;
m_MinRadDE = T(ember.m_MinRadDE); m_MinRadDE = static_cast<T>(ember.m_MinRadDE);
m_MaxRadDE = T(ember.m_MaxRadDE); m_MaxRadDE = static_cast<T>(ember.m_MaxRadDE);
m_CurveDE = T(ember.m_CurveDE); m_CurveDE = static_cast<T>(ember.m_CurveDE);
m_SpatialFilterType = ember.m_SpatialFilterType; m_SpatialFilterType = ember.m_SpatialFilterType;
m_SpatialFilterRadius = T(ember.m_SpatialFilterRadius); m_SpatialFilterRadius = static_cast<T>(ember.m_SpatialFilterRadius);
m_TemporalFilterType = ember.m_TemporalFilterType; m_TemporalFilterType = ember.m_TemporalFilterType;
m_TemporalFilterExp = T(ember.m_TemporalFilterExp); m_TemporalFilterExp = static_cast<T>(ember.m_TemporalFilterExp);
m_TemporalFilterWidth = T(ember.m_TemporalFilterWidth); m_TemporalFilterWidth = static_cast<T>(ember.m_TemporalFilterWidth);
m_PaletteMode = ember.m_PaletteMode; m_PaletteMode = ember.m_PaletteMode;
m_PaletteInterp = ember.m_PaletteInterp; m_PaletteInterp = ember.m_PaletteInterp;
m_Name = ember.m_Name; m_Name = ember.m_Name;
@ -223,7 +223,7 @@ public:
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
{ {
Xform<T> xform; Xform<T> xform;
xform.m_ColorX = T((oldsize + i) & 1); xform.m_ColorX = static_cast<T>((oldsize + i) & 1);
xform.AddVariation(m_VariationList->GetVariationCopy(eVariationId::VAR_LINEAR)); xform.AddVariation(m_VariationList->GetVariationCopy(eVariationId::VAR_LINEAR));
AddXform(xform); AddXform(xform);
} }
@ -381,7 +381,7 @@ public:
for (size_t i = 0; i < m_Xforms.size(); i++) for (size_t i = 0; i < m_Xforms.size(); i++)
if (GetXform(i) == xform) if (GetXform(i) == xform)
return intmax_t(i); return static_cast<intmax_t>(i);
return index; return index;
} }
@ -394,11 +394,11 @@ public:
/// <returns>The index of the matched xform if found, else -1.</returns> /// <returns>The index of the matched xform if found, else -1.</returns>
intmax_t GetTotalXformIndex(const Xform<T>* xform, bool forceFinal = false) const intmax_t GetTotalXformIndex(const Xform<T>* xform, bool forceFinal = false) const
{ {
size_t totalXformCount = TotalXformCount(forceFinal); const auto totalXformCount = TotalXformCount(forceFinal);
for (size_t i = 0; i < totalXformCount; i++) for (size_t i = 0; i < totalXformCount; i++)
if (GetTotalXform(i, forceFinal) == xform) if (GetTotalXform(i, forceFinal) == xform)
return intmax_t(i); return static_cast<intmax_t>(i);
return -1; return -1;
} }
@ -483,16 +483,16 @@ public:
m_CamMat[1][2] = std::sin(m_CamPitch) * std::cos(-m_CamYaw); m_CamMat[1][2] = std::sin(m_CamPitch) * std::cos(-m_CamYaw);
m_CamMat[2][2] = std::cos(m_CamPitch); m_CamMat[2][2] = std::cos(m_CamPitch);
if (projBits & et(eProjBits::PROJBITS_BLUR)) if (projBits & static_cast<et>(eProjBits::PROJBITS_BLUR))
{ {
if (projBits & et(eProjBits::PROJBITS_YAW)) if (projBits & static_cast<et>(eProjBits::PROJBITS_YAW))
m_ProjFunc = &EmberNs::Ember<T>::ProjectPitchYawDepthBlur; m_ProjFunc = &EmberNs::Ember<T>::ProjectPitchYawDepthBlur;
else else
m_ProjFunc = &EmberNs::Ember<T>::ProjectPitchDepthBlur; m_ProjFunc = &EmberNs::Ember<T>::ProjectPitchDepthBlur;
} }
else if ((projBits & et(eProjBits::PROJBITS_PITCH)) || (projBits & et(eProjBits::PROJBITS_YAW))) else if ((projBits & static_cast<et>(eProjBits::PROJBITS_PITCH)) || (projBits & static_cast<et>(eProjBits::PROJBITS_YAW)))
{ {
if (projBits & et(eProjBits::PROJBITS_YAW)) if (projBits & static_cast<et>(eProjBits::PROJBITS_YAW))
m_ProjFunc = &EmberNs::Ember<T>::ProjectPitchYaw; m_ProjFunc = &EmberNs::Ember<T>::ProjectPitchYaw;
else else
m_ProjFunc = &EmberNs::Ember<T>::ProjectPitch; m_ProjFunc = &EmberNs::Ember<T>::ProjectPitch;
@ -503,7 +503,7 @@ public:
} }
} }
m_BlurCoef = T(0.1) * m_CamDepthBlur; m_BlurCoef = static_cast<T>(0.1) * m_CamDepthBlur;
} }
/// <summary> /// <summary>
@ -540,9 +540,9 @@ public:
if ((onlyScaleIfNewIsSmaller && (width < m_OrigFinalRasW || height < m_OrigFinalRasH)) || !onlyScaleIfNewIsSmaller) if ((onlyScaleIfNewIsSmaller && (width < m_OrigFinalRasW || height < m_OrigFinalRasH)) || !onlyScaleIfNewIsSmaller)
{ {
if (scaleType == eScaleType::SCALE_WIDTH) if (scaleType == eScaleType::SCALE_WIDTH)
m_PixelsPerUnit = m_OrigPixPerUnit * (T(width) / T(m_OrigFinalRasW)); m_PixelsPerUnit = m_OrigPixPerUnit * (static_cast<T>(width) / static_cast<T>(m_OrigFinalRasW));
else if (scaleType == eScaleType::SCALE_HEIGHT) else if (scaleType == eScaleType::SCALE_HEIGHT)
m_PixelsPerUnit = m_OrigPixPerUnit * (T(height) / T(m_OrigFinalRasH)); m_PixelsPerUnit = m_OrigPixPerUnit * (static_cast<T>(height) / static_cast<T> (m_OrigFinalRasH));
else else
m_PixelsPerUnit = m_OrigPixPerUnit; m_PixelsPerUnit = m_OrigPixPerUnit;
} }
@ -577,7 +577,7 @@ public:
/// </summary> /// </summary>
void EqualizeWeights() void EqualizeWeights()
{ {
T weight = T(1) / m_Xforms.size(); T weight = static_cast<T>(1) / m_Xforms.size();
for (auto& xform : m_Xforms) xform.m_Weight = weight; for (auto& xform : m_Xforms) xform.m_Weight = weight;
} }
@ -648,9 +648,9 @@ public:
{ {
size_t count = 0, i = 0, j = 0; size_t count = 0, i = 0, j = 0;
while (auto xform = GetTotalXform(i++)) while (const auto xform = GetTotalXform(i++))
for (j = 0; j < xform->TotalVariationCount(); j++) for (j = 0; j < xform->TotalVariationCount(); j++)
if (auto var = xform->GetVariation(j)) if (const auto var = xform->GetVariation(j))
count += var->StateParamCount(); count += var->StateParamCount();
return count; return count;
@ -735,9 +735,9 @@ public:
Palette<float>::RgbToHsv(glm::value_ptr(embers[k].m_Palette[i]), t); Palette<float>::RgbToHsv(glm::value_ptr(embers[k].m_Palette[i]), t);
for (size_t j = 0; j < 3; j++) for (size_t j = 0; j < 3; j++)
s[j] += float(coefs[k]) * t[j]; s[j] += static_cast<float>(coefs[k]) * t[j];
s[3] += float(coefs[k]) * embers[k].m_Palette[i][3]; s[3] += static_cast<float>(coefs[k]) * embers[k].m_Palette[i][3];
} }
Palette<float>::HsvToRgb(s, glm::value_ptr(m_Palette[i])); Palette<float>::HsvToRgb(s, glm::value_ptr(m_Palette[i]));
@ -1165,15 +1165,15 @@ public:
{ {
size_t val = 0; size_t val = 0;
if (m_CamZPos != 0) val |= et(eProjBits::PROJBITS_ZPOS); if (m_CamZPos != 0) val |= static_cast<et>(eProjBits::PROJBITS_ZPOS);
if (m_CamPerspective != 0) val |= et(eProjBits::PROJBITS_PERSP); if (m_CamPerspective != 0) val |= static_cast<et>(eProjBits::PROJBITS_PERSP);
if (m_CamPitch != 0) val |= et(eProjBits::PROJBITS_PITCH); if (m_CamPitch != 0) val |= static_cast<et>(eProjBits::PROJBITS_PITCH);
if (m_CamYaw != 0) val |= et(eProjBits::PROJBITS_YAW); if (m_CamYaw != 0) val |= static_cast<et>(eProjBits::PROJBITS_YAW);
if (m_CamDepthBlur != 0) val |= et(eProjBits::PROJBITS_BLUR); if (m_CamDepthBlur != 0) val |= static_cast<et>(eProjBits::PROJBITS_BLUR);
return val; return val;
} }
@ -1240,11 +1240,11 @@ public:
z = m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z; z = m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z;
zr = Zeps(1 - m_CamPerspective * z); zr = Zeps(1 - m_CamPerspective * z);
sincos(t, &dsin, &dcos); sincos(t, &dsin, &dcos);
T prcx = point.m_X / ctr.CachedCarHalfX(); const T prcx = point.m_X / ctr.CachedCarHalfX();
T prcy = y / ctr.CachedCarHalfY(); const T prcy = y / ctr.CachedCarHalfY();
T dist = VarFuncs<T>::Hypot(prcx, prcy) * 10; const T dist = VarFuncs<T>::Hypot(prcx, prcy) * 10;
T scale = m_BlurCurve ? (Sqr(dist) / (4 * m_BlurCurve)) : T(1); const T scale = m_BlurCurve ? (Sqr(dist) / (4 * m_BlurCurve)) : static_cast<T>(1);
T dr = rand.Frand01<T>() * (m_BlurCoef * scale) * z; const T dr = rand.Frand01<T>() * (m_BlurCoef * scale) * z;
point.m_X = (point.m_X + dr * dcos) / zr; point.m_X = (point.m_X + dr * dcos) / zr;
point.m_Y = (y + dr * dsin) / zr; point.m_Y = (y + dr * dsin) / zr;
point.m_Z -= m_CamZPos; point.m_Z -= m_CamZPos;
@ -1258,17 +1258,17 @@ public:
void ProjectPitchYawDepthBlur(Point<T>& point, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, const CarToRas<T>& ctr) void ProjectPitchYawDepthBlur(Point<T>& point, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, const CarToRas<T>& ctr)
{ {
T dsin, dcos; T dsin, dcos;
T t = rand.Frand01<T>() * M_2PI; const T t = rand.Frand01<T>() * M_2PI;
T z = point.m_Z - m_CamZPos; T z = point.m_Z - m_CamZPos;
T x = m_CamMat[0][0] * point.m_X + m_CamMat[1][0] * point.m_Y; const T x = m_CamMat[0][0] * point.m_X + m_CamMat[1][0] * point.m_Y;
T y = m_CamMat[0][1] * point.m_X + m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z; const T y = m_CamMat[0][1] * point.m_X + m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z;
z = m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z; z = m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z;
T zr = Zeps(1 - m_CamPerspective * z); const T zr = Zeps(1 - m_CamPerspective * z);
T prcx = x / ctr.CachedCarHalfX(); const T prcx = x / ctr.CachedCarHalfX();
T prcy = y / ctr.CachedCarHalfY(); const T prcy = y / ctr.CachedCarHalfY();
T dist = VarFuncs<T>::Hypot(prcx, prcy) * 10; const T dist = VarFuncs<T>::Hypot(prcx, prcy) * 10;
T scale = m_BlurCurve ? (Sqr(dist) / (4 * m_BlurCurve)) : T(1); const T scale = m_BlurCurve ? (Sqr(dist) / (4 * m_BlurCurve)) : static_cast<T>(1);
T dr = rand.Frand01<T>() * (m_BlurCoef * scale) * z; const T dr = rand.Frand01<T>() * (m_BlurCoef * scale) * z;
sincos(t, &dsin, &dcos); sincos(t, &dsin, &dcos);
point.m_X = (x + dr * dcos) / zr; point.m_X = (x + dr * dcos) / zr;
point.m_Y = (y + dr * dsin) / zr; point.m_Y = (y + dr * dsin) / zr;
@ -1282,10 +1282,10 @@ public:
/// <param name="rand">Ignored</param> /// <param name="rand">Ignored</param>
void ProjectPitchYaw(Point<T>& point, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, const CarToRas<T>& ctr) void ProjectPitchYaw(Point<T>& point, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, const CarToRas<T>& ctr)
{ {
T z = point.m_Z - m_CamZPos; const T z = point.m_Z - m_CamZPos;
T x = m_CamMat[0][0] * point.m_X + m_CamMat[1][0] * point.m_Y; const T x = m_CamMat[0][0] * point.m_X + m_CamMat[1][0] * point.m_Y;
T y = m_CamMat[0][1] * point.m_X + m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z; const T y = m_CamMat[0][1] * point.m_X + m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z;
T zr = Zeps(1 - m_CamPerspective * (m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z)); const T zr = Zeps(1 - m_CamPerspective * (m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z));
point.m_X = x / zr; point.m_X = x / zr;
point.m_Y = y / zr; point.m_Y = y / zr;
point.m_Z -= m_CamZPos; point.m_Z -= m_CamZPos;
@ -1428,7 +1428,7 @@ public:
m_FinalRasW = 100; m_FinalRasW = 100;
m_FinalRasH = 100; m_FinalRasH = 100;
m_Supersample = 1; m_Supersample = 1;
m_SpatialFilterRadius = T(0.5); m_SpatialFilterRadius = static_cast<T>(0.5);
m_Zoom = 0; m_Zoom = 0;
m_ProjFunc = &EmberNs::Ember<T>::ProjectNone; m_ProjFunc = &EmberNs::Ember<T>::ProjectNone;
m_CamZPos = 0; m_CamZPos = 0;
@ -1443,10 +1443,10 @@ public:
m_SubBatchSize = 10240; m_SubBatchSize = 10240;
m_RandPointRange = 1; m_RandPointRange = 1;
m_FuseCount = 15; m_FuseCount = 15;
m_MaxRadDE = T(9.0); m_MaxRadDE = static_cast<T>(9.0);
m_MinRadDE = 0; m_MinRadDE = 0;
m_CurveDE = T(0.4); m_CurveDE = static_cast<T>(0.4);
m_GammaThresh = T(0.01); m_GammaThresh = static_cast<T>(0.01);
m_TemporalSamples = 100; m_TemporalSamples = 100;
m_SpatialFilterType = eSpatialFilterType::GAUSSIAN_SPATIAL_FILTER; m_SpatialFilterType = eSpatialFilterType::GAUSSIAN_SPATIAL_FILTER;
m_AffineInterp = eAffineInterp::AFFINE_INTERP_LOG; m_AffineInterp = eAffineInterp::AFFINE_INTERP_LOG;
@ -1702,7 +1702,7 @@ public:
//Gamma threshold used in gamma correction during final accumulation. //Gamma threshold used in gamma correction during final accumulation.
//Xml field: "gamma_threshold". //Xml field: "gamma_threshold".
T m_GammaThresh = T(0.01); T m_GammaThresh = static_cast<T>(0.01);
//Value to control saturation of some pixels in gamma correction during final accumulation. //Value to control saturation of some pixels in gamma correction during final accumulation.
//Xml field: "highlight_power". //Xml field: "highlight_power".
@ -1760,13 +1760,13 @@ public:
//The shape of the curve that governs how quickly or slowly the filter drops off as it moves away from the center point. //The shape of the curve that governs how quickly or slowly the filter drops off as it moves away from the center point.
//Xml field: "estimator_curve". //Xml field: "estimator_curve".
T m_CurveDE = T(0.4); T m_CurveDE = static_cast<T>(0.4);
//Spatial Filter. //Spatial Filter.
//The radius of the spatial filter used in final accumulation. //The radius of the spatial filter used in final accumulation.
//Xml field: "filter". //Xml field: "filter".
T m_SpatialFilterRadius = T(0.5); T m_SpatialFilterRadius = static_cast<T>(0.5);
//The type of spatial filter used in final accumulation: //The type of spatial filter used in final accumulation:
//Gaussian, Hermite, Box, Triangle, Bell, Bspline, Lanczos3 //Gaussian, Hermite, Box, Triangle, Bell, Bspline, Lanczos3
@ -1871,7 +1871,7 @@ private:
for (size_t k = 0; k < size; k++) for (size_t k = 0; k < size; k++)
t += coefs[k] * embers[k].*m; t += coefs[k] * embers[k].*m;
this->*m = size_t(std::rint(t)); this->*m = static_cast<size_t>(std::rint(t));
} }
/// <summary> /// <summary>
@ -1886,7 +1886,7 @@ private:
template <T Xform<T>::*m> template <T Xform<T>::*m>
void InterpXform(Xform<T>* xform, size_t i, const Ember<T>* embers, const vector<T>& coefs, size_t size) void InterpXform(Xform<T>* xform, size_t i, const Ember<T>* embers, const vector<T>& coefs, size_t size)
{ {
xform->*m = T(0); xform->*m = static_cast<T>(0);
for (size_t k = 0; k < size; k++) for (size_t k = 0; k < size; k++)
xform->*m += coefs[k] * embers[k].GetTotalXform(i)->*m; xform->*m += coefs[k] * embers[k].GetTotalXform(i)->*m;

View File

@ -132,8 +132,8 @@ public:
{ {
CopyCont(m_MotionParams, other.m_MotionParams); CopyCont(m_MotionParams, other.m_MotionParams);
m_MotionFunc = other.m_MotionFunc; m_MotionFunc = other.m_MotionFunc;
m_MotionFreq = T(other.m_MotionFreq); m_MotionFreq = static_cast<T>(other.m_MotionFreq);
m_MotionOffset = T(other.m_MotionOffset); m_MotionOffset = static_cast<T>(other.m_MotionOffset);
return *this; return *this;
} }

View File

@ -224,7 +224,7 @@ public:
#ifdef ISAAC_FLAM3_DEBUG #ifdef ISAAC_FLAM3_DEBUG
return (Rand() & 0xfffffff) / (floatType)0xfffffff; return (Rand() & 0xfffffff) / (floatType)0xfffffff;
#else #else
return Frand<floatType>(floatType(0), floatType(1)); return Frand<floatType>(static_cast<floatType>(0), static_cast<floatType>(1));
#endif #endif
} }

View File

@ -397,7 +397,7 @@ public:
/// <returns>A vector holding the color values</returns> /// <returns>A vector holding the color values</returns>
vector<byte> MakeRgbPaletteBlock(size_t height) vector<byte> MakeRgbPaletteBlock(size_t height)
{ {
size_t width = Size(); const auto width = Size();
vector<byte> v(height * width * 3); vector<byte> v(height * width * 3);
if (v.size() == (height * Size() * 3)) if (v.size() == (height * Size() * 3))
@ -406,9 +406,9 @@ public:
{ {
for (size_t j = 0; j < width; j++) for (size_t j = 0; j < width; j++)
{ {
v[(width * 3 * i) + (j * 3)] = byte(m_Entries[j][0] * T(255));//Palettes are as [0..1], so convert to [0..255] here since it's for GUI display. v[(width * 3 * i) + (j * 3)] = static_cast<byte>(m_Entries[j][0] * T(255));//Palettes are as [0..1], so convert to [0..255] here since it's for GUI display.
v[(width * 3 * i) + (j * 3) + 1] = byte(m_Entries[j][1] * T(255)); v[(width * 3 * i) + (j * 3) + 1] = static_cast<byte>(m_Entries[j][1] * T(255));
v[(width * 3 * i) + (j * 3) + 2] = byte(m_Entries[j][2] * T(255)); v[(width * 3 * i) + (j * 3) + 2] = static_cast<byte>(m_Entries[j][2] * T(255));
} }
} }
} }

View File

@ -148,22 +148,22 @@ public:
{ {
m_Affine = xform.m_Affine; m_Affine = xform.m_Affine;
m_Post = xform.m_Post; m_Post = xform.m_Post;
m_Weight = T(xform.m_Weight); m_Weight = static_cast<T>(xform.m_Weight);
m_ColorX = T(xform.m_ColorX); m_ColorX = static_cast<T>(xform.m_ColorX);
m_ColorY = T(xform.m_ColorY); m_ColorY = static_cast<T>(xform.m_ColorY);
m_DirectColor = T(xform.m_DirectColor); m_DirectColor = static_cast<T>(xform.m_DirectColor);
m_ColorSpeed = T(xform.m_ColorSpeed); m_ColorSpeed = static_cast<T>(xform.m_ColorSpeed);
m_Animate = T(xform.m_Animate); m_Animate = static_cast<T>(xform.m_Animate);
m_Opacity = T(xform.m_Opacity); m_Opacity = static_cast<T>(xform.m_Opacity);
CacheColorVals(); CacheColorVals();
m_HasPre = xform.HasPre(); m_HasPre = xform.HasPre();
m_HasPost = xform.HasPost(); m_HasPost = xform.HasPost();
m_HasPreOrRegularVars = xform.PreVariationCount() > 0 || xform.VariationCount() > 0; m_HasPreOrRegularVars = xform.PreVariationCount() > 0 || xform.VariationCount() > 0;
m_Wind[0] = T(xform.m_Wind[0]); m_Wind[0] = static_cast<T>(xform.m_Wind[0]);
m_Wind[1] = T(xform.m_Wind[1]); m_Wind[1] = static_cast<T>(xform.m_Wind[1]);
m_MotionFreq = T(xform.m_MotionFreq); m_MotionFreq = static_cast<T>(xform.m_MotionFreq);
m_MotionFunc = xform.m_MotionFunc; m_MotionFunc = xform.m_MotionFunc;
m_MotionOffset = T(xform.m_MotionOffset); m_MotionOffset = static_cast<T>(xform.m_MotionOffset);
ClearAndDeleteVariations(); ClearAndDeleteVariations();
//Must manually add them via the AddVariation() function so that //Must manually add them via the AddVariation() function so that
@ -207,9 +207,9 @@ public:
if (useDefaults) if (useDefaults)
{ {
m_Weight = 0; m_Weight = 0;
m_ColorSpeed = T(0.5); m_ColorSpeed = static_cast<T>(0.5);
m_Animate = 1; m_Animate = 1;
m_ColorX = T(count & 1); m_ColorX = static_cast<T>(count & 1);
m_ColorY = 0; m_ColorY = 0;
m_DirectColor = 1; m_DirectColor = 1;
m_Opacity = 1; m_Opacity = 1;
@ -562,7 +562,7 @@ public:
//m_ColorSpeedCache = m_ColorX * (1 - m_ColorSpeed) / 2;//Apo style. //m_ColorSpeedCache = m_ColorX * (1 - m_ColorSpeed) / 2;//Apo style.
//m_OneMinusColorCache = (1 + m_ColorSpeed) / 2; //m_OneMinusColorCache = (1 + m_ColorSpeed) / 2;
m_ColorSpeedCache = m_ColorSpeed * m_ColorX;//Flam3 style. m_ColorSpeedCache = m_ColorSpeed * m_ColorX;//Flam3 style.
m_OneMinusColorCache = T(1.0) - m_ColorSpeed; m_OneMinusColorCache = static_cast<T>(1) - m_ColorSpeed;
} }
/// <summary> /// <summary>

View File

@ -232,7 +232,7 @@ void GLWidget::DrawQuad()
//Only draw if the dimensions match exactly. //Only draw if the dimensions match exactly.
if (m_TexWidth == m_Fractorium->m_Controller->FinalRasW() && if (m_TexWidth == m_Fractorium->m_Controller->FinalRasW() &&
m_TexHeight == m_Fractorium->m_Controller->FinalRasH() && m_TexHeight == m_Fractorium->m_Controller->FinalRasH() &&
((m_TexWidth * m_TexHeight) == GLint(finalImage->size()))) ((m_TexWidth * m_TexHeight) == static_cast<GLint>(finalImage->size())))
{ {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
@ -284,7 +284,7 @@ void GLWidget::DrawQuad()
if (finalImage &&//Make absolutely sure all image dimensions match when copying host side buffer to GL texture. if (finalImage &&//Make absolutely sure all image dimensions match when copying host side buffer to GL texture.
!finalImage->empty() && !finalImage->empty() &&
((m_TexWidth * m_TexHeight) == GLint(finalImage->size())) && ((m_TexWidth * m_TexHeight) == static_cast<GLint>(finalImage->size())) &&
(finalImage->size() == renderer->FinalDimensions())) (finalImage->size() == renderer->FinalDimensions()))
this->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_TexWidth, m_TexHeight, GL_RGBA, GL_FLOAT, finalImage->data()); this->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_TexWidth, m_TexHeight, GL_RGBA, GL_FLOAT, finalImage->data());
} }
@ -1243,8 +1243,8 @@ bool GLWidget::Allocate(bool force)
if (doIt) if (doIt)
{ {
m_TexWidth = GLint(w); m_TexWidth = static_cast<GLint>(w);
m_TexHeight = GLint(h); m_TexHeight = static_cast<GLint>(h);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@ -1275,8 +1275,8 @@ bool GLWidget::Allocate(bool force)
if (doIt) if (doIt)
{ {
m_TexWidth = GLint(w); m_TexWidth = static_cast<GLint>(w);
m_TexHeight = GLint(h); m_TexHeight = static_cast<GLint>(h);
this->glEnable(GL_TEXTURE_2D); this->glEnable(GL_TEXTURE_2D);
if (doResize) if (doResize)
@ -1335,7 +1335,7 @@ void GLWidget::SetViewport()
{ {
if (m_Init && (m_ViewWidth != m_TexWidth || m_ViewHeight != m_TexHeight)) if (m_Init && (m_ViewWidth != m_TexWidth || m_ViewHeight != m_TexHeight))
{ {
this->glViewport(0, 0, GLint(m_TexWidth), GLint(m_TexHeight)); this->glViewport(0, 0, static_cast<GLint>(m_TexWidth), static_cast<GLint>(m_TexHeight));
#ifdef USE_GLSL #ifdef USE_GLSL
m_Viewport = glm::ivec4(0, 0, m_TexWidth, m_TexHeight); m_Viewport = glm::ivec4(0, 0, m_TexWidth, m_TexHeight);
#endif #endif