Repository: FlaxEngine/FlaxEngine
File: Source/Engine/Visject/VisjectGraph.cpp (C++)

Code before:
    case 45:
        value = (uint64)tryGetValue(node->GetBox(0), Value::Zero);
        break;
        // Enum AND
    case 46:
        value = tryGetValue(node->GetBox(0), Value::Zero);
        if (value.Type.Type == VariantType::Enum)
            value.AsUint64 = value.AsUint64 & (uint64)tryGetValue(node->GetBox(1), Value::Zero);
        break;
        // Enum OR
    case 47:
        value = tryGetValue(node->GetBox(0), Value::Zero);
        if (value.Type.Type == VariantType::Enum)
            value.AsUint64 = value.AsUint64 | (uint64)tryGetValue(node->GetBox(1), Value::Zero);
        break;

    case 48:
    {
        const float inVal  = tryGetValue(node->GetBox(0), node->Values[0]).AsFloat;
        const Vector2 rangeA = tryGetValue(node->GetBox(1), node->Values[1]).AsVector2();
        const Vector2 rangeB = tryGetValue(node->GetBox(2), node->Values[2]).AsVector2();

        auto mapFunc = rangeB.X + (inVal - rangeA.X) * (rangeB.Y - rangeB.X) / (rangeA.Y - rangeA.X);
        
        // Clamp value?
        value = node->Values[3].AsBool ? Math::Clamp(mapFunc, rangeB.X, rangeB.Y) : mapFunc;
        break;
    }
    default:
        break;
    }
}

void VisjectExecutor::ProcessGroupPacking(Box* box, Node* node, Value& value)
{
    switch (node->TypeID)
    {
        // Pack
    case 20:
    {
        float vX = (float)tryGetValue(node->GetBox(1), node->Values[0]);
        float vY = (float)tryGetValue(node->GetBox(2), node->Values[1]);
        value = Vector2(vX, vY);
        break;
    }
    case 21:
    {
        float vX = (float)tryGetValue(node->GetBox(1), node->Values[0]);
        float vY = (float)tryGetValue(node->GetBox(2), node->Values[1]);
        float vZ = (float)tryGetValue(node->GetBox(3), node->Values[2]);
        value = Vector3(vX, vY, vZ);

Review comment (suggestion):
Instead of using `node->Values[3].AsBool` call `tryGetValue` like for other inputs to handle both default value and custom connected value.

Code after:
    case 45:
        value = (uint64)tryGetValue(node->GetBox(0), Value::Zero);
        break;
        // Enum AND
    case 46:
        value = tryGetValue(node->GetBox(0), Value::Zero);
        if (value.Type.Type == VariantType::Enum)
            value.AsUint64 = value.AsUint64 & (uint64)tryGetValue(node->GetBox(1), Value::Zero);
        break;
        // Enum OR
    case 47:
        value = tryGetValue(node->GetBox(0), Value::Zero);
        if (value.Type.Type == VariantType::Enum)
            value.AsUint64 = value.AsUint64 | (uint64)tryGetValue(node->GetBox(1), Value::Zero);
        break;
        // Remap
    case 48:
    {
        const float inVal  = tryGetValue(node->GetBox(0), node->Values[0]).AsFloat;
        const Vector2 rangeA = tryGetValue(node->GetBox(1), node->Values[1]).AsVector2();
        const Vector2 rangeB = tryGetValue(node->GetBox(2), node->Values[2]).AsVector2();
        const bool clamp = tryGetValue(node->GetBox(3), node->Values[3]).AsBool;

        auto mapFunc = rangeB.X + (inVal - rangeA.X) * (rangeB.Y - rangeB.X) / (rangeA.Y - rangeA.X);
        
        // Clamp value?
        value = clamp ? Math::Clamp(mapFunc, rangeB.X, rangeB.Y) : mapFunc;
        break;
    }
    default:
        break;
    }
}

void VisjectExecutor::ProcessGroupPacking(Box* box, Node* node, Value& value)
{
    switch (node->TypeID)
    {
        // Pack
    case 20:
    {
        float vX = (float)tryGetValue(node->GetBox(1), node->Values[0]);
        float vY = (float)tryGetValue(node->GetBox(2), node->Values[1]);
        value = Vector2(vX, vY);
        break;
    }
    case 21:
    {
        float vX = (float)tryGetValue(node->GetBox(1), node->Values[0]);
        float vY = (float)tryGetValue(node->GetBox(2), node->Values[1]);
        float vZ = (float)tryGetValue(node->GetBox(3), node->Values[2]);