示例#1
0
 public void AddFrames(List <LinkedList <int> > collisionlist)
 {
     foreach (var collisions in collisionlist)
     {
         int           frameid = _unique_frame_collisions.Count;
         HashSet <int> unique  = new HashSet <int>();
         foreach (var collision in collisions)
         {
             var id = collision;
             if (_allcollisions.Add(id))
             {
                 if (Settings.Editor.HitTest)
                 {
                     if (_currentframe >= frameid)
                     {
                         _renderer_changelist.Add(id);
                     }
                 }
                 unique.Add(id);
                 _line_framehit.Add(id, frameid);
             }
         }
         _unique_frame_collisions.Add(unique);
     }
 }
示例#2
0
        public Dictionary <int, int> AddLines(List <GameLine> lines, LineVertex[] vertices)
        {
            Dictionary <int, int> ret = new Dictionary <int, int>(lines.Count);
            int startidx  = _indices.Count;
            int startvert = _vertexcount;

            _indices.EnsureCapacity(vertices.Length);
            for (int ix = 0; ix < lines.Count; ix++)
            {
                var baseoffset = (ix * linesize);
                for (int i = 0; i < linesize; i++)
                {
                    _indices.Add(startvert + baseoffset + i);
                }
                ret.Add(lines[ix].ID, startidx + baseoffset);
            }
            _vbo.Bind();
            EnsureVBOSize(_vertexcount + vertices.Length);
            _vbo.SetData(vertices, 0, _vertexcount, vertices.Length);
            _vbo.Unbind();
            _vertexcount += vertices.Length;

            _ibo.Bind();
            EnsureIBOSize(_indices.Count + vertices.Length);
            _ibo.SetData(_indices.unsafe_array, startidx, startidx, vertices.Length);
            _ibo.Unbind();
            return(ret);
        }
示例#3
0
        /// <summary>
        /// Clears the timeline of pre-calculated frames and starts at the
        /// new provided state.
        /// </summary>
        /// <param name="state">The start position, frame 0</param>
        public void Restart(Rider state, float zoom)
        {
            using (_framesync.AcquireWrite())
            {
                _hittest.Reset();
                _frames.Clear();
                _frames.Add(new frameinfo()
                {
                    Rider     = state,
                    Zoom      = zoom,
                    BGColor   = new Color4((byte)_track.BGColorR, (byte)_track.BGColorG, (byte)_track.BGColorB, (byte)255),
                    LineColor = Color.FromArgb(255, _track.LineColorR, _track.LineColorG, _track.LineColorB),
                });
                //Also reset the trigger colors
                Constants.TriggerBGColor               = new Color4((byte)_track.BGColorR, (byte)_track.BGColorG, (byte)_track.BGColorB, (byte)255);
                Constants.StaticTriggerBGColor         = new Color4((byte)_track.BGColorR, (byte)_track.BGColorG, (byte)_track.BGColorB, (byte)255);
                Constants.TriggerLineColorChange       = Color.FromArgb(255, _track.LineColorR, _track.LineColorG, _track.LineColorB);
                Constants.StaticTriggerLineColorChange = Color.FromArgb(255, _track.LineColorR, _track.LineColorG, _track.LineColorB);
                //Set Gravity
                RiderConstants.Gravity = new Vector2d(0.175 * _track.XGravity, 0.175 * _track.YGravity); //gravity
                //Set Gravity well size
                StandardLine.Zone = _track.GravityWellSize;

                using (changesync.AcquireWrite())
                {
                    _first_invalid_frame = _frames.Count;
                }
            }
        }
示例#4
0
 /// <summary>
 /// Clears the timeline of pre-calculated frames and starts at the
 /// new provided state.
 /// </summary>
 /// <param name="state">The start position, frame 0</param>
 public void Restart(Rider state)
 {
     using (_framesync.AcquireWrite())
     {
         _hittest.Reset();
         _frames.Clear();
         _frames.Add(state);
         using (changesync.AcquireWrite())
         {
             _first_invalid_frame = _frames.Count;
         }
     }
 }
示例#5
0
 /// <summary>
 /// Clears the timeline of pre-calculated frames and starts at the
 /// new provided state.
 /// </summary>
 /// <param name="state">The start position, frame 0</param>
 public void Restart(Rider state, float zoom)
 {
     using (_framesync.AcquireWrite())
     {
         _hittest.Reset();
         _frames.Clear();
         _frames.Add(new frameinfo()
         {
             Rider = state, TriggerHitFrame = -1, TriggerLineID = -1, Zoom = zoom
         });
         using (changesync.AcquireWrite())
         {
             _first_invalid_frame = _frames.Count;
         }
     }
 }
示例#6
0
        /// <summary>
        /// Redraws the red line accel indicator.
        /// </summary>
        private void DrawAccel(RedLine line, bool hide)
        {
            var entry    = _lookup[line.ID];
            var newdecor = hide ? new GenericVertex[ShapeSize * line.Multiplier] : GetAccelDecor(line);
            int shapes   = newdecor.Length / ShapeSize;

            for (int ix = 0; ix < entry.shapes; ix++)
            {
                int offset = entry.start + (ix * ShapeSize);
                if (IsNulled(offset))
                {
                    continue;//nulled out
                }
                _freeverts.Enqueue(_indices.unsafe_array[offset]);
                for (int i = 0; i < ShapeSize; i++)
                {
                    _indices.unsafe_array[offset + i] = nullindex;
                }
            }
            bool growing = shapes > entry.shapes;

            _accelbuffer.Bind();
            for (int ix = 0; ix < shapes; ix++)
            {
                var vertexbase = GetVertexBase();
                _accelbuffer.SetData(
                    newdecor,
                    ShapeSize * ix,
                    vertexbase,
                    ShapeSize);
                for (int i = 0; i < ShapeSize; i++)
                {
                    if (growing)
                    {
                        _indices.Add(vertexbase + i);
                    }
                    else
                    {
                        int offset = entry.start + (ix * ShapeSize) + i;
                        _indices.unsafe_array[offset] = vertexbase + i;
                    }
                }
            }
            _accelbuffer.Unbind();

            _accelibo.Bind();
            _accelibo.SetData(
                _indices.unsafe_array,
                entry.start,
                entry.start,
                entry.shapes * ShapeSize);
            if (growing)
            {
                int startindex = _indices.Count - (shapes * ShapeSize);
                EnsureIBOSize(_indices.Count);
                _accelibo.SetData(
                    _indices.unsafe_array,
                    startindex,
                    startindex,
                    shapes * ShapeSize);
                _lookup[line.ID] = new accelentry()
                {
                    shapes = shapes,
                    start  = startindex
                };
            }
            _accelibo.Unbind();
        }
 public ClampCamera()
 {
     _frames.Add(new CameraEntry(Vector2d.Zero));
 }
示例#8
0
 public ICamera()
 {
     _frames.Add(new CameraEntry(Vector2d.Zero));
     _framecache.Add(Vector2d.Zero);
 }
示例#9
0
        /// <summary>
        /// Clears the renderer and initializes it with new lines.
        /// </summary>
        public void InitializeTrack(Track track)
        {
            AutoArray <GameLine> scenery = new AutoArray <GameLine>(track.SceneryLines);

            scenery.UnsafeSetCount(track.SceneryLines);
            AutoArray <GameLine> phys  = new AutoArray <GameLine>(track.BlueLines);
            AutoArray <GameLine> accel = new AutoArray <GameLine>(track.RedLines);
            var sorted = track.GetSortedLines();

            using (_sync.AcquireWrite())
            {
                _lineactions.Clear();
                _physvbo.Clear();
                _sceneryvbo.Clear();
                _accelvbo.Clear();
                _bluedecorator.Clear();
                _acceldecorator.Clear();
                _physlines.Clear();
                _scenerylines.Clear();
                _accellines.Clear();
                RequiresUpdate = true;

                int scenerycount = 0;
                for (int i = 0; i < sorted.Length; i++)
                {
                    var line = sorted[i];

                    switch (line.Type)
                    {
                    case LineType.Scenery:
                        scenery.unsafe_array[scenery.Count - (1 + scenerycount++)] = line;
                        break;

                    case LineType.Blue:
                        phys.Add(line);
                        break;

                    case LineType.Red:
                        accel.Add(line);
                        break;
                    }
                }

                Debug.Assert(scenerycount == scenery.Count,
                             "Predicted scenery count was not accurate");
                if (scenery.Count != 0)
                {
                    LineVertex[] sceneryverts = new LineVertex[scenery.Count * linesize];
                    System.Threading.Tasks.Parallel.For(0, scenery.Count, (index) =>
                    {
                        int counter = 0;
                        var verts   = (GenerateLine(scenery[index], false));
                        foreach (var vert in verts)
                        {
                            sceneryverts[index * linesize + counter++] = vert;
                        }
                    });
                    _scenerylines = _sceneryvbo.AddLines(
                        scenery,
                        sceneryverts);
                }
                if (phys.Count != 0)
                {
                    LineVertex[] physverts = new LineVertex[phys.Count * linesize];
                    System.Threading.Tasks.Parallel.For(0, phys.Count, (index) =>
                    {
                        int counter = 0;
                        var verts   = (GenerateLine(phys[index], false));
                        foreach (var vert in verts)
                        {
                            physverts[index * linesize + counter++] = vert;
                        }
                    });
                    _physlines = _physvbo.AddLines(
                        phys,
                        physverts);
                    _bluedecorator.Initialize(phys);
                }
                if (accel.Count != 0)
                {
                    LineVertex[] accelverts = new LineVertex[accel.Count * linesize];
                    System.Threading.Tasks.Parallel.For(0, accel.Count, (index) =>
                    {
                        int counter = 0;
                        var verts   = (GenerateLine(accel[index], false));
                        foreach (var vert in verts)
                        {
                            accelverts[index * linesize + counter++] = vert;
                        }
                    });
                    _accellines = _accelvbo.AddLines(
                        accel,
                        accelverts);
                    _acceldecorator.Initialize(accel);
                }
                RequiresUpdate = true;
            }
        }
示例#10
0
 public void AddVertex(T vertex)
 {
     Array.Add(vertex);
 }