protected override ValueType CheckInputsAndGetType(ValueType[] inTypes) { ValueType input = inTypes[0]; ValueTypeConfig config = ValueTypeConfig.Types[(int)input]; if (!config.IsValue) { return(ValueType.Error); } int[] comps = ValidateSwizzle(ref Components, GetComponentsCount(input) - 1); if (comps.Length > 0) { _comp0 = comps[0]; } if (comps.Length > 1) { _comp1 = comps[1]; } if (comps.Length > 2) { _comp2 = comps[2]; } if (comps.Length > 3) { _comp3 = comps[3]; } bool siColor = IsColor(Components); return(GetOutType(comps.Length, siColor)); }
public override void InitializeNodeProcessor(NodeProcessor processor) { GeneratedOperationInitializer(_Type); int inputsCount = OperationConfigs[(int)_Type].InputCount; if (inputsCount == 2) { ValueTypeConfig a = ValueTypeConfig.Types[(int)Parent.GetNode(Inputs[0]).CashedOutputType]; ValueTypeConfig b = ValueTypeConfig.Types[(int)Parent.GetNode(Inputs[1]).CashedOutputType]; GeneratedProcessorInitializerTwoInput(processor, a, b); } else { GeneratedProcessorInitializerOneInput(processor); } }
void GeneratedProcessorInitializerTwoInput(NodeProcessor processor, ValueTypeConfig aConfig, ValueTypeConfig bConfig) { if (aConfig.IsVector && bConfig.IsVector) { processor.Vector2Out = () => { Vector2 in0 = processor.Inputs[0].Vector2Out(); Vector2 in1 = processor.Inputs[1].Vector2Out(); return(new Vector2(OperationTwoInput(in0.x, in1.x), OperationTwoInput(in0.y, in1.y))); }; processor.Vector3Out = () => { Vector3 in0 = processor.Inputs[0].Vector3Out(); Vector3 in1 = processor.Inputs[1].Vector3Out(); return(new Vector3(OperationTwoInput(in0.x, in1.x), OperationTwoInput(in0.y, in1.y), OperationTwoInput(in0.z, in1.z))); }; processor.Vector4Out = () => { Vector4 in0 = processor.Inputs[0].Vector4Out(); Vector4 in1 = processor.Inputs[1].Vector4Out(); return(new Vector4(OperationTwoInput(in0.x, in1.x), OperationTwoInput(in0.y, in1.y), OperationTwoInput(in0.z, in1.z), OperationTwoInput(in0.w, in1.w))); }; processor.ColorOut = () => { Color in0 = processor.Inputs[0].ColorOut(); Color in1 = processor.Inputs[1].ColorOut(); return(new Color(OperationTwoInput(in0.r, in1.r), OperationTwoInput(in0.g, in1.g), OperationTwoInput(in0.b, in1.b), OperationTwoInput(in0.a, in1.a))); }; } else if (aConfig.IsVector && !bConfig.IsVector) { if (bConfig.ValueType == ValueType.Float) { processor.Vector2Out = () => { Vector2 in0 = processor.Inputs[0].Vector2Out(); float in1 = processor.Inputs[1].FloatOut(); return(new Vector2(OperationTwoInput(in0.x, in1), OperationTwoInput(in0.y, in1))); }; processor.Vector3Out = () => { Vector3 in0 = processor.Inputs[0].Vector3Out(); float in1 = processor.Inputs[1].FloatOut(); return(new Vector3(OperationTwoInput(in0.x, in1), OperationTwoInput(in0.y, in1), OperationTwoInput(in0.z, in1))); }; processor.Vector4Out = () => { Vector4 in0 = processor.Inputs[0].Vector4Out(); float in1 = processor.Inputs[1].FloatOut(); return(new Vector4(OperationTwoInput(in0.x, in1), OperationTwoInput(in0.y, in1), OperationTwoInput(in0.z, in1), OperationTwoInput(in0.w, in1))); }; processor.ColorOut = () => { Color in0 = processor.Inputs[0].ColorOut(); float in1 = processor.Inputs[1].FloatOut(); return(new Color(OperationTwoInput(in0.r, in1), OperationTwoInput(in0.g, in1), OperationTwoInput(in0.b, in1), OperationTwoInput(in0.a, in1))); }; } else { processor.Vector2Out = () => { Vector2 in0 = processor.Inputs[0].Vector2Out(); int in1 = processor.Inputs[1].IntOut(); return(new Vector2(OperationTwoInput(in0.x, in1), OperationTwoInput(in0.y, in1))); }; processor.Vector3Out = () => { Vector3 in0 = processor.Inputs[0].Vector3Out(); int in1 = processor.Inputs[1].IntOut(); return(new Vector3(OperationTwoInput(in0.x, in1), OperationTwoInput(in0.y, in1), OperationTwoInput(in0.z, in1))); }; processor.Vector4Out = () => { Vector4 in0 = processor.Inputs[0].Vector4Out(); int in1 = processor.Inputs[1].IntOut(); return(new Vector4(OperationTwoInput(in0.x, in1), OperationTwoInput(in0.y, in1), OperationTwoInput(in0.z, in1), OperationTwoInput(in0.w, in1))); }; processor.ColorOut = () => { Color in0 = processor.Inputs[0].ColorOut(); int in1 = processor.Inputs[1].IntOut(); return(new Color(OperationTwoInput(in0.r, in1), OperationTwoInput(in0.g, in1), OperationTwoInput(in0.b, in1), OperationTwoInput(in0.a, in1))); }; } } else if (!aConfig.IsVector && bConfig.IsVector) { if (aConfig.ValueType == ValueType.Float) { processor.Vector2Out = () => { float in0 = processor.Inputs[0].FloatOut(); Vector2 in1 = processor.Inputs[1].Vector2Out(); return(new Vector2(OperationTwoInput(in0, in1.x), OperationTwoInput(in0, in1.y))); }; processor.Vector3Out = () => { float in0 = processor.Inputs[0].FloatOut(); Vector3 in1 = processor.Inputs[1].Vector3Out(); return(new Vector3(OperationTwoInput(in0, in1.x), OperationTwoInput(in0, in1.y), OperationTwoInput(in0, in1.z))); }; processor.Vector4Out = () => { float in0 = processor.Inputs[0].FloatOut(); Vector4 in1 = processor.Inputs[1].Vector4Out(); return(new Vector4(OperationTwoInput(in0, in1.x), OperationTwoInput(in0, in1.y), OperationTwoInput(in0, in1.z), OperationTwoInput(in0, in1.w))); }; processor.ColorOut = () => { float in0 = processor.Inputs[0].FloatOut(); Color in1 = processor.Inputs[1].ColorOut(); return(new Color(OperationTwoInput(in0, in1.r), OperationTwoInput(in0, in1.g), OperationTwoInput(in0, in1.b), OperationTwoInput(in0, in1.a))); }; } else { processor.Vector2Out = () => { int in0 = processor.Inputs[0].IntOut(); Vector2 in1 = processor.Inputs[1].Vector2Out(); return(new Vector2(OperationTwoInput(in0, in1.x), OperationTwoInput(in0, in1.y))); }; processor.Vector3Out = () => { int in0 = processor.Inputs[0].IntOut(); Vector3 in1 = processor.Inputs[1].Vector3Out(); return(new Vector3(OperationTwoInput(in0, in1.x), OperationTwoInput(in0, in1.y), OperationTwoInput(in0, in1.z))); }; processor.Vector4Out = () => { int in0 = processor.Inputs[0].IntOut(); Vector4 in1 = processor.Inputs[1].Vector4Out(); return(new Vector4(OperationTwoInput(in0, in1.x), OperationTwoInput(in0, in1.y), OperationTwoInput(in0, in1.z), OperationTwoInput(in0, in1.w))); }; processor.ColorOut = () => { int in0 = processor.Inputs[0].IntOut(); Color in1 = processor.Inputs[1].ColorOut(); return(new Color(OperationTwoInput(in0, in1.r), OperationTwoInput(in0, in1.g), OperationTwoInput(in0, in1.b), OperationTwoInput(in0, in1.a))); }; } } else if (!aConfig.IsVector && !bConfig.IsVector) { if (aConfig.ValueType == ValueType.Float) { if (bConfig.ValueType == ValueType.Float) { processor.FloatOut = () => { float in0 = processor.Inputs[0].FloatOut(); float in1 = processor.Inputs[1].FloatOut(); return(OperationTwoInput(in0, in1)); }; } else { processor.FloatOut = () => { float in0 = processor.Inputs[0].FloatOut(); int in1 = processor.Inputs[1].IntOut(); return(OperationTwoInput(in0, in1)); }; } } else { if (bConfig.ValueType == ValueType.Float) { processor.FloatOut = () => { int in0 = processor.Inputs[0].IntOut(); float in1 = processor.Inputs[1].FloatOut(); return(OperationTwoInput(in0, in1)); }; } else { processor.IntOut = () => { int in0 = processor.Inputs[0].IntOut(); int in1 = processor.Inputs[1].IntOut(); return(OperationTwoInputInt(in0, in1)); }; } } } }