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


C# MyCellCoord.SetUnpack方法代码示例

本文整理汇总了C#中VRage.Voxels.MyCellCoord.SetUnpack方法的典型用法代码示例。如果您正苦于以下问题:C# MyCellCoord.SetUnpack方法的具体用法?C# MyCellCoord.SetUnpack怎么用?C# MyCellCoord.SetUnpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VRage.Voxels.MyCellCoord的用法示例。


在下文中一共展示了MyCellCoord.SetUnpack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawScaledNodes

        private static void DrawScaledNodes(ref Matrix worldMatrix, Color color, Dictionary<UInt64, MyOctreeNode> octree)
        {
            using (var batch = MyRenderProxy.DebugDrawBatchAABB(worldMatrix, color, true, true))
            {
                MyCellCoord cell = new MyCellCoord();
                foreach (var entry in octree)
                {
                    cell.SetUnpack(entry.Key);
                    cell.Lod += LeafLodCount;
                    var data = entry.Value;
                    for (int i = 0; i < MyOctreeNode.CHILD_COUNT; ++i)
                    {
                        if (data.HasChild(i) && cell.Lod != LeafLodCount)
                            continue;
                        Vector3I childOffset;
                        ComputeChildCoord(i, out childOffset);
                        float ratio = data.GetData(i) / MyVoxelConstants.VOXEL_CONTENT_FULL_FLOAT;
                        if (ratio == 0f)
                            continue;

                        var voxelPos = (cell.CoordInLod << (cell.Lod + 1)) + (childOffset << cell.Lod);
                        var lodSize = MyVoxelConstants.VOXEL_SIZE_IN_METRES * (1 << cell.Lod);
                        var center = voxelPos * MyVoxelConstants.VOXEL_SIZE_IN_METRES + 0.5f * lodSize;
                        ratio = (float)Math.Pow((double)ratio * MyVoxelConstants.VOXEL_VOLUME_IN_METERS, 0.3333);
                        lodSize *= ratio;
                        BoundingBoxD bb = new BoundingBoxD(
                            center - 0.5f * lodSize,
                            center + 0.5f * lodSize);
                        batch.Add(ref bb);
                    }
                }
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:33,代码来源:MyOctreeStorage.cs

示例2: DrawSparseOctrees

        private static void DrawSparseOctrees(ref Matrix worldMatrix, Color color, MyVoxelDebugDrawMode mode, Dictionary<UInt64, IMyOctreeLeafNode> octree)
        {
            var camera = Sandbox.Game.World.MySector.MainCamera;
            if (camera == null)
                return;
            var targetPoint = camera.Position + camera.ForwardVector * 10;
            targetPoint = (Vector3)Vector3D.Transform(targetPoint, MatrixD.Invert(worldMatrix));

            using (var batch = VRageRender.MyRenderProxy.DebugDrawBatchAABB(worldMatrix, color, true, true))
            {
                MyCellCoord cell = new MyCellCoord();
                foreach (var entry in octree)
                {
                    var leaf = entry.Value as MyMicroOctreeLeaf;
                    if (leaf != null)
                    {
                        cell.SetUnpack(entry.Key);
                        Vector3D min = (cell.CoordInLod << LeafLodCount) * MyVoxelConstants.VOXEL_SIZE_IN_METRES;
                        Vector3D max = min + LeafSizeInVoxels * MyVoxelConstants.VOXEL_SIZE_IN_METRES;
                        if (targetPoint.IsInsideInclusive(ref min, ref max))
                            leaf.DebugDraw(batch, min, mode);
                    }
                }
            }
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:25,代码来源:MyOctreeStorage.cs

示例3: UpdateCellsInScene

            internal void UpdateCellsInScene(Vector3D localPosition)
            {
                LodLevel parentLod, childLod;
                GetNearbyLodLevels(out parentLod, out childLod);

                MyCellCoord thisLodCell = new MyCellCoord();
                foreach (var entry in m_nonEmptyCells)
                {
                    var data = entry.Value;
                    Debug.Assert(data.Cell != null);
                    thisLodCell.SetUnpack(entry.Key);

                    if (ChildrenWereLoaded(childLod, ref thisLodCell) || !AllSiblingsWereLoaded(ref thisLodCell))
                    {
                            RemoveFromScene(entry.Key, data);
                        }
                        else
                        {
                            AddToScene(entry.Key, data);
                        //data.Cell.PixelDiscardEnabled = false;
                        }
                    }
                        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:23,代码来源:MyClipmap.cs

示例4: DrawLeaves

 private static void DrawLeaves(ref Matrix worldMatrix, Color color, Dictionary<UInt64, IMyOctreeLeafNode> octree)
 {
     using (var batch = MyRenderProxy.DebugDrawBatchAABB(worldMatrix, color, true, true))
     {
         MyCellCoord cell = new MyCellCoord();
         foreach (var entry in octree)
         {
             cell.SetUnpack(entry.Key);
             cell.Lod += LeafLodCount;
             var data = entry.Value;
             var voxelPos = cell.CoordInLod << cell.Lod;
             var bb = new BoundingBoxD(
                 voxelPos * MyVoxelConstants.VOXEL_SIZE_IN_METRES,
                 (voxelPos + (1 << cell.Lod)) * MyVoxelConstants.VOXEL_SIZE_IN_METRES);
             batch.Add(ref bb);
         }
     }
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:18,代码来源:MyOctreeStorage.cs

示例5: DebugDraw

        public void DebugDraw()
        {
            if (MyFakes.DEBUG_DRAW_NAVMESH_EXPLORED_HL_CELLS)
            {
                foreach (var cell in m_exploredCells)
                {
                    BoundingBoxD cellAABB;
                    Vector3I cellCopy = cell;

                    MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(m_mesh.VoxelMapReferencePosition, ref cellCopy, out cellAABB);

                    VRageRender.MyRenderProxy.DebugDrawAABB(cellAABB, Color.Sienna, 1.0f, 1.0f, false);
                }
            }

            if (MyFakes.DEBUG_DRAW_NAVMESH_FRINGE_HL_CELLS)
            {
                foreach (var packedCoord in m_navmeshComponents.GetPresentCells())
                {
                    MyCellCoord coord = new MyCellCoord();
                    coord.SetUnpack(packedCoord);
                    Vector3I cellCoord = coord.CoordInLod;

                    if (m_exploredCells.Contains(ref cellCoord))
                    {
                        MyNavmeshComponents.CellInfo cellInfo = new MyNavmeshComponents.CellInfo();
                        if (m_navmeshComponents.TryGetCell(packedCoord, out cellInfo))
                        {
                            for (int i = 0; i < cellInfo.ComponentNum; ++i)
                            {
                                int componentIndex = cellInfo.StartingIndex + i;
                                var primitive = m_mesh.HighLevelGroup.GetPrimitive(componentIndex);
                                foreach (var direction in Base6Directions.EnumDirections)
                                {
                                    var dirFlag = Base6Directions.GetDirectionFlag(direction);
                                    if (cellInfo.ExploredDirections.HasFlag(dirFlag))
                                    {
                                        continue;
                                    }

                                    if (m_exploredCells.Contains(cellCoord + Base6Directions.GetIntVector(direction)))
                                    {
                                        continue;
                                    }

                                    Vector3 dirVec = Base6Directions.GetVector(direction);
                                    VRageRender.MyRenderProxy.DebugDrawLine3D(primitive.WorldPosition, primitive.WorldPosition + dirVec * 3.0f, Color.Red, Color.Red, false);
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:54,代码来源:MyVoxelHighLevelHelper.cs

示例6: KeepOrDiscardClippedCells

            internal void KeepOrDiscardClippedCells(RequestCollector collector)
            {
                LodLevel parentLod, childLod;
                GetNearbyLodLevels(out parentLod, out childLod);

                MyCellCoord thisLodCell = new MyCellCoord();
                foreach (var entry in m_clippedCells)
                {
                    var data = entry.Value;
                    bool needed = false;

                    // too far, but less detailed data might be missing so we still check parent
                    thisLodCell.SetUnpack(entry.Key);
                    needed = !WasAncestorCellLoaded(parentLod, ref thisLodCell);

                    if (needed)
                    {
                        if (data.State == CellState.Invalid)
                        {
                            collector.AddRequest(entry.Key, data.WasLoaded);
                            data.State = CellState.Pending;
                        }

                        m_storedCellData.Add(entry.Key, data);
                    }
                    else
                    {
                        if (data.State == CellState.Pending)
                            collector.CancelRequest(entry.Key);
                        if (data.Cell != null)
                            Delete(entry.Key, data);
                    }
                }

                m_clippedCells.Clear();
            }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:36,代码来源:MyClipmap.cs

示例7: RemoveExplored

        private void RemoveExplored(ulong packedCoord)
        {
            MyCellCoord coord = new MyCellCoord();
            coord.SetUnpack(packedCoord);

            m_exploredCells.Remove(ref coord.CoordInLod);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyVoxelHighLevelHelper.cs

示例8: KeepOrDiscardClippedCells

            internal void KeepOrDiscardClippedCells(RequestCollector collector)
            {
                LodLevel parentLod, childLod;
                GetNearbyLodLevels(out parentLod, out childLod);

                MyCellCoord thisLodCell = new MyCellCoord();
                foreach (var entry in m_clippedCells)
                {
                    var data = entry.Value;
                    bool needed = false;

                    // too far, but less detailed data might be missing so we still check parent
                    thisLodCell.SetUnpack(entry.Key);
                    needed = !WasAncestorCellLoaded(parentLod, ref thisLodCell);

                    if (needed)
                    {
                        if (data.State == CellState.Invalid)
                        {
                            if (!TryAddCellRequest(collector, parentLod, thisLodCell, entry.Key, data))
                                continue;
                        }

                        m_storedCellData.Add(entry.Key, data);
                    }
                    else
                    {
                        if (UseCache && data.State == CellState.Loaded)
                        {
                            var clipmapCellId = MyCellCoord.GetClipmapCellHash(m_clipmap.Id, entry.Key);

                            CellsCache.Write(clipmapCellId, data);
                            Delete(entry.Key, data, false);
                        }
                        else
                        {
                            if (data.State == CellState.Pending)
                                collector.CancelRequest(entry.Key);
                            if (data.Cell != null)
                                Delete(entry.Key, data);
                        }

                        if (!UseCache)
                        {
                            CellsCache.Reset();
                        }
                    }
                }

                m_clippedCells.Clear();
            }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:51,代码来源:MyClipmap.LodLevel.cs

示例9: GetComponent

        public IMyHighLevelComponent GetComponent(MyHighLevelPrimitive primitive)
        {
            ulong cellIndex;
            if (m_navmeshComponents.GetComponentCell(primitive.Index, out cellIndex))
            {
                Base6Directions.DirectionFlags exploredDirections;
                
                if (m_navmeshComponents.GetComponentInfo(primitive.Index, cellIndex, out exploredDirections))
                {
                    MyCellCoord coord = new MyCellCoord();
                    coord.SetUnpack(cellIndex);

                    // Look at present unexplored cells around this cell.
                    // Their direction can be marked as explored, because there was no geometry when they were being explored
                    foreach (var direction in Base6Directions.EnumDirections)
                    {
                        var directionFlag = Base6Directions.GetDirectionFlag(direction);
                        if (exploredDirections.HasFlag(directionFlag))
                        {
                            continue;
                        }

                        Vector3I neighbor = coord.CoordInLod + Base6Directions.GetIntVector(direction);
                        if (m_exploredCells.Contains(ref neighbor))
                        {
                            exploredDirections |= directionFlag;
                        }
                    }

                    return new Component(primitive.Index, exploredDirections);
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:41,代码来源:MyVoxelHighLevelHelper.cs

示例10: TryClearCell

        public void TryClearCell(ulong packedCoord)
        {
            if (m_triangleLists.ContainsKey(packedCoord))
            {
                ClearCachedCell(packedCoord);
            }

            RemoveExplored(packedCoord);

            MyNavmeshComponents.CellInfo cellInfo;
            if (!m_navmeshComponents.TryGetCell(packedCoord, out cellInfo))
            {
                return;
            }

            for (int i = 0; i < cellInfo.ComponentNum; ++i)
            {
                int componentIndex = cellInfo.StartingIndex + i;
                m_mesh.HighLevelGroup.RemovePrimitive(componentIndex);
            }

            foreach (var direction in Base6Directions.EnumDirections)
            {
                Base6Directions.DirectionFlags dirFlag = Base6Directions.GetDirectionFlag(direction);
                if (cellInfo.ExploredDirections.HasFlag(dirFlag))
                {
                    Vector3I dirVec = Base6Directions.GetIntVector(direction);

                    MyCellCoord otherCoord = new MyCellCoord();
                    otherCoord.SetUnpack(packedCoord);
                    Debug.Assert(otherCoord.Lod == MyVoxelNavigationMesh.NAVMESH_LOD);
                    otherCoord.CoordInLod = otherCoord.CoordInLod + dirVec;

                    MyNavmeshComponents.CellInfo otherCellInfo;

                    if (m_navmeshComponents.TryGetCell(otherCoord.PackId64(), out otherCellInfo))
                    {
                        Base6Directions.DirectionFlags flippedFlag = Base6Directions.GetDirectionFlag(Base6Directions.GetFlippedDirection(direction));
                        m_navmeshComponents.SetExplored(otherCoord.PackId64(), otherCellInfo.ExploredDirections & ~flippedFlag);
                    }
                    else
                    {
                        Debug.Assert(false, "Could not get the oposite explored cell!");
                    }
                }
            }

            m_navmeshComponents.ClearCell(packedCoord, ref cellInfo);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:49,代码来源:MyVoxelHighLevelHelper.cs

示例11: UpdateCellsInScene

            internal void UpdateCellsInScene(float cameraDistance, Vector3D localPosition)
            {
                LodLevel parentLod, childLod;
                GetNearbyLodLevels(out parentLod, out childLod);

                MyCellCoord thisLodCell = new MyCellCoord();
                foreach (var entry in m_nonEmptyCells)
                {
                    var data = entry.Value;
                    Debug.Assert(data.Cell != null, "Empty cell in m_nonEmptyCells!");
                    if (data.Cell != null)
                    {
                        thisLodCell.SetUnpack(entry.Key);

                        if (ChildrenWereLoaded(childLod, ref thisLodCell)
                            ||
                        (MyVoxelCoordSystems.RenderCellSizeShiftToLessDetailed(thisLodCell.Lod) == 1 && !AllSiblingsWereLoaded(ref thisLodCell))
                            ||
                            !ShouldBeThisLodVisible(cameraDistance)
                            )
                        {
                            RemoveFromScene(entry.Key, data);
                        }
                        else
                        {
                            AddToScene(entry.Key, data);
                        }
                    }
                }
            }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:30,代码来源:MyClipmap.LodLevel.cs

示例12: DebugDraw

            public void DebugDraw()
            {
                //if (m_lodIndex > 5)
                //    return;


    //            if (m_lodIndex == 1)
    //            {
    //                float sizeInMetres = MyVoxelCoordSystems.RenderCellSizeInMeters(m_lodIndex);

    //                //var start = localFarCameraBox.Min;
    //                //var end = localFarCameraBox.Max;
    //                var start = m_localNearCameraBox.Min;
    //                var end = m_localNearCameraBox.Max;
    //                Vector3I coord = start;

    //                Color nearColor = Color.Yellow;
    //                Color farColor = Color.White;

    //                var startF = m_localFarCameraBox.Min;
    //                var endF = m_localFarCameraBox.Max;
    //                Vector3I coordF = startF;

    ////                for (var it = new Vector3I_RangeIterator(ref startF, ref endF);
    ////it.IsValid(); it.GetNext(out coordF))
    ////                {
    ////                    Vector3D min = Vector3D.Transform((Vector3D)(sizeInMetres * coordF), m_parent.m_worldMatrix);
    ////                    Vector3D max = Vector3D.Transform((Vector3D)(sizeInMetres * coordF + new Vector3(sizeInMetres)), m_parent.m_worldMatrix);

    ////                    BoundingBoxD aabb = new BoundingBoxD(min, max);
    ////                    MyRenderProxy.DebugDrawAABB(aabb, farColor, 1, 1, false);

    ////                    if (Vector3D.Distance(CameraFrustumGetter().Matrix.Translation, aabb.Center) < 200)
    ////                        MyRenderProxy.DebugDrawText3D(aabb.Center, coordF.ToString(), farColor, 0.5f, false);
    ////                }


    //                for (var it = new Vector3I_RangeIterator(ref start, ref end);
    //it.IsValid(); it.GetNext(out coord))
    //                {
    //                    Vector3D min = Vector3D.Transform((Vector3D)(sizeInMetres * coord), m_clipmap.m_worldMatrix);
    //                    Vector3D max = Vector3D.Transform((Vector3D)(sizeInMetres * coord + new Vector3(sizeInMetres)), m_clipmap.m_worldMatrix);

    //                    BoundingBoxD aabb = new BoundingBoxD(min, max);
    //                    MyRenderProxy.DebugDrawAABB(aabb, nearColor, 1, 1, false);
    //                }


    //                Vector3D center = Vector3D.Transform(m_localPosition, m_clipmap.m_worldMatrix);

    //                MyRenderProxy.DebugDrawSphere(center, m_nearDistance, nearColor, 1, false);
    //                MyRenderProxy.DebugDrawSphere(center, m_farDistance, farColor, 1, false);

    //            }

                var camera = m_clipmap.LastCameraPosition;

                //if (m_lodIndex < 6)
                {
                    float sizeInMetres = MyVoxelCoordSystems.RenderCellSizeInMeters(m_lodIndex);
                    Color color = LOD_COLORS[m_lodIndex] + new Vector4(0.2f);


                    foreach (var cell in m_storedCellData)
                    {
                        if (!cell.Value.InScene)
                            continue;

                        MyCellCoord cellStr = new MyCellCoord();
                        cellStr.SetUnpack(cell.Key);
                        var coordF = cellStr.CoordInLod;

                        Vector3D min = Vector3D.Transform((Vector3D)(sizeInMetres * coordF), m_clipmap.m_worldMatrix);
                        Vector3D max = Vector3D.Transform((Vector3D)(sizeInMetres * coordF + new Vector3(sizeInMetres)), m_clipmap.m_worldMatrix);

                        BoundingBoxD aabb = new BoundingBoxD(min, max);
                        double distance = Vector3D.Distance(camera, aabb.Center);
                        //if (distance < sizeInMetres * 4)
                            MyRenderProxy.DebugDrawAABB(aabb, color, 1, 1, true);
                        if (distance < sizeInMetres * 2)
                            MyRenderProxy.DebugDrawText3D(aabb.Center, String.Format("{0}:{1}", m_lodIndex, coordF.ToString()), color, 0.7f, false);
                    }

                    if (m_storedCellData.Count > 0)
                    {
                        Vector3D center = Vector3D.Transform(m_localPosition, m_clipmap.m_worldMatrix);
                        //MyRenderProxy.DebugDrawSphere(center, m_farDistance, color, 1, false);
                    }

                }
            }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:91,代码来源:MyClipmap.LodLevel.cs

示例13: UpdateCellsInScene

            internal void UpdateCellsInScene(Vector3D localPosition)
            {
                LodLevel parentLod, childLod;
                GetNearbyLodLevels(out parentLod, out childLod);

                MyCellCoord thisLodCell = new MyCellCoord();
                foreach (var entry in m_nonEmptyCells)
                {
                    var data = entry.Value;
                    Debug.Assert(data.Cell != null);
                    thisLodCell.SetUnpack(entry.Key);

                    if (NEW_VOXEL_CLIPPING)
                    {
                        var siblingsLoaded = AllSiblingsWereLoaded(ref thisLodCell);
                        if (ChildrenWereLoaded(childLod, ref thisLodCell) && siblingsLoaded)
                        {
                            RemoveFromScene(entry.Key, data);
                        }
                        else
                        {
                            AddToScene(entry.Key, data);
                        }
                    }
                    else
                    {
                        if (ChildrenWereLoaded(childLod, ref thisLodCell)
                            ||
                     (MyVoxelCoordSystems.RenderCellSizeShiftToLessDetailed(thisLodCell.Lod) == 1 && !AllSiblingsWereLoaded(ref thisLodCell))
                            )
                        {
                            RemoveFromScene(entry.Key, data);
                        }
                        else
                        {
                            AddToScene(entry.Key, data);
                        }
                    }
                }
            }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:40,代码来源:MyClipmap.LodLevel.cs

示例14: LoadInternal

        protected override void LoadInternal(int fileVersion, Stream stream, ref bool isOldFormat)
        {
            Debug.Assert(fileVersion == CURRENT_FILE_VERSION);

            ChunkHeader header = new ChunkHeader();
            Dictionary<byte, MyVoxelMaterialDefinition> materialTable = null;
            HashSet<UInt64> materialLeaves = new HashSet<UInt64>();
            HashSet<UInt64> contentLeaves = new HashSet<UInt64>();
            while (header.ChunkType != ChunkTypeEnum.EndOfFile)
            {
                MyMicroOctreeLeaf contentLeaf;
                MyMicroOctreeLeaf materialLeaf;
                UInt64 key;

                header.ReadFrom(stream);
                Debug.Assert(Enum.IsDefined(typeof(ChunkTypeEnum), header.ChunkType));

                switch (header.ChunkType)
                {
                    case ChunkTypeEnum.StorageMetaData:
                        ReadStorageMetaData(stream, header, ref isOldFormat);
                        break;

                    case ChunkTypeEnum.MaterialIndexTable:
                        materialTable = ReadMaterialTable(stream, header, ref isOldFormat);
                        break;

                    case ChunkTypeEnum.MacroContentNodes:
                        ReadOctreeNodes(stream, header, ref isOldFormat, m_contentNodes);
                        break;

                    case ChunkTypeEnum.MacroMaterialNodes:
                        ReadOctreeNodes(stream, header, ref isOldFormat, m_materialNodes);
                        break;

                    case ChunkTypeEnum.ContentLeafProvider:
                        ReadProviderLeaf(stream, header, ref isOldFormat, contentLeaves);
                        break;

                    case ChunkTypeEnum.ContentLeafOctree:
                        ReadOctreeLeaf(stream, header, ref isOldFormat, MyStorageDataTypeEnum.Content, out key, out contentLeaf);
                        m_contentLeaves.Add(key, contentLeaf);
                        break;

                    case ChunkTypeEnum.MaterialLeafProvider:
                        ReadProviderLeaf(stream, header, ref isOldFormat, materialLeaves);
                        break;

                    case ChunkTypeEnum.MaterialLeafOctree:
                        ReadOctreeLeaf(stream, header, ref isOldFormat, MyStorageDataTypeEnum.Material, out key, out materialLeaf);
                        m_materialLeaves.Add(key, materialLeaf);
                        break;

                    case ChunkTypeEnum.DataProvider:
                        ReadDataProvider(stream, header, ref isOldFormat, out m_dataProvider);
                        break;

                    case ChunkTypeEnum.EndOfFile:
                        break;

                    default:
                        throw new InvalidBranchException();
                }
            }

            { // At this point data provider should be loaded too, so have him create leaves
                MyCellCoord cell = new MyCellCoord();
                foreach (var key in contentLeaves)
                {
                    cell.SetUnpack(key);
                    cell.Lod += LeafLodCount;
                    m_contentLeaves.Add(key, new MyProviderLeaf(m_dataProvider, MyStorageDataTypeEnum.Content, ref cell));
                }

                foreach (var key in materialLeaves)
                {
                    cell.SetUnpack(key);
                    cell.Lod += LeafLodCount;
                    m_materialLeaves.Add(key, new MyProviderLeaf(m_dataProvider, MyStorageDataTypeEnum.Material, ref cell));
                }
            }

            { // material reindexing when definitions change
                Debug.Assert(materialTable != null);
                bool needsReindexing = false;
                foreach (var entry in materialTable)
                {
                    if (entry.Key != entry.Value.Index)
                        needsReindexing = true;
                    m_oldToNewIndexMap.Add(entry.Key, entry.Value.Index);
                }

                if (needsReindexing)
                {
                    if (m_dataProvider != null)
                    {
                        m_dataProvider.ReindexMaterials(m_oldToNewIndexMap);
                    }

                    foreach (var entry in m_materialLeaves)
//.........这里部分代码省略.........
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:101,代码来源:MyOctreeStorage.cs

示例15: ProcessTriangleForHierarchy

        private bool ProcessTriangleForHierarchy(MyNavigationTriangle triangle)
        {
            // The triangle parent can be wrong when we have multiple navmeshes connected via external edges
            if (triangle.Parent != m_mesh)
            {
                return false;
            }

            if (triangle.ComponentIndex == -1)
            {
                m_navmeshComponents.AddComponentTriangle(triangle, triangle.Center);
                triangle.ComponentIndex = m_navmeshComponents.OpenComponentIndex;
                return true;
            }
            else if (triangle.ComponentIndex == m_navmeshComponents.OpenComponentIndex)
            {
                return true;
            }
            else
            {
                ulong cellIndex;
                if (m_navmeshComponents.GetComponentCell(triangle.ComponentIndex, out cellIndex))
                {
                    MyCellCoord cellCoord = new MyCellCoord();
                    cellCoord.SetUnpack(cellIndex);
                    Vector3I diff = cellCoord.CoordInLod - m_currentCell;
                    if (diff.RectangularLength() != 1)
                    {
                        // CH: TODO: Connection of components over cell edges or vertices. I currently silently ignore that...
                        return false;
                    }

                    ConnectionInfo connection = new ConnectionInfo();
                    connection.Direction = Base6Directions.GetDirection(diff);
                    connection.ComponentIndex = triangle.ComponentIndex;

                    // Save connections to other components. There won't be so many, so we can keep them in a list instead of a HashSet
                    if (!m_currentCellConnections[m_currentComponentRel].Contains(connection))
                    {
                        m_currentCellConnections[m_currentComponentRel].Add(connection);
                    }
                }
            }
            return false;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:45,代码来源:MyVoxelHighLevelHelper.cs


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