--Bug fixes

-mirror_x, y and z variations were totally wrong.
 -Reading color curves from older version 2 .chaos files which did not have the "knots" and "values" names was broken.
This commit is contained in:
Person 2019-05-22 20:33:19 -07:00
parent 28ce868a9f
commit a9650e6b43
2 changed files with 110 additions and 113 deletions

View File

@ -1161,56 +1161,40 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
helper.Out.x = std::abs(helper.In.x);
if (rand.RandBit())
helper.Out.x = -helper.Out.x;
helper.Out.y = helper.In.y;
helper.Out.z = helper.In.z;
if (m_VarType == eVariationType::VARTYPE_REG) if (m_VarType == eVariationType::VARTYPE_REG)
{ {
helper.Out.x = std::abs(outPoint.m_X); outPoint.m_X = 0;//All will be added.
outPoint.m_Y = 0;
if (rand.RandBit()) outPoint.m_Z = 0;
helper.Out.x = -helper.Out.x;
helper.Out.y = 0;
helper.Out.z = 0;
outPoint.m_X = 0;//Flipped x will be added.
}
else
{
helper.Out.x = std::abs(helper.In.x);
if (rand.RandBit())
helper.Out.x = -helper.Out.x;
helper.Out.y = helper.In.y;
helper.Out.z = helper.In.z;
} }
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
{ {
ostringstream ss; ostringstream ss;
ss << "\t{\n"; ss << "\t{\n"
"\t\tvOut.x = fabs(vIn.x);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\n"
"\t\t vOut.x = -vOut.x;\n"
"\n"
"\t\tvOut.y = vIn.y;\n"
"\t\tvOut.z = vIn.z;\n";
if (m_VarType == eVariationType::VARTYPE_REG) if (m_VarType == eVariationType::VARTYPE_REG)
{ {
ss << ss <<
"\t\tvOut.x = fabs(outPoint->m_X);\n" "\t\toutPoint->m_X = 0;\n"
"\n" "\t\toutPoint->m_Y = 0;\n"
"\t\tif (MwcNext(mwc) & 1)\n" "\t\toutPoint->m_Z = 0;\n";
"\t\t vOut.x = -vOut.x;\n"
"\n"
"\t\tvOut.y = 0;\n"
"\t\tvOut.z = 0;\n"
"\t\toutPoint->m_X = 0;\n";
}
else
{
ss <<
"\t\tvOut.x = fabs(vIn.x);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\n"
"\t\t vOut.x = -vOut.x;\n"
"\n"
"\t\tvOut.y = vIn.y;\n"
"\t\tvOut.z = vIn.z;\n";
} }
ss << "\t}\n"; ss << "\t}\n";
@ -1232,56 +1216,40 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
helper.Out.y = std::abs(helper.In.y);
if (rand.RandBit())
helper.Out.y = -helper.Out.y;
helper.Out.x = helper.In.x;
helper.Out.z = helper.In.z;
if (m_VarType == eVariationType::VARTYPE_REG) if (m_VarType == eVariationType::VARTYPE_REG)
{ {
helper.Out.y = std::abs(outPoint.m_Y); outPoint.m_X = 0;//All will be added.
outPoint.m_Y = 0;
if (rand.RandBit()) outPoint.m_Z = 0;
helper.Out.y = -helper.Out.y;
helper.Out.x = 0;
helper.Out.z = 0;
outPoint.m_Y = 0;//Flipped y will be added.
}
else
{
helper.Out.y = std::abs(helper.In.y);
if (rand.RandBit())
helper.Out.y = -helper.Out.y;
helper.Out.x = helper.In.x;
helper.Out.z = helper.In.z;
} }
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
{ {
ostringstream ss; ostringstream ss;
ss << "\t{\n"; ss << "\t{\n"
"\t\tvOut.y = fabs(vIn.y);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\n"
"\t\t vOut.y = -vOut.y;\n"
"\n"
"\t\tvOut.x = vIn.x;\n"
"\t\tvOut.z = vIn.z;\n";
if (m_VarType == eVariationType::VARTYPE_REG) if (m_VarType == eVariationType::VARTYPE_REG)
{ {
ss << ss <<
"\t\tvOut.y = fabs(outPoint->m_Y);\n" "\t\toutPoint->m_X = 0;\n"
"\n" "\t\toutPoint->m_Y = 0;\n"
"\t\tif (MwcNext(mwc) & 1)\n" "\t\toutPoint->m_Z = 0;\n";
"\t\t vOut.y = -vOut.y;\n"
"\n"
"\t\tvOut.x = 0;\n"
"\t\tvOut.z = 0;\n"
"\t\toutPoint->m_Y = 0;\n";
}
else
{
ss <<
"\t\tvOut.y = fabs(vIn.y);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\n"
"\t\t vOut.y = -vOut.y;\n"
"\n"
"\t\tvOut.x = vIn.x;\n"
"\t\tvOut.z = vIn.z;\n";
} }
ss << "\t}\n"; ss << "\t}\n";
@ -1303,57 +1271,41 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
helper.Out.z = std::abs(helper.In.z);
if (rand.RandBit())
helper.Out.z = -helper.Out.z;
helper.Out.x = helper.In.x;
helper.Out.y = helper.In.y;
if (m_VarType == eVariationType::VARTYPE_REG) if (m_VarType == eVariationType::VARTYPE_REG)
{ {
helper.Out.z = std::abs(outPoint.m_Z); outPoint.m_X = 0;//All will be added.
outPoint.m_Y = 0;
if (rand.RandBit()) outPoint.m_Z = 0;
helper.Out.z = -helper.Out.z;
helper.Out.x = 0;
helper.Out.y = 0;
outPoint.m_Z = 0;//Flipped z will be added.
}
else
{
helper.Out.z = std::abs(helper.In.z);
if (rand.RandBit())
helper.Out.z = -helper.Out.z;
helper.Out.x = helper.In.x;
helper.Out.y = helper.In.y;
} }
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
{ {
ostringstream ss; ostringstream ss;
ss << "\t{\n"; ss << "\t{\n"
"\t\tvOut.z = fabs(vIn.z);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\n"
"\t\t vOut.z = -vOut.z;\n"
"\n"
"\t\tvOut.x = vIn.x;\n"
"\t\tvOut.y = vIn.y;\n";
if (m_VarType == eVariationType::VARTYPE_REG) if (m_VarType == eVariationType::VARTYPE_REG)
{ {
ss << ss <<
"\t\tvOut.z = fabs(outPoint->m_Z);\n" "\t\toutPoint->m_X = 0;\n"
"\n" "\t\toutPoint->m_Y = 0;\n"
"\t\tif (MwcNext(mwc) & 1)\n"
"\t\t vOut.z = -vOut.z;\n"
"\n"
"\t\tvOut.x = 0;\n"
"\t\tvOut.y = 0;\n"
"\t\toutPoint->m_Z = 0;\n"; "\t\toutPoint->m_Z = 0;\n";
} }
else
{
ss <<
"\t\tvOut.z = fabs(vIn.z);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\n"
"\t\t vOut.z = -vOut.z;\n"
"\n"
"\t\tvOut.x = vIn.x;\n"
"\t\tvOut.y = vIn.y;\n";
}
ss << "\t}\n"; ss << "\t}\n";
return ss.str(); return ss.str();

View File

@ -1234,14 +1234,59 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
vector<v2F> vals; vector<v2F> vals;
if (auto knotsnode = GetChildNode(node, "knots")) if (auto knotsnode = GetChildNode(node, "knots"))
{
if (auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values")) if (auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (knotvalsnode->children) if (knotvalsnode->children)
knots = CCX(knotvalsnode->children->content); knots = CCX(knotvalsnode->children->content);
}
if (auto valuesnode = GetChildNode(node, "values")) if (auto valuesnode = GetChildNode(node, "values"))
{
if (auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values")) if (auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (valvalsnode->children) if (valvalsnode->children)
values = CCX(valvalsnode->children->content); values = CCX(valvalsnode->children->content);
}
if (knots.empty() && values.empty())
{
bool haveknots = false, havevals = false;
for (auto childNode = node->children; childNode; childNode = childNode->next)
{
if (childNode->type == XML_ELEMENT_NODE)
{
if (auto node = CheckNodeName(childNode, "table"))
{
if (!haveknots)
{
if (auto knotvalsnode = GetChildNodeByNodeName(node, "values"))
{
if (knotvalsnode->children)
{
knots = CCX(knotvalsnode->children->content);
haveknots = true;
}
continue;
}
}
else if (!havevals)
{
if (auto valvalsnode = GetChildNodeByNodeName(node, "values"))
{
if (valvalsnode->children)
{
values = CCX(valvalsnode->children->content);
havevals = true;
}
continue;
}
}
}
}
}
}
istringstream kistr(knots); istringstream kistr(knots);
istringstream vistr(values); istringstream vistr(values);