Exemple #1
0
        /// <summary>
        /// Moves the line in the track, grid, and renderer.
        /// Updates extensions
        /// Notifies the undo/timeline managers
        /// </summary>
        public void MoveLine(
            GameLine line,
            Vector2d pos1,
            Vector2d pos2)
        {
            if (line.Position != pos1 || line.Position2 != pos2)
            {
                var clone = line.Clone();
                var std   = line as StandardLine;
                if (std != null)
                {
                    SaveCells(line.Position, line.Position2);
                    SaveCells(pos1, pos2);
                    if (_updateextensions)
                    {
                        RemoveExtensions(std);
                    }
                    Track.MoveLine(std, pos1, pos2);
                    if (_updateextensions)
                    {
                        AddExtensions(std);
                    }
                }
                else
                {
                    line.Position  = pos1;
                    line.Position2 = pos2;
                }
                _editorcells.RemoveLine(clone);
                _editorcells.AddLine(line);

                RegisterUndoAction(clone, line);
                _renderer.RedrawLine(line);
            }
        }
Exemple #2
0
        public void Render(float blend)
        {
            _invalidated = false;
            if (_refreshtrack)
            {
                using (_tracksync.AcquireRead())
                {
                    _renderer.RefreshTrack(_track);
                }
                _refreshtrack = false;
            }
            DrawOptions drawOptions = new DrawOptions();

            drawOptions.DrawFlag = _flag != null;
            if (drawOptions.DrawFlag)
            {
                drawOptions.FlagRider = _flag.State;
            }
            drawOptions.Blend        = blend;
            drawOptions.NightMode    = Settings.NightMode;
            drawOptions.GravityWells = Settings.Local.RenderGravityWells;
            drawOptions.LineColors   = !Settings.Local.PreviewMode && (!Playing || Settings.Local.ColorPlayback);
            drawOptions.KnobState    = KnobState.Hidden;
            if (!Playing && game.SelectedTool is MoveTool movetool)
            {
                drawOptions.KnobState = movetool.CanLifelock
                ? KnobState.LifeLock
                : KnobState.Shown;
            }
            drawOptions.Paused              = Paused;
            drawOptions.PlaybackMode        = PlaybackMode;
            drawOptions.Rider               = RenderRiderInfo.State;
            drawOptions.ShowContactLines    = Settings.Local.DrawContactPoints;
            drawOptions.ShowMomentumVectors = Settings.Local.MomentumVectors;
            drawOptions.Zoom           = Zoom;
            drawOptions.RiderDiagnosis = RenderRiderInfo.Diagnosis;
            int renderframe = Offset;

            if (Playing && Offset > 0 && blend < 1)
            {
                //interpolate between last frame and current one
                var current = Timeline.GetFrame(Offset);
                var prev    = Timeline.GetFrame(Offset - 1);
                drawOptions.Rider = Rider.Lerp(prev, current, blend);
                renderframe       = Offset - 1;
            }
            drawOptions.Iteration = IterationsOffset;
            if (!_loadingTrack)
            {
                var changes = Timeline.RequestFrameForRender(renderframe);
                foreach (var change in changes)
                {
                    GameLine line;
                    if (_track.LineLookup.TryGetValue(change, out line))
                    {
                        _renderer.RedrawLine(line);
                    }
                }
            }

            _renderer.Render(_track, Timeline, Camera, drawOptions);
        }
Exemple #3
0
        public void Render(float blend)
        {
            _invalidated = false;
            if (_refreshtrack)
            {
                using (_tracksync.AcquireRead())
                {
                    _renderer.RefreshTrack(_track);
                }
                _refreshtrack = false;
            }
            DrawOptions drawOptions = new DrawOptions();

            drawOptions.DrawFlag = _flag != null && !Settings.Local.RecordingMode;
            if (drawOptions.DrawFlag)
            {
                drawOptions.FlagRider = _flag.State;
            }
            drawOptions.Blend        = blend;
            drawOptions.NightMode    = Settings.NightMode;
            drawOptions.GravityWells = Settings.Editor.RenderGravityWells;
            drawOptions.LineColors   = !Settings.PreviewMode && (!Playing || Settings.ColorPlayback);
            drawOptions.KnobState    = KnobState.Hidden;
            var selectedtool = CurrentTools.SelectedTool;

            if (!Playing &&
                (selectedtool == CurrentTools.MoveTool ||
                 selectedtool == CurrentTools.SelectTool))
            {
                drawOptions.KnobState = KnobState.Shown;
            }
            drawOptions.Paused              = Paused;
            drawOptions.Rider               = RenderRiderInfo.State;
            drawOptions.ShowContactLines    = Settings.Editor.DrawContactPoints;
            drawOptions.ShowMomentumVectors = Settings.Editor.MomentumVectors;
            drawOptions.Zoom           = Zoom;
            drawOptions.RiderDiagnosis = RenderRiderInfo.Diagnosis;
            if (Settings.Local.TrackOverlay && !Playing)
            {
                drawOptions.OverlayFrame = Settings.Local.TrackOverlayFixed
                ? Settings.Local.TrackOverlayFixedFrame
                : Offset + Settings.Local.TrackOverlayOffset;
                drawOptions.OverlayFrame = MathHelper.Clamp(
                    drawOptions.OverlayFrame,
                    0,
                    FrameCount + 999);
            }
            int renderframe = Offset;

            if (Playing && Offset > 0 && blend < 1)
            {
                //interpolate between last frame and current one
                var current = Timeline.GetFrame(Offset);
                var prev    = Timeline.GetFrame(Offset - 1);
                drawOptions.Rider = Rider.Lerp(prev, current, blend);
                renderframe       = Offset - 1;
            }
            drawOptions.Iteration = IterationsOffset;
            // todo there's a race condition here where if the track finished
            // loading between this if statement and the render call above
            // and theres a line change queued, the line may not exist in
            // renderer, causing a crash
            if (!_loadingTrack)
            {
                var changes = Timeline.RequestFrameForRender(renderframe);
                foreach (var change in changes)
                {
                    GameLine line;
                    if (_track.LineLookup.TryGetValue(change, out line))
                    {
                        _renderer.RedrawLine(line);
                    }
                }
            }

            _renderer.Render(_track, Timeline, Camera, drawOptions);
        }