Photon Quantum 3.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Quantum.Physics2D.Hit Struct Reference

Information returned from a valid hit of a physics query. More...

Public Member Functions

override Int32 GetHashCode ()
 Overrides the hash code generation of this type. More...
 
Shape2DGetShape (FrameBase f)
 Gets the shape of the entity. If the entity is a compound, it returns the specific shape of the compound. More...
 
ref MapStaticCollider2D GetStaticCollider (FrameBase f)
 Gets a reference to the static collider hit. Does not perform additional safety checks. More...
 
ref MapStaticCollider2D GetStaticCollider (FrameThreadSafe f)
 
ref StaticColliderData GetStaticData (FrameBase f)
 Gets a reference to the data of the static collider hit (MapStaticCollider2D.StaticData). Does not perform additional safety checks. More...
 
ref StaticColliderData GetStaticData (FrameThreadSafe f)
 
void SetHitEntity (EntityRef entity)
 Sets the entity that was hit. Automatically resets StaticColliderIndex to -1. More...
 
void SetHitStaticCollider (int staticColliderIndex, AssetRef< Map > mapRef)
 Sets the index of the static collider hit on the Map.StaticColliders2D array of the referenced map. More...
 
bool TryGetShape (FrameBase f, out Shape2D *shape)
 Checks if the hit is valid and outs the shape of the entity. Otherwise, it will return false. If the entity is a compound, it returns the specific shape of the compound. More...
 
bool TryGetStaticCollider (FrameBase f, out MapStaticCollider2D collider)
 Tries to access the static collider that was hit. More...
 
bool TryGetStaticCollider (FrameThreadSafe f, out MapStaticCollider2D collider)
 
bool TryGetStaticData (FrameBase f, out StaticColliderData data)
 Tries to access the data of the static collider that was hit (MapStaticCollider2D.StaticData). More...
 
bool TryGetStaticData (FrameThreadSafe f, out StaticColliderData data)
 

Static Public Member Functions

static void Serialize (void *ptr, FrameSerializer serializer)
 Serializes a Hit into a FrameSerializer. More...
 

Public Attributes

FP CastDistanceNormalized
 A normalized value (0 to 1) of the feature being casted when the hit occurs, relative to its full cast distance. More...
 
FPVector2 Normal
 The surface normal of the hit. More...
 
FP OverlapPenetration
 The penetration of a shape overlap query on the collider that was hit. More...
 
FPVector2 Point
 The point in world space where the collider is hit by the query. More...
 
ushort ShapeUserTag
 The Shape2D.UserTag field of the shape hit by the query. More...
 

Static Public Attributes

const int SIZE = SecondInfo + sizeof(Int32) * 2
 The size of the struct in bytes. More...
 

Properties

EntityRefEntity [get]
 The reference of the entity hit by the query, EntityRef.None if hitting a static collider (IsDynamic false). More...
 
Boolean IsDynamic [get]
 If the collider hit by the query is not static, i.e. it belongs to an Entity. More...
 
Boolean IsStatic [get]
 If the collider hit by the query is static. More...
 
Boolean? IsTrigger [get, set]
 If the collider hit by the query is Trigger. More...
 
int StaticColliderIndex [get]
 0-based index of the static collider on the Map.StaticColliders2D array of the map referenced by StaticColliderMapRef. If the hit IsDynamic, this value is -1. Tip: use TryGetStaticCollider(FrameBase, out MapStaticCollider2D), TryGetStaticData(FrameBase, out StaticColliderData), GetStaticCollider(FrameBase) or GetStaticData(FrameBase) in order to safely and conveniently access info about a static collider hit. More...
 
AssetRef< MapStaticColliderMapRef [get]
 The reference to the map used by the physics engine when a static collider is hit. Otherwise, this value is default (hit IsDynamic). More...
 

Detailed Description

Information returned from a valid hit of a physics query.

Member Function Documentation

◆ GetShape()

Shape2D* Quantum.Physics2D.Hit.GetShape ( FrameBase  f)
inline

Gets the shape of the entity. If the entity is a compound, it returns the specific shape of the compound.

Parameters
fThe frame.
Returns
The entity's Shape2D pointer.

◆ TryGetShape()

bool Quantum.Physics2D.Hit.TryGetShape ( FrameBase  f,
out Shape2D shape 
)
inline

Checks if the hit is valid and outs the shape of the entity. Otherwise, it will return false. If the entity is a compound, it returns the specific shape of the compound.

Parameters
fThe frame.
shapeThe shape pointer.
Returns
True if the hit is valid.

◆ SetHitEntity()

void Quantum.Physics2D.Hit.SetHitEntity ( EntityRef  entity)
inline

Sets the entity that was hit. Automatically resets StaticColliderIndex to -1.

Parameters
entityThe entity reference.

◆ SetHitStaticCollider()

void Quantum.Physics2D.Hit.SetHitStaticCollider ( int  staticColliderIndex,
AssetRef< Map mapRef 
)
inline

Sets the index of the static collider hit on the Map.StaticColliders2D array of the referenced map.

Parameters
staticColliderIndexA valid index of the static collider on the array of the map.
mapRefA reference to the map where the static collider hit is located.

◆ TryGetStaticCollider()

bool Quantum.Physics2D.Hit.TryGetStaticCollider ( FrameBase  f,
out MapStaticCollider2D  collider 
)
inline

Tries to access the static collider that was hit.

Parameters
fCurrent frame.
colliderA copy of the static collider data found. Default if the metadata is not valid (returns false).
Returns
false if the collider hit is not static or the collide index or referenced map are not valid. true otherwise.

◆ TryGetStaticData()

bool Quantum.Physics2D.Hit.TryGetStaticData ( FrameBase  f,
out StaticColliderData  data 
)
inline

Tries to access the data of the static collider that was hit (MapStaticCollider2D.StaticData).

Parameters
fCurrent frame.
dataA copy of the static collider data found. Default if the metadata is not valid (returns false).
Returns
false if the collider hit is not static or the collide index or referenced map are not valid. true otherwise.

◆ GetStaticCollider()

ref MapStaticCollider2D Quantum.Physics2D.Hit.GetStaticCollider ( FrameBase  f)
inline

Gets a reference to the static collider hit. Does not perform additional safety checks.

Parameters
fCurrent frame.
Exceptions
NullReferenceExceptionIf the StaticColliderMapRef does not reference a valid asset.
IndexOutOfRangeExceptionIf the hit is not static (IsDynamic) or the collider index is not valid for the array of static colliders on the referenced map.
Returns
A reference to the static collider hit.

◆ GetStaticData()

ref StaticColliderData Quantum.Physics2D.Hit.GetStaticData ( FrameBase  f)
inline

Gets a reference to the data of the static collider hit (MapStaticCollider2D.StaticData). Does not perform additional safety checks.

Parameters
fCurrent frame.
Exceptions
NullReferenceExceptionIf the StaticColliderMapRef does not reference a valid asset.
IndexOutOfRangeExceptionIf the hit is not static (IsDynamic) or the collider index is not valid for the array of static colliders on the referenced map.
Returns
A reference to the static collider hit.

◆ Serialize()

static void Quantum.Physics2D.Hit.Serialize ( void *  ptr,
FrameSerializer  serializer 
)
inlinestatic

Serializes a Hit into a FrameSerializer.

Parameters
ptrThe pointer to the Hit.
serializerThe FrameSerializer instance into which the struct will be serialized.

◆ GetHashCode()

override Int32 Quantum.Physics2D.Hit.GetHashCode ( )
inline

Overrides the hash code generation of this type.

Returns
A hash code of the current state of this instance.

Member Data Documentation

◆ SIZE

const int Quantum.Physics2D.Hit.SIZE = SecondInfo + sizeof(Int32) * 2
static

The size of the struct in bytes.

◆ ShapeUserTag

ushort Quantum.Physics2D.Hit.ShapeUserTag

The Shape2D.UserTag field of the shape hit by the query.

◆ OverlapPenetration

FP Quantum.Physics2D.Hit.OverlapPenetration

The penetration of a shape overlap query on the collider that was hit.

This field is not computed unless QueryOptions.ComputeDetailedInfo is used in the query options and only applies to Shape Overlap queries. It overlaps in memory and is mutually exclusive with CastDistanceNormalized.

◆ CastDistanceNormalized

FP Quantum.Physics2D.Hit.CastDistanceNormalized

A normalized value (0 to 1) of the feature being casted when the hit occurs, relative to its full cast distance.

This field only applies to Ray, Line or Shape casts. It overlaps in memory and is mutually exclusive with OverlapPenetration.

◆ Point

FPVector2 Quantum.Physics2D.Hit.Point

The point in world space where the collider is hit by the query.

◆ Normal

FPVector2 Quantum.Physics2D.Hit.Normal

The surface normal of the hit.

This field is not computed unless QueryOptions.ComputeDetailedInfo is used in the query options.

Property Documentation

◆ IsDynamic

Boolean Quantum.Physics2D.Hit.IsDynamic
get

If the collider hit by the query is not static, i.e. it belongs to an Entity.

◆ IsStatic

Boolean Quantum.Physics2D.Hit.IsStatic
get

If the collider hit by the query is static.

◆ StaticColliderIndex

int Quantum.Physics2D.Hit.StaticColliderIndex
get

0-based index of the static collider on the Map.StaticColliders2D array of the map referenced by StaticColliderMapRef. If the hit IsDynamic, this value is -1. Tip: use TryGetStaticCollider(FrameBase, out MapStaticCollider2D), TryGetStaticData(FrameBase, out StaticColliderData), GetStaticCollider(FrameBase) or GetStaticData(FrameBase) in order to safely and conveniently access info about a static collider hit.

◆ StaticColliderMapRef

AssetRef<Map> Quantum.Physics2D.Hit.StaticColliderMapRef
get

The reference to the map used by the physics engine when a static collider is hit. Otherwise, this value is default (hit IsDynamic).

◆ IsTrigger

Boolean? Quantum.Physics2D.Hit.IsTrigger
getset

If the collider hit by the query is Trigger.

◆ Entity

EntityRef? Quantum.Physics2D.Hit.Entity
get

The reference of the entity hit by the query, EntityRef.None if hitting a static collider (IsDynamic false).