multiple files can be open at the same time
This commit is contained in:
@@ -366,19 +366,45 @@ public:
|
||||
/// Outputs the world-space X coordinate of the cell being evaluated.
|
||||
class PositionXNode : public Node {
|
||||
public:
|
||||
Type GetOutputType() const override { return Type::Int; }
|
||||
Type GetOutputType() const override { return Type::Float; }
|
||||
std::vector<Type> GetInputTypes() const override { return {}; }
|
||||
std::string GetName() const override { return "PositionX"; }
|
||||
Value Evaluate(const EvalContext& ctx, const std::vector<Value>&) const override { return Value::MakeInt(ctx.worldX); };
|
||||
Value Evaluate(const EvalContext& ctx, const std::vector<Value>&) const override { return Value::MakeFloat(ctx.worldX); };
|
||||
};
|
||||
|
||||
/// Outputs the world-space Y coordinate of the cell being evaluated.
|
||||
class PositionYNode : public Node {
|
||||
public:
|
||||
Type GetOutputType() const override { return Type::Int; }
|
||||
Type GetOutputType() const override { return Type::Float; }
|
||||
std::vector<Type> GetInputTypes() const override { return {}; }
|
||||
std::string GetName() const override { return "PositionY"; }
|
||||
Value Evaluate(const EvalContext& ctx, const std::vector<Value>&) const override { return Value::MakeInt(ctx.worldY); };
|
||||
Value Evaluate(const EvalContext& ctx, const std::vector<Value>&) const override { return Value::MakeFloat(ctx.worldY); };
|
||||
};
|
||||
|
||||
// ─────────────────────────────── Abs / Negate ────────────────────────────────
|
||||
|
||||
/// |a| (Float)
|
||||
class AbsNode : public Node {
|
||||
public:
|
||||
Type GetOutputType() const override { return Type::Float; }
|
||||
std::vector<Type> GetInputTypes() const override { return { Type::Float }; }
|
||||
std::string GetName() const override { return "Abs"; }
|
||||
Value Evaluate(const EvalContext&, const std::vector<Value>& in) const override {
|
||||
DEV_ASSERT(in.size() == 1);
|
||||
return Value::MakeFloat(std::abs(in[0].AsFloat()));
|
||||
}
|
||||
};
|
||||
|
||||
/// −a (Float)
|
||||
class NegateNode : public Node {
|
||||
public:
|
||||
Type GetOutputType() const override { return Type::Float; }
|
||||
std::vector<Type> GetInputTypes() const override { return { Type::Float }; }
|
||||
std::string GetName() const override { return "Negate"; }
|
||||
Value Evaluate(const EvalContext&, const std::vector<Value>& in) const override {
|
||||
DEV_ASSERT(in.size() == 1);
|
||||
return Value::MakeFloat(-in[0].AsFloat());
|
||||
}
|
||||
};
|
||||
|
||||
// ─────────────────────────────── Min / Max / Clamp ───────────────────────────
|
||||
@@ -419,6 +445,37 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// ─────────────────────────────── Map (range remap) ───────────────────────────
|
||||
|
||||
/// Remaps a value from [min0, max0] to [min1, max1].
|
||||
///
|
||||
/// inputs[0] value to remap (Float)
|
||||
///
|
||||
/// The four range endpoints are baked into the node at construction time.
|
||||
/// When min0 == max0 the output is min1 (avoids divide-by-zero).
|
||||
class MapNode : public Node {
|
||||
public:
|
||||
float min0 { 0.0f };
|
||||
float max0 { 1.0f };
|
||||
float min1 { 0.0f };
|
||||
float max1 { 1.0f };
|
||||
|
||||
MapNode() = default;
|
||||
MapNode(float mn0, float mx0, float mn1, float mx1)
|
||||
: min0(mn0), max0(mx0), min1(mn1), max1(mx1) {}
|
||||
|
||||
Type GetOutputType() const override { return Type::Float; }
|
||||
std::vector<Type> GetInputTypes() const override { return { Type::Float }; }
|
||||
std::string GetName() const override { return "Map"; }
|
||||
Value Evaluate(const EvalContext&, const std::vector<Value>& in) const override {
|
||||
DEV_ASSERT(in.size() == 1);
|
||||
float range0 = max0 - min0;
|
||||
if (range0 == 0.0f) return Value::MakeFloat(min1);
|
||||
float t = (in[0].AsFloat() - min0) / range0;
|
||||
return Value::MakeFloat(min1 + t * (max1 - min1));
|
||||
}
|
||||
};
|
||||
|
||||
// ─────────────────────────────── Int control flow ────────────────────────────
|
||||
|
||||
/// Selects between two integer inputs based on a boolean condition.
|
||||
|
||||
Reference in New Issue
Block a user