public void ReadLod(MyStorageData target, MyStorageDataTypeFlags dataTypes, ref Vector3I targetOffset, int lodIndex, ref Vector3I min, ref Vector3I max) { Debug.Assert(min.IsInsideInclusive(Vector3I.Zero, MaxVector >> lodIndex) && max.IsInsideInclusive(Vector3I.Zero, MaxVector >> lodIndex)); //using (Lock.AcquireSharedUsing()) { if (lodIndex > m_maxLod) { UpdateLodData(lodIndex); } if (dataTypes.Requests(MyStorageDataTypeEnum.Content)) { ReadLod(target, MyStorageDataTypeEnum.Content, Content, targetOffset, lodIndex, min, max); } if (dataTypes.Requests(MyStorageDataTypeEnum.Material)) { ReadLod(target, MyStorageDataTypeEnum.Material, Material, targetOffset, lodIndex, min, max); } } HitCount++; }
private int GetDivideIndex(ref Vector3I renderCellCoord) { // TODO: Optimize int divideIndex = 0; if (m_lodDivisions > 1) { BoundingBoxD lodAabb = m_boundingBoxes.GetAabb(m_boundingBoxes.GetRoot()); Vector3I test = Vector3I.Round(lodAabb.Size / (double)MyVoxelCoordSystems.RenderCellSizeInMeters(m_lod)); //Vector3I lodSizeMinusOne = m_parentClipmap.LodSizeMinusOne(m_lod); //Vector3I lodSize = lodSizeMinusOne + Vector3I.One; Vector3I lodSize = test; Vector3I lodSizeMinusOne = test - 1; Vector3I lodDivision = Vector3I.One * (m_lodDivisions - 1); var cellIterator = new Vector3I.RangeIterator(ref Vector3I.Zero, ref lodDivision); for (; cellIterator.IsValid(); cellIterator.MoveNext()) { Vector3I currentDivision = cellIterator.Current; Vector3I min = currentDivision * lodSize / m_lodDivisions; Vector3I max = (currentDivision + Vector3I.One) * lodSize / m_lodDivisions; if (renderCellCoord.IsInsideInclusive(ref min, ref max)) { break; } } Debug.Assert(cellIterator.IsValid(), "Valid division index not found!"); Vector3I foundCell = cellIterator.Current; divideIndex = GetDivideIndexFromMergeCell(ref foundCell); } return(divideIndex); }
private void AssertRangeIsInside(int lodIndex, ref Vector3I globalMin, ref Vector3I globalMax) { var leafMinInLod = m_leafMin >> lodIndex; var leafMaxInLod = m_leafMax >> lodIndex; Debug.Assert(globalMin.IsInsideInclusive(ref leafMinInLod, ref leafMaxInLod)); Debug.Assert(globalMax.IsInsideInclusive(ref leafMinInLod, ref leafMaxInLod)); }
private void AssertRangeIsInside(int lodIndex, ref Vector3I globalMin, ref Vector3I globalMax) { Debug.Assert(m_cell.Lod >= lodIndex); var lodShift = m_cell.Lod - lodIndex; var lodSize = 1 << lodShift; var leafMinInLod = m_cell.CoordInLod << lodShift; var leafMaxInLod = leafMinInLod + (lodSize - 1); Debug.Assert(globalMin.IsInsideInclusive(ref leafMinInLod, ref leafMaxInLod)); Debug.Assert(globalMax.IsInsideInclusive(ref leafMinInLod, ref leafMaxInLod)); }
public void OnStorageChanged(Vector3I minChanged, Vector3I maxChanged, MyStorageDataTypeFlags dataChanged) { ProfilerShort.Begin("MyVoxelMap::storage_RangeChanged"); minChanged = Vector3I.Clamp(minChanged, m_storageMin, m_storageMax); maxChanged = Vector3I.Clamp(maxChanged, m_storageMin, m_storageMax); Debug.Assert(minChanged.IsInsideInclusive(ref m_storageMin, ref m_storageMax) && maxChanged.IsInsideInclusive(ref m_storageMin, ref m_storageMax)); // Physics doesn't care about materials, just shape of things. if ((dataChanged & MyStorageDataTypeFlags.Content) != 0 && Physics != null) { Physics.InvalidateRange(minChanged, maxChanged); } ProfilerShort.End(); }
/// <summary> /// Invalidates voxel cache /// </summary> /// <param name="minChanged">Inclusive min</param> /// <param name="maxChanged">Inclusive max</param> private void storage_RangeChanged(Vector3I minChanged, Vector3I maxChanged, MyStorageDataTypeFlags dataChanged) { ProfilerShort.Begin("MyVoxelMap::storage_RangeChanged"); Debug.Assert(minChanged.IsInsideInclusive(ref m_storageMin, ref m_storageMax) && maxChanged.IsInsideInclusive(ref m_storageMin, ref m_storageMax)); // Physics doesn't care about materials, just shape of things. if ((dataChanged & MyStorageDataTypeFlags.Content) != 0 && Physics != null) { Physics.InvalidateRange(minChanged, maxChanged); } if (Render is MyRenderComponentVoxelMap) { (Render as MyRenderComponentVoxelMap).InvalidateRange(minChanged, maxChanged); } ProfilerShort.End(); }
public void ReadLod(MyStorageData target, MyStorageDataTypeFlags dataTypes, ref Vector3I targetOffset, int lodIndex, ref Vector3I min, ref Vector3I max) { Debug.Assert(min.IsInsideInclusive(Vector3I.Zero, MaxVector >> lodIndex) && max.IsInsideInclusive(Vector3I.Zero, MaxVector >> lodIndex)); //using (Lock.AcquireSharedUsing()) { if (lodIndex > MaxLod) UpdateLodData(lodIndex); if (dataTypes.Requests(MyStorageDataTypeEnum.Content)) { ReadLod(target, MyStorageDataTypeEnum.Content, Content, targetOffset, lodIndex, min, max); } if (dataTypes.Requests(MyStorageDataTypeEnum.Material)) { ReadLod(target, MyStorageDataTypeEnum.Material, Material, targetOffset, lodIndex, min, max); } } HitCount++; }
private int GetDivideIndex(ref Vector3I renderCellCoord) { // TODO: Optimize int divideIndex = 0; if (m_lodDivisions > 1) { BoundingBoxD lodAabb = m_boundingBoxes.GetAabb(m_boundingBoxes.GetRoot()); Vector3I test = Vector3I.Round(lodAabb.Size / (double)MyVoxelCoordSystems.RenderCellSizeInMeters(m_lod)); //Vector3I lodSizeMinusOne = m_parentClipmap.LodSizeMinusOne(m_lod); //Vector3I lodSize = lodSizeMinusOne + Vector3I.One; Vector3I lodSize = test; Vector3I lodSizeMinusOne = test - 1; Vector3I lodDivision = Vector3I.One * (m_lodDivisions - 1); var cellIterator = new Vector3I.RangeIterator(ref Vector3I.Zero, ref lodDivision); for (; cellIterator.IsValid(); cellIterator.MoveNext()) { Vector3I currentDivision = cellIterator.Current; Vector3I min = currentDivision * lodSize / m_lodDivisions; Vector3I max = (currentDivision + Vector3I.One) * lodSize / m_lodDivisions; if (renderCellCoord.IsInsideInclusive(ref min, ref max)) break; } Debug.Assert(cellIterator.IsValid(), "Valid division index not found!"); Vector3I foundCell = cellIterator.Current; divideIndex = GetDivideIndexFromMergeCell(ref foundCell); } return divideIndex; }
/// <summary> /// Invalidates voxel cache /// </summary> /// <param name="minChanged">Inclusive min</param> /// <param name="maxChanged">Inclusive max</param> private void storage_RangeChanged(Vector3I minChanged, Vector3I maxChanged, MyStorageDataTypeFlags dataChanged) { ProfilerShort.Begin("MyVoxelMap::storage_RangeChanged"); Debug.Assert(minChanged.IsInsideInclusive(ref m_storageMin, ref m_storageMax) && maxChanged.IsInsideInclusive(ref m_storageMin, ref m_storageMax)); // Physics doesn't care about materials, just shape of things. if ((dataChanged & MyStorageDataTypeFlags.Content) != 0 && Physics != null) { Physics.InvalidateRange(minChanged, maxChanged); } if (Render is MyRenderComponentVoxelMap) { (Render as MyRenderComponentVoxelMap).InvalidateRange(minChanged, maxChanged); } ContentChanged = true; ProfilerShort.End(); }