--User changes

-Add variations changes to the list of functionality that can be applied to all xforms using the Select tab.
 -Allow for graphical affine adjustments to apply to multiple selected xforms.
 -Slight optimization of the pie variation.
 -Undo state is only saved when the render completes and the mouse buttons are released. This helps avoid intermediate steps for quickly completing renders while dragging.
 -Add some keyboard shortcuts for toolbar and menu items.
 -Make info tab tree always expanded.

--Bug fixes
 -Make precalcs for all hypertile variations safer by using Zeps() for denominators.
 -Changing the current xform with more than one selected would set all xform's color index value that of the current one.
 -Use hard found palette path information for randoms as well.
 -OpenCL build and assignment errors for Z value in epispiral variation.
 -Unitialized local variables in hexaplay3D, crob, pRose3D.

--Code changes
 -Change static member variables from m_ to s_.
 -Get rid of excessive endl and replace with "\n".
 -Remove old IMAGEGL2D define from before Nvidia supported OpenCL 1.2.
 -Remove old CriticalSection code and use std::recursive_mutex.
 -Make Affine2D Rotate() and RotateTrans() take radians instead of angles.
 -More C++11 work.
 -General cleanup.
This commit is contained in:
mfeemster
2016-02-11 21:38:21 -08:00
parent a345e2d5e1
commit a800b08b67
69 changed files with 981 additions and 1094 deletions

View File

@ -3,39 +3,39 @@
namespace EmberCLns
{
std::unordered_map<string, string> FunctionMapper::m_GlobalMap;
std::unordered_map<string, string> FunctionMapper::s_GlobalMap;
FunctionMapper::FunctionMapper()
{
if (m_GlobalMap.empty())
if (s_GlobalMap.empty())
{
m_GlobalMap["LRint"] =
s_GlobalMap["LRint"] =
"inline real_t LRint(real_t x)\n"
"{\n"
" intPrec temp = (x >= 0.0 ? (intPrec)(x + 0.5) : (intPrec)(x - 0.5));\n"
" return (real_t)temp;\n"
"}\n";
m_GlobalMap["Round"] =
s_GlobalMap["Round"] =
"inline real_t Round(real_t r)\n"
"{\n"
" return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);\n"
"}\n";
m_GlobalMap["Sign"] =
s_GlobalMap["Sign"] =
"inline real_t Sign(real_t v)\n"
"{\n"
" return (v < 0.0) ? -1 : (v > 0.0) ? 1 : 0.0;\n"
"}\n";
m_GlobalMap["SignNz"] =
s_GlobalMap["SignNz"] =
"inline real_t SignNz(real_t v)\n"
"{\n"
" return (v < 0.0) ? -1.0 : 1.0;\n"
"}\n";
m_GlobalMap["Sqr"] =
s_GlobalMap["Sqr"] =
"inline real_t Sqr(real_t v)\n"
"{\n"
" return v * v;\n"
"}\n";
m_GlobalMap["SafeSqrt"] =
s_GlobalMap["SafeSqrt"] =
"inline real_t SafeSqrt(real_t x)\n"
"{\n"
" if (x <= 0.0)\n"
@ -43,7 +43,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return sqrt(x);\n"
"}\n";
m_GlobalMap["SafeDivInv"] =
s_GlobalMap["SafeDivInv"] =
"inline real_t SafeDivInv(real_t q, real_t r)\n"
"{\n"
" if (r < EPS)\n"
@ -51,81 +51,81 @@ FunctionMapper::FunctionMapper()
"\n"
" return q / r;\n"
"}\n";
m_GlobalMap["Cube"] =
s_GlobalMap["Cube"] =
"inline real_t Cube(real_t v)\n"
"{\n"
" return v * v * v;\n"
"}\n";
m_GlobalMap["Hypot"] =
s_GlobalMap["Hypot"] =
"inline real_t Hypot(real_t x, real_t y)\n"
"{\n"
" return sqrt(SQR(x) + SQR(y));\n"
"}\n";
m_GlobalMap["Spread"] =
s_GlobalMap["Spread"] =
"inline real_t Spread(real_t x, real_t y)\n"
"{\n"
" return Hypot(x, y) * ((x) > 0.0 ? 1.0 : -1.0);\n"
"}\n";
m_GlobalMap["Powq4"] =
s_GlobalMap["Powq4"] =
"inline real_t Powq4(real_t x, real_t y)\n"
"{\n"
" return pow(fabs(x), y) * SignNz(x);\n"
"}\n";
m_GlobalMap["Powq4c"] =
s_GlobalMap["Powq4c"] =
"inline real_t Powq4c(real_t x, real_t y)\n"
"{\n"
" return y == 1.0 ? x : Powq4(x, y);\n"
"}\n";
m_GlobalMap["Zeps"] =
s_GlobalMap["Zeps"] =
"inline real_t Zeps(real_t x)\n"
"{\n"
" return x == 0.0 ? EPS : x;\n"
"}\n";
m_GlobalMap["Lerp"] =
s_GlobalMap["Lerp"] =
"inline real_t Lerp(real_t a, real_t b, real_t p)\n"
"{\n"
" return a + (b - a) * p;\n"
"}\n";
m_GlobalMap["Fabsmod"] =
s_GlobalMap["Fabsmod"] =
"inline real_t Fabsmod(real_t v)\n"
"{\n"
" real_t dummy;\n"
"\n"
" return modf(v, &dummy);\n"
"}\n";
m_GlobalMap["Fosc"] =
s_GlobalMap["Fosc"] =
"inline real_t Fosc(real_t p, real_t amp, real_t ph)\n"
"{\n"
" return 0.5 - cos(p * amp + ph) * 0.5;\n"
"}\n";
m_GlobalMap["Foscn"] =
s_GlobalMap["Foscn"] =
"inline real_t Foscn(real_t p, real_t ph)\n"
"{\n"
" return 0.5 - cos(p + ph) * 0.5;\n"
"}\n";
m_GlobalMap["LogScale"] =
s_GlobalMap["LogScale"] =
"inline real_t LogScale(real_t x)\n"
"{\n"
" return x == 0.0 ? 0.0 : log((fabs(x) + 1) * M_E) * SignNz(x) / M_E;\n"
"}\n";
m_GlobalMap["LogMap"] =
s_GlobalMap["LogMap"] =
"inline real_t LogMap(real_t x)\n"
"{\n"
" return x == 0.0 ? 0.0 : (M_E + log(x * M_E)) * 0.25 * SignNz(x);\n"
"}\n";
m_GlobalMap["ClampGte"] =
s_GlobalMap["ClampGte"] =
"inline real_t ClampGte(real_t val, real_t gte)\n"
"{\n"
" return (val < gte) ? gte : val;\n"
"}\n";
m_GlobalMap["Swap"] =
s_GlobalMap["Swap"] =
"inline void Swap(real_t* val1, real_t* val2)\n"
"{\n"
" real_t tmp = *val1;\n"
" *val1 = *val2;\n"
" *val2 = tmp;\n"
"}\n";
m_GlobalMap["Vratio"] =
s_GlobalMap["Vratio"] =
"inline real_t Vratio(real2* p, real2* q, real2* u)\n"
"{\n"
" real2 pmq = *p - *q;\n"
@ -135,7 +135,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return 2 * (((*u).x - (*q).x) * pmq.x + ((*u).y - (*q).y) * pmq.y) / Zeps(SQR(pmq.x) + SQR(pmq.y));\n"
"}\n";
m_GlobalMap["Closest"] =
s_GlobalMap["Closest"] =
"inline int Closest(real2* p, int n, real2* u)\n"
"{\n"
" real_t d2;\n"
@ -155,7 +155,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return j;\n"
"}\n";
m_GlobalMap["Voronoi"] =
s_GlobalMap["Voronoi"] =
"inline real_t Voronoi(real2* p, int n, int q, real2* u)\n"
"{\n"
" real_t ratio;\n"
@ -175,7 +175,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return ratiomax;\n"
"}\n";
m_GlobalMap["SimplexNoise3D"] =
s_GlobalMap["SimplexNoise3D"] =
"inline real_t SimplexNoise3D(real3* v, __global real_t* p, __global real3* grad)\n"
"{\n"
" real3 c[4];\n"
@ -263,7 +263,7 @@ FunctionMapper::FunctionMapper()
"\n"
" return 32 * n;\n"
"}\n";
m_GlobalMap["PerlinNoise3D"] =
s_GlobalMap["PerlinNoise3D"] =
"inline real_t PerlinNoise3D(real3* v, __global real_t* p, __global real3* grad, real_t aScale, real_t fScale, int octaves)\n"
"{\n"
" int i;\n"
@ -281,11 +281,11 @@ FunctionMapper::FunctionMapper()
"\n"
" return n;\n"
"}\n";
m_GlobalMap["JacobiElliptic"] =
s_GlobalMap["JacobiElliptic"] =
"inline void JacobiElliptic(real_t uu, real_t emmc, real_t* sn, real_t* cn, real_t* dn)\n"
"{\n"
" real_t CA = 0.0003;\n"
" real_t a, b, c, d, em[13], en[13];\n"
" real_t a, b, c, d = 1, em[13], en[13];\n"
" int bo;\n"
" int l;\n"
" int ii;\n"
@ -371,11 +371,16 @@ FunctionMapper::FunctionMapper()
}
}
/// <summary>
/// Get a pointer to the text of the global function whose name is the passed in string.
/// </summary>
/// <param name="func">The function name to retrieve</param>
/// <returns>A pointer to the function body string if found, else nullptr.</returns>
const string* FunctionMapper::GetGlobalFunc(const string& func)
{
const auto& text = m_GlobalMap.find(func);
const auto& text = s_GlobalMap.find(func);
if (text != m_GlobalMap.end())
if (text != s_GlobalMap.end())
return &text->second;
else
return nullptr;