HasChildren() public method

public HasChildren ( ) : bool
return bool
Beispiel #1
0
        unsafe private int getReservedCount()
        {
            if (!isSubsampled)
            {
                return(1);

                fixed(OctreeNode *ptree = MemoryMarshal.Cast <byte, OctreeNode>(nodeBuffer))
                {
                    int reserved = 1;

                    for (nuint i = 0; i < 8; i++)
                    {
                        var node = ptree + i;
                        if (!OctreeNode.HasChildren(node))
                        {
                            reserved += 8;
                        }
                        else
                        {
                            ushort *children = (ushort *)node;
                            for (nuint j = 0; j < 8; j++)
                            {
                                if (children[j] == 0)
                                {
                                    reserved++;
                                }
                            }
                        }
                    }

                    return(reserved);
                }
        }

        unsafe private int getPixelCount()
Beispiel #2
0
        unsafe private void migrateNodes(OctreeNode *ptree, OctreeNode *pmap, uint *pilut, OctreeNode *node, OctreeNode *nnode, nuint currLevel, ref nuint nidx)
        {
            var pnew = nnode;

            ushort *children  = (ushort *)node;
            ushort *nchildren = (ushort *)pnew;

            if (currLevel > 0)
            {
                bool isLeaf = !OctreeNode.HasChildren(node);

                pnew      = pmap + nidx++;
                nchildren = (ushort *)pnew;

                uint *sums = (uint *)((ushort *)node + 8);
                if (currLevel < minLeafLevel && isLeaf)
                {
                    nuint idx =
                        pilut[(nuint)sums[0]] |
                        pilut[(nuint)sums[1] + 256] |
                        pilut[(nuint)sums[2] + 512];

                    idx >>= (int)(currLevel * 3);

                    nuint nnidx = nidx++;
                    nchildren[idx & 7] = (ushort)nnidx;

                    pnew      = pmap + nnidx;
                    nchildren = (ushort *)pnew;
                }

                uint *nsums = (uint *)(nchildren + 8);
                Unsafe.CopyBlockUnaligned(nsums, sums, sizeof(uint) * 4);

                if (currLevel >= minLeafLevel && !isLeaf)
                {
                    nsums[3] = byte.MaxValue;
                }

                if (isLeaf)
                {
                    return;
                }
            }

            for (nuint i = 0; i < 8; i++)
            {
                nuint child = children[i];
                if (child != 0)
                {
                    nchildren[i] = (ushort)nidx;
                    migrateNodes(ptree, pmap, pilut, ptree + child, pmap + nidx, currLevel + 1, ref nidx);
                }
            }
        }