Ejemplo n.º 1
0
    private void clipToViewport(dfRenderData renderData)
    {
        Plane[]   clippingPlanes = this.GetClippingPlanes();
        Material  material       = renderData.Material;
        Matrix4x4 transform      = renderData.Transform;

        dfRichTextLabel.clipBuffer.Clear();
        dfClippingUtil.Clip(clippingPlanes, renderData, dfRichTextLabel.clipBuffer);
        renderData.Clear();
        renderData.Merge(dfRichTextLabel.clipBuffer, false);
        renderData.Material  = material;
        renderData.Transform = transform;
    }
Ejemplo n.º 2
0
    private void clipToViewport(dfRenderData renderData)
    {
        var planes = getViewportClippingPlanes();

        var material = renderData.Material;
        var matrix   = renderData.Transform;

        clipBuffer.Clear();
        dfClippingUtil.Clip(planes, renderData, clipBuffer);

        renderData.Clear();
        renderData.Merge(clipBuffer, false);
        renderData.Material  = material;
        renderData.Transform = matrix;
    }
    public void clipToPlanes(dfList <Plane> planes, dfRenderData data, dfRenderData dest, uint controlChecksum)
    {
        if (data == null || data.Vertices.Count == 0)
        {
            return;
        }

        if (planes == null || planes.Count == 0)
        {
            dest.Merge(data);
            return;
        }

        dfClippingUtil.Clip(planes, data, dest);
    }
Ejemplo n.º 4
0
 private dfRenderData compileMasterBuffer()
 {
     this.submeshes.Clear();
     masterBuffer.Clear();
     for (int i = 0; i < this.drawCallCount; i++)
     {
         this.submeshes.Add(masterBuffer.Triangles.Count);
         dfRenderData buffer = this.drawCallBuffers[i];
         if (this.generateNormals && (buffer.Normals.Count == 0))
         {
             this.generateNormalsAndTangents(buffer);
         }
         masterBuffer.Merge(buffer, false);
     }
     masterBuffer.ApplyTransform(base.transform.worldToLocalMatrix);
     return(masterBuffer);
 }
Ejemplo n.º 5
0
    private void clipToViewport( dfRenderData renderData )
    {
        //@Profiler.BeginSample( "Clip markup box to viewport" );

        var planes = getViewportClippingPlanes();

        var material = renderData.Material;
        var matrix = renderData.Transform;

        clipBuffer.Clear();
        dfClippingUtil.Clip( planes, renderData, clipBuffer );

        renderData.Clear();
        renderData.Merge( clipBuffer, false );
        renderData.Material = material;
        renderData.Transform = matrix;

        Profiler.EndSample();
    }
    private bool processRenderData( ref dfRenderData buffer, dfRenderData controlData, ref Bounds bounds, ref Rect screenRect, uint checksum, dfTriangleClippingRegion clipInfo, ref bool wasClipped )
    {
        wasClipped = false;

        // This shouldn't happen in practice, but need to make certain
        if( controlData == null || controlData.Material == null || !controlData.IsValid() )
            return false;

        // A new draw call is needed every time the current Material, Texture, or Shader
        // changes. If the control returned a buffer that is not empty and uses a
        // different Material, need to grab a new draw call buffer from the object pool.
        bool needNewDrawcall = false;
        if( buffer == null )
        {
            needNewDrawcall = true;
        }
        else
        {
            if( !Material.Equals( controlData.Material, buffer.Material ) )
            {
                needNewDrawcall = true;
            }
            else if( !textureEqual( controlData.Material.mainTexture, buffer.Material.mainTexture ) )
            {
                needNewDrawcall = true;
            }
            else if( !shaderEqual( buffer.Shader, controlData.Shader ) )
            {
                needNewDrawcall = true;
            }
            else if( !this.clipInfo.IsEmpty && drawCallBuffers.Count == 1 )
            {
                needNewDrawcall = true;
            }
        }

        if( needNewDrawcall )
        {
            buffer = getDrawCallBuffer( controlData.Material );
            buffer.Material = controlData.Material;
            buffer.Material.mainTexture = controlData.Material.mainTexture;
            buffer.Material.shader = controlData.Shader ?? controlData.Material.shader;
        }

        if( !Application.isPlaying || clipType == dfClippingMethod.Software )
        {

            // Ensure that the control's render data is properly clipped to the
            // current clipping region
            if( clipInfo.PerformClipping( buffer, ref bounds, checksum, controlData ) )
            {
                return true;
            }

            // If PerformClipping() returns FALSE, then the control was outside of
            // the active clipping region
            wasClipped = true;

        }
        else
        {
            if( clipRect.IsEmpty() || screenRect.Intersects( clipRect ) )
            {
                buffer.Merge( controlData );
            }
            else
            {
                // Control was not inside of the active clipping rectangle
                wasClipped = true;
            }
        }

        return false;
    }
    private void clipToViewport( dfRenderData renderData )
    {
        var planes = getViewportClippingPlanes();

        var material = renderData.Material;
        var matrix = renderData.Transform;

        clipBuffer.Clear();
        dfClippingUtil.Clip( planes, renderData, clipBuffer );

        renderData.Clear();
        renderData.Merge( clipBuffer, false );
        renderData.Material = material;
        renderData.Transform = matrix;
    }
Ejemplo n.º 8
0
	public void clipToPlanes( dfList<Plane> planes, dfRenderData data, dfRenderData dest, uint controlChecksum )
	{

		if( data == null || data.Vertices.Count == 0 )
			return;

		if( planes == null || planes.Count == 0 )
		{
			dest.Merge( data );
			return;
		}

		dfClippingUtil.Clip( planes, data, dest );

	}
Ejemplo n.º 9
0
	/// <summary>
	/// Perform triangle clipping on the dfControl's RenderData and append the results
	/// to the destination RenderData
	/// </summary>
	/// <param name="dest">The buffer which will receive the final results</param>
	/// <param name="control">A <see cref="Bounds"/> instance fully enclosing the control</param>
	/// <param name="controlData">The <see cref="RenderData"/> structure generated by the dfControl</param>
	/// <returns>Returns TRUE if the dfControl was rendered, FALSE if it was not (lies entirely outside the clipping region)</returns>
	public bool PerformClipping( dfRenderData dest, ref Bounds bounds, uint checksum, dfRenderData controlData )
	{

		// If there are no clipping planes defined, then simply merge the control's
		// rendering information with the master buffer.
		if( planes == null || planes.Count == 0 )
		{
			dest.Merge( controlData );
			return true;
		}

		// If the RenderData's Checksum matches the dfControl's current checksum 
		// then in the case of a dfControl which was previously determined to be 
		// either entirely inside of all clipping planes or entirely outside
		// of any clipping plane we can skip clipping and intersection testing
		if( controlData.Checksum == checksum )
		{

			if( controlData.Intersection == dfIntersectionType.Inside )
			{
				// Merge the control's rendering information without any clipping
				//@Profiler.BeginSample( "Merge cached buffer - Fully inside" );
				dest.Merge( controlData );
				//@Profiler.EndSample();
				return true;
			}
			else if( controlData.Intersection == dfIntersectionType.None )
			{
				// Control lies entirely outside of the clipping region,
				// no need to include any of its rendering information
				//@Profiler.BeginSample( "Discard cached buffer - No intersection" );
				//@Profiler.EndSample();
				return false;
			}

		}

		var wasRendered = false;

		//@Profiler.BeginSample( "Clipping buffer data" );

		dfIntersectionType intersectionTest;
		var clipPlanes = TestIntersection( bounds, out intersectionTest );

		if( intersectionTest == dfIntersectionType.Inside )
		{
			//@Profiler.BeginSample( "Merging buffer - Fully inside" );
			dest.Merge( controlData );
			//@Profiler.EndSample();
			wasRendered = true;
		}
		else if( intersectionTest == dfIntersectionType.Intersecting )
		{
			//@Profiler.BeginSample( "Clipping intersecting buffer" );
			clipToPlanes( clipPlanes, controlData, dest, checksum );
			//@Profiler.EndSample();
			wasRendered = true;
		}

		controlData.Checksum = checksum;
		controlData.Intersection = intersectionTest;

		//@Profiler.EndSample();
		return wasRendered;

	}
Ejemplo n.º 10
0
 private void clipToViewport(dfRenderData renderData)
 {
     Plane[] clippingPlanes = this.GetClippingPlanes();
     Material material = renderData.Material;
     Matrix4x4 transform = renderData.Transform;
     dfRichTextLabel.clipBuffer.Clear();
     dfClippingUtil.Clip(clippingPlanes, renderData, dfRichTextLabel.clipBuffer);
     renderData.Clear();
     renderData.Merge(dfRichTextLabel.clipBuffer, false);
     renderData.Material = material;
     renderData.Transform = transform;
 }
    private bool processRenderData(ref dfRenderData buffer, dfRenderData controlData, ref Bounds bounds, ref Rect screenRect, uint checksum, dfTriangleClippingRegion clipInfo, ref bool wasClipped)
    {
        wasClipped = false;

        // This shouldn't happen in practice, but need to make certain
        if (controlData == null || controlData.Material == null || !controlData.IsValid())
        {
            return(false);
        }

        // A new draw call is needed every time the current Material, Texture, or Shader
        // changes. If the control returned a buffer that is not empty and uses a
        // different Material, need to grab a new draw call buffer from the object pool.
        bool needNewDrawcall = false;

        if (buffer == null)
        {
            needNewDrawcall = true;
        }
        else
        {
            if (!Material.Equals(controlData.Material, buffer.Material))
            {
                needNewDrawcall = true;
            }
            else if (!textureEqual(controlData.Material.mainTexture, buffer.Material.mainTexture))
            {
                needNewDrawcall = true;
            }
            else if (!shaderEqual(buffer.Shader, controlData.Shader))
            {
                needNewDrawcall = true;
            }
            else if (!this.clipInfo.IsEmpty && drawCallBuffers.Count == 1)
            {
                needNewDrawcall = true;
            }
        }

        if (needNewDrawcall)
        {
            buffer                      = getDrawCallBuffer(controlData.Material);
            buffer.Material             = controlData.Material;
            buffer.Material.mainTexture = controlData.Material.mainTexture;
            buffer.Material.shader      = controlData.Shader ?? controlData.Material.shader;
        }

        if (!Application.isPlaying || clipType == dfClippingMethod.Software)
        {
            // Ensure that the control's render data is properly clipped to the
            // current clipping region
            if (clipInfo.PerformClipping(buffer, ref bounds, checksum, controlData))
            {
                return(true);
            }

            // If PerformClipping() returns FALSE, then the control was outside of
            // the active clipping region
            wasClipped = true;
        }
        else
        {
            if (clipRect.IsEmpty() || screenRect.Intersects(clipRect))
            {
                buffer.Merge(controlData);
            }
            else
            {
                // Control was not inside of the active clipping rectangle
                wasClipped = true;
            }
        }

        return(false);
    }
    /// <summary>
    /// Perform triangle clipping on the dfControl's RenderData and append the results
    /// to the destination RenderData
    /// </summary>
    /// <param name="dest">The buffer which will receive the final results</param>
    /// <param name="control">A <see cref="Bounds"/> instance fully enclosing the control</param>
    /// <param name="controlData">The <see cref="RenderData"/> structure generated by the dfControl</param>
    /// <returns>Returns TRUE if the dfControl was rendered, FALSE if it was not (lies entirely outside the clipping region)</returns>
    public bool PerformClipping(dfRenderData dest, ref Bounds bounds, uint checksum, dfRenderData controlData)
    {
        // If there are no clipping planes defined, then simply merge the control's
        // rendering information with the master buffer.
        if (planes == null || planes.Count == 0)
        {
            dest.Merge(controlData);
            return(true);
        }

        // If the RenderData's Checksum matches the dfControl's current checksum
        // then in the case of a dfControl which was previously determined to be
        // either entirely inside of all clipping planes or entirely outside
        // of any clipping plane we can skip clipping and intersection testing
        if (controlData.Checksum == checksum)
        {
            if (controlData.Intersection == dfIntersectionType.Inside)
            {
                // Merge the control's rendering information without any clipping
                //@Profiler.BeginSample( "Merge cached buffer - Fully inside" );
                dest.Merge(controlData);
                //@Profiler.EndSample();
                return(true);
            }
            else if (controlData.Intersection == dfIntersectionType.None)
            {
                // Control lies entirely outside of the clipping region,
                // no need to include any of its rendering information
                //@Profiler.BeginSample( "Discard cached buffer - No intersection" );
                //@Profiler.EndSample();
                return(false);
            }
        }

        var wasRendered = false;

        //@Profiler.BeginSample( "Clipping buffer data" );

        dfIntersectionType intersectionTest;
        var clipPlanes = TestIntersection(bounds, out intersectionTest);

        if (intersectionTest == dfIntersectionType.Inside)
        {
            //@Profiler.BeginSample( "Merging buffer - Fully inside" );
            dest.Merge(controlData);
            //@Profiler.EndSample();
            wasRendered = true;
        }
        else if (intersectionTest == dfIntersectionType.Intersecting)
        {
            //@Profiler.BeginSample( "Clipping intersecting buffer" );
            clipToPlanes(clipPlanes, controlData, dest, checksum);
            //@Profiler.EndSample();
            wasRendered = true;
        }

        controlData.Checksum     = checksum;
        controlData.Intersection = intersectionTest;

        //@Profiler.EndSample();
        return(wasRendered);
    }