예제 #1
0
    //*** Nodes stuffs ****//

    // Add a new object to the tree
    public void AddNodeObject(string fullPath, object[] args, string type)
    {
        var name       = MyUtility.GetNameFromUrlPath(fullPath);
        var parentPath = MyUtility.GetParentUrlPath(fullPath);

        // If the node is a root node
        if (string.IsNullOrEmpty(parentPath))
        {
            var node = CreateNodeObject(name, fullPath, args, type);
            _rootNodes.Add(node);
        }
        // If the node is a child node
        else
        {
            var parentNode = FindBaseItem(parentPath);

            if (parentNode != null)
            {
                var node = CreateNodeObject(name, fullPath, args, type);
                _rootNodes.Add(node);
                parentNode.AddChild(node);

                if (name.Contains("RNA"))
                {
                    _rnaInstanceNodeId = node.Id;
                }
            }
            else
            {
                throw new Exception("System error");
            }
        }
    }
예제 #2
0
    void InitHistogramLookups()
    {
        // Init histogram GPU buffer
        CPUBuffers.Get.HistogramData.Clear();
        foreach (var path in SceneManager.Get.SceneHierarchy)
        {
            var hist = new HistStruct
            {
                parent    = -1,
                all       = 0,
                cutaway   = 0,
                occluding = 0,
                visible   = 0
            };

            if (MyUtility.IsPathRoot(path))
            {
                hist.parent = -1;
            }
            else
            {
                var parentPath = MyUtility.GetParentUrlPath(path);
                if (!SceneManager.Get.SceneHierarchy.Contains(parentPath))
                {
                    throw new Exception("Hierarchy corrupted");
                }
                hist.parent = SceneManager.Get.SceneHierarchy.IndexOf(parentPath);
            }

            CPUBuffers.Get.HistogramData.Add(hist);
        }

        //*******************************//

        CPUBuffers.Get.IngredientToNodeLookup.Clear();

        foreach (var ingredientName in SceneManager.Get.AllIngredientNames)
        {
            if (SceneManager.Get.SceneHierarchy.Contains(ingredientName))
            {
                CPUBuffers.Get.IngredientToNodeLookup.Add(SceneManager.Get.SceneHierarchy.IndexOf(ingredientName));
            }
        }

        //*******************************//

        CPUBuffers.Get.NodeToIngredientLookup.Clear();

        foreach (var path in SceneManager.Get.SceneHierarchy)
        {
            if (SceneManager.Get.AllIngredientNames.Contains(path))
            {
                CPUBuffers.Get.NodeToIngredientLookup.Add(SceneManager.Get.AllIngredientNames.IndexOf(path));
            }
            else
            {
                CPUBuffers.Get.NodeToIngredientLookup.Add(-1);
            }
        }
    }
예제 #3
0
    //--------------------------------------------------------------

    #region Ingredients

    public void AddIngredientToHierarchy(string ingredientUrlPath)
    {
        var urlPathSplit = MyUtility.SplitUrlPath(ingredientUrlPath);

        if (urlPathSplit.Count() == 1)
        {
            if (!SceneHierarchy.Contains(urlPathSplit.First()))
            {
                SceneHierarchy.Add(urlPathSplit.First());
            }
        }
        else
        {
            var parentUrlPath = MyUtility.GetParentUrlPath(ingredientUrlPath);

            if (!SceneHierarchy.Contains(parentUrlPath))
            {
                AddIngredientToHierarchy(parentUrlPath);
            }

            if (!SceneHierarchy.Contains(ingredientUrlPath))
            {
                SceneHierarchy.Add(ingredientUrlPath);
            }
            else
            {
                throw new Exception("Ingredient path already used");
            }
        }
    }
예제 #4
0
    //--------------------------------------------------------------

    #region Ingredients

    //*** Hierarchy stuffs ****//

    public void AddIngredientToHierarchy(string ingredientUrlPath)
    {
        Debug.Log("SceneManager.AddIngredientToHierarchy");
        var urlPathSplit           = MyUtility.SplitUrlPath(ingredientUrlPath);
        int parentIndexInHierarchy = -1;

        if (urlPathSplit.Count() == 1)  // root node
        {
            if (!SceneHierarchy.Contains(urlPathSplit.First()))
            {
                SceneHierarchy.Add(urlPathSplit.First());
            }
        }
        else                            // child node
        {
            var parentUrlPath = MyUtility.GetParentUrlPath(ingredientUrlPath);

            // To make sure that the parents are added in the hierarchy
            if (!SceneHierarchy.Contains(parentUrlPath))
            {
                AddIngredientToHierarchy(parentUrlPath);
                parentIndexInHierarchy = SceneHierarchy.IndexOf(parentUrlPath);
            }
            else // parent is already in hierarchy
            {    // which means that I will get the index of the parent so that I can put the new item on the right place
                parentIndexInHierarchy = SceneHierarchy.IndexOf(parentUrlPath);
            }

            if (!SceneHierarchy.Contains(ingredientUrlPath))
            {
                if (parentIndexInHierarchy != -1)
                {
                    SceneHierarchy.Insert(parentIndexInHierarchy + 1, ingredientUrlPath);
                }
                else
                {   // new ingredient
                    SceneHierarchy.Add(ingredientUrlPath);
                }
            }
            else
            {
                throw new Exception("Ingredient path already used");
            }
        }
    }