public MeshJobData(int3 dimensions, bool includeLighting, NativeArray <VoxelTypeID> voxels, NativeArray <RotatedVoxelEntry> rotatedVoxels, NativeArray <LightValue> lights, NeighbourData neighbourData, NativeMeshDatabase meshDatabase, NativeVoxelTypeDatabase voxelTypeDatabase, Allocator allocator) { this.dimensions = dimensions; this.includeLighting = includeLighting; this.voxels = voxels; this.rotatedVoxels = rotatedVoxels; this.lights = lights; this.neighbourData = neighbourData; this.meshDatabase = meshDatabase; this.voxelTypeDatabase = voxelTypeDatabase; vertices = new NativeList <Vector3>(allocator); vertexColours = new NativeList <Color>(allocator); uvs = new NativeList <Vector3>(allocator); normals = new NativeList <Vector3>(allocator); allTriangleIndices = new NativeList <int>(allocator); materialRuns = new NativeList <MaterialRun>(allocator); collisionSubmesh = new CollisionSubmeshDescriptor(allocator); }
public static NativeVoxelTypeDatabase FromTypeData(List <VoxelTypeData> typeData) { List <float> zIndicesPerFaceList = new List <float>(); List <StartEndRange> voxelTypeToZIndicesRangeMapList = new List <StartEndRange>(); List <bool> voxelTypeToIsPassableMapList = new List <bool>(); //AIR voxelTypeToZIndicesRangeMapList.Add(new StartEndRange()); voxelTypeToIsPassableMapList.Add(true); for (int i = 1; i < typeData.Count; i++) { StartEndRange range = new StartEndRange(); range.start = zIndicesPerFaceList.Count; var zIndices = typeData[i].zIndicesPerFace; zIndicesPerFaceList.AddRange(zIndices); range.end = zIndicesPerFaceList.Count; voxelTypeToZIndicesRangeMapList.Add(range); voxelTypeToIsPassableMapList.Add(typeData[i].definition.isPassable); } NativeVoxelTypeDatabase database = new NativeVoxelTypeDatabase(); database.zIndicesPerFace = new NativeArray <float>(zIndicesPerFaceList.ToArray(), Allocator.Persistent); database.voxelTypeToZIndicesRangeMap = new NativeArray <StartEndRange>(voxelTypeToZIndicesRangeMapList.ToArray(), Allocator.Persistent); database.voxelTypeToIsPassableMap = new NativeArray <bool>(voxelTypeToIsPassableMapList.ToArray(), Allocator.Persistent); return(database); }