示例#1
0
        public SVOData Create(RT.CS.Node root, GetLeaf getLeaf = null)
        {
            SVOData result = new SVOData();

            List <int>  nodes       = new List <int>();
            List <uint> attachments = new List <uint>();

            CompressSVO(root, nodes, attachments, getLeaf);

            result.childDescriptors = nodes;
            result.attachments      = attachments;

            return(result);
        }
示例#2
0
        private void CompressSVOAux(Node node, int nodeIndex, List <int> compressedNodes, List <uint> attachments, GetLeaf getLeaf = null)
        {
            if (node == null || node.leaf)
            {
                return;
            }

            int childPointer = 0;
            int validMask    = 0;
            int leafMask     = 0;

            int numHitChild = 0;

            List <Color> childColors = new List <Color>();

            for (int childNum = 0; childNum < 8; childNum++)
            {
                int bit = (int)1 << childNum;

                if (node.children[childNum] != null)
                {
                    validMask |= bit;

                    if (node.children[childNum].leaf)
                    {
                        if (getLeaf != null)
                        {
                            Vector3 pos = node.children[childNum].position;
                            childPointer = getLeaf(new Vector4Int((int)pos.x, (int)pos.y, (int)pos.z, (int)node.children[childNum].size)) - nodeIndex;
                        }
                        else
                        {
                            leafMask |= bit;
                        }
                    }
                    else
                    {
                        if (childPointer == 0)
                        {
                            childPointer = compressedNodes.Count - nodeIndex;
                            if ((childPointer & 0x8000) != 0)                      // far

                            {
                            }
                        }
                        compressedNodes.Add(0);
                        attachments.Add(0); attachments.Add(0);
                    }
                }
            }

            int childPointerClone = childPointer;

            for (int childNum = 0; childNum < 8; childNum++)
            {
                if (node.children[childNum] != null && !node.children[childNum].leaf)
                {
                    CompressSVOAux(node.children[childNum], nodeIndex + childPointerClone++, compressedNodes, attachments, getLeaf);
                }
            }

            int nonLeafMask = leafMask ^ 255;

            nonLeafMask &= validMask;

            int result = (childPointer << 16) | (validMask << 8) | (nonLeafMask << 0);

            ulong attachment = GetAttachment(node);

            attachments[nodeIndex * 2]     = ((uint)attachment);
            attachments[nodeIndex * 2 + 1] = ((uint)(attachment >> 32));
            compressedNodes[nodeIndex]     = result;
        }
示例#3
0
 private void CompressSVO(Node root, List <int> compressedNodes, List <uint> attachments, GetLeaf getLeaf = null)
 {
     compressedNodes.Add(0);
     attachments.Add(0); attachments.Add(0);
     CompressSVOAux(root, 0, compressedNodes, attachments, getLeaf);
 }