Exemple #1
0
 public void Remove(MassiveGrassGrid.CellIndex index)
 {
     if (Application.isPlaying)
     {
         UnityEngine.Object.Destroy(meshes[index]);
     }
     else
     {
         UnityEngine.Object.DestroyImmediate(meshes[index]);
     }
     meshes.Remove(index);
 }
        public async Task <Mesh> Build(
            Terrain terrain,
            List <Texture2D> alphaMaps,
            MassiveGrassGrid.CellIndex index,
            Rect rect,
            MassiveGrassProfile profile)
        {
            var elements = await GenerateElements(terrain, rect, profile, index.hash % 50000);

            var builder = profile.CreateBuilder();

            return(await builder.Build(terrain, alphaMaps, profile, elements));
        }
Exemple #3
0
        public void Remove(MassiveGrassGrid.CellIndex index)
        {
            if (!activeIndices.Contains(index))
            {
                return;
            }
            if (meshes.ContainsKey(index))
            {
                SafeDestroy(meshes[index]);
                meshes.Remove(index);
            }

            activeIndices.Remove(index);
        }
Exemple #4
0
        public void Create(MassiveGrassGrid.CellIndex index, Rect rect)
        {
            if (activeIndices.Contains(index))
            {
                return;
            }

            activeIndices.Add(index);
            if (!requestQueue.ContainsKey(index))
            {
                requestQueue[index] = (new Request(index, rect));
                if (requestQueue.Count == 1)
                {
                    ProcessQueue();
                }
            }
        }
Exemple #5
0
        private async Task Build(MassiveGrassGrid.CellIndex index)
        {
            var request = requestQueue[index];
            var rect    = request.rect;
            var mesh    = await meshBuilder.Build(terrain, alphaMaps, index, rect, profile);

            if (!activeIndices.Contains(index))
            {
                SafeDestroy(mesh);
                if (requestQueue.ContainsKey(index))
                {
                    requestQueue.Remove(index);
                }
                return;
            }

            meshes[index] = mesh;
            requestQueue.Remove(index);
        }
Exemple #6
0
 public async void Create(MassiveGrassGrid.CellIndex index, Rect rect)
 {
     // メッシュ生成タスクを呼び出す
     meshes[index] = await meshBuilder.Build(terrain, alphaMaps, index, rect, profile);
 }
Exemple #7
0
 public Request(MassiveGrassGrid.CellIndex index, Rect rect)
 {
     this.index = index;
     this.rect  = rect;
 }
Exemple #8
0
        public async Task <MeshData> BuildMeshData(Terrain terrain, IReadOnlyCollection <Texture2D> alphaMaps, MassiveGrassGrid.CellIndex index, Rect rect, MassiveGrassProfile profile)
        {
            var elements = await GenerateElements(terrain, rect, profile, index.hash % 50000);

            builder = builder ?? profile.CreateBuilder();
            return(await builder.BuildMeshData(terrain, alphaMaps, profile, elements));
        }