Пример #1
0
    private dfIntersectionType getViewportIntersection(dfMarkupBox box)
    {
        if (box.Display == dfMarkupDisplayType.none)
        {
            return(dfIntersectionType.None);
        }

        var viewSize = this.Size;
        var min      = box.GetOffset() - scrollPosition;
        var max      = min + box.Size;

        if (max.x <= 0 || max.y <= 0)
        {
            return(dfIntersectionType.None);
        }

        if (min.x >= viewSize.x || min.y >= viewSize.y)
        {
            return(dfIntersectionType.None);
        }

        if (min.x < 0 || min.y < 0 || max.x > viewSize.x || max.y > viewSize.y)
        {
            return(dfIntersectionType.Intersecting);
        }

        return(dfIntersectionType.Inside);
    }
Пример #2
0
    private void gatherRenderBuffers(dfMarkupBox box, dfList <dfRenderData> buffers)
    {
        dfIntersectionType type = this.getViewportIntersection(box);

        if (type != dfIntersectionType.None)
        {
            dfRenderData renderData = box.Render();
            if (renderData != null)
            {
                if ((renderData.Material == null) && (this.atlas != null))
                {
                    renderData.Material = this.atlas.Material;
                }
                float            num                = base.PixelsToUnits();
                Vector2          vector             = -this.scrollPosition.Scale(1f, -1f).RoundToInt();
                Vector3          vector2            = ((Vector3)(vector + box.GetOffset().Scale(1f, -1f))) + base.pivot.TransformToUpperLeft(base.Size);
                dfList <Vector3> vertices           = renderData.Vertices;
                Matrix4x4        localToWorldMatrix = base.transform.localToWorldMatrix;
                for (int j = 0; j < renderData.Vertices.Count; j++)
                {
                    vertices[j] = localToWorldMatrix.MultiplyPoint((Vector3)((vector2 + vertices[j]) * num));
                }
                if (type == dfIntersectionType.Intersecting)
                {
                    this.clipToViewport(renderData);
                }
                buffers.Add(renderData);
            }
            for (int i = 0; i < box.Children.Count; i++)
            {
                this.gatherRenderBuffers(box.Children[i], buffers);
            }
        }
    }
Пример #3
0
    private void gatherRenderBuffers(dfMarkupBox box, dfList <dfRenderData> buffers)
    {
        var intersectionType = getViewportIntersection(box);

        if (intersectionType == dfIntersectionType.None)
        {
            return;
        }

        var buffer = box.Render();

        if (buffer != null)
        {
            if (buffer.Material == null)
            {
                if (this.atlas != null)
                {
                    buffer.Material = atlas.Material;
                }
            }

            var p2u    = PixelsToUnits();
            var scroll = -scrollPosition.Scale(1, -1).RoundToInt();
            var offset = (Vector3)(scroll + box.GetOffset().Scale(1, -1)) + pivot.TransformToUpperLeft(Size);

            var vertices = buffer.Vertices;
            for (int i = 0; i < buffer.Vertices.Count; i++)
            {
                vertices[i] = (offset + vertices[i]) * p2u;
            }

            if (intersectionType == dfIntersectionType.Intersecting)
            {
                clipToViewport(buffer);
            }

            buffer.Transform = transform.localToWorldMatrix;
            buffers.Add(buffer);
        }

        for (int i = 0; i < box.Children.Count; i++)
        {
            gatherRenderBuffers(box.Children[i], buffers);
        }
    }
Пример #4
0
    private dfIntersectionType getViewportIntersection(dfMarkupBox box)
    {
        if (box.Display == dfMarkupDisplayType.none)
        {
            return(dfIntersectionType.None);
        }
        Vector2 size    = base.Size;
        Vector2 offset  = box.GetOffset() - this.scrollPosition;
        Vector2 vector2 = offset + box.Size;

        if (vector2.x <= 0f || vector2.y <= 0f)
        {
            return(dfIntersectionType.None);
        }
        if (offset.x >= size.x || offset.y >= size.y)
        {
            return(dfIntersectionType.None);
        }
        if (offset.x >= 0f && offset.y >= 0f && vector2.x <= size.x && vector2.y <= size.y)
        {
            return(dfIntersectionType.Inside);
        }
        return(dfIntersectionType.Intersecting);
    }
Пример #5
0
    private void gatherRenderBuffers(dfMarkupBox box, dfList <dfRenderData> buffers)
    {
        dfIntersectionType viewportIntersection = this.getViewportIntersection(box);

        if (viewportIntersection == dfIntersectionType.None)
        {
            return;
        }
        dfRenderData material = box.Render();

        if (material != null)
        {
            if (material.Material == null && this.atlas != null)
            {
                material.Material = this.atlas.Material;
            }
            float            units     = base.PixelsToUnits();
            Vector2          num       = -this.scrollPosition.Scale(1f, -1f).RoundToInt();
            Vector3          vector3   = (num + box.GetOffset().Scale(1f, -1f)) + this.pivot.TransformToUpperLeft(base.Size);
            dfList <Vector3> vertices  = material.Vertices;
            Matrix4x4        matrix4x4 = base.transform.localToWorldMatrix;
            for (int i = 0; i < material.Vertices.Count; i++)
            {
                vertices[i] = matrix4x4.MultiplyPoint((vector3 + vertices[i]) * units);
            }
            if (viewportIntersection == dfIntersectionType.Intersecting)
            {
                this.clipToViewport(material);
            }
            buffers.Add(material);
        }
        for (int j = 0; j < box.Children.Count; j++)
        {
            this.gatherRenderBuffers(box.Children[j], buffers);
        }
    }
Пример #6
0
    private dfIntersectionType getViewportIntersection(dfMarkupBox box)
    {
        if (box.Display == dfMarkupDisplayType.none)
        {
            return(dfIntersectionType.None);
        }
        Vector2 size    = base.Size;
        Vector2 vector2 = box.GetOffset() - this.scrollPosition;
        Vector2 vector3 = vector2 + box.Size;

        if ((vector3.x <= 0f) || (vector3.y <= 0f))
        {
            return(dfIntersectionType.None);
        }
        if ((vector2.x >= size.x) || (vector2.y >= size.y))
        {
            return(dfIntersectionType.None);
        }
        if (((vector2.x >= 0f) && (vector2.y >= 0f)) && ((vector3.x <= size.x) && (vector3.y <= size.y)))
        {
            return(dfIntersectionType.Inside);
        }
        return(dfIntersectionType.Intersecting);
    }
Пример #7
0
    private dfIntersectionType getViewportIntersection( dfMarkupBox box )
    {
        if( box.Display == dfMarkupDisplayType.none )
            return dfIntersectionType.None;

        var viewSize = this.Size;
        var min = box.GetOffset() - scrollPosition;
        var max = min + box.Size;

        if( max.x <= 0 || max.y <= 0 )
            return dfIntersectionType.None;

        if( min.x >= viewSize.x || min.y >= viewSize.y )
            return dfIntersectionType.None;

        if( min.x < 0 || min.y < 0 || max.x > viewSize.x || max.y > viewSize.y )
            return dfIntersectionType.Intersecting;

        return dfIntersectionType.Inside;
    }
Пример #8
0
    private void gatherRenderBuffers( dfMarkupBox box, dfList<dfRenderData> buffers )
    {
        var intersectionType = getViewportIntersection( box );
        if( intersectionType == dfIntersectionType.None )
        {
            return;
        }

        var buffer = box.Render();
        if( buffer != null )
        {

            if( buffer.Material == null )
            {
                if( this.atlas != null )
                {
                    buffer.Material = atlas.Material;
                }
            }

            var p2u = PixelsToUnits();
            var scroll = -scrollPosition.Scale( 1, -1 ).RoundToInt();
            var offset = (Vector3)( scroll + box.GetOffset().Scale( 1, -1 ) ) + pivot.TransformToUpperLeft( Size );

            var vertices = buffer.Vertices;
            for( int i = 0; i < buffer.Vertices.Count; i++ )
            {
                vertices[ i ] = ( offset + vertices[ i ] ) * p2u;
            }

            if( intersectionType == dfIntersectionType.Intersecting )
            {
                clipToViewport( buffer );
            }

            buffer.Transform = transform.localToWorldMatrix;
            buffers.Add( buffer );

        }

        for( int i = 0; i < box.Children.Count; i++ )
        {
            gatherRenderBuffers( box.Children[ i ], buffers );
        }
    }
Пример #9
0
 private dfIntersectionType getViewportIntersection(dfMarkupBox box)
 {
     if (box.Display == dfMarkupDisplayType.none)
     {
         return dfIntersectionType.None;
     }
     Vector2 size = base.Size;
     Vector2 offset = box.GetOffset() - this.scrollPosition;
     Vector2 vector2 = offset + box.Size;
     if (vector2.x <= 0f || vector2.y <= 0f)
     {
         return dfIntersectionType.None;
     }
     if (offset.x >= size.x || offset.y >= size.y)
     {
         return dfIntersectionType.None;
     }
     if (offset.x >= 0f && offset.y >= 0f && vector2.x <= size.x && vector2.y <= size.y)
     {
         return dfIntersectionType.Inside;
     }
     return dfIntersectionType.Intersecting;
 }
Пример #10
0
 private void gatherRenderBuffers(dfMarkupBox box, dfList<dfRenderData> buffers)
 {
     dfIntersectionType viewportIntersection = this.getViewportIntersection(box);
     if (viewportIntersection == dfIntersectionType.None)
     {
         return;
     }
     dfRenderData material = box.Render();
     if (material != null)
     {
         if (material.Material == null && this.atlas != null)
         {
             material.Material = this.atlas.Material;
         }
         float units = base.PixelsToUnits();
         Vector2 num = -this.scrollPosition.Scale(1f, -1f).RoundToInt();
         Vector3 vector3 = (num + box.GetOffset().Scale(1f, -1f)) + this.pivot.TransformToUpperLeft(base.Size);
         dfList<Vector3> vertices = material.Vertices;
         Matrix4x4 matrix4x4 = base.transform.localToWorldMatrix;
         for (int i = 0; i < material.Vertices.Count; i++)
         {
             vertices[i] = matrix4x4.MultiplyPoint((vector3 + vertices[i]) * units);
         }
         if (viewportIntersection == dfIntersectionType.Intersecting)
         {
             this.clipToViewport(material);
         }
         buffers.Add(material);
     }
     for (int j = 0; j < box.Children.Count; j++)
     {
         this.gatherRenderBuffers(box.Children[j], buffers);
     }
 }