Exemple #1
0
        public void OnSceneGUI()
        {
            var settings = BGPrivateField.GetSettings(Curve);

            AdjustMath(settings, Math);

            if (Curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off)
            {
                Math.Recalculate(true);
            }


            if (settings.HandlesSettings != null && settings.HandlesType == BGCurveSettings.HandlesTypeEnum.Configurable ||
                settings.ControlHandlesSettings != null && settings.ControlHandlesType == BGCurveSettings.HandlesTypeEnum.Configurable)
            {
                BGEditorUtility.ReloadSnapSettings();
            }


            OverlayMessage.OnSceneGui();

            var frustum = GeometryUtility.CalculateFrustumPlanes(SceneView.currentDrawingSceneView.camera);

            // process all editors
            foreach (var editor in editors)
            {
                editor.OnSceneGui(frustum);
            }

            editorSelection.Process(Event.current);


            transformMonitor.CheckForChange();
        }
        // ================================================================================ 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);
        }