public Rider GetStart()
 {
     return(Rider.Create(this.StartOffset, new Vector2d(ZeroStart ? 0 : RiderConstants.StartingMomentum, 0)));
 }
Exemple #2
0
 public void Reset(Rider r)
 {
     r.Reset(_track.Start, _track);
 }
Exemple #3
0
        /// <summary>
        /// Ticks the rider in the simulation
        /// </summary>
        public Rider TickBasic(Rider state, int maxiteration = 6)
        {
            int trig = 0;

            return(state.Simulate(_track.Grid, _track.Bones, ref trig, null, maxiteration));
        }
Exemple #4
0
 public void SetRiderState(Rider r)
 {
     _track.RiderState = r;
 }
Exemple #5
0
        public void Render()
        {
            var rect        = Camera.GetRenderRect(Zoom, game.RenderSize.Width, game.RenderSize.Height);
            var st          = OpenTK.Input.Keyboard.GetState();
            var needsredraw = (!_trackrect.Contains(rect.Left, rect.Top) ||
                               !_trackrect.Contains(rect.Left + rect.Width, rect.Top + rect.Height));

            if (!needsredraw)
            {
                var viewport = rect.Inflate(rect.Width, rect.Height);
                if (viewport.Width < _trackrect.Width / 3 && viewport.Height < _trackrect.Height / 3)
                {
                    needsredraw = true;
                }
            }
            var drawcolor = !Animating || Paused || game.SettingColorPlayback;

            if (game.SettingPreviewMode)
            {
                drawcolor = false;
            }
            var knob       = 0;
            var adjustTool = game.SelectedTool as LineAdjustTool;

            if (adjustTool != null && (!Animating || Paused))
            {
                knob = 1;
                if ((!adjustTool.Started && (st[OpenTK.Input.Key.AltLeft] || st[OpenTK.Input.Key.AltRight])) ||
                    adjustTool.LifeLock)
                {
                    knob = 2;
                }
            }
            if (needsredraw || RequiresUpdate)
            {
                EnterTrackRead();
                var viewport = rect.Inflate(rect.Width, rect.Height);
                var lines    = _track.GetLinesInRect(viewport, false, true);
                _trackrect = viewport;
                _renderer.UpdateViewport(lines);
                ExitTrackRead();
            }
            _renderer.Render(_track, drawcolor, knob, game.SettingRenderGravityWells);
            _sceneryrenderer.Render(drawcolor);
            List <RiderDrawCommand> commands = new List <RiderDrawCommand>();

            EnterPlayback();
            if (game.IterationsOffset != 6 && Frame != 0 && Animating && Paused)
            {
                var renderstate = _track.RiderStates[Frame - 1].Clone();
                _track.TickWithIterations(renderstate);
                commands.Add(new RiderDrawCommand(game.IterationsOffset, renderstate, game.SettingDrawContactPoints ? 0.4f : 1, true,
                                                  game.SettingDrawContactPoints, game.SettingMomentumVectors));
            }
            else
            {
                commands.Add(new RiderDrawCommand(RiderState.Clone(), game.SettingDrawContactPoints ? 0.4f : 1, true,
                                                  game.SettingDrawContactPoints, game.SettingMomentumVectors));
            }
            if (game.SettingOnionSkinning && _track.RiderStates.Count != 0 && Animating)
            {
                const int onions      = 10;
                Rider[]   onionstates = new Rider[onions * 2];
                for (int i = 0; i < onions; i++)
                {
                    var frame = _track.Frame - (onions - i);
                    if (frame > 0)
                    {
                        onionstates[i] = _track.RiderStates[frame].Clone();
                    }
                }
                Rider positivestate = _track.RiderStates[_track.Frame].Clone();

                for (int i = onions + 1; i < onions * 2; i++)
                {
                    _track.Tick(positivestate);
                    onionstates[i] = positivestate.Clone();
                }

                foreach (var state in onionstates)
                {
                    if (state == null)
                    {
                        continue;
                    }
                    commands.Add(new RiderDrawCommand(state, 0.2f, false,
                                                      game.SettingDrawContactPoints, game.SettingMomentumVectors));
                }
            }
            if (_flag != null)
            {
                commands.Add(new RiderDrawCommand(_flag.State.Clone(), 0.6f, false,
                                                  game.SettingDrawContactPoints, game.SettingMomentumVectors));
            }
            ExitPlayback();
            foreach (var v in commands)            //todo rider vbo for every rider, massive improvements.
            {
                if (v.iteration != -1)
                {
                    GameRenderer.DrawIteration(v.opacity, v.state, v.iteration, v.momentum, v.contactpoints);
                }
                else
                {
                    GameRenderer.DrawRider(v.opacity, v.state, v.scarf, v.contactpoints, v.momentum);
                }
            }
        }
Exemple #6
0
 public HashSet <int> Diagnose(Rider state)
 {
     return(_track.Diagnose(state));
 }
Exemple #7
0
 public HashSet <int> DiagnoseIteration(Rider state, int it)
 {
     return(_track.DiagnoseIteration(state, it));
 }
Exemple #8
0
        public ConcurrentDictionary <int, StandardLine> Tick(Rider state)
        {
            var ret = _track.Tick(state);

            return(ret);
        }
Exemple #9
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 #10
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);
        }