コード例 #1
0
        protected override void Prepare(PrepareManager manager)
        {
            _DrawCalls.Sort(_Comparer);

            int primCount = 0;

            for (int i = 0, c = _DrawCalls.Count; i < c; i++)
            {
                primCount += _DrawCalls[i].PrimitiveCount;
            }

            NativeBatch.RecordPrimitives(primCount);
        }
コード例 #2
0
ファイル: RenderGeometry.cs プロジェクト: jli94/Fracture
        protected override void Prepare(PrepareManager manager)
        {
            if (Count > 0)
            {
                _BufferGenerator = Container.RenderManager.GetBufferGenerator <BufferGenerator <GeometryVertex> >();

                _DrawArguments = _DrawArgumentsListPool.Allocate(null);
                var swb = _BufferGenerator.Allocate(VertexCount, IndexCount, true);
                _SoftwareBuffer = swb;

                var vb = new Internal.VertexBuffer <GeometryVertex>(swb.Vertices);
                var ib = new Internal.IndexBuffer(swb.Indices);
                int vertexOffset = 0, indexOffset = 0;
                int totalPrimCount = 0;

                foreach (var kvp in Lists)
                {
                    var l = kvp.Value;
                    var c = l.Count;

                    l.FastCLRSort(_DrawCallSorter);

                    int vertexCount = vb.Count, indexCount = ib.Count;

                    var _l = l.GetBuffer();
                    for (int i = 0; i < c; i++)
                    {
                        var dc = _l[i];
                        dc.Preparer(ref vb, ref ib, ref dc);
                    }

                    vertexCount = vb.Count - vertexCount;
                    indexCount  = ib.Count - indexCount;

                    int primCount;
                    MakeDrawArguments(kvp.Key, ref vb, ref ib, ref vertexOffset, ref indexOffset, out primCount, vertexCount, indexCount);

                    totalPrimCount += primCount;
                }

                NativeBatch.RecordPrimitives(totalPrimCount);
            }
        }