Пример #1
0
        internal static void BindProxyGeometry(MyRenderableProxy proxy, MyRenderContext renderContext)
        {
            MyMeshBuffers buffers;

            if (proxy.Mesh != LodMeshId.NULL)
            {
                buffers = proxy.Mesh.Buffers;
            }
            else
            {
                buffers = proxy.MergedMesh.Buffers;
            }

            bool firstChanged  = renderContext.UpdateVB(0, buffers.VB0.Buffer, buffers.VB0.Stride);
            bool secondChanged = renderContext.UpdateVB(1, buffers.VB1.Buffer, buffers.VB1.Stride);

            if (firstChanged && secondChanged)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(buffers.VB0.Buffer, buffers.VB0.Stride, 0));
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(1, new VertexBufferBinding(buffers.VB1.Buffer, buffers.VB1.Stride, 0));
                renderContext.Stats.SetVB++;
            }
            else if (firstChanged)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(buffers.VB0.Buffer, buffers.VB0.Stride, 0));
                renderContext.Stats.SetVB++;
            }
            else if (secondChanged)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(1, new VertexBufferBinding(buffers.VB1.Buffer, buffers.VB1.Stride, 0));
                renderContext.Stats.SetVB++;
            }

            if (proxy.InstancingEnabled && proxy.Instancing.VB.Index != -1)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(2, new VertexBufferBinding(proxy.Instancing.VB.Buffer, proxy.Instancing.VB.Stride, 0));
                renderContext.Stats.SetVB++;
            }
            renderContext.SetIB(buffers.IB.Buffer, buffers.IB.Format);
        }
Пример #2
0
        internal static void BindProxyGeometry(MyRenderableProxy proxy, MyRenderContext renderContext)
        {
            MyMeshBuffers buffers;
            
            if(proxy.Mesh != LodMeshId.NULL)
                buffers = proxy.Mesh.Buffers;
            else
                buffers = proxy.MergedMesh.Buffers;

            bool firstChanged = renderContext.UpdateVB(0, buffers.VB0.Buffer, buffers.VB0.Stride);
            bool secondChanged = renderContext.UpdateVB(1, buffers.VB1.Buffer, buffers.VB1.Stride);
            
            if (firstChanged && secondChanged)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(buffers.VB0.Buffer, buffers.VB0.Stride, 0));
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(1, new VertexBufferBinding(buffers.VB1.Buffer, buffers.VB1.Stride, 0));
                renderContext.Stats.SetVB++;
            }
            else if (firstChanged)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(buffers.VB0.Buffer, buffers.VB0.Stride, 0));
                renderContext.Stats.SetVB++;
            }
            else if (secondChanged)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(1, new VertexBufferBinding(buffers.VB1.Buffer, buffers.VB1.Stride, 0));
                renderContext.Stats.SetVB++;
            }
            
            if (proxy.InstancingEnabled && proxy.Instancing.VB.Index != -1)
            {
                renderContext.DeviceContext.InputAssembler.SetVertexBuffers(2, new VertexBufferBinding(proxy.Instancing.VB.Buffer, proxy.Instancing.VB.Stride, 0));
                renderContext.Stats.SetVB++;
            }
            renderContext.SetIB(buffers.IB.Buffer, buffers.IB.Format);
        }