From 82b41c37e7ea782164106f1301d887f1c2f8d238 Mon Sep 17 00:00:00 2001 From: Michel Mastriani Date: Fri, 24 May 2019 14:26:03 -0300 Subject: [PATCH 1/2] Added poincare2 --- Source/Ember/Variation.h | 3 ++ Source/Ember/VariationList.cpp | 1 + Source/Ember/Variations02.h | 88 ++++++++++++++++++++++++++++++++++ Source/Ember/XmlToEmber.cpp | 19 ++++---- 4 files changed, 100 insertions(+), 11 deletions(-) diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h index 2eb2caf..b10d413 100644 --- a/Source/Ember/Variation.h +++ b/Source/Ember/Variation.h @@ -312,6 +312,7 @@ enum class eVariationId : et VAR_PIE3D , VAR_PIXEL_FLOW , VAR_POINCARE , + VAR_POINCARE2 , VAR_POINCARE3D , VAR_POINT_SYMMETRY, VAR_POLAR , @@ -725,6 +726,7 @@ enum class eVariationId : et VAR_PRE_PIE3D, VAR_PRE_PIXEL_FLOW, VAR_PRE_POINCARE, + VAR_PRE_POINCARE2, VAR_PRE_POINCARE3D, VAR_PRE_POINT_SYMMETRY, VAR_PRE_POLAR, @@ -1137,6 +1139,7 @@ enum class eVariationId : et VAR_POST_PIE3D, VAR_POST_PIXEL_FLOW, VAR_POST_POINCARE, + VAR_POST_POINCARE2, VAR_POST_POINCARE3D, VAR_POST_POINT_SYMMETRY, VAR_POST_POLAR, diff --git a/Source/Ember/VariationList.cpp b/Source/Ember/VariationList.cpp index 08fcc10..ee648ba 100644 --- a/Source/Ember/VariationList.cpp +++ b/Source/Ember/VariationList.cpp @@ -172,6 +172,7 @@ VariationList::VariationList() ADDPREPOSTREGVAR(NPolar) ADDPREPOSTREGVAR(Ortho) ADDPREPOSTREGVAR(Poincare) + ADDPREPOSTREGVAR(Poincare2) ADDPREPOSTREGVAR(Poincare3D) ADDPREPOSTREGVAR(Polynomial) ADDPREPOSTREGVAR(PSphere) diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index c70c80a..031dd0c 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -4493,6 +4493,93 @@ private: T m_C2d; }; +/// +/// Poincare. +/// +template +class Poincare2Variation : public ParametricVariation +{ +public: + Poincare2Variation(T weight = 1.0) : ParametricVariation("poincare2", eVariationId::VAR_POINCARE2, weight) + { + Init(); + } + + PARVARCOPY(Poincare2Variation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T a = helper.In.x - m_Cx; + T b = helper.In.y - m_Cy; + T c = T(1) - m_Cx * helper.In.x - m_Cy * helper.In.y; + T d = m_Cy * helper.In.x - m_Cx * helper.In.y; + + T num = m_Weight / (c * c + d * d); + + helper.Out.x = (a * c + b * d) * num; + helper.Out.y = (b * c - a * d) * num; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0; + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string cP = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cQ = "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; + + ss << "\t{\n" + << "\t\treal_t a = vIn.x - " << cX << ";\n" + << "\t\treal_t b = vIn.y - " << cY << ";\n" + << "\t\treal_t c = 1 - " << cX << " * vIn.x - " << cY << " * vIn.y;\n" + << "\t\treal_t d = " << cY <<" * vIn.x - " << cX << " * vIn.y;\n" + << "\t\treal_t num = " << weight <<" / (c * c + d * d);\n" + << "\n" + << "\t\tvOut.x = (a * c + b * d) * num;\n" + << "\t\tvOut.y = (b * c - a * d) * num;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + T a0 = M_2PI / m_PoincareP; + T dist2 = T(1) - (cos(a0) - T(1)) / (cos(a0) + cos(M_2PI / m_PoincareQ)); + T dist = (dist2 > T(0)) ? T(1) / sqrt(dist2) : T(1); + + if (T(1) / m_PoincareP + T(1) / m_PoincareQ < T(0.5)) + { + m_Cx = cos(a0) * dist; + m_Cy = sin(a0) * dist; + } + else + m_Cx = m_Cy = T(0); + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_PoincareP, prefix + "poincare_p", 3)); + m_Params.push_back(ParamWithName(&m_PoincareQ, prefix + "poincare_q", 7)); + m_Params.push_back(ParamWithName(true, &m_Cx, prefix + "poincare_cx")); //Precalc. + m_Params.push_back(ParamWithName(true, &m_Cy, prefix + "poincare_cy")); + } + +private: + T m_PoincareP; + T m_PoincareQ; + T m_Cx; //Precalc. + T m_Cy; +}; + /// /// Poincare3D. /// @@ -6014,6 +6101,7 @@ MAKEPREPOSTPARVAR(Murl2, murl2, MURL2) MAKEPREPOSTPARVAR(NPolar, npolar, NPOLAR) MAKEPREPOSTPARVAR(Ortho, ortho, ORTHO) MAKEPREPOSTPARVAR(Poincare, poincare, POINCARE) +MAKEPREPOSTPARVAR(Poincare2, poincare2, POINCARE2) MAKEPREPOSTPARVAR(Poincare3D, poincare3D, POINCARE3D) MAKEPREPOSTPARVAR(Polynomial, polynomial, POLYNOMIAL) MAKEPREPOSTPARVAR(PSphere, psphere, PSPHERE) diff --git a/Source/Ember/XmlToEmber.cpp b/Source/Ember/XmlToEmber.cpp index 5b42a0c..0b01c0b 100644 --- a/Source/Ember/XmlToEmber.cpp +++ b/Source/Ember/XmlToEmber.cpp @@ -908,13 +908,7 @@ bool XmlToEmber::ParseEmberElementFromChaos(xmlNode* emberNode, Ember& cur if (!varname.empty()) { T weight = 1; - string corrvarname; - - if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't. - corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname); - else - corrvarname = varname; - + string corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname); auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname; if (auto var = m_VariationList->GetVariation(corrwprefix)) @@ -2486,11 +2480,14 @@ string XmlToEmber::GetCorrectedVariationName(vector template string XmlToEmber::GetCorrectedVariationName(vector, vector>>& vec, const string& varname) { - for (auto& v : vec) - if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here. - return v.first.second; + if (varname == "poincare")//for Apo flames, poincare must be the same, but chaotica poincare is implemented as poincare2 + return "poincare2"; + else if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't. + for (auto& v : vec) + if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here. + return v.first.second; - return varname; + return varname; } /// From 8b4dfb399137c6317a35c6a17c92bb217e0446a9 Mon Sep 17 00:00:00 2001 From: Michel Mastriani Date: Fri, 24 May 2019 17:33:21 +0000 Subject: [PATCH 2/2] Variations02.h edited online with Bitbucket --- Source/Ember/Variations02.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index 031dd0c..99732e7 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -4494,7 +4494,7 @@ private: }; /// -/// Poincare. +/// Poincare2. /// template class Poincare2Variation : public ParametricVariation