private void CheckData <T>(ref T data, MyCellCoord cell) where T : struct, IEnumerator <byte> { uint num = cell.PackId32(); MyOctreeNode node = this.m_nodes[num]; for (int i = 0; i < 8; i++) { if (node.HasChild(i)) { Vector3I vectori; this.ComputeChildCoord(i, out vectori); } else { int num3 = 1 << ((3 * cell.Lod) & 0x1f); for (int j = 0; j < num3; j++) { } } } }
internal unsafe void ReadRange <TOperator>(ref TOperator target, MyStorageDataTypeEnum type, ref Vector3I writeOffset, int lodIndex, ref Vector3I minInLod, ref Vector3I maxInLod) where TOperator : struct, IVoxelOperator { try { MyCellCoord *coordPtr = (MyCellCoord *)stackalloc byte[(((IntPtr)EstimateStackSize(this.m_treeHeight)) * sizeof(MyCellCoord))]; MyCellCoord coord = new MyCellCoord(this.m_treeHeight - 1, ref Vector3I.Zero); int index = 0 + 1; coordPtr[index] = coord; while (index > 0) { coord = coordPtr[--index]; MyOctreeNode node = this.m_nodes[coord.PackId32()]; int num3 = coord.Lod - lodIndex; Vector3I vectori4 = coord.CoordInLod << 1; Vector3I min = (minInLod >> num3) - vectori4; Vector3I max = (maxInLod >> num3) - vectori4; for (int i = 0; i < 8; i++) { Vector3I vectori; this.ComputeChildCoord(i, out vectori); if (vectori.IsInsideInclusiveEnd(ref min, ref max)) { if ((lodIndex < coord.Lod) && node.HasChild(i)) { index++; coordPtr[index] = new MyCellCoord(coord.Lod - 1, (Vector3I)(vectori4 + vectori)); } else { byte inOutContent = &node.Data.FixedElementField[i]; Vector3I result = (Vector3I)(vectori4 + vectori); if (num3 == 0) { Vector3I position = (Vector3I)((writeOffset + result) - minInLod); target.Op(ref position, type, ref inOutContent); } else { result = result << num3; Vector3I vectori7 = (Vector3I)((result + (1 << (num3 & 0x1f))) - 1); Vector3I *vectoriPtr1 = (Vector3I *)ref result; Vector3I.Max(ref (Vector3I) ref vectoriPtr1, ref minInLod, out result); Vector3I *vectoriPtr2 = (Vector3I *)ref vectori7; Vector3I.Min(ref (Vector3I) ref vectoriPtr2, ref maxInLod, out vectori7); int z = result.Z; while (z <= vectori7.Z) { int y = result.Y; while (true) { if (y > vectori7.Y) { z++; break; } int x = result.X; while (true) { if (x > vectori7.X) { y++; break; } Vector3I position = writeOffset; int * numPtr1 = (int *)ref position.X; numPtr1[0] += x - minInLod.X; int *numPtr2 = (int *)ref position.Y; numPtr2[0] += y - minInLod.Y; int *numPtr3 = (int *)ref position.Z; numPtr3[0] += z - minInLod.Z; target.Op(ref position, type, ref inOutContent); x++; } } } } } } } } } finally { } }
internal unsafe ContainmentType Intersect(ref BoundingBoxI box, int lod, bool exhaustiveContainmentCheck = true) { MyCellCoord *coordPtr = (MyCellCoord *)stackalloc byte[(((IntPtr)EstimateStackSize(this.m_treeHeight)) * sizeof(MyCellCoord))]; MyCellCoord coord = new MyCellCoord(this.m_treeHeight - 1, ref Vector3I.Zero); int index = 0 + 1; coordPtr[index] = coord; Vector3I min = box.Min; Vector3I max = box.Max; ContainmentType disjoint = ContainmentType.Disjoint; while (index > 0) { coord = coordPtr[--index]; MyOctreeNode node = this.m_nodes[coord.PackId32()]; int num3 = coord.Lod; Vector3I vectori6 = coord.CoordInLod << 1; Vector3I vectori4 = (min >> num3) - vectori6; Vector3I vectori5 = (max >> num3) - vectori6; for (int i = 0; i < 8; i++) { Vector3I vectori3; this.ComputeChildCoord(i, out vectori3); if (vectori3.IsInsideInclusiveEnd(ref vectori4, ref vectori5)) { if ((coord.Lod > 0) && node.HasChild(i)) { index++; coordPtr[index] = new MyCellCoord(coord.Lod - 1, (Vector3I)(vectori6 + vectori3)); } else { byte num5 = &node.Data.FixedElementField[i]; if (num3 == 0) { if (num5 != 0) { return(ContainmentType.Intersects); } } else { BoundingBoxI xi; bool flag; xi.Min = (Vector3I)(vectori6 + vectori3); Vector3I *vectoriPtr1 = (Vector3I *)ref xi.Min; vectoriPtr1[0] = vectoriPtr1[0] << num3; BoundingBoxI *xiPtr1 = (BoundingBoxI *)ref xi; xiPtr1->Max = (Vector3I)((xi.Min + (1 << (num3 & 0x1f))) - 1); Vector3I.Max(ref xi.Min, ref min, out xi.Min); Vector3I.Min(ref xi.Max, ref max, out xi.Max); ((BoundingBoxI *)ref xi).Intersects(ref xi, out flag); if (flag) { return(ContainmentType.Intersects); } } } } } } return(disjoint); }
internal unsafe void DebugDraw(IMyDebugDrawBatchAabb batch, Vector3 worldPos, MyVoxelDebugDrawMode mode) { Color?nullable; if (mode == MyVoxelDebugDrawMode.Content_MicroNodes) { foreach (KeyValuePair <uint, MyOctreeNode> pair in this.m_nodes) { MyCellCoord coord = new MyCellCoord(); coord.SetUnpack(pair.Key); MyOctreeNode node = pair.Value; for (int i = 0; i < 8; i++) { if (!node.HasChild(i) || (coord.Lod == 0)) { Vector3I vectori; BoundingBoxD xd; this.ComputeChildCoord(i, out vectori); Vector3I vectori2 = (Vector3I)((coord.CoordInLod << (coord.Lod + 1)) + (vectori << coord.Lod)); xd.Min = worldPos + (vectori2 * 1f); BoundingBoxD *xdPtr1 = (BoundingBoxD *)ref xd; xdPtr1->Max = xd.Min + (1f * (1 << (coord.Lod & 0x1f))); if (node.GetData(i) != 0) { nullable = null; batch.Add(ref xd, nullable); } } } } return; } else if (mode != MyVoxelDebugDrawMode.Content_MicroNodesScaled) { return; } foreach (KeyValuePair <uint, MyOctreeNode> pair2 in this.m_nodes) { MyCellCoord coord2 = new MyCellCoord(); coord2.SetUnpack(pair2.Key); MyOctreeNode node2 = pair2.Value; for (int i = 0; i < 8; i++) { if (!node2.HasChild(i)) { Vector3I vectori3; this.ComputeChildCoord(i, out vectori3); float num3 = ((float)node2.GetData(i)) / 255f; if (num3 != 0f) { BoundingBoxD xd2; num3 = (float)Math.Pow(num3 * 1.0, 0.3333); Vector3I vectori4 = (Vector3I)((coord2.CoordInLod << (coord2.Lod + 1)) + (vectori3 << coord2.Lod)); float num4 = 1f * (1 << (coord2.Lod & 0x1f)); Vector3 vector = (worldPos + (vectori4 * 1f)) + (0.5f * num4); xd2.Min = vector - ((0.5f * num3) * num4); xd2.Max = vector + ((0.5f * num3) * num4); nullable = null; batch.Add(ref xd2, nullable); } } } } }