public void updateLists()
        {
            // handle removals
            if (_entitiesToRemove.Count > 0)
            {
                Utils.swap(ref _entitiesToRemove, ref _tempEntityList);
                for (var i = 0; i < _tempEntityList.Count; i++)
                {
                    var entity = _tempEntityList[i];

                    // handle the tagList
                    removeFromTagList(entity);

                    // handle the regular entity list
                    _entities.remove(entity);
                    entity.onRemovedFromScene();
                    entity.scene = null;

                    if (Core.entitySystemsEnabled)
                    {
                        scene.entityProcessors.onEntityRemoved(entity);
                    }
                }

                _tempEntityList.Clear();
            }

            // handle additions
            if (_entitiesToAdd.Count > 0)
            {
                Utils.swap(ref _entitiesToAdd, ref _tempEntityList);
                for (var i = 0; i < _tempEntityList.Count; i++)
                {
                    var entity = _tempEntityList[i];

                    _entities.add(entity);
                    entity.scene = scene;

                    // handle the tagList
                    addToTagList(entity);

                    if (Core.entitySystemsEnabled)
                    {
                        scene.entityProcessors.onEntityAdded(entity);
                    }
                }

                // now that all entities are added to the scene, we loop through again and call onAddedToScene
                for (var i = 0; i < _tempEntityList.Count; i++)
                {
                    _tempEntityList[i].onAddedToScene();
                }

                _tempEntityList.Clear();
                _isEntityListUnsorted = true;
            }

            if (_isEntityListUnsorted)
            {
                _entities.sort();
                _isEntityListUnsorted = false;
            }

            // sort our tagList if needed
            if (_unsortedTags.Count > 0)
            {
                for (int i = 0, count = _unsortedTags.Count; i < count; i++)
                {
                    var tag = _unsortedTags[i];
                    _entityDict[tag].Sort();
                }
                _unsortedTags.Clear();
            }
        }
        void calculateVertices()
        {
            if (!_areVertsDirty || _points.length < 2)
            {
                return;
            }

            _areVertsDirty = false;
            _indices.reset();
            _vertices.reset();

            var maxX = float.MinValue;
            var minX = float.MaxValue;
            var maxY = float.MinValue;
            var minY = float.MaxValue;

            if (_useStartEndWidths)
            {
                _maxWidth = System.Math.Max(_startWidth, _endWidth);
            }

            // calculate line length first and simulataneously get our min/max points for the bounds
            var lineLength   = 0f;
            var halfMaxWidth = _maxWidth * 0.5f;

            _points.buffer[0].lengthFromPreviousPoint = 0;
            for (var i = 0; i < _points.length - 1; i++)
            {
                var distance = Vector2.Distance(_points.buffer[i].position, _points.buffer[i + 1].position);
                _points.buffer[i + 1].lengthFromPreviousPoint = distance;
                lineLength += distance;

                maxX = Mathf.maxOf(maxX, _points.buffer[i].position.X + halfMaxWidth, _points.buffer[i + 1].position.X + halfMaxWidth);
                minX = Mathf.minOf(minX, _points.buffer[i].position.X - halfMaxWidth, _points.buffer[i + 1].position.X - halfMaxWidth);
                maxY = Mathf.maxOf(maxY, _points.buffer[i].position.Y + halfMaxWidth, _points.buffer[i + 1].position.Y + halfMaxWidth);
                minY = Mathf.minOf(minY, _points.buffer[i].position.Y - halfMaxWidth, _points.buffer[i + 1].position.Y - halfMaxWidth);
            }

            _bounds.x      = minX;
            _bounds.y      = minY;
            _bounds.width  = maxX - minX;
            _bounds.height = maxY - minY;

            // special case: single segment
            if (_points.length == 2)
            {
                if (_useStartEndWidths)
                {
                    _points.buffer[0].width = _startWidth;
                    _points.buffer[1].width = _endWidth;
                }

                if (_useStartEndColors)
                {
                    _points.buffer[0].color = _startColor;
                    _points.buffer[1].color = _endColor;
                }

                _firstSegment.setPoints(ref _points.buffer[0], ref _points.buffer[1]);
                addSingleSegmentLine(ref _firstSegment, _points.buffer[1].color);
                return;
            }

            var distanceSoFar = 0f;
            var fusedPoint    = Vector2.Zero;
            var vertIndex     = 0;
            var thirdPoint    = new SegmentPoint();

            for (var i = 0; i < _points.length - 1; i++)
            {
                var firstPoint  = _points.buffer[i];
                var secondPoint = _points.buffer[i + 1];

                var hasThirdPoint = _points.length > i + 2;
                if (hasThirdPoint)
                {
                    thirdPoint = _points.buffer[i + 2];
                }

                // we need the distance along the line of both the first and second points. distanceSoFar will always be for the furthest point
                // which is the previous point before adding the current segment distance.
                var firstPointDistance = distanceSoFar;
                distanceSoFar += secondPoint.lengthFromPreviousPoint;

                var firstPointRatio  = firstPointDistance / lineLength;
                var secondPointRatio = distanceSoFar / lineLength;
                var thirdPointRatio  = 0f;
                if (hasThirdPoint)
                {
                    thirdPointRatio = (distanceSoFar + thirdPoint.lengthFromPreviousPoint) / lineLength;
                }

                if (_useStartEndColors)
                {
                    ColorExt.lerp(ref _startColor, ref _endColor, out firstPoint.color, firstPointRatio);
                    ColorExt.lerp(ref _startColor, ref _endColor, out secondPoint.color, secondPointRatio);

                    if (hasThirdPoint)
                    {
                        ColorExt.lerp(ref _startColor, ref _endColor, out thirdPoint.color, thirdPointRatio);
                    }
                }

                if (_useStartEndWidths)
                {
                    firstPoint.width  = Mathf.lerp(_startWidth, _endWidth, firstPointRatio);
                    secondPoint.width = Mathf.lerp(_startWidth, _endWidth, secondPointRatio);

                    if (hasThirdPoint)
                    {
                        thirdPoint.width = Mathf.lerp(_startWidth, _endWidth, thirdPointRatio);
                    }
                }


                if (i == 0)
                {
                    _firstSegment.setPoints(ref firstPoint, ref secondPoint);
                    _secondSegment.setPoints(ref secondPoint, ref thirdPoint);
                }
                else
                {
                    Utils.swap(ref _firstSegment, ref _secondSegment);
                    if (hasThirdPoint)
                    {
                        _secondSegment.setPoints(ref secondPoint, ref thirdPoint);
                    }
                }

                // dont recalculate the fusedPoint for the last segment since there will be no third point to work with
                if (hasThirdPoint)
                {
                    var shouldFuseBottom = Vector2Ext.isTriangleCCW(firstPoint.position, secondPoint.position, thirdPoint.position);
                    _secondSegment.setFusedData(shouldFuseBottom, ref _firstSegment);
                }

                // special care needs to be take with the first segment since it has a different vert count
                if (i == 0)
                {
                    addFirstSegment(ref _firstSegment, ref _secondSegment, ref vertIndex);
                }
                else
                {
                    addSegment(ref _firstSegment, ref vertIndex);
                }

                _lastSegment.cloneFrom(ref _firstSegment);
            }
        }