Exemple #1
0
        public void GenerateSplatMapParallel(bool clearLockedTextures)
        {
            if (!VegetationSystemPro)
            {
                return;
            }

            VegetationSystemPro.ClearCache();

            List <IVegetationStudioTerrain> overlapTerrainList =
                GetOverlapTerrainList(VegetationSystemPro.VegetationSystemBounds);

            PrepareTextureCurves();

            float worldspaceMinHeight = VegetationSystemPro.VegetationSystemBounds.center.y -
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float worldspaceSeaLevel  = worldspaceMinHeight + VegetationSystemPro.SeaLevel;
            float worldspaceMaxHeight = VegetationSystemPro.VegetationSystemBounds.center.y +
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float heightCurveSampleHeight = worldspaceMaxHeight - worldspaceSeaLevel;


            VegetationPackagePro defaultBiomeVegetationPackagePro =
                VegetationSystemPro.GetVegetationPackageFromBiome(BiomeType.Default);

            if (defaultBiomeVegetationPackagePro == null)
            {
                Debug.LogWarning("You need a default biome in order to generate splatmaps. ");
                return;
            }

            int terrainCount = overlapTerrainList.Count;

            for (int i = 0; i <= overlapTerrainList.Count - 1; i++)
            {
                overlapTerrainList[i].PrepareSplatmapGeneration(clearLockedTextures);
#if UNITY_EDITOR
                EditorUtility.DisplayProgressBar("Prepare generation",
                                                 "Terrain " + (i + 1) + "/" + terrainCount, (i + 1) / (float)terrainCount);
#endif
            }

            for (int i = 0; i <= overlapTerrainList.Count - 1; i++)
            {
                overlapTerrainList[i].GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                            BiomeType.Default, null, defaultBiomeVegetationPackagePro.TerrainTextureSettingsList, heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);

#if UNITY_EDITOR
                EditorUtility.DisplayProgressBar("Generating default biome",
                                                 "Terrain " + (i + 1) + "/" + terrainCount, (i + 1) / (float)terrainCount);
#endif
            }

            List <BiomeType> additionalBiomeList = VegetationSystemPro.GetAdditionalBiomeList();


            List <VegetationPackagePro> additionalVegetationPackageList = new List <VegetationPackagePro>();
            for (int i = 0; i <= additionalBiomeList.Count - 1; i++)
            {
                additionalVegetationPackageList.Add(
                    VegetationSystemPro.GetVegetationPackageFromBiome(additionalBiomeList[i]));
            }
            BiomeSortOrderComparer biomeSortOrderComparer = new BiomeSortOrderComparer();
            additionalVegetationPackageList.Sort(biomeSortOrderComparer);

            for (int i = 0; i <= additionalVegetationPackageList.Count - 1; i++)
            {
                VegetationPackagePro currentVegetationPackagePro = additionalVegetationPackageList[i];
                if (!currentVegetationPackagePro.GenerateBiomeSplamap)
                {
                    continue;
                }

                List <PolygonBiomeMask> biomeMaskList = VegetationStudioManager.GetBiomeMasks(currentVegetationPackagePro.BiomeType);
                for (int j = 0; j <= overlapTerrainList.Count - 1; j++)
                {
                    overlapTerrainList[j].GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                                currentVegetationPackagePro.BiomeType, biomeMaskList, currentVegetationPackagePro.TerrainTextureSettingsList, heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);
                }
            }

            JobHandle.ScheduleBatchedJobs();


            for (int i = 0; i <= overlapTerrainList.Count - 1; i++)
            {
#if UNITY_EDITOR
                EditorUtility.DisplayProgressBar("Updating terrain",
                                                 "Terrain " + (i + 1) + "/" + terrainCount, (i + 1) / (float)terrainCount);
      #endif
                overlapTerrainList[i].CompleteSplatmapGeneration();
            }
#if UNITY_EDITOR
            EditorUtility.ClearProgressBar();
#endif
            DisposeTextureCurves();
        }
Exemple #2
0
        public void GenerateSplatMap(bool clearLockedTextures, IVegetationStudioTerrain iVegetationStudioTerrain)
        {
            if (!VegetationSystemPro)
            {
                return;
            }

            VegetationSystemPro.ClearCache(iVegetationStudioTerrain.TerrainBounds);
            PrepareTextureCurves();

            float worldspaceMinHeight = VegetationSystemPro.VegetationSystemBounds.center.y -
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float worldspaceSeaLevel  = worldspaceMinHeight + VegetationSystemPro.SeaLevel;
            float worldspaceMaxHeight = VegetationSystemPro.VegetationSystemBounds.center.y +
                                        VegetationSystemPro.VegetationSystemBounds.extents.y;
            float heightCurveSampleHeight = worldspaceMaxHeight - worldspaceSeaLevel;

            VegetationPackagePro defaultBiomeVegetationPackagePro =
                VegetationSystemPro.GetVegetationPackageFromBiome(BiomeType.Default);

            if (defaultBiomeVegetationPackagePro == null)
            {
                Debug.LogWarning("You need a default biome in order to generate splatmaps. ");
                return;
            }

            iVegetationStudioTerrain.PrepareSplatmapGeneration(clearLockedTextures);

            iVegetationStudioTerrain.GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                           BiomeType.Default, null, defaultBiomeVegetationPackagePro.TerrainTextureSettingsList,
                                                           heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);

            List <BiomeType> additionalBiomeList = VegetationSystemPro.GetAdditionalBiomeList();

            List <VegetationPackagePro> additionalVegetationPackageList = new List <VegetationPackagePro>();

            for (int i = 0; i <= additionalBiomeList.Count - 1; i++)
            {
                additionalVegetationPackageList.Add(
                    VegetationSystemPro.GetVegetationPackageFromBiome(additionalBiomeList[i]));
            }
            BiomeSortOrderComparer biomeSortOrderComparer = new BiomeSortOrderComparer();

            additionalVegetationPackageList.Sort(biomeSortOrderComparer);

            for (int i = 0; i <= additionalVegetationPackageList.Count - 1; i++)
            {
                VegetationPackagePro currentVegetationPackagePro = additionalVegetationPackageList[i];
                if (!currentVegetationPackagePro.GenerateBiomeSplamap)
                {
                    continue;
                }

                List <PolygonBiomeMask> biomeMaskList = VegetationStudioManager.GetBiomeMasks(currentVegetationPackagePro.BiomeType);
                iVegetationStudioTerrain.GenerateSplatMapBiome(VegetationSystemPro.VegetationSystemBounds,
                                                               currentVegetationPackagePro.BiomeType, biomeMaskList, currentVegetationPackagePro.TerrainTextureSettingsList, heightCurveSampleHeight, worldspaceSeaLevel, clearLockedTextures);
            }

            JobHandle.ScheduleBatchedJobs();
            iVegetationStudioTerrain.CompleteSplatmapGeneration();
            DisposeTextureCurves();
        }