Example #1
0
    private unsafe void DrawNode(int idx, int depth, Vector3 coords)
    {
        Node node     = nodeData[idx];
        var  nodeSize = bounds.size / (1 << depth);
        var  center   = bounds.min + Vector3.Scale(coords + 0.5f * Vector3.one, nodeSize);

        Gizmos.DrawWireCube(center, nodeSize);

        for (int i = 0; i < 8; i++)
        {
            int child = node.children[i];
            if (child > 0 && child < nodeData.Length)
            {
                Vector3 child_coords = Morton.Decode(i);
                DrawNode(child, depth + 1, 2f * coords + child_coords);
            }
        }
    }
        public void EncodeDecode()
        {
            Vector3 coords = new Vector3(1, 2, 3);

            Assert.AreEqual(Morton.Decode(Morton.Encode(coords)), coords);
        }