public void UpdateCollisionMesh()
        {
            if (HasSetCollider || (Viewer?.ViewerType == TerrainViewer.ViewerTypes.secondary))
            {
                return;
            }

            float sqrDstFromViewerToEdge = Bounds.SqrDistance(ViewerPosition);

            if (sqrDstFromViewerToEdge < detailLevels[colliderLODIndex].SqrVisibleDistanceThreshold)
            {
                if (!lodMeshes[colliderLODIndex].HasRequestedMesh)
                {
                    lodMeshes[colliderLODIndex].RequestMesh(DataMap.HeightMap, MeshSettings);
                }
            }

            if (sqrDstFromViewerToEdge < sqrColliderGenerationDistanceThreshold)
            {
                if (lodMeshes[colliderLODIndex].HasMesh)
                {
                    meshCollider.sharedMesh = lodMeshes[colliderLODIndex].Mesh;
                    HasSetCollider          = true;
                    OnColliderChanged?.Invoke(this, true);
                }
            }
        }
        public void SetVisible(bool visible)
        {
            // Clean up any visible chunkparts
            if (DataMapReceived)
            {
                foreach (TerrainChunkPart chunkPart in DataMap.ChunkParts.Values)
                {
                    if (chunkPart.Visible)
                    {
                        chunkPart.Visible = false;
                    }
                }
            }

            MeshObject.SetActive(visible);

            meshCollider.sharedMesh = null;
            HasSetCollider          = false;
            OnColliderChanged?.Invoke(this, false);
        }