More C++11

This commit is contained in:
mfeemster 2014-09-09 22:41:26 -07:00
parent e4a47d0d16
commit 44c90abb32
39 changed files with 881 additions and 730 deletions

View File

@ -16,10 +16,10 @@
<Option createStaticLib="1" />
<Compiler>
<Add option="-D_DEBUG" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add option="-D_M_X64" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
<Target title="ReleaseNvidia Win32">
<Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -27,16 +27,6 @@
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-DWIN32" />
<Add option="-DNDEBUG" />
<Add option="-D_WINDOWS" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add directory="../../../glm" />
<Add directory="../../../libxml2/include" />
<Add directory="../../../tbb/include" />
</Compiler>
</Target>
<Target title="ReleaseNvidia x64">
<Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -45,15 +35,13 @@
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-DWIN32" />
<Add option="-fomit-frame-pointer" />
<Add option="-O2" />
<Add option="-DNDEBUG" />
<Add option="-D_WINDOWS" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add directory="../../../glm" />
<Add directory="../../../libxml2/include" />
<Add directory="../../../tbb/include" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
<Target title="Release x64">
<Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -62,15 +50,13 @@
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-DWIN32" />
<Add option="-fomit-frame-pointer" />
<Add option="-O2" />
<Add option="-DNDEBUG" />
<Add option="-D_WINDOWS" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add directory="../../../glm" />
<Add directory="../../../libxml2/include" />
<Add directory="../../../tbb/include" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
<Target title="Release Win32">
<Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -78,16 +64,6 @@
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-DWIN32" />
<Add option="-DNDEBUG" />
<Add option="-D_WINDOWS" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add directory="../../../glm" />
<Add directory="../../../libxml2/include" />
<Add directory="../../../tbb/include" />
</Compiler>
</Target>
<Target title="Debug Win32">
<Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -95,23 +71,30 @@
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-DWIN32" />
<Add option="-D_DEBUG" />
<Add option="-D_WINDOWS" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add directory="../../../glm" />
<Add directory="../../../libxml2/include" />
<Add directory="../../../tbb/include" />
</Compiler>
</Target>
</Build>
<Compiler>
<Add option="-march=k8" />
<Add option="-Wnon-virtual-dtor" />
<Add option="-Wshadow" />
<Add option="-Winit-self" />
<Add option="-Wredundant-decls" />
<Add option="-Wcast-align" />
<Add option="-Winline" />
<Add option="-Wunreachable-code" />
<Add option="-Wmissing-include-dirs" />
<Add option="-Wswitch-enum" />
<Add option="-Wswitch-default" />
<Add option="-Wmain" />
<Add option="-pedantic" />
<Add option="-Wzero-as-null-pointer-constant" />
<Add option="-std=c++11" />
<Add option="-Wall" />
<Add option="-fpermissive" />
<Add option="-fPIC" />
<Add option="-D_M_X64" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add directory="/usr/include/libxml2" />
</Compiler>
<Linker>

View File

@ -1,64 +1,169 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug x64" />
<File name="../../Source/Ember/XmlToEmber.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<ActiveTarget name="Release x64" />
<File name="../../Source/Ember/Ember.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="../../Source/Ember/Affine2D.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/VariationsDC.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6270" topLine="202" />
</Cursor>
</File>
<File name="../../Source/Ember/Variations05.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="37378" topLine="1097" />
</Cursor>
</File>
<File name="../../Source/Ember/EmberToXml.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20943" topLine="583" />
</Cursor>
</File>
<File name="../../Source/Ember/TemporalFilter.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9058" topLine="269" />
</Cursor>
</File>
<File name="../../Source/Ember/Affine2D.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1969" topLine="12" />
</Cursor>
</File>
<File name="../../Source/Ember/VariationList.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="14159" topLine="419" />
</Cursor>
</File>
<File name="../../Source/Ember/Timing.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1699" topLine="12" />
</Cursor>
</File>
<File name="../../Source/Ember/EmberDefines.h" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2838" topLine="47" />
</Cursor>
</File>
<File name="../../Source/Ember/DllMain.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="../../Source/Ember/EmberToXml.h" open="1" top="1" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/Variations04.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="6418" topLine="129" />
<Cursor1 position="98407" topLine="3204" />
</Cursor>
</File>
<File name="../../Source/Ember/Renderer.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/XmlToEmber.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5242" topLine="116" />
<Cursor1 position="16510" topLine="323" />
</Cursor>
</File>
<File name="../../Source/Ember/Renderer.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/Interpolate.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="18225" topLine="507" />
</Cursor>
</File>
<File name="../../Source/Ember/Palette.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8808" topLine="105" />
</Cursor>
</File>
<File name="../../Source/Ember/SheepTools.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="26633" topLine="913" />
</Cursor>
</File>
<File name="../../Source/Ember/Affine2D.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="../../Source/Ember/Ember.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/Utils.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="22496" topLine="746" />
</Cursor>
</File>
<File name="../../Source/Ember/Isaac.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8062" topLine="258" />
</Cursor>
</File>
<File name="../../Source/Ember/Ember.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="19820" topLine="664" />
</Cursor>
</File>
<File name="../../Source/Ember/Variations01.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="136093" topLine="4660" />
</Cursor>
</File>
<File name="../../Source/Ember/Renderer.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16331" topLine="326" />
</Cursor>
</File>
<File name="../../Source/Ember/Point.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="3653" topLine="148" />
</Cursor>
</File>
<File name="../../Source/Ember/Xform.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="32608" topLine="1024" />
</Cursor>
</File>
<File name="../../Source/Ember/EmberPch.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="../../Source/Ember/Utils.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/SpatialFilter.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="21424" topLine="713" />
<Cursor1 position="22861" topLine="816" />
</Cursor>
</File>
<File name="../../Source/Ember/CarToRas.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/CarToRas.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="2973" topLine="67" />
</Cursor>
</File>
<File name="../../Source/Ember/Ember.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/EmberPch.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="953" topLine="25" />
</Cursor>
</File>
<File name="../../Source/Ember/Affine2D.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/PaletteList.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="1381" topLine="37" />
</Cursor>
</File>
<File name="../../Source/Ember/DllMain.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/Variation.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="42788" topLine="1649" />
</Cursor>
</File>
<File name="../../Source/Ember/EmberPch.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="../../Source/Ember/Iterator.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="2509" topLine="39" />
</Cursor>
</File>
<File name="../../Source/Ember/Variations03.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="62259" topLine="1950" />
</Cursor>
</File>
<File name="../../Source/Ember/Renderer.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13576" topLine="347" />
</Cursor>
</File>
<File name="../../Source/Ember/Variations02.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="116327" topLine="3912" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug x64" />
<ActiveTarget name="Release x64" />
<File name="../../Source/EmberCommon/EmberCommon.h" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="../../Source/EmberAnimate/EmberAnimate.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9928" topLine="290" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug x64" />
<ActiveTarget name="Release x64" />
</CodeBlocks_layout_file>

View File

@ -1,4 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug x64" />
<ActiveTarget name="Release x64" />
<File name="../../Source/EmberCommon/EmberCommon.h" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
<Folding>
<Collapse line="17" />
</Folding>
</File>
<File name="../../Source/EmberCommon/EmberCommonPch.cpp" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -161,18 +161,18 @@
</Linker>
</Target>
</Build>
<Unit filename="../../EmberCommon/EmberCommon.h" />
<Unit filename="../../EmberCommon/EmberCommonPch.cpp" />
<Unit filename="../../EmberCommon/EmberCommonPch.h" />
<Unit filename="../../EmberCommon/EmberOptions.h" />
<Unit filename="../../EmberCommon/JpegUtils.h" />
<Unit filename="../../EmberCommon/SimpleGlob.h" />
<Unit filename="../../EmberCommon/SimpleOpt.h" />
<Unit filename="../../EmberRender/EmberRender.cpp" />
<Unit filename="../../EmberRender/EmberRender.h" />
<Unit filename="../../EmberRender/EmberRender.rc" />
<Unit filename="../../EmberRender/resource.h" />
<Unit filename="../../Fractorium/Icons/Fractorium.ico" />
<Unit filename="../../Source/EmberCommon/EmberCommon.h" />
<Unit filename="../../Source/EmberCommon/EmberCommonPch.cpp" />
<Unit filename="../../Source/EmberCommon/EmberCommonPch.h" />
<Unit filename="../../Source/EmberCommon/EmberOptions.h" />
<Unit filename="../../Source/EmberCommon/JpegUtils.h" />
<Unit filename="../../Source/EmberCommon/SimpleGlob.h" />
<Unit filename="../../Source/EmberCommon/SimpleOpt.h" />
<Unit filename="../../Source/EmberRender/EmberRender.cpp" />
<Unit filename="../../Source/EmberRender/EmberRender.h" />
<Unit filename="../../Source/EmberRender/resource.h" />
<Unit filename="ReadMe.txt" />
<Extensions>
<code_completion />

View File

@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug x64" />
<ActiveTarget name="Release x64" />
<File name="../../Source/EmberCommon/EmberCommon.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="108" />
</Cursor>
</File>
<File name="../../Source/EmberRender/EmberRender.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="526" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -134,8 +134,8 @@ public:
m_PixPerImageUnitH = (T)rasH * invSizeH;
m_RasLlY = m_PixPerImageUnitH * carLlY;
T m_OneRow = abs(m_CarUrY - m_CarLlY) / m_RasHeight;
T m_OneCol = abs(m_CarUrX - m_CarLlX) / m_RasWidth;
m_OneRow = abs(m_CarUrY - m_CarLlY) / m_RasHeight;
m_OneCol = abs(m_CarUrX - m_CarLlX) / m_RasWidth;
m_PadCarLlX = m_CarLlX + m_OneCol;
m_PadCarUrX = m_CarUrX - m_OneCol;
@ -249,4 +249,4 @@ private:
T m_CarLlX, m_CarLlY, m_CarUrX, m_CarUrY;//The bounds of the cartesian plane.
T m_PadCarLlX, m_PadCarLlY, m_PadCarUrX, m_PadCarUrY;//The bounds of the cartesian plane padded by one raster row and column on each side.
};
}
}

View File

@ -43,9 +43,9 @@ public:
{
Init();
}
Ember(const Ember<T>& ember)
: m_Edits(NULL)
: m_Edits(nullptr)
{
Ember<T>::operator=<T>(ember);
}
@ -56,7 +56,7 @@ public:
/// <param name="ember">The Ember object to copy</param>
template <typename U>
Ember(const Ember<U>& ember)
: m_Edits(NULL)
: m_Edits(nullptr)
{
Ember<T>::operator=<U>(ember);
}
@ -106,7 +106,7 @@ public:
m_CamDepthBlur = T(ember.m_CamDepthBlur);
m_CamMat = ember.m_CamMat;
m_CenterX = T(ember.m_CenterX);
m_CenterY = T(ember.m_CenterY);
m_CenterY = T(ember.m_CenterY);
m_Rotate = T(ember.m_Rotate);
m_Hue = T(ember.m_Hue);
m_Brightness = T(ember.m_Brightness);
@ -165,8 +165,8 @@ public:
SetProjFunc();
ClearEdit();
if (ember.m_Edits != NULL)
if (ember.m_Edits != nullptr)
m_Edits = xmlCopyDoc(ember.m_Edits, 1);
return *this;
@ -235,9 +235,9 @@ public:
m_Index = 0;
m_Xforms.reserve(12);
m_Edits = NULL;
m_Edits = nullptr;
}
/// <summary>
/// Add a copy of a new xform to the xforms vector.
/// </summary>
@ -284,7 +284,7 @@ public:
Ember<T> ember(*this);
ember.PadXforms(xformPad);
if (doFinal)
{
if (UseFinalXform())//Caller wanted one and this ember has one.
@ -301,7 +301,7 @@ public:
ember.m_FinalXform.AddVariation(new LinearVariation<T>(0));//Do this so it doesn't appear empty.
}
}
return ember;
}
@ -322,7 +322,7 @@ public:
//Now shuffle xaos values from i on back by 1 for every xform.
for (unsigned int x1 = 0; x1 < XformCount(); x1++)
{
if (xform = GetXform(x1))
if ((xform = GetXform(x1)))
{
for (unsigned int x2 = i + 1; x2 <= XformCount(); x2++)//Iterate from the position after the deletion index up to the old count.
xform->SetXaos(x2 - 1, xform->Xaos(x2));
@ -330,7 +330,7 @@ public:
xform->TruncateXaos();//Make sure no old values are hanging around in case more xforms are added to this ember later.
}
}
return true;
}
@ -358,13 +358,13 @@ public:
/// Get a pointer to the xform at the specified index, excluding the final one.
/// </summary>
/// <param name="i">The index to get</param>
/// <returns>A pointer to the xform at the index if successful, else NULL.</returns>
/// <returns>A pointer to the xform at the index if successful, else nullptr.</returns>
Xform<T>* GetXform(unsigned int i) const
{
if (i < XformCount())
return (Xform<T>*)&m_Xforms[i];
else
return NULL;
return nullptr;
}
/// <summary>
@ -372,7 +372,7 @@ public:
/// </summary>
/// <param name="i">The index to get</param>
/// <param name="forceFinal">If true, return the final xform when its index is requested even if one is not present</param>
/// <returns>A pointer to the xform at the index if successful, else NULL.</returns>
/// <returns>A pointer to the xform at the index if successful, else nullptr.</returns>
Xform<T>* GetTotalXform(unsigned int i, bool forceFinal = false) const
{
if (i < XformCount())
@ -380,7 +380,7 @@ public:
else if (i == XformCount() || forceFinal)
return (Xform<T>*)&m_FinalXform;
else
return NULL;
return nullptr;
}
/// <summary>
@ -407,7 +407,7 @@ public:
int GetTotalXformIndex(Xform<T>* xform) const
{
unsigned int totalXformCount = TotalXformCount();
for (unsigned int i = 0; i < totalXformCount; i++)
if (GetTotalXform(i) == xform)
return (int)i;
@ -461,7 +461,7 @@ public:
for (unsigned int i = 0; i < TotalXformCount(); i++)
{
Xform<T>* xform = GetTotalXform(i);
xform->CacheColorVals();
xform->SetPrecalcFlags();
}
@ -677,29 +677,29 @@ public:
bool allID, final;
unsigned int i, j, k, l, maxXformCount, totalXformCount;
T bgAlphaSave = m_Background.a;
T coefSave[2];
T coefSave[2] {0, 0};
vector<Xform<T>*> xformVec;
//Palette and others
//Palette and others
if (embers[0].m_PaletteInterp == INTERP_HSV)
{
for (i = 0; i < 256; i++)
{
T t[3], s[4] = { 0, 0, 0, 0 };
for (k = 0; k < size; k++)
{
Palette<T>::RgbToHsv(glm::value_ptr(embers[k].m_Palette[i]), t);
for (j = 0; j < 3; j++)
s[j] += coefs[k] * t[j];
s[3] += coefs[k] * embers[k].m_Palette[i][3];
}
Palette<T>::HsvToRgb(s, glm::value_ptr(m_Palette[i]));
m_Palette[i][3] = s[3];
for (j = 0; j < 4; j++)
Clamp<T>(m_Palette[i][j], 0, 1);
}
@ -803,7 +803,7 @@ public:
var->m_Weight = 0;
if (parVar != NULL)
if (parVar != nullptr)
parVar->Clear();
for (k = 0; k < size; k++)//For each ember in the list.
@ -814,17 +814,17 @@ public:
{
Variation<T>* tempVar = tempXform->GetVariationById(var->VariationId());//See if the variation at this xform index exists in that ember at this xform index.
if (tempVar != NULL)
if (tempVar != nullptr)
{
//Interp weight.
var->m_Weight += tempVar->m_Weight * coefs[k];
//If it was a parametric variation, interp params.
if (parVar != NULL)
if (parVar != nullptr)
{
ParametricVariation<T>* tempParVar = dynamic_cast<ParametricVariation<T>*>(tempVar);
if (tempParVar != NULL && (parVar->ParamCount() == tempParVar->ParamCount()))//This check will should always be true, but just check to be absolutely sure to avoid clobbering memory.
if (tempParVar != nullptr && (parVar->ParamCount() == tempParVar->ParamCount()))//This check will should always be true, but just check to be absolutely sure to avoid clobbering memory.
{
ParamWithName<T>* params = parVar->Params();
ParamWithName<T>* tempParams = tempParVar->Params();
@ -846,7 +846,7 @@ public:
InterpXform<&Xform<T>::m_ColorSpeed>(thisXform, i, embers, coefs, size);
InterpXform<&Xform<T>::m_Opacity> (thisXform, i, embers, coefs, size);
InterpXform<&Xform<T>::m_Animate> (thisXform, i, embers, coefs, size);
ClampGte0Ref(thisXform->m_Weight);
ClampRef<T>(thisXform->m_ColorX, 0, 1);
ClampRef<T>(thisXform->m_ColorSpeed, -1, 1);
@ -857,9 +857,9 @@ public:
vector<v2T> cxMag(size);
vector<v2T> cxAng(size);
vector<v2T> cxTrn(size);
thisXform->m_Affine.m_Mat = m23T(0);
//Affine part.
Interpolater<T>::ConvertLinearToPolar(embers, size, i, 0, cxAng, cxMag, cxTrn);
Interpolater<T>::InterpAndConvertBack(coefs, cxAng, cxMag, cxTrn, thisXform->m_Affine);
@ -887,7 +887,7 @@ public:
{
Interpolater<T>::ConvertLinearToPolar(embers, size, i, 1, cxAng, cxMag, cxTrn);
Interpolater<T>::InterpAndConvertBack(coefs, cxAng, cxMag, cxTrn, thisXform->m_Post);
}
}
}
else if (m_AffineInterp == INTERP_LINEAR)
{
@ -999,7 +999,7 @@ public:
//Don't rotate xforms with animate set to 0.
if (m_Xforms[i].m_Animate == 0)
continue;
//Assume that if there are no variations, then it's a padding xform.
if (m_Xforms[i].Empty() && m_AffineInterp != INTERP_LOG)
continue;
@ -1066,7 +1066,7 @@ public:
m_Xforms[i].m_Affine.E(1);
m_Xforms[i].m_Affine.F(0);
m_Xforms[i].AddVariation(new LinearVariation<T>());
result++;
sym = -sym;
}
@ -1201,9 +1201,9 @@ public:
T z = point.m_Z - m_CamZPos;
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;
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);
T dr = rand.Frand01<T>() * m_BlurCoef * z;
@ -1294,7 +1294,7 @@ public:
m_Supersample = 0;
m_SpatialFilterRadius = -1;
m_Zoom = 999999;
m_ProjFunc = NULL;
m_ProjFunc = nullptr;
m_CamZPos = 999999;
m_CamPerspective = 999999;
m_CamYaw = 999999;
@ -1316,21 +1316,21 @@ public:
m_TemporalFilterExp = -999;
m_PaletteMode = PALETTE_STEP;
}
m_Xforms.clear();
m_FinalXform.Clear();
ClearEdit();
}
/// <summary>
/// Thin wrapper to clear edit doc if not NULL and set to NULL.
/// Thin wrapper to clear edit doc if not nullptr and set to nullptr.
/// </summary>
void ClearEdit()
{
if (m_Edits != NULL)
if (m_Edits != nullptr)
xmlFreeDoc(m_Edits);
m_Edits = NULL;
m_Edits = nullptr;
}
/// <summary>
@ -1384,7 +1384,7 @@ public:
<< "Temporal Filter Type: " << m_TemporalFilterType << endl
<< "Temporal Filter Exp: " << m_TemporalFilterExp << endl
<< "Temporal Filter Width: " << m_TemporalFilterWidth << endl
<< "Palette Mode: " << m_PaletteMode << endl
<< "Palette Interp: " << m_PaletteInterp << endl
<< "Palette Index: " << m_Palette.m_Index << endl
@ -1454,14 +1454,14 @@ public:
//Note that increasing this value does not adjust the quality by a proportional amount, so an increased value may produce a degraded image.
//Xml field: "scale".
T m_PixelsPerUnit;
//A value greater than 0 will zoom in the field of view, however it will also increase the quality by a proportional amount. This is used to
//A value greater than 0 will zoom in the field of view, however it will also increase the quality by a proportional amount. This is used to
//overcome the shortcoming of scale by also adjusting the quality.
//Xml field: "zoom".
T m_Zoom;
//3D fields.
private:
private:
typedef void (Ember<T>::*ProjFuncPtr)(Point<T>&, QTIsaac<ISAAC_SIZE, ISAAC_INT>&);
ProjFuncPtr m_ProjFunc;
@ -1492,41 +1492,41 @@ public:
//Xml field: "center".
T m_CenterX;
T m_CenterY;
//Rotate the camera by this many degrees. Since this is a camera rotation, the final output image will be rotated counter-clockwise.
//Xml field: "rotate".
T m_Rotate;
//When specifying the palette as an index in the palette file, rather than inserted in the Xml, it can optionally have its hue
//rotated by this amount.
//Xml field: "hue".
T m_Hue;
//Determine how bright to make the image during final accumulation.
//Xml field: "brightness".
T m_Brightness;
//Gamma level used in gamma correction during final accumulation.
//Xml field: "gamma".
T m_Gamma;
//Used in color correction during final accumulation.
//Xml field: "vibrancy".
T m_Vibrancy;
//Gamma threshold used in gamma correction during final accumulation.
//Xml field: "gamma_threshold".
T m_GammaThresh;
//Value to control saturation of some pixels in gamma correction during final accumulation.
//Xml field: "highlight_power".
T m_HighlightPower;
//When animating a file full of many embers, this value is used to specify the time in the animation
//that this ember should be rendered. They must all be sequential and increase by a default value of 1.
//Xml field: "time".
T m_Time;
//The background color of the image used in final accumulation, ranged 0-1.
//Xml field: "background".
Color<T> m_Background;
@ -1544,7 +1544,7 @@ public:
//The type of interpolation to use for the palette when interpolating embers for animation.
//Xml field: "palette_interpolation".
ePaletteInterp m_PaletteInterp;
//Temporal Filter.
//Only used if temporal filter type is exp, else unused.
@ -1564,11 +1564,11 @@ public:
//The minimum radius of the DE filter.
//Xml field: "estimator_minimum".
T m_MinRadDE;
//The maximum radius of the DE filter.
//Xml field: "estimator_radius".
T m_MaxRadDE;
//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".
T m_CurveDE;
@ -1584,7 +1584,7 @@ public:
//Lanczos2, Mitchell, Blackman, Catrom, Hamming, Hanning, Quadratic.
//Xml field: "filter_shape".
eSpatialFilterType m_SpatialFilterType;
//Palette.
//The method used for retrieving a color from the palette when accumulating to the histogram: step, linear.
@ -1701,4 +1701,4 @@ static inline bool CompareEmbers(const Ember<T>& a, const Ember<T>& b)
{
return a.m_Time < b.m_Time;
}
}
}

View File

@ -14,7 +14,7 @@
#endif
#else
#define EMBER_API
#define fopen_s(pFile,filename,mode) ((*(pFile))=fopen((filename),(mode)))==NULL
#define fopen_s(pFile,filename,mode) ((*(pFile)=fopen((filename),(mode)))==nullptr)
#define _stat stat
#define _fstat fstat
#define _stricmp strcmp

View File

@ -146,7 +146,7 @@ public:
os << " rotate=\"" << ember.m_Rotate << "\"";
os << " supersample=\"" << max(1u, ember.m_Supersample) << "\"";
os << " filter=\"" << ember.m_SpatialFilterRadius << "\"";
os << " filter_shape=\"" << ToLower(SpatialFilterCreator<T>::ToString(ember.m_SpatialFilterType)) << "\"";
os << " temporal_filter_type=\"" << ToLower(TemporalFilterCreator<T>::ToString(ember.m_TemporalFilterType)) << "\"";
@ -247,7 +247,7 @@ public:
double g = ember.m_Palette[i][1] * 255;
double b = ember.m_Palette[i][2] * 255;
double a = ember.m_Palette[i][3] * 255;
os << " ";
//The original used a precision of 6 which is totally unnecessary, use 2.
if (IsClose(a, 255.0))
@ -269,7 +269,7 @@ public:
}
}
if (doEdits && ember.m_Edits != NULL)
if (doEdits && ember.m_Edits != nullptr)
os << ToString(xmlDocGetRootElement(ember.m_Edits), 1, true, printEditDepth);
os << "</flame>\n";
@ -282,8 +282,8 @@ public:
/// This is used when an ember is made out of some mutation or edit from one or two existing embers and
/// the user wants to capture the genetic lineage history information in the edit doc of the new ember.
/// </summary>
/// <param name="parent0">The first parent, optionally NULL.</param>
/// <param name="parent1">The second parent, optionally NULL.</param>
/// <param name="parent0">The first parent, optionally nullptr.</param>
/// <param name="parent1">The second parent, optionally nullptr.</param>
/// <param name="action">The action that was taken to create the new ember</param>
/// <param name="nick">The nickname of the author</param>
/// <param name="url">The Url of the author</param>
@ -298,18 +298,18 @@ public:
char buffer[128];
char commentString[128];
time_t myTime;
xmlDocPtr commentDoc = NULL;
xmlDocPtr commentDoc = nullptr;
xmlDocPtr doc = xmlNewDoc(XC "1.0");
xmlNodePtr rootNode = NULL, node = NULL, nodeCopy = NULL;
xmlNodePtr rootComment = NULL;
xmlNodePtr rootNode = nullptr, node = nullptr, nodeCopy = nullptr;
xmlNodePtr rootComment = nullptr;
//Create the root node, called "edit".
rootNode = xmlNewNode(NULL, XC "edit");
rootNode = xmlNewNode(nullptr, XC "edit");
xmlDocSetRootElement(doc, rootNode);
//Add the edit attributes.
//Date.
myTime = time(NULL);
myTime = time(nullptr);
#ifdef WIN32
tm localt;
localtime_s(&localt, &myTime);
@ -339,7 +339,7 @@ public:
if (sheepGen > 0 && sheepId > 0)
{
//Create a child node of the root node called sheep.
node = xmlNewChild(rootNode, NULL, XC "sheep", NULL);
node = xmlNewChild(rootNode, nullptr, XC "sheep", nullptr);
//Create the sheep attributes.
sprintf_s(buffer, 128, "%d", sheepGen);
@ -366,7 +366,7 @@ public:
else
{
//Insert a (parent has no edit) message.
nodeCopy = xmlNewChild(rootNode, NULL, XC "edit", NULL);
nodeCopy = xmlNewChild(rootNode, nullptr, XC "edit", nullptr);
AddFilenameWithoutAmpersand(nodeCopy, parent0->m_ParentFilename);
sprintf_s(buffer, 128, "%d", parent0->m_Index);
xmlNewProp(nodeCopy, XC "index", XC buffer);
@ -388,7 +388,7 @@ public:
else
{
//Insert a (parent has no edit) message.
nodeCopy = xmlNewChild(rootNode, NULL, XC "edit",NULL);
nodeCopy = xmlNewChild(rootNode, nullptr, XC "edit",nullptr);
AddFilenameWithoutAmpersand(nodeCopy, parent1->m_ParentFilename);
sprintf_s(buffer, 128, "%d", parent1->m_Index);
xmlNewProp(nodeCopy, XC "index", XC buffer);
@ -405,10 +405,10 @@ public:
if (comment != "")
{
sprintf_s(commentString, 128, "<comm>%s</comm>", comment.c_str());
commentDoc = xmlReadMemory(commentString, (int)strlen(commentString), "comment.env", NULL, XML_PARSE_NONET);
commentDoc = xmlReadMemory(commentString, (int)strlen(commentString), "comment.env", nullptr, XML_PARSE_NONET);
//Check for errors.
if (commentDoc != NULL)
if (commentDoc != nullptr)
{
//Loop through the children of the new document and copy them into the rootNode.
@ -567,9 +567,9 @@ private:
const char* tabString = " ", *attStr;
const char* editString = "edit";
const char* sheepString = "sheep";
unsigned int ti, editOrSheep = 0;
xmlAttrPtr attPtr = NULL, curAtt = NULL;
xmlNodePtr childPtr = NULL, curChild = NULL;
unsigned int ti;//, editOrSheep = 0;
xmlAttrPtr attPtr = nullptr, curAtt = nullptr;
xmlNodePtr childPtr = nullptr, curChild = nullptr;
ostringstream os;
if (printEditDepth > 0 && tabs > printEditDepth)
@ -589,13 +589,13 @@ private:
//If it's an edit node, add one to the tab.
if (!Compare(editNode->name, editString))
{
editOrSheep = 1;
//editOrSheep = 1;
tabs++;
}
else if (!Compare(editNode->name, sheepString))
editOrSheep = 2;
else
editOrSheep = 0;
else if (!Compare(editNode->name, sheepString)) { }
//editOrSheep = 2;
else { }
//editOrSheep = 0;
//Print the attributes.
attPtr = editNode->properties;
@ -649,15 +649,15 @@ private:
//Child is a text node, don't want to indent more than once.
if (xmlIsBlankNode(curChild))
continue;
if (!indentPrinted && formatting)
{
for (ti = 0; ti < tabs; ti++)
os << tabString;
indentPrinted = true;
}
//Print nodes without formatting.
os << ToString(curChild, tabs, false, printEditDepth);
}
@ -702,4 +702,4 @@ private:
}
}
};
}
}

View File

@ -85,14 +85,14 @@ public:
for (xf = 0; xf < maxCount; xf++)//This will include both normal xforms and the final.
{
destXform = destEmbers[i].GetTotalXform(xf, final);
//Ensure every parametric variation contained in every xform at either position i - 1 or i + 1 is also contained in the dest xform.
if (i > 0)
destOtherXform = destEmbers[i - 1].GetTotalXform(xf);
else if (i < count - 1)
destOtherXform = destEmbers[i + 1].GetTotalXform(xf);
else
destOtherXform = NULL;//Should never happen
destOtherXform = nullptr;//Should never happen
if (destOtherXform)
MergeXformVariations1Way(destOtherXform, destXform, true, true);
@ -130,15 +130,15 @@ public:
//with weight -1.
//Added JULIAN/JULIASCOPE to get rid of black wedges.
if (destOtherXform->GetVariationById(VAR_SPHERICAL) ||
destOtherXform->GetVariationById(VAR_NGON) ||
destOtherXform->GetVariationById(VAR_JULIAN) ||
destOtherXform->GetVariationById(VAR_NGON) ||
destOtherXform->GetVariationById(VAR_JULIAN) ||
destOtherXform->GetVariationById(VAR_JULIASCOPE) ||
destOtherXform->GetVariationById(VAR_POLAR) ||
destOtherXform->GetVariationById(VAR_WEDGE_SPH) ||
destOtherXform->GetVariationById(VAR_WEDGE_JULIA))
{
destXform->AddVariation(new LinearVariation<T>(-1));
//Set the coefs appropriately.
destXform->m_Affine.A(-1);
destXform->m_Affine.D(0);
@ -244,7 +244,7 @@ public:
if (xf >= sourceEmbers[i + ii].TotalXformCount())
continue;
Xform<T>* destOtherXform = destEmbers[i + ii].GetTotalXform(xf);
destOtherXform = destEmbers[i + ii].GetTotalXform(xf);
if (destOtherXform->GetVariationById(VAR_FAN))
{
@ -413,7 +413,7 @@ public:
while (embers[i1].m_Time < time)
i1++;
i1--;
i2 = i1 + 1;
}
@ -437,7 +437,7 @@ public:
Align(&embers[i1], &localEmbers[0], 2);
smoothFlag = false;
}
if (i2 == size - 1)
{
//fprintf(stderr, "error: cannot use smooth interpolation on last segment.\n");
@ -445,7 +445,7 @@ public:
Align(&embers[i1], &localEmbers[0], 2);
smoothFlag = false;
}
Align(&embers[i1 - 1], &localEmbers[0], 4);//Should really be doing some sort of checking here to ensure the ember vectors have 4 elements.
smoothFlag = true;
}
@ -545,7 +545,7 @@ public:
static void InterpParametricVar(vector<ParametricVariation<T>*>& first, ParametricVariation<T>* second, vector<T>& c)
{
//First, make sure the variation vector is the same size as the coefficient vector.
if (second != NULL && first.size() == c.size())
if (second != nullptr && first.size() == c.size())
{
second->Clear();
ParamWithName<T>* secondParams = second->Params();
@ -616,7 +616,7 @@ public:
//Establish the angles and magnitudes for each component.
//Keep translation linear.
zlm[0] = zlm[1] = 0;
if (Xform<T>* xform = embers[k].GetTotalXform(xfi))
{
for (col = 0; col < 2; col++)
@ -633,16 +633,16 @@ public:
c1[1] = xform->m_Post.m_Mat[1][col];
t = xform->m_Post.m_Mat[col][2];
}
cxAng[k][col] = atan2(c1[1], c1[0]);
cxMag[k][col] = sqrt(c1[0] * c1[0] + c1[1] * c1[1]);
if (cxMag[k][col] == 0)
zlm[col] = 1;
cxTrn[k][col] = t;
}
if (zlm[0] == 1 && zlm[1] == 0)
cxAng[k][0] = cxAng[k][1];
else if (zlm[0] == 0 && zlm[1] == 1)
@ -671,7 +671,7 @@ public:
//Make sure both angles are within [refang refang + 2 * pi].
while(cxAng[k - 1][col] < refang)
cxAng[k - 1][col] += M_2PI;
while(cxAng[k - 1][col] > refang + M_2PI)
cxAng[k - 1][col] -= M_2PI;
@ -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]);
}
}
@ -772,7 +772,7 @@ public:
size_t size = coefs.size();
glm::length_t i, col, accmode[2] = { 0, 0 };
T expmag, accang[2] = { 0, 0 }, accmag[2] = { 0, 0 };
//Accumulation mode defaults to logarithmic, but in special
//cases switch to linear accumulation.
for (col = 0; col < 2; col++)
@ -783,23 +783,23 @@ public:
accmode[col] = 1;//Mode set to linear interp.
}
}
for (i = 0; i < size; i++)
{
for (col = 0; col < 2; col++)
{
accang[col] += coefs[i] * cxAng[i][col];
if (accmode[col] == 0)
accmag[col] += coefs[i] * log(cxMag[i][col]);
else
else
accmag[col] += coefs[i] * (cxMag[i][col]);
//Translation is ready to go.
store.m_Mat[col][2] += coefs[i] * cxTrn[i][col];
}
}
//Convert the angle back to rectangular.
for (col = 0; col < 2; col++)
{
@ -807,7 +807,7 @@ public:
expmag = exp(accmag[col]);
else
expmag = accmag[col];
store.m_Mat[0][col] = expmag * cos(accang[col]);
store.m_Mat[1][col] = expmag * sin(accang[col]);
}
@ -836,7 +836,7 @@ public:
{
//maxStag is the spacing between xform start times if staggerPercent = 1.0.
T maxStag = T(numXforms - 1) / numXforms;
//Scale the spacing by staggerPercent.
T stagScaled = staggerPercent * maxStag;
@ -845,7 +845,7 @@ public:
//The second line makes the last xform interpolate first.
T st = stagScaled * (numXforms - 1 - thisXform) / (numXforms - 1);
T et = st + (1 - stagScaled);
if (t <= st)
return 0;
else if (t >= et)
@ -871,17 +871,17 @@ public:
else if (funcNum == MOTION_TRIANGLE)
{
T fr = fmod(timeVal, T(1.0));
if (fr < 0)
fr += 1;
if (fr <= T(0.25))
fr *= 4;
else if (fr <= T(0.75))
fr = -4 * fr + 2;
else
fr = 4 * fr - 4;
return fr;
}
else//MOTION_HILL
@ -889,7 +889,7 @@ public:
return ((1 - cos(T(2.0) * T(M_PI) * timeVal)) * T(0.5));
}
}
/*
//Will need to alter this to handle 2D palettes.
static bool InterpMissingColors(vector<glm::detail::tvec4<T>>& palette)
@ -914,18 +914,18 @@ public:
break;
}
}
if (i == 256)
{
//No colors. Set all indices properly.
for (i = 0; i < 256; i++)
palette[i].m_Index = (T)i;
palette[i].m_Index = (T)i;
return false;
}
wrapMin = minIndex + 256;
for (i = 255; i >= 0; i--)//Moving backwards, ouch!
{
if (palette[i].m_Index >= 0)
@ -934,9 +934,9 @@ public:
break;
}
}
wrapMax = maxIndex - 256;
//Loop over the indices looking for negs,
i = 0;
@ -956,29 +956,29 @@ public:
colorri = intr;
i++;
}
if (intl == -1)
{
intl = wrapMax;
colorli = maxIndex;
}
if (intr == 256)
{
intr = wrapMin;
colorri = minIndex;
}
for (j = str; j <= enr; j++)
{
prcr = (j - intl) / T(intr - intl);
for (k = 0; k <= 3; k++)
palette[j].Channels[k] = T(palette[colorli].Channels[k] * (1 - prcr) + palette[colorri].Channels[k] * prcr);
palette[j].m_Index = T(j);
}
i = colorri + 1;
}
else
@ -1020,4 +1020,4 @@ public:
return ad > bd;
}
};
}
}

View File

@ -5,29 +5,29 @@
/// <summary>
/// C++ TEMPLATE VERSION OF Robert J. Jenkins Jr.'s
/// ISAAC Random Number Generator.
///
///
/// Ported from vanilla C to to template C++ class
/// by Quinn Tyler Jackson on 16-23 July 1998.
///
///
/// quinn@qtj.net
///
///
/// The function for the expected period of this
/// random number generator, according to Jenkins is:
///
///
/// f(a,b) = 2**((a+b*(3+2^^a)-1)
///
///
/// (where a is ALPHA and b is bitwidth)
///
///
/// So, for a bitwidth of 32 and an ALPHA of 8,
/// the expected period of ISAAC is:
///
///
/// 2^^(8+32*(3+2^^8)-1) = 2^^8295
///
///
/// Jackson has been able to run implementations
/// with an ALPHA as high as 16, or
///
///
/// 2^^2097263
///
///
/// -Modified by Matt Feemster to eliminate needless dynamic memory allocation and virtual functions and bring inline with Ember coding style.
/// </summary>
@ -38,13 +38,13 @@
typedef uint64_t ISAAC_INT;
const ISAAC_INT GOLDEN_RATIO = ISAAC_INT(0x9e3779b97f4a7c13);
#endif
namespace EmberNs
{
/// <summary>
/// QTIsaac class which allows using ISAAC in an OOP manner.
/// </summary>
template <int ALPHA = 4, class T = ISAAC_INT>
template <int ALPHA = 4, class T = ISAAC_INT>
class EMBER_API QTIsaac
{
public:
@ -69,7 +69,7 @@ public:
T randb;
T randc;
};
/// <summary>
/// Constructor which initialized the random context using the values passed in.
/// Leaving these as their defaults is fine, and will still give different
@ -80,8 +80,8 @@ public:
/// <param name="a">First random seed. Default: 0.</param>
/// <param name="b">Second random seed. Default: 0.</param>
/// <param name="c">Third random seed. Default: 0.</param>
/// <param name="s">Pointer to a buffer of 256 random integer seeds. Default: NULL.</param>
QTIsaac(T a = 0, T b = 0, T c = 0, T* s = NULL)
/// <param name="s">Pointer to a buffer of 256 random integer seeds. Default: nullptr.</param>
QTIsaac(T a = 0, T b = 0, T c = 0, T* s = nullptr)
{
Srand(a, b, c, s);
}
@ -193,44 +193,44 @@ public:
T a, b, c, d, e, f, g, h;
T* m = ctx->randmem;
T* r = ctx->randrsl;
a = b = c = d = e = f = g = h = GOLDEN_RATIO;
if (!useSeed)
{
ctx->randa = 0;
ctx->randb = 0;
ctx->randc = 0;
}
//Scramble it.
for (i = 0; i < 4; ++i)
for (i = 0; i < 4; ++i)
{
Shuffle(a, b, c, d, e, f, g, h);
}
if (useSeed)
if (useSeed)
{
//Initialize using the contents of r[] as the seed.
for (i = 0; i < N; i += 8)
{
a += r[i ]; b += r[i + 1]; c += r[i + 2]; d += r[i + 3];
e += r[i + 4]; f += r[i + 5]; g += r[i + 6]; h += r[i + 7];
Shuffle(a, b, c, d, e, f, g, h);
m[i ] = a; m[i + 1] = b; m[i + 2] = c; m[i + 3] = d;
m[i + 4] = e; m[i + 5] = f; m[i + 6] = g; m[i + 7] = h;
}
}
//Do a second pass to make all of the seed affect all of m.
for (i = 0; i < N; i += 8)
{
a += m[i ]; b += m[i + 1]; c += m[i + 2]; d += m[i + 3];
e += m[i + 4]; f += m[i + 5]; g += m[i + 6]; h += m[i + 7];
Shuffle(a, b, c, d, e, f, g, h);
m[i ] = a; m[i + 1] = b; m[i + 2] = c; m[i + 3] = d;
m[i + 4] = e; m[i + 5] = f; m[i + 6] = g; m[i + 7] = h;
}
@ -239,11 +239,11 @@ public:
{
//Fill in mm[] with messy stuff.
Shuffle(a, b, c, d, e, f, g, h);
m[i ] = a; m[i + 1] = b; m[i + 2] = c; m[i + 3] = d;
m[i + 4] = e; m[i + 5] = f; m[i + 6] = g; m[i + 7] = h;
}
Isaac(ctx); //Fill in the first set of results.
ctx->randcnt = N;//TODO//0;//Prepare to use the first set of results.
}
@ -255,10 +255,10 @@ public:
/// <param name="a">First random seed. Default: 0.</param>
/// <param name="b">Second random seed. Default: 0.</param>
/// <param name="c">Third random seed. Default: 0.</param>
/// <param name="s">Pointer to a buffer of 256 random integer seeds. Default: NULL.</param>
void Srand(T a = 0, T b = 0, T c = 0, T* s = NULL)
/// <param name="s">Pointer to a buffer of 256 random integer seeds. Default: nullptr.</param>
void Srand(T a = 0, T b = 0, T c = 0, T* s = nullptr)
{
if (s == NULL)//Default to using time plus index as the seed if s was NULL.
if (s == nullptr)//Default to using time plus index as the seed if s was nullptr.
{
for (int i = 0; i < N; i++)
m_Rc.randrsl[i] = (T)time(0) + i;
@ -272,9 +272,9 @@ public:
#ifndef ISAAC_FLAM3_DEBUG
if (a == 0 && b == 0 && c == 0)
{
m_Rc.randa = (T)time(0);
m_Rc.randb = (T)time(0) * (T)time(0);
m_Rc.randc = (T)time(0) * (T)time(0) * (T)time(0);
m_Rc.randa = (T)time(nullptr);
m_Rc.randb = (T)time(nullptr) * (T)time(nullptr);
m_Rc.randc = (T)time(nullptr) * (T)time(nullptr) * (T)time(nullptr);
}
else
#endif
@ -283,10 +283,10 @@ public:
m_Rc.randb = b;
m_Rc.randc = c;
}
RandInit(&m_Rc, true);
}
protected:
/// <summary>
/// Compute the next batch of random numbers for a random context.
@ -295,17 +295,17 @@ protected:
void Isaac(randctx* ctx)
{
T x,y;
T* mm = ctx->randmem;
T* r = ctx->randrsl;
T a = (ctx->randa);
T b = (ctx->randb + (++ctx->randc));
T* m = mm;
T* m = mm;
T* m2 = (m + (N / 2));
T* mend = m2;
for(; m < mend; )
{
#ifndef __ISAAC64
@ -320,9 +320,9 @@ protected:
RngStep( a ^ (a >> 33) , a, b, mm, m, m2, r, x, y);
#endif // __ISAAC64
}
m2 = mm;
for(; m2<mend;)
{
#ifndef __ISAAC64
@ -337,11 +337,11 @@ protected:
RngStep( a ^ (a >> 33) , a, b, mm, m, m2, r, x, y);
#endif // __ISAAC64
}
ctx->randb = b;
ctx->randa = a;
}
/// <summary>
/// Retrieves a value using indirection.
/// </summary>
@ -362,26 +362,26 @@ protected:
/// </summary>
void RngStep(T mix, T& a, T& b, T*& mm, T*& m, T*& m2, T*& r, T& x, T& y)
{
x = *m;
a = (a ^ (mix)) + *(m2++);
*(m++) = y = Ind(mm, x) + a + b;
*(r++) = b = Ind(mm, y >> ALPHA) + x;
x = *m;
a = (a ^ (mix)) + *(m2++);
*(m++) = y = Ind(mm, x) + a + b;
*(r++) = b = Ind(mm, y >> ALPHA) + x;
}
/// <summary>
/// Unsure what this does.
/// </summary>
void Shuffle(T& a, T& b, T& c, T& d, T& e, T& f, T& g, T& h)
{
{
#ifndef __ISAAC64
a ^= b << 11; d += a; b += c;
b ^= c >> 2; e += b; c += d;
c ^= d << 8; f += c; d += e;
d ^= e >> 16; g += d; e += f;
e ^= f << 10; h += e; f += g;
f ^= g >> 4; a += f; g += h;
g ^= h << 8; b += g; h += a;
h ^= a >> 9; c += h; a += b;
a ^= b << 11; d += a; b += c;
b ^= c >> 2; e += b; c += d;
c ^= d << 8; f += c; d += e;
d ^= e >> 16; g += d; e += f;
e ^= f << 10; h += e; f += g;
f ^= g >> 4; a += f; g += h;
g ^= h << 8; b += g; h += a;
h ^= a >> 9; c += h; a += b;
#else // __ISAAC64
a -= e; f ^= h >> 9; h += a;
b -= f; g ^= a << 9; a += b;
@ -393,8 +393,8 @@ protected:
h -= d; e ^= g << 14; g += h;
#endif // __ISAAC64
}
private:
randctx m_Rc;//The random context which holds all of the seed and state information as well as the random number values.
};
}
}

View File

@ -57,7 +57,7 @@ public:
/// <summary>
/// Accessors.
/// </summary>
const unsigned char* XformDistributions() const { return m_XformDistributions.empty() ? NULL : &m_XformDistributions[0]; }
const unsigned char* XformDistributions() const { return m_XformDistributions.empty() ? nullptr : &m_XformDistributions[0]; }
const unsigned int XformDistributionsSize() const { return (unsigned int)m_XformDistributions.size(); }
/// <summary>
@ -70,7 +70,7 @@ public:
/// <param name="rand">The random context to use</param>
/// <returns>The number of bad values</returns>
virtual unsigned int Iterate(Ember<T>& ember, unsigned int count, unsigned int skip, Point<T>* samples, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) { return 0; }
/// <summary>
/// Initialize the xform selection vector by normalizing the weights of all xforms and
/// setting the corresponding percentage of elements in the vector to each xform's index in its
@ -103,7 +103,7 @@ public:
for (i = 0; i < ember.XformCount(); i++)
{
T d = xforms[i].m_Weight;
if (distrib > 0)
d *= xforms[distrib - 1].Xaos(i);
@ -124,12 +124,12 @@ public:
for (i = 0; i < ember.XformCount(); i++)
{
T temp = xforms[i].m_Weight;
if (distrib > 0)
temp *= xforms[distrib - 1].Xaos(i);
currentDensityLimit += temp;
//Populate points corresponding to this xform's weight/density.
//Also check that j is within the bounds of the distribution array just to be safe in the case of a rounding error.
while (tempDensity < currentDensityLimit && j < CHOOSE_XFORM_GRAIN)
@ -169,7 +169,7 @@ public:
return true;
}
protected:
protected:
/// <summary>
/// When iterating, if the computed location of the point is either very close to zero, or very close to infinity,
/// it's considered a bad value. In that case, a new random input point is fed into a new randomly chosen xform. This
@ -240,7 +240,7 @@ protected:
/// <summary>
/// Retrieve an element in the distributions vector between 0 and CHOOSE_XFORM_GRAIN which will
/// contain the index of the next xform to use. When xaos is prsent, the offset is the index in
/// contain the index of the next xform to use. When xaos is prsent, the offset is the index in
/// the ember of the previous xform used when.
/// </summary>
/// <param name="index">The index to retrieve</param>
@ -344,7 +344,7 @@ public:
}
DoFinalXform(ember, p1, samples, rand);//Apply to last fuse point and store as the first element in samples.
for (i = 1; i < count; i++)//Real loop.
{
if (xforms[NextXformFromIndex(rand.Rand())].Apply(&p1, &p1, rand))//Feed the resulting value of applying the randomly selected xform back into the next iter, and not the result of applying the final xform.
@ -405,7 +405,7 @@ public:
{
unsigned int consec = 0;
Point<T> firstBadPoint;
while (consec < 5)
{
consec++;
@ -468,11 +468,11 @@ public:
DoFinalXform(ember, p1, samples, rand);//Apply to last fuse point and store as the first element in samples.
ember.Proj(samples[0], rand);
for (i = 1; i < count; i++)//Real loop.
{
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(&p1, &p1, rand))//Feed the resulting value of applying the randomly selected xform back into the next iter, and not the result of applying the final xform.
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -520,7 +520,7 @@ public:
for (i = 0; i < skip; i++)//Fuse.
{
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(&p1, &p1, rand))
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -532,7 +532,7 @@ public:
for (i = 1; i < count; i++)//Real loop.
{
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(&p1, &p1, rand))//Feed the resulting value of applying the randomly selected xform back into the next iter, and not the result of applying the final xform.
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -547,7 +547,7 @@ public:
for (i = 0; i < skip; i++)//Fuse.
{
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(&p1, &p1, rand))
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -559,7 +559,7 @@ public:
for (i = 0; i < count - 1; i++)//Real loop.
{
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(samples + i, samples + i + 1, rand))
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, samples + i + 1, rand);
@ -571,4 +571,4 @@ public:
return badVals;
}
};
}
}

View File

@ -44,7 +44,7 @@ public:
m_Name = name;
m_Index = index;
m_Entries.resize(size);
if (xmlPaletteEntries)
{
memcpy(&m_Entries[0], xmlPaletteEntries, Size() * sizeof(m_Entries[0]));
@ -115,6 +115,14 @@ public:
Palette<T>::operator=<U>(palette);
}
/// <summary>
/// Empty destructor.
/// Needed to eliminate warnings about inlining.
/// </summary>
~Palette()
{
}
/// <summary>
/// Default assignment operator.
/// </summary>
@ -197,16 +205,16 @@ public:
palette.m_Index = m_Index;
palette.m_Name = m_Name;
palette.m_Entries.resize(Size());
for (unsigned int i = 0; i < Size(); i++)
{
size_t ii = (i * 256) / COLORMAP_LENGTH;
T rgb[3], hsv[3];
rgb[0] = m_Entries[ii].r;
rgb[1] = m_Entries[ii].g;
rgb[2] = m_Entries[ii].b;
RgbToHsv(rgb, hsv);
hsv[0] += hue * T(6.0);
HsvToRgb(hsv, rgb);
@ -264,7 +272,7 @@ public:
for (size_t i = 0; i < Size(); i++)
{
size_t ii = (i * 256) / COLORMAP_LENGTH;
rgb[0] = palette[(COLORMAP_LENGTH + ii - rot) % COLORMAP_LENGTH].r;//Rotation.
rgb[1] = palette[(COLORMAP_LENGTH + ii - rot) % COLORMAP_LENGTH].g;
rgb[2] = palette[(COLORMAP_LENGTH + ii - rot) % COLORMAP_LENGTH].b;
@ -284,7 +292,7 @@ public:
palette[i].r = rgb[0];
palette[i].g = rgb[1];
palette[i].b = rgb[2];
palette[i].a = 1;
palette[i].a = 1;
}
if (blur > 0)
@ -445,7 +453,7 @@ public:
p = v * (1 - s);
q = v * (1 - (s * f));
t = v * (1 - (s * (1 - f)));
switch (j)
{
case 0: r = v; g = t; b = p; break;
@ -481,7 +489,7 @@ public:
{
T frac, alpha;
T funcval = pow(linrange, gamma);
if (density > 0)
{
if (density < linrange)
@ -494,7 +502,7 @@ public:
}
else
alpha = 0;
return alpha;
}
@ -534,7 +542,7 @@ public:
{
newls = T(255.0) / maxc;
lsratio = pow(newls / ls, highPow);
//Calculate the max-value color (ranged 0 - 1).
for (rgbi = 0; rgbi < 3; rgbi++)
newRgb[rgbi] = (bucketT)newls * cBuf[rgbi] / bucketT(255.0);
@ -551,7 +559,7 @@ public:
{
newls = T(255.0) / maxc;
adjustedHighlight = -highPow;
if (adjustedHighlight > 1)
adjustedHighlight = 1;

View File

@ -45,9 +45,9 @@ public:
if (ReadFile(filename.c_str(), buf))
{
xmlDocPtr doc = xmlReadMemory((const char*)buf.data(), (int)buf.size(), filename.c_str(), NULL, XML_PARSE_NONET);
xmlDocPtr doc = xmlReadMemory((const char*)buf.data(), (int)buf.size(), filename.c_str(), nullptr, XML_PARSE_NONET);
if (doc != NULL)
if (doc != nullptr)
{
xmlNode* rootNode = xmlDocGetRootElement(doc);
@ -74,7 +74,7 @@ public:
/// Gets the palette at a specified index.
/// </summary>
/// <param name="i">The index of the palette to read. A value of -1 indicates a random palette.</param>
/// <returns>A pointer to the requested palette if the index was in range, else NULL.</returns>
/// <returns>A pointer to the requested palette if the index was in range, else nullptr.</returns>
Palette<T>* GetPalette(int i)
{
if (!m_Palettes.empty())
@ -85,21 +85,21 @@ public:
return &m_Palettes[i];
}
return NULL;
return nullptr;
}
/// <summary>
/// Gets a pointer to a palette with a specified name.
/// </summary>
/// <param name="name">The name of the palette to retrieve</param>
/// <returns>A pointer to the palette if found, else NULL</returns>
/// <returns>A pointer to the palette if found, else nullptr</returns>
Palette<T>* GetPaletteByName(string& name)
{
for (unsigned int i = 0; i < Count(); i++)
if (m_Palettes[i].m_Name == name)
return &m_Palettes[i];
return NULL;
return nullptr;
}
/// <summary>
@ -166,7 +166,7 @@ private:
if (!Compare(attr->name, "data"))
{
int colorIndex = 0;
int r, g, b;
unsigned int r, g, b;
int colorCount = 0;
hexError = false;
@ -223,4 +223,4 @@ private:
static bool m_Init;//Initialized to false in Ember.cpp, and will be set to true upon successful reading of an Xml palette file.
static vector<Palette<T>> m_Palettes;//The vector that stores the palettes.
};
}
}

View File

@ -224,4 +224,4 @@ public:
a = norm ? T(1) : T(255);
}
};
}
}

View File

@ -23,11 +23,11 @@ Renderer<T, bucketT>::Renderer()
m_PixelAspectRatio = 1;
m_Transparency = false;
ThreadCount(Timing::ProcessorCount());
m_StandardIterator = auto_ptr<StandardIterator<T>>(new StandardIterator<T>());
m_XaosIterator = auto_ptr<XaosIterator<T>>(new XaosIterator<T>());
m_StandardIterator = unique_ptr<StandardIterator<T>>(new StandardIterator<T>());
m_XaosIterator = unique_ptr<XaosIterator<T>>(new XaosIterator<T>());
m_Iterator = m_StandardIterator.get();
m_Callback = NULL;
m_ProgressParameter = NULL;
m_Callback = nullptr;
m_ProgressParameter = nullptr;
m_LastPass = 0;
m_LastTemporalSample = 0;
m_LastIter = 0;
@ -60,7 +60,7 @@ void Renderer<T, bucketT>::ComputeBounds()
m_GutterWidth = ClampGte((m_SpatialFilter->FinalFilterWidth() - Supersample()) / 2, 0u);
//Check the size of the density estimation filter.
//If the radius of the density estimation filter is greater than the
//If the radius of the density estimation filter is greater than the
//gutter width, have to pad with more. Otherwise, use the same value.
for (unsigned int i = 0; i < m_Embers.size(); i++)
maxDEFilterWidth = max((unsigned int)(ceil(m_Embers[i].m_MaxRadDE) * m_Ember.m_Supersample), maxDEFilterWidth);
@ -130,7 +130,7 @@ void Renderer<T, bucketT>::ChangeVal(std::function<void (void)> func, eProcessAc
Abort();
EnterRender();
func();
//If they want a full render, don't bother inspecting process state, just start over.
if (action == FULL_RENDER)
{
@ -138,7 +138,7 @@ void Renderer<T, bucketT>::ChangeVal(std::function<void (void)> func, eProcessAc
m_ProcessAction = FULL_RENDER;
}
//Keep iterating is when rendering has completed and the user increases the quality.
//Rendering can be started where it left off by adding just the difference between the
//Rendering can be started where it left off by adding just the difference between the
//new and old quality values.
else if (action == KEEP_ITERATING)
{
@ -190,7 +190,7 @@ void Renderer<T, bucketT>::ChangeVal(std::function<void (void)> func, eProcessAc
m_ProcessAction = ACCUM_ONLY;
}
}
LeaveRender();
}
@ -209,7 +209,7 @@ template <typename T, typename bucketT>
void Renderer<T, bucketT>::SetEmber(Ember<T>& ember, eProcessAction action)
{
ChangeVal([&]
{
{
m_Embers.clear();
m_Embers.push_back(ember);
m_Embers[0].m_TemporalSamples = 1;//Set temporal samples here to 1 because using the real value only makes sense when using a vector of Embers for animation.
@ -256,7 +256,7 @@ void Renderer<T, bucketT>::AddEmber(Ember<T>& ember)
/// from the last temporal filter created.
/// </summary>
/// <param name="newAlloc">True if a new filter instance was created, else false.</param>
/// <returns>True if the filter is not NULL (whether a new one was created or not), else false.</returns>
/// <returns>True if the filter is not nullptr (whether a new one was created or not), else false.</returns>
template <typename T, typename bucketT>
bool Renderer<T, bucketT>::CreateTemporalFilter(bool& newAlloc)
{
@ -270,12 +270,12 @@ bool Renderer<T, bucketT>::CreateTemporalFilter(bool& newAlloc)
(m_Ember.m_TemporalFilterWidth != m_TemporalFilter->FilterWidth()) ||
(m_Ember.m_TemporalFilterExp != m_TemporalFilter->FilterExp()))
{
m_TemporalFilter = auto_ptr<TemporalFilter<T>>(
m_TemporalFilter = unique_ptr<TemporalFilter<T>>(
TemporalFilterCreator<T>::Create(m_Ember.m_TemporalFilterType, m_Ember.m_Passes, m_Ember.m_TemporalSamples, m_Ember.m_TemporalFilterWidth, m_Ember.m_TemporalFilterExp));
newAlloc = true;
}
return m_TemporalFilter.get() != NULL;
return m_TemporalFilter.get() != nullptr;
}
/// <summary>
@ -363,7 +363,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<unsigned char>& finalImage, doubl
bool accumOnly = m_ProcessAction == ACCUM_ONLY;
bool resume = m_ProcessState != NONE;
bool newFilterAlloc;
unsigned int temporalSample, pass;
unsigned int temporalSample = 0, pass;
T deTime;
eRenderStatus success = RENDER_OK;
//double iterationTime = 0;
@ -419,10 +419,10 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<unsigned char>& finalImage, doubl
m_Vibrancy = m_Ember.m_Vibrancy;
m_Gamma = m_Ember.m_Gamma;
m_Background = m_Ember.m_Background;
if (filterAndAccumOnly)
goto FilterAndAccum;
if (accumOnly)
goto AccumOnly;
}
@ -442,7 +442,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<unsigned char>& finalImage, doubl
CreateTemporalFilter(newFilterAlloc);
ComputeBounds();
if (m_SpatialFilter.get() == NULL || m_TemporalFilter.get() == NULL)
if (m_SpatialFilter.get() == nullptr || m_TemporalFilter.get() == nullptr)
{
m_ErrorReport.push_back("Spatial and temporal filter allocations failed, aborting.\n");
success = RENDER_ERROR;
@ -509,7 +509,6 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<unsigned char>& finalImage, doubl
//The actual number of times to iterate. Each thread will get (totalIters / ThreadCount) iters to do.
//This is based on zoom and scale calculated in ComputeCamera().
//Note that the iter count is based on the final image dimensions, and not the super sampled dimensions.
uint64_t totalIterCount = TotalIterCount();
uint64_t itersPerTemporalSample = ItersPerTemporalSample();//The total number of iterations for this temporal sample in this pass without overrides.
uint64_t sampleItersToDo;//The number of iterations to actually do in this sample in this pass, considering overrides.
@ -596,7 +595,7 @@ FilterAndAccum:
}
else
m_K2 = (Supersample() * Supersample() * Passes()) / (area * m_ScaledQuality * m_TemporalFilter->SumFilt());
if (filterAndAccumOnly || pass == 0)
ResetBuckets(false, true);//Only the histogram was reset above, now reset the density filtering buffer.
//t.Tic();
@ -645,7 +644,7 @@ FilterAndAccum:
//Also skip if rendering jumped straight here after completely finishing beforehand.
if (!filterAndAccumOnly && temporalSample >= TemporalSamples())//This may not work if filtering was prematurely exited.
pass++;
if (!filterAndAccumOnly)
m_LastPass = pass;
@ -662,14 +661,14 @@ AccumOnly:
success = RENDER_ABORT;
goto Finish;
}
//Make sure a filter has been created.
CreateSpatialFilter(newFilterAlloc);
if (AccumulatorToFinalImage(finalImage, finalOffset) == RENDER_OK)
{
m_Stats.m_RenderMs = m_RenderTimer.Toc();//Record total time from the very beginning to the very end, including all intermediate calls.
//Even though the ember changes throughought the inner loops because of interpolation, it's probably ok to assign here.
//This will hold the last interpolated value (even though spatial and temporal filters were created based off of one of the first interpolated values).
m_LastEmber = m_Ember;
@ -786,7 +785,7 @@ uint64_t Renderer<T, bucketT>::MemoryAvailable()
static int mib[2] = { CTL_HW, HW_PHYSMEM };
#endif
if (sysctl(mib, 2, &physmem, &len, NULL, 0) == 0 && len == sizeof(physmem))
if (sysctl(mib, 2, &physmem, &len, nullptr, 0) == 0 && len == sizeof(physmem))
{
memAvailable = physmem;
}
@ -840,7 +839,7 @@ bool Renderer<T, bucketT>::Ok() const
/// log scale filtering will be used.
/// </summary>
/// <param name="newAlloc">True if a new filter instance was created, else false.</param>
/// <returns>True if the filter is not NULL (whether a new one was created or not) or if max rad is 0, else false.</returns>
/// <returns>True if the filter is not nullptr (whether a new one was created or not) or if max rad is 0, else false.</returns>
template <typename T, typename bucketT>
bool Renderer<T, bucketT>::CreateDEFilter(bool& newAlloc)
{
@ -856,7 +855,7 @@ bool Renderer<T, bucketT>::CreateDEFilter(bool& newAlloc)
(m_Ember.m_CurveDE != m_DensityFilter->Curve()) ||
(m_Ember.m_Supersample != m_DensityFilter->Supersample()))
{
m_DensityFilter = auto_ptr<DensityFilter<T>>(new DensityFilter<T>(m_Ember.m_MinRadDE, m_Ember.m_MaxRadDE, m_Ember.m_CurveDE, m_Ember.m_Supersample));
m_DensityFilter = unique_ptr<DensityFilter<T>>(new DensityFilter<T>(m_Ember.m_MinRadDE, m_Ember.m_MaxRadDE, m_Ember.m_CurveDE, m_Ember.m_Supersample));
newAlloc = true;
}
@ -882,7 +881,7 @@ bool Renderer<T, bucketT>::CreateDEFilter(bool& newAlloc)
/// from the last spatial filter created.
/// </summary>
/// <param name="newAlloc">True if a new filter instance was created, else false.</param>
/// <returns>True if the filter is not NULL (whether a new one was created or not), else false.</returns>
/// <returns>True if the filter is not nullptr (whether a new one was created or not), else false.</returns>
template <typename T, typename bucketT>
bool Renderer<T, bucketT>::CreateSpatialFilter(bool& newAlloc)
{
@ -895,12 +894,12 @@ bool Renderer<T, bucketT>::CreateSpatialFilter(bool& newAlloc)
(m_Ember.m_Supersample != m_SpatialFilter->Supersample()) ||
(m_PixelAspectRatio != m_SpatialFilter->PixelAspectRatio()))
{
m_SpatialFilter = auto_ptr<SpatialFilter<T>>(
m_SpatialFilter = unique_ptr<SpatialFilter<T>>(
SpatialFilterCreator<T>::Create(m_Ember.m_SpatialFilterType, m_Ember.m_SpatialFilterRadius, m_Ember.m_Supersample, m_PixelAspectRatio));
newAlloc = true;
}
return m_SpatialFilter.get() != NULL;
return m_SpatialFilter.get() != nullptr;
}
/// <summary>
@ -972,7 +971,7 @@ unsigned int Renderer<T, bucketT>::ThreadCount() const { return m_ThreadsToUse;
/// Reset the rendering process.
/// </summary>
/// <param name="threads">The number of threads to use</param>
/// <param name="seedString">The seed string to use if threads is 1. Default: NULL.</param>
/// <param name="seedString">The seed string to use if threads is 1. Default: nullptr.</param>
template <typename T, typename bucketT>
void Renderer<T, bucketT>::ThreadCount(unsigned int threads, const char* seedString)
{
@ -1194,7 +1193,7 @@ eRenderStatus Renderer<T, bucketT>::LogScaleDensityFilter()
parallel_for(startRow, endRow, [&] (unsigned int j)
{
unsigned int row = j * m_SuperRasW;
for (unsigned int i = startCol; (i < endCol) && !m_Abort; i++)
{
unsigned int index = row + i;
@ -1240,7 +1239,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
unsigned int startCol = Supersample() - 1;
unsigned int endCol = m_SuperRasW - (Supersample() - 1);
unsigned int chunkSize = (unsigned int)ceil(double(endRow - startRow) / double(threads));
//parallel_for scales very well, dividing the work almost perfectly among all processors.
parallel_for((unsigned int)0, threads, [&] (unsigned int threadIndex)
{
@ -1311,7 +1310,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
//Only have to calculate the values for ~1/8 of the square.
filterCoefIndex = filterSelectInt * m_DensityFilter->KernelSize();
arrFilterWidth = (int)ceil(filterWidths[filterSelectInt]) - 1;
for (jj = 0; jj <= arrFilterWidth; jj++)
{
for (ii = 0; ii <= jj; ii++, filterCoefIndex++)
@ -1369,7 +1368,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1))
{
double etaMs = ((100.0 - percent) / percent) * totalTime.Toc();
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 1, etaMs))
Abort();
@ -1379,7 +1378,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
}
}
});
if (m_Callback && !m_Abort)
m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, 100.0, 1, 0);
@ -1398,7 +1397,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(vector<unsigned char
{
if (PrepFinalAccumVector(pixels))
return AccumulatorToFinalImage(pixels.data(), finalOffset);
return RENDER_ERROR;
}
@ -1431,7 +1430,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(unsigned char* pixel
parallel_for((unsigned int)0, m_SuperRasH, [&] (unsigned int j)
{
unsigned int rowStart = j * m_SuperRasW;//Pull out of inner loop for optimization.
for (unsigned int i = 0; i < m_SuperRasW && !m_Abort; i++)
{
GammaCorrection(m_AccumulatorBuckets[i + rowStart], background, g, linRange, vibrancy, true, false, &(m_AccumulatorBuckets[i + rowStart][0]));//Write back in place.
@ -1461,14 +1460,14 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(unsigned char* pixel
unsigned int ii, jj;
unsigned int x = m_DensityFilterOffset + (i * Supersample());//Start at the beginning column of each super sample block.
newBucket.Clear();
//Original was iterating column-wise, which is slow.
//Here, iterate one row at a time, giving a 10% speed increase.
for (jj = 0; jj < filterWidth; jj++)
{
unsigned int filterKRowIndex = jj * filterWidth;
unsigned int accumRowIndex = (y + jj) * m_SuperRasW;//Pull out of inner loop for optimization.
for (ii = 0; ii < filterWidth; ii++)
{
//Need to dereference the spatial filter pointer object to use the [] operator. Makes no speed difference.
@ -1477,7 +1476,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(unsigned char* pixel
newBucket += (m_AccumulatorBuckets[(x + ii) + accumRowIndex] * k);
}
}
if (BytesPerChannel() == 2)
{
p16 = (unsigned short*)(pixels + pixelsRowStart);
@ -1524,7 +1523,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(unsigned char* pixel
}
}
});
//Insert the palette into the image for debugging purposes. Only works with 8bpc.
if (m_InsertPalette && BytesPerChannel() == 1)
{
@ -1532,7 +1531,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(unsigned char* pixel
if (ph >= FinalRasH())
ph = FinalRasH();
for (j = 0; j < ph; j++)
{
for (i = 0; i < FinalRasW(); i++)
@ -1621,7 +1620,7 @@ EmberStats Renderer<T, bucketT>::Iterate(uint64_t iterCount, unsigned int pass,
//accumulationTime += t.Toc();
if (m_LockAccum)
m_AccumCs.Leave();
if (m_Callback && threadIndex == 0)
{
percent = 100.0 *
@ -1647,7 +1646,7 @@ EmberStats Renderer<T, bucketT>::Iterate(uint64_t iterCount, unsigned int pass,
if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1))//Call callback function if either 10% has passed, or one second (and 1%).
{
etaMs = ((100.0 - percent) / percent) * m_RenderTimer.Toc();
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 0, etaMs))
Abort();
@ -1681,7 +1680,7 @@ EmberStats Renderer<T, bucketT>::Iterate(uint64_t iterCount, unsigned int pass,
/// </summary>
/// <returns>The vector of random contexts to assign</returns>
template <typename T, typename bucketT>
vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>> Renderer<T, bucketT>::RandVec() { return m_Rand; };
vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>> Renderer<T, bucketT>::RandVec() { return m_Rand; }
/// <summary>
/// Set the vector of random contexts.
@ -1706,7 +1705,7 @@ bool Renderer<T, bucketT>::RandVec(vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>>& randV
}
return b;
};
}
/// <summary>
/// Get whether the histogram is locked during accumulation.
@ -1957,7 +1956,7 @@ void Renderer<T, bucketT>::Accumulate(Point<T>* samples, unsigned int sampleCoun
const glm::detail::tvec4<bucketT, glm::defaultp>* dmap = &(palette->m_Entries[0]);
//It's critical to understand what's going on here as it's one of the most important parts of the algorithm.
//A color value gets retrieved from the palette and
//A color value gets retrieved from the palette and
//its RGB values are added to the existing RGB values in the histogram bucket.
//Alpha is always 1 in the palettes, so that serves as the hit count.
//This differs from the original since redundantly adding both an alpha component and a hit count is omitted.
@ -1985,7 +1984,7 @@ void Renderer<T, bucketT>::Accumulate(Point<T>* samples, unsigned int sampleCoun
if (samples[i].m_VizAdjusted != 0)
{
m_CarToRas.Convert(samples[i], histIndex);
//There is a very slim chance that a point will be right on the border and will technically be in bounds, passing the InBounds() test,
//but ends up being mapped to a histogram bucket that is out of bounds due to roundoff error. Perform one final check before proceeding.
//This will result in a few points at the very edges getting discarded, but prevents a crash and doesn't seem to make a speed difference.
@ -2016,7 +2015,7 @@ void Renderer<T, bucketT>::Accumulate(Point<T>* samples, unsigned int sampleCoun
{
colorIndexFrac = colorIndex - (bucketT)intColorIndex;//Interpolate between intColorIndex and intColorIndex + 1.
}
if (samples[i].m_VizAdjusted == 1)
m_HistBuckets[histIndex] += ((dmap[intColorIndex] * (1 - colorIndexFrac)) + (dmap[intColorIndex + 1] * colorIndexFrac));
else
@ -2141,7 +2140,7 @@ bool Renderer<T, bucketT>::AssignIterator()
m_Iterator = m_XaosIterator.get();
else
m_Iterator = m_StandardIterator.get();
//Timing t;
return m_Iterator->InitDistributions(m_Ember);
//t.Toc("Distrib creation");
@ -2240,7 +2239,7 @@ template <typename T, typename bucketT> ePaletteMode Renderer<T, bucketT
/// Iterator wrappers.
/// </summary>
template <typename T, typename bucketT> const unsigned char* Renderer<T, bucketT>::XformDistributions() const { return m_Iterator != NULL ? m_Iterator->XformDistributions() : NULL; }
template <typename T, typename bucketT> const unsigned int Renderer<T, bucketT>::XformDistributionsSize() const { return m_Iterator != NULL ? m_Iterator->XformDistributionsSize() : 0; }
template <typename T, typename bucketT> Point<T>* Renderer<T, bucketT>::Samples(unsigned int threadIndex) const { return threadIndex < m_Samples.size() ? (Point<T>*)m_Samples[threadIndex].data() : NULL; }
}
template <typename T, typename bucketT> const unsigned char* Renderer<T, bucketT>::XformDistributions() const { return m_Iterator != nullptr ? m_Iterator->XformDistributions() : nullptr; }
template <typename T, typename bucketT> const unsigned int Renderer<T, bucketT>::XformDistributionsSize() const { return m_Iterator != nullptr ? m_Iterator->XformDistributionsSize() : 0; }
template <typename T, typename bucketT> Point<T>* Renderer<T, bucketT>::Samples(unsigned int threadIndex) const { return threadIndex < m_Samples.size() ? (Point<T>*)m_Samples[threadIndex].data() : nullptr; }
}

View File

@ -119,7 +119,7 @@ public:
virtual void EarlyClip(bool earlyClip) { }
virtual bool YAxisUp() const { return false; }
virtual void YAxisUp(bool yup) { }
virtual void ThreadCount(unsigned int threads, const char* seedString = NULL) { }
virtual void ThreadCount(unsigned int threads, const char* seedString = nullptr) { }
virtual void Transparency(bool transparency) { }
virtual void InteractiveFilter(eInteractiveFilter filter) { }
virtual unsigned int FinalRasW() const { return 0; }
@ -141,7 +141,7 @@ public:
virtual EmberStats Stats() const { EmberStats stats; return stats; }
virtual eRenderStatus Run(vector<unsigned char>& finalImage, double time = 0, unsigned int subBatchCountOverride = 0, bool forceOutput = false, size_t finalOffset = 0) { return RENDER_ERROR; }
virtual EmberImageComments ImageComments(unsigned int printEditDepth = 0, bool intPalette = false, bool hexPalette = true) { EmberImageComments comments; return comments; }
virtual DensityFilterBase* GetDensityFilter() { return NULL; }
virtual DensityFilterBase* GetDensityFilter() { return nullptr; }
};
/// <summary>
@ -204,7 +204,7 @@ public:
virtual void NumChannels(unsigned int numChannels);
virtual eRendererType RendererType() const;
virtual unsigned int ThreadCount() const;
virtual void ThreadCount(unsigned int threads, const char* seedString = NULL);
virtual void ThreadCount(unsigned int threads, const char* seedString = nullptr);
virtual void Callback(RenderCallback* callback);
protected:
@ -341,7 +341,7 @@ protected:
private:
//Miscellaneous functions used only in this class.
void Accumulate(Point<T>* samples, unsigned int sampleCount, const Palette<bucketT>* palette);
inline void AddToAccum(const glm::detail::tvec4<bucketT, glm::defaultp>& bucket, int i, int ii, int j, int jj);
/*inline*/ void AddToAccum(const glm::detail::tvec4<bucketT, glm::defaultp>& bucket, int i, int ii, int j, int jj);
template <typename accumT> void GammaCorrection(glm::detail::tvec4<bucketT, glm::defaultp>& bucket, Color<T>& background, T g, T linRange, T vibrancy, bool doAlpha, bool scale, accumT* correctedChannels);
protected:
@ -395,14 +395,14 @@ protected:
CarToRas<T> m_CarToRas;
RenderCallback* m_Callback;
Iterator<T>* m_Iterator;
auto_ptr<StandardIterator<T>> m_StandardIterator;
auto_ptr<XaosIterator<T>> m_XaosIterator;
unique_ptr<StandardIterator<T>> m_StandardIterator;
unique_ptr<XaosIterator<T>> m_XaosIterator;
Palette<bucketT> m_Dmap;
vector<glm::detail::tvec4<bucketT, glm::defaultp>> m_HistBuckets;
vector<glm::detail::tvec4<bucketT, glm::defaultp>> m_AccumulatorBuckets;
auto_ptr<SpatialFilter<T>> m_SpatialFilter;
auto_ptr<TemporalFilter<T>> m_TemporalFilter;
auto_ptr<DensityFilter<T>> m_DensityFilter;
unique_ptr<SpatialFilter<T>> m_SpatialFilter;
unique_ptr<TemporalFilter<T>> m_TemporalFilter;
unique_ptr<DensityFilter<T>> m_DensityFilter;
vector<vector<Point<T>>> m_Samples;
vector<uint64_t> m_SubBatch;
vector<uint64_t> m_BadVals;

View File

@ -33,7 +33,7 @@ enum eCrossMode
{
CROSS_NOT_SPECIFIED = -1,
CROSS_UNION = 0,
CROSS_INTERPOLATE = 1,
CROSS_INTERPOLATE = 1,
CROSS_ALTERNATE = 2
};
@ -56,7 +56,7 @@ class EMBER_API SheepTools
public:
/// <summary>
/// Constructor which takes a palette path and pre-constructed renderer.
/// This class will take over ownership of the passed in renderer so the
/// This class will take over ownership of the passed in renderer so the
/// caller should not delete it.
/// </summary>
/// <param name="palettePath">The full path and filename of the palette file</param>
@ -73,9 +73,9 @@ public:
m_OffsetY = 0;
m_PaletteList.Init(palettePath);
m_StandardIterator = auto_ptr<StandardIterator<T>>(new StandardIterator<T>());
m_XaosIterator = auto_ptr<XaosIterator<T>>(new XaosIterator<T>());
m_Renderer = auto_ptr<Renderer<T, bucketT>>(renderer);
m_StandardIterator = unique_ptr<StandardIterator<T>>(new StandardIterator<T>());
m_XaosIterator = unique_ptr<XaosIterator<T>>(new XaosIterator<T>());
m_Renderer = unique_ptr<Renderer<T, bucketT>>(renderer);
m_Rand = QTIsaac<ISAAC_SIZE, ISAAC_INT>(ISAAC_INT(t.Tic()), ISAAC_INT(t.Tic() * 2), ISAAC_INT(t.Tic() * 3));
}
@ -98,7 +98,7 @@ public:
ember.AddXform(xform1);
ember.AddXform(xform2);
ember.AddXform(xform3);
if (m_PaletteList.Init())
ember.m_Palette = *m_PaletteList.GetPalette(-1);
@ -140,8 +140,8 @@ public:
do
{
Variation<T>* var = NULL;
Variation<T>* smallestVar = NULL;
Variation<T>* var = nullptr;
Variation<T>* smallestVar = nullptr;
numVars = 0;
smallest = -1;
@ -200,7 +200,7 @@ public:
if (mode == MUTATE_NOT_SPECIFIED)
{
randSelect = m_Rand.Frand01<T>();
if (randSelect < T(0.1))
mode = MUTATE_ALL_VARIATIONS;
else if (randSelect < T(0.3))
@ -216,7 +216,7 @@ public:
else
mode = MUTATE_ALL_COEFS;
}
if (mode == MUTATE_ALL_VARIATIONS)
{
os << "mutate all variations";
@ -238,7 +238,7 @@ public:
Variation<T>* var1 = xform1->GetVariation(j);
Variation<T>* var2 = xform2->GetVariationById(var1->VariationId());
if ((var1 == NULL) ^ (var2 == NULL))//If any of them are different, clear the first and copy all of the second and exit the while loop.
if ((var1 == nullptr) ^ (var2 == nullptr))//If any of them are different, clear the first and copy all of the second and exit the while loop.
{
xform1->ClearAndDeleteVariations();
@ -285,7 +285,7 @@ public:
{
unsigned int b = 1 + m_Rand.Rand() % 6;
unsigned int same = m_Rand.Rand() & 3;//25% chance of using the same post for all of them.
sprintf_s(ministr, 32, "(%d%s)", b, (same > 0) ? " same" : "");
os << "mutate post xforms " << ministr;
@ -295,7 +295,7 @@ public:
Xform<T>* xform = ember.GetTotalXform(i);
if (copy)//Copy the post from the first xform to the rest of them.
{
{
xform->m_Post = ember.GetTotalXform(0)->m_Post;
}
else
@ -304,40 +304,40 @@ public:
if (b & 1)
{
T f = T(M_PI) * m_Rand.Frand11<T>();
T a, b, d, e;
T ra, rb, rd, re;
a = (xform->m_Affine.A() * cos(f) + xform->m_Affine.B() * -sin(f));
d = (xform->m_Affine.A() * sin(f) + xform->m_Affine.D() * cos(f));
b = (xform->m_Affine.B() * cos(f) + xform->m_Affine.E() * -sin(f));
e = (xform->m_Affine.B() * sin(f) + xform->m_Affine.E() * cos(f));
ra = (xform->m_Affine.A() * cos(f) + xform->m_Affine.B() * -sin(f));
rd = (xform->m_Affine.A() * sin(f) + xform->m_Affine.D() * cos(f));
rb = (xform->m_Affine.B() * cos(f) + xform->m_Affine.E() * -sin(f));
re = (xform->m_Affine.B() * sin(f) + xform->m_Affine.E() * cos(f));
xform->m_Affine.A(a);
xform->m_Affine.B(b);
xform->m_Affine.D(d);
xform->m_Affine.E(e);
xform->m_Affine.A(ra);
xform->m_Affine.B(rb);
xform->m_Affine.D(rd);
xform->m_Affine.E(re);
f *= -1;
a = (xform->m_Post.A() * cos(f) + xform->m_Post.B() * -sin(f));
d = (xform->m_Post.A() * sin(f) + xform->m_Post.D() * cos(f));
b = (xform->m_Post.B() * cos(f) + xform->m_Post.E() * -sin(f));
e = (xform->m_Post.B() * sin(f) + xform->m_Post.E() * cos(f));
ra = (xform->m_Post.A() * cos(f) + xform->m_Post.B() * -sin(f));
rd = (xform->m_Post.A() * sin(f) + xform->m_Post.D() * cos(f));
rb = (xform->m_Post.B() * cos(f) + xform->m_Post.E() * -sin(f));
re = (xform->m_Post.B() * sin(f) + xform->m_Post.E() * cos(f));
xform->m_Post.A(a);
xform->m_Post.B(b);
xform->m_Post.D(d);
xform->m_Post.E(e);
xform->m_Post.A(ra);
xform->m_Post.B(rb);
xform->m_Post.D(rd);
xform->m_Post.E(re);
}
//33% chance.
if (b & 2)
{
{
T f = T(0.2) + m_Rand.Frand01<T>();
T g = T(0.2) + m_Rand.Frand01<T>();
if (m_Rand.RandBit())
f = 1 / f;
if (m_Rand.RandBit())
g = f;
else
@ -355,7 +355,7 @@ public:
}
if (b & 4)//16% chance.
{
{
T f = m_Rand.Frand11<T>();
T g = m_Rand.Frand11<T>();
@ -372,12 +372,12 @@ public:
T s = m_Rand.Frand01<T>();
if (s < T(0.4))//Randomize xform color coords.
{
{
ImproveColors(ember, 100, false, 10);
os << "mutate color coords";
}
else if (s < T(0.8))//Randomize xform color coords and palette.
{
{
ImproveColors(ember, 25, true, 10);
os << "mutate color all";
}
@ -412,7 +412,7 @@ public:
ember.DeleteTotalXform(nx);
}
else if (mode == MUTATE_ALL_COEFS)
{
{
os << "mutate all coefs";
Random(mutation, useVars, sym, ember.TotalXformCount());
@ -451,7 +451,7 @@ public:
if (crossMode == CROSS_NOT_SPECIFIED)
{
T s = m_Rand.Frand01<T>();
if (s < 0.1)
crossMode = CROSS_UNION;
else if (s < 0.2)
@ -494,29 +494,29 @@ public:
{
int got0, got1, usedParent;
string trystr;
//Each xform comes from a random parent, possible for an entire parent to be excluded.
do
{
got0 = got1 = 0;
rb = m_Rand.RandBit();
os << rb << ":";
//Copy the parent, sorting the final xform to the end if it's present.
emberOut = rb ? ember1 : ember0;
usedParent = rb;
//Only replace non-final xforms.
for (i = 0; i < emberOut.XformCount(); i++)
{
rb = m_Rand.RandBit();
//Replace xform if bit is 1.
if (rb == 1)
{
if (usedParent == 0)
{
if (i < ember1.XformCount() && ember1.GetXform(i)->m_Weight > 0)
if (i < ember1.XformCount() && ember1.GetXform(i)->m_Weight > 0)
{
Xform<T>* xform = emberOut.GetXform(i);
*xform = *ember1.GetXform(i);
@ -555,14 +555,14 @@ public:
got0 = 1;
}
}
if (usedParent == 0 && ember0.UseFinalXform())
got0 = 1;
else if (usedParent == 1 && ember1.UseFinalXform())
got1 = 1;
} while ((i > 1) && !(got0 && got1));
os << "cross alternate ";
os << trystr;
}
@ -574,15 +574,15 @@ public:
//emberOut.GetTotalXform(i)->m_ColorX = m_Rand.Frand01<T>();//Do rand which gives better coloring but produces different results every time it's run.
//emberOut.GetTotalXform(i)->m_ColorY = ?????;//Will need to update this if 2D coordinates are ever supported.
}
//Potentially genetically cross the two palettes together.
if (m_Rand.Frand01<T>() < T(0.4))
{
//Select the starting parent.
unsigned int ci, startParent = m_Rand.RandBit();
os << " cmap_cross " << startParent << ":";
//Loop over the entries, switching to the other parent 1% of the time.
for (ci = 0; ci < 256; ci++)//Will need to update this if 2D coordinates are ever supported.
{
@ -653,7 +653,7 @@ public:
{
ember.AddXforms(xformDistrib[m_Rand.Rand() % Vlen(xformDistrib)]);
addfinal = m_Rand.Frand01<T>() < T(0.15);//Add a final xform 15% of the time.
if (addfinal)
{
Xform<T> xform;
@ -661,14 +661,14 @@ public:
xform.m_Affine.A(T(1.1));//Just put something in there so it doesn't show up as being an empty final xform.
ember.SetFinalXform(xform);
}
}
}
//If first input variation is -1 random choose one to use or decide to use multiple.
if (useVars.empty() || useVars[0] == -1)
var = m_Rand.RandBit() ? m_Rand.Rand() % varCount : -1;
else
var = -2;
samed = m_Rand.RandBit();
multid = m_Rand.RandBit();
postid = m_Rand.Frand01<T>() < T(0.6);
@ -734,7 +734,7 @@ public:
n = 2;
while (m_Rand.RandBit() && (n < varCount))
n++;
//Randomly choose n variations, and change their weights.
//A var can be selected more than once, further reducing
//the probability that multiple vars are used.
@ -769,7 +769,7 @@ public:
if (m_Rand.RandBit())
n++;
//Randomly choose n variations, and change their weights.
//A var can be selected more than once, further reducing
//the probability that multiple vars are used.
@ -786,7 +786,7 @@ public:
xform->AddVariation(m_VariationList.GetVariationCopy(useVars[m_Rand.Rand() % useVars.size()], m_Rand.Frand<T>(T(0.001), 1)));
}
}
xform->NormalizeVariationWeights();//Normalize weights to 1.0 total.
}
@ -822,7 +822,7 @@ public:
cout << "Error in TryColors(), skipping ImproveColors()" << endl;
return;
}
for (i = 0; i < tries; i++)
{
ChangeColors(ember, changePalette);
@ -833,14 +833,14 @@ public:
cout << "Error in TryColors, aborting tries." << endl;
break;
}
if (b > best)
{
best = b;
bestEmber = ember;
}
}
ember = bestEmber;
}
@ -857,13 +857,13 @@ public:
unsigned int pixTotal, res3 = res * res * res;
T scalar;
Ember<T> adjustedEmber = ember;
adjustedEmber.m_Quality = 1;
adjustedEmber.m_Supersample = 1;
adjustedEmber.m_MaxRadDE = 0;
//Scale the image so that the total number of pixels is ~10,000.
pixTotal = ember.m_FinalRasW * ember.m_FinalRasH;
pixTotal = ember.m_FinalRasW * ember.m_FinalRasH;
scalar = sqrt(T(10000) / pixTotal);
adjustedEmber.m_FinalRasW = (unsigned int)(ember.m_FinalRasW * scalar);
adjustedEmber.m_FinalRasH = (unsigned int)(ember.m_FinalRasH * scalar);
@ -877,8 +877,8 @@ public:
m_Renderer->PixelAspectRatio(1);
m_Renderer->ThreadCount(Timing::ProcessorCount());
m_Renderer->SubBatchSize(10000);
m_Renderer->Callback(NULL);
m_Renderer->Callback(nullptr);
if (m_Renderer->Run(m_FinalImage) != RENDER_OK)
{
cout << "Error rendering test image for TryColors(). Aborting." << endl;
@ -919,7 +919,7 @@ public:
if (changePalette)
{
Palette<T>* palette;
Palette<T>* palette = nullptr;
ember.m_Hue = 0.0;
@ -942,16 +942,16 @@ public:
ember.GetTotalXform(i)->m_ColorX = m_Rand.Frand01<T>();
ember.GetTotalXform(i)->m_ColorY = m_Rand.Frand01<T>();
}
xform0 = RandomXform(ember, -1);
xform1 = RandomXform(ember, ember.GetXformIndex(xform0));
if (xform0 && (m_Rand.Rand() & 1))
{
xform0->m_ColorX = 0;
xform0->m_ColorY = 0;
}
if (xform1 && (m_Rand.Rand() & 1))
{
xform1->m_ColorX = 1;
@ -965,7 +965,7 @@ public:
/// </summary>
/// <param name="ember">The ember to get a random xform from</param>
/// <param name="excluded">Optionally exclude an xform. Pass -1 to include all for consideration.</param>
/// <returns>The random xform if successful, else NULL.</returns>
/// <returns>The random xform if successful, else nullptr.</returns>
Xform<T>* RandomXform(Ember<T>& ember, int excluded)
{
int ntries = 0;
@ -983,7 +983,7 @@ public:
}
}
return NULL;
return nullptr;
}
/// <summary>
@ -1007,7 +1007,7 @@ public:
if (!xform1->m_Motion.empty())
xform2->ApplyMotion(*xform1, blend);
xform2->DeleteMotionElements();
}
@ -1033,7 +1033,7 @@ public:
for (si = 0; si < 2; si++)
{
prealign[si] = embers[si];
for (i = 0; i < embers[si].TotalXformCount(); i++)
{
Xform<T>* xform = embers[si].GetTotalXform(i);
@ -1042,7 +1042,7 @@ public:
xform->ApplyMotion(*(prealign[si].GetTotalXform(i)), blend);//Apply motion parameters to result.xform[i] using blend parameter.
}
}
//Use the un-padded original for blend=0 when creating a sequence.
//This keeps the original interpolation type intact.
if (seqFlag && blend == 0)
@ -1053,17 +1053,17 @@ public:
{
//Align what's going to be interpolated.
Interpolater<T>::Align(prealign, spun, 2);
spun[0].m_Time = 0;
spun[1].m_Time = 1;
//Call this first to establish the asymmetric reference angles.
Interpolater<T>::AsymmetricRefAngles(spun, 2);
//Rotate the aligned xforms.
spun[0].RotateAffines(-blend * 360);
spun[1].RotateAffines(-blend * 360);
Interpolater<T>::Interpolate(spun, 2, m_Smooth ? Interpolater<T>::Smoother(blend) : blend, m_Stagger, result);
}
@ -1078,7 +1078,7 @@ public:
/// Apply subpixel jitter to center using offset members.
/// </summary>
/// <param name="parent">The ember to spin</param>
/// <param name="templ">The template to apply if not NULL, else ignore.</param>
/// <param name="templ">The template to apply if not nullptr, else ignore.</param>
/// <param name="result">The result of the spin</param>
/// <param name="frame">The frame in the sequence to be stored in the m_Time member of result</param>
/// <param name="blend">The interpolation time</param>
@ -1101,7 +1101,7 @@ public:
//Create the edit doc xml.
sprintf_s(temp, 50, "rotate %g", blend * 360.0);
result.ClearEdit();
result.m_Edits = m_EmberToXml.CreateNewEditdoc(&parent, NULL, temp, m_Nick, m_Url, m_Id, m_Comment, m_SheepGen, m_SheepId);
result.m_Edits = m_EmberToXml.CreateNewEditdoc(&parent, nullptr, temp, m_Nick, m_Url, m_Id, m_Comment, m_SheepGen, m_SheepId);
//Subpixel jitter.
Offset(result, m_OffsetX, m_OffsetY);
@ -1118,7 +1118,7 @@ public:
/// Apply subpixel jitter to center using offset members.
/// </summary>
/// <param name="parents">The embers to interpolate</param>
/// <param name="templ">The template to apply if not NULL, else ignore.</param>
/// <param name="templ">The template to apply if not nullptr, else ignore.</param>
/// <param name="result">The result of the spin</param>
/// <param name="frame">The frame in the sequence to be stored in the m_Time member of result</param>
/// <param name="seqFlag">True if embers points to the first or last ember in the entire sequence, else false.</param>
@ -1131,7 +1131,7 @@ public:
Edge(parents, result, blend, seqFlag);
//Original did an interpolated palette hack here for random palettes, but it was never used anywhere so ember omits it.//ORIG
//Apply the template if necessary.
if (templ)
ApplyTemplate(result, *templ);
@ -1166,68 +1166,68 @@ public:
if (templ.m_Zoom < 999999998)
ember.m_Zoom = templ.m_Zoom;
if (templ.m_Supersample > 0)
ember.m_Supersample = templ.m_Supersample;
if (templ.m_SpatialFilterRadius >= 0)
ember.m_SpatialFilterRadius = templ.m_SpatialFilterRadius;
if (templ.m_Quality > 0)
ember.m_Quality = templ.m_Quality;
if (templ.m_Passes > 0)
ember.m_Passes = templ.m_Passes;
if (templ.m_TemporalSamples > 0)
ember.m_TemporalSamples = templ.m_TemporalSamples;
if (templ.m_FinalRasW > 0)
{
//Preserving scale should be an option.
ember.m_PixelsPerUnit = ember.m_PixelsPerUnit * templ.m_FinalRasW / ember.m_FinalRasW;
ember.m_FinalRasW = templ.m_FinalRasW;
}
if (templ.m_FinalRasH > 0)
ember.m_FinalRasH = templ.m_FinalRasH;
if (templ.m_MaxRadDE >= 0)
ember.m_MaxRadDE = templ.m_MaxRadDE;
if (templ.m_MinRadDE >= 0)
ember.m_MinRadDE = templ.m_MinRadDE;
if (templ.m_CurveDE >= 0)
ember.m_CurveDE = templ.m_CurveDE;
if (templ.m_GammaThresh >= 0)
ember.m_GammaThresh = templ.m_GammaThresh;
if (templ.m_Passes > 0)
ember.m_Passes = templ.m_Passes;
if (templ.m_SpatialFilterType > 0)
ember.m_SpatialFilterType = templ.m_SpatialFilterType;
if (templ.m_Interp >= 0)
ember.m_Interp = templ.m_Interp;
if (templ.m_AffineInterp >= 0)
ember.m_AffineInterp = templ.m_AffineInterp;
if (templ.m_TemporalFilterType >= 0)
ember.m_TemporalFilterType = templ.m_TemporalFilterType;
if (templ.m_TemporalFilterWidth > 0)
ember.m_TemporalFilterWidth = templ.m_TemporalFilterWidth;
if (templ.m_TemporalFilterExp > -900)
ember.m_TemporalFilterExp = templ.m_TemporalFilterExp;
if (templ.m_HighlightPower >= 0)
ember.m_HighlightPower = templ.m_HighlightPower;
if (templ.m_PaletteMode >= 0)
ember.m_PaletteMode = templ.m_PaletteMode;
}
@ -1261,7 +1261,7 @@ public:
T th = by * 2 * T(M_PI) / 360;
T c = cos(th);
T s = -sin(th);
newCenterX -= oldCenterX;
newCenterY -= oldCenterY;
r[0] = c * newCenterX - s * newCenterY;
@ -1269,7 +1269,7 @@ public:
newCenterX = r[0] + oldCenterX;
newCenterY = r[1] + oldCenterY;
}
/// <summary>
/// Find a 2D bounding box that does not enclose eps of the fractal density in each compass direction.
/// This will run the inner loops of iteration without all of the surrounding interpolation and filtering.
@ -1297,7 +1297,7 @@ public:
if (bv / T(samples) > eps)
eps = 3 * bv / T(samples);
if (eps > T(0.3))
eps = T(0.3);
@ -1384,11 +1384,11 @@ private:
vector<unsigned int> m_Hist;
EmberToXml<T> m_EmberToXml;
Iterator<T>* m_Iterator;
auto_ptr<StandardIterator<T>> m_StandardIterator;
auto_ptr<XaosIterator<T>> m_XaosIterator;
auto_ptr<Renderer<T, bucketT>> m_Renderer;
unique_ptr<StandardIterator<T>> m_StandardIterator;
unique_ptr<XaosIterator<T>> m_XaosIterator;
unique_ptr<Renderer<T, bucketT>> m_Renderer;
QTIsaac<ISAAC_SIZE, ISAAC_INT> m_Rand;
PaletteList<T> m_PaletteList;
VariationList<T> m_VariationList;
};
}
}

View File

@ -89,7 +89,7 @@ public:
{
m_FinalFilterWidth = filter.m_FinalFilterWidth;
m_Supersample = filter.m_Supersample;
m_Support = filter.m_Support;
m_Support = filter.m_Support;
m_FilterRadius = filter.m_FilterRadius;
m_PixelAspectRatio = filter.m_PixelAspectRatio;
m_FilterType = filter.m_FilterType;
@ -107,7 +107,7 @@ public:
{
T fw = T(2.0) * m_Support * m_Supersample * m_FilterRadius / m_PixelAspectRatio;
T adjust, ii, jj;
int fwidth = ((int)fw) + 1;
int i, j;
@ -283,7 +283,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
HermiteFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(HERMITE_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Hermite filter to t parameter and return.
/// f(t) = 2|t|^3 - 3|t|^2 + 1, -1 <= t <= 1.
@ -318,7 +318,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BoxFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(BOX_SPATIAL_FILTER, T(0.5), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Box filter to t parameter and return.
/// </summary>
@ -349,7 +349,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
TriangleFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(TRIANGLE_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Triangle filter to t parameter and return.
/// </summary>
@ -383,7 +383,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BellFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(BELL_SPATIAL_FILTER, T(1.5), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Bell filter to t parameter and return.
/// </summary>
@ -392,7 +392,7 @@ public:
virtual T Filter(T t) const
{
//box (*) box (*) box.
if (t < 0)
if (t < 0)
t = -t;
if (t < T(0.5))
@ -424,7 +424,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BsplineFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(BSPLINE_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply B Spline filter to t parameter and return.
/// </summary>
@ -467,9 +467,9 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
Lanczos3Filter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
Lanczos3Filter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(LANCZOS3_SPATIAL_FILTER, T(3.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Lanczos 3 filter to t parameter and return.
/// </summary>
@ -503,7 +503,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
Lanczos2Filter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(LANCZOS2_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Lanczos 2 filter to t parameter and return.
/// </summary>
@ -537,7 +537,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
MitchellFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(MITCHELL_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Mitchell filter to t parameter and return.
/// </summary>
@ -590,7 +590,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BlackmanFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(BLACKMAN_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Blackman filter to t parameter and return.
/// </summary>
@ -618,7 +618,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
CatromFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(CATROM_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Catmull-Rom filter to t parameter and return.
/// </summary>
@ -661,7 +661,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
HammingFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(HAMMING_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Hamming filter to t parameter and return.
/// </summary>
@ -689,7 +689,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
HanningFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(HANNING_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Hanning filter to t parameter and return.
/// </summary>
@ -717,7 +717,7 @@ public:
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
QuadraticFilter(T filterRadius, unsigned int superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(QUADRATIC_SPATIAL_FILTER, T(1.5), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Quadratic filter to t parameter and return.
/// </summary>
@ -758,7 +758,7 @@ public:
/// <returns>A pointer to the newly created filter object</returns>
static SpatialFilter<T>* Create(eSpatialFilterType filterType, T filterRadius, unsigned int superSample, T pixelAspectRatio = 1)
{
SpatialFilter<T>* filter = NULL;
SpatialFilter<T>* filter = nullptr;
if (filterType == GAUSSIAN_SPATIAL_FILTER)
filter = new GaussianFilter<T>(filterRadius, superSample, pixelAspectRatio);
@ -906,4 +906,4 @@ public:
return filter;
}
};
}
}

View File

@ -72,7 +72,7 @@ public:
m_Deltas[i] = (T(i) / T(steps - 1) - T(0.5)) * filterWidth;
}
}
/// <summary>
/// Copy constructor.
/// </summary>
@ -141,7 +141,7 @@ public:
return ss.str();
}
/// <summary>
/// Accessors.
/// </summary>
@ -169,7 +169,7 @@ protected:
m_Filter[i] /= maxFilt;
m_SumFilt += m_Filter[i];
}
m_SumFilt /= Size();
}
@ -214,7 +214,7 @@ public:
//Scale the color based on these values.
m_Filter[i] = pow(slpx, fabs(filterExp));
//Keep the max.
if (m_Filter[i] > maxFilt)
maxFilt = m_Filter[i];
@ -251,7 +251,7 @@ public:
for (unsigned int i = 0; i < Size(); i++)
{
m_Filter[i] = gaussian.Filter(gaussian.Support() * fabs(i - halfSteps) / halfSteps);
//Keep the max.
if (m_Filter[i] > maxFilt)
maxFilt = m_Filter[i];
@ -283,7 +283,7 @@ public:
{
for (unsigned int i = 0; i < Size(); i++)
m_Filter[i] = 1;
FinishFilter(1);
}
}
@ -307,7 +307,7 @@ public:
/// <returns>A pointer to the newly created filter object</returns>
static TemporalFilter<T>* Create(eTemporalFilterType filterType, unsigned int passes, unsigned int temporalSamples, T filterWidth, T filterExp = 1)
{
TemporalFilter<T>* filter = NULL;
TemporalFilter<T>* filter = nullptr;
if (filterType == BOX_TEMPORAL_FILTER)
filter = new BoxTemporalFilter<T>(passes, temporalSamples, filterWidth);
@ -375,4 +375,4 @@ public:
return filter;
}
};
}
}

View File

@ -42,15 +42,15 @@ public:
/// <summary>
/// Set the end time and optionally output a string showing the elapsed time.
/// </summary>
/// <param name="str">The string to output. Default: NULL.</param>
/// <param name="str">The string to output. Default: nullptr.</param>
/// <param name="fullString">If true, output the string verbatim, else output the text " processing time: " in between str and the formatted time.</param>
/// <returns>The elapsed time in milliseconds as a double</returns>
double Toc(const char* str = NULL, bool fullString = false)
double Toc(const char* str = nullptr, bool fullString = false)
{
m_EndTime = Clock::now();
double ms = ElapsedTime();
if (str != NULL)
if (str != nullptr)
{
cout << string(str) << (fullString ? "" : " processing time: ") << Format(ms) << endl;
}

View File

@ -40,6 +40,14 @@ static inline void ForEach(c& container, fn func)
class EMBER_API EmberImageComments
{
public:
/// <summary>
/// Empty destructor.
/// Needed to eliminate warnings about inlining.
/// </summary>
~EmberImageComments()
{
}
/// <summary>
/// Set all values to the empty string.
/// </summary>
@ -68,6 +76,11 @@ public:
class EMBER_API EmberReport
{
public:
/// <summary>
/// Virtual destructor needed for virtual classes.
/// </summary>
virtual ~EmberReport() { }
/// <summary>
/// Write the entire error report as a single string to the console.
/// Derived classes with members that also derive from EmberReport should override this to capture
@ -144,13 +157,13 @@ protected:
static bool ReadFile(const char* filename, string& buf, bool nullTerminate = true)
{
bool b = false;
FILE* f;
FILE* f = nullptr;
try
{
fopen_s(&f, filename, "rb");//Open in binary mode.
if (f != NULL)
if (f != nullptr)
{
struct _stat statBuf;
@ -162,15 +175,15 @@ static bool ReadFile(const char* filename, string& buf, bool nullTerminate = tru
if (statResult == 0)//Check if statistics are valid.
{
buf.resize(statBuf.st_size + (nullTerminate ? 1 : 0));//Allocate vector to be the size of the entire file, with an optional additional character for NULL.
buf.resize(statBuf.st_size + (nullTerminate ? 1 : 0));//Allocate vector to be the size of the entire file, with an optional additional character for nullptr.
if (buf.size() == statBuf.st_size + 1)//Ensure allocation succeeded.
if (buf.size() == (size_t)(statBuf.st_size + 1))//Ensure allocation succeeded.
{
size_t bytesRead = fread(&buf[0], 1, statBuf.st_size, f);//Read the entire file at once.
if (bytesRead == statBuf.st_size)//Ensure the number of bytes read matched what was requested.
if (bytesRead == (size_t)statBuf.st_size)//Ensure the number of bytes read matched what was requested.
{
if (nullTerminate)//Optionally NULL terminate if they want to treat it as a string.
if (nullTerminate)//Optionally nullptr terminate if they want to treat it as a string.
buf[buf.size() - 1] = 0;
b = true;//Success.
@ -183,7 +196,7 @@ static bool ReadFile(const char* filename, string& buf, bool nullTerminate = tru
}
catch (...)
{
if (f != NULL)
if (f != nullptr)
fclose(f);
b = false;
@ -209,7 +222,7 @@ static void CopyVec(vector<T>& dest, const vector<U>& source)
}
/// <summary>
/// Clear a vector of pointers to any type by checking each element for NULL and calling delete on it, then clearing the entire vector.
/// Clear a vector of pointers to any type by checking each element for nullptr and calling delete on it, then clearing the entire vector.
/// Optionally call array delete if the elements themselves are pointers to dynamically allocated arrays.
/// </summary>
/// <param name="vec">The vector to be cleared</param>
@ -219,7 +232,7 @@ static void ClearVec(vector<T*>& vec, bool arrayDelete = false)
{
for (unsigned int i = 0; i < vec.size(); i++)
{
if (vec[i] != NULL)
if (vec[i] != nullptr)
{
if (arrayDelete)
delete [] vec[i];
@ -227,31 +240,12 @@ static void ClearVec(vector<T*>& vec, bool arrayDelete = false)
delete vec[i];
}
vec[i] = NULL;
vec[i] = nullptr;
}
vec.clear();
}
/// <summary>
/// Convert an RGBA buffer to an RGB buffer.
/// </summary>
/// <param name="rgba">The RGBA buffer</param>
/// <param name="rgb">The RGB buffer</param>
/// <param name="width">The width of the image in pixels</param>
/// <param name="height">The height of the image in pixels</param>
static void RgbaToRgb(vector<unsigned char>& rgba, vector<unsigned char>& rgb, unsigned int width, unsigned int height)
{
rgb.resize(width * height * 3);
for (unsigned int i = 0, j = 0; i < (width * height * 4); i += 4, j += 3)
{
rgb[j] = rgba[i];
rgb[j + 1] = rgba[i + 1];
rgb[j + 2] = rgba[i + 2];
}
}
/// <summary>
/// System floor() extremely slow because it accounts for various error conditions.
/// This is a much faster version that works on data that is not NaN.
@ -737,7 +731,7 @@ static inline T NormalizeDeg360(T angle)
/// </summary>
/// <param name="str">The string to copy and make lower case</param>
/// <returns>The lower case string</returns>
static inline string ToLower(const string& str)
static string ToLower(const string& str)
{
string lower;
@ -751,7 +745,7 @@ static inline string ToLower(const string& str)
/// </summary>
/// <param name="str">The string to copy and make upper case</param>
/// <returns>The upper case string</returns>
static inline string ToUpper(const string& str)
static string ToUpper(const string& str)
{
string upper;
@ -767,7 +761,7 @@ static inline string ToUpper(const string& str)
/// <param name="str">The string to trim</param>
/// <param name="ch">The character to trim. Default: space.</param>
/// <returns>The trimmed string</returns>
static inline string Trim(string& str, char ch = ' ')
static string Trim(string& str, char ch = ' ')
{
string ret;
@ -817,8 +811,8 @@ int Arg<int>(char* name, int def)
{
char* ch;
int returnVal;
size_t len;
#ifdef WIN32
size_t len;
errno_t err = _dupenv_s(&ch, &len, name);
#else
int err = 1;
@ -880,8 +874,8 @@ double Arg<double>(char* name, double def)
{
char* ch;
double returnVal;
size_t len;
#ifdef WIN32
size_t len;
errno_t err = _dupenv_s(&ch, &len, name);
#else
int err = 1;
@ -913,8 +907,8 @@ string Arg<string>(char* name, string def)
{
char* ch;
string returnVal;
size_t len;
#ifdef WIN32
size_t len;
errno_t err = _dupenv_s(&ch, &len, name);
#else
int err = 1;

View File

@ -1009,7 +1009,7 @@ public:
bool needPrecalcAtanYX = false)
: m_Name(name)//Omit unnecessary default constructor call.
{
m_Xform = NULL;
m_Xform = nullptr;
m_VariationId = id;
m_Weight = weight;
m_NeedPrecalcSumSquares = needPrecalcSumSquares;
@ -1085,7 +1085,7 @@ public:
m_AssignType = variation.AssignType();
m_VariationId = variation.VariationId();
m_Weight = T(variation.m_Weight);
m_Xform = typeid(T) == typeid(U) ? (Xform<T>*)variation.ParentXform() : NULL;
m_Xform = typeid(T) == typeid(U) ? (Xform<T>*)variation.ParentXform() : nullptr;
m_NeedPrecalcSumSquares = variation.NeedPrecalcSumSquares();
m_NeedPrecalcSqrtSumSquares = variation.NeedPrecalcSqrtSumSquares();
m_NeedPrecalcAngles = variation.NeedPrecalcAngles();
@ -1403,7 +1403,7 @@ public:
/// </summary>
ParamWithName()
{
Init(NULL, "", 0, REAL, TLOW, TMAX);
Init(nullptr, "", 0, REAL, TLOW, TMAX);
}
/// <summary>
@ -1541,6 +1541,7 @@ public:
}
case INTEGER_NONZERO :
default:
{
int vi = (int)max(min<T>((T)Floor<T>(val + T(0.5)), m_Max), m_Min);
@ -1660,6 +1661,14 @@ public:
m_Params.reserve(5);
}
/// <summary>
/// Empty virtual destructor.
/// Needed to eliminate warnings about inlining.
/// </summary>
virtual ~ParametricVariation()
{
}
/// <summary>
/// Determine whether the params vector contains a parameter with the specified name.
/// </summary>
@ -1689,7 +1698,7 @@ public:
if (!_stricmp(m_Params[i].Name().c_str(), name))
return m_Params[i].Param();
return NULL;
return nullptr;
}
/// <summary>
@ -1857,13 +1866,11 @@ protected:
using Variation<T>::XformIndexInEmber; \
using Variation<T>::Prefix;
//using Variation<T>::Precalc; \
#ifdef DO_DOUBLE
#define VARCOPYDOUBLE(name) \
virtual void Copy(Variation<double>*& var) const override \
{ \
if (var != NULL) \
if (var != nullptr) \
delete var; \
\
var = new name<double>(*this); \
@ -1894,7 +1901,7 @@ protected:
\
virtual void Copy(Variation<float>*& var) const override \
{ \
if (var != NULL) \
if (var != nullptr) \
delete var; \
\
var = new name<float>(*this); \
@ -1921,7 +1928,7 @@ protected:
\
virtual void Copy(Variation<float>*& var) const override \
{ \
if (var != NULL) \
if (var != nullptr) \
delete var; \
\
var = new name<float>(*this); \
@ -1981,8 +1988,6 @@ protected:
using ParametricVariation<T>::m_Params; \
using ParametricVariation<T>::CopyParamVals;
//using Variation<T>::Precalc; \
#define PARVARCOPY(name) \
VARUSINGS \
PARVARUSINGS \
@ -2009,7 +2014,7 @@ protected:
\
virtual void Copy(Variation<float>*& var) const override \
{ \
if (var != NULL) \
if (var != nullptr) \
delete var; \
\
var = new name<float>(*this); \
@ -2040,7 +2045,7 @@ protected:
\
virtual void Copy(Variation<float>*& var) const override \
{ \
if (var != NULL) \
if (var != nullptr) \
delete var; \
\
var = new name<float>(*this); \

View File

@ -374,25 +374,25 @@ public:
/// Get a pointer to the variation at the specified index.
/// </summary>
/// <param name="index">The index in the list to retrieve</param>
/// <returns>A pointer to the variation at the index if in range, else NULL.</returns>
Variation<T>* GetVariation(size_t index) { return index < m_Variations.size() ? m_Variations[index] : NULL; }
/// <returns>A pointer to the variation at the index if in range, else nullptr.</returns>
Variation<T>* GetVariation(size_t index) { return index < m_Variations.size() ? m_Variations[index] : nullptr; }
/// <summary>
/// Get a pointer to the variation of a specified type at the specified index.
/// </summary>
/// <param name="index">The index in the list to retrieve</param>
/// <param name="varType">The type of variation to retrieve</param>
/// <returns>A pointer to the variation of the specified type at the index if in range, else NULL.</returns>
/// <returns>A pointer to the variation of the specified type at the index if in range, else nullptr.</returns>
Variation<T>* GetVariation(size_t index, eVariationType varType)
{
if (varType == VARTYPE_REG)
return index < m_RegVariations.size() ? m_RegVariations[index] : NULL;
return index < m_RegVariations.size() ? m_RegVariations[index] : nullptr;
else if (varType == VARTYPE_PRE)
return index < m_PreVariations.size() ? m_PreVariations[index] : NULL;
return index < m_PreVariations.size() ? m_PreVariations[index] : nullptr;
else if (varType == VARTYPE_POST)
return index < m_PostVariations.size() ? m_PostVariations[index] : NULL;
return index < m_PostVariations.size() ? m_PostVariations[index] : nullptr;
else
return NULL;
return nullptr;
}
/// <summary>
@ -401,7 +401,7 @@ public:
/// </summary>
/// <param name="index">The index in the list to make a copy of</param>
/// <param name="weight">The weight to assign the new copy. Default: 1</param>
/// <returns>A pointer to the variation at the index if in range, else NULL.</returns>
/// <returns>A pointer to the variation at the index if in range, else nullptr.</returns>
Variation<T>* GetVariationCopy(size_t index, T weight = 1) { return MakeCopyWithWeight(GetVariation(index), weight); }
Variation<T>* GetVariationCopy(size_t index, eVariationType varType, T weight = 1) { return MakeCopyWithWeight(GetVariation(index, varType), weight); }
@ -409,14 +409,14 @@ public:
/// Get a pointer to the variation with the specified ID.
/// </summary>
/// <param name="id">The ID to search for</param>
/// <returns>A pointer to the variation if found, else NULL.</returns>
/// <returns>A pointer to the variation if found, else nullptr.</returns>
Variation<T>* GetVariation(eVariationId id)
{
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != NULL; i++)
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
if (id == m_Variations[i]->VariationId())
return m_Variations[i];
return NULL;
return nullptr;
}
/// <summary>
@ -425,21 +425,21 @@ public:
/// </summary>
/// <param name="id">The id of the variation in the list to make a copy of</param>
/// <param name="weight">The weight to assign the new copy. Default: 1</param>
/// <returns>A pointer to the variation with a matching ID, else NULL.</returns>
/// <returns>A pointer to the variation with a matching ID, else nullptr.</returns>
Variation<T>* GetVariationCopy(eVariationId id, T weight = 1) { return MakeCopyWithWeight(GetVariation(id), weight); }
/// <summary>
/// Get a pointer to the variation with the specified name.
/// </summary>
/// <param name="name">The name to search for</param>
/// <returns>A pointer to the variation if found, else NULL.</returns>
Variation<T>* GetVariation(string name)
/// <returns>A pointer to the variation if found, else nullptr.</returns>
Variation<T>* GetVariation(string& name)
{
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != NULL; i++)
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
return m_Variations[i];
return NULL;
return nullptr;
}
/// <summary>
@ -448,7 +448,7 @@ public:
/// </summary>
/// <param name="name">The name of the variation in the list to make a copy of</param>
/// <param name="weight">The weight to assign the new copy. Default: 1</param>
/// <returns>A pointer to the variation with a matching name, else NULL.</returns>
/// <returns>A pointer to the variation with a matching name, else nullptr.</returns>
Variation<T>* GetVariationCopy(string name, T weight = 1) { return MakeCopyWithWeight(GetVariation(name), weight); }
/// <summary>
@ -456,21 +456,21 @@ public:
/// Note this is the index in the parametric variations list, not in the master list.
/// </summary>
/// <param name="index">The index in the parametric variations list to retrieve</param>
/// <returns>The parametric variation at the index specified if in range, else NULL.</returns>
ParametricVariation<T>* GetParametricVariation(size_t index) { return index < m_ParametricVariations.size() ? m_ParametricVariations[index] : NULL; }
/// <returns>The parametric variation at the index specified if in range, else nullptr.</returns>
ParametricVariation<T>* GetParametricVariation(size_t index) { return index < m_ParametricVariations.size() ? m_ParametricVariations[index] : nullptr; }
/// <summary>
/// Get a parametric variation with the specified name.
/// </summary>
/// <param name="name">The name of the variation in the parametric variations list to retrieve</param>
/// <returns>The parametric variation with a matching name, else NULL.</returns>
/// <returns>The parametric variation with a matching name, else nullptr.</returns>
ParametricVariation<T>* GetParametricVariation(string name)
{
for (unsigned int i = 0; i < m_ParametricVariations.size() && m_ParametricVariations[i] != NULL; i++)
for (unsigned int i = 0; i < m_ParametricVariations.size() && m_ParametricVariations[i] != nullptr; i++)
if (!_stricmp(name.c_str(), m_ParametricVariations[i]->Name().c_str()))
return m_ParametricVariations[i];
return NULL;
return nullptr;
}
/// <summary>
@ -480,10 +480,10 @@ public:
/// <returns>The index of the variation with the matching name, else -1</returns>
int GetVariationIndex(string name)
{
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != NULL; i++)
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
return i;
return -1;
}
@ -503,7 +503,7 @@ private:
/// </summary>
/// <param name="var">The variation to copy</param>
/// <param name="weight">The weight to assign it</param>
/// <returns>A pointer to the new variation copy if success, else NULL.</returns>
/// <returns>A pointer to the new variation copy if success, else nullptr.</returns>
Variation<T>* MakeCopyWithWeight(Variation<T>* var, T weight)
{
if (var)
@ -514,7 +514,7 @@ private:
return var2;
}
return NULL;
return nullptr;
}
/// <summary>
@ -534,4 +534,4 @@ private:
vector<Variation<T>*> m_PostVariations;
vector<ParametricVariation<T>*> m_ParametricVariations;//A list of pointers to elements in m_Variations which are derived from ParametricVariation.
};
}
}

View File

@ -727,7 +727,7 @@ public:
virtual void Precalc() override
{
if (m_Xform)//If this variation exists by itself and hasn't been added to an xform yet, m_Xform will be NULL.
if (m_Xform)//If this variation exists by itself and hasn't been added to an xform yet, m_Xform will be nullptr.
{
T dx = m_Xform->m_Affine.C();
T dy = m_Xform->m_Affine.F();
@ -4674,7 +4674,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index;

View File

@ -347,7 +347,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int varIndex = IndexInXform();
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
@ -1925,7 +1925,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string repeat = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -4435,7 +4435,6 @@ public:
{
T c0 = helper.In.x * m_Vpi;
T c1 = helper.In.y * m_Vpi;
T c2 = helper.In.z * m_Vpi;
T sinc0, cosc0, sinc1, cosc1;
sincos(c0, &sinc0, &cosc0);
@ -4449,7 +4448,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string zscale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -4458,7 +4457,6 @@ public:
ss << "\t{\n"
<< "\t\treal_t c0 = vIn.x * " << vpi << ";\n"
<< "\t\treal_t c1 = vIn.y * " << vpi << ";\n"
<< "\t\treal_t c2 = vIn.z * " << vpi << ";\n"
<< "\n"
<< "\t\treal_t sinc0 = sin(c0);\n"
<< "\t\treal_t cosc0 = cos(c0);\n"

View File

@ -1964,7 +1964,6 @@ public:
{
T sinX = sin(helper.In.x);
T cosX = cos(helper.In.x);
T sinY = sin(helper.In.y);
T cosY = cos(helper.In.y);
T bx = Cube(cosX*cosY);
T by = Cube(sinX*cosY);

View File

@ -698,7 +698,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string rxSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
@ -783,7 +783,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string rySin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
@ -865,7 +865,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string rzSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
@ -1549,6 +1549,7 @@ public:
r = (rand.Rand((ISAAC_INT)m_Slices) + m_YThickness + rand.Frand01<T>() * (1 - m_YThickness)) / m_Slices;
break;
case 4:
default:
a = (rand.Rand((ISAAC_INT)m_Slices) + m_XThickness + rand.Frand01<T>() * (1 - m_XThickness)) / m_Slices;
r = rand.Frand01<T>();
break;
@ -1562,7 +1563,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -2830,7 +2831,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string thetaPeriod = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -3209,7 +3210,7 @@ public:
T c = cos(absV);
T sh = sinh(helper.In.x);
T ch = cosh(helper.In.x);
T d = m_Weight * c * sh / absV;
T d = m_Weight * ch * s / absV;
helper.Out.x = m_Weight * sh * c;
helper.Out.y = d * helper.In.y;
@ -3227,7 +3228,7 @@ public:
<< "\t\treal_t c = cos(absV);\n"
<< "\t\treal_t sh = sinh(vIn.x);\n"
<< "\t\treal_t ch = cosh(vIn.x);\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] * c * sh / absV;\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] * ch * s / absV;\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sh * c;\n"
<< "\t\tvOut.y = d * vIn.y;\n"
@ -4238,7 +4239,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string extended = "parVars[" + ToUpper(m_Params[i++].Name()) + index;

View File

@ -658,6 +658,7 @@ public:
helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) - lattd;
break;
case 7 :
default:
helper.Out.x = ((px - (m_Smooth * (1 - m_Fill) * px * exnze)) + (helper.In.x * m_Smooth * m_Fill * exnze)) - lattd;
helper.Out.y = ((py - (m_Smooth * (1 - m_Fill) * py * wynze)) + (helper.In.y * m_Smooth * m_Fill * wynze)) - lattd;
helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) - lattd;
@ -888,6 +889,7 @@ public:
helper.Out.z = pztz * m_Fill * znxy - lattd;
break;
case 7 :
default:
helper.Out.x = pxtx * m_Fill * exnze - lattd;
helper.Out.y = pyty * m_Fill * wynze - lattd;
helper.Out.z = pztz * m_Fill * znxy - lattd;
@ -1078,7 +1080,6 @@ public:
T ww = SQR(helper.In.z);
T atOmegaX = atan2(vv, ww);
T atOmegaY = atan2(uu, ww);
T atOmegaZ = atan2(vv, uu);
T su = sin(helper.In.x);
T cu = cos(helper.In.x);
T sv = sin(helper.In.y);
@ -1110,7 +1111,6 @@ public:
<< "\t\treal_t ww = SQR(vIn.z);\n"
<< "\t\treal_t atOmegaX = atan2(vv, ww);\n"
<< "\t\treal_t atOmegaY = atan2(uu, ww);\n"
<< "\t\treal_t atOmegaZ = atan2(vv, uu);\n"
<< "\t\treal_t su = sin(vIn.x);\n"
<< "\t\treal_t cu = cos(vIn.x);\n"
<< "\t\treal_t sv = sin(vIn.y);\n"
@ -1334,7 +1334,6 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T rmod = rand.Frand01<T>() * T(0.5) + T(0.125);
T kikr = helper.m_PrecalcAtanyx;
T efTez = helper.In.z == 0 ? kikr : helper.In.z;
T r2 = helper.m_PrecalcSumSquares + SQR(efTez);
@ -1364,7 +1363,6 @@ public:
string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t rmod = MwcNext01(mwc) * 0.5 + 0.125;\n"
<< "\t\treal_t kikr = precalcAtanyx;\n"
<< "\t\treal_t efTez = vIn.z == 0 ? kikr : vIn.z;\n"
<< "\t\treal_t r2 = precalcSumSquares + SQR(efTez);\n"
@ -1644,7 +1642,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -1780,7 +1778,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -2149,6 +2147,7 @@ public:
helper.Out.z = m_Weight * (rad * sigmas);
break;
case 2://Box.
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 * pow(ax, m_BoxPow) * rs * denom;//m_BoxPow should be an integer value held in T,
@ -2318,6 +2317,7 @@ public:
}
break;
case 2://Gaussian.
default:
{
const T sigma = dist * random.y * M_2PI;
const T phi = dist * random.z * T(M_PI);
@ -2339,7 +2339,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string scatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -2483,6 +2483,7 @@ public:
radius = sqrt(Sqr(helper.In.x - m_CenterX) + Sqr(helper.In.y - m_CenterY) + Sqr(helper.In.z - m_CenterZ));
break;
case 1://Square.
default:
radius = max(fabs(helper.In.x - m_CenterX), max(fabs(helper.In.y - m_CenterY), (fabs(helper.In.z - m_CenterZ))));//Original called a macro named min, which internally performed max.
break;
}
@ -2532,6 +2533,7 @@ public:
}
break;
case 2://Log.
default:
{
const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (LogMap(dist) - dist);
@ -2547,7 +2549,7 @@ public:
virtual string OpenCLString() override
{
ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
int i = 0;
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
string blurType = "parVars[" + ToUpper(m_Params[i++].Name()) + index;

View File

@ -211,6 +211,7 @@ public:
break;
case 2:
default:
x = m_Weight * p;
y = m_Weight * q;
z = m_Weight * (j ? -1 : 1);

View File

@ -68,7 +68,7 @@ public:
T pe = 1,
T pc = 0,
T pf = 0)
{
Init();
@ -101,7 +101,7 @@ public:
/// </summary>
/// <param name="xform">The Xform object to copy</param>
Xform(const Xform<T>& xform)
: m_ParentEmber(NULL)//Hack.
: m_ParentEmber(nullptr)//Hack.
{
Xform<T>::operator=<T>(xform);
}
@ -112,7 +112,7 @@ public:
/// <param name="xform">The Xform object to copy</param>
template <typename U>
Xform(const Xform<U>& xform)
: m_ParentEmber(NULL)//Hack.
: m_ParentEmber(nullptr)//Hack.
{
Xform<T>::operator=<U>(xform);
}
@ -171,8 +171,8 @@ public:
//the variation's m_IndexInXform member gets properly set to this.
for (unsigned int i = 0; i < xform.TotalVariationCount(); i++)
{
Variation<T>* var = NULL;
Variation<T>* var = nullptr;
if (Variation<U>* varOrig = xform.GetVariation(i))
{
varOrig->Copy(var);//Will convert from type U to type T.
@ -236,7 +236,7 @@ public:
m_NeedPrecalcAtanYX = false;
m_HasPost = false;
m_HasPreOrRegularVars = false;
m_ParentEmber = NULL;
m_ParentEmber = nullptr;
m_PreVariations.reserve(MAX_VARS_PER_XFORM);
m_Variations.reserve(MAX_VARS_PER_XFORM);
m_PostVariations.reserve(MAX_VARS_PER_XFORM);
@ -254,7 +254,7 @@ public:
/// <returns>True if the successful, else false.</returns>
bool AddVariation(Variation<T>* variation)
{
if (variation && (GetVariationById(variation->VariationId()) == NULL))
if (variation && (GetVariationById(variation->VariationId()) == nullptr))
{
string name = variation->Name();
bool pre = name.find("pre_") == 0;
@ -294,11 +294,11 @@ public:
/// Get a pointer to the variation at the specified index.
/// </summary>
/// <param name="index">The index in the list to retrieve</param>
/// <returns>A pointer to the variation at the index if in range, else NULL.</returns>
/// <returns>A pointer to the variation at the index if in range, else nullptr.</returns>
Variation<T>* GetVariation(size_t index) const
{
size_t count = 0;
Variation<T>* var = NULL;
Variation<T>* var = nullptr;
const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{
@ -320,16 +320,16 @@ public:
/// Get a pointer to the variation with the specified ID.
/// </summary>
/// <param name="id">The ID to search for</param>
/// <returns>A pointer to the variation if found, else NULL.</returns>
/// <returns>A pointer to the variation if found, else nullptr.</returns>
Variation<T>* GetVariationById(eVariationId id) const
{
Variation<T>* var = NULL;
Variation<T>* var = nullptr;
const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{
for (unsigned int i = 0; i < variations.size(); i++)
{
if (variations[i] != NULL && variations[i]->VariationId() == id)
if (variations[i] != nullptr && variations[i]->VariationId() == id)
{
var = variations[i];
keepGoing = false;
@ -345,16 +345,16 @@ public:
/// Get a pointer to the variation with the specified name.
/// </summary>
/// <param name="name">The name to search for</param>
/// <returns>A pointer to the variation if found, else NULL.</returns>
/// <returns>A pointer to the variation if found, else nullptr.</returns>
Variation<T>* GetVariationByName(string name) const
{
Variation<T>* var = NULL;
Variation<T>* var = nullptr;
const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{
for (unsigned int i = 0; i < variations.size(); i++)
{
if (variations[i] != NULL && variations[i]->Name() == name)
if (variations[i] != nullptr && variations[i]->Name() == name)
{
var = variations[i];
keepGoing = false;
@ -406,7 +406,7 @@ public:
{
for (unsigned int i = 0; i < variations.size(); i++)
{
if (variations[i] != NULL && variations[i]->VariationId() == id)
if (variations[i] != nullptr && variations[i]->VariationId() == id)
{
delete variations[i];
variations.erase(variations.begin() + i);
@ -442,7 +442,7 @@ public:
/// Reset this xform to be totally empty by clearing all variations, resetting both affines to the
/// identity matrix, clearing xaos, color, visibility, wind, animate and setting name
/// to the empty string.
/// Note that this also sets the parent ember to NULL, so if this xform is reused after calling Clear(),
/// Note that this also sets the parent ember to nullptr, so if this xform is reused after calling Clear(),
/// the caller must reset the parent ember to whatever ember they add it to again.
/// </summary>
void Clear()
@ -452,7 +452,7 @@ public:
m_Affine.MakeID();
m_Post.MakeID();
m_Xaos.clear();
m_ParentEmber = NULL;
m_ParentEmber = nullptr;
m_ColorSpeedCache = 0;
m_OneMinusColorCache = 0;
m_VizAdjusted = 0;
@ -537,7 +537,7 @@ public:
while (m_Xaos.size() > m_ParentEmber->XformCount())
m_Xaos.pop_back();
}
/// <summary>
/// Remove all xaos from this xform.
/// </summary>
@ -657,7 +657,7 @@ public:
m_PostVariations[i]->Func(iterHelper, *outPoint, rand);
WritePost(iterHelper, *outPoint, m_PostVariations[i]->AssignType());
}
//Optionally apply the post affine transform if it's present.
if (m_HasPost)
{
@ -688,7 +688,7 @@ public:
//Loop over the motion elements and add their contribution to the original vals.
for (i = 0; i < xform.m_Motion.size(); i++)
{
{
//Original only pulls these from the first motion xform which is a bug. Want to pull it from each one.
Xform<T>* currentMot = &xform.m_Motion[i];
int freq = currentMot->m_MotionFreq;
@ -698,11 +698,11 @@ public:
APPMOT(m_Weight);
APPMOT(m_ColorX);
//APPMOT(m_ColorY);
APPMOT(m_DirectColor);
APPMOT(m_Opacity);
APPMOT(m_DirectColor);
APPMOT(m_Opacity);
APPMOT(m_ColorSpeed);
APPMOT(m_Animate);
for (j = 0; j < currentMot->TotalVariationCount(); j++)//For each variation in the motion xform.
{
Variation<T>* motVar = currentMot->GetVariation(j);//Get the variation, which may or may not be present in this xform.
@ -724,7 +724,7 @@ public:
//At this point, we've added if needed, or just applied the motion func to the weight.
//Now apply the motion func to the params if needed.
if (motParVar != NULL)
if (motParVar != nullptr)
{
ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(var);
ParamWithName<T>* params = parVar->Params();
@ -747,7 +747,7 @@ public:
}
}
}
//Make sure certain params are within reasonable bounds.
ClampRef<T>(m_ColorX, 0, 1);
//ClampRef<T>(m_ColorY, 0, 1);
@ -866,11 +866,11 @@ public:
if (m_NeedPrecalcAtanXY)
helper.m_PrecalcAtanxy = atan2(helper.m_TransX, helper.m_TransY);
if (m_NeedPrecalcAtanYX)
helper.m_PrecalcAtanyx = atan2(helper.m_TransY, helper.m_TransX);
}
/// <summary>
/// Flatten this xform by adding a flatten variation if none is present, and if any of the
/// variations or parameters in the vector are present.
@ -881,7 +881,7 @@ public:
{
bool shouldFlatten = true;
if (GetVariationById(VAR_FLATTEN) == NULL)
if (GetVariationById(VAR_FLATTEN) == nullptr)
{
AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{
@ -953,6 +953,7 @@ public:
"\tvIn.z = transZ;\n";
break;
case VARTYPE_POST:
default:
s =
"\tvIn.x = outPoint->m_X;\n"
"\tvIn.y = outPoint->m_Y;\n"
@ -980,6 +981,7 @@ public:
break;
}
case ASSIGNTYPE_SUM:
default:
{
helper.m_TransX += helper.Out.x;
helper.m_TransY += helper.Out.y;
@ -1006,6 +1008,7 @@ public:
break;
}
case ASSIGNTYPE_SUM:
default:
{
outPoint.m_X += helper.Out.x;
outPoint.m_Y += helper.Out.y;
@ -1014,7 +1017,7 @@ public:
}
}
}
/// <summary>
/// Generate the OpenCL string for writing output values from a call to a variation.
/// </summary>
@ -1048,6 +1051,7 @@ public:
break;
}
case ASSIGNTYPE_SUM:
default:
{
s =
"\ttransX += vOut.x;\n"
@ -1060,6 +1064,7 @@ public:
break;
}
case VARTYPE_POST:
default:
{
switch (assignType)
{
@ -1072,6 +1077,7 @@ public:
break;
}
case ASSIGNTYPE_SUM:
default:
{
s =
"\toutPoint->m_X += vOut.x;\n"
@ -1160,7 +1166,7 @@ public:
//Color coordinates for this function. This is the index into the palette used to look up a color and add to the histogram for each iter.
//The original only allows for an x coord. Will eventually allow for a y coord like Fractron for 2D palettes.
T m_ColorX, m_ColorY;
private:
T m_ColorSpeedCache;//Cache of m_ColorSpeed * m_ColorX. Need to recalc cache values whenever anything relating to color is set. Made private because one affects the other.
T m_OneMinusColorCache;//Cache of 1 - m_ColorSpeedCache.
@ -1184,7 +1190,7 @@ public:
private:
vector<Variation<T>*> m_PostVariations;//The list of post variations to call when applying this xform.
public:
T m_DirectColor;//Used with direct color variations.
@ -1192,7 +1198,7 @@ public:
//Discussed on page 4 of the paper:
//Probability wi.
T m_Weight;
//Scaling factor on color added to current iteration, also known as color weight. Normally defaults to 0.5.
//Discussed on page 9 of the paper with a hard coded default value of 0.5:
//C = (C + Ci) * m_ColorSpeed.
@ -1247,4 +1253,4 @@ private:
bool m_NeedPrecalcAtanXY;//Whether any variation uses the precalc atan XY value in its calculations.
bool m_NeedPrecalcAtanYX;//Whether any variation uses the precalc atan YX value in its calculations.
};
}
}

View File

@ -28,22 +28,22 @@ public:
{
m_Category = category;
m_NewLocale = string(loc);
m_OriginalLocale = setlocale(category, NULL);//Query.
m_OriginalLocale = setlocale(category, nullptr);//Query.
if (m_OriginalLocale.empty())
cout << "Couldn't get original locale." << endl;
if (setlocale(category, loc) == NULL)//Set.
if (setlocale(category, loc) == nullptr)//Set.
cout << "Couldn't set new locale " << category << ", " << loc << "." << endl;
}
/// <summary>
/// Reset the locale to the value stored during construction.
/// </summary>
~Locale()
{
if (!m_OriginalLocale.empty())
if (setlocale(m_Category, m_OriginalLocale.c_str()) == NULL)//Restore.
if (setlocale(m_Category, m_OriginalLocale.c_str()) == nullptr)//Restore.
cout << "Couldn't restore original locale " << m_Category << ", " << m_OriginalLocale << "." << endl;
}
@ -250,7 +250,7 @@ public:
bool Parse(unsigned char* buf, const char* filename, vector<Ember<T>>& embers)
{
char* bn;
const char* xmlBuf;
const char* xmlPtr;
const char* loc = __FUNCTION__;
unsigned int emberSize;
size_t bufSize;
@ -260,12 +260,12 @@ public:
m_ErrorReport.clear();
//Parse XML string into internal document.
xmlBuf = (const char*)(&buf[0]);
bufSize = strlen(xmlBuf);
xmlPtr = (const char*)(&buf[0]);
bufSize = strlen(xmlPtr);
embers.reserve(bufSize / 2500);//The Xml text for an ember is around 2500 bytes, but can be much more. Pre-allocate to aovid unnecessary resizing.
doc = xmlReadMemory(xmlBuf, (int)bufSize, filename, NULL, XML_PARSE_NONET);//Forbid network access during read.
doc = xmlReadMemory(xmlPtr, (int)bufSize, filename, nullptr, XML_PARSE_NONET);//Forbid network access during read.
if (doc == NULL)
if (doc == nullptr)
{
m_ErrorReport.push_back(string(loc) + " : Error parsing xml file " + string(filename));
return false;
@ -310,7 +310,7 @@ public:
{
while (embers[i].m_Rotate < embers[i - 1].m_Rotate - 180)
embers[i].m_Rotate += 360;
while (embers[i].m_Rotate > embers[i - 1].m_Rotate + 180)
embers[i].m_Rotate -= 360;
}
@ -416,7 +416,7 @@ public:
//Convert the string using strtod().
val = strtol(str, &endp, 10);
//Check errno & return string.
if (endp != str + strlen(str))
{
@ -483,7 +483,7 @@ private:
void ScanForEmberNodes(xmlNode* curNode, char* parentFile, vector<Ember<T>>& embers)
{
bool parseEmberSuccess;
xmlNodePtr thisNode = NULL;
xmlNodePtr thisNode = nullptr;
const char* loc = __FUNCTION__;
string parentFileString = string(parentFile);
@ -537,7 +537,7 @@ private:
/// <returns>True if there were no errors, else false.</returns>
bool ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber)
{
bool b = true;
bool ret = true;
unsigned int newLinear = 0;
char* attStr;
const char* loc = __FUNCTION__;
@ -550,7 +550,7 @@ private:
currentEmber.m_Palette.Clear();//Wipe out the current palette.
att = emberNode->properties;//The top level element is a ember element, read the attributes of it and store them.
if (att == NULL)
if (att == nullptr)
{
m_ErrorReport.push_back(string(loc) + " : <flame> element has no attributes");
return false;
@ -561,36 +561,36 @@ private:
attStr = (char*)xmlGetProp(emberNode, curAtt->name);
//First parse out simple float reads.
if (ParseAndAssignFloat(curAtt->name, attStr, "time", currentEmber.m_Time, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "scale", currentEmber.m_PixelsPerUnit, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "rotate", currentEmber.m_Rotate, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "zoom", currentEmber.m_Zoom, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "filter", currentEmber.m_SpatialFilterRadius, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_width", currentEmber.m_TemporalFilterWidth, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_exp", currentEmber.m_TemporalFilterExp, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "quality", currentEmber.m_Quality, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "brightness", currentEmber.m_Brightness, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma", currentEmber.m_Gamma, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "highlight_power", currentEmber.m_HighlightPower, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "vibrancy", currentEmber.m_Vibrancy, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_radius", currentEmber.m_MaxRadDE, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_minimum", currentEmber.m_MinRadDE, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_curve", currentEmber.m_CurveDE, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma_threshold", currentEmber.m_GammaThresh, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_zpos", currentEmber.m_CamZPos, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_persp", currentEmber.m_CamPerspective, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_perspective", currentEmber.m_CamPerspective, b)) { }//Apo bug.
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_yaw", currentEmber.m_CamYaw, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_pitch", currentEmber.m_CamPitch, b)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_dof", currentEmber.m_CamDepthBlur, b)) { }
if (ParseAndAssignFloat(curAtt->name, attStr, "time", currentEmber.m_Time, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "scale", currentEmber.m_PixelsPerUnit, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "rotate", currentEmber.m_Rotate, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "zoom", currentEmber.m_Zoom, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "filter", currentEmber.m_SpatialFilterRadius, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_width", currentEmber.m_TemporalFilterWidth, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_exp", currentEmber.m_TemporalFilterExp, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "quality", currentEmber.m_Quality, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "brightness", currentEmber.m_Brightness, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma", currentEmber.m_Gamma, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "highlight_power", currentEmber.m_HighlightPower, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "vibrancy", currentEmber.m_Vibrancy, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_radius", currentEmber.m_MaxRadDE, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_minimum", currentEmber.m_MinRadDE, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_curve", currentEmber.m_CurveDE, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma_threshold", currentEmber.m_GammaThresh, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_zpos", currentEmber.m_CamZPos, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_persp", currentEmber.m_CamPerspective, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_perspective", currentEmber.m_CamPerspective, ret)) { }//Apo bug.
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_yaw", currentEmber.m_CamYaw, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_pitch", currentEmber.m_CamPitch, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_dof", currentEmber.m_CamDepthBlur, ret)) { }
//Parse simple int reads.
else if (ParseAndAssignInt(curAtt->name, attStr, "palette", currentEmber.m_Palette.m_Index, b)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "oversample", currentEmber.m_Supersample , b)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "supersample", currentEmber.m_Supersample , b)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "temporal_samples", currentEmber.m_TemporalSamples, b)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "soloxform", soloXform , b)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "new_linear", newLinear , b)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "palette", currentEmber.m_Palette.m_Index, ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "oversample", currentEmber.m_Supersample , ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "supersample", currentEmber.m_Supersample , ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "temporal_samples", currentEmber.m_TemporalSamples, ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "soloxform", soloXform , ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "new_linear", newLinear , ret)) { }
//Parse more complicated reads that have multiple possible values.
else if (!Compare(curAtt->name, "interpolation"))
@ -631,7 +631,7 @@ private:
}
else if (!Compare(curAtt->name, "size"))
{
if (sscanf_s(attStr, "%d %d", &currentEmber.m_FinalRasW, &currentEmber.m_FinalRasH) != 2)
if (sscanf_s(attStr, "%u %u", &currentEmber.m_FinalRasW, &currentEmber.m_FinalRasH) != 2)
{
m_ErrorReport.push_back(string(loc) + " : Invalid size attribute " + string(attStr));
xmlFree(attStr);
@ -709,7 +709,7 @@ private:
//Loop through the attributes of the color element.
att = childNode->properties;
if (att == NULL)
if (att == nullptr)
{
m_ErrorReport.push_back(string(loc) + " : No attributes for color element");
continue;
@ -775,7 +775,7 @@ private:
//Loop through the attributes of the color element.
att = childNode->properties;
if (att == NULL)
if (att == nullptr)
{
m_ErrorReport.push_back(string(loc) + " : No attributes for colors element");
continue;
@ -821,7 +821,7 @@ private:
//Loop through the attributes of the palette element.
att = childNode->properties;
if (att == NULL)
if (att == nullptr)
{
m_ErrorReport.push_back(string(loc) + " : No attributes for palette element");
continue;
@ -864,7 +864,7 @@ private:
else if (!Compare(curAtt->name, "format"))
{
newFormat = true;
if (!_stricmp(attStr, "RGB"))
numBytes = 3;
else if (!_stricmp(attStr, "RGBA"))
@ -879,7 +879,7 @@ private:
{
m_ErrorReport.push_back(string(loc) + " : Unknown palette attribute " + string((const char*)curAtt->name));
}
xmlFree(attStr);
}
@ -914,7 +914,7 @@ private:
//Loop through the attributes of the palette element.
att = childNode->properties;
if (att == NULL)
if (att == nullptr)
{
m_ErrorReport.push_back(string(loc) + " : No attributes for palette element");
continue;
@ -944,7 +944,7 @@ private:
}
else if (!Compare(childNode->name, "xform") || !Compare(childNode->name, "finalxform"))
{
Xform<T>* theXform = NULL;
Xform<T>* theXform = nullptr;
if (!Compare(childNode->name, "finalxform"))
{
@ -1033,7 +1033,7 @@ private:
bool ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion)
{
bool success = true;
char* attStr, *copy;
char* attStr;
const char* loc = __FUNCTION__;
unsigned int j;
T temp;
@ -1044,7 +1044,7 @@ private:
//Loop through the attributes of the xform element.
attPtr = childNode->properties;
if (attPtr == NULL)
if (attPtr == nullptr)
{
m_ErrorReport.push_back(string(loc) + " : Error: No attributes for element");
return false;
@ -1052,7 +1052,7 @@ private:
for (curAtt = attPtr; curAtt; curAtt = curAtt->next)
{
copy = attStr = (char*)xmlGetProp(childNode, curAtt->name);
attStr = (char*)xmlGetProp(childNode, curAtt->name);
//First parse out simple float reads.
if (ParseAndAssignFloat(curAtt->name, attStr, "weight", xform.m_Weight, success)) { }
@ -1095,7 +1095,6 @@ private:
}
else if (!Compare(curAtt->name, "color"))
{
T tmpc1 = 0;
xform.m_ColorX = xform.m_ColorY = 0;
//Try two coords first .
@ -1141,7 +1140,7 @@ private:
a = d = b = e = c = f = 0;
m_ErrorReport.push_back(string(loc) + " : Bad coeffs attribute " + string(attStr));
}
xform.m_Affine.A(T(a));
xform.m_Affine.B(T(b));
xform.m_Affine.C(T(c));
@ -1167,7 +1166,6 @@ private:
else
{
string s = GetCorrectedVariationName(m_BadVariationNames, curAtt);
const char* name = s.c_str();
if (Variation<T>* var = m_VariationList.GetVariation(s))
{
@ -1192,11 +1190,11 @@ private:
if (!Compare(curAtt->name, "var1"))
{
copy = attStr = (char*)xmlGetProp(childNode, curAtt->name);
attStr = (char*)xmlGetProp(childNode, curAtt->name);
for (j = 0; j < xform.TotalVariationCount(); j++)
xform.GetVariation(j)->m_Weight = 0;
if (Atof(attStr, temp))
{
unsigned int iTemp = (unsigned int)temp;
@ -1207,7 +1205,7 @@ private:
var1 = true;
}
}
if (!var1)
m_ErrorReport.push_back(string(loc) + " : Bad value for var1 " + string(attStr));
@ -1223,7 +1221,7 @@ private:
if (!Compare(curAtt->name, "var"))
{
copy = attStr = (char*)xmlGetProp(childNode, curAtt->name);
attStr = (char*)xmlGetProp(childNode, curAtt->name);
if (Atof(attStr, temp))
{
@ -1232,7 +1230,7 @@ private:
var = true;
}
if (!var)
m_ErrorReport.push_back(string(loc) + " : Bad value for var " + string(attStr));
@ -1254,7 +1252,7 @@ private:
if (parVar->ContainsParam(name))
{
T val = 0;
copy = attStr = (char*)xmlGetProp(childNode, curAtt->name);
attStr = (char*)xmlGetProp(childNode, curAtt->name);
if (Atof(attStr, val))
{
@ -1264,7 +1262,7 @@ private:
{
m_ErrorReport.push_back(string(loc) + " : Failed to parse parametric variation parameter " + s + " - " + string(attStr));
}
xmlFree(attStr);
}
}
@ -1339,7 +1337,7 @@ private:
{
if (!_stricmp(name, (const char*)temp->name))
return true;
} while (temp = temp->next);
} while ((temp = temp->next));
return false;
}
@ -1357,13 +1355,13 @@ private:
{
int colorIndex = 0;
int colorCount = 0;
int r, g, b, a;
unsigned int r, g, b, a;
int ret;
char tmps[2];
int skip = (int)abs(chan);
bool ok = true;
const char* loc = __FUNCTION__;
//Strip whitespace prior to first color.
while (isspace((int)colstr[colorIndex]))
colorIndex++;
@ -1389,10 +1387,10 @@ private:
}
colorIndex += 2 * skip;
while (isspace((int)colstr[colorIndex]))
colorIndex++;
ember.m_Palette.m_Entries[colorCount].r = T(r) / T(255);//Hex palette is [0..255], convert to [0..1].
ember.m_Palette.m_Entries[colorCount].g = T(g) / T(255);
ember.m_Palette.m_Entries[colorCount].b = T(b) / T(255);
@ -1411,7 +1409,7 @@ private:
m_ErrorReport.push_back(string(loc) + " : Extra data at end of hex color data " + string(&(colstr[colorIndex])));
ok = false;
}
return ok;
}
@ -1443,13 +1441,13 @@ private:
Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted0[i]), s);
Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted1[i]), t);
s[3] = hueAdjusted0[i][3];
t[3] = hueAdjusted1[i][3];
for (j = 0; j < 4; j++)
t[j] = ((1 - blend) * s[j]) + (blend * t[j]);
Palette<T>::HsvToRgb(t, glm::value_ptr(palette.m_Entries[i]));
palette.m_Entries[i][3] = t[3];
}
@ -1518,7 +1516,7 @@ private:
}
return ret;
}
}
static bool m_Init;
static vector<pair<string, string>> m_BadParamNames;
@ -1526,4 +1524,4 @@ private:
VariationList<T> m_VariationList;//The variation list used to make copies of variations to populate the embers with.
PaletteList<T> m_PaletteList;
};
}
}

View File

@ -311,7 +311,7 @@ bool EmberAnimate(EmberOptions& opt)
if ((opt.Format() == "jpg" || opt.Format() == "bmp") && renderer->NumChannels() == 4)
{
EmberNs::RgbaToRgb(finalImage, vecRgb, renderer->FinalRasW(), renderer->FinalRasH());
RgbaToRgb(finalImage, vecRgb, renderer->FinalRasW(), renderer->FinalRasH());
finalImagep = vecRgb.data();
}

View File

@ -84,7 +84,7 @@ private:
/// <returns>True if success, else false.</returns>
template <typename T>
static bool ParseEmberFile(XmlToEmber<T>& parser, string filename, vector<Ember<T>>& embers)
{
{
if (!parser.Parse(filename.c_str(), embers))
{
cout << "Error parsing flame file " << filename << ", returning without executing." << endl;
@ -109,7 +109,7 @@ static bool ParseEmberFile(XmlToEmber<T>& parser, string filename, vector<Ember<
/// <returns>True if success, else false.</returns>
template <typename T>
static bool InitPaletteList(string filename)
{
{
PaletteList<T> paletteList;//Even though this is local, the members are static so they will remain.
if (!paletteList.Init(filename))
@ -122,6 +122,25 @@ static bool InitPaletteList(string filename)
return true;
}
/// <summary>
/// Convert an RGBA buffer to an RGB buffer.
/// </summary>
/// <param name="rgba">The RGBA buffer</param>
/// <param name="rgb">The RGB buffer</param>
/// <param name="width">The width of the image in pixels</param>
/// <param name="height">The height of the image in pixels</param>
static void RgbaToRgb(vector<unsigned char>& rgba, vector<unsigned char>& rgb, unsigned int width, unsigned int height)
{
rgb.resize(width * height * 3);
for (unsigned int i = 0, j = 0; i < (width * height * 4); i += 4, j += 3)
{
rgb[j] = rgba[i];
rgb[j + 1] = rgba[i + 1];
rgb[j + 2] = rgba[i + 2];
}
}
/// <summary>
/// Calculate the number of strips required if the needed amount of memory
/// is greater than the system memory, or greater than what the user want to allow.

View File

@ -309,7 +309,7 @@ bool EmberRender(EmberOptions& opt)
if ((opt.Format() == "jpg" || opt.Format() == "bmp") && renderer->NumChannels() == 4)
{
EmberNs::RgbaToRgb(finalImage, vecRgb, renderer->FinalRasW(), realHeight);
RgbaToRgb(finalImage, vecRgb, renderer->FinalRasW(), realHeight);
finalImagep = vecRgb.data();
}

View File

@ -1748,7 +1748,7 @@ double RandD(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
int _tmain(int argc, _TCHAR* argv[])
{
int i;
//int i;
Timing t(4);
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;

View File

@ -137,7 +137,7 @@ void FractoriumEmberControllerBase::SaveCurrentRender(QString filename)
if ((suffix == "jpg" || suffix == "bmp") && m_Renderer->NumChannels() == 4)
{
EmberNs::RgbaToRgb(m_FinalImage, vecRgb, width, height);
RgbaToRgb(m_FinalImage, vecRgb, width, height);
data = vecRgb.data();
}