本文整理汇总了C#中dfRenderData.EnsureCapacity方法的典型用法代码示例。如果您正苦于以下问题:C# dfRenderData.EnsureCapacity方法的具体用法?C# dfRenderData.EnsureCapacity怎么用?C# dfRenderData.EnsureCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dfRenderData
的用法示例。
在下文中一共展示了dfRenderData.EnsureCapacity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clip
public static void Clip(IList<Plane> planes, dfRenderData source, dfRenderData dest)
{
dest.EnsureCapacity(dest.Vertices.Count + source.Vertices.Count);
for (int i = 0; i < source.Triangles.Count; i = i + 3)
{
for (int j = 0; j < 3; j++)
{
int item = source.Triangles[i + j];
Matrix4x4 transform = source.Transform;
dfClippingUtil.clipSource[0].corner[j] = transform.MultiplyPoint(source.Vertices[item]);
dfClippingUtil.clipSource[0].uv[j] = source.UV[item];
dfClippingUtil.clipSource[0].color[j] = source.Colors[item];
}
int plane = 1;
for (int k = 0; k < planes.Count; k++)
{
plane = dfClippingUtil.clipToPlane(planes[k], dfClippingUtil.clipSource, dfClippingUtil.clipDest, plane);
dfClippingUtil.ClipTriangle[] clipTriangleArray = dfClippingUtil.clipSource;
dfClippingUtil.clipSource = dfClippingUtil.clipDest;
dfClippingUtil.clipDest = clipTriangleArray;
}
for (int l = 0; l < plane; l++)
{
dfClippingUtil.clipSource[l].CopyTo(dest);
}
}
}
示例2: Clip
/// <summary>
/// Clips a <see cref="dfRenderData"/> instance containing control rendering data
/// against a list of <see cref="Plane"/> objects defined by the current clipping
/// region, and outputs the clipped data into <paramref name="dest"/>
/// </summary>
/// <param name="planes">The list of planes to clip against</param>
/// <param name="source">The control rendering data to be clipped</param>
/// <param name="dest">The output buffer that will hold the resulting clipped data</param>
public static void Clip( IList<Plane> planes, dfRenderData source, dfRenderData dest )
{
dest.EnsureCapacity( dest.Vertices.Count + source.Vertices.Count );
var triangleCount = source.Triangles.Count;
var vertices = source.Vertices.Items;
var triangles = source.Triangles.Items;
var uvs = source.UV.Items;
var colors = source.Colors.Items;
var transform = source.Transform;
var planeCount = planes.Count;
for( int sourceIndex = 0; sourceIndex < triangleCount; sourceIndex += 3 )
{
for( int i = 0; i < 3; i++ )
{
var index = triangles[ sourceIndex + i ];
clipSource[ 0 ].corner[ i ] = transform.MultiplyPoint( vertices[ index ] );
clipSource[ 0 ].uv[ i ] = uvs[ index ];
clipSource[ 0 ].color[ i ] = colors[ index ];
}
var count = 1;
for( int planeIndex = 0; planeIndex < planeCount; planeIndex++ )
{
var clipPlane = planes[ planeIndex ];
count = clipToPlane( ref clipPlane, clipSource, clipDest, count );
var temp = clipSource;
clipSource = clipDest;
clipDest = temp;
}
for( int i = 0; i < count; i++ )
{
clipSource[ i ].CopyTo( dest );
}
}
}
示例3: Render
/// <summary>
/// Render the given text as mesh data to the given destination buffer
/// </summary>
/// <param name="text">The text to be rendered</param>
/// <param name="destination">The dfRenderData buffer that will hold the
/// text mesh information</param>
public override void Render( string text, dfRenderData destination )
{
//@Profiler.BeginSample( "Render dynamic font text" );
textColors.Clear();
textColors.Push( Color.white );
// Ensure that the required characters can be found in the dynamic font's
// character data.
var font = (dfDynamicFont)Font;
var fontSize = Mathf.CeilToInt( font.FontSize * TextScale );
font.RequestCharacters( text, fontSize, FontStyle.Normal );
tokenize( text );
var lines = calculateLinebreaks();
destination.EnsureCapacity( getAnticipatedVertCount( tokens ) );
var maxWidth = 0;
var maxHeight = 0;
var position = ( VectorOffset / PixelRatio ).CeilToInt();
for( int i = 0; i < lines.Count; i++ )
{
var line = lines[ i ];
var lineStartIndex = destination.Vertices.Count;
var spriteStartIndex = ( SpriteBuffer != null ) ? SpriteBuffer.Vertices.Count : 0;
renderLine( lines[ i ], textColors, position, destination );
position.y -= line.lineHeight;
maxWidth = Mathf.Max( (int)line.lineWidth, maxWidth );
maxHeight += Mathf.CeilToInt( line.lineHeight );
if( line.lineWidth > MaxSize.x )
{
clipRight( destination, lineStartIndex );
clipRight( SpriteBuffer, spriteStartIndex );
}
clipBottom( destination, lineStartIndex );
clipBottom( SpriteBuffer, spriteStartIndex );
}
this.RenderedSize = new Vector2(
Mathf.Min( MaxSize.x, maxWidth ),
Mathf.Min( MaxSize.y, maxHeight )
) * TextScale;
this.tokens.Release();
this.tokens = null;
//@Profiler.EndSample();
}