Class PhysicManager3D
Class that represent a Physic Manager used for 3D physic simulations.
Inheritance
Implements
Inherited Members
Namespace: Evergine.Framework.Managers
Assembly: Evergine.Framework.dll
Syntax
public abstract class PhysicManager3D : UpdatableSceneManager, IDependencyObject
Fields
RenderManager
The render manager.
Declaration
[BindSceneManager(false, false)]
public RenderManager RenderManager
Field Value
Type | Description |
---|---|
RenderManager |
Properties
ApplySpeculativeContactRestitution
Gets or sets a value indicating whether you want to apply the 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 physics simulation. Default value of 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 every step.
Declaration
public abstract int MaxSubSteps { get; set; }
Property Value
Type | Description |
---|---|
int |
PerformPhysicSteps
Gets or sets a value indicating whether the physic world perform rigidbody calculations.
Declaration
public bool PerformPhysicSteps { get; set; }
Property Value
Type | Description |
---|---|
bool |
PhysicComponentList
Gets the physic component list.
Declaration
public IEnumerable<Behavior> PhysicComponentList { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Behavior> |
PhysicWorldResolution
Gets or sets the resolution of the physic world. Changing this value does not affect the size or positions of Evergine entities. It only affects internally in the physic world.
Declaration
public abstract float PhysicWorldResolution { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
AddPhysicBody(IPhysicBody3D)
Add the physic body to the simulation world.
Declaration
public abstract void AddPhysicBody(IPhysicBody3D body)
Parameters
Type | Name | Description |
---|---|---|
IPhysicBody3D | body | The body. |
AddPhysicComponent(Behavior)
Add a physic component.
Declaration
protected virtual void AddPhysicComponent(Behavior behavior)
Parameters
Type | Name | Description |
---|---|---|
Behavior | behavior | The physic component. |
ContactPairTest(IPhysicBody3D, IPhysicBody3D, IColliderShape3D, IColliderShape3D, ICollection<ContactPoint3D>)
The contact test query perform a collision test against the specified physic 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 physic body to detect contact. |
IPhysicBody3D | physicBodyB | The second physic body to detect contact. |
IColliderShape3D | colliderShapeA | The collider on bodyA to test. |
IColliderShape3D | colliderShapeB | The collider on bodyB 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 perform a collision test against the specified physic object.
Declaration
public int ContactPairTest(IPhysicBody3D physicBodyA, IPhysicBody3D physicBodyB, ICollection<ContactPoint3D> resultsOutput)
Parameters
Type | Name | Description |
---|---|---|
IPhysicBody3D | physicBodyA | The first physic body to detect contact. |
IPhysicBody3D | physicBodyB | The second physic 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 perform a collision test against all overlapping objects in the physic world.
Declaration
public abstract int ContactTest(IPhysicBody3D physicBody, IColliderShape3D colliderShapeA, ICollection<ContactPoint3D> resultsOutput)
Parameters
Type | Name | Description |
---|---|---|
IPhysicBody3D | physicBody | The physic 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 perform a collision test against all overlapping objects in the physic world.
Declaration
public int ContactTest(IPhysicBody3D physicBody, ICollection<ContactPoint3D> resultsOutput)
Parameters
Type | Name | Description |
---|---|---|
IPhysicBody3D | physicBody | The physic 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)
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 from matrix. |
Matrix4x4 | to | The to matrix. |
CollisionCategory3D | filterMask | The collision category to hit the ray. |
Returns
Type | Description |
---|---|
HitResult3D | The hit result. |
ConvexSweepTestAll(IColliderShape3D, ref Matrix4x4, ref Matrix4x4, ICollection<HitResult3D>, CollisionCategory3D)
Sweep test using a collider shape and 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 from matrix. |
Matrix4x4 | to | The to matrix. |
ICollection<HitResult3D> | resultsOutput | The collection where the contact results will be included. |
CollisionCategory3D | filterMask | The collision category to hit the ray. |
CreateColliderShape<T>(params object[])
Instantiate 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[])
Create a physic action instance (character, vehicle controllers...)
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 physic 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 physic body interface. |
J | The body definition class. |
DebugDraw()
Draw 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 all 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. |
OnDetach()
Invoked when the object is detached.
Declaration
protected override void OnDetach()
Overrides
OnLoaded()
Initializes this manager.
Declaration
protected override void OnLoaded()
Overrides
PointTest(IColliderShape3D, ref Vector3)
Test if a point is inside a physic body.
Declaration
public abstract bool PointTest(IColliderShape3D collider, ref Vector3 position)
Parameters
Type | Name | Description |
---|---|---|
IColliderShape3D | collider | The collider to test with. |
Vector3 | position | The position to test in world coordinates. |
Returns
Type | Description |
---|---|
bool | If this position is inside this body. |
PointTest(IPhysicBody3D, ref Vector3)
Test if a point is inside a physic body.
Declaration
public abstract bool PointTest(IPhysicBody3D physicBody, ref Vector3 position)
Parameters
Type | Name | Description |
---|---|---|
IPhysicBody3D | physicBody | The physic body. |
Vector3 | position | The position to test in world coordinates. |
Returns
Type | Description |
---|---|
bool | If this position is inside this body. |
RayCast(ref Ray, float, CollisionCategory3D)
Raycast and stop 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 to hit the ray. |
Returns
Type | Description |
---|---|
HitResult3D | The closest hit result. |
RayCast(ref RayStep, CollisionCategory3D)
Raycast and stop 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 to hit the ray. |
Returns
Type | Description |
---|---|
HitResult3D | The closest hit result. |
RayCast(ref Vector3, ref Vector3, CollisionCategory3D)
Raycast and stop 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 start ray position. |
Vector3 | to | The ray ending. |
CollisionCategory3D | filterMask | The collision category to hit the ray. |
Returns
Type | Description |
---|---|
HitResult3D | The closest hit result. |
RayCastAll(ref Ray, float, ICollection<HitResult3D>, CollisionCategory3D)
Raycast 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 hit the ray. |
RayCastAll(ref RayStep, ICollection<HitResult3D>, CollisionCategory3D)
Raycast 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 the ray. |
RayCastAll(ref Vector3, ref Vector3, ICollection<HitResult3D>, CollisionCategory3D)
Raycast 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 start ray position. |
Vector3 | to | The ray ending. |
ICollection<HitResult3D> | resultsOutput | The collection where the results will be included. |
CollisionCategory3D | filterMask | The collision category to hit the ray. |
RemoveJoint(IJoint3D)
Remove the joint from the physic world.
Declaration
public abstract void RemoveJoint(IJoint3D joint)
Parameters
Type | Name | Description |
---|---|---|
IJoint3D | joint | The joint to remove. |
RemovePhysicAction(IPhysicAction3D)
Remove the physic action.
Declaration
public abstract void RemovePhysicAction(IPhysicAction3D physicAction)
Parameters
Type | Name | Description |
---|---|---|
IPhysicAction3D | physicAction | The physic 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)
Remove the physic component.
Declaration
protected virtual bool RemovePhysicComponent(Behavior behavior)
Parameters
Type | Name | Description |
---|---|---|
Behavior | behavior | The physic component. |
Returns
Type | Description |
---|---|
bool | If the component has been removed. |
SetDebugDraw(ISimulationDebugDraw3D)
Sets the debug draw 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 do an step
Declaration
public abstract event EventHandler OnPhysicStep
Event Type
Type | Description |
---|---|
EventHandler |