Esempio n. 1
0
        private void LateUpdate()
        {
            if (_chunkRequestQueue.Count > 0)
            {
                var geometryRequests  = _chunkRequestQueue.Pull(_pullCount, _camera.Position);
                var geometryResponses = _voxelGeometryController.Execute(geometryRequests);

                foreach (var geometryResponse in geometryResponses)
                {
                    /*
                     * var chunk = _chunks[geometryResponse.ChunkIndex];
                     * chunk.SetMesh(geometryResponse);*/
                }
            }

            if (_fallingRequestQueue.Count > 0)
            {
                var geometryRequests  = _fallingRequestQueue.Pull(_pullCount, _camera.Position);
                var geometryResponses = _voxelGeometryController.Execute(geometryRequests);

                foreach (var geometryResponse in geometryResponses)
                {
                    /*
                     * var fallingConstructionController = _fallingConstructionControllers[geometryResponse.ConstructionIndex];
                     * fallingConstructionController.SetMesh(geometryResponse);*/
                }
            }
        }
Esempio n. 2
0
    private void LateUpdate()
    {
        _chunkRenderer.Execute();

        if (_chunkRequestQueue.Count > 0)
        {
            var geometryRequests  = _chunkRequestQueue.Pull(4, _cameraTransform.position);
            var geometryResponses = _voxelGeometryController.Execute(geometryRequests);

            var length = geometryResponses.Length;

            if (length > 0)
            {
                var bakeChunks = new VolumeChunk[geometryResponses.Length];

                for (var i = 0; i < length; i++)
                {
                    var geometryResponse = geometryResponses[i];

                    var chunk = _chunks[geometryResponse.ChunkIndex];
                    chunk.SetMesh(geometryResponse);

                    bakeChunks[i] = chunk;
                }

                var tasks = new Task[length];

                for (var i = 0; i < length; i++)
                {
                    var bakeId = bakeChunks[i].MeshId;
                    tasks[i] = Task.Run(() => Physics.BakeMesh(bakeId, false));
                }

                Task.WaitAll(tasks);

                for (var i = 0; i < length; i++)
                {
                    bakeChunks[i].UpdateColliderMesh();
                }
            }
        }

        if (_fallingRequestQueue.Count > 0)
        {
            var geometryRequests  = _fallingRequestQueue.Pull(4, _cameraTransform.position);
            var geometryResponses = _voxelGeometryController.Execute(geometryRequests);

            foreach (var geometryResponse in geometryResponses)
            {
                var fallingConstruction = _fallingConstructions[geometryResponse.ConstructionIndex];
                fallingConstruction.SetMesh(geometryResponse);
            }
        }
    }