예제 #1
0
            uint GetVoxelFromGenDataArray(NativeArray <VoxelGenDataMirror> data, IntVector3 posOverDiv)
            {
                int opI;

                if (lodIndex == 0)
                {
                    opI = posOverDiv.ToFlatZXYIndex(chunkSize);
                    int opMod = opI % voxelsPerMapData;
                    opI /= voxelsPerMapData;
                    uint voxels = data[opI].voxel;
                    return((uint)VGenConfig.DecodeMapGenType(voxels, opMod));
                }
                else
                {
                    int div = (int)Mathf.Pow(2, lodIndex);
                    opI = (posOverDiv).ToFlatXYZIndex(chunkSize / div);
                    return((uint)VGenConfig.DecodeVoxelType(data[opI].voxel)); //This is a type-x-y-z encoded voxel if set. if not, its just EmptyVoxel
                }
            }
예제 #2
0
        public static uint GetExists(NativeArray <uint> existsMap, IntVector3 pos, IntVector3 chunkSize)
        {
            var val = existsMap[GetExistsMapIndex(pos, chunkSize)];

            return((val >> (pos.ToFlatZXYIndex(chunkSize) % VGenConfig.SizeOfHLSLInt)) & 1);
        }
예제 #3
0
 public static int GetExistsMapIndex(IntVector3 pos, IntVector3 chunkSize)
 {
     return(pos.ToFlatZXYIndex(chunkSize) / VGenConfig.SizeOfHLSLInt);
 }
예제 #4
0
 public static int GetPerlinGenPackedIndex(IntVector3 chunkRelative, IntVector3 chunkSize, int voxelsPerMapData = 4)
 {
     return(chunkRelative.ToFlatZXYIndex(chunkSize) / voxelsPerMapData);
 }