Packagecom.pblabs.rendering2D
Interfacepublic interface ISpatialManager2D
Implementors BasicSpatialManager2D, Box2DManagerComponent

Basic interface for 2D spatial database. This provides enough capabilities to do visibility culling, limited picking, and ray casts. Most implementations (like ones using a physics library) will expose a lot more functionality, but this is enough to do rendering and UI tasks.



Public Methods
 MethodDefined By
  
Add a generic spatial object to this manager.
ISpatialManager2D
  
castRay(start:Point, end:Point, flags:ObjectType, result:RayHitInfo):Boolean
Cast a ray and (optionally) return information about what it hits in result.
ISpatialManager2D
  
getObjectsUnderPoint(worldPosition:Point, results:Array, mask:ObjectType = null):Boolean
Return all the spatial objects under a given point.
ISpatialManager2D
  
queryCircle(center:Point, radius:Number, mask:ObjectType, results:Array):Boolean
Return all the spatial objects that overlap the specified circle.
ISpatialManager2D
  
queryRectangle(box:Rectangle, mask:ObjectType, results:Array):Boolean
Return all the spatial objects that overlap with the specified box and match one or more of the types in the mask.
ISpatialManager2D
  
Remove a previously registered object from this manager.
ISpatialManager2D
Method Detail
addSpatialObject()method
public function addSpatialObject(object:ISpatialObject2D):void

Add a generic spatial object to this manager. A manager with advanced functionality will support both general ISpatialObject2D implementations as well as enabling special functionality for its peered classes.

Parameters

object:ISpatialObject2D

castRay()method 
public function castRay(start:Point, end:Point, flags:ObjectType, result:RayHitInfo):Boolean

Cast a ray and (optionally) return information about what it hits in result.

Parameters

start:Point
 
end:Point
 
flags:ObjectType
 
result:RayHitInfo

Returns
Boolean
getObjectsUnderPoint()method 
public function getObjectsUnderPoint(worldPosition:Point, results:Array, mask:ObjectType = null):Boolean

Return all the spatial objects under a given point. Objects can optionally implement pixel-level collision checking.

Parameters

worldPosition:Point — Point in worldspace to check.
 
results:Array — An array into which ISpatialObject2Ds are added based on what is under point.
 
mask:ObjectType (default = null) — Only consider objects that match this ObjectType. Null uses all types.

Returns
Boolean — Found something under point or not.
queryCircle()method 
public function queryCircle(center:Point, radius:Number, mask:ObjectType, results:Array):Boolean

Return all the spatial objects that overlap the specified circle.

Parameters

center:Point
 
radius:Number
 
mask:ObjectType
 
results:Array

Returns
Boolean

See also

QueryRectangle
queryRectangle()method 
public function queryRectangle(box:Rectangle, mask:ObjectType, results:Array):Boolean

Return all the spatial objects that overlap with the specified box and match one or more of the types in the mask.

Note that if you pass in a populated array, this method appends to it. This can be useful if you want to combine the results of several queries. If you just want the results from one query, make sure to set results.length=0; before you pass it to queryRectangle.

Parameters

box:Rectangle
 
mask:ObjectType
 
results:Array

Returns
Boolean — True if one or more objects were found and push()'ed to results.
removeSpatialObject()method 
public function removeSpatialObject(object:ISpatialObject2D):void

Remove a previously registered object from this manager.

Parameters

object:ISpatialObject2D

See also

AddSpatialObject