private Vector2d Calculate(int frame)
        {
            if (_cacheframe != -1 &&
                _cacheframe <= frame &&
                (frame - _cacheframe) < 80)
            {
                return(ClampFrames(
                           _cacheframe,
                           (frame - _cacheframe),
                           _cachepos));
            }
            Vector2d framecenter = _frames[frame].RiderCenter;
            var      box         = new CameraBoundingBox(framecenter);

            if (Settings.RoundLegacyCamera)
            {
                box.SetupSmooth(_frames[frame].ppf, _zoom);
            }
            else
            {
                box.SetupLegacy(_zoom);
            }
            var framebounds = box.Bounds;
            int calcstart   = 0;
            var ret         = framecenter;
            var xfound      = false;
            var yfound      = false;

            for (int i = frame; i >= 0; i--)
            {
                var current = _frames[i].RiderCenter;
                var cmp     = framecenter - current;
                // todo, i have no idea why this works.
                // seriously, ive tried so much stuff, but for the ellipse
                // camera i can't seem to make it work any better than with
                // width or height * 2
                if (Math.Abs(cmp.X) >= framebounds.Width * 2)
                {
                    xfound = true;
                }
                if (Math.Abs(cmp.Y) >= framebounds.Height * 2)
                {
                    yfound = true;
                }
                if (xfound && yfound)
                {
                    calcstart = i;
                    break;
                }
            }
            var calccount = (frame - calcstart);

            return(ClampFrames(calcstart, calccount, _frames[calcstart].RiderCenter));
        }
Ejemplo n.º 2
0
        public static CameraBoundingBox Create(Vector2d center, float zoom)
        {
            CameraBoundingBox box = new CameraBoundingBox(new Vector2d(center.X, center.Y));

            if (Settings.RoundLegacyCamera || Settings.SmoothCamera)
            {
                box.SetupSmooth(0, zoom);
            }
            else
            {
                box.SetupLegacy(zoom);
            }
            return(box);
        }
Ejemplo n.º 3
0
        private Vector2d Clamp(Vector2d pos, Vector2d center, double ppf)
        {
            CameraBoundingBox box = new CameraBoundingBox(center);

            if (Settings.SmoothCamera)
            {
                box.SetupSmooth(ppf, _zoom);
            }
            else
            {
                box.SetupLegacy(_zoom);
            }
            return(box.Clamp(pos));
        }
        private Vector2d Clamp(Vector2d pos, int frame)
        {
            var entry             = _frames[frame];
            CameraBoundingBox box = new CameraBoundingBox(entry.RiderCenter);

            if (Settings.RoundLegacyCamera)
            {
                box.SetupSmooth(entry.ppf, _zoom);
            }
            else
            {
                box.SetupLegacy(_zoom);
            }
            return(box.Clamp(pos));
        }
Ejemplo n.º 5
0
        public DoubleRect getclamp(float zoom, int width, int height)
        {
            var ret = GetViewport(zoom, width, height);
            var pos = ret.Vector + (ret.Size / 2);
            var b   = new CameraBoundingBox(pos);

            if (Settings.SmoothCamera || Settings.RoundLegacyCamera)
            {
                b.SetupSmooth(GetPPF(_currentframe), _zoom);
                return(b.Bounds);
            }
            else
            {
                b.SetupLegacy(_zoom);
                return(b.Bounds);
            }
        }
Ejemplo n.º 6
0
        public DoubleRect getclamp(float zoom, int width, int height, Vector2d offset)
        {
            offset.Y = -offset.Y; //Flip Y value so it's up, not down
            var ret = GetViewport(zoom, width, height, offset);
            var pos = ret.Vector + (ret.Size / 2);
            var b   = new CameraBoundingBox(pos);

            if (Settings.SmoothCamera || Settings.RoundLegacyCamera)
            {
                b.SetupSmooth(GetPPF(_currentframe), _zoom);
                return(b.Bounds);
            }
            else
            {
                b.SetupLegacy(_zoom);
                return(b.Bounds);
            }
        }