C# Class Nez.Spatial.SpatialHash

Datei anzeigen Open project: prime31/Nez Class Usage Examples

Public Properties

Property Type Description
gridBounds Microsoft.Xna.Framework.Rectangle

Public Methods

Method Description
SpatialHash ( int cellSize = 100 ) : System
aabbBroadphase ( RectangleF &bounds, Collider excludeCollider, int layerMask ) : HashSet

returns all objects in cells that the bounding box intersects

clear ( ) : void
debugDraw ( float secondsToDisplay, float textScale = 1f ) : void

debug draws the contents of the spatial hash. Note that Core.debugRenderEnabled must be true or nothing will be displayed.

debugDrawCellDetails ( int x, int y, int cellCount, float secondsToDisplay = 0.5f, float textScale = 1f ) : void
getAllObjects ( ) : HashSet

returns all the Colliders in the SpatialHash

linecast ( Vector2 start, Vector2 end, RaycastHit hits, int layerMask ) : int

casts a line through the spatial hash and fills the hits array up with any colliders that the line hits

overlapCircle ( Vector2 circleCenter, float radius, Collider results, int layerMask ) : int

gets all the colliders that fall within the specified circle

overlapRectangle ( RectangleF &rect, Collider results, int layerMask ) : int

gets all the colliders that fall within the specified rect

register ( Collider collider ) : void

adds the object to the SpatialHash

remove ( Collider collider ) : void

removes the object from the SpatialHash

removeWithBruteForce ( Collider obj ) : void

removes the object from the SpatialHash using a brute force approach

Private Methods

Method Description
cellAtPosition ( int x, int y, bool createCellIfEmpty = false ) : List
cellCoords ( float x, float y ) : Point
cellCoords ( int x, int y ) : Point

Method Details

SpatialHash() public method

public SpatialHash ( int cellSize = 100 ) : System
cellSize int
return System

aabbBroadphase() public method

returns all objects in cells that the bounding box intersects
public aabbBroadphase ( RectangleF &bounds, Collider excludeCollider, int layerMask ) : HashSet
bounds RectangleF Bounds.
excludeCollider Collider
layerMask int Layer mask.
return HashSet

clear() public method

public clear ( ) : void
return void

debugDraw() public method

debug draws the contents of the spatial hash. Note that Core.debugRenderEnabled must be true or nothing will be displayed.
public debugDraw ( float secondsToDisplay, float textScale = 1f ) : void
secondsToDisplay float Seconds to display.
textScale float Text scale.
return void

debugDrawCellDetails() public method

public debugDrawCellDetails ( int x, int y, int cellCount, float secondsToDisplay = 0.5f, float textScale = 1f ) : void
x int
y int
cellCount int
secondsToDisplay float
textScale float
return void

getAllObjects() public method

returns all the Colliders in the SpatialHash
public getAllObjects ( ) : HashSet
return HashSet

linecast() public method

casts a line through the spatial hash and fills the hits array up with any colliders that the line hits
public linecast ( Vector2 start, Vector2 end, RaycastHit hits, int layerMask ) : int
start Vector2 Start.
end Vector2 End.
hits RaycastHit Hits.
layerMask int Layer mask.
return int

overlapCircle() public method

gets all the colliders that fall within the specified circle
public overlapCircle ( Vector2 circleCenter, float radius, Collider results, int layerMask ) : int
circleCenter Vector2 Circle center.
radius float Radius.
results Collider Results.
layerMask int Layer mask.
return int

overlapRectangle() public method

gets all the colliders that fall within the specified rect
public overlapRectangle ( RectangleF &rect, Collider results, int layerMask ) : int
rect RectangleF Rect.
results Collider Results.
layerMask int Layer mask.
return int

register() public method

adds the object to the SpatialHash
public register ( Collider collider ) : void
collider Collider Object.
return void

remove() public method

removes the object from the SpatialHash
public remove ( Collider collider ) : void
collider Collider Collider.
return void

removeWithBruteForce() public method

removes the object from the SpatialHash using a brute force approach
public removeWithBruteForce ( Collider obj ) : void
obj Collider Object.
return void

Property Details

gridBounds public_oe property

public Rectangle,Microsoft.Xna.Framework gridBounds
return Microsoft.Xna.Framework.Rectangle