mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 21:20:07 -05:00
Merged mfeemster/fractorium into master
This commit is contained in:
commit
f852f935a5
@ -4515,9 +4515,7 @@ public:
|
||||
T b = helper.In.y - m_Cy;
|
||||
T c = 1 - m_Cx * helper.In.x - m_Cy * helper.In.y;
|
||||
T d = m_Cy * helper.In.x - m_Cx * helper.In.y;
|
||||
|
||||
T num = m_Weight / Zeps(c * c + d * d);
|
||||
|
||||
helper.Out.x = (a * c + b * d) * num;
|
||||
helper.Out.y = (b * c - a * d) * num;
|
||||
helper.Out.z = DefaultZ(helper);
|
||||
@ -4534,16 +4532,15 @@ public:
|
||||
string cQ = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cX = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string cY = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t a = vIn.x - " << cX << ";\n"
|
||||
<< "\t\treal_t b = vIn.y - " << cY << ";\n"
|
||||
<< "\t\treal_t c = 1 - " << cX << " * vIn.x - " << cY << " * vIn.y;\n"
|
||||
<< "\t\treal_t d = " << cY <<" * vIn.x - " << cX << " * vIn.y;\n"
|
||||
<< "\t\treal_t num = " << weight <<" / Zeps(c * c + d * d);\n"
|
||||
<< "\t\treal_t d = fma(" << cY << ", vIn.x, -(" << cX << " * vIn.y));\n"
|
||||
<< "\t\treal_t num = " << weight << " / Zeps(fma(c, c, d * d));\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = (a * c + b * d) * num;\n"
|
||||
<< "\t\tvOut.y = (b * c - a * d) * num;\n"
|
||||
<< "\t\tvOut.x = fma(a, c, b * d) * num;\n"
|
||||
<< "\t\tvOut.y = fma(b, c, -(a * d)) * num;\n"
|
||||
<< "\t\tvOut.z = " << DefaultZCl()
|
||||
<< "\t}\n";
|
||||
return ss.str();
|
||||
|
@ -1108,7 +1108,7 @@ public:
|
||||
T temp, x = helper.In.x / m_Width;
|
||||
bool pos = x > 0;
|
||||
|
||||
if (std::cos((pos ? x - (int)x : x + (int)x) * M_PI) < rand.Frand01<T>() * 2 - 1)
|
||||
if (std::cos((pos ? x - (int)x : x + (int)x) * T(M_PI)) < rand.Frand01<T>() * 2 - 1)
|
||||
temp = pos ? -m_Vwidth : m_Vwidth;
|
||||
else
|
||||
temp = 0;
|
||||
@ -4280,11 +4280,11 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
v2T z1(helper.In.x, helper.In.y);
|
||||
v2T z = VarFuncs<T>::RealDivComplex(1.0, z1);
|
||||
v2T result = VarFuncs<T>::ComplexMultReal(VarFuncs<T>::ComplexLog(VarFuncs<T>::ComplexPlusComplex(z, VarFuncs<T>::ComplexMultComplex(VarFuncs<T>::ComplexSqrt(VarFuncs<T>::ComplexPlusReal(z, 1.0)), VarFuncs<T>::ComplexSqrt(VarFuncs<T>::ComplexMinusReal(z, 1.0))))), m_WeightInvPi);
|
||||
helper.Out.x = result.x;
|
||||
helper.Out.y = result.y;
|
||||
std::complex<T> z(helper.In.x, helper.In.y);
|
||||
z = T(1.0) / z;
|
||||
std::complex<T> result = m_WeightInvPi * std::log(z + std::sqrt(z + T(1.0)) * std::sqrt(z - T(1.0)));
|
||||
helper.Out.x = result.real();
|
||||
helper.Out.y = result.imag();
|
||||
helper.Out.z = DefaultZ(helper);
|
||||
}
|
||||
|
||||
@ -4347,19 +4347,19 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
v2T z1(helper.In.x, helper.In.y);
|
||||
v2T z = VarFuncs<T>::RealDivComplex(1.0, z1);
|
||||
v2T result = VarFuncs<T>::ComplexMultReal(VarFuncs<T>::ComplexLog(VarFuncs<T>::ComplexPlusComplex(z, VarFuncs<T>::ComplexMultComplex(VarFuncs<T>::ComplexSqrt(VarFuncs<T>::ComplexPlusReal(z, 1.0)), VarFuncs<T>::ComplexSqrt(VarFuncs<T>::ComplexMinusReal(z, 1.0))))), m_WeightInvPi);
|
||||
std::complex<T> z(helper.In.x, helper.In.y);
|
||||
z = T(1.0) / z;
|
||||
std::complex<T> result = m_WeightInvPi * std::log(z + std::sqrt(z + T(1.0)) * std::sqrt(z - T(1.0)));
|
||||
|
||||
if (result.y < 0)
|
||||
if (result.imag() < 0)
|
||||
{
|
||||
helper.Out.x = result.x;
|
||||
helper.Out.y = result.y + 1;
|
||||
helper.Out.x = result.real();
|
||||
helper.Out.y = result.imag() + T(1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
helper.Out.x = -result.x;
|
||||
helper.Out.y = result.y - 1;
|
||||
helper.Out.x = -result.real();
|
||||
helper.Out.y = result.imag() - T(1.0);
|
||||
}
|
||||
|
||||
helper.Out.z = DefaultZ(helper);
|
||||
@ -4433,10 +4433,10 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
v2T z(helper.In.x, helper.In.y);
|
||||
v2T result = VarFuncs<T>::ComplexMultReal(VarFuncs<T>::ComplexLog(VarFuncs<T>::ComplexPlusComplex(z, VarFuncs<T>::ComplexSqrt(VarFuncs<T>::ComplexPlusReal(VarFuncs<T>::ComplexMultComplex(z, z), 1.0)))), m_WeightInvPi);
|
||||
helper.Out.x = result.x;
|
||||
helper.Out.y = result.y;
|
||||
std::complex<T> z(helper.In.x, helper.In.y);
|
||||
std::complex<T> result = m_WeightInvPi * std::log(z + std::sqrt(z * z + T(1.0)));
|
||||
helper.Out.x = result.real();
|
||||
helper.Out.y = result.imag();
|
||||
helper.Out.z = DefaultZ(helper);
|
||||
}
|
||||
|
||||
@ -4497,11 +4497,10 @@ public:
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
v2T z(helper.In.x, helper.In.y);
|
||||
v2T zm(-helper.In.x, -helper.In.y);
|
||||
v2T result = VarFuncs<T>::ComplexMultReal(VarFuncs<T>::ComplexLog(VarFuncs<T>::ComplexDivComplex(VarFuncs<T>::ComplexPlusReal(z, 1.0), VarFuncs<T>::ComplexPlusReal(zm, 1.0))), m_WeightInvPi);
|
||||
helper.Out.x = result.x;
|
||||
helper.Out.y = result.y;
|
||||
std::complex<T> z(helper.In.x, helper.In.y);
|
||||
std::complex<T> result = m_WeightInvPi * std::log((z + T(1.0)) / (-z + T(1.0)));
|
||||
helper.Out.x = result.real();
|
||||
helper.Out.y = result.imag();
|
||||
helper.Out.z = DefaultZ(helper);
|
||||
}
|
||||
|
||||
@ -7096,7 +7095,6 @@ public:
|
||||
T Cx, Cy;
|
||||
T Lx, Ly;
|
||||
T r, theta, s, c;
|
||||
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
@ -7104,7 +7102,6 @@ public:
|
||||
{
|
||||
Cx = (Floor<T>(Vx / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize;
|
||||
Cy = (Floor<T>(Vy / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize;
|
||||
|
||||
Lx = Vx - Cx;
|
||||
Ly = Vy - Cy;
|
||||
|
||||
@ -7118,8 +7115,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
helper.Out.x += m_Weight * Vx;
|
||||
helper.Out.y += m_Weight * Vy;
|
||||
helper.Out.x = m_Weight * Vx;
|
||||
helper.Out.y = m_Weight * Vy;
|
||||
helper.Out.z = DefaultZ(helper);
|
||||
}
|
||||
|
||||
@ -7134,7 +7131,7 @@ public:
|
||||
string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string r2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t Vx, Vy, Cx, Cy, Lx, Ly;\n"
|
||||
<< "\t\treal_t Vx, Vy, Cx, Cy, Lx, Ly, Lxy;\n"
|
||||
<< "\t\treal_t r, theta, s, c;\n"
|
||||
<< "\n"
|
||||
<< "\t\tVx = vIn.x;\n"
|
||||
@ -7147,10 +7144,11 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\t\tLx = Vx - Cx;\n"
|
||||
<< "\t\t\tLy = Vy - Cy;\n"
|
||||
<< "\t\t\tLxy = fma(Lx, Lx, Ly * Ly);\n"
|
||||
<< "\n"
|
||||
<< "\t\t\tif ((Lx * Lx + Ly * Ly) <= " << r2 << ")\n"
|
||||
<< "\t\t\tif (Lxy <= " << r2 << ")\n"
|
||||
<< "\t\t\t{\n"
|
||||
<< "\t\t\t\tr = (Lx * Lx + Ly * Ly) / " << r2 << ";\n"
|
||||
<< "\t\t\t\tr = Lxy / " << r2 << ";\n"
|
||||
<< "\t\t\t\ttheta = " << twist << " * log(r);\n"
|
||||
<< "\t\t\t\ts = sin(theta);\n"
|
||||
<< "\t\t\t\tc = cos(theta);\n"
|
||||
@ -7159,8 +7157,8 @@ public:
|
||||
<< "\t\t\t}\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x += " << weight << " * Vx;\n"
|
||||
<< "\t\tvOut.y += " << weight << " * Vy;\n"
|
||||
<< "\t\tvOut.x = " << weight << " * Vx;\n"
|
||||
<< "\t\tvOut.y = " << weight << " * Vy;\n"
|
||||
<< "\t\tvOut.z = " << DefaultZCl()
|
||||
<< "\t}\n";
|
||||
return ss.str();
|
||||
@ -7169,7 +7167,7 @@ public:
|
||||
virtual void Precalc() override
|
||||
{
|
||||
T radius = T(0.5) * m_GnarlyCellSize;
|
||||
m_R2 = Zeps(radius * radius);
|
||||
m_R2 = Zeps(SQR(radius));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -961,7 +961,9 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
|
||||
}
|
||||
else if (parvar)
|
||||
{
|
||||
if (!StartsWith(paramstr, prefix))
|
||||
paramstr = prefix + paramstr;
|
||||
|
||||
parvar->SetParamVal(paramstr.c_str(), val);
|
||||
//if (!parvar->SetParamVal(paramstr.c_str(), val))
|
||||
// AddToReport(string(loc) + " : Failed to set parametric variation parameter " + paramstr);
|
||||
|
@ -20,7 +20,6 @@ CurvesGraphicsView::CurvesGraphicsView(QWidget* parent)
|
||||
m_GPen.setWidth(2);
|
||||
m_BPen.setWidth(2);
|
||||
setScene(&m_Scene);
|
||||
SetTop(CurveIndex::ALL);
|
||||
//qDebug() << "Original scene rect before setting anything is: " << sceneRect();
|
||||
m_OriginalRect = sceneRect();
|
||||
Curves<float> curves(true);
|
||||
@ -30,17 +29,20 @@ CurvesGraphicsView::CurvesGraphicsView(QWidget* parent)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the position of a given point within a given curve.
|
||||
/// Called when an underlying point has had its position changed, so emit a signal so that a listener can take action.
|
||||
/// </summary>
|
||||
/// <param name="curveIndex">The curve whose point value will be retrieved, 0-3.</param>
|
||||
/// <param name="pointIndex">The point within the curve value will be retrieved, 1-2.</param>
|
||||
/// <param name="curveIndex">The curve whose point value was changed, 0-3.</param>
|
||||
/// <param name="pointIndex">The point within the curve whose point value was changed.</param>
|
||||
/// <param name="point">The position of the point. X,Y will each be within 0-1.</param>
|
||||
void CurvesGraphicsView::PointChanged(int curveIndex, int pointIndex, const QPointF& point)
|
||||
{
|
||||
if (curveIndex == m_Index)
|
||||
{
|
||||
double x = point.x() / width();
|
||||
double y = (height() - point.y()) / height();
|
||||
emit PointChangedSignal(curveIndex, pointIndex, QPointF(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the position of a given point within a given curve.
|
||||
@ -105,6 +107,7 @@ void CurvesGraphicsView::Set(Curves<float>& curves)
|
||||
createpoints(1, m_RedP, Qt::GlobalColor::red, 1);
|
||||
createpoints(2, m_GrnP, Qt::GlobalColor::green, 1);
|
||||
createpoints(3, m_BluP, Qt::GlobalColor::blue, 1);
|
||||
SetTop(CurveIndex(m_Index));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -135,16 +138,10 @@ void CurvesGraphicsView::SetTop(CurveIndex curveIndex)
|
||||
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
{
|
||||
if (i == m_Index)
|
||||
{
|
||||
bool b = (i == m_Index);
|
||||
|
||||
for (auto& p : m_Points[i])
|
||||
p->setZValue(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& p : m_Points[i])
|
||||
p->setZValue(1);
|
||||
}
|
||||
p->SetCurrent(b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,7 +234,7 @@ void CurvesGraphicsView::mousePressEvent(QMouseEvent* e)
|
||||
return -1;
|
||||
};
|
||||
|
||||
if (e->button() == Qt::RightButton)//Right button does whole image rotation and scaling.
|
||||
if (e->button() == Qt::RightButton)
|
||||
{
|
||||
int i = findpoint(e->pos().x(), e->pos().y());
|
||||
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
void Set(int curveIndex, int pointIndex, const QPointF& point);
|
||||
void Set(Curves<float>& curves);
|
||||
void SetTop(CurveIndex curveIndex);
|
||||
size_t SelectedCurveIndex() const { return m_Index; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void PointChangedSignal(int curveIndex, int pointIndex, const QPointF& point);
|
||||
@ -87,13 +88,23 @@ public:
|
||||
EllipseItem(const QRectF& rect, int curveIndex, int pointIndex, CurvesGraphicsView* viewParent, QGraphicsItem* parent = nullptr)
|
||||
: QGraphicsEllipseItem(rect, parent)
|
||||
{
|
||||
m_CurveIndex = curveIndex;
|
||||
m_PointIndex = pointIndex;
|
||||
m_ViewParent = viewParent;
|
||||
setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable);
|
||||
setFlag(QGraphicsItem::ItemIsMovable);
|
||||
setPen(Qt::NoPen);
|
||||
m_CurveIndex = curveIndex;
|
||||
m_PointIndex = pointIndex;
|
||||
m_ViewParent = viewParent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether this item is selectable, which means this curve is the current one.
|
||||
/// </summary>
|
||||
/// <param name="b">True if selected, else false.</param>
|
||||
void SetCurrent(bool b)
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemIsMovable, b);
|
||||
setZValue(b ? 2 : 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -125,7 +136,7 @@ protected:
|
||||
/// <returns>The new position</returns>
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value) override
|
||||
{
|
||||
if (change == ItemPositionChange && scene())
|
||||
if ((change == ItemPositionChange) && scene())
|
||||
{
|
||||
//Value is the new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
|
@ -19,9 +19,11 @@ namespace apoconv
|
||||
{ "(float)", "" },
|
||||
{ "double", "T" },
|
||||
{ "float", "T" },
|
||||
{ "Complex", "std::complex<T>" },
|
||||
//{ "0.0", "0" },
|
||||
{ "0.5", "T(0.5)" },
|
||||
{ "1.0", "T(1.0)" },
|
||||
{ "2.0", "T(2.0)" },
|
||||
{ "0.1", "T(0.1)" },
|
||||
{ "0.01", "T(0.01)" },
|
||||
{ "0.001", "T(0.001)" },
|
||||
@ -56,6 +58,7 @@ namespace apoconv
|
||||
{ "sqrt(", "std::sqrt(" },
|
||||
{ "pow(", "std::pow(" },
|
||||
{ "fabs(", "std::abs(" },
|
||||
{ "log(", "std::log(" },
|
||||
|
||||
{ "sqr(", "Sqr(" },
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user