--User changes

-Add gnarly variation.

--Bug fixes
 -Fix reading of post variations in .chaos files.
 -Make selection of points on color curves control apply only to the current selection as specified by the radio buttons below.

--Code changes
 -Use std::complex<T> type in some variations' CPU code.
This commit is contained in:
Person
2019-05-28 20:08:59 -07:00
parent a698edf887
commit c000c67d45
9 changed files with 234 additions and 226 deletions

View File

@ -4502,89 +4502,86 @@ template <typename T>
class Poincare2Variation : public ParametricVariation<T>
{
public:
Poincare2Variation(T weight = 1.0) : ParametricVariation<T>("poincare2", eVariationId::VAR_POINCARE2, weight)
{
Init();
}
Poincare2Variation(T weight = 1.0) : ParametricVariation<T>("poincare2", eVariationId::VAR_POINCARE2, weight)
{
Init();
}
PARVARCOPY(Poincare2Variation)
PARVARCOPY(Poincare2Variation)
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T a = helper.In.x - m_Cx;
T b = helper.In.y - m_Cy;
T c = 1 - m_Cx * helper.In.x - m_Cy * helper.In.y;
T d = m_Cy * helper.In.x - m_Cx * helper.In.y;
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T a = helper.In.x - m_Cx;
T b = helper.In.y - m_Cy;
T c = 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 / Zeps(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);
}
T num = m_Weight / Zeps(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 <<" / Zeps(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 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 = fma(" << cY << ", vIn.x, -(" << cX << " * vIn.y));\n"
<< "\t\treal_t num = " << weight << " / Zeps(fma(c, c, d * d));\n"
<< "\n"
<< "\t\tvOut.x = fma(a, c, b * d) * num;\n"
<< "\t\tvOut.y = fma(b, c, -(a * d)) * num;\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
virtual void Precalc() override
{
T a0 = M_2PI / m_PoincareP;
T dist2 = 1 - (std::cos(a0) - 1) / (std::cos(a0) + std::cos(M_2PI / m_PoincareQ));
T dist = (dist2 > 0) ? T(1) / std::sqrt(dist2) : T(1);
if (1 / m_PoincareP + 1 / m_PoincareQ < T(0.5))
{
m_Cx = std::cos(a0) * dist;
m_Cy = std::sin(a0) * dist;
}
else
m_Cx = m_Cy = 0;
}
virtual void Precalc() override
{
T a0 = M_2PI / m_PoincareP;
T dist2 = 1 - (std::cos(a0) - 1) / (std::cos(a0) + std::cos(M_2PI / m_PoincareQ));
T dist = (dist2 > 0) ? T(1) / std::sqrt(dist2) : T(1);
if (1 / m_PoincareP + 1 / m_PoincareQ < T(0.5))
{
m_Cx = std::cos(a0) * dist;
m_Cy = std::sin(a0) * dist;
}
else
m_Cx = m_Cy = 0;
}
protected:
void Init()
{
string prefix = Prefix();
m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_PoincareP, prefix + "poincare2_p", 3));
m_Params.push_back(ParamWithName<T>(&m_PoincareQ, prefix + "poincare2_q", 7));
m_Params.push_back(ParamWithName<T>(true, &m_Cx, prefix + "poincare2_cx"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Cy, prefix + "poincare2_cy"));
}
void Init()
{
string prefix = Prefix();
m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_PoincareP, prefix + "poincare2_p", 3));
m_Params.push_back(ParamWithName<T>(&m_PoincareQ, prefix + "poincare2_q", 7));
m_Params.push_back(ParamWithName<T>(true, &m_Cx, prefix + "poincare2_cx"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Cy, prefix + "poincare2_cy"));
}
private:
T m_PoincareP;
T m_PoincareQ;
T m_Cx;//Precalc.
T m_Cy;
T m_PoincareP;
T m_PoincareQ;
T m_Cx;//Precalc.
T m_Cy;
};
/// <summary>