Class PhysicManager3D
Class that represents a Physics Manager used for 3D physics simulations.
Inheritance
Implements
Inherited Members
Namespace: Evergine.Framework.Managers
Assembly: Evergine.Framework.dll
Syntax
public abstract class PhysicManager3D : UpdatableSceneManager, IDependencyObject
Fields
RenderManager
The rendering manager.
Declaration
[BindSceneManager(false, false)]
public RenderManager RenderManager
Field Value
| Type | Description |
|---|---|
| RenderManager |
Properties
ApplySpeculativeContactRestitution
Gets or sets a value indicating whether to apply speculative contact restitution.
Declaration
public abstract bool ApplySpeculativeContactRestitution { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
DrawFlags
Gets or sets the debug draw flags.
Declaration
public abstract DebugDrawFlags DrawFlags { get; set; }
Property Value
| Type | Description |
|---|---|
| DebugDrawFlags |
FixedTimeStep
Gets or sets the resolution of the physics simulation. The default value is 1/60, or 60fps.
Declaration
public abstract float FixedTimeStep { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Gravity
Gets or sets the global gravity vector.
Declaration
public abstract Vector3 Gravity { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
InternalWorld
Gets the internal native world instance.
Declaration
public abstract object InternalWorld { get; }
Property Value
| Type | Description |
|---|---|
| object |
MaxSubSteps
Gets or sets the maximum number of substeps that Physics3D is allowed to perform each step.
Declaration
public abstract int MaxSubSteps { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
PerformPhysicSteps
Gets or sets a value indicating whether the physics world performs rigidbody calculations.
Declaration
public bool PerformPhysicSteps { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
PhysicComponentList
Gets the physics component list.
Declaration
public IEnumerable<Behavior> PhysicComponentList { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<Behavior> |
PhysicWorldResolution
Gets or sets the resolution of the physics world. Changing this value does not affect the size or positions of Evergine entities. It only affects the internal physics world.
Declaration
public abstract float PhysicWorldResolution { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
AddPhysicBody(IPhysicBody3D)
Adds the physics body to the simulation world.
Declaration
public abstract void AddPhysicBody(IPhysicBody3D body)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicBody3D | body | The body. |
AddPhysicComponent(Behavior)
Adds a physics component.
Declaration
protected virtual void AddPhysicComponent(Behavior behavior)
Parameters
| Type | Name | Description |
|---|---|---|
| Behavior | behavior | The physics component. |
ContactPairTest(IPhysicBody3D, IPhysicBody3D, IColliderShape3D, IColliderShape3D, ICollection<ContactPoint3D>)
The contact test query performs a collision test against the specified physics object.
Declaration
public abstract int ContactPairTest(IPhysicBody3D physicBodyA, IPhysicBody3D physicBodyB, IColliderShape3D colliderShapeA, IColliderShape3D colliderShapeB, ICollection<ContactPoint3D> resultsOutput)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicBody3D | physicBodyA | The first physics body to detect contact. |
| IPhysicBody3D | physicBodyB | The second physics body to detect contact. |
| IColliderShape3D | colliderShapeA | The collider on body A to test. |
| IColliderShape3D | colliderShapeB | The collider on body B to test. |
| ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be included. |
Returns
| Type | Description |
|---|---|
| int | The number of contacts detected. |
ContactPairTest(IPhysicBody3D, IPhysicBody3D, ICollection<ContactPoint3D>)
The contact test query performs a collision test against the specified physics object.
Declaration
public int ContactPairTest(IPhysicBody3D physicBodyA, IPhysicBody3D physicBodyB, ICollection<ContactPoint3D> resultsOutput)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicBody3D | physicBodyA | The first physics body to detect contact. |
| IPhysicBody3D | physicBodyB | The second physics body to detect contact. |
| ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be included. |
Returns
| Type | Description |
|---|---|
| int | The number of contacts detected. |
ContactTest(IPhysicBody3D, IColliderShape3D, ICollection<ContactPoint3D>)
The contact test query performs a collision test against all overlapping objects in the physics world.
Declaration
public abstract int ContactTest(IPhysicBody3D physicBody, IColliderShape3D colliderShapeA, ICollection<ContactPoint3D> resultsOutput)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicBody3D | physicBody | The physics body to detect contact. |
| IColliderShape3D | colliderShapeA | The collider on bodyA to test. |
| ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be included. |
Returns
| Type | Description |
|---|---|
| int | The number of contacts detected. |
Remarks
resultsOutput is not cleared.
ContactTest(IPhysicBody3D, ICollection<ContactPoint3D>)
The contact test query performs a collision test against all overlapping objects in the physics world.
Declaration
public int ContactTest(IPhysicBody3D physicBody, ICollection<ContactPoint3D> resultsOutput)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicBody3D | physicBody | The physics body to detect contact. |
| ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be included. |
Returns
| Type | Description |
|---|---|
| int | The number of contacts detected. |
Remarks
resultsOutput is not cleared.
ConvexSweepTest(IColliderShape3D, ref Matrix4x4, ref Matrix4x4, CollisionCategory3D)
Performs a sweep test using a collider shape and stops at the first hit.
Declaration
public abstract HitResult3D ConvexSweepTest(IColliderShape3D colliderShape, ref Matrix4x4 from, ref Matrix4x4 to, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| IColliderShape3D | colliderShape | The collider shape. |
| Matrix4x4 | from | The starting matrix. |
| Matrix4x4 | to | The ending matrix. |
| CollisionCategory3D | filterMask | The collision category filter for the ray. |
Returns
| Type | Description |
|---|---|
| HitResult3D | The result of the hit. |
ConvexSweepTestAll(IColliderShape3D, ref Matrix4x4, ref Matrix4x4, ICollection<HitResult3D>, CollisionCategory3D)
Sweep test using a collider shape that stops at the first hit.
Declaration
public abstract void ConvexSweepTestAll(IColliderShape3D colliderShape, ref Matrix4x4 from, ref Matrix4x4 to, ICollection<HitResult3D> resultsOutput, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| IColliderShape3D | colliderShape | The collider shape. |
| Matrix4x4 | from | The initial matrix. |
| Matrix4x4 | to | The target matrix. |
| ICollection<HitResult3D> | resultsOutput | The collection where the contact results will be included. |
| CollisionCategory3D | filterMask | The collision category that the ray will hit. |
CreateColliderShape<T>(params object[])
Instantiates a new Collider shape.
Declaration
public abstract T CreateColliderShape<T>(params object[] param) where T : IColliderShape3D
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | param | Collider parameters. |
Returns
| Type | Description |
|---|---|
| T | The new collider shape. |
Type Parameters
| Name | Description |
|---|---|
| T | The ColliderShape type. |
CreateJoint<T, J>(J)
Creates a joint.
Declaration
public abstract T CreateJoint<T, J>(J jointDef) where T : IJoint3D where J : JointDef3D<T>
Parameters
| Type | Name | Description |
|---|---|---|
| J | jointDef | The joint definition instance. |
Returns
| Type | Description |
|---|---|
| T | The new joint instance. |
Type Parameters
| Name | Description |
|---|---|
| T | The joint type. |
| J | The joint definition type. |
CreatePhysicAction<T>(params object[])
Creates a physics action instance (character, vehicle controllers, etc.)
Declaration
public abstract T CreatePhysicAction<T>(params object[] param) where T : IPhysicAction3D
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | param | The initialization parameters. |
Returns
| Type | Description |
|---|---|
| T | The created instance. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the physics action. |
CreatePhysicBody<T, J>(J)
Creates a StaticBody 3D.
Declaration
public abstract T CreatePhysicBody<T, J>(J bodyDef) where T : IPhysicBody3D where J : PhysicBodyDef3D<T>
Parameters
| Type | Name | Description |
|---|---|---|
| J | bodyDef | Body definition. |
Returns
| Type | Description |
|---|---|
| T | The static body instance. |
Type Parameters
| Name | Description |
|---|---|
| T | The physics body interface. |
| J | The body definition class. |
DebugDraw()
Draws the debug information.
Declaration
public abstract void DebugDraw()
OnAttached()
Invoked when the object is attached to the system.
Declaration
protected override bool OnAttached()
Returns
| Type | Description |
|---|---|
| bool | True if everything is OK. |
Overrides
OnCameraRender(object, DrawContext)
Camera render event handler method.
Declaration
protected virtual void OnCameraRender(object sender, DrawContext e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | Sender object. |
| DrawContext | e | Drawing context. |
OnDetached()
Invoked when the object is detached.
Declaration
protected override void OnDetached()
Overrides
OnLoaded()
Initializes this manager.
Declaration
protected override void OnLoaded()
Overrides
PointTest(IColliderShape3D, ref Vector3)
Tests if a point is inside a physics body.
Declaration
public abstract bool PointTest(IColliderShape3D collider, ref Vector3 position)
Parameters
| Type | Name | Description |
|---|---|---|
| IColliderShape3D | collider | The collider to test. |
| Vector3 | position | The position to test in world coordinates. |
Returns
| Type | Description |
|---|---|
| bool | True if the position is inside the body. |
PointTest(IPhysicBody3D, ref Vector3)
Tests if a point is inside a physical body.
Declaration
public abstract bool PointTest(IPhysicBody3D physicBody, ref Vector3 position)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicBody3D | physicBody | The physical body. |
| Vector3 | position | The position to test in world coordinates. |
Returns
| Type | Description |
|---|---|
| bool | Whether this position is inside this body. |
RayCast(ref Ray, float, CollisionCategory3D)
Raycasts and stops at the first hit.
Declaration
public abstract HitResult3D RayCast(ref Ray ray, float rayDistance, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray. |
| float | rayDistance | The distance to test. |
| CollisionCategory3D | filterMask | The collision category that the ray should hit. |
Returns
| Type | Description |
|---|---|
| HitResult3D | The closest hit result. |
RayCast(ref RayStep, CollisionCategory3D)
Performs a raycast and stops at the first hit.
Declaration
public abstract HitResult3D RayCast(ref RayStep rayStep, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| RayStep | rayStep | The ray step. |
| CollisionCategory3D | filterMask | The collision category used to filter hits. |
Returns
| Type | Description |
|---|---|
| HitResult3D | The closest hit result. |
RayCast(ref Vector3, ref Vector3, CollisionCategory3D)
Casts a ray and stops at the first hit.
Declaration
public abstract HitResult3D RayCast(ref Vector3 from, ref Vector3 to, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | from | The starting ray position. |
| Vector3 | to | The ray's endpoint. |
| CollisionCategory3D | filterMask | The collision category to be used for the raycast. |
Returns
| Type | Description |
|---|---|
| HitResult3D | The result of the closest hit. |
RayCastAll(ref Ray, float, ICollection<HitResult3D>, CollisionCategory3D)
Raycasts and gets all the hits.
Declaration
public abstract void RayCastAll(ref Ray ray, float rayDistance, ICollection<HitResult3D> resultsOutput, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray. |
| float | rayDistance | The distance to test. |
| ICollection<HitResult3D> | resultsOutput | The collection where the results will be included. |
| CollisionCategory3D | filterMask | The collision category to be hit by the ray. |
RayCastAll(ref RayStep, ICollection<HitResult3D>, CollisionCategory3D)
Raycasts and gets all the hits.
Declaration
public abstract void RayCastAll(ref RayStep rayStep, ICollection<HitResult3D> resultsOutput, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| RayStep | rayStep | The ray step. |
| ICollection<HitResult3D> | resultsOutput | The collection where the results will be included. |
| CollisionCategory3D | filterMask | The collision category to hit with the ray. |
RayCastAll(ref Vector3, ref Vector3, ICollection<HitResult3D>, CollisionCategory3D)
Raycasts and gets all the hits.
Declaration
public abstract void RayCastAll(ref Vector3 from, ref Vector3 to, ICollection<HitResult3D> resultsOutput, CollisionCategory3D filterMask = CollisionCategory3D.All)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | from | The starting ray position. |
| Vector3 | to | The ray endpoint. |
| ICollection<HitResult3D> | resultsOutput | The collection where the results will be stored. |
| CollisionCategory3D | filterMask | The collision category for the ray to hit. |
RemoveJoint(IJoint3D)
Removes the joint from the physics world.
Declaration
public abstract void RemoveJoint(IJoint3D joint)
Parameters
| Type | Name | Description |
|---|---|---|
| IJoint3D | joint | The joint to remove. |
RemovePhysicAction(IPhysicAction3D)
Removes the physical action.
Declaration
public abstract void RemovePhysicAction(IPhysicAction3D physicAction)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicAction3D | physicAction | The physical action to remove. |
RemovePhysicBody(IPhysicBody3D)
Removes a Rigidbody 3D from the world.
Declaration
public abstract void RemovePhysicBody(IPhysicBody3D body)
Parameters
| Type | Name | Description |
|---|---|---|
| IPhysicBody3D | body | The body to remove. |
RemovePhysicComponent(Behavior)
Removes the physics component.
Declaration
protected virtual bool RemovePhysicComponent(Behavior behavior)
Parameters
| Type | Name | Description |
|---|---|---|
| Behavior | behavior | The physics component. |
Returns
| Type | Description |
|---|---|
| bool | Whether the component has been removed. |
SetDebugDraw(ISimulationDebugDraw3D)
Sets the debug drawing of Simulation 2D.
Declaration
public abstract void SetDebugDraw(ISimulationDebugDraw3D debugDraw)
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulationDebugDraw3D | debugDraw | The debug draw instance. |
Events
OnPhysicStep
Event fired when the physics will take a step
Declaration
public abstract event EventHandler OnPhysicStep
Event Type
| Type | Description |
|---|---|
| EventHandler |