mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 13:10:04 -05:00
Improved performance in hypercrop variation
This commit is contained in:
parent
def996d10c
commit
088d4656e4
@ -2069,15 +2069,12 @@ public:
|
||||
{
|
||||
T fx = helper.In.x;
|
||||
T fy = helper.In.y;
|
||||
T fz = helper.In.z;
|
||||
T a0 = T(M_PI) / m_N;
|
||||
T len = 1 / Zeps(std::cos(a0));
|
||||
T d = m_Rad * std::sin(a0) * 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;
|
||||
T fz = helper.In.z;
|
||||
T angle = Floor<T>(helper.m_PrecalcAtanyx * m_Coeff) / m_Coeff + m_A0;
|
||||
T x0 = std::cos(angle) * m_Len;
|
||||
T y0 = std::sin(angle) * m_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)
|
||||
{
|
||||
@ -2096,8 +2093,8 @@ public:
|
||||
else
|
||||
{
|
||||
T rangle = std::atan2(helper.In.y - y0, helper.In.x - x0);
|
||||
fx = x0 + std::cos(rangle) * d;
|
||||
fy = y0 + std::sin(rangle) * d;
|
||||
fx = x0 + std::cos(rangle) * m_D;
|
||||
fy = y0 + std::sin(rangle) * m_D;
|
||||
fz = 0;
|
||||
}
|
||||
}
|
||||
@ -2118,21 +2115,21 @@ public:
|
||||
string n = "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 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"
|
||||
<< "\t\treal_t fx = vIn.x;\n"
|
||||
<< "\t\treal_t fy = vIn.y;\n"
|
||||
<< "\t\treal_t fz = vIn.z;\n"
|
||||
<< "\t\treal_t a0 = MPI / " << n << ";\n"
|
||||
<< "\t\treal_t len = 1 / Zeps(cos(a0));\n"
|
||||
<< "\t\treal_t d = " << rad << " * sin(a0) * 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 angle = floor(precalcAtanyx * " << coeff << ") / " << coeff << " + " << a0 << ";\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 ymy = vIn.y - y0;\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 if (" << zero << " > 1.5)\n"
|
||||
<< "\t\t {\n"
|
||||
@ -2151,8 +2148,8 @@ public:
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\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 fy = fma(sin(rangle), d, y0);\n"
|
||||
<< "\t\t fx = fma(cos(rangle), " << d << ", x0);\n"
|
||||
<< "\t\t fy = fma(sin(rangle), " << d << ", y0);\n"
|
||||
<< "\t\t fz = 0;\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t }\n"
|
||||
@ -2169,6 +2166,9 @@ public:
|
||||
{
|
||||
m_N = Zeps(m_N);
|
||||
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
|
||||
@ -2185,6 +2185,9 @@ protected:
|
||||
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>(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:
|
||||
@ -2192,6 +2195,9 @@ private:
|
||||
T m_Rad;
|
||||
T m_Zero;
|
||||
T m_Coeff;//Precalc.
|
||||
T m_A0;
|
||||
T m_Len;
|
||||
T m_D;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user