示例#1
0
    public dfList <T> Concat(dfList <T> list)
    {
        dfList <T> list2 = dfList <T> .Obtain(this.count + list.count);

        list2.AddRange((dfList <T>) this);
        list2.AddRange(list);
        return(list2);
    }
示例#2
0
    public dfList <T> Concat(dfList <T> list)
    {
        dfList <T> ts = dfList <T> .Obtain(this.count + list.count);

        ts.AddRange(this);
        ts.AddRange(list);
        return(ts);
    }
示例#3
0
    /// <summary>
    /// Merges another <see cref="dfRenderData"/> instance with this instance
    /// </summary>
    /// <param name="buffer">The render data to be appended to this instance</param>
    /// <param name="transformVertices">If set to TRUE, the render data in
    /// <paramref name="buffer"/> will be transformed by its <see cref="Transform"/>
    /// before being merged with this instance. If set to FALSE, the data will be
    /// merged without tranforming.</param>
    public void Merge(dfRenderData buffer, bool transformVertices)
    {
        // We need the current currentIndex of vertices before adding any more so that
        // we have a proper base index for our triangle indices
        var baseIndex = Vertices.Count;

        #region Merge vertices

        Vertices.AddRange(buffer.Vertices);
        if (transformVertices)
        {
            var rawVerts  = Vertices.Items;
            var count     = buffer.Vertices.Count;
            var transform = buffer.Transform;

            for (int i = baseIndex; i < baseIndex + count; i++)
            {
                rawVerts[i] = transform.MultiplyPoint(rawVerts[i]);
            }
        }

        #endregion

        #region Merge triangles

        var triangleBaseIndex = Triangles.Count;

        Triangles.AddRange(buffer.Triangles);

        var bufferTriangleCount = buffer.Triangles.Count;
        var rawTriangles        = Triangles.Items;
        for (int i = triangleBaseIndex; i < triangleBaseIndex + bufferTriangleCount; i++)
        {
            rawTriangles[i] += baseIndex;
        }

        #endregion

        UV.AddRange(buffer.UV);
        Colors.AddRange(buffer.Colors);
        Normals.AddRange(buffer.Normals);
        Tangents.AddRange(buffer.Tangents);
    }
示例#4
0
 private void addQuadUV(dfList <Vector2> uv, Vector2[] spriteUV)
 {
     uv.AddRange(spriteUV);
 }
示例#5
0
 private void addQuadUV( dfList<Vector2> uv, Vector2[] spriteUV )
 {
     uv.AddRange( spriteUV );
 }
    internal void Render( Camera renderCamera, dfControl control, dfList<Rect> occluders, dfList<dfControl> controlsRendered, uint checksum, float opacity )
    {
        if( meshRenderer == null )
        {
            initialize();
        }

        this.renderCamera = renderCamera;
        this.attachedControl = control;

        if( !isDirty )
        {

            // Update the caller's lists
            occluders.AddRange( groupOccluders );
            controlsRendered.AddRange( groupControls );

            return;

        }

        // Clear lists that will contain the results of the rendering process
        groupOccluders.Clear();
        groupControls.Clear();
        renderGroups.Clear();
        resetDrawCalls();

        // Disable shader clipping by default
        this.clipInfo = new ClipRegionInfo();
        this.clipRect = new Rect();

        // Define the main draw call buffer, which will be assigned as needed
        // by the renderControl() method
        var buffer = (dfRenderData)null;

        using( var defaultClipRegion = dfTriangleClippingRegion.Obtain() )
        {

            // Initialize the clipping region stack
            clipStack.Clear();
            clipStack.Push( defaultClipRegion );

            // Render the control and all of its children
            renderControl( ref buffer, control, checksum, opacity );

            // The clip stack is reset after every frame as it's only needed during rendering
            clipStack.Pop();

        }

        // Remove any empty draw call buffers. There might be empty
        // draw call buffers due to controls that were clipped.
        drawCallBuffers.RemoveAll( isEmptyBuffer );
        drawCallCount = drawCallBuffers.Count;

        // At this point, the drawCallCount variable contains the
        // number of draw calls needed to render the user interface.
        if( drawCallBuffers.Count == 0 )
        {
            meshRenderer.enabled = false;
            return;
        }
        else
        {
            meshRenderer.enabled = true;
        }

        // Consolidate all draw call buffers into one master buffer
        // that will be used to build the Mesh
        var masterBuffer = compileMasterBuffer();

        // Build the master mesh
        var mesh = renderMesh;
        mesh.Clear( true );
        mesh.vertices = masterBuffer.Vertices.ToTempArray();
        mesh.uv = masterBuffer.UV.ToTempArray();
        mesh.colors32 = masterBuffer.Colors.ToTempArray();

        #region Set sub-meshes

        mesh.subMeshCount = submeshes.Count;
        for( int i = 0; i < submeshes.Count; i++ )
        {

            // Calculate the start and length of the submesh array
            var startIndex = submeshes[ i ];
            var length = masterBuffer.Triangles.Count - startIndex;
            if( i < submeshes.Count - 1 )
            {
                length = submeshes[ i + 1 ] - startIndex;
            }

            var submeshTriangles = dfTempArray<int>.Obtain( length, 128 );
            masterBuffer.Triangles.CopyTo( startIndex, submeshTriangles, 0, length );

            // Set the submesh's triangle index array
            mesh.SetTriangles( submeshTriangles, i );

        }

        #endregion

        // This render group no longer requires updating
        isDirty = false;

        // Update the caller's lists
        occluders.AddRange( groupOccluders );
        controlsRendered.AddRange( groupControls );
    }
    internal void Render(Camera renderCamera, dfControl control, dfList <Rect> occluders, dfList <dfControl> controlsRendered, uint checksum, float opacity)
    {
        if (meshRenderer == null)
        {
            initialize();
        }

        this.renderCamera    = renderCamera;
        this.attachedControl = control;

        if (!isDirty)
        {
            // Update the caller's lists
            occluders.AddRange(groupOccluders);
            controlsRendered.AddRange(groupControls);

            return;
        }

        // Clear lists that will contain the results of the rendering process
        groupOccluders.Clear();
        groupControls.Clear();
        renderGroups.Clear();
        resetDrawCalls();

        // Disable shader clipping by default
        this.clipInfo = new ClipRegionInfo();
        this.clipRect = new Rect();

        // Define the main draw call buffer, which will be assigned as needed
        // by the renderControl() method
        var buffer = (dfRenderData)null;

        using (var defaultClipRegion = dfTriangleClippingRegion.Obtain())
        {
            // Initialize the clipping region stack
            clipStack.Clear();
            clipStack.Push(defaultClipRegion);

            // Render the control and all of its children
            renderControl(ref buffer, control, checksum, opacity);

            // The clip stack is reset after every frame as it's only needed during rendering
            clipStack.Pop();
        }

        // Remove any empty draw call buffers. There might be empty
        // draw call buffers due to controls that were clipped.
        drawCallBuffers.RemoveAll(isEmptyBuffer);
        drawCallCount = drawCallBuffers.Count;

        // At this point, the drawCallCount variable contains the
        // number of draw calls needed to render the user interface.
        if (drawCallBuffers.Count == 0)
        {
            meshRenderer.enabled = false;
            return;
        }
        else
        {
            meshRenderer.enabled = true;
        }

        // Consolidate all draw call buffers into one master buffer
        // that will be used to build the Mesh
        var masterBuffer = compileMasterBuffer();

        // Build the master mesh
        var mesh = renderMesh;

        mesh.Clear(true);
        mesh.vertices = masterBuffer.Vertices.Items;
        mesh.uv       = masterBuffer.UV.Items;
        mesh.colors32 = masterBuffer.Colors.Items;

        #region Set sub-meshes

        mesh.subMeshCount = submeshes.Count;
        for (int i = 0; i < submeshes.Count; i++)
        {
            // Calculate the start and length of the submesh array
            var startIndex = submeshes[i];
            var length     = masterBuffer.Triangles.Count - startIndex;
            if (i < submeshes.Count - 1)
            {
                length = submeshes[i + 1] - startIndex;
            }

            var submeshTriangles = dfTempArray <int> .Obtain(length);

            masterBuffer.Triangles.CopyTo(startIndex, submeshTriangles, 0, length);

            // Set the submesh's triangle index array
            mesh.SetTriangles(submeshTriangles, i);
        }

        #endregion

        // This render group no longer requires updating
        isDirty = false;

        // Update the caller's lists
        occluders.AddRange(groupOccluders);
        controlsRendered.AddRange(groupControls);
    }