Ejemplo n.º 1
0
        bool ProviderFilter(VFXNodeProvider.Descriptor d)
        {
            var mySlot = controller.model;
            var parameterDescriptor = d.modelDescriptor as VFXParameterController;
            IVFXSlotContainer container = null;
            if (parameterDescriptor != null)
            {
                container = parameterDescriptor.model;
            }
            else
            {
                VFXModelDescriptor desc = d.modelDescriptor as VFXModelDescriptor;
                if (desc == null)
                {
                    string path = d.modelDescriptor as string;

                    if (path != null && !path.StartsWith(VisualEffectAssetEditorUtility.templatePath))
                    {
                        if (Path.GetExtension(path) == VisualEffectSubgraphOperator.Extension)
                        {
                            var subGraph = AssetDatabase.LoadAssetAtPath<VisualEffectSubgraphOperator>(path);
                            if (subGraph != null && (!controller.viewController.model.isSubgraph || !subGraph.GetResource().GetOrCreateGraph().subgraphDependencies.Contains(controller.viewController.model.subgraph) && subGraph.GetResource() != controller.viewController.model))
                                return true;
                        }
                    }
                    return false;
                }

                container = desc.model as IVFXSlotContainer;
                if (container == null)
                    return false;

                if (direction == Direction.Output
                    &&  mySlot != null
                    && container is VFXOperatorDynamicOperand
                    && (container as VFXOperatorDynamicOperand).validTypes.Contains(mySlot.property.type))
                    return true;
            }

            IEnumerable<Type> validTypes = null;
            if (mySlot == null)
            {
                var op = controller.sourceNode.model as VFXOperatorDynamicOperand;
                if (op != null)
                    validTypes = op.validTypes;
            }

            var getSlots = direction == Direction.Input ? (System.Func<int, VFXSlot>)container.GetOutputSlot : (System.Func<int, VFXSlot>)container.GetInputSlot;
            int count = direction == Direction.Input ? container.GetNbOutputSlots() : container.GetNbInputSlots();
            for (int i = 0; i < count; ++i)
            {
                var slot = getSlots(i);
                if (mySlot != null && slot.CanLink(mySlot))
                    return true;
                else if (validTypes != null && validTypes.Contains(slot.property.type))
                    return true;
            }
            return false;
        }
Ejemplo n.º 2
0
        static VFXSlot FetchSlot(IVFXSlotContainer container, int[] slotPath, bool input)
        {
            int containerSlotIndex = slotPath[slotPath.Length - 1];

            VFXSlot slot = null;

            if (input)
            {
                if (container.GetNbInputSlots() > containerSlotIndex)
                {
                    slot = container.GetInputSlot(slotPath[slotPath.Length - 1]);
                }
            }
            else
            {
                if (container.GetNbOutputSlots() > containerSlotIndex)
                {
                    slot = container.GetOutputSlot(slotPath[slotPath.Length - 1]);
                }
            }
            if (slot == null)
            {
                return(null);
            }

            for (int i = slotPath.Length - 2; i >= 0; --i)
            {
                if (slot.GetNbChildren() > slotPath[i])
                {
                    slot = slot[slotPath[i]];
                }
                else
                {
                    return(null);
                }
            }

            return(slot);
        }
Ejemplo n.º 3
0
        bool ProviderFilter(VFXNodeProvider.Descriptor d)
        {
            var mySlot = controller.model;
            var parameterDescriptor     = d.modelDescriptor as VFXParameterController;
            IVFXSlotContainer container = null;

            if (parameterDescriptor != null)
            {
                container = parameterDescriptor.model;
            }
            else
            {
                VFXModelDescriptor desc = d.modelDescriptor as VFXModelDescriptor;
                if (desc == null)
                {
                    string path = d.modelDescriptor as string;

                    if (path != null && !path.StartsWith(VisualEffectAssetEditorUtility.templatePath))
                    {
                        if (Path.GetExtension(path) == VisualEffectSubgraphOperator.Extension)
                        {
                            var subGraph = AssetDatabase.LoadAssetAtPath <VisualEffectSubgraphOperator>(path);
                            if (subGraph != null && (!controller.viewController.model.isSubgraph || !subGraph.GetResource().GetOrCreateGraph().subgraphDependencies.Contains(controller.viewController.model.subgraph) && subGraph.GetResource() != controller.viewController.model))
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                }

                container = desc.model as IVFXSlotContainer;
                if (container == null)
                {
                    return(false);
                }

                if (direction == Direction.Output &&
                    mySlot != null &&
                    container is VFXOperatorDynamicOperand &&
                    (container as VFXOperatorDynamicOperand).validTypes.Contains(mySlot.property.type))
                {
                    return(true);
                }
            }

            IEnumerable <Type> validTypes = null;

            if (mySlot == null)
            {
                var op = controller.sourceNode.model as VFXOperatorDynamicOperand;
                if (op != null)
                {
                    validTypes = op.validTypes;
                }
            }

            var getSlots = direction == Direction.Input ? container.GetOutputSlot : (System.Func <int, VFXSlot>)container.GetInputSlot;
            var count    = direction == Direction.Input ? container.GetNbOutputSlots() : container.GetNbInputSlots();

            // Template containers are not sync initially to save time during loading
            // For container with no input or output this can be called everytime, but should also be very fast
            if (count == 0)
            {
                container.ResyncSlots(false);
                count = direction == Direction.Input ? container.GetNbOutputSlots() : container.GetNbInputSlots();
            }

            for (int i = 0; i < count; ++i)
            {
                var slot = getSlots(i);
                if (mySlot != null && slot.CanLink(mySlot))
                {
                    return(true);
                }
                else if (validTypes != null && validTypes.Contains(slot.property.type))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        bool ProviderFilter(VFXNodeProvider.Descriptor d)
        {
            var mySlot = controller.model;
            var parameterDescriptor     = d.modelDescriptor as VFXParameterController;
            IVFXSlotContainer container = null;

            if (parameterDescriptor != null)
            {
                container = parameterDescriptor.model;
            }
            else
            {
                VFXModelDescriptor desc = d.modelDescriptor as VFXModelDescriptor;
                if (desc == null)
                {
                    return(false);
                }

                container = desc.model as IVFXSlotContainer;
                if (container == null)
                {
                    return(false);
                }

                if (direction == Direction.Output &&
                    mySlot != null &&
                    container is VFXOperatorDynamicOperand &&
                    (container as VFXOperatorDynamicOperand).validTypes.Contains(mySlot.property.type))
                {
                    return(true);
                }
            }

            IEnumerable <Type> validTypes = null;

            if (mySlot == null)
            {
                var op = controller.sourceNode.model as VFXOperatorDynamicOperand;
                if (op != null)
                {
                    validTypes = op.validTypes;
                }
            }

            var getSlots = direction == Direction.Input ? (System.Func <int, VFXSlot>)container.GetOutputSlot : (System.Func <int, VFXSlot>)container.GetInputSlot;
            int count    = direction == Direction.Input ? container.GetNbOutputSlots() : container.GetNbInputSlots();

            for (int i = 0; i < count; ++i)
            {
                var slot = getSlots(i);
                if (mySlot != null && slot.CanLink(mySlot))
                {
                    return(true);
                }
                else if (validTypes != null && validTypes.Contains(slot.property.type))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        bool ProviderFilter(VFXNodeProvider.Descriptor d)
        {
            var mySlot = controller.model;

            IEnumerable <Type> validTypes = null;

            if (mySlot == null)
            {
                var op = controller.sourceNode.model as VFXOperatorNumericCascadedUnified;
                if (op != null)
                {
                    validTypes = op.validTypes;
                }
            }
            var parameterDescriptor     = d.modelDescriptor as VFXParameterController;
            IVFXSlotContainer container = null;

            if (parameterDescriptor != null)
            {
                container = parameterDescriptor.model;
            }
            else
            {
                VFXModelDescriptor desc = d.modelDescriptor as VFXModelDescriptor;
                if (desc == null)
                {
                    return(false);
                }

                container = desc.model as IVFXSlotContainer;
                if (container == null)
                {
                    return(false);
                }
            }

            var getSlots = direction == Direction.Input ? (System.Func <int, VFXSlot>)container.GetOutputSlot : (System.Func <int, VFXSlot>)container.GetInputSlot;

            int count = direction == Direction.Input ? container.GetNbOutputSlots() : container.GetNbInputSlots();

            bool oneFound = false;

            for (int i = 0; i < count; ++i)
            {
                VFXSlot slot = getSlots(i);

                if (mySlot != null)
                {
                    if (slot.CanLink(mySlot))
                    {
                        oneFound = true;
                        break;
                    }
                }
                else if (validTypes != null)
                {
                    if (validTypes.Contains(slot.property.type))
                    {
                        oneFound = true;
                        break;
                    }
                }
            }

            return(oneFound);
        }