public void FillArgs(ref GTexturePainterArgs args, bool useBrushDynamic = true)
        {
            args.Radius              = BrushRadius;
            args.Rotation            = BrushRotation;
            args.Opacity             = BrushOpacity;
            args.Color               = BrushColor;
            args.SplatIndex          = SelectedSplatIndex;
            args.SamplePoint         = SamplePoint;
            args.CustomArgs          = CustomPainterArgs;
            args.ForceUpdateGeometry = ForceUpdateGeometry;
            if (SelectedBrushMaskIndex >= 0 && SelectedBrushMaskIndex < BrushMasks.Count)
            {
                args.Mask = BrushMasks[SelectedBrushMaskIndex];
            }

            if (args.ActionType == GPainterActionType.Alternative &&
                args.MouseEventType == GPainterMouseEventType.Down)
            {
                SamplePoint      = args.HitPoint;
                args.SamplePoint = args.HitPoint;
            }

            if (useBrushDynamic)
            {
                ProcessBrushDynamic(ref args);
            }

            Vector3[] corners = GCommon.GetBrushQuadCorners(args.HitPoint, args.Radius, args.Rotation);
            args.WorldPointCorners = corners;
        }
Пример #2
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>();

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

#if UNITY_EDITOR
            if (args.MouseEventType == GPainterMouseEventType.Down &&
                args.ShouldCommitNow == false)
            {
                Editor_CreateInitialHistoryEntry(args);
            }
#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
            if (args.MouseEventType == GPainterMouseEventType.Up)
            {
                Editor_CreateHistory(args);
            }
#endif
        }
Пример #3
0
        private void DrawHandleAtCursor(RaycastHit hit)
        {
            Color cursorColor =
                Event.current.shift ? GGriffinSettings.Instance.PaintToolSettings.AlternativeActionCursorColor :
                Event.current.control ? GGriffinSettings.Instance.PaintToolSettings.NegativeActionCursorColor :
                GGriffinSettings.Instance.PaintToolSettings.NormalActionCursorColor;

            cursorColor.a = cursorColor.a * Mathf.Lerp(0.5f, 1f, painter.BrushDensity * 1.0f / 100f);

            if (GGriffinSettings.Instance.PaintToolSettings.UseSimpleCursor)
            {
                Handles.color = cursorColor;
                Vector3[] corner = GCommon.GetBrushQuadCorners(hit.point, painter.BrushRadius, painter.BrushRotation);
                Handles.DrawAAPolyLine(5, corner[0], corner[1], corner[2], corner[3], corner[0]);
            }
            else
            {
                Matrix4x4 cursorToWorld = Matrix4x4.TRS(hit.point, Quaternion.Euler(0, painter.BrushRotation, 0), 2 * painter.BrushRadius * Vector3.one);
                worldPoints[0] = cursorToWorld.MultiplyPoint(new Vector3(-0.5f, 0, -0.5f));
                worldPoints[1] = cursorToWorld.MultiplyPoint(new Vector3(-0.5f, 0, 0.5f));
                worldPoints[2] = cursorToWorld.MultiplyPoint(new Vector3(0.5f, 0, 0.5f));
                worldPoints[3] = cursorToWorld.MultiplyPoint(new Vector3(0.5f, 0, -0.5f));

                Material mat = GInternalMaterials.PainterCursorProjectorMaterial;
                mat.SetColor("_Color", cursorColor);
                mat.SetTexture("_MainTex", painter.BrushMasks[painter.SelectedBrushMaskIndex]);
                mat.SetMatrix("_WorldToCursorMatrix", cursorToWorld.inverse);
                mat.SetPass(0);

                IEnumerator <GStylizedTerrain> terrains = GStylizedTerrain.ActiveTerrains.GetEnumerator();
                while (terrains.MoveNext())
                {
                    GStylizedTerrain t = terrains.Current;
                    if (t.TerrainData == null)
                    {
                        continue;
                    }
                    if (painter.GroupId >= 0 &&
                        painter.GroupId != t.GroupId)
                    {
                        continue;
                    }
                    DrawCursorProjected(t);
                }
            }
        }
Пример #4
0
        public void Paint(GObjectPainterArgs args)
        {
            IGObjectPainter p = ActivePainter;

            if (p == null)
            {
                return;
            }

            args.Radius        = BrushRadius;
            args.Rotation      = BrushRotation;
            args.Density       = BrushDensity;
            args.EraseRatio    = EraseRatio;
            args.ScaleStrength = ScaleStrength;
            args.CustomArgs    = CustomPainterArgs;
            args.Filters       = GetComponents <GSpawnFilter>();
            if (SelectedBrushMaskIndex >= 0 && SelectedBrushMaskIndex < BrushMasks.Count)
            {
                args.Mask = BrushMasks[SelectedBrushMaskIndex];
            }
            if (SelectedPrototypeIndices.Count == 0)
            {
                return;
            }
            args.Prototypes        = Prototypes;
            args.PrototypeIndices  = SelectedPrototypeIndices;
            args.EnableTerrainMask = EnableTerrainMask;

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

            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);
            }
        }