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); } } }
/// <summary> /// Used to reset all lists in preparation for filling with new or /// updated rendering data. NOTE: While this function does appear /// to empty the data lists, it does not free the internal memory /// used to hold the information, with the assumption that this /// will glyphData in fewer garbage collections. /// </summary> public void Clear() { Material = null; Shader = null; Transform = Matrix4x4.identity; Checksum = 0x00; Intersection = dfIntersectionType.None; Vertices.Clear(); UV.Clear(); Triangles.Clear(); Colors.Clear(); Normals.Clear(); Tangents.Clear(); }
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); } }
public dfList<Plane> TestIntersection( Bounds bounds, out dfIntersectionType type ) { if( planes == null || planes.Count == 0 ) { type = dfIntersectionType.Inside; return null; } intersectedPlanes.Clear(); var center = bounds.center; var extents = bounds.extents; var intersecting = false; var planeCount = planes.Count; var rawPlanes = planes.Items; for( int i = 0; i < planeCount; i++ ) { var plane = rawPlanes[ i ]; var planeNormal = plane.normal; var planeDist = plane.distance; // Compute the projection interval radius of b onto L(t) = b.c + t * p.n float r = extents.x * Mathf.Abs( planeNormal.x ) + extents.y * Mathf.Abs( planeNormal.y ) + extents.z * Mathf.Abs( planeNormal.z ); // Compute distance of box center from plane float distance = Vector3.Dot( planeNormal, center ) + planeDist; // Intersection occurs when distance falls within [-r,+r] interval if( Mathf.Abs( distance ) <= r ) { intersecting = true; intersectedPlanes.Add( plane ); } else { // If the control lies behind *any* of the planes, there // is no point in continuing with the rest of the test if( distance < -r ) { type = dfIntersectionType.None; return null; } } } if( intersecting ) { type = dfIntersectionType.Intersecting; return intersectedPlanes; } type = dfIntersectionType.Inside; return null; }
public dfList <Plane> TestIntersection(Bounds bounds, out dfIntersectionType type) { if (planes == null || planes.Count == 0) { type = dfIntersectionType.Inside; return(null); } intersectedPlanes.Clear(); var center = bounds.center; var extents = bounds.extents; var intersecting = false; var planeCount = planes.Count; var rawPlanes = planes.Items; for (int i = 0; i < planeCount; i++) { var plane = rawPlanes[i]; var planeNormal = plane.normal; var planeDist = plane.distance; // Compute the projection interval radius of b onto L(t) = b.c + t * p.n float r = extents.x * Mathf.Abs(planeNormal.x) + extents.y * Mathf.Abs(planeNormal.y) + extents.z * Mathf.Abs(planeNormal.z); // Compute distance of box center from plane float distance = Vector3.Dot(planeNormal, center) + planeDist; // Intersection occurs when distance falls within [-r,+r] interval if (Mathf.Abs(distance) <= r) { intersecting = true; intersectedPlanes.Add(plane); } else { // If the control lies behind *any* of the planes, there // is no point in continuing with the rest of the test if (distance < -r) { type = dfIntersectionType.None; return(null); } } } if (intersecting) { type = dfIntersectionType.Intersecting; return(intersectedPlanes); } type = dfIntersectionType.Inside; return(null); }