Ejemplo n.º 1
0
        public static RecastGridData VoxelizationToGrid(Voxelization voxel)
        {
            Vector3        min      = voxel.Bounds.min;
            RecastGridData gridData = new RecastGridData
            {
                OriginPoint = new Vector3(min.x, min.z),
                Width       = voxel.Size.x,
                Length      = voxel.Size.z,
                Mask        = new SerializBitArray(voxel.Size.x * voxel.Size.z)
            };
            int bgHeight = (int)voxel.Bounds.min.y;

            if (bgHeight < 0)
            {
                bgHeight = -bgHeight;
            }
            for (int x = 0; x < voxel.Size.x; ++x)
            {
                for (int z = 0; z < voxel.Size.x; ++z)
                {
                    if (voxel.Check(x, bgHeight, z) && !voxel.Check(x, bgHeight + 1, z))
                    {
                        gridData.Mask.Set(z * voxel.Size.x + x, true);
                    }
                }
            }
            return(gridData);
        }
Ejemplo n.º 2
0
        public static BitArray VoxelizationWalkableFilter(Voxelization voxel)
        {
            BitArray bitArray = new BitArray(voxel.Size.x * voxel.Size.z);
            int      bgHeight = (int)voxel.Bounds.min.y;

            if (bgHeight < 0)
            {
                bgHeight = -bgHeight;
            }
            for (int x = 0; x < voxel.Size.x; ++x)
            {
                for (int z = 0; z < voxel.Size.x; ++z)
                {
                    if (voxel.Check(x, bgHeight, z) && !voxel.Check(x, bgHeight + 1, z))
                    {
                        bitArray.Set(z * voxel.Size.x + x, true);
                    }
                }
            }
            return(bitArray);
        }