C# Class Nez.Physics

Afficher le fichier Open project: prime31/Nez

Méthodes publiques

Свойство Type Description
gravity Microsoft.Xna.Framework.Vector2
raycastsHitTriggers bool
raycastsStartInColliders bool
spatialHashCellSize int

Méthodes publiques

Méthode Description
addCollider ( Collider collider ) : void

adds the collider to the physics system

boxcastBroadphase ( RectangleF rect, int layerMask = allLayers ) : IEnumerable

returns all colliders with bounds that are intersected by collider.bounds. Note that this is a broadphase check so it only checks bounds and does not do individual Collider-to-Collider checks!

boxcastBroadphaseExcludingSelf ( Collider collider, RectangleF &rect, int layerMask = allLayers ) : IEnumerable

returns all colliders that are intersected by bounds excluding the passed-in collider (self). this method is useful if you want to create the swept bounds on your own for other queries

boxcastBroadphaseExcludingSelf ( Collider collider, float deltaX, float deltaY, int layerMask = allLayers ) : IEnumerable

returns all colliders that are intersected by collider.bounds expanded to incorporate deltaX/deltaY excluding the passed-in collider (self)

boxcastBroadphaseExcludingSelf ( Collider collider, int layerMask = allLayers ) : IEnumerable

returns all colliders with bounds that are intersected by collider.bounds excluding the passed-in collider (self)

clear ( ) : void

removes all colliders from the SpatialHash

getAllColliders ( ) : IEnumerable

gets all the Colliders managed by the SpatialHash

linecast ( Vector2 start, Vector2 end, int layerMask = allLayers ) : RaycastHit

casts a line from start to end and returns the first hit of a collider that matches layerMask

linecastAll ( Vector2 start, Vector2 end, RaycastHit hits, int layerMask = allLayers ) : int

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

overlapCircle ( Vector2 center, float radius, int layerMask = allLayers ) : Collider

check if any collider falls within a circular area. Returns the first Collider encountered.

overlapCircleAll ( Vector2 center, float radius, Collider results, int layerMask = allLayers ) : int

gets all the colliders that fall within the specified circle

overlapRectangle ( RectangleF rect, int layerMask = allLayers ) : Collider

check if any collider falls within a rectangular area

overlapRectangleAll ( RectangleF &rect, Collider results, int layerMask = allLayers ) : int

gets all the colliders that fall within the specified rect

removeCollider ( Collider collider ) : void

removes the collider from the physics system

reset ( ) : void
updateCollider ( Collider collider ) : void

updates the colliders position in the physics system. This essentially just removes then re-adds the Collider with its new bounds

Private Methods

Méthode Description
debugDraw ( float secondsToDisplay ) : void

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

Method Details

addCollider() public static méthode

adds the collider to the physics system
public static addCollider ( Collider collider ) : void
collider Collider Collider.
Résultat void

boxcastBroadphase() public static méthode

returns all colliders with bounds that are intersected by collider.bounds. Note that this is a broadphase check so it only checks bounds and does not do individual Collider-to-Collider checks!
public static boxcastBroadphase ( RectangleF rect, int layerMask = allLayers ) : IEnumerable
rect RectangleF
layerMask int Layer mask.
Résultat IEnumerable

boxcastBroadphaseExcludingSelf() public static méthode

returns all colliders that are intersected by bounds excluding the passed-in collider (self). this method is useful if you want to create the swept bounds on your own for other queries
public static boxcastBroadphaseExcludingSelf ( Collider collider, RectangleF &rect, int layerMask = allLayers ) : IEnumerable
collider Collider Collider.
rect RectangleF
layerMask int
Résultat IEnumerable

boxcastBroadphaseExcludingSelf() public static méthode

returns all colliders that are intersected by collider.bounds expanded to incorporate deltaX/deltaY excluding the passed-in collider (self)
public static boxcastBroadphaseExcludingSelf ( Collider collider, float deltaX, float deltaY, int layerMask = allLayers ) : IEnumerable
collider Collider Collider.
deltaX float
deltaY float
layerMask int
Résultat IEnumerable

boxcastBroadphaseExcludingSelf() public static méthode

returns all colliders with bounds that are intersected by collider.bounds excluding the passed-in collider (self)
public static boxcastBroadphaseExcludingSelf ( Collider collider, int layerMask = allLayers ) : IEnumerable
collider Collider Collider.
layerMask int
Résultat IEnumerable

clear() public static méthode

removes all colliders from the SpatialHash
public static clear ( ) : void
Résultat void

getAllColliders() public static méthode

gets all the Colliders managed by the SpatialHash
public static getAllColliders ( ) : IEnumerable
Résultat IEnumerable

linecast() public static méthode

casts a line from start to end and returns the first hit of a collider that matches layerMask
public static linecast ( Vector2 start, Vector2 end, int layerMask = allLayers ) : RaycastHit
start Microsoft.Xna.Framework.Vector2 Start.
end Microsoft.Xna.Framework.Vector2 End.
layerMask int Layer mask.
Résultat RaycastHit

linecastAll() public static méthode

casts a line through the spatial hash and fills the hits array up with any colliders that the line hits
public static linecastAll ( Vector2 start, Vector2 end, RaycastHit hits, int layerMask = allLayers ) : int
start Microsoft.Xna.Framework.Vector2 Start.
end Microsoft.Xna.Framework.Vector2 End.
hits RaycastHit Hits.
layerMask int Layer mask.
Résultat int

overlapCircle() public static méthode

check if any collider falls within a circular area. Returns the first Collider encountered.
public static overlapCircle ( Vector2 center, float radius, int layerMask = allLayers ) : Collider
center Microsoft.Xna.Framework.Vector2 Center.
radius float Radius.
layerMask int Layer mask.
Résultat Collider

overlapCircleAll() public static méthode

gets all the colliders that fall within the specified circle
public static overlapCircleAll ( Vector2 center, float radius, Collider results, int layerMask = allLayers ) : int
center Microsoft.Xna.Framework.Vector2 Center.
radius float Radius.
results Collider Results.
layerMask int Layer mask.
Résultat int

overlapRectangle() public static méthode

check if any collider falls within a rectangular area
public static overlapRectangle ( RectangleF rect, int layerMask = allLayers ) : Collider
rect RectangleF Rect.
layerMask int Layer mask.
Résultat Collider

overlapRectangleAll() public static méthode

gets all the colliders that fall within the specified rect
public static overlapRectangleAll ( RectangleF &rect, Collider results, int layerMask = allLayers ) : int
rect RectangleF Rect.
results Collider Results.
layerMask int Layer mask.
Résultat int

removeCollider() public static méthode

removes the collider from the physics system
public static removeCollider ( Collider collider ) : void
collider Collider Collider.
Résultat void

reset() public static méthode

public static reset ( ) : void
Résultat void

updateCollider() public static méthode

updates the colliders position in the physics system. This essentially just removes then re-adds the Collider with its new bounds
public static updateCollider ( Collider collider ) : void
collider Collider Collider.
Résultat void

Property Details

gravity public_oe static_oe property

convenience field for storing a gravity value globally
public static Vector2,Microsoft.Xna.Framework gravity
Résultat Microsoft.Xna.Framework.Vector2

raycastsHitTriggers public_oe static_oe property

Do raycasts detect Colliders configured as triggers?
public static bool raycastsHitTriggers
Résultat bool

raycastsStartInColliders public_oe static_oe property

Do ray/line casts that start inside a collider detect those colliders?
public static bool raycastsStartInColliders
Résultat bool

spatialHashCellSize public_oe static_oe property

cell size used when reset is called and a new SpatialHash is created
public static int spatialHashCellSize
Résultat int