mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-06-30 21:36:33 -04:00
--User changes
-Add support for multiple GPU devices. --These options are present in the command line and in Fractorium. -Change scheme of specifying devices from platform,device to just total device index. --Single number on the command line. --Change from combo boxes for device selection to a table of all devices in Fractorium. -Temporal samples defaults to 100 instead of 1000 which was needless overkill. --Bug fixes -EmberAnimate, EmberRender, FractoriumSettings, FinalRenderDialog: Fix wrong order of arguments to Clamp() when assigning thread priority. -VariationsDC.h: Fix NVidia OpenCL compilation error in DCTriangleVariation. -FractoriumXformsColor.cpp: Checking for null pixmap pointer is not enough, must also check if the underlying buffer is null via call to QPixmap::isNull(). --Code changes -Ember.h: Add case for FLAME_MOTION_NONE and default in ApplyFlameMotion(). -EmberMotion.h: Call base constructor. -EmberPch.h: #pragma once only on Windows. -EmberToXml.h: --Handle different types of exceptions. --Add default cases to ToString(). -Isaac.h: Remove unused variable in constructor. -Point.h: Call base constructor in Color(). -Renderer.h/cpp: --Add bool to Alloc() to only allocate memory for the histogram. Needed for multi-GPU. --Make CoordMap() return a const ref, not a pointer. -SheepTools.h: --Use 64-bit types like the rest of the code already does. --Fix some comment misspellings. -Timing.h: Make BeginTime(), EndTime(), ElapsedTime() and Format() be const functions. -Utils.h: --Add new functions Equal() and Split(). --Handle more exception types in ReadFile(). --Get rid of most legacy blending of C and C++ argument parsing. -XmlToEmber.h: --Get rid of most legacy blending of C and C++ code from flam3. --Remove some unused variables. -EmberAnimate: --Support multi-GPU processing that alternates full frames between devices. --Use OpenCLInfo instead of OpenCLWrapper for --openclinfo option. --Remove bucketT template parameter, and hard code float in its place. --If a render fails, exit since there is no point in continuing an animation with a missing frame. --Pass variables to threaded save better, which most likely fixes a very subtle bug that existed before. --Remove some unused variables. -EmberGenome, EmberRender: --Support multi-GPU processing that alternates full frames between devices. --Use OpenCLInfo instead of OpenCLWrapper for --openclinfo option. --Remove bucketT template parameter, and hard code float in its place. -EmberRender: --Support multi-GPU processing that alternates full frames between devices. --Use OpenCLInfo instead of OpenCLWrapper for --openclinfo option. --Remove bucketT template parameter, and hard code float in its place. --Only print values when not rendering with OpenCL, since they're always 0 in that case. -EmberCLPch.h: --#pragma once only on Windows. --#include <atomic>. -IterOpenCLKernelCreator.h: Add new kernel for summing two histograms. This is needed for multi-GPU. -OpenCLWrapper.h: --Move all OpenCL info related code into its own class OpenCLInfo. --Add members to cache the values of global memory size and max allocation size. -RendererCL.h/cpp: --Redesign to accomodate multi-GPU. --Constructor now takes a vector of devices. --Remove DumpErrorReport() function, it's handled in the base. --ClearBuffer(), ReadPoints(), WritePoints(), ReadHist() and WriteHist() now optionally take a device index as a parameter. --MakeDmap() override and m_DmapCL member removed because it no longer applies since the histogram is always float since the last commit. --Add new function SumDeviceHist() to sum histograms from two devices by first copying to a temporary on the host, then a temporary on the device, then summing. --m_Calls member removed, as it's now per-device. --OpenCLWrapper removed. --m_Seeds member is now a vector of vector of seeds, to accomodate a separate and different array of seeds for each device. --Added member m_Devices, a vector of unique_ptr of RendererCLDevice. -EmberCommon.h --Added Devices() function to convert from a vector of device indices to a vector of platform,device indices. --Changed CreateRenderer() to accept a vector of devices to create a single RendererCL which will split work across multiple devices. --Added CreateRenderers() function to accept a vector of devices to create multiple RendererCL, each which will render on a single device. --Add more comments to some existing functions. -EmberCommonPch.h: #pragma once only on Windows. -EmberOptions.h: --Remove --platform option, it's just sequential device number now with the --device option. --Make --out be OPT_USE_RENDER instead of OPT_RENDER_ANIM since it's an error condition when animating. It makes no sense to write all frames to a single image. --Add Devices() function to parse comma separated --device option string and return a vector of device indices. --Make int and uint types be 64-bit, so intmax_t and size_t. --Make better use of macros. -JpegUtils.h: Make string parameters to WriteJpeg() and WritePng() be const ref. -All project files: Turn off buffer security check option in Visual Studio (/Gs-) -deployment.pri: Remove the line OTHER_FILES +=, it's pointless and was causing problems. -Ember.pro, EmberCL.pro: Add CONFIG += plugin, otherwise it wouldn't link. -EmberCL.pro: Add new files for multi-GPU support. -build_all.sh: use -j4 and QMAKE=${QMAKE:/usr/bin/qmake} -shared_settings.pri: -Add version string. -Remove old DESTDIR definitions. -Add the following lines or else nothing would build: CONFIG(release, debug|release) { CONFIG += warn_off DESTDIR = ../../../Bin/release } CONFIG(debug, debug|release) { DESTDIR = ../../../Bin/debug } QMAKE_POST_LINK += $$quote(cp --update ../../../Data/flam3-palettes.xml $${DESTDIR}$$escape_expand(\n\t)) LIBS += -L/usr/lib -lpthread -AboutDialog.ui: Another futile attempt to make it look correct on Linux. -FinalRenderDialog.h/cpp: --Add support for multi-GPU. --Change from combo boxes for device selection to a table of all devices. --Ensure device selection makes sense. --Remove "FinalRender" prefix of various function names, it's implied given the context. -FinalRenderEmberController.h/cpp: --Add support for multi-GPU. --Change m_FinishedImageCount to be atomic. --Move CancelRender() from the base to FinalRenderEmberController<T>. --Refactor RenderComplete() to omit any progress related functionality or image saving since it can be potentially ran in a thread. --Consolidate setting various renderer fields into SyncGuiToRenderer(). -Fractorium.cpp: Allow for resizing of the options dialog to show the entire device table. -FractoriumCommon.h: Add various functions to handle a table showing the available OpenCL devices on the system. -FractoriumEmberController.h/cpp: Remove m_FinalImageIndex, it's no longer needed. -FractoriumRender.cpp: Scale the interactive sub batch count and quality by the number of devices used. -FractoriumSettings.h/cpp: --Temporal samples defaults to 100 instead of 1000 which was needless overkill. --Add multi-GPU support, remove old device,platform pair. -FractoriumToolbar.cpp: Disable OpenCL toolbar button if there are no devices present on the system. -FractoriumOptionsDialog.h/cpp: --Add support for multi-GPU. --Consolidate more assignments in DataToGui(). --Enable/disable CPU/OpenCL items in response to OpenCL checkbox event. -Misc: Convert almost everything to size_t for unsigned, intmax_t for signed.
This commit is contained in:
@ -293,7 +293,7 @@ template <typename T>
|
||||
typename m4T Affine2D<T>::ToMat4ColMajor(bool center) const
|
||||
{
|
||||
m4T mat(A(), B(), 0, center ? 0 : C(), //Col0...
|
||||
D(), E(), 0, center ? 0 : F(), //1
|
||||
D(), E(), 0, center ? 0 : F(), //1
|
||||
0, 0, 1, 0, //2
|
||||
0, 0, 0, 1);//3
|
||||
|
||||
@ -309,7 +309,7 @@ template <typename T>
|
||||
typename m4T Affine2D<T>::ToMat4RowMajor(bool center) const
|
||||
{
|
||||
m4T mat(A(), D(), 0, 0,
|
||||
B(), E(), 0, 0,
|
||||
B(), E(), 0, 0,
|
||||
0, 0, 1, 0,
|
||||
center ? 0 : C(), center ? 0 : F(), 0, 1);
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
template <typename U>
|
||||
Curves<T>& operator = (const Curves<U>& curves)
|
||||
{
|
||||
for (uint i = 0; i < 4; i++)
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
m_Points[i][0].x = T(curves.m_Points[i][0].x); m_Points[i][0].y = T(curves.m_Points[i][0].y); m_Weights[i].x = T(curves.m_Weights[i].x);
|
||||
m_Points[i][1].x = T(curves.m_Points[i][1].x); m_Points[i][1].y = T(curves.m_Points[i][1].y); m_Weights[i].y = T(curves.m_Weights[i].y);
|
||||
@ -87,7 +87,7 @@ public:
|
||||
/// <returns>Reference to updated self</returns>
|
||||
Curves<T>& operator += (const Curves<T>& curves)
|
||||
{
|
||||
for (uint i = 0; i < 4; i++)
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
m_Points[i][0] += curves.m_Points[i][0];
|
||||
m_Points[i][1] += curves.m_Points[i][1];
|
||||
@ -107,7 +107,7 @@ public:
|
||||
/// <returns>Reference to updated self</returns>
|
||||
Curves<T>& operator *= (const Curves<T>& curves)
|
||||
{
|
||||
for (uint i = 0; i < 4; i++)
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
m_Points[i][0] *= curves.m_Points[i][0];
|
||||
m_Points[i][1] *= curves.m_Points[i][1];
|
||||
@ -127,7 +127,7 @@ public:
|
||||
/// <returns>Reference to updated self</returns>
|
||||
Curves<T>& operator *= (const T& t)
|
||||
{
|
||||
for (uint i = 0; i < 4; i++)
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
m_Points[i][0] *= t;
|
||||
m_Points[i][1] *= t;
|
||||
@ -145,7 +145,7 @@ public:
|
||||
/// </summary>
|
||||
void Init()
|
||||
{
|
||||
for (uint i = 0; i < 4; i++)
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
m_Points[i][0] = v2T(0);//0,0 -> 0,0 -> 1,1 -> 1,1.
|
||||
m_Points[i][1] = v2T(0);
|
||||
@ -173,7 +173,7 @@ public:
|
||||
{
|
||||
bool set = false;
|
||||
|
||||
for (uint i = 0; i < 4; i++)
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
if ((m_Points[i][0] != v2T(0)) ||
|
||||
(m_Points[i][1] != v2T(0)) ||
|
||||
@ -257,7 +257,7 @@ Curves<T> operator * (const Curves<T>& curves, const T& t)
|
||||
{
|
||||
Curves<T> c(curves);
|
||||
|
||||
for (uint i = 0; i < 4; i++)
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
c.m_Points[i][0] *= t;
|
||||
c.m_Points[i][1] *= t;
|
||||
|
@ -1075,14 +1075,15 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="sym">The type of symmetry to add</param>
|
||||
/// <param name="rand">The random context to use for generating random symmetry</param>
|
||||
void AddSymmetry(int sym, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
void AddSymmetry(intmax_t sym, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
size_t i, k, result = 0;
|
||||
intmax_t k;
|
||||
size_t i, result = 0;
|
||||
T a;
|
||||
|
||||
if (sym == 0)
|
||||
{
|
||||
static int symDistrib[] = {
|
||||
static intmax_t symDistrib[] = {
|
||||
-4, -3,
|
||||
-2, -2, -2,
|
||||
-1, -1, -1,
|
||||
@ -1356,6 +1357,9 @@ public:
|
||||
case FLAME_MOTION_VIBRANCY:
|
||||
APP_FMP(m_Vibrancy);
|
||||
break;
|
||||
case FLAME_MOTION_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1581,7 +1585,7 @@ public:
|
||||
|
||||
//Whether or not any symmetry was added. This field is in a bit of a state of conflict right now as flam3 has a severe bug.
|
||||
//Xml field: "symmetry".
|
||||
int m_Symmetry;
|
||||
intmax_t m_Symmetry;
|
||||
|
||||
//The number of iterations per pixel of the final output image. Note this is not affected by the increase in pixels in the
|
||||
//histogram and DE filtering buffer due to supersampling. It can be affected by a non-zero zoom value though.
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="other">The MotionParam object to copy</param>
|
||||
MotionParam(const MotionParam<T>& other)
|
||||
: pair <eEmberMotionParam, T>()
|
||||
{
|
||||
operator=<T>(other);
|
||||
}
|
||||
@ -70,8 +71,8 @@ public:
|
||||
template <typename U>
|
||||
MotionParam &operator = (const MotionParam<U>& other)
|
||||
{
|
||||
this->first = other.first;
|
||||
this->second = T(other.second);
|
||||
this->first = other.first;
|
||||
this->second = T(other.second);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
#pragma once
|
||||
#ifdef WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Precompiled header file. Place all system includes here with appropriate #defines for different operating systems and compilers.
|
||||
|
@ -104,13 +104,19 @@ public:
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
if (f.is_open())
|
||||
f.close();
|
||||
|
||||
cout << "Error: Writing flame " << filename << " failed: " << e.what() << endl;
|
||||
b = false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "Error: Writing flame " << filename << " failed." << endl;
|
||||
b = false;
|
||||
}
|
||||
|
||||
if (f.is_open())
|
||||
f.close();
|
||||
|
||||
return b;
|
||||
}
|
||||
@ -125,7 +131,7 @@ public:
|
||||
/// <param name="intPalette">If true use integers instead of floating point numbers when embedding a non-hex formatted palette, else use floating point numbers.</param>
|
||||
/// <param name="hexPalette">If true, embed a hexadecimal palette instead of Xml Color tags, else use Xml color tags.</param>
|
||||
/// <returns>The Xml string representation of the passed in ember</returns>
|
||||
string ToString(Ember<T>& ember, string extraAttributes, size_t printEditDepth, bool doEdits, bool intPalette, bool hexPalette = true)
|
||||
string ToString(Ember<T>& ember, const string& extraAttributes, size_t printEditDepth, bool doEdits, bool intPalette, bool hexPalette = true)
|
||||
{
|
||||
size_t i, j;
|
||||
string s;
|
||||
@ -313,7 +319,7 @@ public:
|
||||
/// <param name="sheepGen">The sheep generation used if > 0. Default: 0.</param>
|
||||
/// <param name="sheepId">The sheep id used if > 0. Default: 0.</param>
|
||||
/// <returns></returns>
|
||||
xmlDocPtr CreateNewEditdoc(Ember<T>* parent0, Ember<T>* parent1, string action, string nick, string url, string id, string comment, int sheepGen = 0, int sheepId = 0)
|
||||
xmlDocPtr CreateNewEditdoc(Ember<T>* parent0, Ember<T>* parent1, const string& action, const string& nick, const string& url, const string& id, const string& comment, intmax_t sheepGen = 0, intmax_t sheepId = 0)
|
||||
{
|
||||
char timeString[128];
|
||||
time_t myTime;
|
||||
@ -750,6 +756,7 @@ private:
|
||||
case MOTION_TRIANGLE:
|
||||
os << "\"triangle\"";
|
||||
break;
|
||||
default:
|
||||
case MOTION_SAW:
|
||||
os << "\"saw\"";
|
||||
break;
|
||||
@ -761,7 +768,7 @@ private:
|
||||
T cx = 0.0;
|
||||
T cy = 0.0;
|
||||
|
||||
for (int i = 0; i < motion.m_MotionParams.size(); ++i)
|
||||
for (size_t i = 0; i < motion.m_MotionParams.size(); ++i)
|
||||
{
|
||||
switch(motion.m_MotionParams[i].first)
|
||||
{
|
||||
@ -816,6 +823,9 @@ private:
|
||||
case FLAME_MOTION_VIBRANCY:
|
||||
os << " vibrancy=\"" << motion.m_MotionParams[i].second << "\"";
|
||||
break;
|
||||
case FLAME_MOTION_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class EMBER_API QTIsaac
|
||||
public:
|
||||
enum { N = (1 << ALPHA) };
|
||||
UintBytes m_Cache;
|
||||
int m_LastIndex;
|
||||
size_t m_LastIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Global ISAAC RNG to be used from anywhere. This is not thread safe, so take caution to only
|
||||
@ -94,7 +94,7 @@ public:
|
||||
Srand(a, b, c, s);
|
||||
m_LastIndex = 0;
|
||||
m_Cache.Uint = Rand();
|
||||
T temp = RandByte();//Need to call at least once so other libraries can link.
|
||||
RandByte();//Need to call at least once so other libraries can link.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -291,12 +291,12 @@ public:
|
||||
{
|
||||
if (s == nullptr)//Default to using time plus index as the seed if s was nullptr.
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
m_Rc.randrsl[i] = static_cast<T>(NowMs()) + i;
|
||||
for (size_t i = 0; i < N; i++)
|
||||
m_Rc.randrsl[i] = static_cast<T>(NowMs() + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
for (size_t i = 0; i < N; i++)
|
||||
m_Rc.randrsl[i] = s[i];
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
/// <param name="index">The index in the palette file</param>
|
||||
/// <param name="size">The size of the palette which should be 256</param>
|
||||
/// <param name="xmlPaletteEntries">A pointer to 256 color entries</param>
|
||||
Palette(const string& name, int index, uint size, v4T* xmlPaletteEntries)
|
||||
Palette(const string& name, int index, size_t size, v4T* xmlPaletteEntries)
|
||||
{
|
||||
m_Name = name;
|
||||
m_Index = index;
|
||||
@ -86,7 +86,7 @@ public:
|
||||
0x00, 0x81, 0x96, 0x8d, 0x00, 0x81, 0x9a, 0x8d, 0x00, 0x85, 0x9a, 0x8d, 0x00, 0x89, 0x9e, 0x8d, 0x00, 0x89, 0x9e, 0x8d, 0x00, 0x8d, 0xa2, 0x97, 0x00, 0x95, 0xa2, 0x97, 0x00, 0x8d, 0xa2, 0x97,
|
||||
0x00, 0x96, 0xa6, 0x8d, 0x00, 0x9a, 0xa1, 0x8d, 0x00, 0x9e, 0xa9, 0x84, 0x00, 0x9e, 0xa6, 0x7a, 0x00, 0xa2, 0xa5, 0x71, 0x00, 0x9e, 0xa6, 0x71, 0x00, 0x9a, 0xa6, 0x71, 0x00, 0x95, 0x9d, 0x71 };
|
||||
|
||||
for (uint i = 0; i < size; i++)
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
m_Entries[i].a = T(palette15[i * 4 + 0]);
|
||||
m_Entries[i].r = T(palette15[i * 4 + 1]);
|
||||
@ -208,7 +208,7 @@ public:
|
||||
palette.m_Filename = m_Filename;
|
||||
palette.m_Entries.resize(Size());
|
||||
|
||||
for (uint i = 0; i < Size(); i++)
|
||||
for (size_t i = 0; i < Size(); i++)
|
||||
{
|
||||
size_t ii = (i * 256) / COLORMAP_LENGTH;
|
||||
T rgb[3], hsv[3];
|
||||
@ -348,7 +348,7 @@ public:
|
||||
if (palette.Size() != Size())
|
||||
palette.m_Entries.resize(Size());
|
||||
|
||||
for (uint j = 0; j < palette.Size(); j++)
|
||||
for (size_t j = 0; j < palette.Size(); j++)
|
||||
{
|
||||
palette.m_Entries[j] = m_Entries[j] * colorScalar;
|
||||
palette.m_Entries[j].a = 1;
|
||||
@ -362,16 +362,16 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="height">The height of the output block</param>
|
||||
/// <returns>A vector holding the color values</returns>
|
||||
vector<byte> MakeRgbPaletteBlock(uint height)
|
||||
vector<byte> MakeRgbPaletteBlock(size_t height)
|
||||
{
|
||||
size_t width = Size();
|
||||
vector<byte> v(height * width * 3);
|
||||
|
||||
if (v.size() == (height * Size() * 3))
|
||||
{
|
||||
for (uint i = 0; i < height; i++)
|
||||
for (size_t i = 0; i < height; i++)
|
||||
{
|
||||
for (uint j = 0; j < width; j++)
|
||||
for (size_t j = 0; j < width; j++)
|
||||
{
|
||||
v[(width * 3 * i) + (j * 3)] = byte(m_Entries[j][0] * T(255));//Palettes are as [0..1], so convert to [0..255] here since it's for GUI display.
|
||||
v[(width * 3 * i) + (j * 3) + 1] = byte(m_Entries[j][1] * T(255));
|
||||
@ -443,7 +443,7 @@ public:
|
||||
/// <param name="b">Blue 0 - 1</param>
|
||||
static void HsvToRgb(T h, T s, T v, T& r, T& g, T& b)
|
||||
{
|
||||
int j;
|
||||
intmax_t j;
|
||||
T f, p, q, t;
|
||||
|
||||
while (h >= 6)
|
||||
@ -522,7 +522,7 @@ public:
|
||||
template<typename bucketT>
|
||||
static void CalcNewRgb(bucketT* cBuf, T ls, T highPow, bucketT* newRgb)
|
||||
{
|
||||
int rgbi;
|
||||
size_t rgbi;
|
||||
T newls, lsratio;
|
||||
bucketT newhsv[3];
|
||||
T maxa, maxc;
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
Palette<T>* GetRandomPalette()
|
||||
{
|
||||
auto p = m_Palettes.begin();
|
||||
int i = 0, paletteFileIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand() % Size();
|
||||
size_t i = 0, paletteFileIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand() % Size();
|
||||
|
||||
//Move p forward i elements.
|
||||
while (i < paletteFileIndex && p != m_Palettes.end())
|
||||
@ -91,7 +91,7 @@ public:
|
||||
|
||||
if (i < Size())
|
||||
{
|
||||
int paletteIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand() % p->second.size();
|
||||
size_t paletteIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand() % p->second.size();
|
||||
|
||||
if (paletteIndex < p->second.size())
|
||||
return &p->second[paletteIndex];
|
||||
@ -106,11 +106,11 @@ public:
|
||||
/// <param name="filename">The filename of the palette to retrieve</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 nullptr.</returns>
|
||||
Palette<T>* GetPalette(const string& filename, int i)
|
||||
Palette<T>* GetPalette(const string& filename, size_t i)
|
||||
{
|
||||
auto& palettes = m_Palettes[filename];
|
||||
|
||||
if (!palettes.empty() && i < int(palettes.size()))
|
||||
if (!palettes.empty() && i < palettes.size())
|
||||
return &palettes[i];
|
||||
|
||||
return nullptr;
|
||||
@ -142,7 +142,7 @@ public:
|
||||
/// <param name="hue">The hue adjustment to apply</param>
|
||||
/// <param name="palette">The palette to store the output</param>
|
||||
/// <returns>True if successful, else false.</returns>
|
||||
bool GetHueAdjustedPalette(const string& filename, int i, T hue, Palette<T>& palette)
|
||||
bool GetHueAdjustedPalette(const string& filename, size_t i, T hue, Palette<T>& palette)
|
||||
{
|
||||
bool b = false;
|
||||
|
||||
|
@ -151,6 +151,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="color">The Color object to copy</param>
|
||||
Color(const Color<T>& color)
|
||||
: v4T()
|
||||
{
|
||||
Color<T>::operator=<T>(color);
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ Finish:
|
||||
/// <param name="hexPalette">If true, embed a hexadecimal palette instead of Xml Color tags, else use Xml color tags.</param>
|
||||
/// <returns>The EmberImageComments object with image comments filled out</returns>
|
||||
template <typename T, typename bucketT>
|
||||
EmberImageComments Renderer<T, bucketT>::ImageComments(EmberStats& stats, size_t printEditDepth, bool intPalette, bool hexPalette)
|
||||
EmberImageComments Renderer<T, bucketT>::ImageComments(const EmberStats& stats, size_t printEditDepth, bool intPalette, bool hexPalette)
|
||||
{
|
||||
ostringstream ss;
|
||||
EmberImageComments comments;
|
||||
@ -708,7 +708,7 @@ void Renderer<T, bucketT>::MakeDmap(T colorScalar)
|
||||
/// </summary>
|
||||
/// <returns>True if success, else false</returns>
|
||||
template <typename T, typename bucketT>
|
||||
bool Renderer<T, bucketT>::Alloc()
|
||||
bool Renderer<T, bucketT>::Alloc(bool histOnly)
|
||||
{
|
||||
bool b = true;
|
||||
bool lock =
|
||||
@ -730,6 +730,14 @@ bool Renderer<T, bucketT>::Alloc()
|
||||
b &= (m_HistBuckets.size() == m_SuperSize);
|
||||
}
|
||||
|
||||
if (histOnly)
|
||||
{
|
||||
if (lock)
|
||||
LeaveResize();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
if (m_SuperSize != m_AccumulatorBuckets.size())
|
||||
{
|
||||
m_AccumulatorBuckets.resize(m_SuperSize);
|
||||
@ -1224,7 +1232,7 @@ EmberStats Renderer<T, bucketT>::Iterate(size_t iterCount, size_t temporalSample
|
||||
sp.sched_priority = m_Priority;
|
||||
pthread_setschedparam(pthread_self(), SCHED_RR, &sp);
|
||||
#else
|
||||
pthread_setschedprio(pthread_self(), (int)m_Priority);
|
||||
pthread_setschedprio(pthread_self(), int(m_Priority));
|
||||
#endif
|
||||
//Timing t;
|
||||
IterParams<T> params;
|
||||
@ -1268,7 +1276,6 @@ EmberStats Renderer<T, bucketT>::Iterate(size_t iterCount, size_t temporalSample
|
||||
if (m_Callback && threadIndex == 0)
|
||||
{
|
||||
percent = 100.0 *
|
||||
|
||||
double
|
||||
(
|
||||
double
|
||||
@ -1342,7 +1349,7 @@ template <typename T, typename bucketT> T Renderer<T, bucketT>::PixelsP
|
||||
template <typename T, typename bucketT> T Renderer<T, bucketT>::PixelsPerUnitY() const { return m_PixelsPerUnitY; }
|
||||
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::K1() const { return m_K1; }
|
||||
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::K2() const { return m_K2; }
|
||||
template <typename T, typename bucketT> const CarToRas<T>* Renderer<T, bucketT>::CoordMap() const { return &m_CarToRas; }
|
||||
template <typename T, typename bucketT> const CarToRas<T>& Renderer<T, bucketT>::CoordMap() const { return m_CarToRas; }
|
||||
template <typename T, typename bucketT> tvec4<bucketT, glm::defaultp>* Renderer<T, bucketT>::HistBuckets() { return m_HistBuckets.data(); }
|
||||
template <typename T, typename bucketT> tvec4<bucketT, glm::defaultp>* Renderer<T, bucketT>::AccumulatorBuckets() { return m_AccumulatorBuckets.data(); }
|
||||
template <typename T, typename bucketT> SpatialFilter<bucketT>* Renderer<T, bucketT>::GetSpatialFilter() { return m_SpatialFilter.get(); }
|
||||
|
@ -38,9 +38,7 @@ namespace EmberNs
|
||||
/// for every single function in this class, saying it can't find the implementation. This warning
|
||||
/// can be safely ignored.
|
||||
/// Template argument T expected to be float or double.
|
||||
/// Template argument bucketT was originally used to experiment with different types for the histogram, however
|
||||
/// the only types that work are float and double, so it's useless and should always match what T is.
|
||||
/// Mismatched types between T and bucketT are undefined.
|
||||
/// Template argument bucketT must always be float.
|
||||
/// </summary>
|
||||
template <typename T, typename bucketT>
|
||||
class EMBER_API Renderer : public RendererBase
|
||||
@ -65,12 +63,12 @@ public:
|
||||
virtual bool CreateTemporalFilter(bool& newAlloc) override;
|
||||
virtual size_t HistBucketSize() const override { return sizeof(tvec4<bucketT, glm::defaultp>); }
|
||||
virtual eRenderStatus Run(vector<byte>& finalImage, double time = 0, size_t subBatchCountOverride = 0, bool forceOutput = false, size_t finalOffset = 0) override;
|
||||
virtual EmberImageComments ImageComments(EmberStats& stats, size_t printEditDepth = 0, bool intPalette = false, bool hexPalette = true) override;
|
||||
virtual EmberImageComments ImageComments(const EmberStats& stats, size_t printEditDepth = 0, bool intPalette = false, bool hexPalette = true) override;
|
||||
|
||||
protected:
|
||||
//New virtual functions to be overridden in derived renderers that use the GPU, but not accessed outside.
|
||||
virtual void MakeDmap(T colorScalar);
|
||||
virtual bool Alloc();
|
||||
virtual bool Alloc(bool histOnly = false);
|
||||
virtual bool ResetBuckets(bool resetHist = true, bool resetAccum = true);
|
||||
virtual eRenderStatus LogScaleDensityFilter();
|
||||
virtual eRenderStatus GaussianDensityFilter();
|
||||
@ -89,7 +87,7 @@ public:
|
||||
inline T PixelsPerUnitY() const;
|
||||
inline bucketT K1() const;
|
||||
inline bucketT K2() const;
|
||||
inline const CarToRas<T>* CoordMap() const;
|
||||
inline const CarToRas<T>& CoordMap() const;
|
||||
inline tvec4<bucketT, glm::defaultp>* HistBuckets();
|
||||
inline tvec4<bucketT, glm::defaultp>* AccumulatorBuckets();
|
||||
inline SpatialFilter<bucketT>* GetSpatialFilter();
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
virtual void ComputeQuality() = 0;
|
||||
virtual void ComputeCamera() = 0;
|
||||
virtual eRenderStatus Run(vector<byte>& finalImage, double time = 0, size_t subBatchCountOverride = 0, bool forceOutput = false, size_t finalOffset = 0) = 0;
|
||||
virtual EmberImageComments ImageComments(EmberStats& stats, size_t printEditDepth = 0, bool intPalette = false, bool hexPalette = true) = 0;
|
||||
virtual EmberImageComments ImageComments(const EmberStats& stats, size_t printEditDepth = 0, bool intPalette = false, bool hexPalette = true) = 0;
|
||||
virtual DensityFilterBase* GetDensityFilter() = 0;
|
||||
|
||||
//Non-virtual renderer properties, getters only.
|
||||
|
@ -44,7 +44,7 @@ enum eCrossMode
|
||||
/// Most functions in this class perform a particular action and return
|
||||
/// a string describing what it did so it can be recorded in an Xml edit doc
|
||||
/// to be saved with the ember when converting to Xml.
|
||||
/// Since it's members can occupy significant memory space and also have
|
||||
/// Since its members can occupy significant memory space and also have
|
||||
/// hefty initialization sequences, it's important to declare one instance
|
||||
/// and reuse it for the duration of the program instead of creating and deleting
|
||||
/// them as local variables.
|
||||
@ -186,11 +186,10 @@ public:
|
||||
/// <param name="sym">The type of symmetry to add if random specified. If 0, it will be added randomly.</param>
|
||||
/// <param name="speed">The speed to multiply the pre affine transforms by if the mutate mode is MUTATE_ALL_COEFS, else ignored.</param>
|
||||
/// <returns>A string describing what was done</returns>
|
||||
string Mutate(Ember<T>& ember, eMutateMode mode, vector<eVariationId>& useVars, int sym, T speed)
|
||||
string Mutate(Ember<T>& ember, eMutateMode mode, vector<eVariationId>& useVars, intmax_t sym, T speed)
|
||||
{
|
||||
bool done = false;
|
||||
size_t modXform;
|
||||
char ministr[32];
|
||||
T randSelect;
|
||||
ostringstream os;
|
||||
Ember<T> mutation;
|
||||
@ -285,14 +284,13 @@ public:
|
||||
else if (mode == MUTATE_POST_XFORMS)
|
||||
{
|
||||
bool same = (m_Rand.Rand() & 3) > 0;//25% chance of using the same post for all of them.
|
||||
uint b = 1 + m_Rand.Rand() % 6;
|
||||
size_t b = 1 + m_Rand.Rand() % 6;
|
||||
|
||||
sprintf_s(ministr, 32, "(%d%s)", b, same ? " same" : "");
|
||||
os << "mutate post xforms " << ministr;
|
||||
os << "mutate post xforms " << b << (same ? " same" : "");
|
||||
|
||||
for (size_t i = 0; i < ember.TotalXformCount(); i++)
|
||||
{
|
||||
int copy = (i > 0) && same;
|
||||
bool copy = (i > 0) && same;
|
||||
Xform<T>* xform = ember.GetTotalXform(i);
|
||||
|
||||
if (copy)//Copy the post from the first xform to the rest of them.
|
||||
@ -605,7 +603,7 @@ public:
|
||||
{
|
||||
vector<eVariationId> useVars;
|
||||
|
||||
Random(ember, useVars, static_cast<int>(m_Rand.Frand<T>(-2, 2)), 0);
|
||||
Random(ember, useVars, static_cast<intmax_t>(m_Rand.Frand<T>(-2, 2)), 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -615,7 +613,7 @@ public:
|
||||
/// <param name="useVars">A list of variations to use. If empty, any variation can be used.</param>
|
||||
/// <param name="sym">The symmetry type to use from -2 to 2</param>
|
||||
/// <param name="specXforms">The number of xforms to use. If 0, a quasi random count is used.</param>
|
||||
void Random(Ember<T>& ember, vector<eVariationId>& useVars, int sym, size_t specXforms)
|
||||
void Random(Ember<T>& ember, vector<eVariationId>& useVars, intmax_t sym, size_t specXforms)
|
||||
{
|
||||
bool postid, addfinal = false;
|
||||
int var, samed, multid, samepost;
|
||||
@ -806,9 +804,9 @@ public:
|
||||
/// <param name="tries">The number of test renders to try before giving up</param>
|
||||
/// <param name="changePalette">Change palette if true, else keep trying with the same palette.</param>
|
||||
/// <param name="colorResolution">The resolution of the test histogram. This value ^ 3 will be used for the total size. Common value is 10.</param>
|
||||
void ImproveColors(Ember<T>& ember, int tries, bool changePalette, int colorResolution)
|
||||
void ImproveColors(Ember<T>& ember, size_t tries, bool changePalette, size_t colorResolution)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
T best, b;
|
||||
Ember<T> bestEmber = ember;
|
||||
|
||||
@ -847,7 +845,7 @@ public:
|
||||
/// <param name="ember">The ember to render</param>
|
||||
/// <param name="colorResolution">The resolution of the test histogram. This value ^ 3 will be used for the total size. Common value is 10.</param>
|
||||
/// <returns>The number of histogram cells that weren't black</returns>
|
||||
T TryColors(Ember<T>& ember, int colorResolution)
|
||||
T TryColors(Ember<T>& ember, size_t colorResolution)
|
||||
{
|
||||
byte* p;
|
||||
size_t i, hits = 0, res = colorResolution;
|
||||
@ -903,7 +901,7 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change around color coordinates. Optionall change out the entire palette.
|
||||
/// Change around color coordinates. Optionally change out the entire palette.
|
||||
/// </summary>
|
||||
/// <param name="ember">The ember whose xform's color coordinates will be changed</param>
|
||||
/// <param name="changePalette">Change palette if true, else don't</param>
|
||||
@ -1071,7 +1069,7 @@ public:
|
||||
/// <param name="result">The result of the spin</param>
|
||||
/// <param name="frame">The frame in the sequence to be stored in the m_Time member of result</param>
|
||||
/// <param name="blend">The interpolation time</param>
|
||||
void Spin(Ember<T>& parent, Ember<T>* templ, Ember<T>& result, int frame, T blend)
|
||||
void Spin(Ember<T>& parent, Ember<T>* templ, Ember<T>& result, size_t frame, T blend)
|
||||
{
|
||||
char temp[50];
|
||||
|
||||
@ -1112,7 +1110,7 @@ public:
|
||||
/// <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="blend">The interpolation time</param>
|
||||
void SpinInter(Ember<T>* parents, Ember<T>* templ, Ember<T>& result, int frame, bool seqFlag, T blend)
|
||||
void SpinInter(Ember<T>* parents, Ember<T>* templ, Ember<T>& result, size_t frame, bool seqFlag, T blend)
|
||||
{
|
||||
char temp[50];
|
||||
|
||||
@ -1286,8 +1284,8 @@ public:
|
||||
m_Samples.resize(samples);
|
||||
params.m_Count = samples;
|
||||
params.m_Skip = 20;
|
||||
//params.m_OneColDiv2 = m_Renderer->CoordMap()->OneCol() / 2;
|
||||
//params.m_OneRowDiv2 = m_Renderer->CoordMap()->OneRow() / 2;
|
||||
//params.m_OneColDiv2 = m_Renderer->CoordMap().OneCol() / 2;
|
||||
//params.m_OneRowDiv2 = m_Renderer->CoordMap().OneRow() / 2;
|
||||
|
||||
size_t bv = m_Iterator->Iterate(ember, params, m_Samples.data(), m_Rand);//Use a special fuse of 20, all other calls to this will use 15, or 100.
|
||||
|
||||
@ -1349,7 +1347,7 @@ public:
|
||||
/// <param name="comment">The comment to include</param>
|
||||
/// <param name="sheepGen">The sheep generation used if > 0. Default: 0.</param>
|
||||
/// <param name="sheepId">The sheep id used if > 0. Default: 0.</param>
|
||||
void SetSpinParams(bool smooth, T stagger, T offsetX, T offsetY, string nick, string url, string id, string comment, int sheepGen, int sheepId)
|
||||
void SetSpinParams(bool smooth, T stagger, T offsetX, T offsetY, const string& nick, const string& url, const string& id, const string& comment, intmax_t sheepGen, intmax_t sheepId)
|
||||
{
|
||||
m_Smooth = smooth;
|
||||
m_SheepGen = sheepGen;
|
||||
@ -1365,8 +1363,8 @@ public:
|
||||
|
||||
private:
|
||||
bool m_Smooth;
|
||||
int m_SheepGen;
|
||||
int m_SheepId;
|
||||
intmax_t m_SheepGen;
|
||||
intmax_t m_SheepId;
|
||||
T m_Stagger;
|
||||
T m_OffsetX;
|
||||
T m_OffsetY;
|
||||
|
@ -62,19 +62,19 @@ public:
|
||||
/// Return the begin time as a double.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
double BeginTime() { return static_cast<double>(m_BeginTime.time_since_epoch().count()); }
|
||||
double BeginTime() const { return static_cast<double>(m_BeginTime.time_since_epoch().count()); }
|
||||
|
||||
/// <summary>
|
||||
/// Return the end time as a double.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
double EndTime() { return static_cast<double>(m_EndTime.time_since_epoch().count()); }
|
||||
double EndTime() const { return static_cast<double>(m_EndTime.time_since_epoch().count()); }
|
||||
|
||||
/// <summary>
|
||||
/// Return the elapsed time in milliseconds.
|
||||
/// </summary>
|
||||
/// <returns>The elapsed time in milliseconds as a double</returns>
|
||||
double ElapsedTime()
|
||||
double ElapsedTime() const
|
||||
{
|
||||
duration<double> elapsed = duration_cast<milliseconds, Clock::rep, Clock::period>(m_EndTime - m_BeginTime);
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="ms">The ms</param>
|
||||
/// <returns>The formatted string</returns>
|
||||
string Format(double ms)
|
||||
string Format(double ms) const
|
||||
{
|
||||
stringstream ss;
|
||||
|
||||
|
@ -213,13 +213,19 @@ static bool ReadFile(const char* filename, string& buf, bool nullTerminate = tru
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
if (f != nullptr)
|
||||
fclose(f);
|
||||
|
||||
cout << "Error: Reading file " << filename << " failed: " << e.what() << endl;
|
||||
b = false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "Error: Reading file " << filename << " failed." << endl;
|
||||
b = false;
|
||||
}
|
||||
|
||||
if (f != nullptr)
|
||||
fclose(f);
|
||||
|
||||
return b;
|
||||
}
|
||||
@ -270,7 +276,7 @@ static void CopyVec(vector<T>& dest, const vector<U>& source, std::function<void
|
||||
template <typename T>
|
||||
static void ClearVec(vector<T*>& vec, bool arrayDelete = false)
|
||||
{
|
||||
for (uint i = 0; i < vec.size(); i++)
|
||||
for (size_t i = 0; i < vec.size(); i++)
|
||||
{
|
||||
if (vec[i] != nullptr)
|
||||
{
|
||||
@ -286,6 +292,32 @@ static void ClearVec(vector<T*>& vec, bool arrayDelete = false)
|
||||
vec.clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine whether all elements in two containers are equal.
|
||||
/// </summary>
|
||||
/// <param name="c1">The first collection to compare</param>
|
||||
/// <param name="c2">The second collection to compare</param>
|
||||
/// <returns>True if the sizes and all elements in both collections are equal, else false.</returns>
|
||||
template <typename T>
|
||||
static bool Equal(const T& c1, const T& c2)
|
||||
{
|
||||
bool equal = c1.size() == c2.size();
|
||||
|
||||
if (equal)
|
||||
{
|
||||
for (auto it1 = c1.begin(), it2 = c2.begin(); it1 != c1.end(); ++it1, ++it2)
|
||||
{
|
||||
if (*it1 != *it2)
|
||||
{
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return equal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thin wrapper around passing a vector to memset() to relieve
|
||||
/// the caller of having to pass the size.
|
||||
@ -305,15 +337,15 @@ static inline void Memset(vector<T>& vec, int val = 0)
|
||||
/// <param name="x">The value to return the floor of</param>
|
||||
/// <returns>The floored value</returns>
|
||||
template <typename T>
|
||||
static inline int Floor(T val)
|
||||
static inline intmax_t Floor(T val)
|
||||
{
|
||||
if (val >= 0)
|
||||
{
|
||||
return static_cast<int>(val);
|
||||
return static_cast<intmax_t>(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = static_cast<int>(val);//Truncate.
|
||||
intmax_t i = static_cast<intmax_t>(val);//Truncate.
|
||||
return i - (i > val);//Convert trunc to floor.
|
||||
}
|
||||
}
|
||||
@ -862,25 +894,9 @@ static string GetPath(const string& filename)
|
||||
/// <returns>The value of the specified environment variable if found, else default</returns>
|
||||
template <typename T>
|
||||
static inline T Arg(char* name, T def)
|
||||
{
|
||||
T t;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Template specialization for Arg<>() with a type of int.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the environment variable to query</param>
|
||||
/// <param name="def">The default value to return if the environment variable was not present</param>
|
||||
/// <returns>The value of the specified environment variable if found, else default</returns>
|
||||
template <>
|
||||
#ifdef _WIN32
|
||||
static
|
||||
#endif
|
||||
int Arg<int>(char* name, int def)
|
||||
{
|
||||
char* ch;
|
||||
int returnVal;
|
||||
T returnVal;
|
||||
#ifdef WIN32
|
||||
size_t len;
|
||||
errno_t err = _dupenv_s(&ch, &len, name);
|
||||
@ -892,7 +908,17 @@ int Arg<int>(char* name, int def)
|
||||
if (err || !ch)
|
||||
returnVal = def;
|
||||
else
|
||||
returnVal = atoi(ch);
|
||||
{
|
||||
T tempVal;
|
||||
istringstream istr(ch);
|
||||
|
||||
istr >> tempVal;
|
||||
|
||||
if (!istr.bad() && !istr.fail())
|
||||
returnVal = tempVal;
|
||||
else
|
||||
returnVal = def;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
free(ch);
|
||||
@ -900,21 +926,6 @@ int Arg<int>(char* name, int def)
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Template specialization for Arg<>() with a type of uint.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the environment variable to query</param>
|
||||
/// <param name="def">The default value to return if the environment variable was not present</param>
|
||||
/// <returns>The value of the specified environment variable if found, else default</returns>
|
||||
template <>
|
||||
#ifdef _WIN32
|
||||
static
|
||||
#endif
|
||||
uint Arg<uint>(char* name, uint def)
|
||||
{
|
||||
return Arg<int>(name, static_cast<int>(def));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Template specialization for Arg<>() with a type of bool.
|
||||
/// </summary>
|
||||
@ -930,39 +941,6 @@ bool Arg<bool>(char* name, bool def)
|
||||
return (Arg<int>(name, -999) != -999) ? true : def;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Template specialization for Arg<>() with a type of double.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the environment variable to query</param>
|
||||
/// <param name="def">The default value to return if the environment variable was not present</param>
|
||||
/// <returns>The value of the specified environment variable if found, else default</returns>
|
||||
template <>
|
||||
#ifdef _WIN32
|
||||
static
|
||||
#endif
|
||||
double Arg<double>(char* name, double def)
|
||||
{
|
||||
char* ch;
|
||||
double returnVal;
|
||||
#ifdef WIN32
|
||||
size_t len;
|
||||
errno_t err = _dupenv_s(&ch, &len, name);
|
||||
#else
|
||||
int err = 1;
|
||||
ch = getenv(name);
|
||||
#endif
|
||||
|
||||
if (err || !ch)
|
||||
returnVal = def;
|
||||
else
|
||||
returnVal = atof(ch);
|
||||
|
||||
#ifdef WIN32
|
||||
free(ch);
|
||||
#endif
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Template specialization for Arg<>() with a type of string.
|
||||
/// </summary>
|
||||
@ -1031,6 +1009,24 @@ static uint FindAndReplace(T& source, const T& find, const T& replace)
|
||||
return replaceCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Split a string into tokens and place them in a vector.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to split</param>
|
||||
/// <param name="del">The delimiter to split the string on</param>
|
||||
/// <returns>The split strings, each as an element in a vector.</returns>
|
||||
static vector<string> Split(const string& str, char del)
|
||||
{
|
||||
string tok;
|
||||
vector<string> vec;
|
||||
stringstream ss(str);
|
||||
|
||||
while (getline(ss, tok, del))
|
||||
vec.push_back(tok);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a character pointer to a version string composed of the EMBER_OS and EMBER_VERSION values.
|
||||
/// </summary>
|
||||
|
@ -1428,7 +1428,7 @@ public:
|
||||
/// <param name="type">The type of the parameter</param>
|
||||
/// <param name="min">The minimum value the parameter can be</param>
|
||||
/// <param name="max">The maximum value the parameter can be</param>
|
||||
ParamWithName(T* param, string name, T def = 0, eParamType type = REAL, T min = TLOW, T max = TMAX)
|
||||
ParamWithName(T* param, const string& name, T def = 0, eParamType type = REAL, T min = TLOW, T max = TMAX)
|
||||
{
|
||||
Init(param, name, def, type, min, max);
|
||||
}
|
||||
@ -1481,7 +1481,7 @@ public:
|
||||
/// <param name="min">The minimum value the parameter can be</param>
|
||||
/// <param name="max">The maximum value the parameter can be</param>
|
||||
/// <param name="isPrecalc">Whether the parameter is actually a precalculated value. Default: false.</param>
|
||||
void Init(T* param, string name, T def = 0, eParamType type = REAL, T min = TLOW, T max = TMAX, bool isPrecalc = false)
|
||||
void Init(T* param, const string& name, T def = 0, eParamType type = REAL, T min = TLOW, T max = TMAX, bool isPrecalc = false)
|
||||
{
|
||||
m_Param = param;
|
||||
m_Def = def;
|
||||
|
@ -355,7 +355,7 @@ public:
|
||||
|
||||
//Keep a list of which variations derive from ParametricVariation.
|
||||
//Note that these are not new copies, rather just pointers to the original instances in m_Variations.
|
||||
for (uint i = 0; i < m_Variations.size(); i++)
|
||||
for (size_t i = 0; i < m_Variations.size(); i++)
|
||||
{
|
||||
if (ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(m_Variations[i]))
|
||||
m_ParametricVariations.push_back(parVar);
|
||||
@ -412,7 +412,7 @@ public:
|
||||
/// <returns>A pointer to the variation if found, else nullptr.</returns>
|
||||
const Variation<T>* GetVariation(eVariationId id) const
|
||||
{
|
||||
for (uint i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
|
||||
for (size_t i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
|
||||
if (id == m_Variations[i]->VariationId())
|
||||
return m_Variations[i];
|
||||
|
||||
@ -435,7 +435,7 @@ public:
|
||||
/// <returns>A pointer to the variation if found, else nullptr.</returns>
|
||||
const Variation<T>* GetVariation(const string& name) const
|
||||
{
|
||||
for (uint i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
|
||||
for (size_t i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
|
||||
if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
|
||||
return m_Variations[i];
|
||||
|
||||
@ -466,7 +466,7 @@ public:
|
||||
/// <returns>The parametric variation with a matching name, else nullptr.</returns>
|
||||
const ParametricVariation<T>* GetParametricVariation(const string& name) const
|
||||
{
|
||||
for (uint i = 0; i < m_ParametricVariations.size() && m_ParametricVariations[i] != nullptr; i++)
|
||||
for (size_t i = 0; i < m_ParametricVariations.size() && m_ParametricVariations[i] != nullptr; i++)
|
||||
if (!_stricmp(name.c_str(), m_ParametricVariations[i]->Name().c_str()))
|
||||
return m_ParametricVariations[i];
|
||||
|
||||
@ -480,9 +480,9 @@ public:
|
||||
/// <returns>The index of the variation with the matching name, else -1</returns>
|
||||
int GetVariationIndex(const string& name)
|
||||
{
|
||||
for (uint i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
|
||||
for (size_t i = 0; i < m_Variations.size() && m_Variations[i] != nullptr; i++)
|
||||
if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
|
||||
return i;
|
||||
return int(i);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public:
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
T r = Zeps(pow(helper.m_PrecalcSqrtSumSquares, m_Dist));
|
||||
int n = Floor<T>(m_Power * rand.Frand01<T>());
|
||||
intmax_t n = Floor<T>(m_Power * rand.Frand01<T>());
|
||||
T alpha = helper.m_PrecalcAtanyx + n * M_2PI / Zeps<T>(T(Floor<T>(m_Power)));
|
||||
T sina = sin(alpha);
|
||||
T cosa = cos(alpha);
|
||||
@ -2571,7 +2571,7 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
int n;
|
||||
intmax_t n;
|
||||
|
||||
T z = 4 * m_Dist / m_Power;
|
||||
T r = pow(helper.m_PrecalcSqrtSumSquares, z);
|
||||
|
@ -1372,12 +1372,13 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
int i, j, l, k, m, m1, n, n1;
|
||||
intmax_t l, k;
|
||||
int i, j, m, m1, n, n1;
|
||||
T r, rMin, offsetX, offsetY, x0 = 0, y0 = 0, x, y;
|
||||
|
||||
rMin = 20;
|
||||
m = Floor<T>(helper.In.x / m_Step);
|
||||
n = Floor<T>(helper.In.y / m_Step);
|
||||
m = int(Floor<T>(helper.In.x / m_Step));
|
||||
n = int(Floor<T>(helper.In.y / m_Step));
|
||||
|
||||
for (i = -1; i < 2; i++)
|
||||
{
|
||||
|
@ -95,8 +95,8 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
int m = Floor<T>(T(0.5) * helper.In.x / m_Sc);
|
||||
int n = Floor<T>(T(0.5) * helper.In.y / m_Sc);
|
||||
int m = int(Floor<T>(T(0.5) * helper.In.x / m_Sc));
|
||||
int n = int(Floor<T>(T(0.5) * helper.In.y / m_Sc));
|
||||
T x = helper.In.x - (m * 2 + 1) * m_Sc;
|
||||
T y = helper.In.y - (n * 2 + 1) * m_Sc;
|
||||
T u = Zeps(Hypot(x, y));
|
||||
@ -277,7 +277,7 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
int m, n, iters = 0;
|
||||
intmax_t m, n, iters = 0;
|
||||
T x, y, u;
|
||||
|
||||
do
|
||||
@ -293,7 +293,7 @@ public:
|
||||
if (++iters > 10)
|
||||
break;
|
||||
}
|
||||
while ((DiscreteNoise2(int(m + m_Seed), n) > m_Dens) || (u > (T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3)) * m_Sc));
|
||||
while ((DiscreteNoise2(int(m + m_Seed), int(n)) > m_Dens) || (u > (T(0.3) + T(0.7) * DiscreteNoise2(int(m + 10), int(n + 3))) * m_Sc));
|
||||
|
||||
helper.Out.x = m_Weight * (x + (m * 2 + 1) * m_Sc);
|
||||
helper.Out.y = m_Weight * (y + (n * 2 + 1) * m_Sc);
|
||||
@ -406,14 +406,14 @@ public:
|
||||
|
||||
Trans(m_X, m_Y, helper.In.x, helper.In.y, &ux, &uy);
|
||||
|
||||
int m = Floor<T>(T(0.5) * ux / m_Sc);
|
||||
int n = Floor<T>(T(0.5) * uy / m_Sc);
|
||||
intmax_t m = Floor<T>(T(0.5) * ux / m_Sc);
|
||||
intmax_t n = Floor<T>(T(0.5) * uy / m_Sc);
|
||||
|
||||
x = ux - (m * 2 + 1) * m_Sc;
|
||||
y = uy - (n * 2 + 1) * m_Sc;
|
||||
u = Hypot(x, y);
|
||||
|
||||
if ((DiscreteNoise2(int(m + m_Seed), n) > m_Dens) || (u > (T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3)) * m_Sc))
|
||||
if ((DiscreteNoise2(int(m + m_Seed), int(n)) > m_Dens) || (u > (T(0.3) + T(0.7) * DiscreteNoise2(int(m + 10), int(n + 3))) * m_Sc))
|
||||
{
|
||||
ux = ux;
|
||||
uy = uy;
|
||||
@ -548,7 +548,7 @@ private:
|
||||
|
||||
void CircleR(T* ux, T* vy, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
int m, n, iters = 0;
|
||||
intmax_t m, n, iters = 0;
|
||||
T x, y, alpha, u;
|
||||
|
||||
do
|
||||
@ -558,14 +558,14 @@ private:
|
||||
m = Floor<T>(T(0.5) * x / m_Sc);
|
||||
n = Floor<T>(T(0.5) * y / m_Sc);
|
||||
alpha = M_2PI * rand.Frand01<T>();
|
||||
u = T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3);
|
||||
u = T(0.3) + T(0.7) * DiscreteNoise2(int(m + 10), int(n + 3));
|
||||
x = u * cos(alpha);
|
||||
y = u * sin(alpha);
|
||||
|
||||
if (++iters > 10)
|
||||
break;
|
||||
}
|
||||
while (DiscreteNoise2(int(m + m_Seed), n) > m_Dens);
|
||||
while (DiscreteNoise2(int(m + m_Seed), int(n)) > m_Dens);
|
||||
|
||||
*ux = x + (m * 2 + 1) * m_Sc;
|
||||
*vy = y + (n * 2 + 1) * m_Sc;
|
||||
@ -2704,7 +2704,7 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
int m, n;
|
||||
intmax_t m, n;
|
||||
T alpha, beta, offsetAl, offsetBe, offsetGa, x, y;
|
||||
|
||||
//Transfer to trilinear coordinates, normalized to real distances from triangle sides.
|
||||
|
@ -878,7 +878,7 @@ public:
|
||||
<< "\t\t inside = 1;\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (" << zeroEdges << " && !inside)\n"
|
||||
<< "\t\tif (" << zeroEdges << " != 0.0 && !inside)\n"
|
||||
<< "\t\t{\n"
|
||||
<< "\t\t u = v = 0;\n"
|
||||
<< "\t\t}\n"
|
||||
|
@ -315,7 +315,7 @@ public:
|
||||
//An adjustment of +/- 360 degrees is made until this is true.
|
||||
if (emberSize > 1)
|
||||
{
|
||||
for (uint i = 1; i < emberSize; i++)
|
||||
for (size_t i = 1; i < emberSize; i++)
|
||||
{
|
||||
//Only do this adjustment if not in compat mode..
|
||||
if (embers[i - 1].m_AffineInterp != INTERP_COMPAT && embers[i - 1].m_AffineInterp != INTERP_OLDER)
|
||||
@ -362,79 +362,22 @@ public:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the string to a floating point value and return a bool indicating success.
|
||||
/// Thin wrapper around converting the string to a numeric value and return a bool indicating success.
|
||||
/// See error report for errors.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to convert</param>
|
||||
/// <param name="val">The converted value</param>
|
||||
/// <returns>True if success, else false.</returns>
|
||||
bool Atof(const char* str, T& val)
|
||||
template <typename valT>
|
||||
bool Aton(const char* str, valT& val)
|
||||
{
|
||||
bool b = true;
|
||||
char* endp;
|
||||
const char* loc = __FUNCTION__;
|
||||
std::istringstream istr(str);
|
||||
|
||||
//Reset errno.
|
||||
errno = 0;//Note that this is not thread-safe.
|
||||
istr >> val;
|
||||
|
||||
//Convert the string using strtod().
|
||||
val = T(strtod(str, &endp));
|
||||
|
||||
//Check errno & return string.
|
||||
if (endp != str + strlen(str))
|
||||
{
|
||||
m_ErrorReport.push_back(string(loc) + " : Error converting " + string(str) + ", extra chars");
|
||||
b = false;
|
||||
}
|
||||
|
||||
if (errno)
|
||||
{
|
||||
m_ErrorReport.push_back(string(loc) + " : Error converting " + string(str));
|
||||
b = false;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thin wrapper around Atoi().
|
||||
/// See error report for errors.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to convert</param>
|
||||
/// <param name="val">The converted uinteger value</param>
|
||||
/// <returns>True if success, else false.</returns>
|
||||
bool Atoi(const char* str, uint& val)
|
||||
{
|
||||
return Atoi(str, reinterpret_cast<int&>(val));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the string to an uinteger value and return a bool indicating success.
|
||||
/// See error report for errors.
|
||||
/// </summary>
|
||||
/// <param name="str">The string to convert</param>
|
||||
/// <param name="val">The converted uinteger value</param>
|
||||
/// <returns>True if success, else false.</returns>
|
||||
bool Atoi(const char* str, int& val)
|
||||
{
|
||||
bool b = true;
|
||||
char* endp;
|
||||
const char* loc = __FUNCTION__;
|
||||
|
||||
//Reset errno.
|
||||
errno = 0;//Note that this is not thread-safe.
|
||||
|
||||
//Convert the string using strtod().
|
||||
val = strtol(str, &endp, 10);
|
||||
|
||||
//Check errno & return string.
|
||||
if (endp != str + strlen(str))
|
||||
{
|
||||
m_ErrorReport.push_back(string(loc) + " : Error converting " + string(str) + ", extra chars");
|
||||
b = false;
|
||||
}
|
||||
|
||||
if (errno)
|
||||
if (istr.bad() || istr.fail())
|
||||
{
|
||||
m_ErrorReport.push_back(string(loc) + " : Error converting " + string(str));
|
||||
b = false;
|
||||
@ -443,6 +386,7 @@ public:
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Convert an integer to a string.
|
||||
/// Just a wrapper around _itoa_s() which wraps the result in a std::string.
|
||||
@ -554,11 +498,11 @@ private:
|
||||
{
|
||||
bool ret = true;
|
||||
bool fromEmber = false;
|
||||
uint newLinear = 0;
|
||||
size_t newLinear = 0;
|
||||
char* attStr;
|
||||
const char* loc = __FUNCTION__;
|
||||
int soloXform = -1;
|
||||
uint i, j, count, index = 0;
|
||||
size_t i, count, index = 0;
|
||||
double vals[16];
|
||||
xmlAttrPtr att, curAtt;
|
||||
xmlNodePtr editNode, childNode, motionNode;
|
||||
@ -577,38 +521,38 @@ private:
|
||||
attStr = reinterpret_cast<char*>(xmlGetProp(emberNode, curAtt->name));
|
||||
|
||||
//First parse out simple float reads.
|
||||
if (ParseAndAssignFloat(curAtt->name, attStr, "time", currentEmber.m_Time, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "scale", currentEmber.m_PixelsPerUnit, ret)) { currentEmber.m_OrigPixPerUnit = currentEmber.m_PixelsPerUnit; }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "rotate", currentEmber.m_Rotate, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "zoom", currentEmber.m_Zoom, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "filter", currentEmber.m_SpatialFilterRadius, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_width", currentEmber.m_TemporalFilterWidth, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "temporal_filter_exp", currentEmber.m_TemporalFilterExp, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "quality", currentEmber.m_Quality, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "brightness", currentEmber.m_Brightness, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma", currentEmber.m_Gamma, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "highlight_power", currentEmber.m_HighlightPower, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "vibrancy", currentEmber.m_Vibrancy, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_radius", currentEmber.m_MaxRadDE, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_minimum", currentEmber.m_MinRadDE, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "estimator_curve", currentEmber.m_CurveDE, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "gamma_threshold", currentEmber.m_GammaThresh, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_zpos", currentEmber.m_CamZPos, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_persp", currentEmber.m_CamPerspective, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_perspective", currentEmber.m_CamPerspective, ret)) { }//Apo bug.
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_yaw", currentEmber.m_CamYaw, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_pitch", currentEmber.m_CamPitch, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "cam_dof", currentEmber.m_CamDepthBlur, ret)) { }
|
||||
if (ParseAndAssign(curAtt->name, attStr, "time", currentEmber.m_Time, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "scale", currentEmber.m_PixelsPerUnit, ret)) { currentEmber.m_OrigPixPerUnit = currentEmber.m_PixelsPerUnit; }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "rotate", currentEmber.m_Rotate, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "zoom", currentEmber.m_Zoom, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "filter", currentEmber.m_SpatialFilterRadius, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "temporal_filter_width", currentEmber.m_TemporalFilterWidth, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "temporal_filter_exp", currentEmber.m_TemporalFilterExp, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "quality", currentEmber.m_Quality, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "brightness", currentEmber.m_Brightness, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "gamma", currentEmber.m_Gamma, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "highlight_power", currentEmber.m_HighlightPower, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "vibrancy", currentEmber.m_Vibrancy, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "estimator_radius", currentEmber.m_MaxRadDE, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "estimator_minimum", currentEmber.m_MinRadDE, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "estimator_curve", currentEmber.m_CurveDE, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "gamma_threshold", currentEmber.m_GammaThresh, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "cam_zpos", currentEmber.m_CamZPos, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "cam_persp", currentEmber.m_CamPerspective, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "cam_perspective", currentEmber.m_CamPerspective, ret)) { }//Apo bug.
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "cam_yaw", currentEmber.m_CamYaw, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "cam_pitch", currentEmber.m_CamPitch, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "cam_dof", currentEmber.m_CamDepthBlur, ret)) { }
|
||||
|
||||
//Parse simple int reads.
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "palette", currentEmber.m_Palette.m_Index, ret)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "oversample", currentEmber.m_Supersample , ret)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "supersample", currentEmber.m_Supersample , ret)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "temporal_samples", currentEmber.m_TemporalSamples, ret)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "sub_batch_size", currentEmber.m_SubBatchSize , ret)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "fuse", currentEmber.m_FuseCount , ret)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "soloxform", soloXform , ret)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "new_linear", newLinear , ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "palette", currentEmber.m_Palette.m_Index, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "oversample", currentEmber.m_Supersample , ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "supersample", currentEmber.m_Supersample , ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "temporal_samples", currentEmber.m_TemporalSamples, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "sub_batch_size", currentEmber.m_SubBatchSize , ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "fuse", currentEmber.m_FuseCount , ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "soloxform", soloXform , ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "new_linear", newLinear , ret)) { }
|
||||
|
||||
//Parse more complicated reads that have multiple possible values.
|
||||
else if (!Compare(curAtt->name, "interpolation"))
|
||||
@ -718,7 +662,7 @@ private:
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
for (j = 0; j < 4; j++)
|
||||
for (glm::length_t j = 0; j < 4; j++)
|
||||
{
|
||||
ss >> currentEmber.m_Curves.m_Points[i][j].x;
|
||||
ss >> currentEmber.m_Curves.m_Points[i][j].y;
|
||||
@ -759,7 +703,7 @@ private:
|
||||
|
||||
if (!Compare(curAtt->name, "index"))
|
||||
{
|
||||
Atoi(attStr, index);
|
||||
Aton(attStr, index);
|
||||
}
|
||||
else if(!Compare(curAtt->name, "rgb"))
|
||||
{
|
||||
@ -819,7 +763,7 @@ private:
|
||||
|
||||
if (!Compare(curAtt->name, "count"))
|
||||
{
|
||||
Atoi(attStr, count);
|
||||
Aton(attStr, count);
|
||||
}
|
||||
else if (!Compare(curAtt->name, "data"))
|
||||
{
|
||||
@ -842,11 +786,6 @@ private:
|
||||
//Make sure BOTH are not specified, otherwise either are ok.
|
||||
int numColors = 0;
|
||||
int numBytes = 0;
|
||||
int index0, index1;
|
||||
T hue0, hue1;
|
||||
T blend = 0.5;
|
||||
index0 = index1 = -1;
|
||||
hue0 = hue1 = 0.0;
|
||||
|
||||
//Loop through the attributes of the palette element.
|
||||
att = childNode->properties;
|
||||
@ -863,7 +802,7 @@ private:
|
||||
|
||||
if (!Compare(curAtt->name, "count"))
|
||||
{
|
||||
Atoi(attStr, numColors);
|
||||
Aton(attStr, numColors);
|
||||
}
|
||||
else if (!Compare(curAtt->name, "format"))
|
||||
{
|
||||
@ -915,7 +854,7 @@ private:
|
||||
|
||||
if (!Compare(curAtt->name, "kind"))
|
||||
{
|
||||
Atoi(attStr, symKind);
|
||||
Aton(attStr, symKind);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1016,8 +955,8 @@ private:
|
||||
{
|
||||
attStr = reinterpret_cast<char*>(xmlGetProp(childNode, curAtt->name));
|
||||
|
||||
if (ParseAndAssignFloat(curAtt->name, attStr, "motion_frequency", motion.m_MotionFreq, ret)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "motion_offset", motion.m_MotionOffset, ret)) { }
|
||||
if (ParseAndAssign(curAtt->name, attStr, "motion_frequency", motion.m_MotionFreq, ret)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "motion_offset", motion.m_MotionOffset, ret)) { }
|
||||
else if (!Compare(curAtt->name, "motion_function"))
|
||||
{
|
||||
string func(attStr);
|
||||
@ -1135,7 +1074,7 @@ private:
|
||||
bool r = false;
|
||||
T val = 0.0;
|
||||
|
||||
if (Atof(attStr, val))
|
||||
if (Aton(attStr, val))
|
||||
{
|
||||
motion.m_MotionParams.push_back(MotionParam<T>(param, val));
|
||||
r = true;
|
||||
@ -1160,7 +1099,7 @@ private:
|
||||
bool success = true;
|
||||
char* attStr;
|
||||
const char* loc = __FUNCTION__;
|
||||
uint j;
|
||||
size_t j;
|
||||
T temp;
|
||||
double a, b, c, d, e, f;
|
||||
double vals[10];
|
||||
@ -1180,13 +1119,13 @@ private:
|
||||
attStr = reinterpret_cast<char*>(xmlGetProp(childNode, curAtt->name));
|
||||
|
||||
//First parse out simple float reads.
|
||||
if (ParseAndAssignFloat(curAtt->name, attStr, "weight", xform.m_Weight, success)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "color_speed", xform.m_ColorSpeed, success)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "animate", xform.m_Animate, success)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "opacity", xform.m_Opacity, success)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "var_color", xform.m_DirectColor, success)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "motion_frequency", xform.m_MotionFreq, success)) { }
|
||||
else if (ParseAndAssignFloat(curAtt->name, attStr, "motion_offset", xform.m_MotionOffset, success)) { }
|
||||
if (ParseAndAssign(curAtt->name, attStr, "weight", xform.m_Weight, success)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "color_speed", xform.m_ColorSpeed, success)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "animate", xform.m_Animate, success)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "opacity", xform.m_Opacity, success)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "var_color", xform.m_DirectColor, success)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "motion_frequency", xform.m_MotionFreq, success)) { }
|
||||
else if (ParseAndAssign(curAtt->name, attStr, "motion_offset", xform.m_MotionOffset, success)) { }
|
||||
|
||||
//Parse more complicated reads that have multiple possible values.
|
||||
else if (!Compare(curAtt->name, "name"))
|
||||
@ -1198,7 +1137,7 @@ private:
|
||||
{
|
||||
//Deprecated, set both color_speed and animate to this value.
|
||||
//Huh? Either set it or not?
|
||||
Atof(attStr, temp);
|
||||
Aton(attStr, temp);
|
||||
xform.m_ColorSpeed = (1 - temp) / 2;
|
||||
xform.m_Animate = T(temp > 0 ? 0 : 1);
|
||||
}
|
||||
@ -1297,7 +1236,7 @@ private:
|
||||
{
|
||||
auto varCopy = var->Copy();
|
||||
|
||||
Atof(attStr, varCopy->m_Weight);
|
||||
Aton(attStr, varCopy->m_Weight);
|
||||
xform.AddVariation(varCopy);
|
||||
}
|
||||
//else
|
||||
@ -1321,7 +1260,7 @@ private:
|
||||
for (j = 0; j < xform.TotalVariationCount(); j++)
|
||||
xform.GetVariation(j)->m_Weight = 0;
|
||||
|
||||
if (Atof(attStr, temp))
|
||||
if (Aton(attStr, temp))
|
||||
{
|
||||
uint iTemp = static_cast<uint>(temp);
|
||||
|
||||
@ -1349,7 +1288,7 @@ private:
|
||||
{
|
||||
attStr = reinterpret_cast<char*>(xmlGetProp(childNode, curAtt->name));
|
||||
|
||||
if (Atof(attStr, temp))
|
||||
if (Aton(attStr, temp))
|
||||
{
|
||||
for (j = 0; j < xform.TotalVariationCount(); j++)
|
||||
xform.GetVariation(j)->m_Weight = temp;
|
||||
@ -1366,7 +1305,7 @@ private:
|
||||
}
|
||||
|
||||
//Now that all xforms have been parsed, go through and try to find params for the parametric variations.
|
||||
for (uint i = 0; i < xform.TotalVariationCount(); i++)
|
||||
for (size_t i = 0; i < xform.TotalVariationCount(); i++)
|
||||
{
|
||||
if (ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(xform.GetVariation(i)))
|
||||
{
|
||||
@ -1381,7 +1320,7 @@ private:
|
||||
T val = 0;
|
||||
attStr = CX(xmlGetProp(childNode, curAtt->name));
|
||||
|
||||
if (Atof(attStr, val))
|
||||
if (Aton(attStr, val))
|
||||
{
|
||||
parVar->SetParamVal(name, val);
|
||||
}
|
||||
@ -1476,14 +1415,14 @@ private:
|
||||
/// <param name="numColors">The number of colors present</param>
|
||||
/// <param name="chan">The number of channels in each color</param>
|
||||
/// <returns>True if there were no errors, else false.</returns>
|
||||
bool ParseHexColors(char* colstr, Ember<T>& ember, int numColors, int chan)
|
||||
bool ParseHexColors(char* colstr, Ember<T>& ember, size_t numColors, intmax_t chan)
|
||||
{
|
||||
int colorIndex = 0;
|
||||
int colorCount = 0;
|
||||
size_t colorIndex = 0;
|
||||
size_t colorCount = 0;
|
||||
uint r, g, b, a;
|
||||
int ret;
|
||||
char tmps[2];
|
||||
int skip = static_cast<int>(abs(chan));
|
||||
size_t skip = std::abs(chan);
|
||||
bool ok = true;
|
||||
const char* loc = __FUNCTION__;
|
||||
|
||||
@ -1539,47 +1478,25 @@ private:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to parse a floating point Xml value and convert it to float.
|
||||
/// Wrapper to parse a numeric Xml string value and convert it.
|
||||
/// </summary>
|
||||
/// <param name="name">The xml tag to parse</param>
|
||||
/// <param name="attStr">The name of the Xml attribute</param>
|
||||
/// <param name="str">The name of the Xml tag</param>
|
||||
/// <param name="val">The parsed value</param>
|
||||
/// <param name="b">Bitwise ANDed with true if name matched str and the call to Atof() succeeded, else false. Used for keeping a running value between successive calls.</param>
|
||||
/// <returns>True if the tag was matched, else false</returns>
|
||||
bool ParseAndAssignFloat(const xmlChar* name, const char* attStr, const char* str, T& val, bool& b)
|
||||
/// <param name="b">Bitwise ANDed with true if name matched str and the conversion succeeded, else false. Used for keeping a running value between successive calls.</param>
|
||||
/// <returns>True if the tag was matched and the conversion succeeded, else false</returns>
|
||||
template <typename valT>
|
||||
bool ParseAndAssign(const xmlChar* name, const char* attStr, const char* str, valT& val, bool& b)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (!Compare(name, str))
|
||||
{
|
||||
b &= Atof(attStr, val);
|
||||
ret = true;//Means the strcmp() was right, but doesn't necessarily mean the conversion went ok.
|
||||
}
|
||||
istringstream istr(attStr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper to parse an int Xml string value and convert it to an int.
|
||||
/// </summary>
|
||||
/// <param name="name">The xml tag to parse</param>
|
||||
/// <param name="attStr">The name of the Xml attribute</param>
|
||||
/// <param name="str">The name of the Xml tag</param>
|
||||
/// <param name="val">The parsed value</param>
|
||||
/// <param name="b">Bitwise ANDed with true if name matched str and the call to Atoi() succeeded, else false. Used for keeping a running value between successive calls.</param>
|
||||
/// <returns>True if the tag was matched, else false</returns>
|
||||
template <typename intT>
|
||||
bool ParseAndAssignInt(const xmlChar* name, const char* attStr, const char* str, intT& val, bool& b)
|
||||
{
|
||||
bool ret = false;
|
||||
T fval = 0;
|
||||
|
||||
if (!Compare(name, str))
|
||||
{
|
||||
b &= Atof(attStr, fval);
|
||||
val = static_cast<intT>(fval);
|
||||
ret = true;//Means the strcmp() was right, but doesn't necessarily mean the conversion went ok.
|
||||
istr >> val;
|
||||
ret = !istr.bad() && !istr.fail();//Means the Compare() was right, and the conversion succeeded.
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user