protected virtual bool UpdateSlots(List <VFXDataAnchorController> newAnchors, IEnumerable <VFXSlot> slotList, bool expanded, bool input) { VFXSlot[] slots = slotList.ToArray(); bool changed = false; foreach (VFXSlot slot in slots) { VFXDataAnchorController propController = GetPropertyController(slot, input); if (propController == null) { propController = AddDataAnchor(slot, input, !expanded); changed = true; } newAnchors.Add(propController); if (!VFXDataAnchorController.SlotShouldSkipFirstLevel(slot)) { changed |= UpdateSlots(newAnchors, slot.children, expanded && propController.expandedSelf, input); } else { VFXSlot firstSlot = slot.children.First(); changed |= UpdateSlots(newAnchors, firstSlot.children, expanded && propController.expandedSelf, input); } } return(changed); }
public override void OnEdgeFromOutputGoingToBeRemoved(VFXDataAnchorController myOutput, VFXDataAnchorController otherInput) { base.OnEdgeFromOutputGoingToBeRemoved(myOutput, otherInput); if (!parentController.isOutput) { infos.linkedSlots.RemoveAll(t => t.outputSlot == myOutput.model && t.inputSlot == otherInput.model); } }
public override VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController controller, VFXNodeUI node) { VFXContextDataAnchorController anchorController = controller as VFXContextDataAnchorController; VFXEditableDataAnchor anchor = VFXBlockDataAnchor.Create(anchorController, node); return(anchor); }
public static new VFXInputParameterDataAnchor Create(VFXDataAnchorController controller, VFXNodeUI node) { var anchor = new VFXInputParameterDataAnchor(controller.orientation, controller.direction, controller.portType, node); anchor.m_EdgeConnector = new EdgeConnector <VFXDataEdge>(anchor); anchor.controller = controller; anchor.AddManipulator(anchor.m_EdgeConnector); return(anchor); }
public void RemoveOperand(VFXDataAnchorController myInput) { var slotIndex = model.GetSlotIndex(myInput.model); if (slotIndex != -1) { RemoveOperand(slotIndex); } }
public override VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController controller, VFXNodeUI node) { if (controller.direction == Direction.Input) { return(VFXInputParameterDataAnchor.Create(controller, node)); } else { return(VFXOutputParameterDataAnchor.Create(controller, node)); } }
public bool CouldLink(VFXDataAnchorController myAnchor, VFXDataAnchorController otherAnchor, VFXDataAnchorController.CanLinkCache cache) { if (myAnchor.direction == Direction.Input) { return(CouldLinkMyInputTo(myAnchor, otherAnchor, cache)); } else { return(otherAnchor.sourceNode.CouldLinkMyInputTo(otherAnchor, myAnchor, cache)); } }
// TODO This is a workaround to avoid having a generic type for the anchor as generic types mess with USS. public static new VFXEditableDataAnchor Create(VFXDataAnchorController controller, VFXNodeUI node) { Profiler.BeginSample("VFXEditableDataAnchor.Create"); var anchor = new VFXEditableDataAnchor(controller.orientation, controller.direction, controller.portType, node); anchor.m_EdgeConnector = new VFXEdgeConnector(anchor); anchor.controller = controller; anchor.AddManipulator(anchor.m_EdgeConnector); Profiler.EndSample(); return(anchor); }
protected override bool CouldLinkMyInputTo(VFXDataAnchorController myInput, VFXDataAnchorController otherOutput, VFXDataAnchorController.CanLinkCache cache) { if (otherOutput.direction == myInput.direction) { return(false); } if (!myInput.CanLinkToNode(otherOutput.sourceNode, cache)) { return(false); } return(model.GetBestAffinityType(otherOutput.portType) != null); }
public virtual VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController controller, VFXNodeUI node) { if (controller.direction == Direction.Input) { VFXEditableDataAnchor anchor = VFXEditableDataAnchor.Create(controller, node); return(anchor); } else { return(VFXOutputDataAnchor.Create(controller, node)); } }
public VFXDataAnchorController GetPropertyController(VFXSlot slot, bool input) { VFXDataAnchorController result = null; if (input) { result = inputPorts.Cast <VFXDataAnchorController>().Where(t => t.model == slot).FirstOrDefault(); } else { result = outputPorts.Cast <VFXDataAnchorController>().Where(t => t.model == slot).FirstOrDefault(); } return(result); }
public virtual VFXParameter.NodeLinkedSlot CreateLinkTo(VFXDataAnchorController output) { var slotOutput = output != null ? output.model : null; var slotInput = model; sourceNode.WillCreateLink(ref slotInput, ref slotOutput); if (slotInput != null && slotOutput != null && slotInput.Link(slotOutput)) { return(new VFXParameter.NodeLinkedSlot() { inputSlot = slotInput, outputSlot = slotOutput }); } return(new VFXParameter.NodeLinkedSlot()); }
public virtual bool CanLink(VFXDataAnchorController controller, CanLinkCache cache = null) { if (controller.model != null) { if (model.CanLink(controller.model) && controller.model.CanLink(model)) { if (!CanLinkToNode(controller.sourceNode, cache)) { return(false); } return(true); } return(sourceNode.CouldLink(this, controller, cache)); } return(controller.CanLink(this, cache)); }
public override VFXParameter.NodeLinkedSlot CreateLinkTo(VFXDataAnchorController output) { var slotOutput = output != null ? output.model : null; VFXOperatorNumericCascadedUnified op = sourceNode.model; op.AddOperand(op.GetBestAffinityType(output.model.property.type)); var slotInput = op.GetInputSlot(op.GetNbInputSlots() - 1); if (slotInput != null && slotOutput != null && slotInput.Link(slotOutput)) { return(new VFXParameter.NodeLinkedSlot() { inputSlot = slotInput, outputSlot = slotOutput }); } return(new VFXParameter.NodeLinkedSlot()); }
public override bool CanLink(VFXDataAnchorController controller, CanLinkCache cache = null) { var op = (sourceNode as VFXCascadedOperatorController); if (op == null) { return(false); } if (controller is VFXUpcommingDataAnchorController) { return(false); } if (!CanLinkToNode(controller.sourceNode, cache)) { return(false); } return(op.model.GetBestAffinityType(controller.model.property.type) != null); }
protected override bool CouldLinkMyInputTo(VFXDataAnchorController myInput, VFXDataAnchorController otherOutput, VFXDataAnchorController.CanLinkCache cache) { if (!myInput.model.IsMasterSlot()) { return(false); } if (otherOutput.direction == myInput.direction) { return(false); } if (!myInput.CanLinkToNode(otherOutput.sourceNode, cache)) { return(false); } int inputIndex = model.GetSlotIndex(myInput.model); IVFXOperatorNumericUnifiedConstrained constraintInterface = model as IVFXOperatorNumericUnifiedConstrained; var bestAffinityType = model.GetBestAffinityType(otherOutput.portType); if (bestAffinityType == null) { return(false); } if (constraintInterface.slotIndicesThatCanBeScalar.Contains(inputIndex)) { if (VFXTypeUtility.GetComponentCount(otherOutput.model) != 0) // If it is a vector or float type, then conversion to float exists { return(true); } } return(model.GetBestAffinityType(otherOutput.portType) != null); }
protected virtual bool CouldLinkMyInputTo(VFXDataAnchorController myInput, VFXDataAnchorController otherOutput, VFXDataAnchorController.CanLinkCache cache) { return(false); }
public override void OnEdgeFromInputGoingToBeRemoved(VFXDataAnchorController myInput) { base.OnEdgeFromInputGoingToBeRemoved(myInput); if (parentController.isOutput) infos.linkedSlots.RemoveAll(t => t.inputSlot == myInput.model); }
void TransfertDataEdges() { m_SourceControllersWithBlocks = m_SourceControllers.Concat(m_SourceControllers.OfType <VFXContextController>().SelectMany(t => t.blockControllers)); // Search for links between with inputs in the selected part and the output in other parts of the graph. Dictionary <VFXDataAnchorController, List <VFXDataAnchorController> > traversingInEdges = new Dictionary <VFXDataAnchorController, List <VFXDataAnchorController> >(); foreach (var edge in m_SourceController.dataEdges.Where( t => { if (parameterNodeControllers.Contains(t.output.sourceNode)) { return(false); } var inputInControllers = m_SourceControllersWithBlocks.Contains(t.input.sourceNode); var outputInControllers = m_SourceControllersWithBlocks.Contains(t.output.sourceNode); return(inputInControllers && !outputInControllers); } )) { List <VFXDataAnchorController> outputs = null; if (!traversingInEdges.TryGetValue(edge.input, out outputs)) { outputs = new List <VFXDataAnchorController>(); traversingInEdges[edge.input] = outputs; } outputs.Add(edge.output); } var newSourceInputs = traversingInEdges.Keys.ToArray(); for (int i = 0; i < newSourceInputs.Length; ++i) { VFXParameter newTargetParameter = m_TargetController.AddVFXParameter(Vector2.zero, VFXLibrary.GetParameters().First(t => t.model.type == newSourceInputs[i].portType)); m_TargetController.LightApplyChanges(); VFXParameterController newTargetParamController = m_TargetController.GetParameterController(newTargetParameter); newTargetParamController.exposed = true; var outputs = traversingInEdges[newSourceInputs[i]]; var linkedParameter = outputs.FirstOrDefault(t => t.sourceNode is VFXParameterNodeController); if (linkedParameter != null) { newTargetParamController.exposedName = (linkedParameter.sourceNode as VFXParameterNodeController).parentController.exposedName; } else { newTargetParamController.exposedName = newSourceInputs[i].name; } //first the equivalent of sourceInput in the target VFXNodeController targetNode = null; Vector2 position; if (newSourceInputs[i].sourceNode is VFXBlockController) { var blockController = newSourceInputs[i].sourceNode as VFXBlockController; if (m_TargetBlocks != null) { targetNode = m_TargetBlocks[m_SourceBlockControllers.IndexOf(blockController)]; position = blockController.contextController.position; } else { var targetContext = m_TargetControllers[m_SourceControllers.IndexOf(blockController.contextController)] as VFXContextController; targetNode = targetContext.blockControllers[blockController.index]; position = blockController.contextController.position; } } else { targetNode = m_TargetControllers[m_SourceControllers.IndexOf(newSourceInputs[i].sourceNode)]; position = targetNode.position; } VFXDataAnchorController targetAnchor = targetNode.inputPorts.First(t => t.path == newSourceInputs[i].path); position.y += targetAnchor.model.owner.inputSlots.IndexOf(targetAnchor.model) * 32; VFXNodeController parameterNode = m_TargetController.AddVFXParameter(position - new Vector2(200, 0), newTargetParamController, null); // Link the parameternode and the input in the target m_TargetController.CreateLink(targetAnchor, parameterNode.outputPorts[0]); if (m_SourceSlotContainer is VFXOperator) { (m_SourceSlotContainer as VFXOperator).ResyncSlots(true); } else if (m_SourceSlotContainer is VFXSubgraphBlock) { VFXSubgraphBlock blk = (m_SourceSlotContainer as VFXSubgraphBlock); blk.RecreateCopy(); blk.ResyncSlots(true); } else if (m_SourceSlotContainer is VFXSubgraphContext) { VFXSubgraphContext ctx = (m_SourceSlotContainer as VFXSubgraphContext); ctx.RecreateCopy(); ctx.ResyncSlots(true); } m_SourceNodeController.ApplyChanges(); //Link all the outputs to the matching input of the subgraph foreach (var output in outputs) { m_SourceController.CreateLink(m_SourceNodeController.inputPorts.First(t => t.model == m_SourceSlotContainer.inputSlots.Last()), output); } } }
void TransfertOperatorOutputEdges() { var traversingOutEdges = new Dictionary <VFXDataAnchorController, List <VFXDataAnchorController> >(); foreach (var edge in m_SourceController.dataEdges.Where( t => { if (t.output.sourceNode is VFXParameterNodeController) { return(false); } var inputInControllers = m_SourceControllersWithBlocks.Contains(t.input.sourceNode); var outputInControllers = m_SourceControllersWithBlocks.Contains(t.output.sourceNode); return(!inputInControllers && outputInControllers); } )) { List <VFXDataAnchorController> inputs = null; if (!traversingOutEdges.TryGetValue(edge.output, out inputs)) { inputs = new List <VFXDataAnchorController>(); traversingOutEdges[edge.output] = inputs; } inputs.Add(edge.input); } var newSourceOutputs = traversingOutEdges.Keys.ToArray(); for (int i = 0; i < newSourceOutputs.Length; ++i) { VFXParameter newTargetParameter = m_TargetController.AddVFXParameter(Vector2.zero, VFXLibrary.GetParameters().First(t => t.model.type == newSourceOutputs[i].portType)); m_TargetController.LightApplyChanges(); VFXParameterController newTargetParamController = m_TargetController.GetParameterController(newTargetParameter); newTargetParamController.isOutput = true; var inputs = traversingOutEdges[newSourceOutputs[i]]; var linkedParameter = inputs.FirstOrDefault(t => t.sourceNode is VFXParameterNodeController); if (linkedParameter != null) { newTargetParamController.exposedName = (linkedParameter.sourceNode as VFXParameterNodeController).parentController.exposedName; } else { newTargetParamController.exposedName = newSourceOutputs[i].name; } //first the equivalent of sourceInput in the target VFXNodeController targetNode = null; if (newSourceOutputs[i].sourceNode is VFXBlockController) { var blockController = newSourceOutputs[i].sourceNode as VFXBlockController; if (m_TargetBlocks != null) { targetNode = m_TargetBlocks[m_SourceBlockControllers.IndexOf(blockController)]; } else { var targetContext = m_TargetControllers[m_SourceControllers.IndexOf(blockController.contextController)] as VFXContextController; targetNode = targetContext.blockControllers[blockController.index]; } } else { targetNode = m_TargetControllers[m_SourceControllers.IndexOf(newSourceOutputs[i].sourceNode)]; } VFXDataAnchorController targetAnchor = targetNode.outputPorts.FirstOrDefault(t => t.path == newSourceOutputs[i].path); if (targetAnchor != null) { VFXNodeController parameterNode = m_TargetController.AddVFXParameter(targetNode.position + new Vector2(400, 0), newTargetParamController, null); // Link the parameternode and the input in the target m_TargetController.CreateLink(parameterNode.inputPorts[0], targetAnchor); if (m_SourceSlotContainer is VFXOperator) { (m_SourceSlotContainer as VFXOperator).ResyncSlots(true); } m_SourceNodeController.ApplyChanges(); } //Link all the outputs to the matching input of the subgraph foreach (var input in inputs) { var port = m_SourceNodeController.outputPorts.FirstOrDefault(t => t.model == m_SourceSlotContainer.outputSlots.Last()); if (port != null) { m_SourceController.CreateLink(input, port); } } } }
public virtual void OnEdgeFromInputGoingToBeRemoved(VFXDataAnchorController myInput) { }
public override void OnEdgeFromInputGoingToBeRemoved(VFXDataAnchorController myInput) { base.OnEdgeFromInputGoingToBeRemoved(myInput); RemoveOperand(myInput); }
public virtual void OnEdgeFromOutputGoingToBeRemoved(VFXDataAnchorController myOutput, VFXDataAnchorController otherInput) { }
public override VFXDataAnchor InstantiateDataAnchor(VFXDataAnchorController controller, VFXNodeUI node) { return(VFXParameterDataAnchor.Create(controller, node)); }
// Provider internal VFXDataAnchorGizmoContext(VFXDataAnchorController controller) { m_Controller = controller; }
public void RemoveOperand(VFXDataAnchorController myInput) { RemoveOperand(model.GetSlotIndex(myInput.model)); }