private void SetNeedsRecalc(int parallelGrain)//this method not fully jobbed up, parallelGrain just used for copy function { NativeArrayUtil.CopyNativeArray(_conwayState, _needsRecalc, parallelGrain); for (int i = 0; i < _conwayState.Length; i++) { if (_conwayState[i]) { //int adjacentsIndex = i * 8; for (int j = 0; j < 8; j++) { int currentAdjacentIndex = _indexer.RawIndexFor(i, _adjacentOffsets[j]); _needsRecalc[currentAdjacentIndex] = true; //Debug.Log("i: " + i + " adjacentIndex: " + j + " value: " + currentAdjacentIndex); } } } }
private void Update() { //=== CHECK ALL CURRENTLY RENDERING CHUNKS for (var i = _renderedDataCount; i < _activeDataCount; i++) { var data = _computeData[i]; if (!data.JobHandle.IsCompleted) { continue; } if (!data.IsRendering) { Debug.LogError($"<color=\"aqua\">WorldRenderer.Update() : Data with jobhandle complete is not actually rendering. id:{i}</color>"); continue; } //Reuse mesh data for given cords or take new from pool var meshId = _meshIdByCoords.ContainsKey(data.Coords) ? _meshIdByCoords[data.Coords] : _activeMeshCount++; data.Complete(); var mesh = _meshData[meshId].Mesh; mesh.Clear(); mesh.vertices = NativeArrayUtil.NativeFloat3ToManagedVector3(data.Vertices); mesh.triangles = data.Triangles.ToArray(); mesh.uv = NativeArrayUtil.NativeFloat2ToManagedVector2(data.Uvs); mesh.colors = NativeArrayUtil.NativeFloatToManagedColor(data.Colors); mesh.normals = NativeArrayUtil.NativeFloat3ToManagedVector3(data.Normals); _meshData[meshId].SetCoords(data.Coords); _meshIdByCoords[data.Coords] = meshId; //swap first uncompleted data with current data //so we have contiguous part of completed data on the beginning of array SwapData(i, _renderedDataCount, true); _renderedDataCount++; //TODO: limit chunks generation by time / number of chunks processed ? } }
public void ClearMap(int grain) { NativeArrayUtil.SetAllValues(_conwayState, false, grain); }