// ================================================================================ Scene public override void OnSceneGui() { var settings = Settings; var rotation = Tools.pivotRotation == PivotRotation.Global ? Quaternion.identity : Curve.transform.rotation; if (Curve.PointsCount != 0 && settings.VRay) { painter = painter ?? new BGCurvePainterHandles(Editor.Math); painter.DrawCurve(); } editorPoint.OnSceneGUIStart(settings); var frustum = GeometryUtility.CalculateFrustumPlanes(SceneView.currentDrawingSceneView.camera); Curve.ForEach((point, index, count) => editorPoint.OnSceneGUI(point, index, settings, rotation, frustum)); //tangents if (settings.ShowCurve && settings.ShowTangents && Editor.Math.SectionsCount > 0 && Editor.Math.IsCalculated(BGCurveBaseMath.Field.Tangent)) { BGEditorUtility.SwapHandlesColor(settings.TangentsColor, () => { var math = Editor.Math; var sectionsCount = math.SectionsCount; var sections = math.SectionInfos; for (var i = 0; i < sectionsCount; i++) { var section = sections[i]; var points = section.Points; ShowTangent(points[0].Position, points[0].Tangent, settings.TangentsSize); if (settings.TangentsPerSection > 1) { var sectionLength = section.Distance; var part = sectionLength / settings.TangentsPerSection; for (var j = 1; j < settings.TangentsPerSection; j++) { var distanceWithinSection = part * j; Vector3 position; Vector3 tangent; section.CalcByDistance(distanceWithinSection, out position, out tangent, true, true); ShowTangent(position, tangent, settings.TangentsSize); } } } }); } editorSelection.Scene(rotation); var currentEvent = Event.current; overlay.Process(currentEvent); editorSelection.Process(currentEvent); }
public static void DrawGizmos(BGCurve curve, GizmoType gizmoType) { if (curve.PointsCount == 0) { return; } var settings = curve.Settings; if (!settings.ShowCurve || settings.VRay) { return; } /* * var settingsShowCurveMode = settings.ShowCurveMode; * // if (true) return; * if (settingsShowCurveMode == BGCurveSettings.ShowCurveModeEnum.CurveOrParentSelected && (gizmoType & GizmoType.InSelectionHierarchy) == 0) return; * if (settingsShowCurveMode == BGCurveSettings.ShowCurveModeEnum.CurveSelected && (gizmoType & GizmoType.Selected) == 0) return; * * if (BGCurvePointGOEditor.PointSelected) return; * * if (Selection.Contains(curve.gameObject) && settings.VRay) return; */ var playMode = EditorApplication.isPlaying; if (lastPlayMode != playMode) { lastPlayMode = playMode; foreach (var painterGizmo in curve2Painter) { painterGizmo.Value.Dispose(); } curve2Painter.Clear(); } if (CurrentCurve != null && curve.GetInstanceID() == CurrentCurve.GetInstanceID()) { if (CurrentGizmoPainter != null) { CurrentGizmoPainter.DrawCurve(); } } else { //curve is not selected in hierarchy var painter = BGEditorUtility.Ensure(curve2Painter, curve, () => new BGCurvePainterGizmo(NewMath(curve, settings), true)); AdjustMath(settings, painter.Math); if (curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off && !Application.isPlaying) { painter.Math.Recalculate(); } painter.DrawCurve(); } }
// ================================================================================ Scene public override void OnSceneGui(Plane[] frustum) { var settings = Settings; var curveRotation = GetRotation(Curve.transform); if (settings.VRay && settings.ShowCurve && Curve.PointsCount != 0) { painter = painter ?? new BGCurvePainterHandles(Editor.Math); painter.DrawCurve(); } Curve.ForEach((point, index, count) => editorPoint.OnSceneGUI(point, index, settings, curveRotation, frustum)); //tangents if (settings.ShowCurve && settings.ShowTangents && Editor.Math.SectionsCount > 0 && Editor.Math.IsCalculated(BGCurveBaseMath.Field.Tangent)) { BGEditorUtility.SwapHandlesColor(settings.TangentsColor, () => { var math = Editor.Math; var sectionsCount = math.SectionsCount; var sections = math.SectionInfos; for (var i = 0; i < sectionsCount; i++) { if (!settings.RestrictGizmozSettings.IsShowing(i)) { continue; } var section = sections[i]; var points = section.Points; ShowTangent(points[0].Position, points[0].Tangent, settings.TangentsSize); if (settings.TangentsPerSection > 1) { var sectionLength = section.Distance; var part = sectionLength / settings.TangentsPerSection; for (var j = 1; j < settings.TangentsPerSection; j++) { var distanceWithinSection = part * j; Vector3 position; Vector3 tangent; section.CalcByDistance(distanceWithinSection, out position, out tangent, true, true); ShowTangent(position, tangent, settings.TangentsSize); } } } }); } editorSelection.Scene(curveRotation); overlay.Process(Event.current); CheckPointsTransforms(); }
public static void DrawGizmos(BGCurve curve, GizmoType gizmoType) { //draw current spline if (curve.PointsCount != 0) { var settings = curve.Settings; if (settings.ShowCurve && !settings.VRay) { if (CurrentGizmoPainter != null) { CurrentGizmoPainter.DrawCurve(); } } } //why we do it? var playMode = EditorApplication.isPlaying; if (lastPlayMode != playMode) { lastPlayMode = playMode; foreach (var painterGizmo in curve2Painter) { painterGizmo.Value.Dispose(); } curve2Painter.Clear(); } //draw other splines with showCurveOption==AnyCurveSelected if (AllCurves != null) { for (var i = 0; i < AllCurves.Length; i++) { var allCurve = AllCurves[i]; var settings = allCurve.Settings; if (settings.ShowCurveOption != BGCurveSettings.ShowCurveOptionsEnum.AnyCurveSelected || allCurve.Equals(curve)) { continue; } var painter = BGEditorUtility.Ensure(curve2Painter, allCurve, () => new BGCurvePainterGizmo(NewMath(allCurve, settings), true)); AdjustMath(settings, painter.Math); if (allCurve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off && !Application.isPlaying) { painter.Math.Recalculate(); } painter.DrawCurve(); } } }
public static void DrawGizmos(BGCurve curve, GizmoType gizmoType) { var playMode = EditorApplication.isPlaying; if (lastPlayMode != playMode) { lastPlayMode = playMode; foreach (var painterGizmo in curve2Painter) { painterGizmo.Value.Dispose(); } curve2Painter.Clear(); } var settings = BGPrivateField.GetSettings(curve); if (!ComplyForDrawGizmos(curve, gizmoType, settings)) { return; } if (CurrentCurve != null && curve.GetInstanceID() == CurrentCurve.GetInstanceID()) { if (CurrentGizmoPainter != null) { CurrentGizmoPainter.DrawCurve(); } } else { //curve is not selected in hierarchy var painter = BGEditorUtility.Ensure(curve2Painter, curve, () => new BGCurvePainterGizmo(NewMath(curve, settings), true)); AdjustMath(settings, painter.Math); if (curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off && !Application.isPlaying) { painter.Math.Recalculate(); } painter.DrawCurve(); } }