Search Results for

    Show / Hide Table of Contents

    PhysicManager and Bullet

    Physics

    In Evergine, Physics are implemented with the PhysicManager3D class, a SceneManager. This manager is responsible for creating and maintaining the Physic World. This is an abstract class that only offers the functionality that a Physic Manager should implement:

    • Create the Physic World
    • Allow the creation of Physic elements (Bodies, Colliders, etc.)
    • Offer the possibility to perform physic queries (ray casting, sweep test, etc.).

    Because PhysicManager3D is a SceneManager, every scene has its own Physic World.

    PhysicManager3D properties

    To properly set up your Physic World, the following properties are useful:

    Property Default Description
    Gravity 0, -9.8, 0 This is the global gravity vector, in m/s². The default value is 1G (-9.8m/s²)
    PerformPhysicSteps true Indicates if the physic simulation will be updated every frame. If your scene has dynamic objects (rigidbodies), and this property is set to false, these objects won't be simulated. If your applications only use static bodies, it is recommended to set this property to false.
    MaxSubSteps 1 In how many subdivisions the physic world updates are divided. Greater values produce better simulations, but the performance is degraded.
    PhysicWorldResolution 1 The general physic world scale. By default, 1 unit in Evergine is equal to 1 unit in Physic World. Changing this value affects this behavior. For example, a value of 10 indicates that a sphere with a radius of 1 will produce a physic object of 10. Changing this value is useful when the objects are too small or too large.
    FixedTimeStep 1.0/60 The physic steps will perform at a fixed timestep indicated in this property (in seconds). By default, it is 60Hz.
    DrawFlags All,
    -DrawAabb,
    -DrawContactPoints
    These flags allow you to select which elements you want to be rendered when RenderManager.DebugLines is set to true. By default, all elements are included except Aabb and contact points:
    • DrawWireframe: Debug draw mesh collider wireframe.
    • DrawAabb: Debug draw bodies AABB.
    • DrawContactPoints: Debug draw the contact points between bodies.
    • DrawConstraints: Debug draw physic joints.
    • DrawConstraintLimits: Debug draw the physic joints limits.
    • DrawFastWireframe: Debug draw wireframes in a fast way.
    • DrawNormals: Debug draw normals.

    Bullet and BulletPhysicManager3D

    Evergine provides an implementation for PhysicManager3D using the open-source Bullet Physics engine. For detailed information, see the Bullet User Manual.

    In Evergine, the Bullet implementation can be used with the BulletPhysicManager3D.

    Bullet Logo

    Using BulletPhysicManager3D

    To start using Physics in your scene, you need to create an instance of BulletPhysicManager3D and register it into your Scene. This implementation is provided in the Evergine.Bullet NuGet package.

    Note

    Evergine project templates will register the Bullet Physic Manager by default.

    public class MyScene : Scene
    {
        public override void RegisterManagers()
        {
            base.RegisterManagers();
            this.Managers.AddManager(new Evergine.Bullet.BulletPhysicManager3D());
        }
    
        // Other scene methods...
    
    }
    
    In this article
    Back to top
    Generated by DocFX