World

A world is a container that manages all physics elements of your application. It contains all PhysicObject as well as RigidConstraint and SoftConstraint etc...

The world also allows you to tweak parameters and settings that will have a direct impact on the physics simulation such as gravity, wind, air, water and more.

Other options are available to either increase or decrease the precision of the simulation, speeding it up or slowing it down based on the requirements of your application.

In addition, it also provides debugging functionalities that allows you to visualize a different aspect of the physics simulation such as bounds, constraints, contact points etc...

See Also

Static Variables


Name Description
collisionlayer_count Total amount of CollisionLayer.

Variables


Name Description
sub_steps The maximum amount of sub steps per physics pass.
fps Regulate the amount of physics frames per seconds.
traversal_mode The type of traversal algorithm used by the physics bounding volume hierarchies (BVH).
deactivation_time The generic deactivation time to use for soft, rigid and dynamic physics expressed in seconds (1.0 = 1sec.).
traversal_mode The type of traversal algorithm used by the physics bounding volume hierarchies (BVH).
contact_breaking_threshold Minimum threshold used to invalidate a contact point when using relative breaking threshold.
relative_contact_breaking_threshold Enable or disable relative contact breaking threshold.
tau Constant spring force to apply on constraints.
damping Default amount of damping applied on constraints.
friction Default amount of friction to use on constraints.
restitution Bounciness factor to apply on constraints.
iterations Base amounts of iterations to apply on RigidConstraint.
position_iterations Used by SoftConstraint to smoothly interpolate the positions between nodes.
velocity_iterations Numbers of velocity iterations used by SoftBody aeros.
erp Control the ERP used for constraints solving; increase this value to avoid jittering.
cfm Common constant force mixing factor to use for constraints solving.
linear_slop Additive distance factor used to calculate penetration.
warmstart_factor Value to use in order to warm start constraints solving.
resting_contact_restitution_frames Numbers of frames to evaluate to determine if a constraint is resting.
min_batch_size How many constraints should be solved per batch.
split_impulse Enable or disable impulse slplit.
split_impulse_penetration_threshold If impulse split is enabled this value controls the penetration threshold value.
split_impulse_erp The error reduction parameter used as Baumgarte factor.
gravity Controls the gravity direction vector that will be applied to all PhysicObject, RigidConstraint, SoftConstraint as well as SoftBody contained in the physics World.
air_density Controls the air density; primarily used by/and to influence lightweight SoftBody and especially aeros.
wind_velocity Wind velocity vector; that affect lightweight SoftBody.
water_density Represents the density of the water in terms of kilograms per meters cube.
water_normal A normalized vector that controls the water level direction.
water_offset Water level position aligned to the water_normal.
continuous Enable or disable continuous collision detection.
solver_mode Bit mask of SolverMode flags that controls the behaviors of the constraint solver.
debug_draw Bit mask of DebugDraw flags that controls physics visual debugging.

Functions


Name Description
Optimize Optimize the active World.
AddPhysicObject Add an existing PhysicObject to the current physics World.
RemovePhysicObject Remove a PhysicObject refrence from the active World.
AddCollisionLayer Function that retrieve the internal index of an existing Sector.
GetCollisionLayer Retrieve an existing CollisionLayer by name.
GetCollisionLayerIndex Return the index of a CollisionLayer reference.
SetCollisionLayerIndex Move a CollisionLayer to a new index.
RemoveCollisionLayer Remove a CollisionLayer from the active World.
RemoveCollisionLayerAt Remove a CollisionLayer using its index as key.
AddRigidConstraint Add a RigidConstraint to the active physics World.
RemoveRigidConstraint Remove an existing RigidConstraint from the World.
AddRigidConstraint Add a RigidConstraint to the active physics World.
PerformDiscreteCollisionDetection Manually perform a collision detection step.
Raycast Perform a multi-hit raycast operation against all the PhysicObject currently available in the World.
SingleRaycast Perform a single-hit raycast operation (faster) against all the PhysicObject currently available in the World.
AddRaycast Add a new raycast action to the physics pipeline.
AddSingleRaycast Add a new single raycast query to the physics pipeline.
RemoveRaycast Remove an existing raycast operation from the physics pipeline.
Sync Resynchronize the physics thread time with the one of the main thread.

WorldRay


A structure used to store the result of a World raycast operation.

Static Variables


Name Description
hit_count Total amount of hits.

Variables


Name Description
ray_from Start position of the ray.
ray_to End position of the ray.
collisionlayer_mask The Specify on which collision layer(s) the ray is placed.
collisionlayer_filter Specify with which collision layer(s) objects the ray should intersect with.
cull_face Enable or disable backface culling.
enabled Enable or disable continuous raycast.
query_available Determine if the raycast query is ready or not.

Functions


Name Description
GetHitPoint Retrieve the position of a specific hit.
GetHitNormal Retrieve the normal at a specific hit position.
GetHitFraction Retrieve the fraction for a specific hit.
GetPhysicObject Return the PhysicObject for a specific hit.

WorldContact


A structure that contains all the information available for a contact point between two PhysicObject.

Static Variables


Name Description
physicobject0 Reference of the first PhysicObject involved in the collision.
physicobject1 Reference to the second PhysicObject involved.
physicmaterial0 Reference of the PhysicMaterial used by the first PhysicObject.
physicmaterial1 Reference of the PhysicMaterial used by the second PhysicObject.
collider0 Reference to the first Collider involved in the contact.
collider1 Reference to the second Collider involved in the contact.
point Location of the contact in world space.
normal Normal vector of the contact point.
local0 Position of the contact in local space relative to the first PhysicObject pivot.
local1 Position of the contact in local space relative to the second PhysicObject pivot.
distance Distance of the contact between the two physic bodies.
lifetime Life time of the active contact point.
applied_impulse The amount of impulse applied on the contact.

SolverMode


Find below the list of all available flags that can be used to tweak the behaviors of the constraint solver.

  • fRandomizeOrder: Use a non-sequential pattern to progressively solve constraints.
  • fFrictionSeparate: Improve the performance of constraints solving by ignoring velocity dependent friction calculation.
  • fUseWarmStarting: Warmstart all constraints using the default warm start value set in the constraint Solver section to give a head start to all constraints solving at start time.
  • fFrictionWarmStarting: Warmstart the friction parameter of all constraints.
  • fUseTwoFrictionDirection: Improve the constraint's friction calculations quality by splitting the incoming and released friction value.
  • fEnableFrictionDirectionCaching: Improve the speed of the friction calculations at the cost of more memory.
  • fDisableVelocityDependenFrictionDirection: Improve the performance of constraints solving by ignoring velocity dependent friction calculation.
  • fUse3PointsArea: Approximate the convex hull area of contact using 3 points instead of 4 (the default value), it is less accurate but faster to calculate and maintain.
  • fUseSIMD: Use SIMD instructions (when available on the platform) for solving constraints.

TraversalMode


List of all available BVH traversal mode.

  • kStackless: Stackless traversal.
  • kCacheFriendly: Stackless and cache friendly.
  • kRecursive: Recursively traverse the BVH tree.

DebugDraw


Available flags for physics debugging and visualization.

  • fNoDeactivation: Disable deactivation.
  • fDrawPhysicBounds: Enable physics bounds debugging.
  • fDrawColliders: Draw physics colliders.
  • fDrawContactPoints: Draw contact points and their associated normal (runtime only).
  • fDrawNormals: Enable faces normal debugging; especially useful when using mesh types to ensure that all normals are actually pointing the right way.
  • fDrawCollisionBounds: Draw a rough representation of the internal bounds used by the physics engine to calculate collision.
  • fDrawCCD: Draw the swept sphere of each object that will be used for continuous collision detection.
  • fSelectedPhysicObjects: Only debug draw selected PhysicObject.
  • fDrawPhysicConstraints: Enable physic constraints debugging.
  • fDrawConstraint: Provides visual shape feedback to constraints.
  • fDrawConstraintLimits: Draw the constraint limits.
  • fDrawConstraintRelation: Draw a dashed line between constraints that are related.
  • fSelectedConstraints: Only debug draw constraints that are connected to selected PhysicObject.
  • fDrawSoftBody: Enable SoftBody debugging.
  • fDrawSoftNormals: Draw the soft body face normals.
  • fDrawSoftContactPoints: Only available at runtime; this option allows you to visually represent the contact point(s) of each node with the surface they collide with.
  • fDrawSoftLinks: Visually represent how the mesh faces are linked.
  • fDrawSoftNodeTree: Draw the soft body node tree.
  • fDrawSoftClusters: Only available when the SoftBody is using clusters; this option allows you to draw the clusters used internally by the engine.
  • fSelectedSoftBodies: Only debug draw the selected SoftBody.




NRG - API 2022.3.383570 - Thu Jul 28 2022
Copyright © 2022 nrgcore.com. All Rights Reserved. Terms of Service - Privacy Policy - EULA