private void Start() { simpleChunkColliderPool = new SimpleChunkColliderPool(colliderParent); displayerPool = new MeshDisplayerPool(transform); interactableDisplayerPool = new InteractableMeshDisplayPool(transform); CreateAllBuffersWithSizes(32); TriangulationTableStaticData.BuildLookUpTables(); InitializeDensityGenerator(); ApplyShaderProperties(marshShader); ApplyShaderProperties(rebuildShader); noiseEditShader.SetBuffer(0, "points", pointsBuffer); watch.Start(); buildAroundSqrDistance = (long)buildAroundDistance * buildAroundDistance; startPos = player.position; IMarchingCubeChunk chunk = FindNonEmptyChunkAround(player.position); maxSqrChunkDistance = buildAroundDistance * buildAroundDistance; BuildRelevantChunksParallelBlockingAround(chunk); }
public OutsideEdgeNeighbourDirection(int triangleIndex, Vector2Int edgePair, Vector2Int relevantVertexIndices, Vector3Int offset) { this.triangleIndex = triangleIndex; this.originalEdgePair = edgePair; this.offset = offset; this.relevantVertexIndices = relevantVertexIndices; rotatedEdgePair = TriangulationTableStaticData.RotateEdgeOn( edgePair.x, edgePair.y, TriangulationTableStaticData.GetAxisFromDelta(offset)); }
public List <PathTriangle> GetNeighboursOf(PathTriangle tri) { List <PathTriangle> result = new List <PathTriangle>(); int index = Array.IndexOf(triangles, tri); GetInternNeighbours(result, index); //TODO: check to make structs readonly and other optimations //possibly stop reading first to avoid memcopy OutsideEdgeNeighbourDirection neighbour; List <OutsideEdgeNeighbourDirection> edgeDirs = neighbourData.OutsideNeighbours; int count = edgeDirs.Count; for (int i = 0; i < count; ++i) { neighbour = edgeDirs[i]; if (neighbour.triangleIndex != index) { continue; } Vector3Int newPos = origin + neighbour.offset; MarchingCubeEntity cubeNeighbour; //TODO: store if it is boundary cube else check not necessary if (cubeFinder.IsCubeInBounds(newPos.x, newPos.y, newPos.z)) { cubeNeighbour = cubeFinder.GetEntityAt(newPos); } else { cubeNeighbour = cubeFinder.GetEntityInNeighbourAt(newPos); if (cubeNeighbour == null) { continue; } } OutsideNeighbourConnectionInfo info; if (TriangulationTableStaticData.TryGetNeighbourTriangleIndex( cubeNeighbour.triangulationIndex, neighbour.originalEdgePair.x, neighbour.originalEdgePair.y, out info)) { result.Add(cubeNeighbour.triangles[info.otherTriangleIndex]); } } return(result); }
private void Start() { neighbourFinder = new AsynchronNeighbourFinder(this); ChunkNeighbourTask.chunkGroup = chunkGroup; mainCam = Camera.main; noiseData.ApplyNoiseBiomData(); CreatePools(); ChunkGPUDataRequest.AssignEmptyMinDegreeBuffer(CreateEmptyMinDegreeBuffer()); chunkGPURequest = new ChunkGPUDataRequest(chunkPipelinePool, storageGroup, minDegreesAtCoordBufferPool); TriangulationTableStaticData.BuildLookUpTables(); watch.Start(); buildAroundSqrDistance = (long)buildAroundDistance * buildAroundDistance; startPos = StartPos; //CompressedMarchingCubeChunk chunk = FindNonEmptyChunkAround(player.position); //maxSqrChunkDistance = buildAroundDistance * buildAroundDistance; //BuildRelevantChunksParallelBlockingAround(chunk); CreatePlanetWithAsyncGPU(); //CreatePlanetFromMeshData(); //BuildRelevantChunksParallelWithAsyncGpuAround(chunk); //int amount = 5; //for (int x = -amount; x <= amount; x++) //{ // for (int y = -amount; y <= amount; y++) // { // CreateChunkWithAsyncGPUReadbackParallel(startPos + new Vector3(32 * x, -DEFAULT_CHUNK_SIZE, 32 * y)); // } //} //FindNonEmptyChunkAroundAsync(startPos, (chunk) => //{ // maxSqrChunkDistance = buildAroundDistance * buildAroundDistance; // BuildRelevantChunksParallelWithAsyncGpuAround(chunk); //}); }