--Bug fixes

-Fix some potential OpenCL compilation bugs on circlecrop, circlecrop2, oscilloscope2, Truchet_hex_crop.
 -Prevent the minus key from changing the current xform when being pressed in a textbox.

--Code changes
 -Cleanup some casting in depth_blur, depth_blur2.
This commit is contained in:
Person 2019-06-24 19:43:15 -07:00
parent d234f635ea
commit ee1d5eb44d
6 changed files with 87 additions and 28 deletions

View File

@ -5026,7 +5026,7 @@ public:
<< "\t\treal_t t;\n"
<< "\t\treal_t pt = " << perturbation << " * sin(" << tpf2 << " * vIn.y);\n"
<< "\n"
<< "\t\tif (!" << damping << ")\n"
<< "\t\tif (" << damping << " == 0)\n"
<< "\t\t t = fma(" << amplitude << ", cos(fma(" << tpf << ", vIn.x, pt)), " << separation << ");\n"
<< "\t\telse\n"
<< "\t\t t = fma(" << amplitude << ", exp(-fabs(vIn.x) * " << damping << ") * cos(fma(" << tpf << ", vIn.x, pt)), " << separation << ");\n"

View File

@ -2190,7 +2190,7 @@ public:
helper.Out.x = m_Weight * xi + m_X;
helper.Out.y = m_Weight * yi + m_Y;
}
else if (!cr0 && esc)
else if (!cr0 && esc)
{
helper.Out.x = m_Weight * rdc * c + m_X;
helper.Out.y = m_Weight * rdc * s + m_Y;
@ -2360,7 +2360,7 @@ public:
<< "\n"
<< "\t\tif (rad > " << out << " || rad < " << in << ")\n"
<< "\t\t{\n"
<< "\t\t if (!" << zero << ")\n"
<< "\t\t if (" << zero << " == 0)\n"
<< "\t\t {\n"
<< "\t\t s = sin(ang) * " << outweight << ";\n"
<< "\t\t c = cos(ang) * " << outweight << ";\n"

View File

@ -1581,7 +1581,7 @@ public:
<< "\n"
<< "\t\tbool add = true;\n"
<< "\n"
<< "\t\tif (" << seed << " == 1)\n"
<< "\t\tif (" << seed << " == (real_t)(1.0))\n"
<< "\t\t{\n"
<< "\t\t if (!((int)rx & 1) && !((int)rz & 1))\n"
<< "\t\t add = false;\n"
@ -1861,7 +1861,7 @@ public:
<< "\t\treal_t y0 = sin(angle2);\n"
<< "\t\treal_t dist = sqrt(Sqr(FX - x0) + Sqr(FY - y0));\n"
<< "\n"
<< "\t\tif (" << inv << ")\n"
<< "\t\tif (" << inv << " != (real_t)(0.0))\n"
<< "\t\t{\n"
<< "\t\t if ((dist > " << d1precalc << ") || (dist < " << d2precalc << "))\n"
<< "\t\t {\n"
@ -3007,11 +3007,12 @@ public:
f = f - int_angle;
T x = f * m_Length;
T z = std::sqrt(1 + SQR(x) - 2 * x * m_CosAlpha);
int iangle = int(int_angle);
if (!(((int)int_angle) & 1))
int_angle = m_2piOverPower * (((int)int_angle) / 2) + std::asin(m_SinAlpha * x / Zeps(z));
if (!(iangle & 1))
int_angle = m_2piOverPower * (iangle / 2) + std::asin(m_SinAlpha * x / Zeps(z));
else
int_angle = m_2piOverPower * (((int)int_angle) / 2) - std::asin(m_SinAlpha * x / Zeps(z));
int_angle = m_2piOverPower * (iangle / 2) - std::asin(m_SinAlpha * x / Zeps(z));
z *= std::sqrt(rand.Frand01<T>());
by = std::sin(int_angle - T(M_PI_2));
@ -3056,11 +3057,12 @@ public:
<< "\t\t f = f - int_angle;\n"
<< "\t\t real_t x = f * " << length << ";\n"
<< "\t\t real_t z = sqrt(1 + SQR(x) - 2 * x * " << cosalpha << ");\n"
<< "\t\t int iangle = (int)int_angle;\n"
<< "\n"
<< "\t\t if (!(((int)int_angle) & 1))\n"
<< "\t\t int_angle = " << twopioverpower << " * (((int)int_angle) / 2) + asin(" << sinalpha << " * x / Zeps(z));\n"
<< "\t\t if (!(iangle & 1))\n"
<< "\t\t int_angle = " << twopioverpower << " * (iangle / 2) + asin(" << sinalpha << " * x / Zeps(z));\n"
<< "\t\t else\n"
<< "\t\t int_angle = " << twopioverpower << " * (((int)int_angle) / 2) - asin(" << sinalpha << " * x / Zeps(z));\n"
<< "\t\t int_angle = " << twopioverpower << " * (iangle / 2) - asin(" << sinalpha << " * x / Zeps(z));\n"
<< "\n"
<< "\t\t z *= sqrt(MwcNext01(mwc));\n"
<< "\t\t by = sin(int_angle - MPI2);\n"
@ -3155,11 +3157,12 @@ public:
f = f - int_angle;
T x = f * m_Length;
T z = std::sqrt(1 + SQR(x) - 2 * x * std::cos(m_Alpha));
int iangle = int(int_angle);
if (!(((int)int_angle) & 1))
int_angle = m_2piOverPower * (((int)int_angle) / 2) + std::asin(std::sin(m_Alpha) * x / Zeps(z));
if (!(iangle & 1))
int_angle = m_2piOverPower * (iangle / 2) + std::asin(std::sin(m_Alpha) * x / Zeps(z));
else
int_angle = m_2piOverPower * (((int)int_angle) / 2) - std::asin(std::sin(m_Alpha) * x / Zeps(z));
int_angle = m_2piOverPower * (iangle / 2) - std::asin(std::sin(m_Alpha) * x / Zeps(z));
z *= std::sqrt(rand.Frand01<T>());
by = std::sin(int_angle - T(M_PI_2));
@ -3209,11 +3212,12 @@ public:
<< "\t\t f = f - int_angle;\n"
<< "\t\t real_t x = f * " << length << ";\n"
<< "\t\t real_t z = sqrt(1 + SQR(x) - 2 * x * cos(" << alpha << "));\n"
<< "\t\t int iangle = (int)int_angle;\n"
<< "\n"
<< "\t\t if (!(((int)int_angle) & 1))\n"
<< "\t\t int_angle = " << twopioverpower << " * (((int)int_angle) / 2) + asin(sin(" << alpha << ") * x / Zeps(z));\n"
<< "\t\t if (!(iangle & 1))\n"
<< "\t\t int_angle = " << twopioverpower << " * (iangle / 2) + asin(sin(" << alpha << ") * x / Zeps(z));\n"
<< "\t\t else\n"
<< "\t\t int_angle = " << twopioverpower << " * (((int)int_angle) / 2) - asin(sin(" << alpha << ") * x / Zeps(z));\n"
<< "\t\t int_angle = " << twopioverpower << " * (iangle / 2) - asin(sin(" << alpha << ") * x / Zeps(z));\n"
<< "\n"
<< "\t\t z *= sqrt(MwcNext01(mwc));\n"
<< "\t\t by = sin(int_angle - MPI2);\n"

View File

@ -736,6 +736,38 @@ bool SearchVar(const Variation<T>* var, const vector<string>& stringVec, bool ma
return ret;
}
template <typename T>
bool SearchVarWWO(const Variation<T>* var, const vector<string>& withVec, const vector<string>& withoutVec)
{
bool ret = false;
size_t i, j, k;
bool onegood = false;
auto cl = var->OpenCLFuncsString() + "\n" + var->OpenCLString();
vector<string> clsplits = Split(cl, '\n');
for (i = 0; i < clsplits.size(); i++)
{
for (j = 0; j < withVec.size(); j++)
{
if (clsplits[i].find(withVec[j]) != std::string::npos)
{
for (k = 0; k < withoutVec.size(); k++)
{
if (clsplits[i].find(withoutVec[k]) != std::string::npos)
{
return false;
}
}
onegood = true;
}
}
}
return onegood;
//return i == clsplits.size() && j == withVec.size() && k == withoutVec.size();
}
/// <summary>
/// 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
@ -766,6 +798,23 @@ static vector<const Variation<T>*> FindVarsWith(const vector<const Variation<T>*
return vec;
}
template <typename T>
static vector<const Variation<T>*> FindVarsWithWithout(const vector<const Variation<T>*>& vars, const vector<string>& withVec, const vector<string>& withoutVec)
{
vector<const Variation<T>*> vec;
auto vl = VariationList<T>::Instance();
for (auto& v : vars)
{
if (SearchVarWWO<T>(v, withVec, withoutVec))
{
vec.push_back(v);
}
}
return vec;
}
/// <summary>
/// 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

View File

@ -1585,21 +1585,26 @@ void TestOperations()
void TestArbitrary()
{
vector<string> stringVec;
vector<string> stringVec, withoutVec;
auto varList = VariationList<float>::Instance();
auto& vars = varList->AllVars();
stringVec.push_back(" = vIn.x - ");
stringVec.push_back(" = vIn.y - ");
stringVec.push_back("sqrt(");
stringVec.push_back("atan2(");
stringVec.push_back("sin(");
stringVec.push_back("cos(");
stringVec.push_back("if (!");
withoutVec.push_back("=");
withoutVec.push_back("<");
withoutVec.push_back(">");
//stringVec.push_back(" = vIn.x - ");
//stringVec.push_back(" = vIn.y - ");
//stringVec.push_back("sqrt(");
//stringVec.push_back("atan2(");
//stringVec.push_back("sin(");
//stringVec.push_back("cos(");
//stringVec.push_back("sincos(");
auto varVec = FindVarsWith<float>(vars, stringVec, true, true);
//auto varVec = FindVarsWith<float>(vars, stringVec, true, true);
auto varVec = FindVarsWithWithout<float>(vars, stringVec, withoutVec);
for (auto& it : varVec)
{
cout << "Variation " << it->Name() << " contained the desired strings." << endl;
cout << "Variation " << it->Name() << " contained the desired w/wo strings." << endl;
}
}

View File

@ -404,10 +404,11 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e)
}
else if (o == this)
{
auto focusedctrlEdit = dynamic_cast<QLineEdit*>(this->focusWidget());
auto focusedctrlSpin = dynamic_cast<QSpinBox*>(this->focusWidget());
auto focusedctrlDbSpin = dynamic_cast<QDoubleSpinBox*>(this->focusWidget());
auto focusedctrlDblSpin = dynamic_cast<QDoubleSpinBox*>(this->focusWidget());
if (!focusedctrlSpin && !focusedctrlDbSpin)//Must exclude these because otherwise, typing a minus key in any of the spinners will switch the xform.
if (!focusedctrlEdit && !focusedctrlSpin && !focusedctrlDblSpin)//Must exclude these because otherwise, typing a minus key in any of the spinners will switch the xform.
{
unsigned int index = combo->currentIndex();