public static void SimpleSwitchGraphBuild()
        {
            WorldGraph graph = TestUtils.GenerateTestWorldGraphBiomeSwitch();
            BiomeData  bd    = new BiomeData();

            var wlevel  = graph.FindNodeByName("wlevel");
            var bswitch = graph.FindNodeByName <NodeBiomeSwitch>("bswitch");
            var b1      = graph.FindNodeByName <NodeBiome>("b1");
            var b2      = graph.FindNodeByName <NodeBiome>("b2");

            bd.biomeSwitchGraphStartPoint = wlevel;

            PartialBiome p1 = new PartialBiome();
            PartialBiome p2 = new PartialBiome();

            b1.outputBiome = p1;
            b2.outputBiome = p2;

            //setup the switch values
            var sd = bswitch.switchList.switchDatas;

            sd[0].min         = 0;
            sd[0].max         = 5;
            sd[0].name        = "1";
            sd[0].samplerName = BiomeSamplerName.terrainHeight;
            sd[1].min         = 5;
            sd[1].max         = 10;
            sd[1].name        = "2";
            sd[1].samplerName = BiomeSamplerName.terrainHeight;

            Sampler2D terrainHeight = new Sampler2D(32, 1);

            terrainHeight.min = 0;
            terrainHeight.max = 10;

            bd.UpdateSamplerValue(BiomeSamplerName.terrainHeight, terrainHeight);

            BiomeSwitchGraph switchGraph = new BiomeSwitchGraph();

            switchGraph.BuildGraph(bd);

            Assert.That(switchGraph.isBuilt == true);

            var values = new BiomeSwitchValues();

            values[0] = 4.0f;
            Assert.That(switchGraph.FindBiome(values).id == p1.id);
            values[0] = 0f;
            Assert.That(switchGraph.FindBiome(values).id == p1.id);
            values[0] = 5f;
            Assert.That(switchGraph.FindBiome(values).id == p1.id);

            values[0] = 6.0f;
            Assert.That(switchGraph.FindBiome(values).id == p2.id);
            values[0] = 10f;
            Assert.That(switchGraph.FindBiome(values).id == p2.id);
        }
Beispiel #2
0
        public static void NodeAPIGetNodesAttachedToAnchor()
        {
            WorldGraph graph = TestUtils.GenerateTestWorldGraph();

            var add4Node   = graph.FindNodeByName("add4");
            var add1Node   = graph.FindNodeByName("add1");
            var debug1Node = graph.FindNodeByName("debug1");

            var add4NodeInAnchor  = add4Node.inputAnchors.First();
            var add4NodeOutAnchor = add4Node.outputAnchors.First();

            List <BaseNode> add4InputNodes  = add4Node.GetNodesAttachedToAnchor(add4NodeInAnchor).ToList();
            List <BaseNode> add4OutputNodes = add4Node.GetNodesAttachedToAnchor(add4NodeOutAnchor).ToList();

            Assert.That(add4InputNodes[0] == add1Node, "add4 input node was " + add4InputNodes[0] + ", " + add1Node + " expected");
            Assert.That(add4OutputNodes[0] == debug1Node, "add4 output node was " + add4OutputNodes[0] + ", " + debug1Node + " expected");
        }
Beispiel #3
0
        public static void NodeAPIGetNodesAttachedToAnchorArray()
        {
            WorldGraph graph = TestUtils.GenerateTestWorldGraph();

            var add2Node   = graph.FindNodeByName("add2");
            var sliderNode = graph.FindNodeByName("slider");
            var debug2Node = graph.FindNodeByName("debug2");

            var add2NodeInputAnchor  = add2Node.inputAnchors.First();
            var add2NodeOutputAnchor = add2Node.outputAnchors.First();

            List <BaseNode> inputNodes  = add2Node.GetNodesAttachedToAnchor(add2NodeInputAnchor).ToList();
            List <BaseNode> outputNodes = add2Node.GetNodesAttachedToAnchor(add2NodeOutputAnchor).ToList();

            Assert.That(inputNodes.Count == 1);
            Assert.That(inputNodes[0] == sliderNode);

            Assert.That(outputNodes.Count == 1);
            Assert.That(outputNodes[0] == debug2Node);
        }
Beispiel #4
0
        public static void GetNodeChildsRecursiveTest()
        {
            WorldGraph worldGraph = TestUtils.GenerateTestWorldGraphBiomeSwitch();

            var wlevel = worldGraph.FindNodeByName("wlevel");

            var recursiveNodesFromC2 = worldGraph.GetNodeChildsRecursive(wlevel);

            //check for duplicates
            Assert.That(recursiveNodesFromC2.Count == recursiveNodesFromC2.Distinct().Count());

            //check for compute order:
            for (int i = 0; i < recursiveNodesFromC2.Count - 1; i++)
            {
                var node1 = recursiveNodesFromC2[i];
                var node2 = recursiveNodesFromC2[i + 1];

                Assert.That(node1.computeOrder <= node2.computeOrder, "Nodes from GetNodeChildsRecursive are not computeOrder sorted");
            }
        }