Chunks
Moddable voxel sandbox for room-scale VR.
Public Member Functions | Protected Member Functions | Properties | Events | List of all members
Chunks.Geometry.AABBPhysics Class Reference

Handles movement and collisions for an axis aligned bounding box. More...

Inheritance diagram for Chunks.Geometry.AABBPhysics:
Chunks.Entities.Component Chunks.Geometry.IRaycastable Chunks.Entities.Object Chunks.Entities.IComponent Chunks.Entities.IComponent Chunks.Entities.IObject Chunks.Entities.IObject

Public Member Functions

 AABBPhysics ()
 
void Impulse (Vector force)
 Adds the given force divided by the entity's mass to the current velocity. More...
 
void Accelerate (Vector accel)
 Accelerates the body by the given amount in metres per second. More...
 
bool Sweep (Vector delta, out WorldSweepHit hitInfo)
 Projects the AABB along the given delta vector, testing to see if a collision will occur. Returns true if a collision is found. More...
 
bool Sweep (Vector offset, Vector delta, out WorldSweepHit hitInfo)
 Projects the AABB along the given delta vector, testing to see if a collision will occur. Returns true if a collision is found. More...
 
bool Contains (Vector worldPos, float margin=0f)
 
bool Raycast (Ray ray, float maxDist, out EntityRaycastHit raycastHit)
 
- Public Member Functions inherited from Chunks.Entities.Component
void DestroyComponent ()
 Removes this component from the entity that contains it. More...
 
void DestroyEntity ()
 Removes the entity containing this component from the world, along with any child entities. More...
 
override string ToString ()
 Returns a string representing this component with the format "TypeName (EntityName)." More...
 
- Public Member Functions inherited from Chunks.Entities.Object
Entity CreateChild ()
 Creates a new Entity parented to this one. More...
 
TComponent CreateChildWithComponent< TComponent > ()
 Creates a new Entity parented to this one with a component of the given type, which is returned. More...
 
Entity FindChild (string name, bool recurse=true)
 Attempts to find a child Entity of this one with the given name, and optionally searches recursively through all children. Null is returned if no matches are found. More...
 
TComponent FindChildComponent< TComponent > (string name, bool recurse=true)
 Attempts to find a child Entity of this one with the given name, and optionally searches recursively through all children. If a matching Entity is found, a component of the given type is retrieved from it. Null is returned if no matches are found. More...
 
Entity FindParent (string name)
 Attempts to find an Entity that contains this Object's Entity with the given Name. Returns null if no match is found. More...
 
TComponent FindParentComponent< TComponent > ()
 Attempts to find an Entity that contains this Object's Entity with a component of the given type. If a matching Entity is found, the component of the given type is retrieved from it. Returns null if no match is found. More...
 
TComponent FindParentComponent< TComponent > (string name)
 Attempts to find an Entity that contains this Object's Entity with the given Name. If a matching Entity is found, a component of the given type is retrieved from it. Returns null if no match is found. More...
 
TComponent AddComponent< TComponent > ()
 Adds a component of the specified type to this entity, returning the new component. More...
 
TComponent GetOrAddComponent< TComponent > ()
 Attempts to get a component of the specified type from this entity, adding it if one doesn't already exist. More...
 
TComponent GetComponent< TComponent > ()
 Attempts to get a component of the specified type from this entity, returning null if one doesn't exist. More...
 
IEnumerable< TComponent > GetComponents< TComponent > ()
 Gets all components derived from the given type. More...
 

Protected Member Functions

override void OnPhysicsUpdate ()
 
override void OnEnable ()
 Called each time this component goes from being disabled to enabled. More...
 
override void OnDisable ()
 Called each time this component goes from being enabled to disabled. More...
 
override void OnDestroy ()
 Called when this component is removed, or the parent entity is destroyed. More...
 
- Protected Member Functions inherited from Chunks.Entities.Component
object Wait (float timeSeconds)
 Suspends coroutine operation for the given time when yielded. More...
 
object StartCoroutine (IEnumerator routine)
 Starts execution of a coroutine. More...
 
virtual void OnSave (BinaryWriter writer)
 Implement this and OnLoad to enable serialization of this component when the parent entity saves. More...
 
virtual void OnLoad (BinaryReader reader)
 Implement this and OnSave to enable serialization of this component when the parent entity saves. More...
 
virtual void OnInitialize ()
 Called only once, when the component is first attached to an entity and is ready to add or retrieve other components. More...
 
virtual void OnUpdate ()
 Called once per world update if this component and its parent entity are enabled. More...
 
virtual void OnPreRender ()
 Called just before the entity containing this component is rendered. More...
 

Properties

Vector Offset [get, set]
 Bounding box center offset. More...
 
Vector Size [get, set]
 Bounding box width, height and depth. More...
 
float AirResistance [get, set]
 The proportion of the entity's velocity that is lost per second while in the air. More...
 
float Friction [get, set]
 The proportion of the entity's tangential velocity that is lost while sliding across a surface. More...
 
float Elasticity [get, set]
 The proportion of the entity's normal velocity that is maintained when bouncing off a surface. More...
 
Vector Gravity [get, set]
 The constant acceleration applied to this entity every second. More...
 
float Density [get, set]
 Used to find the mass of this entity when multiplied by the volume. More...
 
bool IsGrounded [get]
 If true, this entity is touching a surface below it. More...
 
bool ScaleGravityWithSize [get, set]
 If true, the acceleration from gravity will be scaled by the scale of this entity. More...
 
float Mass [get, set]
 Volume multiplied by density. More...
 
Vector Velocity [get, set]
 The amount this entity moves per second. More...
 
bool Simulate [get, set]
 
- Properties inherited from Chunks.Entities.Component
Entity Entity [get]
 The entity this instance is attached to. More...
 
bool IsSavingImplemented [get]
 If true, OnSave and OnLoad have been implemented for this type. More...
 
bool Enabled [get, set]
 Enabled components will be updated, assuming they are within enabled entities. More...
 
- Properties inherited from Chunks.Entities.Object
abstract bool IsValid [get]
 Tests to see if this object hasn't been removed. More...
 
virtual string Name [get, set]
 Custom name associated with this Object's Entity, used to find the Entity in the hierarchy. More...
 
virtual Transform Transform [get]
 Transformation of this Object's Entity. More...
 
virtual IWorld World [get]
 The IWorld that contains this Object. More...
 
- Properties inherited from Chunks.Entities.IComponent
Entity Entity [get]
 
bool IsSavingImplemented [get]
 
bool Enabled [get, set]
 
- Properties inherited from Chunks.Entities.IObject
bool IsValid [get]
 
string Name [get, set]
 
Transform Transform [get]
 
IWorld World [get]
 

Events

EventHandler< CollisionEventArgsCollided
 Invoked when this entity collides with the world. More...
 

Additional Inherited Members

- Public Attributes inherited from Chunks.Entities.Component
override bool IsValid => Behaviour != null
 Tests to see if this component hasn't been removed. More...
 

Detailed Description

Handles movement and collisions for an axis aligned bounding box.

Constructor & Destructor Documentation

Chunks.Geometry.AABBPhysics.AABBPhysics ( )

Member Function Documentation

void Chunks.Geometry.AABBPhysics.Accelerate ( Vector  accel)

Accelerates the body by the given amount in metres per second.

Parameters
accelAcceleration to apply
bool Chunks.Geometry.AABBPhysics.Contains ( Vector  worldPos,
float  margin = 0f 
)
void Chunks.Geometry.AABBPhysics.Impulse ( Vector  force)

Adds the given force divided by the entity's mass to the current velocity.

Parameters
forceForce to apply
override void Chunks.Geometry.AABBPhysics.OnDestroy ( )
protectedvirtual

Called when this component is removed, or the parent entity is destroyed.

Reimplemented from Chunks.Entities.Component.

override void Chunks.Geometry.AABBPhysics.OnDisable ( )
protectedvirtual

Called each time this component goes from being enabled to disabled.

Reimplemented from Chunks.Entities.Component.

override void Chunks.Geometry.AABBPhysics.OnEnable ( )
protectedvirtual

Called each time this component goes from being disabled to enabled.

Reimplemented from Chunks.Entities.Component.

override void Chunks.Geometry.AABBPhysics.OnPhysicsUpdate ( )
protectedvirtual

Reimplemented from Chunks.Entities.Component.

bool Chunks.Geometry.AABBPhysics.Raycast ( Ray  ray,
float  maxDist,
out EntityRaycastHit  raycastHit 
)
bool Chunks.Geometry.AABBPhysics.Sweep ( Vector  delta,
out WorldSweepHit  hitInfo 
)

Projects the AABB along the given delta vector, testing to see if a collision will occur. Returns true if a collision is found.

Parameters
deltaDirection and distance to sweep
hitInfoIf a collision is found, contains collision info
bool Chunks.Geometry.AABBPhysics.Sweep ( Vector  offset,
Vector  delta,
out WorldSweepHit  hitInfo 
)

Projects the AABB along the given delta vector, testing to see if a collision will occur. Returns true if a collision is found.

Parameters
offsetWorld space offset to apply to the AABB before sweeping
deltaDirection and distance to sweep
hitInfoIf a collision is found, contains collision info

Property Documentation

float Chunks.Geometry.AABBPhysics.AirResistance
getset

The proportion of the entity's velocity that is lost per second while in the air.

float Chunks.Geometry.AABBPhysics.Density
getset

Used to find the mass of this entity when multiplied by the volume.

float Chunks.Geometry.AABBPhysics.Elasticity
getset

The proportion of the entity's normal velocity that is maintained when bouncing off a surface.

float Chunks.Geometry.AABBPhysics.Friction
getset

The proportion of the entity's tangential velocity that is lost while sliding across a surface.

Vector Chunks.Geometry.AABBPhysics.Gravity
getset

The constant acceleration applied to this entity every second.

bool Chunks.Geometry.AABBPhysics.IsGrounded
get

If true, this entity is touching a surface below it.

float Chunks.Geometry.AABBPhysics.Mass
getset

Volume multiplied by density.

Vector Chunks.Geometry.AABBPhysics.Offset
getset

Bounding box center offset.

bool Chunks.Geometry.AABBPhysics.ScaleGravityWithSize
getset

If true, the acceleration from gravity will be scaled by the scale of this entity.

bool Chunks.Geometry.AABBPhysics.Simulate
getset
Vector Chunks.Geometry.AABBPhysics.Size
getset

Bounding box width, height and depth.

Vector Chunks.Geometry.AABBPhysics.Velocity
getset

The amount this entity moves per second.

Event Documentation

EventHandler<CollisionEventArgs> Chunks.Geometry.AABBPhysics.Collided

Invoked when this entity collides with the world.


The documentation for this class was generated from the following file: