当前位置: 首页>>代码示例>>C#>>正文


C# Vector3I.DistanceSquared方法代码示例

本文整理汇总了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();
				}
			}
开发者ID:Sutima,项目名称:Autopilot,代码行数:53,代码来源:OreDetector.cs

示例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);
            }
开发者ID:Souper07,项目名称:Autopilot,代码行数:73,代码来源:OreDetector.cs


注:本文中的Vector3I.DistanceSquared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。