package org.papervision3d.core.culling { import flash.geom.Rectangle; import org.papervision3d.core.geom.renderables.Line3D; import org.papervision3d.core.culling.ILineCuller; import org.papervision3d.core.math.util.FastRectangleTools; /** * @author Seb Lee-Delisle */ public class RectangleLineCuller implements ILineCuller { private var cullingRectangle : Rectangle; private var lineBoundsRect : Rectangle; // temporary rectangle to avoid object creation. private var rectIntersection : Rectangle; /** * @Author Seb Lee-Delisle * * RectangleLineCuller * * This Line Culler culls lines based upon whether they intersect the viewport rectangle. */ public function RectangleLineCuller(cullingRectangle:Rectangle = null):void { if(cullingRectangle){ this.cullingRectangle = cullingRectangle; } lineBoundsRect = new Rectangle(); rectIntersection = new Rectangle(); } public function testLine(line : Line3D) : Boolean { // if one or more of the points is behind the camera, then cull. if((!line.v0.vertex3DInstance.visible)||(!line.v1.vertex3DInstance.visible)) return false; var l0x : Number = line.v0.vertex3DInstance.x; var l0y : Number = line.v0.vertex3DInstance.y; var l1x : Number = line.v1.vertex3DInstance.x; var l1y : Number = line.v1.vertex3DInstance.y; // get the line bounds rect lineBoundsRect.width = Math.abs(l1x-l0x); lineBoundsRect.height = Math.abs(l1y-l0y); if(l0xrectIntersection.left) && (xcrossrectIntersection.left) && (xcrossrectIntersection.top) && (ycrossrectIntersection.top) && (ycross