--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

@ -1160,19 +1160,6 @@ public:
VARCOPY(MirrorXVariation) VARCOPY(MirrorXVariation)
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
{
if (m_VarType == eVariationType::VARTYPE_REG)
{
helper.Out.x = std::abs(outPoint.m_X);
if (rand.RandBit())
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); helper.Out.x = std::abs(helper.In.x);
@ -1181,29 +1168,19 @@ public:
helper.Out.y = helper.In.y; helper.Out.y = helper.In.y;
helper.Out.z = helper.In.z; helper.Out.z = helper.In.z;
if (m_VarType == eVariationType::VARTYPE_REG)
{
outPoint.m_X = 0;//All will be added.
outPoint.m_Y = 0;
outPoint.m_Z = 0;
} }
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
{ {
ostringstream ss; ostringstream ss;
ss << "\t{\n"; ss << "\t{\n"
if (m_VarType == eVariationType::VARTYPE_REG)
{
ss <<
"\t\tvOut.x = fabs(outPoint->m_X);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\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" "\t\tvOut.x = fabs(vIn.x);\n"
"\n" "\n"
"\t\tif (MwcNext(mwc) & 1)\n" "\t\tif (MwcNext(mwc) & 1)\n"
@ -1211,6 +1188,13 @@ public:
"\n" "\n"
"\t\tvOut.y = vIn.y;\n" "\t\tvOut.y = vIn.y;\n"
"\t\tvOut.z = vIn.z;\n"; "\t\tvOut.z = vIn.z;\n";
if (m_VarType == eVariationType::VARTYPE_REG)
{
ss <<
"\t\toutPoint->m_X = 0;\n"
"\t\toutPoint->m_Y = 0;\n"
"\t\toutPoint->m_Z = 0;\n";
} }
ss << "\t}\n"; ss << "\t}\n";
@ -1231,19 +1215,6 @@ public:
VARCOPY(MirrorYVariation) VARCOPY(MirrorYVariation)
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
{
if (m_VarType == eVariationType::VARTYPE_REG)
{
helper.Out.y = std::abs(outPoint.m_Y);
if (rand.RandBit())
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); helper.Out.y = std::abs(helper.In.y);
@ -1252,29 +1223,19 @@ public:
helper.Out.x = helper.In.x; helper.Out.x = helper.In.x;
helper.Out.z = helper.In.z; helper.Out.z = helper.In.z;
if (m_VarType == eVariationType::VARTYPE_REG)
{
outPoint.m_X = 0;//All will be added.
outPoint.m_Y = 0;
outPoint.m_Z = 0;
} }
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
{ {
ostringstream ss; ostringstream ss;
ss << "\t{\n"; ss << "\t{\n"
if (m_VarType == eVariationType::VARTYPE_REG)
{
ss <<
"\t\tvOut.y = fabs(outPoint->m_Y);\n"
"\n"
"\t\tif (MwcNext(mwc) & 1)\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" "\t\tvOut.y = fabs(vIn.y);\n"
"\n" "\n"
"\t\tif (MwcNext(mwc) & 1)\n" "\t\tif (MwcNext(mwc) & 1)\n"
@ -1282,6 +1243,13 @@ public:
"\n" "\n"
"\t\tvOut.x = vIn.x;\n" "\t\tvOut.x = vIn.x;\n"
"\t\tvOut.z = vIn.z;\n"; "\t\tvOut.z = vIn.z;\n";
if (m_VarType == eVariationType::VARTYPE_REG)
{
ss <<
"\t\toutPoint->m_X = 0;\n"
"\t\toutPoint->m_Y = 0;\n"
"\t\toutPoint->m_Z = 0;\n";
} }
ss << "\t}\n"; ss << "\t}\n";
@ -1302,19 +1270,6 @@ public:
VARCOPY(MirrorZVariation) VARCOPY(MirrorZVariation)
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
{
if (m_VarType == eVariationType::VARTYPE_REG)
{
helper.Out.z = std::abs(outPoint.m_Z);
if (rand.RandBit())
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); helper.Out.z = std::abs(helper.In.z);
@ -1323,29 +1278,19 @@ public:
helper.Out.x = helper.In.x; helper.Out.x = helper.In.x;
helper.Out.y = helper.In.y; helper.Out.y = helper.In.y;
if (m_VarType == eVariationType::VARTYPE_REG)
{
outPoint.m_X = 0;//All will be added.
outPoint.m_Y = 0;
outPoint.m_Z = 0;
} }
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
{ {
ostringstream ss; ostringstream ss;
ss << "\t{\n"; ss << "\t{\n"
if (m_VarType == eVariationType::VARTYPE_REG)
{
ss <<
"\t\tvOut.z = fabs(outPoint->m_Z);\n"
"\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";
}
else
{
ss <<
"\t\tvOut.z = fabs(vIn.z);\n" "\t\tvOut.z = fabs(vIn.z);\n"
"\n" "\n"
"\t\tif (MwcNext(mwc) & 1)\n" "\t\tif (MwcNext(mwc) & 1)\n"
@ -1353,6 +1298,13 @@ public:
"\n" "\n"
"\t\tvOut.x = vIn.x;\n" "\t\tvOut.x = vIn.x;\n"
"\t\tvOut.y = vIn.y;\n"; "\t\tvOut.y = vIn.y;\n";
if (m_VarType == eVariationType::VARTYPE_REG)
{
ss <<
"\t\toutPoint->m_X = 0;\n"
"\t\toutPoint->m_Y = 0;\n"
"\t\toutPoint->m_Z = 0;\n";
} }
ss << "\t}\n"; ss << "\t}\n";

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);