private Vector3 BirdseyePosition(ChunkView chunkView, ChunkRequest chunkRequest, ChunkFeature chunkFeature, ChunkFeatureView chunkFeatureView) { int depth = ChunkMath.Depth(chunkRequest); int side = ChunkMath.Side(chunkRequest); int depthStartChunkNum = ChunkMath.DepthStartChunkNum(chunkRequest); int sideStartChunkNum = ChunkMath.SideStartChunkNum(chunkRequest); int sideChunkNum = ChunkMath.SideChunkNum(chunkRequest); switch (side) { case 0: return(Position(chunkRequest, chunkReference.Northeast, chunkReference.Northwest, sideChunkNum, depth, chunkFeature, chunkFeatureView)); case 1: return(Position(chunkRequest, chunkReference.East, chunkReference.Northeast, sideChunkNum, depth, chunkFeature, chunkFeatureView)); case 2: return(Position(chunkRequest, chunkReference.Southeast, chunkReference.East, sideChunkNum, depth, chunkFeature, chunkFeatureView)); case 3: return(Position(chunkRequest, chunkReference.Southwest, chunkReference.Southeast, sideChunkNum, depth, chunkFeature, chunkFeatureView)); case 4: return(Position(chunkRequest, chunkReference.West, chunkReference.Southwest, sideChunkNum, depth, chunkFeature, chunkFeatureView)); case 5: return(Position(chunkRequest, chunkReference.Northwest, chunkReference.West, sideChunkNum, depth, chunkFeature, chunkFeatureView)); } Debug.LogError("Failed to compute spiral chunk position"); return(Vector3.zero); }
private List <ChunkFeature> GetUnfittedChunkIndices(ChunkRequest chunkRequest, List <ChunkFeature> chunkFeatures) { List <ChunkFeature> unfittedChunkIndices = new List <ChunkFeature>(); for (int index = 0; index < chunkFeatures.Count; ++index) { ChunkFeature chunkFeature = chunkFeatures[index]; ChunkFeature chunkChainedFeature = chunkFeature; int chunkNumOffset = 0; bool chained = false; while (chunkChainedFeature != null) { ChunkRequest nextChunkRequest = new ChunkRequest() { chunkNum = chunkRequest.chunkNum - chunkNumOffset, }; if (chained && nextChunkRequest.chunkNum != 0 && nextChunkRequest.chunkNum == chunkRequest.sprintEndChunkNum) { unfittedChunkIndices.Add(chunkFeature); break; } int nextDepth = ChunkMath.Depth(nextChunkRequest); int nextDepthStartChunkNum = ChunkMath.DepthStartChunkNum(nextChunkRequest); int nextDepthEndChunkNum = ChunkMath.DepthEndChunkNum(nextChunkRequest); int nextSideChunkNum = ChunkMath.SideChunkNum(nextChunkRequest); // Mark chunk feature to be removed if it hits a corner and it is supposed to skip corners if (chunkChainedFeature.SkipCorners && (chained || nextChunkRequest.chunkNum != nextDepthEndChunkNum) && (nextSideChunkNum == nextDepth - 1 || nextChunkRequest.chunkNum == nextDepthStartChunkNum)) { unfittedChunkIndices.Add(chunkFeature); break; } chunkChainedFeature = chunkChainedFeature.ChunkChainNext; chunkNumOffset++; chained = true; } } return(unfittedChunkIndices); }