本文整理汇总了C#中Vector3I.DistanceSquared方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3I.DistanceSquared方法的具体用法?C# Vector3I.DistanceSquared怎么用?C# Vector3I.DistanceSquared使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3I
的用法示例。
在下文中一共展示了Vector3I.DistanceSquared方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformRead
private void PerformRead()
{
try
{
if (m_voxel == null || m_voxel.Storage == null)
return;
Vector3I size = m_localMax - m_localMin;
m_logger.debugLog("number of coords in box: " + (size.X + 1) * (size.Y + 1) * (size.Z + 1), "PerformRead()");
ulong processed = 0;
m_materialLocations.Clear();
Vector3I vector = new Vector3I();
for (vector.X = m_localMin.X; vector.X < m_localMax.X; vector.X += QUERY_STEP)
for (vector.Y = m_localMin.Y; vector.Y < m_localMax.Y; vector.Y += QUERY_STEP)
for (vector.Z = m_localMin.Z; vector.Z < m_localMax.Z; vector.Z += QUERY_STEP)
if (vector.DistanceSquared(odPosVoxelStorage) <= rangeSquared)
{
m_voxel.Storage.ReadRange(m_storage, MyStorageDataTypeFlags.ContentAndMaterial, QUERY_LOD, vector, vector + QUERY_MAX);
Vector3I index = Vector3I.Zero;
Vector3I size3D = m_storage.Size3D;
for (index.X = 0; index.X < size3D.X; index.X++)
for (index.Y = 0; index.Y < size3D.Y; index.Y++)
for (index.Z = 0; index.Z < size3D.Z; index.Z++)
{
int linear = m_storage.ComputeLinear(ref index);
if (m_storage.Content(linear) > MyVoxelConstants.VOXEL_ISO_LEVEL)
{
byte mat = m_storage.Material(linear);
if (RareMaterials[mat])
{
//m_logger.debugLog("mat: " + mat + ", content: " + m_storage.Content(linear) + ", vector: " + vector + ", position: " + vector + index
// + ", name: " + MyDefinitionManager.Static.GetVoxelMaterialDefinition(mat).MinedOre, "PerformRead()");
m_materialLocations[vector + index] = mat;
processed++;
goto Finished_Deposit;
}
}
}
Finished_Deposit:
processed++;
}
m_logger.debugLog("read " + processed + " chunks" + ", number of mats: " + m_materialLocations.Count, "PerformRead()", Logger.severity.DEBUG);
}
finally
{
lock_readVoxels.ReleaseExclusive();
onFinished.Invoke();
}
}
示例2: Read
/// <summary>
/// Start the reads if it is not already running.
/// </summary>
/// <param name="onFinished">Invoked when reads finish, not invoked if already running.</param>
/// <returns>True if started, false if already running.</returns>
public void Read()
{
using (lock_throwOut.AcquireExclusiveUsing())
m_throwOutVoxelData = Globals.ElapsedTime + LifeSpan_VoxelData;
NeedsUpdate = false;
Vector3D m_oreDetectorPosition = m_oreDetector.GetPosition();
Vector3D worldMin = m_oreDetectorPosition - m_maxRange;
Vector3D worldMax = m_oreDetectorPosition + m_maxRange;
float rangeSquared = m_maxRange * m_maxRange;
Vector3I odPosVoxelStorage, m_localMin, m_localMax;
MyVoxelCoordSystems.WorldPositionToVoxelCoord(m_voxel.PositionLeftBottomCorner, ref m_oreDetectorPosition, out odPosVoxelStorage);
MyVoxelCoordSystems.WorldPositionToVoxelCoord(m_voxel.PositionLeftBottomCorner, ref worldMin, out m_localMin);
MyVoxelCoordSystems.WorldPositionToVoxelCoord(m_voxel.PositionLeftBottomCorner, ref worldMax, out m_localMax);
MyVoxelBase vox = m_voxel as MyVoxelBase;
if (m_voxel == null || m_voxel.Storage == null)
return;
m_localMin = Vector3I.Clamp(m_localMin, vox.StorageMin, vox.StorageMax);
m_localMax = Vector3I.Clamp(m_localMax, vox.StorageMin, vox.StorageMax);
m_localMin >>= QUERY_LOD;
m_localMax >>= QUERY_LOD;
odPosVoxelStorage >>= QUERY_LOD;
m_logger.debugLog("minLocal: " + m_localMin + ", maxLocal: " + m_localMax + ", odPosVoxelStorage: " + odPosVoxelStorage);
Vector3I size = m_localMax - m_localMin;
m_logger.debugLog("number of coords in box: " + (size.X + 1) * (size.Y + 1) * (size.Z + 1));
ulong processed = 0;
m_materialLocations.Clear();
Vector3I vector = new Vector3I();
for (vector.X = m_localMin.X; vector.X < m_localMax.X; vector.X += QUERY_STEP)
for (vector.Y = m_localMin.Y; vector.Y < m_localMax.Y; vector.Y += QUERY_STEP)
for (vector.Z = m_localMin.Z; vector.Z < m_localMax.Z; vector.Z += QUERY_STEP)
if (vector.DistanceSquared(odPosVoxelStorage) <= rangeSquared)
{
m_voxel.Storage.ReadRange(m_storage, MyStorageDataTypeFlags.ContentAndMaterial, QUERY_LOD, vector, vector + QUERY_MAX);
Vector3I index = Vector3I.Zero;
Vector3I size3D = m_storage.Size3D;
for (index.X = 0; index.X < size3D.X; index.X++)
for (index.Y = 0; index.Y < size3D.Y; index.Y++)
for (index.Z = 0; index.Z < size3D.Z; index.Z++)
{
int linear = m_storage.ComputeLinear(ref index);
if (m_storage.Content(linear) > MyVoxelConstants.VOXEL_ISO_LEVEL)
{
byte mat = m_storage.Material(linear);
if (RareMaterials[mat])
{
//m_logger.debugLog("mat: " + mat + ", content: " + m_storage.Content(linear) + ", vector: " + vector + ", position: " + vector + index
// + ", name: " + MyDefinitionManager.Static.GetVoxelMaterialDefinition(mat).MinedOre, "Read()");
m_materialLocations[vector + index] = mat;
processed++;
goto Finished_Deposit;
}
}
}
Finished_Deposit:
processed++;
}
m_logger.debugLog("read " + processed + ", chunks" + ", number of mats: " + m_materialLocations.Count, Logger.severity.DEBUG);
}