public void Paint(GTexturePainterArgs args)
        {
            IGTexturePainter p = ActivePainter;

            if (p == null)
            {
                return;
            }

            FillArgs(ref args);

#if UNITY_EDITOR
            List <GStylizedTerrain> overlappedTerrain = GPaintToolUtilities.CheckBrushOverlap(groupId, args.WorldPointCorners);
            if (args.MouseEventType == GPainterMouseEventType.Down ||
                args.MouseEventType == GPainterMouseEventType.Drag)
            {
                Editor_CreateInitialHistoryEntry(args, overlappedTerrain);
            }
#endif

            IEnumerator <GStylizedTerrain> terrains = GStylizedTerrain.ActiveTerrains.GetEnumerator();
            while (terrains.MoveNext())
            {
                if (terrains.Current.GroupId != GroupId && GroupId >= 0)
                {
                    continue;
                }
                p.Paint(terrains.Current, args);
            }

#if UNITY_EDITOR
            EditedTerrains.UnionWith(overlappedTerrain);
            if (args.MouseEventType == GPainterMouseEventType.Up)
            {
                Editor_CreateHistory(args);
                currentInitialBackupName = null;
                InitialRecordedTerrains.Clear();
                EditedTerrains.Clear();
            }
#endif
        }
        private void Editor_CreateInitialHistoryEntry(GTexturePainterArgs args, List <GStylizedTerrain> overlappedTerrains)
        {
            if (!Editor_EnableHistory)
            {
                return;
            }
            if (overlappedTerrains.Count == 0)
            {
                return;
            }

            List <GTerrainResourceFlag> flags = new List <GTerrainResourceFlag>();

            flags.AddRange(ActivePainter.GetResourceFlagForHistory(args));

            if (InitialRecordedTerrains.Count == 0)
            {
                currentInitialBackupName = GBackup.TryCreateInitialBackup(ActivePainter.HistoryPrefix, overlappedTerrains[0], flags, false);
                if (!string.IsNullOrEmpty(currentInitialBackupName))
                {
                    InitialRecordedTerrains.Add(overlappedTerrains[0]);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(currentInitialBackupName))
                {
                    for (int i = 0; i < overlappedTerrains.Count; ++i)
                    {
                        if (InitialRecordedTerrains.Contains(overlappedTerrains[i]))
                        {
                            continue;
                        }
                        GBackup.BackupTerrain(overlappedTerrains[i], currentInitialBackupName, flags);
                        InitialRecordedTerrains.Add(overlappedTerrains[i]);
                    }
                }
            }
        }
示例#3
0
        public void Paint(GFoliagePainterArgs args)
        {
            IGFoliagePainter p = ActivePainter;

            if (p == null)
            {
                return;
            }

            args.Radius        = BrushRadius;
            args.Rotation      = BrushRotation;
            args.Density       = BrushDensity;
            args.EraseRatio    = EraseRatio;
            args.ScaleStrength = ScaleStrength;
            args.TreeIndices   = SelectedTreeIndices;
            args.GrassIndices  = SelectedGrassIndices;

            args.CustomArgs = CustomPainterArgs;
            if (SelectedBrushMaskIndex >= 0 && SelectedBrushMaskIndex < BrushMasks.Count)
            {
                args.Mask = BrushMasks[SelectedBrushMaskIndex];
            }
            args.Filters           = GetComponents <GSpawnFilter>();
            args.EnableTerrainMask = EnableTerrainMask;

            ProcessBrushDynamic(ref args);
            Vector3[] corners = GCommon.GetBrushQuadCorners(args.HitPoint, args.Radius, args.Rotation);
            args.WorldPointCorners = corners;

#if UNITY_EDITOR
            List <GStylizedTerrain> overlappedTerrain = GPaintToolUtilities.CheckBrushOverlap(groupId, args.WorldPointCorners);
            if ((args.MouseEventType == GPainterMouseEventType.Down ||
                 args.MouseEventType == GPainterMouseEventType.Drag) &&
                args.ShouldCommitNow == false)
            {
                Editor_CreateInitialHistoryEntry(args, overlappedTerrain);
            }
#endif

            IEnumerator <GStylizedTerrain> terrains = GStylizedTerrain.ActiveTerrains.GetEnumerator();
            while (terrains.MoveNext())
            {
                if (terrains.Current.GroupId != GroupId && GroupId >= 0)
                {
                    continue;
                }
                GStylizedTerrain t = terrains.Current;
                p.Paint(t, args);
            }

#if UNITY_EDITOR
            EditedTerrains.UnionWith(overlappedTerrain);
            if (args.MouseEventType == GPainterMouseEventType.Up)
            {
                Editor_CreateHistory(args);
                currentInitialBackupName = null;
                InitialRecordedTerrains.Clear();
                EditedTerrains.Clear();
            }
#endif
        }