public unsafe void ReadRange(ref MyVoxelDataRequest req, bool detectOnly = false) { if (!this.Closed) { if (req.RequestedData.Requests(MyStorageDataTypeEnum.Content)) { this.Shape.ReadContentRange(ref req, detectOnly); MyVoxelRequestFlags *flagsPtr1 = (MyVoxelRequestFlags *)ref req.RequestFlags; *((int *)flagsPtr1) |= 2; } if (!req.Flags.HasFlags(MyVoxelRequestFlags.EmptyData)) { if (req.RequestedData.Requests(MyStorageDataTypeEnum.Material)) { this.Material.ReadMaterialRange(ref req, detectOnly); } } else if (!detectOnly && req.RequestedData.Requests(MyStorageDataTypeEnum.Material)) { req.Target.BlockFill(MyStorageDataTypeEnum.Material, req.MinInLod, req.MaxInLod, 0xff); } } }
public unsafe void ReadMaterialRange(ref MyVoxelDataRequest req, bool detectOnly = false) { Vector3I vectori4; req.Flags = req.RequestFlags & MyVoxelRequestFlags.RequestFlags; Vector3I minInLod = req.MinInLod; Vector3I maxInLod = req.MaxInLod; float lodSize = 1 << (req.Lod & 0x1f); bool flag = req.RequestFlags.HasFlags(MyVoxelRequestFlags.SurfaceMaterial); bool flag2 = req.RequestFlags.HasFlags(MyVoxelRequestFlags.ConsiderContent); bool preciseOrePositions = req.RequestFlags.HasFlags(MyVoxelRequestFlags.PreciseOrePositions); this.m_planetShape.PrepareCache(); if (this.m_biomes != null) { if (req.SizeLinear > 0x7d) { BoundingBox request = new BoundingBox((Vector3)(minInLod * lodSize), (Vector3)(maxInLod * lodSize)); this.PrepareRulesForBoxInternal(ref request); } else if (!m_rangeClean || !ReferenceEquals(CachedProvider, this)) { this.CleanRules(); } } Vector3 vector = (minInLod + 0.5f) * lodSize; Vector3 pos = vector; Vector3I vectori3 = (Vector3I)(-minInLod + req.Offset); if (detectOnly) { vectori4.Z = minInLod.Z; while (vectori4.Z <= maxInLod.Z) { vectori4.Y = minInLod.Y; while (true) { if (vectori4.Y > maxInLod.Y) { float *singlePtr3 = (float *)ref pos.Z; singlePtr3[0] += lodSize; pos.Y = vector.Y; int *numPtr3 = (int *)ref vectori4.Z; numPtr3[0]++; break; } vectori4.X = minInLod.X; while (true) { byte num2; if (vectori4.X > maxInLod.X) { float *singlePtr2 = (float *)ref pos.Y; singlePtr2[0] += lodSize; pos.X = vector.X; int *numPtr2 = (int *)ref vectori4.Y; numPtr2[0]++; break; } MyVoxelMaterialDefinition definition = this.GetMaterialForPosition(ref pos, lodSize, out num2, preciseOrePositions); if ((definition != null) && (definition.Index != 0xff)) { return; } float *singlePtr1 = (float *)ref pos.X; singlePtr1[0] += lodSize; int *numPtr1 = (int *)ref vectori4.X; numPtr1[0]++; } } } MyVoxelRequestFlags *flagsPtr1 = (MyVoxelRequestFlags *)ref req.Flags; *((int *)flagsPtr1) |= 8; } else { bool flag4 = true; MyStorageData target = req.Target; vectori4.Z = minInLod.Z; while (true) { while (true) { if (vectori4.Z <= maxInLod.Z) { vectori4.Y = minInLod.Y; break; } if (flag4) { MyVoxelRequestFlags *flagsPtr2 = (MyVoxelRequestFlags *)ref req.Flags; *((int *)flagsPtr2) |= 8; } return; } while (true) { if (vectori4.Y > maxInLod.Y) { float *singlePtr6 = (float *)ref pos.Z; singlePtr6[0] += lodSize; pos.Y = vector.Y; int *numPtr6 = (int *)ref vectori4.Z; numPtr6[0]++; break; } vectori4.X = minInLod.X; Vector3I p = (Vector3I)(vectori4 + vectori3); int linearIdx = target.ComputeLinear(ref p); while (true) { if (vectori4.X <= maxInLod.X) { byte num4; if ((!flag || (target.Material(linearIdx) == 0)) && (!flag2 || (target.Content(linearIdx) != 0))) { byte num5; MyVoxelMaterialDefinition definition2 = this.GetMaterialForPosition(ref pos, lodSize, out num5, preciseOrePositions); num4 = (definition2 != null) ? definition2.Index : ((byte)0xff); } else { num4 = 0xff; } target.Material(linearIdx, num4); flag4 &= num4 == 0xff; linearIdx += target.StepLinear; float *singlePtr4 = (float *)ref pos.X; singlePtr4[0] += lodSize; int *numPtr4 = (int *)ref vectori4.X; numPtr4[0]++; continue; } else { float *singlePtr5 = (float *)ref pos.Y; singlePtr5[0] += lodSize; pos.X = vector.X; int *numPtr5 = (int *)ref vectori4.Y; numPtr5[0]++; } break; } } } } }