private void DrawLivePreview(GStylizedTerrain t, Camera cam) { if (t.transform.rotation != Quaternion.identity || t.transform.lossyScale != Vector3.one) { return; } List <Rect> dirtyRects = new List <Rect>(instance.SplineCreator.SweepDirtyRect(t)); Rect r = new Rect(0, 0, 0, 0); for (int i = 0; i < dirtyRects.Count; ++i) { r.xMin = Mathf.Min(r.xMin, dirtyRects[i].xMin); r.xMax = Mathf.Max(r.xMax, dirtyRects[i].xMax); r.yMin = Mathf.Min(r.yMin, dirtyRects[i].yMin); r.yMax = Mathf.Max(r.yMax, dirtyRects[i].yMax); } RenderTexture rt = GetPreviewTexture(t); instance.Internal_Apply(t, rt, instance.SplineCreator.Editor_Vertices); GLivePreviewDrawer.DrawMasksLivePreview( t, cam, new Texture[] { rt }, new Color[] { GGriffinSettings.Instance.SplineToolSettings.PositiveHighlightColor }, r); }
private void DrawLivePreview(GStylizedTerrain t, Camera cam) { if (t.transform.rotation != Quaternion.identity || t.transform.lossyScale != Vector3.one) { return; } RenderTexture[] brushes = new RenderTexture[instance.Layers.Count]; for (int i = 0; i < brushes.Length; ++i) { brushes[i] = GetPreviewTexture(t, "brush" + i.ToString(), instance.MaskResolution, FilterMode.Bilinear); } Vector3[] worldPoints = instance.GetQuad(); Vector2[] uvPoint = new Vector2[worldPoints.Length]; for (int i = 0; i < uvPoint.Length; ++i) { uvPoint[i] = t.WorldPointToUV(worldPoints[i]); } Rect dirtyRect = GUtilities.GetRectContainsPoints(uvPoint); if (!dirtyRect.Overlaps(new Rect(0, 0, 1, 1))) { return; } Color[] colors = new Color[instance.Layers.Count]; for (int i = 0; i < colors.Length; ++i) { colors[i] = instance.Layers[i].VisualizeColor; } GLivePreviewDrawer.DrawMasksLivePreview(t, cam, brushes, colors, dirtyRect); }