mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 21:20:07 -05:00
Improved performance in hypercrop variation
This commit is contained in:
parent
def996d10c
commit
088d4656e4
@ -2070,14 +2070,11 @@ public:
|
|||||||
T fx = helper.In.x;
|
T fx = helper.In.x;
|
||||||
T fy = helper.In.y;
|
T fy = helper.In.y;
|
||||||
T fz = helper.In.z;
|
T fz = helper.In.z;
|
||||||
T a0 = T(M_PI) / m_N;
|
T angle = Floor<T>(helper.m_PrecalcAtanyx * m_Coeff) / m_Coeff + m_A0;
|
||||||
T len = 1 / Zeps(std::cos(a0));
|
T x0 = std::cos(angle) * m_Len;
|
||||||
T d = m_Rad * std::sin(a0) * len;
|
T y0 = std::sin(angle) * m_Len;
|
||||||
T angle = Floor<T>(helper.m_PrecalcAtanyx * m_Coeff) / m_Coeff + T(M_PI) / m_N;
|
|
||||||
T x0 = std::cos(angle) * len;
|
|
||||||
T y0 = std::sin(angle) * len;
|
|
||||||
|
|
||||||
if (std::sqrt(Sqr(helper.In.x - x0) + Sqr(helper.In.y - y0)) < d)
|
if (std::sqrt(Sqr(helper.In.x - x0) + Sqr(helper.In.y - y0)) < m_D)
|
||||||
{
|
{
|
||||||
if (m_Zero > 1.5)
|
if (m_Zero > 1.5)
|
||||||
{
|
{
|
||||||
@ -2096,8 +2093,8 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
T rangle = std::atan2(helper.In.y - y0, helper.In.x - x0);
|
T rangle = std::atan2(helper.In.y - y0, helper.In.x - x0);
|
||||||
fx = x0 + std::cos(rangle) * d;
|
fx = x0 + std::cos(rangle) * m_D;
|
||||||
fy = y0 + std::sin(rangle) * d;
|
fy = y0 + std::sin(rangle) * m_D;
|
||||||
fz = 0;
|
fz = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2118,21 +2115,21 @@ public:
|
|||||||
string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
string n = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||||
string rad = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
string rad = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||||
string zero = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
string zero = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||||
string coeff = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
string coeff = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||||
|
string a0 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||||
|
string len = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||||
|
string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||||
ss << "\t{\n"
|
ss << "\t{\n"
|
||||||
<< "\t\treal_t fx = vIn.x;\n"
|
<< "\t\treal_t fx = vIn.x;\n"
|
||||||
<< "\t\treal_t fy = vIn.y;\n"
|
<< "\t\treal_t fy = vIn.y;\n"
|
||||||
<< "\t\treal_t fz = vIn.z;\n"
|
<< "\t\treal_t fz = vIn.z;\n"
|
||||||
<< "\t\treal_t a0 = MPI / " << n << ";\n"
|
<< "\t\treal_t angle = floor(precalcAtanyx * " << coeff << ") / " << coeff << " + " << a0 << ";\n"
|
||||||
<< "\t\treal_t len = 1 / Zeps(cos(a0));\n"
|
<< "\t\treal_t x0 = cos(angle) * " << len << ";\n"
|
||||||
<< "\t\treal_t d = " << rad << " * sin(a0) * len;\n"
|
<< "\t\treal_t y0 = sin(angle) * " << len << ";\n"
|
||||||
<< "\t\treal_t angle = floor(precalcAtanyx * " << coeff << ") / " << coeff << " + MPI / " << n << ";\n"
|
|
||||||
<< "\t\treal_t x0 = cos(angle) * len;\n"
|
|
||||||
<< "\t\treal_t y0 = sin(angle) * len;\n"
|
|
||||||
<< "\t\treal_t xmx = vIn.x - x0;\n"
|
<< "\t\treal_t xmx = vIn.x - x0;\n"
|
||||||
<< "\t\treal_t ymy = vIn.y - y0;\n"
|
<< "\t\treal_t ymy = vIn.y - y0;\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "\t\tif (sqrt(fma(xmx, xmx, SQR(ymy))) < d)\n"
|
<< "\t\tif (sqrt(fma(xmx, xmx, SQR(ymy))) < " << d << ")\n"
|
||||||
<< "\t\t{\n"
|
<< "\t\t{\n"
|
||||||
<< "\t\t if (" << zero << " > 1.5)\n"
|
<< "\t\t if (" << zero << " > 1.5)\n"
|
||||||
<< "\t\t {\n"
|
<< "\t\t {\n"
|
||||||
@ -2151,8 +2148,8 @@ public:
|
|||||||
<< "\t\t else\n"
|
<< "\t\t else\n"
|
||||||
<< "\t\t {\n"
|
<< "\t\t {\n"
|
||||||
<< "\t\t real_t rangle = atan2(vIn.y - y0, vIn.x - x0);\n"
|
<< "\t\t real_t rangle = atan2(vIn.y - y0, vIn.x - x0);\n"
|
||||||
<< "\t\t fx = fma(cos(rangle), d, x0);\n"
|
<< "\t\t fx = fma(cos(rangle), " << d << ", x0);\n"
|
||||||
<< "\t\t fy = fma(sin(rangle), d, y0);\n"
|
<< "\t\t fy = fma(sin(rangle), " << d << ", y0);\n"
|
||||||
<< "\t\t fz = 0;\n"
|
<< "\t\t fz = 0;\n"
|
||||||
<< "\t\t }\n"
|
<< "\t\t }\n"
|
||||||
<< "\t\t }\n"
|
<< "\t\t }\n"
|
||||||
@ -2169,6 +2166,9 @@ public:
|
|||||||
{
|
{
|
||||||
m_N = Zeps(m_N);
|
m_N = Zeps(m_N);
|
||||||
m_Coeff = Zeps<T>(m_N * T(0.5) / T(M_PI));
|
m_Coeff = Zeps<T>(m_N * T(0.5) / T(M_PI));
|
||||||
|
m_A0 = T(M_PI) / m_N;
|
||||||
|
m_Len = 1 / Zeps(std::cos(m_A0));
|
||||||
|
m_D = m_Rad * std::sin(m_A0) * m_Len;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual vector<string> OpenCLGlobalFuncNames() const override
|
virtual vector<string> OpenCLGlobalFuncNames() const override
|
||||||
@ -2185,6 +2185,9 @@ protected:
|
|||||||
m_Params.push_back(ParamWithName<T>(&m_Rad, prefix + "hypercrop_rad", 1));
|
m_Params.push_back(ParamWithName<T>(&m_Rad, prefix + "hypercrop_rad", 1));
|
||||||
m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "hypercrop_zero"));
|
m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "hypercrop_zero"));
|
||||||
m_Params.push_back(ParamWithName<T>(true, &m_Coeff, prefix + "hypercrop_coeff"));//Precalc.
|
m_Params.push_back(ParamWithName<T>(true, &m_Coeff, prefix + "hypercrop_coeff"));//Precalc.
|
||||||
|
m_Params.push_back(ParamWithName<T>(true, &m_A0, prefix + "hypercrop_a0"));//Precalc.
|
||||||
|
m_Params.push_back(ParamWithName<T>(true, &m_Len, prefix + "hypercrop_len"));//Precalc.
|
||||||
|
m_Params.push_back(ParamWithName<T>(true, &m_D, prefix + "hypercrop_d"));//Precalc.
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -2192,6 +2195,9 @@ private:
|
|||||||
T m_Rad;
|
T m_Rad;
|
||||||
T m_Zero;
|
T m_Zero;
|
||||||
T m_Coeff;//Precalc.
|
T m_Coeff;//Precalc.
|
||||||
|
T m_A0;
|
||||||
|
T m_Len;
|
||||||
|
T m_D;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user