Exemple #1
0
        public override JobHandle SampleIncludeVegetationMask(VegetationInstanceData instanceData,
                                                              VegetationTypeIndex vegetationTypeIndex,
                                                              JobHandle dependsOn)
        {
            VegetationTypeSettings vegetationTypeSettings = GetVegetationTypeSettings(vegetationTypeIndex);

            if (vegetationTypeSettings != null)
            {
                IncludeVegetationMaskLineJob includeVegetationMaskLineJob =
                    new IncludeVegetationMaskLineJob
                {
                    Excluded = instanceData.Excluded.ToDeferredJobArray(),
                    Position = instanceData.Position.ToDeferredJobArray(),
                    VegetationMaskDensity = instanceData.VegetationMaskDensity.ToDeferredJobArray(),
                    VegetationMaskScale   = instanceData.VegetationMaskScale.ToDeferredJobArray(),
                    Denisty       = vegetationTypeSettings.Density,
                    Scale         = vegetationTypeSettings.Size,
                    LineSegment2D = _line2D,
                    Width         = _width
                };
                dependsOn = includeVegetationMaskLineJob.Schedule(instanceData.Excluded, 32, dependsOn);
            }

            return(dependsOn);
        }
Exemple #2
0
        public override JobHandle SampleIncludeVegetationMask(VegetationInstanceData instanceData,
                                                              VegetationTypeIndex vegetationTypeIndex,
                                                              JobHandle dependsOn)
        {
            VegetationTypeSettings vegetationTypeSettings = GetVegetationTypeSettings(vegetationTypeIndex);

            if (vegetationTypeSettings != null)
            {
                IncludeVegetatiomMaskBeaconJob includeVegetatiomMaskBeaconJob =
                    new IncludeVegetatiomMaskBeaconJob
                {
                    Excluded = instanceData.Excluded.ToDeferredJobArray(),
                    Position = instanceData.Position.ToDeferredJobArray(),
                    VegetationMaskDensity = instanceData.VegetationMaskDensity.ToDeferredJobArray(),
                    VegetationMaskScale   = instanceData.VegetationMaskScale.ToDeferredJobArray(),
                    Denisty           = vegetationTypeSettings.Density,
                    Scale             = vegetationTypeSettings.Size,
                    FalloutCurveArray = FalloutCurveArray,
                    MaskPosition      = Position,
                    Radius            = Radius
                };
                dependsOn = includeVegetatiomMaskBeaconJob.Schedule(instanceData.Excluded, 32, dependsOn);
            }

            return(dependsOn);
        }
Exemple #3
0
 public VegetationTypeSettings(VegetationTypeSettings orgVegetationTypeSettings)
 {
     Index   = orgVegetationTypeSettings.Index;
     Density = orgVegetationTypeSettings.Density;
     Size    = orgVegetationTypeSettings.Size;
 }
Exemple #4
0
        public override void OnInspectorGUI()
        {
            VegetationMask = (VegetationMask)target;

            base.OnInspectorGUI();
            EditorGUIUtility.labelWidth = 200;

            GUILayout.BeginVertical("box");
            EditorGUILayout.HelpBox("Create the area where you want to modify the vegetation, you can remove and/or include vegetation types", MessageType.Info);
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box");
            if (VegetationMask.enabled)
            {
                EditorGUILayout.LabelField("Insert Node: Ctrl-Click", LabelStyle);
                EditorGUILayout.LabelField("Delete Node: Ctrl-Shift-Click", LabelStyle);
            }
            else
            {
                EditorGUILayout.HelpBox("Enable mask to edit nodes", MessageType.Info);
            }

            if (VegetationMask.Nodes.Count < 4)
            {
                EditorGUILayout.HelpBox("There has to be at least 3 nodes to define the area", MessageType.Warning);
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box");
            EditorGUILayout.HelpBox("Select ground layers that will be used for selection when adding and moving masks. These will be used in addition to unity terrains.", MessageType.Info);
            VegetationMask.GroundLayerMask = LayerMaskField("Ground Layers", VegetationMask.GroundLayerMask);
            GUILayout.EndVertical();


            GUILayout.BeginVertical("box");
            EditorGUI.BeginChangeCheck();
            VegetationMask.ShowArea    = EditorGUILayout.Toggle("Show Area", VegetationMask.ShowArea);
            VegetationMask.ShowHandles = EditorGUILayout.Toggle("Show Handles", VegetationMask.ShowHandles);
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(VegetationMask);
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical("box");
            EditorGUILayout.LabelField("Mask settings", LabelStyle);
            EditorGUI.BeginChangeCheck();
            VegetationMask.MaskName = EditorGUILayout.TextField("Mask Name", VegetationMask.MaskName);

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(VegetationMask);
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box");
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.LabelField("Global vegetation removal", LabelStyle);
            EditorGUILayout.HelpBox("The area within the additional perimeter range will be filtered by a noise texture. To get a 100% removal in this area set min and max range to the same distance.", MessageType.Info);

            VegetationMask.RemoveGrass = EditorGUILayout.Toggle("Remove Grass", VegetationMask.RemoveGrass);
            if (VegetationMask.RemoveGrass)
            {
                //vegetationMask.AdditionalGrassPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalGrassPerimiter, 0f, 40f);
                EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalGrassPerimiter,
                                                ref VegetationMask.AdditionalGrassPerimiterMax, 0, 40);
                VegetationMask.NoiseScaleGrass = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleGrass, 1f, 40f);
            }
            EditorGUILayout.Space();
            VegetationMask.RemovePlants = EditorGUILayout.Toggle("Remove Plants", VegetationMask.RemovePlants);
            if (VegetationMask.RemovePlants)
            {
                //   vegetationMask.AdditionalPlantPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalPlantPerimiter, 0f, 40f);
                EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalPlantPerimiter,
                                                ref VegetationMask.AdditionalPlantPerimiterMax, 0, 40);
                VegetationMask.NoiseScalePlant = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScalePlant, 1f, 40f);
            }
            EditorGUILayout.Space();
            VegetationMask.RemoveTrees = EditorGUILayout.Toggle("Remove Trees", VegetationMask.RemoveTrees);
            if (VegetationMask.RemoveTrees)
            {
                //vegetationMask.AdditionalTreePerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalTreePerimiter, 0f, 40f);
                EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalTreePerimiter,
                                                ref VegetationMask.AdditionalTreePerimiterMax, 0, 40);
                VegetationMask.NoiseScaleTree = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleTree, 1f, 40f);
            }


            EditorGUILayout.Space();
            VegetationMask.RemoveObjects = EditorGUILayout.Toggle("Remove Objects", VegetationMask.RemoveObjects);
            if (VegetationMask.RemoveObjects)
            {
                // vegetationMask.AdditionalObjectPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalObjectPerimiter, 0f, 40f);
                EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalObjectPerimiter,
                                                ref VegetationMask.AdditionalObjectPerimiterMax, 0, 40);
                VegetationMask.NoiseScaleObject = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleObject, 1f, 40f);
            }


            EditorGUILayout.Space();
            VegetationMask.RemoveLargeObjects = EditorGUILayout.Toggle("Remove Large Objects", VegetationMask.RemoveLargeObjects);
            if (VegetationMask.RemoveLargeObjects)
            {
                //vegetationMask.AdditionalLargeObjectPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalLargeObjectPerimiter, 0f, 40f);
                EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalLargeObjectPerimiter,
                                                ref VegetationMask.AdditionalLargeObjectPerimiterMax, 0, 40);
                VegetationMask.NoiseScaleLargeObject = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleLargeObject, 1f, 40f);
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box");
            EditorGUILayout.LabelField("Localized vegetation placement", LabelStyle);
            VegetationMask.IncludeVegetationType = EditorGUILayout.Toggle("Include vegetation", VegetationMask.IncludeVegetationType);

            if (EditorGUI.EndChangeCheck())
            {
                SetMaskDirty();
            }

            if (VegetationMask.IncludeVegetationType)
            {
                if (GUILayout.Button("Add vegetation type"))
                {
                    VegetationTypeSettings newVegetationTypeSettings = new VegetationTypeSettings();
                    VegetationMask.VegetationTypeList.Add(newVegetationTypeSettings);
                    _vegetationTypeIndex = VegetationMask.VegetationTypeList.Count - 1;
                    SetMaskDirty();
                }

                string[] packageNameList = new string[VegetationMask.VegetationTypeList.Count];
                for (int i = 0; i <= VegetationMask.VegetationTypeList.Count - 1; i++)
                {
                    packageNameList[i] = (i + 1).ToString() + ". Item";
                }


                if (VegetationMask.VegetationTypeList.Count > 0)
                {
                    if (_vegetationTypeIndex > VegetationMask.VegetationTypeList.Count - 1)
                    {
                        _vegetationTypeIndex = VegetationMask.VegetationTypeList.Count - 1;
                    }
                    _vegetationTypeIndex = EditorGUILayout.Popup("Selected item", _vegetationTypeIndex, packageNameList);

                    EditorGUI.BeginChangeCheck();
                    GUILayout.BeginVertical("box");

                    VegetationMask.VegetationTypeList[_vegetationTypeIndex].Index   = (VegetationTypeIndex)EditorGUILayout.EnumPopup("Vegetation type", VegetationMask.VegetationTypeList[_vegetationTypeIndex].Index);
                    VegetationMask.VegetationTypeList[_vegetationTypeIndex].Density = EditorGUILayout.Slider("Density", VegetationMask.VegetationTypeList[_vegetationTypeIndex].Density, 0f, 1f);
                    VegetationMask.VegetationTypeList[_vegetationTypeIndex].Size    = EditorGUILayout.Slider("Size", VegetationMask.VegetationTypeList[_vegetationTypeIndex].Size, 0f, 2f);

                    if (GUILayout.Button("Delete selected item"))
                    {
                        VegetationMask.VegetationTypeList.RemoveAt(_vegetationTypeIndex);
                    }

                    GUILayout.EndVertical();

                    if (EditorGUI.EndChangeCheck())
                    {
                        SetMaskDirty();
                    }
                }
            }


            GUILayout.EndVertical();
        }