From 5aec58b4a2b2afee1db3a6aa200d008fbf09b071 Mon Sep 17 00:00:00 2001 From: mfeemster Date: Sat, 14 May 2016 23:33:08 -0700 Subject: [PATCH] --User changes -Add new options to EmberGenome to better help assess which variations have certain characteristics. The options are: --sumvars: Display the names of all regular variations which have the default behavior of summing their outputs and exit. --assignvars: Display the names of all regular variations which have the non-standard behavior of assigning their outputs and exit. --ppsumvars: Display the names of all pre/post variations which have the non-standard behavior of summing their outputs and exit. --ppassignvars: Display the names of all pre/post variations which have the default behavior of assigning their outputs and exit. --dcvars: Display the names of all variations which use direct coloring and exit. --parvars: Display the names of all variations which have parameters and exit. --nonparvars: Display the names of all variations which do not have parameters (weight only) and exit. --Code changes -Make VariationList vectors have const elements since no callers should ever change them. -Add new function to VariationList to retrieve a const ref to the parametric variations. -Move some search functions out of EmberTester and into EmberCommon.h. -General code cleanup. --- Source/Ember/Renderer.cpp | 1 - Source/Ember/VariationList.cpp | 18 +++-- Source/Ember/VariationList.h | 22 +++--- Source/Ember/Variations02.h | 74 ++++++++++---------- Source/Ember/Variations04.h | 24 +++---- Source/Ember/XmlToEmber.h | 4 +- Source/EmberCommon/EmberCommon.h | 97 ++++++++++++++++++++++++++ Source/EmberCommon/EmberOptions.h | 30 +++++++- Source/EmberGenome/EmberGenome.cpp | 73 ++++++++++++++++++- Source/EmberTester/EmberTester.cpp | 72 ++----------------- Source/Fractorium/FractoriumRender.cpp | 3 + 11 files changed, 283 insertions(+), 135 deletions(-) diff --git a/Source/Ember/Renderer.cpp b/Source/Ember/Renderer.cpp index c83f3cb..d1ee3db 100644 --- a/Source/Ember/Renderer.cpp +++ b/Source/Ember/Renderer.cpp @@ -83,7 +83,6 @@ void Renderer::ComputeBounds() //It also prevents the renderer from only performing filtering or final accum based on a filter parameter change, since that //change may have changed the gutter. //By using a fixed gutter, a filter change can be applied without fully restarting iteration. - //m_GutterWidth = 10; m_GutterWidth = 10 * Supersample();//Should be enough to fully accommodate most spatial and density filter widths. m_SuperRasW = (Supersample() * FinalRasW()) + (2 * m_GutterWidth); m_SuperRasH = (Supersample() * FinalRasH()) + (2 * m_GutterWidth); diff --git a/Source/Ember/VariationList.cpp b/Source/Ember/VariationList.cpp index b20003f..7068cc4 100644 --- a/Source/Ember/VariationList.cpp +++ b/Source/Ember/VariationList.cpp @@ -357,13 +357,14 @@ VariationList::VariationList() ADDPREPOSTREGVAR(DCTriangle) ADDPREPOSTREGVAR(DCZTransl) - for (auto var : m_Variations) var->Precalc(); + for (auto var : m_Variations) const_cast*>(var)->Precalc();//Modify once here, then const after this. std::sort(m_Variations.begin(), m_Variations.end(), [&](const Variation* var1, const Variation* var2) { return var1->VariationId() < var2->VariationId(); }); m_RegVariations.reserve(m_Variations.size() / 3); m_PreVariations.reserve(m_Variations.size() / 3); m_PostVariations.reserve(m_Variations.size() / 3); m_ParametricVariations.reserve(size_t(m_Variations.size() * .90));//This is a rough guess at how many are parametric. + m_NonParametricVariations.reserve(size_t(m_Variations.size() * 0.20));//This is a rough guess at how many are not parametric. These don't add to 1 just to allow extra padding. //Place pointers to variations in vectors specific to their type. //Many of the elements in m_ParametricVariations will be present in the reg, pre and post vectors. @@ -377,8 +378,10 @@ VariationList::VariationList() else if (var->VarType() == eVariationType::VARTYPE_POST) m_PostVariations.push_back(var); - if (auto parVar = dynamic_cast*>(var)) + if (auto parVar = dynamic_cast*>(var)) m_ParametricVariations.push_back(parVar); + else + m_NonParametricVariations.push_back(var); } } @@ -543,10 +546,13 @@ template size_t VariationList::RegSize() const { return m_RegVar template size_t VariationList::PreSize() const { return m_PreVariations.size(); } template size_t VariationList::PostSize() const { return m_PostVariations.size(); } template size_t VariationList::ParametricSize() const { return m_ParametricVariations.size(); } -template const vector*>& VariationList::AllVars() const { return m_Variations; } -template const vector*>& VariationList::RegVars() const { return m_RegVariations; } -template const vector*>& VariationList::PreVars() const { return m_PreVariations; } -template const vector*>& VariationList::PostVars() const { return m_PostVariations; } +template size_t VariationList::NonParametricSize() const { return m_NonParametricVariations.size(); } +template const vector*>& VariationList::AllVars() const { return m_Variations; } +template const vector*>& VariationList::RegVars() const { return m_RegVariations; } +template const vector*>& VariationList::PreVars() const { return m_PreVariations; } +template const vector*>& VariationList::PostVars() const { return m_PostVariations; } +template const vector*>& VariationList::NonParametricVariations() const { return m_NonParametricVariations; } +template const vector*>& VariationList::ParametricVariations() const { return m_ParametricVariations; } /// /// Make a dyncamically allocated copy of a variation and assign it a specified weight. diff --git a/Source/Ember/VariationList.h b/Source/Ember/VariationList.h index 168ac98..c81cf68 100644 --- a/Source/Ember/VariationList.h +++ b/Source/Ember/VariationList.h @@ -38,11 +38,14 @@ public: size_t PreSize() const; size_t PostSize() const; size_t ParametricSize() const; + size_t NonParametricSize() const; - const vector*>& AllVars() const; - const vector*>& RegVars() const; - const vector*>& PreVars() const; - const vector*>& PostVars() const; + const vector*>& AllVars() const; + const vector*>& RegVars() const; + const vector*>& PreVars() const; + const vector*>& PostVars() const; + const vector*>& NonParametricVariations() const; + const vector*>& ParametricVariations() const; SINGLETON_DERIVED_DECL(VariationList); @@ -50,10 +53,11 @@ private: VariationList(); Variation* MakeCopyWithWeight(const Variation* var, T weight) const; - vector*> m_Variations;//A list of pointers to dynamically allocated variation objects. - vector*> m_RegVariations; - vector*> m_PreVariations; - vector*> m_PostVariations; - vector*> m_ParametricVariations;//A list of pointers to elements in m_Variations which are derived from ParametricVariation. + vector*> m_Variations;//A list of pointers to dynamically allocated variation objects. + vector*> m_RegVariations; + vector*> m_PreVariations; + vector*> m_PostVariations; + vector*> m_NonParametricVariations; + vector*> m_ParametricVariations;//A list of pointers to elements in m_Variations which are derived from ParametricVariation. }; } diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index e384116..c5eb9d5 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -4109,16 +4109,16 @@ public: intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string c2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cz = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2x = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2y = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s2z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; @@ -4298,8 +4298,8 @@ public: int i = 0; ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string zscale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string vpi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string zscale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string vpi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t c0 = vIn.x * " << vpi << ";\n" << "\t\treal_t c1 = vIn.y * " << vpi << ";\n" @@ -4371,14 +4371,14 @@ public: intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string t3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string t2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string t1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string tc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string bc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string t3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string t2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string t1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string tc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string bc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t xsqr = vIn.x * vIn.x;\n" << "\t\treal_t ysqr = vIn.y * vIn.y;\n" @@ -4474,16 +4474,16 @@ public: intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string frequency = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string velocity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string amplitude = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centery = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string phase = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string frequency = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string velocity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string amplitude = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centery = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string phase = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string p = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string is = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vxp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; @@ -4604,13 +4604,13 @@ public: intmax_t i = 0; ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string shiftX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string shiftY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string ay = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string shiftX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string shiftY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ax = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ay = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string vv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t c0 = " << ax << " / (1 + exp(" << sx << " * vIn.x));\n" << "\t\treal_t c1 = " << ay << " / (1 + exp(" << sy << " * vIn.y));\n" diff --git a/Source/Ember/Variations04.h b/Source/Ember/Variations04.h index 108c423..7a9d468 100644 --- a/Source/Ember/Variations04.h +++ b/Source/Ember/Variations04.h @@ -1143,11 +1143,11 @@ public: intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string strength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string s2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string strength = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string centerY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string s2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t sx = vIn.x - " << centerX << ";\n" << "\t\treal_t sy = vIn.y - " << centerY << ";\n" @@ -1221,12 +1221,12 @@ public: intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string sep = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string absN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string a = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string sep = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t jun = Zeps(fabs(" << n << "));\n" << "\n" @@ -2033,7 +2033,7 @@ public: << "\t\tconst int esc = rad > " << radius << ";\n" << "\t\tconst int cr0 = (int)" << zero << ";\n" << "\n" - << "\t\tif (cr0 && esc)\n" + << "\t\tif (cr0 && esc)\n" << "\t\t{\n" << "\t\t vOut.x = vOut.y = 0;\n"; diff --git a/Source/Ember/XmlToEmber.h b/Source/Ember/XmlToEmber.h index 877c044..214bfb2 100644 --- a/Source/Ember/XmlToEmber.h +++ b/Source/Ember/XmlToEmber.h @@ -80,6 +80,8 @@ public: if (!m_Init) { + //This list is for variation params which are incorrect, but their parent variation name may or may not be correct. + //This has some overlap with the list below since some of these have parent variation names that are incorrect. m_BadParamNames = unordered_map { { "swtin_distort" , "stwin_distort" },//stwin. @@ -215,7 +217,7 @@ public: "post_rotate_y", "curl3D_cz", }; - //This is a vector of the param names as they are in the legacy, badly named flam3/Apophysis code. + //This is a vector of the incorrect variation names and their param names as they are in the legacy, badly named flam3/Apophysis code. vector badParams = { "bwraps7_cellsize", diff --git a/Source/EmberCommon/EmberCommon.h b/Source/EmberCommon/EmberCommon.h index ab4fc46..9974b15 100644 --- a/Source/EmberCommon/EmberCommon.h +++ b/Source/EmberCommon/EmberCommon.h @@ -532,6 +532,103 @@ static size_t VerifyStrips(size_t height, size_t strips, return strips; } +/// +/// Search the variation's OpenCL string to determine whether it contains any of the search strings in stringVec. +/// This is useful for finding variations with certain characteristics since it's not possible +/// to query the CPU C++ code at runtime. +/// +/// The variation whose OpenCL string will be searched +/// The vector of strings to search for +/// True to find all variations which match any strings, false to break after the first match is found. +/// True if there was at least one match, else false. +template +bool SearchVar(const Variation* var, const vector& stringVec, bool matchAll) +{ + bool ret = false; + size_t i; + auto cl = var->OpenCLFuncsString() + "\n" + var->OpenCLString(); + + if (matchAll) + { + for (i = 0; i < stringVec.size(); i++) + if (cl.find(stringVec[i]) == std::string::npos) + break; + + ret = (i == stringVec.size()); + } + else + { + for (i = 0; i < stringVec.size(); i++) + { + if (cl.find(stringVec[i]) != std::string::npos) + { + ret = true; + break; + } + } + } + + return ret; +} + +/// +/// Find all variations whose OpenCL string contains any of the search strings in stringVec. +/// This is useful for finding variations with certain characteristics since it's not possible +/// to query the CPU C++ code at runtime. +/// +/// The vector of variation pointers to search +/// The vector of strings to search for +/// True to find all variations which match any strings, false to break after the first match is found. +/// A vector of pointers to variations whose OpenCL string matched at least one string in stringVec +template +static vector*> FindVarsWith(const vector*>& vars, const vector& stringVec, bool findAll = true) +{ + vector*> vec; + auto vl = VariationList::Instance(); + + for (auto& v : vars) + { + if (SearchVar(v, stringVec, false)) + { + vec.push_back(v); + + if (!findAll) + break; + } + } + + return vec; +} + +/// +/// Find all variations whose OpenCL string does not contain any of the search strings in stringVec. +/// This is useful for finding variations without certain characteristics since it's not possible +/// to query the CPU C++ code at runtime. +/// +/// The vector of variation pointers to search +/// The vector of strings to search for +/// True to find all variations which don't match any strings, false to break after the first non-match is found. +/// A vector of pointers to variations whose OpenCL string did not match any string in stringVec +template +static vector*> FindVarsWithout(const vector*>& vars, const vector& stringVec, bool findAll = true) +{ + vector*> vec; + auto vl = VariationList::Instance(); + + for (auto& v : vars) + { + if (!SearchVar(v, stringVec, false)) + { + vec.push_back(v); + + if (!findAll) + break; + } + } + + return vec; +} + /// /// Simple macro to print a string if the --verbose options has been specified. /// diff --git a/Source/EmberCommon/EmberOptions.h b/Source/EmberCommon/EmberOptions.h index c31ef96..79c164c 100644 --- a/Source/EmberCommon/EmberOptions.h +++ b/Source/EmberCommon/EmberOptions.h @@ -39,6 +39,13 @@ enum class eOptionIDs : et OPT_REG_VARS, OPT_PRE_VARS, OPT_POST_VARS, + OPT_SUM_VARS, + OPT_ASSIGN_VARS, + OPT_PPSUM_VARS, + OPT_PPASSIGN_VARS, + OPT_DC_VARS, + OPT_PAR_VARS, + OPT_NON_PAR_VARS, //Boolean args. OPT_OPENCL, @@ -292,7 +299,7 @@ public: /// EmberOptions() { - const size_t size = 30; + const size_t size = 40; m_BoolArgs.reserve(size); m_IntArgs.reserve(size); m_UintArgs.reserve(size); @@ -306,6 +313,13 @@ public: INITBOOLOPTION(RegVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_REG_VARS, _T("--regvars"), false, SO_NONE, "\t--regvars Display the names of all supported regular variations and exit.\n")); INITBOOLOPTION(PreVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_PRE_VARS, _T("--prevars"), false, SO_NONE, "\t--prevars Display the names of all supported pre variations and exit.\n")); INITBOOLOPTION(PostVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_POST_VARS, _T("--postvars"), false, SO_NONE, "\t--postvars Display the names of all supported post variations and exit.\n")); + INITBOOLOPTION(SumVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_SUM_VARS, _T("--sumvars"), false, SO_NONE, "\t--sumvars Display the names of all regular variations which have the default behavior of summing their output, and exit.\n")); + INITBOOLOPTION(AssignVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_ASSIGN_VARS, _T("--assignvars"), false, SO_NONE, "\t--assignvars Display the names of all regular variations which have the non-standard behavior of assigning their output, and exit.\n")); + INITBOOLOPTION(PpSumVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_PPSUM_VARS, _T("--ppsumvars"), false, SO_NONE, "\t--ppsumvars Display the names of all pre/post variations which have the non-standard behavior of summing their output, and exit.\n")); + INITBOOLOPTION(PpAssignVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_PPASSIGN_VARS, _T("--ppassignvars"), false, SO_NONE, "\t--ppassignvars Display the names of all pre/post variations which have the default behavior of assigning their output, and exit.\n")); + INITBOOLOPTION(DcVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_DC_VARS, _T("--dcvars"), false, SO_NONE, "\t--dcvars Display the names of all variations which alter the color index and exit.\n")); + INITBOOLOPTION(ParVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_PAR_VARS, _T("--parvars"), false, SO_NONE, "\t--parvars Display the names of all variations which have parameters and exit.\n")); + INITBOOLOPTION(NonParVars, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_NON_PAR_VARS, _T("--nonparvars"), false, SO_NONE, "\t--nonparvars Display the names of all variations which do not have parameters (weight only) and exit.\n")); //Diagnostic bools. INITBOOLOPTION(Verbose, Eob(eOptionUse::OPT_USE_ALL, eOptionIDs::OPT_VERBOSE, _T("--verbose"), false, SO_NONE, "\t--verbose Verbose output [default: false].\n")); INITBOOLOPTION(Debug, Eob(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_DEBUG, _T("--debug"), false, SO_NONE, "\t--debug Debug output [default: false].\n")); @@ -449,6 +463,13 @@ public: PARSEBOOLOPTION(eOptionIDs::OPT_REG_VARS, RegVars); PARSEBOOLOPTION(eOptionIDs::OPT_PRE_VARS, PreVars); PARSEBOOLOPTION(eOptionIDs::OPT_POST_VARS, PostVars); + PARSEBOOLOPTION(eOptionIDs::OPT_SUM_VARS, SumVars); + PARSEBOOLOPTION(eOptionIDs::OPT_ASSIGN_VARS, AssignVars); + PARSEBOOLOPTION(eOptionIDs::OPT_PPSUM_VARS, PpSumVars); + PARSEBOOLOPTION(eOptionIDs::OPT_PPASSIGN_VARS, PpAssignVars); + PARSEBOOLOPTION(eOptionIDs::OPT_DC_VARS, DcVars); + PARSEBOOLOPTION(eOptionIDs::OPT_PAR_VARS, ParVars); + PARSEBOOLOPTION(eOptionIDs::OPT_NON_PAR_VARS, NonParVars); PARSEBOOLOPTION(eOptionIDs::OPT_OPENCL, EmberCL); PARSEBOOLOPTION(eOptionIDs::OPT_SP, Sp); PARSEBOOLOPTION(eOptionIDs::OPT_EARLYCLIP, EarlyClip); @@ -721,6 +742,13 @@ public: Eob RegVars; Eob PreVars; Eob PostVars; + Eob SumVars; + Eob AssignVars; + Eob PpSumVars; + Eob PpAssignVars; + Eob DcVars; + Eob ParVars; + Eob NonParVars; Eob EmberCL;//Value bool. Eob Sp; diff --git a/Source/EmberGenome/EmberGenome.cpp b/Source/EmberGenome/EmberGenome.cpp index b20632f..20b40fe 100644 --- a/Source/EmberGenome/EmberGenome.cpp +++ b/Source/EmberGenome/EmberGenome.cpp @@ -66,7 +66,9 @@ bool EmberGenome(EmberOptions& opt) auto varList = VariationList::Instance(); - if (opt.AllVars() || opt.RegVars() || opt.PreVars() || opt.PostVars()) + if (opt.AllVars() || opt.SumVars() || opt.AssignVars() || opt.PpSumVars() || opt.PpAssignVars() || + opt.DcVars() || opt.ParVars() || opt.NonParVars() || + opt.RegVars() || opt.PreVars() || opt.PostVars()) { if (opt.AllVars()) { @@ -75,9 +77,76 @@ bool EmberGenome(EmberOptions& opt) for (auto& v : vars) cout << v->Name() << "\n"; } + else if (opt.SumVars()) + { + auto& reg = varList->RegVars(); + auto matches = FindVarsWithout(varList->RegVars(), vector { "outPoint->m_X =", "outPoint->m_Y =", "outPoint->m_Z =", + "outPoint->m_X=", "outPoint->m_Y=", "outPoint->m_Z=" + }); + + for (auto& v : matches) + cout << v->Name() << "\n"; + } + else if (opt.AssignVars()) + { + auto matches = FindVarsWith(varList->RegVars(), vector { "outPoint->m_X =", "outPoint->m_Y =", "outPoint->m_Z =", + "outPoint->m_X=", "outPoint->m_Y=", "outPoint->m_Z=" + }); + + for (auto& v : matches) + cout << v->Name() << "\n"; + } + else if (opt.PpSumVars()) + { + auto& pre = varList->PreVars(); + auto& post = varList->PostVars(); + + for (auto& v : pre) + if (v->AssignType() == eVariationAssignType::ASSIGNTYPE_SUM) + cout << v->Name() << "\n"; + + for (auto& v : post) + if (v->AssignType() == eVariationAssignType::ASSIGNTYPE_SUM) + cout << v->Name() << "\n"; + } + else if (opt.PpAssignVars()) + { + auto& pre = varList->PreVars(); + auto& post = varList->PostVars(); + + for (auto& v : pre) + if (v->AssignType() == eVariationAssignType::ASSIGNTYPE_SET) + cout << v->Name() << "\n"; + + for (auto& v : post) + if (v->AssignType() == eVariationAssignType::ASSIGNTYPE_SET) + cout << v->Name() << "\n"; + } + else if (opt.DcVars()) + { + auto& all = varList->AllVars(); + auto matches = FindVarsWith(all, vector { "m_ColorX" }); + + for (auto& v : matches) + cout << v->Name() << "\n"; + } + else if (opt.ParVars()) + { + auto& par = varList->ParametricVariations(); + + for (auto& v : par) + cout << v->Name() << "\n"; + } + else if (opt.NonParVars()) + { + auto& par = varList->NonParametricVariations(); + + for (auto& v : par) + cout << v->Name() << "\n"; + } else { - vector*> vars; + vector*> vars; if (opt.RegVars()) vars.insert(vars.end(), varList->RegVars().begin(), varList->RegVars().end()); diff --git a/Source/EmberTester/EmberTester.cpp b/Source/EmberTester/EmberTester.cpp index 557d360..809fc98 100644 --- a/Source/EmberTester/EmberTester.cpp +++ b/Source/EmberTester/EmberTester.cpp @@ -299,65 +299,6 @@ void TestAtomicAdd() } } -template -bool SearchVar(const Variation* var, vector& stringVec, bool matchAll) -{ - bool ret = false; - size_t i; - auto cl = var->OpenCLFuncsString() + "\n" + var->OpenCLString(); - - if (matchAll) - { - for (i = 0; i < stringVec.size(); i++) - { - if (cl.find(stringVec[i]) == std::string::npos) - { - break; - } - } - - ret = (i == stringVec.size()); - } - else - { - for (i = 0; i < stringVec.size(); i++) - { - if (cl.find(stringVec[i]) != std::string::npos) - { - ret = true; - break; - } - } - } - - return ret; -} - -template -static vector*> FindVarsWith(vector& stringVec, bool findAll = true) -{ - int index = 0; - auto vl = VariationList::Instance(); - vector*> vec; - - while (index < vl->RegSize()) - { - auto regVar = vl->GetVariation(index, eVariationType::VARTYPE_REG); - - if (SearchVar(regVar, stringVec, false)) - { - vec.push_back(regVar->Copy()); - - if (!findAll) - break; - } - - index++; - } - - return vec; -} - bool TestVarCounts() { auto vlf(VariationList::Instance()); @@ -1306,7 +1247,8 @@ void TestVarTime() void TestCasting() { vector stringVec; - vector*> varVec; + auto varList = VariationList::Instance(); + auto& vars = varList->AllVars(); stringVec.push_back("T("); stringVec.push_back(".0f"); stringVec.push_back(".1f"); @@ -1318,21 +1260,20 @@ void TestCasting() stringVec.push_back(".7f"); stringVec.push_back(".8f"); stringVec.push_back(".9f"); - varVec = FindVarsWith(stringVec); + auto varVec = FindVarsWith(vars, stringVec); for (auto& it : varVec) { cout << "Variation " << it->Name() << " contained an improper float cast." << endl; } - - ClearVec>(varVec); } template void TestOperations() { vector stringVec; - vector*> varVec; + auto varList = VariationList::Instance(); + auto& vars = varList->AllVars(); //stringVec.push_back("%"); //varVec = FindVarsWith(Vec); // @@ -1345,7 +1286,7 @@ void TestOperations() //ClearVec>(varVec); stringVec.push_back("MwcNext(mwc) %"); stringVec.push_back("MwcNext(mwc)%"); - varVec = FindVarsWith(stringVec); + auto varVec = FindVarsWith(vars, stringVec); for (size_t i = 0; i < varVec.size(); i++) { @@ -1353,7 +1294,6 @@ void TestOperations() } stringVec.clear(); - ClearVec>(varVec); } template diff --git a/Source/Fractorium/FractoriumRender.cpp b/Source/Fractorium/FractoriumRender.cpp index fe42746..6b55742 100644 --- a/Source/Fractorium/FractoriumRender.cpp +++ b/Source/Fractorium/FractoriumRender.cpp @@ -430,6 +430,9 @@ bool FractoriumEmberController::Render() if (m_UndoList.size() >= UNDO_SIZE) m_UndoList.pop_front(); } + + //else + // qDebug() << "Mouse was down, not adding to undo list."; } else if (!m_LastEditWasUndoRedo && m_UndoIndex < m_UndoList.size() - 1)//They were anywhere but the end of the undo list, then did a manual edit, so clear the undo list. {