Beispiel #1
0
        public int Compare(ref PrimitiveDrawCall <T> x, ref PrimitiveDrawCall <T> y)
        {
            // FIXME: Tags?
            var result = (x.SortKey.Order > y.SortKey.Order)
                ? 1
                : (
                (x.SortKey.Order < y.SortKey.Order)
                    ? -1
                    : 0
                );

            return(result);
        }
Beispiel #2
0
 public int Compare(PrimitiveDrawCall <T> x, PrimitiveDrawCall <T> y)
 {
     return(Compare(ref x, ref y));
 }
Beispiel #3
0
        new public void Add(ref PrimitiveDrawCall <T> item)
        {
            if (item.Vertices == null)
            {
                return;
            }

#if VALIDATE
            var indexCount = item.PrimitiveType.ComputeVertexCount(item.PrimitiveCount);
            Debug.Assert(
                item.Indices.Length >= item.IndexOffset + indexCount
                );

            for (int i = 0; i < indexCount; i++)
            {
                Debug.Assert(item.Indices[i + item.IndexOffset] >= 0);
                Debug.Assert(item.Indices[i + item.IndexOffset] < item.VertexCount);
            }
#endif

            var _drawCalls = _DrawCalls.GetBuffer(true);
            int count      = _DrawCalls.Count;
            while (count > 0)
            {
                PrimitiveDrawCall <T> lastCall = _drawCalls[count - 1];

                // Attempt to combine
                if (lastCall.PrimitiveType != item.PrimitiveType)
                {
                    break;
                }

                if ((item.PrimitiveType == PrimitiveType.TriangleStrip) || (item.PrimitiveType == PrimitiveType.LineStrip))
                {
                    break;
                }

                if (lastCall.Vertices != item.Vertices)
                {
                    break;
                }
                if (item.VertexOffset != lastCall.VertexOffset + lastCall.VertexCount)
                {
                    break;
                }

                if ((lastCall.Indices ?? item.Indices) != null)
                {
                    break;
                }

                _drawCalls[count - 1] = new PrimitiveDrawCall <T>(
                    lastCall.PrimitiveType, lastCall.Vertices,
                    lastCall.VertexOffset, lastCall.VertexCount + item.VertexCount,
                    null, 0,
                    lastCall.PrimitiveCount + item.PrimitiveCount
                    );
                return;
            }

            base.Add(ref item);
        }
Beispiel #4
0
 public void Add(PrimitiveDrawCall <T> item)
 {
     Add(ref item);
 }