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" /> <Option createStaticLib="1" />
<Compiler> <Compiler>
<Add option="-D_DEBUG" /> <Add option="-D_DEBUG" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add option="-D_M_X64" />
</Compiler> </Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target> </Target>
<Target title="ReleaseNvidia Win32"> <Target title="ReleaseNvidia Win32">
<Option output="Ember" prefix_auto="1" extension_auto="1" /> <Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -27,16 +27,6 @@
<Option compiler="gcc" /> <Option compiler="gcc" />
<Option createDefFile="1" /> <Option createDefFile="1" />
<Option createStaticLib="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>
<Target title="ReleaseNvidia x64"> <Target title="ReleaseNvidia x64">
<Option output="Ember" prefix_auto="1" extension_auto="1" /> <Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -45,15 +35,13 @@
<Option createDefFile="1" /> <Option createDefFile="1" />
<Option createStaticLib="1" /> <Option createStaticLib="1" />
<Compiler> <Compiler>
<Add option="-DWIN32" /> <Add option="-fomit-frame-pointer" />
<Add option="-O2" />
<Add option="-DNDEBUG" /> <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> </Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target> </Target>
<Target title="Release x64"> <Target title="Release x64">
<Option output="Ember" prefix_auto="1" extension_auto="1" /> <Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -62,15 +50,13 @@
<Option createDefFile="1" /> <Option createDefFile="1" />
<Option createStaticLib="1" /> <Option createStaticLib="1" />
<Compiler> <Compiler>
<Add option="-DWIN32" /> <Add option="-fomit-frame-pointer" />
<Add option="-O2" />
<Add option="-DNDEBUG" /> <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> </Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target> </Target>
<Target title="Release Win32"> <Target title="Release Win32">
<Option output="Ember" prefix_auto="1" extension_auto="1" /> <Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -78,16 +64,6 @@
<Option compiler="gcc" /> <Option compiler="gcc" />
<Option createDefFile="1" /> <Option createDefFile="1" />
<Option createStaticLib="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>
<Target title="Debug Win32"> <Target title="Debug Win32">
<Option output="Ember" prefix_auto="1" extension_auto="1" /> <Option output="Ember" prefix_auto="1" extension_auto="1" />
@ -95,23 +71,30 @@
<Option compiler="gcc" /> <Option compiler="gcc" />
<Option createDefFile="1" /> <Option createDefFile="1" />
<Option createStaticLib="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> </Target>
</Build> </Build>
<Compiler> <Compiler>
<Add option="-march=k8" /> <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="-std=c++11" />
<Add option="-Wall" />
<Add option="-fpermissive" /> <Add option="-fpermissive" />
<Add option="-fPIC" /> <Add option="-fPIC" />
<Add option="-D_M_X64" />
<Add option="-D_USRDLL" />
<Add option="-DBUILDING_EMBER" />
<Add directory="/usr/include/libxml2" /> <Add directory="/usr/include/libxml2" />
</Compiler> </Compiler>
<Linker> <Linker>

View File

@ -1,64 +1,169 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file> <CodeBlocks_layout_file>
<ActiveTarget name="Debug x64" /> <ActiveTarget name="Release 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"> <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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="0" topLine="0" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="0" topLine="0" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="6418" topLine="129" /> <Cursor1 position="98407" topLine="3204" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="5242" topLine="116" /> <Cursor1 position="16510" topLine="323" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="0" topLine="0" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="0" topLine="0" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="21424" topLine="713" /> <Cursor1 position="22861" topLine="816" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="2973" topLine="67" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="953" topLine="25" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="1381" topLine="37" />
</Cursor> </Cursor>
</File> </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> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="42788" topLine="1649" />
</Cursor> </Cursor>
</File> </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> <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> </Cursor>
</File> </File>
</CodeBlocks_layout_file> </CodeBlocks_layout_file>

View File

@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file> <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> </CodeBlocks_layout_file>

View File

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

View File

@ -1,4 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file> <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> </CodeBlocks_layout_file>

View File

@ -161,18 +161,18 @@
</Linker> </Linker>
</Target> </Target>
</Build> </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/EmberRender.rc" />
<Unit filename="../../EmberRender/resource.h" />
<Unit filename="../../Fractorium/Icons/Fractorium.ico" /> <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" /> <Unit filename="ReadMe.txt" />
<Extensions> <Extensions>
<code_completion /> <code_completion />

View File

@ -1,4 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file> <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> </CodeBlocks_layout_file>

View File

@ -134,8 +134,8 @@ public:
m_PixPerImageUnitH = (T)rasH * invSizeH; m_PixPerImageUnitH = (T)rasH * invSizeH;
m_RasLlY = m_PixPerImageUnitH * carLlY; m_RasLlY = m_PixPerImageUnitH * carLlY;
T m_OneRow = abs(m_CarUrY - m_CarLlY) / m_RasHeight; m_OneRow = abs(m_CarUrY - m_CarLlY) / m_RasHeight;
T m_OneCol = abs(m_CarUrX - m_CarLlX) / m_RasWidth; m_OneCol = abs(m_CarUrX - m_CarLlX) / m_RasWidth;
m_PadCarLlX = m_CarLlX + m_OneCol; m_PadCarLlX = m_CarLlX + m_OneCol;
m_PadCarUrX = m_CarUrX - 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_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. 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(); Init();
} }
Ember(const Ember<T>& ember) Ember(const Ember<T>& ember)
: m_Edits(NULL) : m_Edits(nullptr)
{ {
Ember<T>::operator=<T>(ember); Ember<T>::operator=<T>(ember);
} }
@ -56,7 +56,7 @@ public:
/// <param name="ember">The Ember object to copy</param> /// <param name="ember">The Ember object to copy</param>
template <typename U> template <typename U>
Ember(const Ember<U>& ember) Ember(const Ember<U>& ember)
: m_Edits(NULL) : m_Edits(nullptr)
{ {
Ember<T>::operator=<U>(ember); Ember<T>::operator=<U>(ember);
} }
@ -106,7 +106,7 @@ public:
m_CamDepthBlur = T(ember.m_CamDepthBlur); m_CamDepthBlur = T(ember.m_CamDepthBlur);
m_CamMat = ember.m_CamMat; m_CamMat = ember.m_CamMat;
m_CenterX = T(ember.m_CenterX); 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_Rotate = T(ember.m_Rotate);
m_Hue = T(ember.m_Hue); m_Hue = T(ember.m_Hue);
m_Brightness = T(ember.m_Brightness); m_Brightness = T(ember.m_Brightness);
@ -165,8 +165,8 @@ public:
SetProjFunc(); SetProjFunc();
ClearEdit(); ClearEdit();
if (ember.m_Edits != NULL) if (ember.m_Edits != nullptr)
m_Edits = xmlCopyDoc(ember.m_Edits, 1); m_Edits = xmlCopyDoc(ember.m_Edits, 1);
return *this; return *this;
@ -235,9 +235,9 @@ public:
m_Index = 0; m_Index = 0;
m_Xforms.reserve(12); m_Xforms.reserve(12);
m_Edits = NULL; m_Edits = nullptr;
} }
/// <summary> /// <summary>
/// Add a copy of a new xform to the xforms vector. /// Add a copy of a new xform to the xforms vector.
/// </summary> /// </summary>
@ -284,7 +284,7 @@ public:
Ember<T> ember(*this); Ember<T> ember(*this);
ember.PadXforms(xformPad); ember.PadXforms(xformPad);
if (doFinal) if (doFinal)
{ {
if (UseFinalXform())//Caller wanted one and this ember has one. 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. ember.m_FinalXform.AddVariation(new LinearVariation<T>(0));//Do this so it doesn't appear empty.
} }
} }
return ember; return ember;
} }
@ -322,7 +322,7 @@ public:
//Now shuffle xaos values from i on back by 1 for every xform. //Now shuffle xaos values from i on back by 1 for every xform.
for (unsigned int x1 = 0; x1 < XformCount(); x1++) 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. 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)); 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. xform->TruncateXaos();//Make sure no old values are hanging around in case more xforms are added to this ember later.
} }
} }
return true; return true;
} }
@ -358,13 +358,13 @@ public:
/// Get a pointer to the xform at the specified index, excluding the final one. /// Get a pointer to the xform at the specified index, excluding the final one.
/// </summary> /// </summary>
/// <param name="i">The index to get</param> /// <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 Xform<T>* GetXform(unsigned int i) const
{ {
if (i < XformCount()) if (i < XformCount())
return (Xform<T>*)&m_Xforms[i]; return (Xform<T>*)&m_Xforms[i];
else else
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -372,7 +372,7 @@ public:
/// </summary> /// </summary>
/// <param name="i">The index to get</param> /// <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> /// <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 Xform<T>* GetTotalXform(unsigned int i, bool forceFinal = false) const
{ {
if (i < XformCount()) if (i < XformCount())
@ -380,7 +380,7 @@ public:
else if (i == XformCount() || forceFinal) else if (i == XformCount() || forceFinal)
return (Xform<T>*)&m_FinalXform; return (Xform<T>*)&m_FinalXform;
else else
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -407,7 +407,7 @@ public:
int GetTotalXformIndex(Xform<T>* xform) const int GetTotalXformIndex(Xform<T>* xform) const
{ {
unsigned int totalXformCount = TotalXformCount(); unsigned int totalXformCount = TotalXformCount();
for (unsigned int i = 0; i < totalXformCount; i++) for (unsigned int i = 0; i < totalXformCount; i++)
if (GetTotalXform(i) == xform) if (GetTotalXform(i) == xform)
return (int)i; return (int)i;
@ -461,7 +461,7 @@ public:
for (unsigned int i = 0; i < TotalXformCount(); i++) for (unsigned int i = 0; i < TotalXformCount(); i++)
{ {
Xform<T>* xform = GetTotalXform(i); Xform<T>* xform = GetTotalXform(i);
xform->CacheColorVals(); xform->CacheColorVals();
xform->SetPrecalcFlags(); xform->SetPrecalcFlags();
} }
@ -677,29 +677,29 @@ public:
bool allID, final; bool allID, final;
unsigned int i, j, k, l, maxXformCount, totalXformCount; unsigned int i, j, k, l, maxXformCount, totalXformCount;
T bgAlphaSave = m_Background.a; T bgAlphaSave = m_Background.a;
T coefSave[2]; T coefSave[2] {0, 0};
vector<Xform<T>*> xformVec; vector<Xform<T>*> xformVec;
//Palette and others //Palette and others
if (embers[0].m_PaletteInterp == INTERP_HSV) if (embers[0].m_PaletteInterp == INTERP_HSV)
{ {
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
T t[3], s[4] = { 0, 0, 0, 0 }; T t[3], s[4] = { 0, 0, 0, 0 };
for (k = 0; k < size; k++) for (k = 0; k < size; k++)
{ {
Palette<T>::RgbToHsv(glm::value_ptr(embers[k].m_Palette[i]), t); Palette<T>::RgbToHsv(glm::value_ptr(embers[k].m_Palette[i]), t);
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
s[j] += coefs[k] * t[j]; s[j] += coefs[k] * t[j];
s[3] += coefs[k] * embers[k].m_Palette[i][3]; s[3] += coefs[k] * embers[k].m_Palette[i][3];
} }
Palette<T>::HsvToRgb(s, glm::value_ptr(m_Palette[i])); Palette<T>::HsvToRgb(s, glm::value_ptr(m_Palette[i]));
m_Palette[i][3] = s[3]; m_Palette[i][3] = s[3];
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
Clamp<T>(m_Palette[i][j], 0, 1); Clamp<T>(m_Palette[i][j], 0, 1);
} }
@ -803,7 +803,7 @@ public:
var->m_Weight = 0; var->m_Weight = 0;
if (parVar != NULL) if (parVar != nullptr)
parVar->Clear(); parVar->Clear();
for (k = 0; k < size; k++)//For each ember in the list. 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. 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. //Interp weight.
var->m_Weight += tempVar->m_Weight * coefs[k]; var->m_Weight += tempVar->m_Weight * coefs[k];
//If it was a parametric variation, interp params. //If it was a parametric variation, interp params.
if (parVar != NULL) if (parVar != nullptr)
{ {
ParametricVariation<T>* tempParVar = dynamic_cast<ParametricVariation<T>*>(tempVar); 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>* params = parVar->Params();
ParamWithName<T>* tempParams = tempParVar->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_ColorSpeed>(thisXform, i, embers, coefs, size);
InterpXform<&Xform<T>::m_Opacity> (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); InterpXform<&Xform<T>::m_Animate> (thisXform, i, embers, coefs, size);
ClampGte0Ref(thisXform->m_Weight); ClampGte0Ref(thisXform->m_Weight);
ClampRef<T>(thisXform->m_ColorX, 0, 1); ClampRef<T>(thisXform->m_ColorX, 0, 1);
ClampRef<T>(thisXform->m_ColorSpeed, -1, 1); ClampRef<T>(thisXform->m_ColorSpeed, -1, 1);
@ -857,9 +857,9 @@ public:
vector<v2T> cxMag(size); vector<v2T> cxMag(size);
vector<v2T> cxAng(size); vector<v2T> cxAng(size);
vector<v2T> cxTrn(size); vector<v2T> cxTrn(size);
thisXform->m_Affine.m_Mat = m23T(0); thisXform->m_Affine.m_Mat = m23T(0);
//Affine part. //Affine part.
Interpolater<T>::ConvertLinearToPolar(embers, size, i, 0, cxAng, cxMag, cxTrn); Interpolater<T>::ConvertLinearToPolar(embers, size, i, 0, cxAng, cxMag, cxTrn);
Interpolater<T>::InterpAndConvertBack(coefs, cxAng, cxMag, cxTrn, thisXform->m_Affine); 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>::ConvertLinearToPolar(embers, size, i, 1, cxAng, cxMag, cxTrn);
Interpolater<T>::InterpAndConvertBack(coefs, cxAng, cxMag, cxTrn, thisXform->m_Post); Interpolater<T>::InterpAndConvertBack(coefs, cxAng, cxMag, cxTrn, thisXform->m_Post);
} }
} }
else if (m_AffineInterp == INTERP_LINEAR) else if (m_AffineInterp == INTERP_LINEAR)
{ {
@ -999,7 +999,7 @@ public:
//Don't rotate xforms with animate set to 0. //Don't rotate xforms with animate set to 0.
if (m_Xforms[i].m_Animate == 0) if (m_Xforms[i].m_Animate == 0)
continue; continue;
//Assume that if there are no variations, then it's a padding xform. //Assume that if there are no variations, then it's a padding xform.
if (m_Xforms[i].Empty() && m_AffineInterp != INTERP_LOG) if (m_Xforms[i].Empty() && m_AffineInterp != INTERP_LOG)
continue; continue;
@ -1066,7 +1066,7 @@ public:
m_Xforms[i].m_Affine.E(1); m_Xforms[i].m_Affine.E(1);
m_Xforms[i].m_Affine.F(0); m_Xforms[i].m_Affine.F(0);
m_Xforms[i].AddVariation(new LinearVariation<T>()); m_Xforms[i].AddVariation(new LinearVariation<T>());
result++; result++;
sym = -sym; sym = -sym;
} }
@ -1201,9 +1201,9 @@ public:
T z = point.m_Z - m_CamZPos; T z = point.m_Z - m_CamZPos;
T x = m_CamMat[0][0] * point.m_X + m_CamMat[1][0] * point.m_Y; 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; T y = m_CamMat[0][1] * point.m_X + m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z;
z = m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z; z = m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z;
T zr = Zeps(1 - m_CamPerspective * z); T zr = Zeps(1 - m_CamPerspective * z);
T dr = rand.Frand01<T>() * m_BlurCoef * z; T dr = rand.Frand01<T>() * m_BlurCoef * z;
@ -1294,7 +1294,7 @@ public:
m_Supersample = 0; m_Supersample = 0;
m_SpatialFilterRadius = -1; m_SpatialFilterRadius = -1;
m_Zoom = 999999; m_Zoom = 999999;
m_ProjFunc = NULL; m_ProjFunc = nullptr;
m_CamZPos = 999999; m_CamZPos = 999999;
m_CamPerspective = 999999; m_CamPerspective = 999999;
m_CamYaw = 999999; m_CamYaw = 999999;
@ -1316,21 +1316,21 @@ public:
m_TemporalFilterExp = -999; m_TemporalFilterExp = -999;
m_PaletteMode = PALETTE_STEP; m_PaletteMode = PALETTE_STEP;
} }
m_Xforms.clear(); m_Xforms.clear();
m_FinalXform.Clear(); m_FinalXform.Clear();
ClearEdit(); ClearEdit();
} }
/// <summary> /// <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> /// </summary>
void ClearEdit() void ClearEdit()
{ {
if (m_Edits != NULL) if (m_Edits != nullptr)
xmlFreeDoc(m_Edits); xmlFreeDoc(m_Edits);
m_Edits = NULL; m_Edits = nullptr;
} }
/// <summary> /// <summary>
@ -1384,7 +1384,7 @@ public:
<< "Temporal Filter Type: " << m_TemporalFilterType << endl << "Temporal Filter Type: " << m_TemporalFilterType << endl
<< "Temporal Filter Exp: " << m_TemporalFilterExp << endl << "Temporal Filter Exp: " << m_TemporalFilterExp << endl
<< "Temporal Filter Width: " << m_TemporalFilterWidth << endl << "Temporal Filter Width: " << m_TemporalFilterWidth << endl
<< "Palette Mode: " << m_PaletteMode << endl << "Palette Mode: " << m_PaletteMode << endl
<< "Palette Interp: " << m_PaletteInterp << endl << "Palette Interp: " << m_PaletteInterp << endl
<< "Palette Index: " << m_Palette.m_Index << 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. //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". //Xml field: "scale".
T m_PixelsPerUnit; 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. //overcome the shortcoming of scale by also adjusting the quality.
//Xml field: "zoom". //Xml field: "zoom".
T m_Zoom; T m_Zoom;
//3D fields. //3D fields.
private: private:
typedef void (Ember<T>::*ProjFuncPtr)(Point<T>&, QTIsaac<ISAAC_SIZE, ISAAC_INT>&); typedef void (Ember<T>::*ProjFuncPtr)(Point<T>&, QTIsaac<ISAAC_SIZE, ISAAC_INT>&);
ProjFuncPtr m_ProjFunc; ProjFuncPtr m_ProjFunc;
@ -1492,41 +1492,41 @@ public:
//Xml field: "center". //Xml field: "center".
T m_CenterX; T m_CenterX;
T m_CenterY; 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. //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". //Xml field: "rotate".
T m_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 //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. //rotated by this amount.
//Xml field: "hue". //Xml field: "hue".
T m_Hue; T m_Hue;
//Determine how bright to make the image during final accumulation. //Determine how bright to make the image during final accumulation.
//Xml field: "brightness". //Xml field: "brightness".
T m_Brightness; T m_Brightness;
//Gamma level used in gamma correction during final accumulation. //Gamma level used in gamma correction during final accumulation.
//Xml field: "gamma". //Xml field: "gamma".
T m_Gamma; T m_Gamma;
//Used in color correction during final accumulation. //Used in color correction during final accumulation.
//Xml field: "vibrancy". //Xml field: "vibrancy".
T m_Vibrancy; T m_Vibrancy;
//Gamma threshold used in gamma correction during final accumulation. //Gamma threshold used in gamma correction during final accumulation.
//Xml field: "gamma_threshold". //Xml field: "gamma_threshold".
T m_GammaThresh; T m_GammaThresh;
//Value to control saturation of some pixels in gamma correction during final accumulation. //Value to control saturation of some pixels in gamma correction during final accumulation.
//Xml field: "highlight_power". //Xml field: "highlight_power".
T m_HighlightPower; T m_HighlightPower;
//When animating a file full of many embers, this value is used to specify the time in the animation //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. //that this ember should be rendered. They must all be sequential and increase by a default value of 1.
//Xml field: "time". //Xml field: "time".
T m_Time; T m_Time;
//The background color of the image used in final accumulation, ranged 0-1. //The background color of the image used in final accumulation, ranged 0-1.
//Xml field: "background". //Xml field: "background".
Color<T> m_Background; Color<T> m_Background;
@ -1544,7 +1544,7 @@ public:
//The type of interpolation to use for the palette when interpolating embers for animation. //The type of interpolation to use for the palette when interpolating embers for animation.
//Xml field: "palette_interpolation". //Xml field: "palette_interpolation".
ePaletteInterp m_PaletteInterp; ePaletteInterp m_PaletteInterp;
//Temporal Filter. //Temporal Filter.
//Only used if temporal filter type is exp, else unused. //Only used if temporal filter type is exp, else unused.
@ -1564,11 +1564,11 @@ public:
//The minimum radius of the DE filter. //The minimum radius of the DE filter.
//Xml field: "estimator_minimum". //Xml field: "estimator_minimum".
T m_MinRadDE; T m_MinRadDE;
//The maximum radius of the DE filter. //The maximum radius of the DE filter.
//Xml field: "estimator_radius". //Xml field: "estimator_radius".
T m_MaxRadDE; 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. //The shape of the curve that governs how quickly or slowly the filter drops off as it moves away from the center point.
//Xml field: "estimator_curve". //Xml field: "estimator_curve".
T m_CurveDE; T m_CurveDE;
@ -1584,7 +1584,7 @@ public:
//Lanczos2, Mitchell, Blackman, Catrom, Hamming, Hanning, Quadratic. //Lanczos2, Mitchell, Blackman, Catrom, Hamming, Hanning, Quadratic.
//Xml field: "filter_shape". //Xml field: "filter_shape".
eSpatialFilterType m_SpatialFilterType; eSpatialFilterType m_SpatialFilterType;
//Palette. //Palette.
//The method used for retrieving a color from the palette when accumulating to the histogram: step, linear. //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; return a.m_Time < b.m_Time;
} }
} }

View File

@ -14,7 +14,7 @@
#endif #endif
#else #else
#define EMBER_API #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 _stat stat
#define _fstat fstat #define _fstat fstat
#define _stricmp strcmp #define _stricmp strcmp

View File

@ -146,7 +146,7 @@ public:
os << " rotate=\"" << ember.m_Rotate << "\""; os << " rotate=\"" << ember.m_Rotate << "\"";
os << " supersample=\"" << max(1u, ember.m_Supersample) << "\""; os << " supersample=\"" << max(1u, ember.m_Supersample) << "\"";
os << " filter=\"" << ember.m_SpatialFilterRadius << "\""; os << " filter=\"" << ember.m_SpatialFilterRadius << "\"";
os << " filter_shape=\"" << ToLower(SpatialFilterCreator<T>::ToString(ember.m_SpatialFilterType)) << "\""; os << " filter_shape=\"" << ToLower(SpatialFilterCreator<T>::ToString(ember.m_SpatialFilterType)) << "\"";
os << " temporal_filter_type=\"" << ToLower(TemporalFilterCreator<T>::ToString(ember.m_TemporalFilterType)) << "\""; 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 g = ember.m_Palette[i][1] * 255;
double b = ember.m_Palette[i][2] * 255; double b = ember.m_Palette[i][2] * 255;
double a = ember.m_Palette[i][3] * 255; double a = ember.m_Palette[i][3] * 255;
os << " "; os << " ";
//The original used a precision of 6 which is totally unnecessary, use 2. //The original used a precision of 6 which is totally unnecessary, use 2.
if (IsClose(a, 255.0)) 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 << ToString(xmlDocGetRootElement(ember.m_Edits), 1, true, printEditDepth);
os << "</flame>\n"; 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 /// 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. /// the user wants to capture the genetic lineage history information in the edit doc of the new ember.
/// </summary> /// </summary>
/// <param name="parent0">The first parent, optionally NULL.</param> /// <param name="parent0">The first parent, optionally nullptr.</param>
/// <param name="parent1">The second parent, optionally NULL.</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="action">The action that was taken to create the new ember</param>
/// <param name="nick">The nickname of the author</param> /// <param name="nick">The nickname of the author</param>
/// <param name="url">The Url of the author</param> /// <param name="url">The Url of the author</param>
@ -298,18 +298,18 @@ public:
char buffer[128]; char buffer[128];
char commentString[128]; char commentString[128];
time_t myTime; time_t myTime;
xmlDocPtr commentDoc = NULL; xmlDocPtr commentDoc = nullptr;
xmlDocPtr doc = xmlNewDoc(XC "1.0"); xmlDocPtr doc = xmlNewDoc(XC "1.0");
xmlNodePtr rootNode = NULL, node = NULL, nodeCopy = NULL; xmlNodePtr rootNode = nullptr, node = nullptr, nodeCopy = nullptr;
xmlNodePtr rootComment = NULL; xmlNodePtr rootComment = nullptr;
//Create the root node, called "edit". //Create the root node, called "edit".
rootNode = xmlNewNode(NULL, XC "edit"); rootNode = xmlNewNode(nullptr, XC "edit");
xmlDocSetRootElement(doc, rootNode); xmlDocSetRootElement(doc, rootNode);
//Add the edit attributes. //Add the edit attributes.
//Date. //Date.
myTime = time(NULL); myTime = time(nullptr);
#ifdef WIN32 #ifdef WIN32
tm localt; tm localt;
localtime_s(&localt, &myTime); localtime_s(&localt, &myTime);
@ -339,7 +339,7 @@ public:
if (sheepGen > 0 && sheepId > 0) if (sheepGen > 0 && sheepId > 0)
{ {
//Create a child node of the root node called sheep. //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. //Create the sheep attributes.
sprintf_s(buffer, 128, "%d", sheepGen); sprintf_s(buffer, 128, "%d", sheepGen);
@ -366,7 +366,7 @@ public:
else else
{ {
//Insert a (parent has no edit) message. //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); AddFilenameWithoutAmpersand(nodeCopy, parent0->m_ParentFilename);
sprintf_s(buffer, 128, "%d", parent0->m_Index); sprintf_s(buffer, 128, "%d", parent0->m_Index);
xmlNewProp(nodeCopy, XC "index", XC buffer); xmlNewProp(nodeCopy, XC "index", XC buffer);
@ -388,7 +388,7 @@ public:
else else
{ {
//Insert a (parent has no edit) message. //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); AddFilenameWithoutAmpersand(nodeCopy, parent1->m_ParentFilename);
sprintf_s(buffer, 128, "%d", parent1->m_Index); sprintf_s(buffer, 128, "%d", parent1->m_Index);
xmlNewProp(nodeCopy, XC "index", XC buffer); xmlNewProp(nodeCopy, XC "index", XC buffer);
@ -405,10 +405,10 @@ public:
if (comment != "") if (comment != "")
{ {
sprintf_s(commentString, 128, "<comm>%s</comm>", comment.c_str()); 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. //Check for errors.
if (commentDoc != NULL) if (commentDoc != nullptr)
{ {
//Loop through the children of the new document and copy them into the rootNode. //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* tabString = " ", *attStr;
const char* editString = "edit"; const char* editString = "edit";
const char* sheepString = "sheep"; const char* sheepString = "sheep";
unsigned int ti, editOrSheep = 0; unsigned int ti;//, editOrSheep = 0;
xmlAttrPtr attPtr = NULL, curAtt = NULL; xmlAttrPtr attPtr = nullptr, curAtt = nullptr;
xmlNodePtr childPtr = NULL, curChild = NULL; xmlNodePtr childPtr = nullptr, curChild = nullptr;
ostringstream os; ostringstream os;
if (printEditDepth > 0 && tabs > printEditDepth) if (printEditDepth > 0 && tabs > printEditDepth)
@ -589,13 +589,13 @@ private:
//If it's an edit node, add one to the tab. //If it's an edit node, add one to the tab.
if (!Compare(editNode->name, editString)) if (!Compare(editNode->name, editString))
{ {
editOrSheep = 1; //editOrSheep = 1;
tabs++; tabs++;
} }
else if (!Compare(editNode->name, sheepString)) else if (!Compare(editNode->name, sheepString)) { }
editOrSheep = 2; //editOrSheep = 2;
else else { }
editOrSheep = 0; //editOrSheep = 0;
//Print the attributes. //Print the attributes.
attPtr = editNode->properties; attPtr = editNode->properties;
@ -649,15 +649,15 @@ private:
//Child is a text node, don't want to indent more than once. //Child is a text node, don't want to indent more than once.
if (xmlIsBlankNode(curChild)) if (xmlIsBlankNode(curChild))
continue; continue;
if (!indentPrinted && formatting) if (!indentPrinted && formatting)
{ {
for (ti = 0; ti < tabs; ti++) for (ti = 0; ti < tabs; ti++)
os << tabString; os << tabString;
indentPrinted = true; indentPrinted = true;
} }
//Print nodes without formatting. //Print nodes without formatting.
os << ToString(curChild, tabs, false, printEditDepth); 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. for (xf = 0; xf < maxCount; xf++)//This will include both normal xforms and the final.
{ {
destXform = destEmbers[i].GetTotalXform(xf, 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. //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) if (i > 0)
destOtherXform = destEmbers[i - 1].GetTotalXform(xf); destOtherXform = destEmbers[i - 1].GetTotalXform(xf);
else if (i < count - 1) else if (i < count - 1)
destOtherXform = destEmbers[i + 1].GetTotalXform(xf); destOtherXform = destEmbers[i + 1].GetTotalXform(xf);
else else
destOtherXform = NULL;//Should never happen destOtherXform = nullptr;//Should never happen
if (destOtherXform) if (destOtherXform)
MergeXformVariations1Way(destOtherXform, destXform, true, true); MergeXformVariations1Way(destOtherXform, destXform, true, true);
@ -130,15 +130,15 @@ public:
//with weight -1. //with weight -1.
//Added JULIAN/JULIASCOPE to get rid of black wedges. //Added JULIAN/JULIASCOPE to get rid of black wedges.
if (destOtherXform->GetVariationById(VAR_SPHERICAL) || if (destOtherXform->GetVariationById(VAR_SPHERICAL) ||
destOtherXform->GetVariationById(VAR_NGON) || destOtherXform->GetVariationById(VAR_NGON) ||
destOtherXform->GetVariationById(VAR_JULIAN) || destOtherXform->GetVariationById(VAR_JULIAN) ||
destOtherXform->GetVariationById(VAR_JULIASCOPE) || destOtherXform->GetVariationById(VAR_JULIASCOPE) ||
destOtherXform->GetVariationById(VAR_POLAR) || destOtherXform->GetVariationById(VAR_POLAR) ||
destOtherXform->GetVariationById(VAR_WEDGE_SPH) || destOtherXform->GetVariationById(VAR_WEDGE_SPH) ||
destOtherXform->GetVariationById(VAR_WEDGE_JULIA)) destOtherXform->GetVariationById(VAR_WEDGE_JULIA))
{ {
destXform->AddVariation(new LinearVariation<T>(-1)); destXform->AddVariation(new LinearVariation<T>(-1));
//Set the coefs appropriately. //Set the coefs appropriately.
destXform->m_Affine.A(-1); destXform->m_Affine.A(-1);
destXform->m_Affine.D(0); destXform->m_Affine.D(0);
@ -244,7 +244,7 @@ public:
if (xf >= sourceEmbers[i + ii].TotalXformCount()) if (xf >= sourceEmbers[i + ii].TotalXformCount())
continue; continue;
Xform<T>* destOtherXform = destEmbers[i + ii].GetTotalXform(xf); destOtherXform = destEmbers[i + ii].GetTotalXform(xf);
if (destOtherXform->GetVariationById(VAR_FAN)) if (destOtherXform->GetVariationById(VAR_FAN))
{ {
@ -413,7 +413,7 @@ public:
while (embers[i1].m_Time < time) while (embers[i1].m_Time < time)
i1++; i1++;
i1--; i1--;
i2 = i1 + 1; i2 = i1 + 1;
} }
@ -437,7 +437,7 @@ public:
Align(&embers[i1], &localEmbers[0], 2); Align(&embers[i1], &localEmbers[0], 2);
smoothFlag = false; smoothFlag = false;
} }
if (i2 == size - 1) if (i2 == size - 1)
{ {
//fprintf(stderr, "error: cannot use smooth interpolation on last segment.\n"); //fprintf(stderr, "error: cannot use smooth interpolation on last segment.\n");
@ -445,7 +445,7 @@ public:
Align(&embers[i1], &localEmbers[0], 2); Align(&embers[i1], &localEmbers[0], 2);
smoothFlag = false; 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. 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; smoothFlag = true;
} }
@ -545,7 +545,7 @@ public:
static void InterpParametricVar(vector<ParametricVariation<T>*>& first, ParametricVariation<T>* second, vector<T>& c) 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. //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(); second->Clear();
ParamWithName<T>* secondParams = second->Params(); ParamWithName<T>* secondParams = second->Params();
@ -616,7 +616,7 @@ public:
//Establish the angles and magnitudes for each component. //Establish the angles and magnitudes for each component.
//Keep translation linear. //Keep translation linear.
zlm[0] = zlm[1] = 0; zlm[0] = zlm[1] = 0;
if (Xform<T>* xform = embers[k].GetTotalXform(xfi)) if (Xform<T>* xform = embers[k].GetTotalXform(xfi))
{ {
for (col = 0; col < 2; col++) for (col = 0; col < 2; col++)
@ -633,16 +633,16 @@ public:
c1[1] = xform->m_Post.m_Mat[1][col]; c1[1] = xform->m_Post.m_Mat[1][col];
t = xform->m_Post.m_Mat[col][2]; t = xform->m_Post.m_Mat[col][2];
} }
cxAng[k][col] = atan2(c1[1], c1[0]); cxAng[k][col] = atan2(c1[1], c1[0]);
cxMag[k][col] = sqrt(c1[0] * c1[0] + c1[1] * c1[1]); cxMag[k][col] = sqrt(c1[0] * c1[0] + c1[1] * c1[1]);
if (cxMag[k][col] == 0) if (cxMag[k][col] == 0)
zlm[col] = 1; zlm[col] = 1;
cxTrn[k][col] = t; cxTrn[k][col] = t;
} }
if (zlm[0] == 1 && zlm[1] == 0) if (zlm[0] == 1 && zlm[1] == 0)
cxAng[k][0] = cxAng[k][1]; cxAng[k][0] = cxAng[k][1];
else if (zlm[0] == 0 && zlm[1] == 1) else if (zlm[0] == 0 && zlm[1] == 1)
@ -671,7 +671,7 @@ public:
//Make sure both angles are within [refang refang + 2 * pi]. //Make sure both angles are within [refang refang + 2 * pi].
while(cxAng[k - 1][col] < refang) while(cxAng[k - 1][col] < refang)
cxAng[k - 1][col] += M_2PI; cxAng[k - 1][col] += M_2PI;
while(cxAng[k - 1][col] > refang + M_2PI) while(cxAng[k - 1][col] > refang + M_2PI)
cxAng[k - 1][col] -= 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[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]; c1[1] = embers[k].GetXform(xfi)->m_Affine.m_Mat[1][col];
cxang[k][col] = atan2(c1[1], c1[0]); cxang[k][col] = atan2(c1[1], c1[0]);
} }
} }
@ -772,7 +772,7 @@ public:
size_t size = coefs.size(); size_t size = coefs.size();
glm::length_t i, col, accmode[2] = { 0, 0 }; glm::length_t i, col, accmode[2] = { 0, 0 };
T expmag, accang[2] = { 0, 0 }, accmag[2] = { 0, 0 }; T expmag, accang[2] = { 0, 0 }, accmag[2] = { 0, 0 };
//Accumulation mode defaults to logarithmic, but in special //Accumulation mode defaults to logarithmic, but in special
//cases switch to linear accumulation. //cases switch to linear accumulation.
for (col = 0; col < 2; col++) for (col = 0; col < 2; col++)
@ -783,23 +783,23 @@ public:
accmode[col] = 1;//Mode set to linear interp. accmode[col] = 1;//Mode set to linear interp.
} }
} }
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
for (col = 0; col < 2; col++) for (col = 0; col < 2; col++)
{ {
accang[col] += coefs[i] * cxAng[i][col]; accang[col] += coefs[i] * cxAng[i][col];
if (accmode[col] == 0) if (accmode[col] == 0)
accmag[col] += coefs[i] * log(cxMag[i][col]); accmag[col] += coefs[i] * log(cxMag[i][col]);
else else
accmag[col] += coefs[i] * (cxMag[i][col]); accmag[col] += coefs[i] * (cxMag[i][col]);
//Translation is ready to go. //Translation is ready to go.
store.m_Mat[col][2] += coefs[i] * cxTrn[i][col]; store.m_Mat[col][2] += coefs[i] * cxTrn[i][col];
} }
} }
//Convert the angle back to rectangular. //Convert the angle back to rectangular.
for (col = 0; col < 2; col++) for (col = 0; col < 2; col++)
{ {
@ -807,7 +807,7 @@ public:
expmag = exp(accmag[col]); expmag = exp(accmag[col]);
else else
expmag = accmag[col]; expmag = accmag[col];
store.m_Mat[0][col] = expmag * cos(accang[col]); store.m_Mat[0][col] = expmag * cos(accang[col]);
store.m_Mat[1][col] = expmag * sin(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. //maxStag is the spacing between xform start times if staggerPercent = 1.0.
T maxStag = T(numXforms - 1) / numXforms; T maxStag = T(numXforms - 1) / numXforms;
//Scale the spacing by staggerPercent. //Scale the spacing by staggerPercent.
T stagScaled = staggerPercent * maxStag; T stagScaled = staggerPercent * maxStag;
@ -845,7 +845,7 @@ public:
//The second line makes the last xform interpolate first. //The second line makes the last xform interpolate first.
T st = stagScaled * (numXforms - 1 - thisXform) / (numXforms - 1); T st = stagScaled * (numXforms - 1 - thisXform) / (numXforms - 1);
T et = st + (1 - stagScaled); T et = st + (1 - stagScaled);
if (t <= st) if (t <= st)
return 0; return 0;
else if (t >= et) else if (t >= et)
@ -871,17 +871,17 @@ public:
else if (funcNum == MOTION_TRIANGLE) else if (funcNum == MOTION_TRIANGLE)
{ {
T fr = fmod(timeVal, T(1.0)); T fr = fmod(timeVal, T(1.0));
if (fr < 0) if (fr < 0)
fr += 1; fr += 1;
if (fr <= T(0.25)) if (fr <= T(0.25))
fr *= 4; fr *= 4;
else if (fr <= T(0.75)) else if (fr <= T(0.75))
fr = -4 * fr + 2; fr = -4 * fr + 2;
else else
fr = 4 * fr - 4; fr = 4 * fr - 4;
return fr; return fr;
} }
else//MOTION_HILL else//MOTION_HILL
@ -889,7 +889,7 @@ public:
return ((1 - cos(T(2.0) * T(M_PI) * timeVal)) * T(0.5)); return ((1 - cos(T(2.0) * T(M_PI) * timeVal)) * T(0.5));
} }
} }
/* /*
//Will need to alter this to handle 2D palettes. //Will need to alter this to handle 2D palettes.
static bool InterpMissingColors(vector<glm::detail::tvec4<T>>& palette) static bool InterpMissingColors(vector<glm::detail::tvec4<T>>& palette)
@ -914,18 +914,18 @@ public:
break; break;
} }
} }
if (i == 256) if (i == 256)
{ {
//No colors. Set all indices properly. //No colors. Set all indices properly.
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
palette[i].m_Index = (T)i; palette[i].m_Index = (T)i;
return false; return false;
} }
wrapMin = minIndex + 256; wrapMin = minIndex + 256;
for (i = 255; i >= 0; i--)//Moving backwards, ouch! for (i = 255; i >= 0; i--)//Moving backwards, ouch!
{ {
if (palette[i].m_Index >= 0) if (palette[i].m_Index >= 0)
@ -934,9 +934,9 @@ public:
break; break;
} }
} }
wrapMax = maxIndex - 256; wrapMax = maxIndex - 256;
//Loop over the indices looking for negs, //Loop over the indices looking for negs,
i = 0; i = 0;
@ -956,29 +956,29 @@ public:
colorri = intr; colorri = intr;
i++; i++;
} }
if (intl == -1) if (intl == -1)
{ {
intl = wrapMax; intl = wrapMax;
colorli = maxIndex; colorli = maxIndex;
} }
if (intr == 256) if (intr == 256)
{ {
intr = wrapMin; intr = wrapMin;
colorri = minIndex; colorri = minIndex;
} }
for (j = str; j <= enr; j++) for (j = str; j <= enr; j++)
{ {
prcr = (j - intl) / T(intr - intl); prcr = (j - intl) / T(intr - intl);
for (k = 0; k <= 3; k++) for (k = 0; k <= 3; k++)
palette[j].Channels[k] = T(palette[colorli].Channels[k] * (1 - prcr) + palette[colorri].Channels[k] * prcr); palette[j].Channels[k] = T(palette[colorli].Channels[k] * (1 - prcr) + palette[colorri].Channels[k] * prcr);
palette[j].m_Index = T(j); palette[j].m_Index = T(j);
} }
i = colorri + 1; i = colorri + 1;
} }
else else
@ -1020,4 +1020,4 @@ public:
return ad > bd; return ad > bd;
} }
}; };
} }

View File

@ -5,29 +5,29 @@
/// <summary> /// <summary>
/// C++ TEMPLATE VERSION OF Robert J. Jenkins Jr.'s /// C++ TEMPLATE VERSION OF Robert J. Jenkins Jr.'s
/// ISAAC Random Number Generator. /// ISAAC Random Number Generator.
/// ///
/// Ported from vanilla C to to template C++ class /// Ported from vanilla C to to template C++ class
/// by Quinn Tyler Jackson on 16-23 July 1998. /// by Quinn Tyler Jackson on 16-23 July 1998.
/// ///
/// quinn@qtj.net /// quinn@qtj.net
/// ///
/// The function for the expected period of this /// The function for the expected period of this
/// random number generator, according to Jenkins is: /// random number generator, according to Jenkins is:
/// ///
/// f(a,b) = 2**((a+b*(3+2^^a)-1) /// f(a,b) = 2**((a+b*(3+2^^a)-1)
/// ///
/// (where a is ALPHA and b is bitwidth) /// (where a is ALPHA and b is bitwidth)
/// ///
/// So, for a bitwidth of 32 and an ALPHA of 8, /// So, for a bitwidth of 32 and an ALPHA of 8,
/// the expected period of ISAAC is: /// the expected period of ISAAC is:
/// ///
/// 2^^(8+32*(3+2^^8)-1) = 2^^8295 /// 2^^(8+32*(3+2^^8)-1) = 2^^8295
/// ///
/// Jackson has been able to run implementations /// Jackson has been able to run implementations
/// with an ALPHA as high as 16, or /// with an ALPHA as high as 16, or
/// ///
/// 2^^2097263 /// 2^^2097263
/// ///
/// -Modified by Matt Feemster to eliminate needless dynamic memory allocation and virtual functions and bring inline with Ember coding style. /// -Modified by Matt Feemster to eliminate needless dynamic memory allocation and virtual functions and bring inline with Ember coding style.
/// </summary> /// </summary>
@ -38,13 +38,13 @@
typedef uint64_t ISAAC_INT; typedef uint64_t ISAAC_INT;
const ISAAC_INT GOLDEN_RATIO = ISAAC_INT(0x9e3779b97f4a7c13); const ISAAC_INT GOLDEN_RATIO = ISAAC_INT(0x9e3779b97f4a7c13);
#endif #endif
namespace EmberNs namespace EmberNs
{ {
/// <summary> /// <summary>
/// QTIsaac class which allows using ISAAC in an OOP manner. /// QTIsaac class which allows using ISAAC in an OOP manner.
/// </summary> /// </summary>
template <int ALPHA = 4, class T = ISAAC_INT> template <int ALPHA = 4, class T = ISAAC_INT>
class EMBER_API QTIsaac class EMBER_API QTIsaac
{ {
public: public:
@ -69,7 +69,7 @@ public:
T randb; T randb;
T randc; T randc;
}; };
/// <summary> /// <summary>
/// Constructor which initialized the random context using the values passed in. /// Constructor which initialized the random context using the values passed in.
/// Leaving these as their defaults is fine, and will still give different /// 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="a">First random seed. Default: 0.</param>
/// <param name="b">Second 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="c">Third random seed. Default: 0.</param>
/// <param name="s">Pointer to a buffer of 256 random integer seeds. Default: NULL.</param> /// <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 = NULL) QTIsaac(T a = 0, T b = 0, T c = 0, T* s = nullptr)
{ {
Srand(a, b, c, s); Srand(a, b, c, s);
} }
@ -193,44 +193,44 @@ public:
T a, b, c, d, e, f, g, h; T a, b, c, d, e, f, g, h;
T* m = ctx->randmem; T* m = ctx->randmem;
T* r = ctx->randrsl; T* r = ctx->randrsl;
a = b = c = d = e = f = g = h = GOLDEN_RATIO; a = b = c = d = e = f = g = h = GOLDEN_RATIO;
if (!useSeed) if (!useSeed)
{ {
ctx->randa = 0; ctx->randa = 0;
ctx->randb = 0; ctx->randb = 0;
ctx->randc = 0; ctx->randc = 0;
} }
//Scramble it. //Scramble it.
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
Shuffle(a, b, c, d, e, f, g, h); Shuffle(a, b, c, d, e, f, g, h);
} }
if (useSeed) if (useSeed)
{ {
//Initialize using the contents of r[] as the seed. //Initialize using the contents of r[] as the seed.
for (i = 0; i < N; i += 8) for (i = 0; i < N; i += 8)
{ {
a += r[i ]; b += r[i + 1]; c += r[i + 2]; d += r[i + 3]; 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]; 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); 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 ] = 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; 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. //Do a second pass to make all of the seed affect all of m.
for (i = 0; i < N; i += 8) for (i = 0; i < N; i += 8)
{ {
a += m[i ]; b += m[i + 1]; c += m[i + 2]; d += m[i + 3]; 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]; 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); 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 ] = 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; 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. //Fill in mm[] with messy stuff.
Shuffle(a, b, c, d, e, f, g, h); 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 ] = 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; 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. Isaac(ctx); //Fill in the first set of results.
ctx->randcnt = N;//TODO//0;//Prepare to use 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="a">First random seed. Default: 0.</param>
/// <param name="b">Second 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="c">Third random seed. Default: 0.</param>
/// <param name="s">Pointer to a buffer of 256 random integer seeds. Default: NULL.</param> /// <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 = NULL) 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++) for (int i = 0; i < N; i++)
m_Rc.randrsl[i] = (T)time(0) + i; m_Rc.randrsl[i] = (T)time(0) + i;
@ -272,9 +272,9 @@ public:
#ifndef ISAAC_FLAM3_DEBUG #ifndef ISAAC_FLAM3_DEBUG
if (a == 0 && b == 0 && c == 0) if (a == 0 && b == 0 && c == 0)
{ {
m_Rc.randa = (T)time(0); m_Rc.randa = (T)time(nullptr);
m_Rc.randb = (T)time(0) * (T)time(0); m_Rc.randb = (T)time(nullptr) * (T)time(nullptr);
m_Rc.randc = (T)time(0) * (T)time(0) * (T)time(0); m_Rc.randc = (T)time(nullptr) * (T)time(nullptr) * (T)time(nullptr);
} }
else else
#endif #endif
@ -283,10 +283,10 @@ public:
m_Rc.randb = b; m_Rc.randb = b;
m_Rc.randc = c; m_Rc.randc = c;
} }
RandInit(&m_Rc, true); RandInit(&m_Rc, true);
} }
protected: protected:
/// <summary> /// <summary>
/// Compute the next batch of random numbers for a random context. /// Compute the next batch of random numbers for a random context.
@ -295,17 +295,17 @@ protected:
void Isaac(randctx* ctx) void Isaac(randctx* ctx)
{ {
T x,y; T x,y;
T* mm = ctx->randmem; T* mm = ctx->randmem;
T* r = ctx->randrsl; T* r = ctx->randrsl;
T a = (ctx->randa); T a = (ctx->randa);
T b = (ctx->randb + (++ctx->randc)); T b = (ctx->randb + (++ctx->randc));
T* m = mm; T* m = mm;
T* m2 = (m + (N / 2)); T* m2 = (m + (N / 2));
T* mend = m2; T* mend = m2;
for(; m < mend; ) for(; m < mend; )
{ {
#ifndef __ISAAC64 #ifndef __ISAAC64
@ -320,9 +320,9 @@ protected:
RngStep( a ^ (a >> 33) , a, b, mm, m, m2, r, x, y); RngStep( a ^ (a >> 33) , a, b, mm, m, m2, r, x, y);
#endif // __ISAAC64 #endif // __ISAAC64
} }
m2 = mm; m2 = mm;
for(; m2<mend;) for(; m2<mend;)
{ {
#ifndef __ISAAC64 #ifndef __ISAAC64
@ -337,11 +337,11 @@ protected:
RngStep( a ^ (a >> 33) , a, b, mm, m, m2, r, x, y); RngStep( a ^ (a >> 33) , a, b, mm, m, m2, r, x, y);
#endif // __ISAAC64 #endif // __ISAAC64
} }
ctx->randb = b; ctx->randb = b;
ctx->randa = a; ctx->randa = a;
} }
/// <summary> /// <summary>
/// Retrieves a value using indirection. /// Retrieves a value using indirection.
/// </summary> /// </summary>
@ -362,26 +362,26 @@ protected:
/// </summary> /// </summary>
void RngStep(T mix, T& a, T& b, T*& mm, T*& m, T*& m2, T*& r, T& x, T& y) void RngStep(T mix, T& a, T& b, T*& mm, T*& m, T*& m2, T*& r, T& x, T& y)
{ {
x = *m; x = *m;
a = (a ^ (mix)) + *(m2++); a = (a ^ (mix)) + *(m2++);
*(m++) = y = Ind(mm, x) + a + b; *(m++) = y = Ind(mm, x) + a + b;
*(r++) = b = Ind(mm, y >> ALPHA) + x; *(r++) = b = Ind(mm, y >> ALPHA) + x;
} }
/// <summary> /// <summary>
/// Unsure what this does. /// Unsure what this does.
/// </summary> /// </summary>
void Shuffle(T& a, T& b, T& c, T& d, T& e, T& f, T& g, T& h) void Shuffle(T& a, T& b, T& c, T& d, T& e, T& f, T& g, T& h)
{ {
#ifndef __ISAAC64 #ifndef __ISAAC64
a ^= b << 11; d += a; b += c; a ^= b << 11; d += a; b += c;
b ^= c >> 2; e += b; c += d; b ^= c >> 2; e += b; c += d;
c ^= d << 8; f += c; d += e; c ^= d << 8; f += c; d += e;
d ^= e >> 16; g += d; e += f; d ^= e >> 16; g += d; e += f;
e ^= f << 10; h += e; f += g; e ^= f << 10; h += e; f += g;
f ^= g >> 4; a += f; g += h; f ^= g >> 4; a += f; g += h;
g ^= h << 8; b += g; h += a; g ^= h << 8; b += g; h += a;
h ^= a >> 9; c += h; a += b; h ^= a >> 9; c += h; a += b;
#else // __ISAAC64 #else // __ISAAC64
a -= e; f ^= h >> 9; h += a; a -= e; f ^= h >> 9; h += a;
b -= f; g ^= a << 9; a += b; b -= f; g ^= a << 9; a += b;
@ -393,8 +393,8 @@ protected:
h -= d; e ^= g << 14; g += h; h -= d; e ^= g << 14; g += h;
#endif // __ISAAC64 #endif // __ISAAC64
} }
private: private:
randctx m_Rc;//The random context which holds all of the seed and state information as well as the random number values. 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> /// <summary>
/// Accessors. /// Accessors.
/// </summary> /// </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(); } const unsigned int XformDistributionsSize() const { return (unsigned int)m_XformDistributions.size(); }
/// <summary> /// <summary>
@ -70,7 +70,7 @@ public:
/// <param name="rand">The random context to use</param> /// <param name="rand">The random context to use</param>
/// <returns>The number of bad values</returns> /// <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; } 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> /// <summary>
/// Initialize the xform selection vector by normalizing the weights of all xforms and /// 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 /// 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++) for (i = 0; i < ember.XformCount(); i++)
{ {
T d = xforms[i].m_Weight; T d = xforms[i].m_Weight;
if (distrib > 0) if (distrib > 0)
d *= xforms[distrib - 1].Xaos(i); d *= xforms[distrib - 1].Xaos(i);
@ -124,12 +124,12 @@ public:
for (i = 0; i < ember.XformCount(); i++) for (i = 0; i < ember.XformCount(); i++)
{ {
T temp = xforms[i].m_Weight; T temp = xforms[i].m_Weight;
if (distrib > 0) if (distrib > 0)
temp *= xforms[distrib - 1].Xaos(i); temp *= xforms[distrib - 1].Xaos(i);
currentDensityLimit += temp; currentDensityLimit += temp;
//Populate points corresponding to this xform's weight/density. //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. //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) while (tempDensity < currentDensityLimit && j < CHOOSE_XFORM_GRAIN)
@ -169,7 +169,7 @@ public:
return true; return true;
} }
protected: protected:
/// <summary> /// <summary>
/// When iterating, if the computed location of the point is either very close to zero, or very close to infinity, /// 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 /// 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> /// <summary>
/// Retrieve an element in the distributions vector between 0 and CHOOSE_XFORM_GRAIN which will /// 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. /// the ember of the previous xform used when.
/// </summary> /// </summary>
/// <param name="index">The index to retrieve</param> /// <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. 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. 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. 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; unsigned int consec = 0;
Point<T> firstBadPoint; Point<T> firstBadPoint;
while (consec < 5) while (consec < 5)
{ {
consec++; consec++;
@ -468,11 +468,11 @@ public:
DoFinalXform(ember, p1, samples, rand);//Apply to last fuse point and store as the first element in samples. DoFinalXform(ember, p1, samples, rand);//Apply to last fuse point and store as the first element in samples.
ember.Proj(samples[0], rand); ember.Proj(samples[0], rand);
for (i = 1; i < count; i++)//Real loop. for (i = 1; i < count; i++)//Real loop.
{ {
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed); 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. 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); DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -520,7 +520,7 @@ public:
for (i = 0; i < skip; i++)//Fuse. for (i = 0; i < skip; i++)//Fuse.
{ {
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed); xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(&p1, &p1, rand)) if (xforms[xformIndex].Apply(&p1, &p1, rand))
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand); DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -532,7 +532,7 @@ public:
for (i = 1; i < count; i++)//Real loop. for (i = 1; i < count; i++)//Real loop.
{ {
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed); 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. 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); DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -547,7 +547,7 @@ public:
for (i = 0; i < skip; i++)//Fuse. for (i = 0; i < skip; i++)//Fuse.
{ {
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed); xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(&p1, &p1, rand)) if (xforms[xformIndex].Apply(&p1, &p1, rand))
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand); DoBadVals(xforms, xformIndex, lastXformUsed, badVals, &p1, rand);
@ -559,7 +559,7 @@ public:
for (i = 0; i < count - 1; i++)//Real loop. for (i = 0; i < count - 1; i++)//Real loop.
{ {
xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed); xformIndex = NextXformFromIndex(rand.Rand(), lastXformUsed);
if (xforms[xformIndex].Apply(samples + i, samples + i + 1, rand)) if (xforms[xformIndex].Apply(samples + i, samples + i + 1, rand))
DoBadVals(xforms, xformIndex, lastXformUsed, badVals, samples + i + 1, rand); DoBadVals(xforms, xformIndex, lastXformUsed, badVals, samples + i + 1, rand);
@ -571,4 +571,4 @@ public:
return badVals; return badVals;
} }
}; };
} }

View File

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

View File

@ -45,9 +45,9 @@ public:
if (ReadFile(filename.c_str(), buf)) 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); xmlNode* rootNode = xmlDocGetRootElement(doc);
@ -74,7 +74,7 @@ public:
/// Gets the palette at a specified index. /// Gets the palette at a specified index.
/// </summary> /// </summary>
/// <param name="i">The index of the palette to read. A value of -1 indicates a random palette.</param> /// <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) Palette<T>* GetPalette(int i)
{ {
if (!m_Palettes.empty()) if (!m_Palettes.empty())
@ -85,21 +85,21 @@ public:
return &m_Palettes[i]; return &m_Palettes[i];
} }
return NULL; return nullptr;
} }
/// <summary> /// <summary>
/// Gets a pointer to a palette with a specified name. /// Gets a pointer to a palette with a specified name.
/// </summary> /// </summary>
/// <param name="name">The name of the palette to retrieve</param> /// <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) Palette<T>* GetPaletteByName(string& name)
{ {
for (unsigned int i = 0; i < Count(); i++) for (unsigned int i = 0; i < Count(); i++)
if (m_Palettes[i].m_Name == name) if (m_Palettes[i].m_Name == name)
return &m_Palettes[i]; return &m_Palettes[i];
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -166,7 +166,7 @@ private:
if (!Compare(attr->name, "data")) if (!Compare(attr->name, "data"))
{ {
int colorIndex = 0; int colorIndex = 0;
int r, g, b; unsigned int r, g, b;
int colorCount = 0; int colorCount = 0;
hexError = false; 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 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. 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); a = norm ? T(1) : T(255);
} }
}; };
} }

View File

@ -23,11 +23,11 @@ Renderer<T, bucketT>::Renderer()
m_PixelAspectRatio = 1; m_PixelAspectRatio = 1;
m_Transparency = false; m_Transparency = false;
ThreadCount(Timing::ProcessorCount()); ThreadCount(Timing::ProcessorCount());
m_StandardIterator = auto_ptr<StandardIterator<T>>(new StandardIterator<T>()); m_StandardIterator = unique_ptr<StandardIterator<T>>(new StandardIterator<T>());
m_XaosIterator = auto_ptr<XaosIterator<T>>(new XaosIterator<T>()); m_XaosIterator = unique_ptr<XaosIterator<T>>(new XaosIterator<T>());
m_Iterator = m_StandardIterator.get(); m_Iterator = m_StandardIterator.get();
m_Callback = NULL; m_Callback = nullptr;
m_ProgressParameter = NULL; m_ProgressParameter = nullptr;
m_LastPass = 0; m_LastPass = 0;
m_LastTemporalSample = 0; m_LastTemporalSample = 0;
m_LastIter = 0; m_LastIter = 0;
@ -60,7 +60,7 @@ void Renderer<T, bucketT>::ComputeBounds()
m_GutterWidth = ClampGte((m_SpatialFilter->FinalFilterWidth() - Supersample()) / 2, 0u); m_GutterWidth = ClampGte((m_SpatialFilter->FinalFilterWidth() - Supersample()) / 2, 0u);
//Check the size of the density estimation filter. //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. //gutter width, have to pad with more. Otherwise, use the same value.
for (unsigned int i = 0; i < m_Embers.size(); i++) 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); 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(); Abort();
EnterRender(); EnterRender();
func(); func();
//If they want a full render, don't bother inspecting process state, just start over. //If they want a full render, don't bother inspecting process state, just start over.
if (action == FULL_RENDER) if (action == FULL_RENDER)
{ {
@ -138,7 +138,7 @@ void Renderer<T, bucketT>::ChangeVal(std::function<void (void)> func, eProcessAc
m_ProcessAction = FULL_RENDER; m_ProcessAction = FULL_RENDER;
} }
//Keep iterating is when rendering has completed and the user increases the quality. //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. //new and old quality values.
else if (action == KEEP_ITERATING) else if (action == KEEP_ITERATING)
{ {
@ -190,7 +190,7 @@ void Renderer<T, bucketT>::ChangeVal(std::function<void (void)> func, eProcessAc
m_ProcessAction = ACCUM_ONLY; m_ProcessAction = ACCUM_ONLY;
} }
} }
LeaveRender(); LeaveRender();
} }
@ -209,7 +209,7 @@ template <typename T, typename bucketT>
void Renderer<T, bucketT>::SetEmber(Ember<T>& ember, eProcessAction action) void Renderer<T, bucketT>::SetEmber(Ember<T>& ember, eProcessAction action)
{ {
ChangeVal([&] ChangeVal([&]
{ {
m_Embers.clear(); m_Embers.clear();
m_Embers.push_back(ember); 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. 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. /// from the last temporal filter created.
/// </summary> /// </summary>
/// <param name="newAlloc">True if a new filter instance was created, else false.</param> /// <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> template <typename T, typename bucketT>
bool Renderer<T, bucketT>::CreateTemporalFilter(bool& newAlloc) 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_TemporalFilterWidth != m_TemporalFilter->FilterWidth()) ||
(m_Ember.m_TemporalFilterExp != m_TemporalFilter->FilterExp())) (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)); 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; newAlloc = true;
} }
return m_TemporalFilter.get() != NULL; return m_TemporalFilter.get() != nullptr;
} }
/// <summary> /// <summary>
@ -363,7 +363,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<unsigned char>& finalImage, doubl
bool accumOnly = m_ProcessAction == ACCUM_ONLY; bool accumOnly = m_ProcessAction == ACCUM_ONLY;
bool resume = m_ProcessState != NONE; bool resume = m_ProcessState != NONE;
bool newFilterAlloc; bool newFilterAlloc;
unsigned int temporalSample, pass; unsigned int temporalSample = 0, pass;
T deTime; T deTime;
eRenderStatus success = RENDER_OK; eRenderStatus success = RENDER_OK;
//double iterationTime = 0; //double iterationTime = 0;
@ -419,10 +419,10 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<unsigned char>& finalImage, doubl
m_Vibrancy = m_Ember.m_Vibrancy; m_Vibrancy = m_Ember.m_Vibrancy;
m_Gamma = m_Ember.m_Gamma; m_Gamma = m_Ember.m_Gamma;
m_Background = m_Ember.m_Background; m_Background = m_Ember.m_Background;
if (filterAndAccumOnly) if (filterAndAccumOnly)
goto FilterAndAccum; goto FilterAndAccum;
if (accumOnly) if (accumOnly)
goto AccumOnly; goto AccumOnly;
} }
@ -442,7 +442,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<unsigned char>& finalImage, doubl
CreateTemporalFilter(newFilterAlloc); CreateTemporalFilter(newFilterAlloc);
ComputeBounds(); 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"); m_ErrorReport.push_back("Spatial and temporal filter allocations failed, aborting.\n");
success = RENDER_ERROR; 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. //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(). //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. //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 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. uint64_t sampleItersToDo;//The number of iterations to actually do in this sample in this pass, considering overrides.
@ -596,7 +595,7 @@ FilterAndAccum:
} }
else else
m_K2 = (Supersample() * Supersample() * Passes()) / (area * m_ScaledQuality * m_TemporalFilter->SumFilt()); m_K2 = (Supersample() * Supersample() * Passes()) / (area * m_ScaledQuality * m_TemporalFilter->SumFilt());
if (filterAndAccumOnly || pass == 0) if (filterAndAccumOnly || pass == 0)
ResetBuckets(false, true);//Only the histogram was reset above, now reset the density filtering buffer. ResetBuckets(false, true);//Only the histogram was reset above, now reset the density filtering buffer.
//t.Tic(); //t.Tic();
@ -645,7 +644,7 @@ FilterAndAccum:
//Also skip if rendering jumped straight here after completely finishing beforehand. //Also skip if rendering jumped straight here after completely finishing beforehand.
if (!filterAndAccumOnly && temporalSample >= TemporalSamples())//This may not work if filtering was prematurely exited. if (!filterAndAccumOnly && temporalSample >= TemporalSamples())//This may not work if filtering was prematurely exited.
pass++; pass++;
if (!filterAndAccumOnly) if (!filterAndAccumOnly)
m_LastPass = pass; m_LastPass = pass;
@ -662,14 +661,14 @@ AccumOnly:
success = RENDER_ABORT; success = RENDER_ABORT;
goto Finish; goto Finish;
} }
//Make sure a filter has been created. //Make sure a filter has been created.
CreateSpatialFilter(newFilterAlloc); CreateSpatialFilter(newFilterAlloc);
if (AccumulatorToFinalImage(finalImage, finalOffset) == RENDER_OK) 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. 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. //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). //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; m_LastEmber = m_Ember;
@ -786,7 +785,7 @@ uint64_t Renderer<T, bucketT>::MemoryAvailable()
static int mib[2] = { CTL_HW, HW_PHYSMEM }; static int mib[2] = { CTL_HW, HW_PHYSMEM };
#endif #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; memAvailable = physmem;
} }
@ -840,7 +839,7 @@ bool Renderer<T, bucketT>::Ok() const
/// log scale filtering will be used. /// log scale filtering will be used.
/// </summary> /// </summary>
/// <param name="newAlloc">True if a new filter instance was created, else false.</param> /// <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> template <typename T, typename bucketT>
bool Renderer<T, bucketT>::CreateDEFilter(bool& newAlloc) 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_CurveDE != m_DensityFilter->Curve()) ||
(m_Ember.m_Supersample != m_DensityFilter->Supersample())) (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; newAlloc = true;
} }
@ -882,7 +881,7 @@ bool Renderer<T, bucketT>::CreateDEFilter(bool& newAlloc)
/// from the last spatial filter created. /// from the last spatial filter created.
/// </summary> /// </summary>
/// <param name="newAlloc">True if a new filter instance was created, else false.</param> /// <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> template <typename T, typename bucketT>
bool Renderer<T, bucketT>::CreateSpatialFilter(bool& newAlloc) 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_Ember.m_Supersample != m_SpatialFilter->Supersample()) ||
(m_PixelAspectRatio != m_SpatialFilter->PixelAspectRatio())) (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)); SpatialFilterCreator<T>::Create(m_Ember.m_SpatialFilterType, m_Ember.m_SpatialFilterRadius, m_Ember.m_Supersample, m_PixelAspectRatio));
newAlloc = true; newAlloc = true;
} }
return m_SpatialFilter.get() != NULL; return m_SpatialFilter.get() != nullptr;
} }
/// <summary> /// <summary>
@ -972,7 +971,7 @@ unsigned int Renderer<T, bucketT>::ThreadCount() const { return m_ThreadsToUse;
/// Reset the rendering process. /// Reset the rendering process.
/// </summary> /// </summary>
/// <param name="threads">The number of threads to use</param> /// <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> template <typename T, typename bucketT>
void Renderer<T, bucketT>::ThreadCount(unsigned int threads, const char* seedString) 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) parallel_for(startRow, endRow, [&] (unsigned int j)
{ {
unsigned int row = j * m_SuperRasW; unsigned int row = j * m_SuperRasW;
for (unsigned int i = startCol; (i < endCol) && !m_Abort; i++) for (unsigned int i = startCol; (i < endCol) && !m_Abort; i++)
{ {
unsigned int index = row + i; unsigned int index = row + i;
@ -1240,7 +1239,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
unsigned int startCol = Supersample() - 1; unsigned int startCol = Supersample() - 1;
unsigned int endCol = m_SuperRasW - (Supersample() - 1); unsigned int endCol = m_SuperRasW - (Supersample() - 1);
unsigned int chunkSize = (unsigned int)ceil(double(endRow - startRow) / double(threads)); 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 scales very well, dividing the work almost perfectly among all processors.
parallel_for((unsigned int)0, threads, [&] (unsigned int threadIndex) 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. //Only have to calculate the values for ~1/8 of the square.
filterCoefIndex = filterSelectInt * m_DensityFilter->KernelSize(); filterCoefIndex = filterSelectInt * m_DensityFilter->KernelSize();
arrFilterWidth = (int)ceil(filterWidths[filterSelectInt]) - 1; arrFilterWidth = (int)ceil(filterWidths[filterSelectInt]) - 1;
for (jj = 0; jj <= arrFilterWidth; jj++) for (jj = 0; jj <= arrFilterWidth; jj++)
{ {
for (ii = 0; ii <= jj; ii++, filterCoefIndex++) for (ii = 0; ii <= jj; ii++, filterCoefIndex++)
@ -1369,7 +1368,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1)) if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1))
{ {
double etaMs = ((100.0 - percent) / percent) * totalTime.Toc(); double etaMs = ((100.0 - percent) / percent) * totalTime.Toc();
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 1, etaMs)) if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 1, etaMs))
Abort(); Abort();
@ -1379,7 +1378,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
} }
} }
}); });
if (m_Callback && !m_Abort) if (m_Callback && !m_Abort)
m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, 100.0, 1, 0); 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)) if (PrepFinalAccumVector(pixels))
return AccumulatorToFinalImage(pixels.data(), finalOffset); return AccumulatorToFinalImage(pixels.data(), finalOffset);
return RENDER_ERROR; 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) parallel_for((unsigned int)0, m_SuperRasH, [&] (unsigned int j)
{ {
unsigned int rowStart = j * m_SuperRasW;//Pull out of inner loop for optimization. unsigned int rowStart = j * m_SuperRasW;//Pull out of inner loop for optimization.
for (unsigned int i = 0; i < m_SuperRasW && !m_Abort; i++) 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. 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 ii, jj;
unsigned int x = m_DensityFilterOffset + (i * Supersample());//Start at the beginning column of each super sample block. unsigned int x = m_DensityFilterOffset + (i * Supersample());//Start at the beginning column of each super sample block.
newBucket.Clear(); newBucket.Clear();
//Original was iterating column-wise, which is slow. //Original was iterating column-wise, which is slow.
//Here, iterate one row at a time, giving a 10% speed increase. //Here, iterate one row at a time, giving a 10% speed increase.
for (jj = 0; jj < filterWidth; jj++) for (jj = 0; jj < filterWidth; jj++)
{ {
unsigned int filterKRowIndex = jj * filterWidth; unsigned int filterKRowIndex = jj * filterWidth;
unsigned int accumRowIndex = (y + jj) * m_SuperRasW;//Pull out of inner loop for optimization. unsigned int accumRowIndex = (y + jj) * m_SuperRasW;//Pull out of inner loop for optimization.
for (ii = 0; ii < filterWidth; ii++) for (ii = 0; ii < filterWidth; ii++)
{ {
//Need to dereference the spatial filter pointer object to use the [] operator. Makes no speed difference. //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); newBucket += (m_AccumulatorBuckets[(x + ii) + accumRowIndex] * k);
} }
} }
if (BytesPerChannel() == 2) if (BytesPerChannel() == 2)
{ {
p16 = (unsigned short*)(pixels + pixelsRowStart); 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. //Insert the palette into the image for debugging purposes. Only works with 8bpc.
if (m_InsertPalette && BytesPerChannel() == 1) if (m_InsertPalette && BytesPerChannel() == 1)
{ {
@ -1532,7 +1531,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(unsigned char* pixel
if (ph >= FinalRasH()) if (ph >= FinalRasH())
ph = FinalRasH(); ph = FinalRasH();
for (j = 0; j < ph; j++) for (j = 0; j < ph; j++)
{ {
for (i = 0; i < FinalRasW(); i++) for (i = 0; i < FinalRasW(); i++)
@ -1621,7 +1620,7 @@ EmberStats Renderer<T, bucketT>::Iterate(uint64_t iterCount, unsigned int pass,
//accumulationTime += t.Toc(); //accumulationTime += t.Toc();
if (m_LockAccum) if (m_LockAccum)
m_AccumCs.Leave(); m_AccumCs.Leave();
if (m_Callback && threadIndex == 0) if (m_Callback && threadIndex == 0)
{ {
percent = 100.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%). 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(); etaMs = ((100.0 - percent) / percent) * m_RenderTimer.Toc();
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 0, etaMs)) if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 0, etaMs))
Abort(); Abort();
@ -1681,7 +1680,7 @@ EmberStats Renderer<T, bucketT>::Iterate(uint64_t iterCount, unsigned int pass,
/// </summary> /// </summary>
/// <returns>The vector of random contexts to assign</returns> /// <returns>The vector of random contexts to assign</returns>
template <typename T, typename bucketT> 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> /// <summary>
/// Set the vector of random contexts. /// Set the vector of random contexts.
@ -1706,7 +1705,7 @@ bool Renderer<T, bucketT>::RandVec(vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>>& randV
} }
return b; return b;
}; }
/// <summary> /// <summary>
/// Get whether the histogram is locked during accumulation. /// 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]); 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. //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. //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. //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. //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) if (samples[i].m_VizAdjusted != 0)
{ {
m_CarToRas.Convert(samples[i], histIndex); 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, //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. //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. //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. colorIndexFrac = colorIndex - (bucketT)intColorIndex;//Interpolate between intColorIndex and intColorIndex + 1.
} }
if (samples[i].m_VizAdjusted == 1) if (samples[i].m_VizAdjusted == 1)
m_HistBuckets[histIndex] += ((dmap[intColorIndex] * (1 - colorIndexFrac)) + (dmap[intColorIndex + 1] * colorIndexFrac)); m_HistBuckets[histIndex] += ((dmap[intColorIndex] * (1 - colorIndexFrac)) + (dmap[intColorIndex + 1] * colorIndexFrac));
else else
@ -2141,7 +2140,7 @@ bool Renderer<T, bucketT>::AssignIterator()
m_Iterator = m_XaosIterator.get(); m_Iterator = m_XaosIterator.get();
else else
m_Iterator = m_StandardIterator.get(); m_Iterator = m_StandardIterator.get();
//Timing t; //Timing t;
return m_Iterator->InitDistributions(m_Ember); return m_Iterator->InitDistributions(m_Ember);
//t.Toc("Distrib creation"); //t.Toc("Distrib creation");
@ -2240,7 +2239,7 @@ template <typename T, typename bucketT> ePaletteMode Renderer<T, bucketT
/// Iterator wrappers. /// Iterator wrappers.
/// </summary> /// </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 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 != NULL ? m_Iterator->XformDistributionsSize() : 0; } 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() : NULL; } 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 void EarlyClip(bool earlyClip) { }
virtual bool YAxisUp() const { return false; } virtual bool YAxisUp() const { return false; }
virtual void YAxisUp(bool yup) { } 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 Transparency(bool transparency) { }
virtual void InteractiveFilter(eInteractiveFilter filter) { } virtual void InteractiveFilter(eInteractiveFilter filter) { }
virtual unsigned int FinalRasW() const { return 0; } virtual unsigned int FinalRasW() const { return 0; }
@ -141,7 +141,7 @@ public:
virtual EmberStats Stats() const { EmberStats stats; return stats; } 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 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 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> /// <summary>
@ -204,7 +204,7 @@ public:
virtual void NumChannels(unsigned int numChannels); virtual void NumChannels(unsigned int numChannels);
virtual eRendererType RendererType() const; virtual eRendererType RendererType() const;
virtual unsigned int ThreadCount() 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); virtual void Callback(RenderCallback* callback);
protected: protected:
@ -341,7 +341,7 @@ protected:
private: private:
//Miscellaneous functions used only in this class. //Miscellaneous functions used only in this class.
void Accumulate(Point<T>* samples, unsigned int sampleCount, const Palette<bucketT>* palette); 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); 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: protected:
@ -395,14 +395,14 @@ protected:
CarToRas<T> m_CarToRas; CarToRas<T> m_CarToRas;
RenderCallback* m_Callback; RenderCallback* m_Callback;
Iterator<T>* m_Iterator; Iterator<T>* m_Iterator;
auto_ptr<StandardIterator<T>> m_StandardIterator; unique_ptr<StandardIterator<T>> m_StandardIterator;
auto_ptr<XaosIterator<T>> m_XaosIterator; unique_ptr<XaosIterator<T>> m_XaosIterator;
Palette<bucketT> m_Dmap; Palette<bucketT> m_Dmap;
vector<glm::detail::tvec4<bucketT, glm::defaultp>> m_HistBuckets; vector<glm::detail::tvec4<bucketT, glm::defaultp>> m_HistBuckets;
vector<glm::detail::tvec4<bucketT, glm::defaultp>> m_AccumulatorBuckets; vector<glm::detail::tvec4<bucketT, glm::defaultp>> m_AccumulatorBuckets;
auto_ptr<SpatialFilter<T>> m_SpatialFilter; unique_ptr<SpatialFilter<T>> m_SpatialFilter;
auto_ptr<TemporalFilter<T>> m_TemporalFilter; unique_ptr<TemporalFilter<T>> m_TemporalFilter;
auto_ptr<DensityFilter<T>> m_DensityFilter; unique_ptr<DensityFilter<T>> m_DensityFilter;
vector<vector<Point<T>>> m_Samples; vector<vector<Point<T>>> m_Samples;
vector<uint64_t> m_SubBatch; vector<uint64_t> m_SubBatch;
vector<uint64_t> m_BadVals; vector<uint64_t> m_BadVals;

View File

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

View File

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

View File

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

View File

@ -42,15 +42,15 @@ public:
/// <summary> /// <summary>
/// Set the end time and optionally output a string showing the elapsed time. /// Set the end time and optionally output a string showing the elapsed time.
/// </summary> /// </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> /// <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> /// <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(); m_EndTime = Clock::now();
double ms = ElapsedTime(); double ms = ElapsedTime();
if (str != NULL) if (str != nullptr)
{ {
cout << string(str) << (fullString ? "" : " processing time: ") << Format(ms) << endl; 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 class EMBER_API EmberImageComments
{ {
public: public:
/// <summary>
/// Empty destructor.
/// Needed to eliminate warnings about inlining.
/// </summary>
~EmberImageComments()
{
}
/// <summary> /// <summary>
/// Set all values to the empty string. /// Set all values to the empty string.
/// </summary> /// </summary>
@ -68,6 +76,11 @@ public:
class EMBER_API EmberReport class EMBER_API EmberReport
{ {
public: public:
/// <summary>
/// Virtual destructor needed for virtual classes.
/// </summary>
virtual ~EmberReport() { }
/// <summary> /// <summary>
/// Write the entire error report as a single string to the console. /// 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 /// 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) static bool ReadFile(const char* filename, string& buf, bool nullTerminate = true)
{ {
bool b = false; bool b = false;
FILE* f; FILE* f = nullptr;
try try
{ {
fopen_s(&f, filename, "rb");//Open in binary mode. fopen_s(&f, filename, "rb");//Open in binary mode.
if (f != NULL) if (f != nullptr)
{ {
struct _stat statBuf; 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. 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. 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; buf[buf.size() - 1] = 0;
b = true;//Success. b = true;//Success.
@ -183,7 +196,7 @@ static bool ReadFile(const char* filename, string& buf, bool nullTerminate = tru
} }
catch (...) catch (...)
{ {
if (f != NULL) if (f != nullptr)
fclose(f); fclose(f);
b = false; b = false;
@ -209,7 +222,7 @@ static void CopyVec(vector<T>& dest, const vector<U>& source)
} }
/// <summary> /// <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. /// Optionally call array delete if the elements themselves are pointers to dynamically allocated arrays.
/// </summary> /// </summary>
/// <param name="vec">The vector to be cleared</param> /// <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++) for (unsigned int i = 0; i < vec.size(); i++)
{ {
if (vec[i] != NULL) if (vec[i] != nullptr)
{ {
if (arrayDelete) if (arrayDelete)
delete [] vec[i]; delete [] vec[i];
@ -227,31 +240,12 @@ static void ClearVec(vector<T*>& vec, bool arrayDelete = false)
delete vec[i]; delete vec[i];
} }
vec[i] = NULL; vec[i] = nullptr;
} }
vec.clear(); 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> /// <summary>
/// System floor() extremely slow because it accounts for various error conditions. /// 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. /// 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> /// </summary>
/// <param name="str">The string to copy and make lower case</param> /// <param name="str">The string to copy and make lower case</param>
/// <returns>The lower case string</returns> /// <returns>The lower case string</returns>
static inline string ToLower(const string& str) static string ToLower(const string& str)
{ {
string lower; string lower;
@ -751,7 +745,7 @@ static inline string ToLower(const string& str)
/// </summary> /// </summary>
/// <param name="str">The string to copy and make upper case</param> /// <param name="str">The string to copy and make upper case</param>
/// <returns>The upper case string</returns> /// <returns>The upper case string</returns>
static inline string ToUpper(const string& str) static string ToUpper(const string& str)
{ {
string upper; string upper;
@ -767,7 +761,7 @@ static inline string ToUpper(const string& str)
/// <param name="str">The string to trim</param> /// <param name="str">The string to trim</param>
/// <param name="ch">The character to trim. Default: space.</param> /// <param name="ch">The character to trim. Default: space.</param>
/// <returns>The trimmed string</returns> /// <returns>The trimmed string</returns>
static inline string Trim(string& str, char ch = ' ') static string Trim(string& str, char ch = ' ')
{ {
string ret; string ret;
@ -817,8 +811,8 @@ int Arg<int>(char* name, int def)
{ {
char* ch; char* ch;
int returnVal; int returnVal;
size_t len;
#ifdef WIN32 #ifdef WIN32
size_t len;
errno_t err = _dupenv_s(&ch, &len, name); errno_t err = _dupenv_s(&ch, &len, name);
#else #else
int err = 1; int err = 1;
@ -880,8 +874,8 @@ double Arg<double>(char* name, double def)
{ {
char* ch; char* ch;
double returnVal; double returnVal;
size_t len;
#ifdef WIN32 #ifdef WIN32
size_t len;
errno_t err = _dupenv_s(&ch, &len, name); errno_t err = _dupenv_s(&ch, &len, name);
#else #else
int err = 1; int err = 1;
@ -913,8 +907,8 @@ string Arg<string>(char* name, string def)
{ {
char* ch; char* ch;
string returnVal; string returnVal;
size_t len;
#ifdef WIN32 #ifdef WIN32
size_t len;
errno_t err = _dupenv_s(&ch, &len, name); errno_t err = _dupenv_s(&ch, &len, name);
#else #else
int err = 1; int err = 1;

View File

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

View File

@ -374,25 +374,25 @@ public:
/// Get a pointer to the variation at the specified index. /// Get a pointer to the variation at the specified index.
/// </summary> /// </summary>
/// <param name="index">The index in the list to retrieve</param> /// <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) { return index < m_Variations.size() ? m_Variations[index] : NULL; } Variation<T>* GetVariation(size_t index) { return index < m_Variations.size() ? m_Variations[index] : nullptr; }
/// <summary> /// <summary>
/// Get a pointer to the variation of a specified type at the specified index. /// Get a pointer to the variation of a specified type at the specified index.
/// </summary> /// </summary>
/// <param name="index">The index in the list to retrieve</param> /// <param name="index">The index in the list to retrieve</param>
/// <param name="varType">The type of variation 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) Variation<T>* GetVariation(size_t index, eVariationType varType)
{ {
if (varType == VARTYPE_REG) 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) 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) else if (varType == VARTYPE_POST)
return index < m_PostVariations.size() ? m_PostVariations[index] : NULL; return index < m_PostVariations.size() ? m_PostVariations[index] : nullptr;
else else
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -401,7 +401,7 @@ public:
/// </summary> /// </summary>
/// <param name="index">The index in the list to make a copy of</param> /// <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> /// <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, 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); } 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. /// Get a pointer to the variation with the specified ID.
/// </summary> /// </summary>
/// <param name="id">The ID to search for</param> /// <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) 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()) if (id == m_Variations[i]->VariationId())
return m_Variations[i]; return m_Variations[i];
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -425,21 +425,21 @@ public:
/// </summary> /// </summary>
/// <param name="id">The id of the variation in the list to make a copy of</param> /// <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> /// <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); } Variation<T>* GetVariationCopy(eVariationId id, T weight = 1) { return MakeCopyWithWeight(GetVariation(id), weight); }
/// <summary> /// <summary>
/// Get a pointer to the variation with the specified name. /// Get a pointer to the variation with the specified name.
/// </summary> /// </summary>
/// <param name="name">The name to search for</param> /// <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>* GetVariation(string name) 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())) if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
return m_Variations[i]; return m_Variations[i];
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -448,7 +448,7 @@ public:
/// </summary> /// </summary>
/// <param name="name">The name of the variation in the list to make a copy of</param> /// <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> /// <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); } Variation<T>* GetVariationCopy(string name, T weight = 1) { return MakeCopyWithWeight(GetVariation(name), weight); }
/// <summary> /// <summary>
@ -456,21 +456,21 @@ public:
/// Note this is the index in the parametric variations list, not in the master list. /// Note this is the index in the parametric variations list, not in the master list.
/// </summary> /// </summary>
/// <param name="index">The index in the parametric variations list to retrieve</param> /// <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> /// <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] : NULL; } ParametricVariation<T>* GetParametricVariation(size_t index) { return index < m_ParametricVariations.size() ? m_ParametricVariations[index] : nullptr; }
/// <summary> /// <summary>
/// Get a parametric variation with the specified name. /// Get a parametric variation with the specified name.
/// </summary> /// </summary>
/// <param name="name">The name of the variation in the parametric variations list to retrieve</param> /// <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) 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())) if (!_stricmp(name.c_str(), m_ParametricVariations[i]->Name().c_str()))
return m_ParametricVariations[i]; return m_ParametricVariations[i];
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -480,10 +480,10 @@ public:
/// <returns>The index of the variation with the matching name, else -1</returns> /// <returns>The index of the variation with the matching name, else -1</returns>
int GetVariationIndex(string name) 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())) if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
return i; return i;
return -1; return -1;
} }
@ -503,7 +503,7 @@ private:
/// </summary> /// </summary>
/// <param name="var">The variation to copy</param> /// <param name="var">The variation to copy</param>
/// <param name="weight">The weight to assign it</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) Variation<T>* MakeCopyWithWeight(Variation<T>* var, T weight)
{ {
if (var) if (var)
@ -514,7 +514,7 @@ private:
return var2; return var2;
} }
return NULL; return nullptr;
} }
/// <summary> /// <summary>
@ -534,4 +534,4 @@ private:
vector<Variation<T>*> m_PostVariations; vector<Variation<T>*> m_PostVariations;
vector<ParametricVariation<T>*> m_ParametricVariations;//A list of pointers to elements in m_Variations which are derived from ParametricVariation. 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 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 dx = m_Xform->m_Affine.C();
T dy = m_Xform->m_Affine.F(); T dy = m_Xform->m_Affine.F();
@ -4674,7 +4674,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index;

View File

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

View File

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

View File

@ -698,7 +698,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string rxSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string rxSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
@ -783,7 +783,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string rySin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string rySin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
@ -865,7 +865,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string rzSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. 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; r = (rand.Rand((ISAAC_INT)m_Slices) + m_YThickness + rand.Frand01<T>() * (1 - m_YThickness)) / m_Slices;
break; break;
case 4: case 4:
default:
a = (rand.Rand((ISAAC_INT)m_Slices) + m_XThickness + rand.Frand01<T>() * (1 - m_XThickness)) / m_Slices; a = (rand.Rand((ISAAC_INT)m_Slices) + m_XThickness + rand.Frand01<T>() * (1 - m_XThickness)) / m_Slices;
r = rand.Frand01<T>(); r = rand.Frand01<T>();
break; break;
@ -1562,7 +1563,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string slices = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -2830,7 +2831,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string thetaPeriod = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string thetaPeriod = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -3209,7 +3210,7 @@ public:
T c = cos(absV); T c = cos(absV);
T sh = sinh(helper.In.x); T sh = sinh(helper.In.x);
T ch = cosh(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.x = m_Weight * sh * c;
helper.Out.y = d * helper.In.y; helper.Out.y = d * helper.In.y;
@ -3227,7 +3228,7 @@ public:
<< "\t\treal_t c = cos(absV);\n" << "\t\treal_t c = cos(absV);\n"
<< "\t\treal_t sh = sinh(vIn.x);\n" << "\t\treal_t sh = sinh(vIn.x);\n"
<< "\t\treal_t ch = cosh(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" << "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sh * c;\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sh * c;\n"
<< "\t\tvOut.y = d * vIn.y;\n" << "\t\tvOut.y = d * vIn.y;\n"
@ -4238,7 +4239,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string extended = "parVars[" + ToUpper(m_Params[i++].Name()) + index; 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; helper.Out.z = ((pz - (m_Smooth * (1 - m_Fill) * pz * znxy)) + (helper.In.z * m_Smooth * m_Fill * znxy)) - lattd;
break; break;
case 7 : 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.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.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; 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; helper.Out.z = pztz * m_Fill * znxy - lattd;
break; break;
case 7 : case 7 :
default:
helper.Out.x = pxtx * m_Fill * exnze - lattd; helper.Out.x = pxtx * m_Fill * exnze - lattd;
helper.Out.y = pyty * m_Fill * wynze - lattd; helper.Out.y = pyty * m_Fill * wynze - lattd;
helper.Out.z = pztz * m_Fill * znxy - lattd; helper.Out.z = pztz * m_Fill * znxy - lattd;
@ -1078,7 +1080,6 @@ public:
T ww = SQR(helper.In.z); T ww = SQR(helper.In.z);
T atOmegaX = atan2(vv, ww); T atOmegaX = atan2(vv, ww);
T atOmegaY = atan2(uu, ww); T atOmegaY = atan2(uu, ww);
T atOmegaZ = atan2(vv, uu);
T su = sin(helper.In.x); T su = sin(helper.In.x);
T cu = cos(helper.In.x); T cu = cos(helper.In.x);
T sv = sin(helper.In.y); T sv = sin(helper.In.y);
@ -1110,7 +1111,6 @@ public:
<< "\t\treal_t ww = SQR(vIn.z);\n" << "\t\treal_t ww = SQR(vIn.z);\n"
<< "\t\treal_t atOmegaX = atan2(vv, ww);\n" << "\t\treal_t atOmegaX = atan2(vv, ww);\n"
<< "\t\treal_t atOmegaY = atan2(uu, 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 su = sin(vIn.x);\n"
<< "\t\treal_t cu = cos(vIn.x);\n" << "\t\treal_t cu = cos(vIn.x);\n"
<< "\t\treal_t sv = sin(vIn.y);\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 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 kikr = helper.m_PrecalcAtanyx;
T efTez = helper.In.z == 0 ? kikr : helper.In.z; T efTez = helper.In.z == 0 ? kikr : helper.In.z;
T r2 = helper.m_PrecalcSumSquares + SQR(efTez); T r2 = helper.m_PrecalcSumSquares + SQR(efTez);
@ -1364,7 +1363,6 @@ public:
string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t rmod = MwcNext01(mwc) * 0.5 + 0.125;\n"
<< "\t\treal_t kikr = precalcAtanyx;\n" << "\t\treal_t kikr = precalcAtanyx;\n"
<< "\t\treal_t efTez = vIn.z == 0 ? kikr : vIn.z;\n" << "\t\treal_t efTez = vIn.z == 0 ? kikr : vIn.z;\n"
<< "\t\treal_t r2 = precalcSumSquares + SQR(efTez);\n" << "\t\treal_t r2 = precalcSumSquares + SQR(efTez);\n"
@ -1644,7 +1642,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -1780,7 +1778,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
@ -2149,6 +2147,7 @@ public:
helper.Out.z = m_Weight * (rad * sigmas); helper.Out.z = m_Weight * (rad * sigmas);
break; break;
case 2://Box. case 2://Box.
default:
scale = Clamp<T>(rs, 0, T(0.9)) + T(0.1); scale = Clamp<T>(rs, 0, T(0.9)) + T(0.1);
denom = 1 / scale; 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, 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; break;
case 2://Gaussian. case 2://Gaussian.
default:
{ {
const T sigma = dist * random.y * M_2PI; const T sigma = dist * random.y * M_2PI;
const T phi = dist * random.z * T(M_PI); const T phi = dist * random.z * T(M_PI);
@ -2339,7 +2339,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string scatter = "parVars[" + ToUpper(m_Params[i++].Name()) + index; 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)); radius = sqrt(Sqr(helper.In.x - m_CenterX) + Sqr(helper.In.y - m_CenterY) + Sqr(helper.In.z - m_CenterZ));
break; break;
case 1://Square. 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. 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; break;
} }
@ -2532,6 +2533,7 @@ public:
} }
break; break;
case 2://Log. case 2://Log.
default:
{ {
const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (LogMap(dist) - dist); const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (LogMap(dist) - dist);
@ -2547,7 +2549,7 @@ public:
virtual string OpenCLString() override virtual string OpenCLString() override
{ {
ostringstream ss, ss2; ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform(); int i = 0;
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str(); string index = ss2.str();
string blurType = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string blurType = "parVars[" + ToUpper(m_Params[i++].Name()) + index;

View File

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

View File

@ -68,7 +68,7 @@ public:
T pe = 1, T pe = 1,
T pc = 0, T pc = 0,
T pf = 0) T pf = 0)
{ {
Init(); Init();
@ -101,7 +101,7 @@ public:
/// </summary> /// </summary>
/// <param name="xform">The Xform object to copy</param> /// <param name="xform">The Xform object to copy</param>
Xform(const Xform<T>& xform) Xform(const Xform<T>& xform)
: m_ParentEmber(NULL)//Hack. : m_ParentEmber(nullptr)//Hack.
{ {
Xform<T>::operator=<T>(xform); Xform<T>::operator=<T>(xform);
} }
@ -112,7 +112,7 @@ public:
/// <param name="xform">The Xform object to copy</param> /// <param name="xform">The Xform object to copy</param>
template <typename U> template <typename U>
Xform(const Xform<U>& xform) Xform(const Xform<U>& xform)
: m_ParentEmber(NULL)//Hack. : m_ParentEmber(nullptr)//Hack.
{ {
Xform<T>::operator=<U>(xform); Xform<T>::operator=<U>(xform);
} }
@ -171,8 +171,8 @@ public:
//the variation's m_IndexInXform member gets properly set to this. //the variation's m_IndexInXform member gets properly set to this.
for (unsigned int i = 0; i < xform.TotalVariationCount(); i++) for (unsigned int i = 0; i < xform.TotalVariationCount(); i++)
{ {
Variation<T>* var = NULL; Variation<T>* var = nullptr;
if (Variation<U>* varOrig = xform.GetVariation(i)) if (Variation<U>* varOrig = xform.GetVariation(i))
{ {
varOrig->Copy(var);//Will convert from type U to type T. varOrig->Copy(var);//Will convert from type U to type T.
@ -236,7 +236,7 @@ public:
m_NeedPrecalcAtanYX = false; m_NeedPrecalcAtanYX = false;
m_HasPost = false; m_HasPost = false;
m_HasPreOrRegularVars = false; m_HasPreOrRegularVars = false;
m_ParentEmber = NULL; m_ParentEmber = nullptr;
m_PreVariations.reserve(MAX_VARS_PER_XFORM); m_PreVariations.reserve(MAX_VARS_PER_XFORM);
m_Variations.reserve(MAX_VARS_PER_XFORM); m_Variations.reserve(MAX_VARS_PER_XFORM);
m_PostVariations.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> /// <returns>True if the successful, else false.</returns>
bool AddVariation(Variation<T>* variation) bool AddVariation(Variation<T>* variation)
{ {
if (variation && (GetVariationById(variation->VariationId()) == NULL)) if (variation && (GetVariationById(variation->VariationId()) == nullptr))
{ {
string name = variation->Name(); string name = variation->Name();
bool pre = name.find("pre_") == 0; bool pre = name.find("pre_") == 0;
@ -294,11 +294,11 @@ public:
/// Get a pointer to the variation at the specified index. /// Get a pointer to the variation at the specified index.
/// </summary> /// </summary>
/// <param name="index">The index in the list to retrieve</param> /// <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 Variation<T>* GetVariation(size_t index) const
{ {
size_t count = 0; size_t count = 0;
Variation<T>* var = NULL; Variation<T>* var = nullptr;
const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing) 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. /// Get a pointer to the variation with the specified ID.
/// </summary> /// </summary>
/// <param name="id">The ID to search for</param> /// <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>* GetVariationById(eVariationId id) const
{ {
Variation<T>* var = NULL; Variation<T>* var = nullptr;
const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing) const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{ {
for (unsigned int i = 0; i < variations.size(); i++) 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]; var = variations[i];
keepGoing = false; keepGoing = false;
@ -345,16 +345,16 @@ public:
/// Get a pointer to the variation with the specified name. /// Get a pointer to the variation with the specified name.
/// </summary> /// </summary>
/// <param name="name">The name to search for</param> /// <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>* GetVariationByName(string name) const
{ {
Variation<T>* var = NULL; Variation<T>* var = nullptr;
const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing) const_cast<Xform<T>*>(this)->AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{ {
for (unsigned int i = 0; i < variations.size(); i++) 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]; var = variations[i];
keepGoing = false; keepGoing = false;
@ -406,7 +406,7 @@ public:
{ {
for (unsigned int i = 0; i < variations.size(); i++) 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]; delete variations[i];
variations.erase(variations.begin() + 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 /// 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 /// identity matrix, clearing xaos, color, visibility, wind, animate and setting name
/// to the empty string. /// 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. /// the caller must reset the parent ember to whatever ember they add it to again.
/// </summary> /// </summary>
void Clear() void Clear()
@ -452,7 +452,7 @@ public:
m_Affine.MakeID(); m_Affine.MakeID();
m_Post.MakeID(); m_Post.MakeID();
m_Xaos.clear(); m_Xaos.clear();
m_ParentEmber = NULL; m_ParentEmber = nullptr;
m_ColorSpeedCache = 0; m_ColorSpeedCache = 0;
m_OneMinusColorCache = 0; m_OneMinusColorCache = 0;
m_VizAdjusted = 0; m_VizAdjusted = 0;
@ -537,7 +537,7 @@ public:
while (m_Xaos.size() > m_ParentEmber->XformCount()) while (m_Xaos.size() > m_ParentEmber->XformCount())
m_Xaos.pop_back(); m_Xaos.pop_back();
} }
/// <summary> /// <summary>
/// Remove all xaos from this xform. /// Remove all xaos from this xform.
/// </summary> /// </summary>
@ -657,7 +657,7 @@ public:
m_PostVariations[i]->Func(iterHelper, *outPoint, rand); m_PostVariations[i]->Func(iterHelper, *outPoint, rand);
WritePost(iterHelper, *outPoint, m_PostVariations[i]->AssignType()); WritePost(iterHelper, *outPoint, m_PostVariations[i]->AssignType());
} }
//Optionally apply the post affine transform if it's present. //Optionally apply the post affine transform if it's present.
if (m_HasPost) if (m_HasPost)
{ {
@ -688,7 +688,7 @@ public:
//Loop over the motion elements and add their contribution to the original vals. //Loop over the motion elements and add their contribution to the original vals.
for (i = 0; i < xform.m_Motion.size(); i++) 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. //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]; Xform<T>* currentMot = &xform.m_Motion[i];
int freq = currentMot->m_MotionFreq; int freq = currentMot->m_MotionFreq;
@ -698,11 +698,11 @@ public:
APPMOT(m_Weight); APPMOT(m_Weight);
APPMOT(m_ColorX); APPMOT(m_ColorX);
//APPMOT(m_ColorY); //APPMOT(m_ColorY);
APPMOT(m_DirectColor); APPMOT(m_DirectColor);
APPMOT(m_Opacity); APPMOT(m_Opacity);
APPMOT(m_ColorSpeed); APPMOT(m_ColorSpeed);
APPMOT(m_Animate); APPMOT(m_Animate);
for (j = 0; j < currentMot->TotalVariationCount(); j++)//For each variation in the motion xform. 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. 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. //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. //Now apply the motion func to the params if needed.
if (motParVar != NULL) if (motParVar != nullptr)
{ {
ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(var); ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(var);
ParamWithName<T>* params = parVar->Params(); ParamWithName<T>* params = parVar->Params();
@ -747,7 +747,7 @@ public:
} }
} }
} }
//Make sure certain params are within reasonable bounds. //Make sure certain params are within reasonable bounds.
ClampRef<T>(m_ColorX, 0, 1); ClampRef<T>(m_ColorX, 0, 1);
//ClampRef<T>(m_ColorY, 0, 1); //ClampRef<T>(m_ColorY, 0, 1);
@ -866,11 +866,11 @@ public:
if (m_NeedPrecalcAtanXY) if (m_NeedPrecalcAtanXY)
helper.m_PrecalcAtanxy = atan2(helper.m_TransX, helper.m_TransY); helper.m_PrecalcAtanxy = atan2(helper.m_TransX, helper.m_TransY);
if (m_NeedPrecalcAtanYX) if (m_NeedPrecalcAtanYX)
helper.m_PrecalcAtanyx = atan2(helper.m_TransY, helper.m_TransX); helper.m_PrecalcAtanyx = atan2(helper.m_TransY, helper.m_TransX);
} }
/// <summary> /// <summary>
/// Flatten this xform by adding a flatten variation if none is present, and if any of the /// 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. /// variations or parameters in the vector are present.
@ -881,7 +881,7 @@ public:
{ {
bool shouldFlatten = true; bool shouldFlatten = true;
if (GetVariationById(VAR_FLATTEN) == NULL) if (GetVariationById(VAR_FLATTEN) == nullptr)
{ {
AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing) AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
{ {
@ -953,6 +953,7 @@ public:
"\tvIn.z = transZ;\n"; "\tvIn.z = transZ;\n";
break; break;
case VARTYPE_POST: case VARTYPE_POST:
default:
s = s =
"\tvIn.x = outPoint->m_X;\n" "\tvIn.x = outPoint->m_X;\n"
"\tvIn.y = outPoint->m_Y;\n" "\tvIn.y = outPoint->m_Y;\n"
@ -980,6 +981,7 @@ public:
break; break;
} }
case ASSIGNTYPE_SUM: case ASSIGNTYPE_SUM:
default:
{ {
helper.m_TransX += helper.Out.x; helper.m_TransX += helper.Out.x;
helper.m_TransY += helper.Out.y; helper.m_TransY += helper.Out.y;
@ -1006,6 +1008,7 @@ public:
break; break;
} }
case ASSIGNTYPE_SUM: case ASSIGNTYPE_SUM:
default:
{ {
outPoint.m_X += helper.Out.x; outPoint.m_X += helper.Out.x;
outPoint.m_Y += helper.Out.y; outPoint.m_Y += helper.Out.y;
@ -1014,7 +1017,7 @@ public:
} }
} }
} }
/// <summary> /// <summary>
/// Generate the OpenCL string for writing output values from a call to a variation. /// Generate the OpenCL string for writing output values from a call to a variation.
/// </summary> /// </summary>
@ -1048,6 +1051,7 @@ public:
break; break;
} }
case ASSIGNTYPE_SUM: case ASSIGNTYPE_SUM:
default:
{ {
s = s =
"\ttransX += vOut.x;\n" "\ttransX += vOut.x;\n"
@ -1060,6 +1064,7 @@ public:
break; break;
} }
case VARTYPE_POST: case VARTYPE_POST:
default:
{ {
switch (assignType) switch (assignType)
{ {
@ -1072,6 +1077,7 @@ public:
break; break;
} }
case ASSIGNTYPE_SUM: case ASSIGNTYPE_SUM:
default:
{ {
s = s =
"\toutPoint->m_X += vOut.x;\n" "\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. //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. //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; T m_ColorX, m_ColorY;
private: 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_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. T m_OneMinusColorCache;//Cache of 1 - m_ColorSpeedCache.
@ -1184,7 +1190,7 @@ public:
private: private:
vector<Variation<T>*> m_PostVariations;//The list of post variations to call when applying this xform. vector<Variation<T>*> m_PostVariations;//The list of post variations to call when applying this xform.
public: public:
T m_DirectColor;//Used with direct color variations. T m_DirectColor;//Used with direct color variations.
@ -1192,7 +1198,7 @@ public:
//Discussed on page 4 of the paper: //Discussed on page 4 of the paper:
//Probability wi. //Probability wi.
T m_Weight; T m_Weight;
//Scaling factor on color added to current iteration, also known as color weight. Normally defaults to 0.5. //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: //Discussed on page 9 of the paper with a hard coded default value of 0.5:
//C = (C + Ci) * m_ColorSpeed. //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_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. 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_Category = category;
m_NewLocale = string(loc); m_NewLocale = string(loc);
m_OriginalLocale = setlocale(category, NULL);//Query. m_OriginalLocale = setlocale(category, nullptr);//Query.
if (m_OriginalLocale.empty()) if (m_OriginalLocale.empty())
cout << "Couldn't get original locale." << endl; 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; cout << "Couldn't set new locale " << category << ", " << loc << "." << endl;
} }
/// <summary> /// <summary>
/// Reset the locale to the value stored during construction. /// Reset the locale to the value stored during construction.
/// </summary> /// </summary>
~Locale() ~Locale()
{ {
if (!m_OriginalLocale.empty()) 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; 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) bool Parse(unsigned char* buf, const char* filename, vector<Ember<T>>& embers)
{ {
char* bn; char* bn;
const char* xmlBuf; const char* xmlPtr;
const char* loc = __FUNCTION__; const char* loc = __FUNCTION__;
unsigned int emberSize; unsigned int emberSize;
size_t bufSize; size_t bufSize;
@ -260,12 +260,12 @@ public:
m_ErrorReport.clear(); m_ErrorReport.clear();
//Parse XML string into internal document. //Parse XML string into internal document.
xmlBuf = (const char*)(&buf[0]); xmlPtr = (const char*)(&buf[0]);
bufSize = strlen(xmlBuf); 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. 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)); m_ErrorReport.push_back(string(loc) + " : Error parsing xml file " + string(filename));
return false; return false;
@ -310,7 +310,7 @@ public:
{ {
while (embers[i].m_Rotate < embers[i - 1].m_Rotate - 180) while (embers[i].m_Rotate < embers[i - 1].m_Rotate - 180)
embers[i].m_Rotate += 360; embers[i].m_Rotate += 360;
while (embers[i].m_Rotate > embers[i - 1].m_Rotate + 180) while (embers[i].m_Rotate > embers[i - 1].m_Rotate + 180)
embers[i].m_Rotate -= 360; embers[i].m_Rotate -= 360;
} }
@ -416,7 +416,7 @@ public:
//Convert the string using strtod(). //Convert the string using strtod().
val = strtol(str, &endp, 10); val = strtol(str, &endp, 10);
//Check errno & return string. //Check errno & return string.
if (endp != str + strlen(str)) if (endp != str + strlen(str))
{ {
@ -483,7 +483,7 @@ private:
void ScanForEmberNodes(xmlNode* curNode, char* parentFile, vector<Ember<T>>& embers) void ScanForEmberNodes(xmlNode* curNode, char* parentFile, vector<Ember<T>>& embers)
{ {
bool parseEmberSuccess; bool parseEmberSuccess;
xmlNodePtr thisNode = NULL; xmlNodePtr thisNode = nullptr;
const char* loc = __FUNCTION__; const char* loc = __FUNCTION__;
string parentFileString = string(parentFile); string parentFileString = string(parentFile);
@ -537,7 +537,7 @@ private:
/// <returns>True if there were no errors, else false.</returns> /// <returns>True if there were no errors, else false.</returns>
bool ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber) bool ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber)
{ {
bool b = true; bool ret = true;
unsigned int newLinear = 0; unsigned int newLinear = 0;
char* attStr; char* attStr;
const char* loc = __FUNCTION__; const char* loc = __FUNCTION__;
@ -550,7 +550,7 @@ private:
currentEmber.m_Palette.Clear();//Wipe out the current palette. 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. 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"); m_ErrorReport.push_back(string(loc) + " : <flame> element has no attributes");
return false; return false;
@ -561,36 +561,36 @@ private:
attStr = (char*)xmlGetProp(emberNode, curAtt->name); attStr = (char*)xmlGetProp(emberNode, curAtt->name);
//First parse out simple float reads. //First parse out simple float reads.
if (ParseAndAssignFloat(curAtt->name, attStr, "time", currentEmber.m_Time, b)) { } if (ParseAndAssignFloat(curAtt->name, attStr, "time", currentEmber.m_Time, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "scale", currentEmber.m_PixelsPerUnit, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "scale", currentEmber.m_PixelsPerUnit, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "rotate", currentEmber.m_Rotate, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "rotate", currentEmber.m_Rotate, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "zoom", currentEmber.m_Zoom, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "zoom", currentEmber.m_Zoom, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "filter", currentEmber.m_SpatialFilterRadius, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "filter", currentEmber.m_SpatialFilterRadius, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_width", currentEmber.m_TemporalFilterWidth, b)) { } 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, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_exp", currentEmber.m_TemporalFilterExp, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "quality", currentEmber.m_Quality, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "quality", currentEmber.m_Quality, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "brightness", currentEmber.m_Brightness, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "brightness", currentEmber.m_Brightness, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma", currentEmber.m_Gamma, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma", currentEmber.m_Gamma, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "highlight_power", currentEmber.m_HighlightPower, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "highlight_power", currentEmber.m_HighlightPower, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "vibrancy", currentEmber.m_Vibrancy, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "vibrancy", currentEmber.m_Vibrancy, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_radius", currentEmber.m_MaxRadDE, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_radius", currentEmber.m_MaxRadDE, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_minimum", currentEmber.m_MinRadDE, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_minimum", currentEmber.m_MinRadDE, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_curve", currentEmber.m_CurveDE, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_curve", currentEmber.m_CurveDE, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma_threshold", currentEmber.m_GammaThresh, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma_threshold", currentEmber.m_GammaThresh, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_zpos", currentEmber.m_CamZPos, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_zpos", currentEmber.m_CamZPos, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_persp", currentEmber.m_CamPerspective, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_persp", currentEmber.m_CamPerspective, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_perspective", currentEmber.m_CamPerspective, b)) { }//Apo bug. 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, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_yaw", currentEmber.m_CamYaw, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_pitch", currentEmber.m_CamPitch, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_pitch", currentEmber.m_CamPitch, ret)) { }
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_dof", currentEmber.m_CamDepthBlur, b)) { } else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_dof", currentEmber.m_CamDepthBlur, ret)) { }
//Parse simple int reads. //Parse simple int reads.
else if (ParseAndAssignInt(curAtt->name, attStr, "palette", currentEmber.m_Palette.m_Index, b)) { } else if (ParseAndAssignInt(curAtt->name, attStr, "palette", currentEmber.m_Palette.m_Index, ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "oversample", currentEmber.m_Supersample , b)) { } else if (ParseAndAssignInt(curAtt->name, attStr, "oversample", currentEmber.m_Supersample , ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "supersample", currentEmber.m_Supersample , b)) { } else if (ParseAndAssignInt(curAtt->name, attStr, "supersample", currentEmber.m_Supersample , ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "temporal_samples", currentEmber.m_TemporalSamples, b)) { } else if (ParseAndAssignInt(curAtt->name, attStr, "temporal_samples", currentEmber.m_TemporalSamples, ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "soloxform", soloXform , b)) { } else if (ParseAndAssignInt(curAtt->name, attStr, "soloxform", soloXform , ret)) { }
else if (ParseAndAssignInt(curAtt->name, attStr, "new_linear", newLinear , b)) { } else if (ParseAndAssignInt(curAtt->name, attStr, "new_linear", newLinear , ret)) { }
//Parse more complicated reads that have multiple possible values. //Parse more complicated reads that have multiple possible values.
else if (!Compare(curAtt->name, "interpolation")) else if (!Compare(curAtt->name, "interpolation"))
@ -631,7 +631,7 @@ private:
} }
else if (!Compare(curAtt->name, "size")) 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)); m_ErrorReport.push_back(string(loc) + " : Invalid size attribute " + string(attStr));
xmlFree(attStr); xmlFree(attStr);
@ -709,7 +709,7 @@ private:
//Loop through the attributes of the color element. //Loop through the attributes of the color element.
att = childNode->properties; att = childNode->properties;
if (att == NULL) if (att == nullptr)
{ {
m_ErrorReport.push_back(string(loc) + " : No attributes for color element"); m_ErrorReport.push_back(string(loc) + " : No attributes for color element");
continue; continue;
@ -775,7 +775,7 @@ private:
//Loop through the attributes of the color element. //Loop through the attributes of the color element.
att = childNode->properties; att = childNode->properties;
if (att == NULL) if (att == nullptr)
{ {
m_ErrorReport.push_back(string(loc) + " : No attributes for colors element"); m_ErrorReport.push_back(string(loc) + " : No attributes for colors element");
continue; continue;
@ -821,7 +821,7 @@ private:
//Loop through the attributes of the palette element. //Loop through the attributes of the palette element.
att = childNode->properties; att = childNode->properties;
if (att == NULL) if (att == nullptr)
{ {
m_ErrorReport.push_back(string(loc) + " : No attributes for palette element"); m_ErrorReport.push_back(string(loc) + " : No attributes for palette element");
continue; continue;
@ -864,7 +864,7 @@ private:
else if (!Compare(curAtt->name, "format")) else if (!Compare(curAtt->name, "format"))
{ {
newFormat = true; newFormat = true;
if (!_stricmp(attStr, "RGB")) if (!_stricmp(attStr, "RGB"))
numBytes = 3; numBytes = 3;
else if (!_stricmp(attStr, "RGBA")) else if (!_stricmp(attStr, "RGBA"))
@ -879,7 +879,7 @@ private:
{ {
m_ErrorReport.push_back(string(loc) + " : Unknown palette attribute " + string((const char*)curAtt->name)); m_ErrorReport.push_back(string(loc) + " : Unknown palette attribute " + string((const char*)curAtt->name));
} }
xmlFree(attStr); xmlFree(attStr);
} }
@ -914,7 +914,7 @@ private:
//Loop through the attributes of the palette element. //Loop through the attributes of the palette element.
att = childNode->properties; att = childNode->properties;
if (att == NULL) if (att == nullptr)
{ {
m_ErrorReport.push_back(string(loc) + " : No attributes for palette element"); m_ErrorReport.push_back(string(loc) + " : No attributes for palette element");
continue; continue;
@ -944,7 +944,7 @@ private:
} }
else if (!Compare(childNode->name, "xform") || !Compare(childNode->name, "finalxform")) else if (!Compare(childNode->name, "xform") || !Compare(childNode->name, "finalxform"))
{ {
Xform<T>* theXform = NULL; Xform<T>* theXform = nullptr;
if (!Compare(childNode->name, "finalxform")) if (!Compare(childNode->name, "finalxform"))
{ {
@ -1033,7 +1033,7 @@ private:
bool ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion) bool ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion)
{ {
bool success = true; bool success = true;
char* attStr, *copy; char* attStr;
const char* loc = __FUNCTION__; const char* loc = __FUNCTION__;
unsigned int j; unsigned int j;
T temp; T temp;
@ -1044,7 +1044,7 @@ private:
//Loop through the attributes of the xform element. //Loop through the attributes of the xform element.
attPtr = childNode->properties; attPtr = childNode->properties;
if (attPtr == NULL) if (attPtr == nullptr)
{ {
m_ErrorReport.push_back(string(loc) + " : Error: No attributes for element"); m_ErrorReport.push_back(string(loc) + " : Error: No attributes for element");
return false; return false;
@ -1052,7 +1052,7 @@ private:
for (curAtt = attPtr; curAtt; curAtt = curAtt->next) 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. //First parse out simple float reads.
if (ParseAndAssignFloat(curAtt->name, attStr, "weight", xform.m_Weight, success)) { } if (ParseAndAssignFloat(curAtt->name, attStr, "weight", xform.m_Weight, success)) { }
@ -1095,7 +1095,6 @@ private:
} }
else if (!Compare(curAtt->name, "color")) else if (!Compare(curAtt->name, "color"))
{ {
T tmpc1 = 0;
xform.m_ColorX = xform.m_ColorY = 0; xform.m_ColorX = xform.m_ColorY = 0;
//Try two coords first . //Try two coords first .
@ -1141,7 +1140,7 @@ private:
a = d = b = e = c = f = 0; a = d = b = e = c = f = 0;
m_ErrorReport.push_back(string(loc) + " : Bad coeffs attribute " + string(attStr)); m_ErrorReport.push_back(string(loc) + " : Bad coeffs attribute " + string(attStr));
} }
xform.m_Affine.A(T(a)); xform.m_Affine.A(T(a));
xform.m_Affine.B(T(b)); xform.m_Affine.B(T(b));
xform.m_Affine.C(T(c)); xform.m_Affine.C(T(c));
@ -1167,7 +1166,6 @@ private:
else else
{ {
string s = GetCorrectedVariationName(m_BadVariationNames, curAtt); string s = GetCorrectedVariationName(m_BadVariationNames, curAtt);
const char* name = s.c_str();
if (Variation<T>* var = m_VariationList.GetVariation(s)) if (Variation<T>* var = m_VariationList.GetVariation(s))
{ {
@ -1192,11 +1190,11 @@ private:
if (!Compare(curAtt->name, "var1")) 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++) for (j = 0; j < xform.TotalVariationCount(); j++)
xform.GetVariation(j)->m_Weight = 0; xform.GetVariation(j)->m_Weight = 0;
if (Atof(attStr, temp)) if (Atof(attStr, temp))
{ {
unsigned int iTemp = (unsigned int)temp; unsigned int iTemp = (unsigned int)temp;
@ -1207,7 +1205,7 @@ private:
var1 = true; var1 = true;
} }
} }
if (!var1) if (!var1)
m_ErrorReport.push_back(string(loc) + " : Bad value for var1 " + string(attStr)); m_ErrorReport.push_back(string(loc) + " : Bad value for var1 " + string(attStr));
@ -1223,7 +1221,7 @@ private:
if (!Compare(curAtt->name, "var")) if (!Compare(curAtt->name, "var"))
{ {
copy = attStr = (char*)xmlGetProp(childNode, curAtt->name); attStr = (char*)xmlGetProp(childNode, curAtt->name);
if (Atof(attStr, temp)) if (Atof(attStr, temp))
{ {
@ -1232,7 +1230,7 @@ private:
var = true; var = true;
} }
if (!var) if (!var)
m_ErrorReport.push_back(string(loc) + " : Bad value for var " + string(attStr)); m_ErrorReport.push_back(string(loc) + " : Bad value for var " + string(attStr));
@ -1254,7 +1252,7 @@ private:
if (parVar->ContainsParam(name)) if (parVar->ContainsParam(name))
{ {
T val = 0; T val = 0;
copy = attStr = (char*)xmlGetProp(childNode, curAtt->name); attStr = (char*)xmlGetProp(childNode, curAtt->name);
if (Atof(attStr, val)) if (Atof(attStr, val))
{ {
@ -1264,7 +1262,7 @@ private:
{ {
m_ErrorReport.push_back(string(loc) + " : Failed to parse parametric variation parameter " + s + " - " + string(attStr)); m_ErrorReport.push_back(string(loc) + " : Failed to parse parametric variation parameter " + s + " - " + string(attStr));
} }
xmlFree(attStr); xmlFree(attStr);
} }
} }
@ -1339,7 +1337,7 @@ private:
{ {
if (!_stricmp(name, (const char*)temp->name)) if (!_stricmp(name, (const char*)temp->name))
return true; return true;
} while (temp = temp->next); } while ((temp = temp->next));
return false; return false;
} }
@ -1357,13 +1355,13 @@ private:
{ {
int colorIndex = 0; int colorIndex = 0;
int colorCount = 0; int colorCount = 0;
int r, g, b, a; unsigned int r, g, b, a;
int ret; int ret;
char tmps[2]; char tmps[2];
int skip = (int)abs(chan); int skip = (int)abs(chan);
bool ok = true; bool ok = true;
const char* loc = __FUNCTION__; const char* loc = __FUNCTION__;
//Strip whitespace prior to first color. //Strip whitespace prior to first color.
while (isspace((int)colstr[colorIndex])) while (isspace((int)colstr[colorIndex]))
colorIndex++; colorIndex++;
@ -1389,10 +1387,10 @@ private:
} }
colorIndex += 2 * skip; colorIndex += 2 * skip;
while (isspace((int)colstr[colorIndex])) while (isspace((int)colstr[colorIndex]))
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].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].g = T(g) / T(255);
ember.m_Palette.m_Entries[colorCount].b = T(b) / 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]))); m_ErrorReport.push_back(string(loc) + " : Extra data at end of hex color data " + string(&(colstr[colorIndex])));
ok = false; ok = false;
} }
return ok; return ok;
} }
@ -1443,13 +1441,13 @@ private:
Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted0[i]), s); Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted0[i]), s);
Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted1[i]), t); Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted1[i]), t);
s[3] = hueAdjusted0[i][3]; s[3] = hueAdjusted0[i][3];
t[3] = hueAdjusted1[i][3]; t[3] = hueAdjusted1[i][3];
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
t[j] = ((1 - blend) * s[j]) + (blend * t[j]); t[j] = ((1 - blend) * s[j]) + (blend * t[j]);
Palette<T>::HsvToRgb(t, glm::value_ptr(palette.m_Entries[i])); Palette<T>::HsvToRgb(t, glm::value_ptr(palette.m_Entries[i]));
palette.m_Entries[i][3] = t[3]; palette.m_Entries[i][3] = t[3];
} }
@ -1518,7 +1516,7 @@ private:
} }
return ret; return ret;
} }
static bool m_Init; static bool m_Init;
static vector<pair<string, string>> m_BadParamNames; 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. VariationList<T> m_VariationList;//The variation list used to make copies of variations to populate the embers with.
PaletteList<T> m_PaletteList; PaletteList<T> m_PaletteList;
}; };
} }

View File

@ -311,7 +311,7 @@ bool EmberAnimate(EmberOptions& opt)
if ((opt.Format() == "jpg" || opt.Format() == "bmp") && renderer->NumChannels() == 4) 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(); finalImagep = vecRgb.data();
} }

View File

@ -84,7 +84,7 @@ private:
/// <returns>True if success, else false.</returns> /// <returns>True if success, else false.</returns>
template <typename T> template <typename T>
static bool ParseEmberFile(XmlToEmber<T>& parser, string filename, vector<Ember<T>>& embers) static bool ParseEmberFile(XmlToEmber<T>& parser, string filename, vector<Ember<T>>& embers)
{ {
if (!parser.Parse(filename.c_str(), embers)) if (!parser.Parse(filename.c_str(), embers))
{ {
cout << "Error parsing flame file " << filename << ", returning without executing." << endl; 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> /// <returns>True if success, else false.</returns>
template <typename T> template <typename T>
static bool InitPaletteList(string filename) static bool InitPaletteList(string filename)
{ {
PaletteList<T> paletteList;//Even though this is local, the members are static so they will remain. PaletteList<T> paletteList;//Even though this is local, the members are static so they will remain.
if (!paletteList.Init(filename)) if (!paletteList.Init(filename))
@ -122,6 +122,25 @@ static bool InitPaletteList(string filename)
return true; 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> /// <summary>
/// Calculate the number of strips required if the needed amount of memory /// 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. /// 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) 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(); finalImagep = vecRgb.data();
} }

View File

@ -1748,7 +1748,7 @@ double RandD(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
int _tmain(int argc, _TCHAR* argv[]) int _tmain(int argc, _TCHAR* argv[])
{ {
int i; //int i;
Timing t(4); Timing t(4);
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand; 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) 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(); data = vecRgb.data();
} }