Пример #1
0
        private void _Perform(Node n, Perform performFunc)
        {
            n.dirty             = false;
            n.data.NeedsRevisit = false;

            //root node
            if (n.streamFrom.Count == 0)
            {
                IEnumerable <Model.ConnectionData> outputConnections = n.streamTo.Select(v => v.connection);

                LogUtility.Logger.Log(n.data.Name + " performed(root)");
                performFunc(n.data, null, outputConnections,
                            (Model.ConnectionData destination, Dictionary <string, List <AssetReference> > newOutput) =>
                {
                    if (destination != null)
                    {
                        AssetStream output = n.streamTo.Find(v => v.connection == destination);
                        Assert.IsNotNull(output);
                        if (output.assetGroups != newOutput)
                        {
                            output.nodeTo.dirty = true;
                            LogUtility.Logger.LogFormat(LogType.Log, "{0} marked dirty ({1} => {2} updated)", output.nodeTo.data.Name, output.nodeFrom.data.Name, output.nodeTo.data.Name);
                            m_streamManager.AssignAssetGroup(output.connection, newOutput);
                            output.assetGroups = newOutput;
                        }
                    }
                }
                            );
            }
            else
            {
                if (n.streamTo.Count > 0)
                {
                    IEnumerable <Model.ConnectionData> outputConnections = n.streamTo.Select(v => v.connection);
                    IEnumerable <AssetGroups>          inputs            = n.streamFrom.Select(v => new AssetGroups(v.connection, v.assetGroups));

                    LogUtility.Logger.LogFormat(LogType.Log, "{0} perfomed", n.data.Name);
                    performFunc(n.data, inputs, outputConnections,
                                (Model.ConnectionData destination, Dictionary <string, List <AssetReference> > newOutput) =>
                    {
                        Assert.IsNotNull(destination);
                        AssetStream output = n.streamTo.Find(v => v.connection == destination);
                        Assert.IsNotNull(output);
                        output.AddNewOutput(newOutput);
                    }
                                );
                }
                else
                {
                    IEnumerable <AssetGroups> inputs = n.streamFrom.Select(v => new AssetGroups(v.connection, v.assetGroups));

                    LogUtility.Logger.LogFormat(LogType.Log, "{0} perfomed", n.data.Name);
                    performFunc(n.data, inputs, null, null);
                }

                // Test output asset group after all input-output pairs are performed
                if (n.streamTo.Count > 0)
                {
                    foreach (var to in n.streamTo)
                    {
                        if (to.IsStreamAssetRequireUpdate)
                        {
                            to.UpdateAssetGroup(m_streamManager);
                        }
                        else
                        {
                            LogUtility.Logger.LogFormat(LogType.Log, "[skipped]stream update skipped. Result is equivarent: {0} -> {1}", n.data.Name, to.nodeTo.data.Name);
                        }
                    }
                }
            }
        }