Exemple #1
0
        public override void TryAndProcess()
        {
            if (!input.IsValid || !input2.IsValid || !input3.IsValid)
            {
                return;
            }

            NodeType t = input.Reference.Type;

            try
            {
                if (t == NodeType.Float2 || t == NodeType.Float3 || t == NodeType.Float4)
                {
                    MVector min = (MVector)input2.Data;
                    MVector max = (MVector)input3.Data;
                    MVector v   = (MVector)input.Data;

                    output.Data = v.Clamp(min, max);
                }
                else if (t == NodeType.Float)
                {
                    float min = input2.Data.ToFloat();
                    float max = input3.Data.ToFloat();
                    float v   = input.Data.ToFloat();

                    output.Data = Math.Min(max, Math.Max(min, v));
                }

                result = output.Data?.ToString();
            }
            catch (Exception e)
            {
            }

            UpdateOutputType();
        }