} // a struct respresentaion of the Node class public ComputeBuffer NodeTreeToBuffer(Node n) { unsafe { int count = n.ChildNodeCount(); ComputeBuffer ret = new ComputeBuffer(count, sizeof(NodeS)); NodeS[] arr = new NodeS[count]; arr = computeOrder(arr, 0, n); arr[0] = n.ToNodeS(); return(ret); } }
public unsafe NodeS[] computeOrder(NodeS[] arr, int i, Node n) { for (int u = 0; u < arr.Length; u++) { if (arr[u].c[0] != 0) { continue; } for (int y = 0; y < 4; y++) { NodeS node = n.c[y].ToNodeS(); node.p = i; arr[u + y] = node; // set child } } return(null); }