Classes¶
Physics
Brief descriptions¶
Structures |
|
Classes |
|
Provides physics system functionality like creating a physical body or casting a ray. |
Detailed information¶
physics::ICorePhysics¶
engine/core/modules/physics/include/nau/physics/core_physics.h
-
struct ICorePhysics¶
Public Functions
-
virtual ~ICorePhysics() = default¶
-
virtual nau::Ptr<IPhysicsWorld> findPhysicsWorld(Uid worldUid) = 0¶
-
inline auto getDefaultPhysicsWorld()¶
-
virtual ~ICorePhysics() = default¶
physics::ICorePhysicsInternal¶
engine/core/modules/physics/include/nau/physics/internal/core_physics_internal.h
-
struct ICorePhysicsInternal¶
physics::IPhysicsWorld¶
engine/core/modules/physics/include/nau/physics/physics_world.h
-
class IPhysicsWorld : public virtual IRefCounted¶
Provides physics system functionality like creating a physical body or casting a ray.
Subclassed by nau::physics::jolt::JoltPhysicsWorld
Private Types
-
using Ptr = nau::Ptr<IPhysicsWorld>¶
Pointer type used to reference IPhysicsWorld objects.
Private Functions
-
virtual void tick(float dt) = 0¶
Advances physics simulation for a single frame.
- Parameters:
dt – [in] Delta time.
-
virtual nau::Ptr<IPhysicsBody> createBody(Uid originSceneObjectUid, const PhysicsBodyCreationData &creationData) = 0¶
Creates a physical body and places it in the physical world.
- Parameters:
originSceneObjectUid – [in] Scene object’s uid to attach the body to.
creationData – [in] Keeps physical properties of the body assigned on its creation
- Returns:
A pointer to the created physical body.
-
virtual void setChannelsCollidable(CollisionChannel channelA, CollisionChannel channelB, bool collidable = true) = 0¶
Allows or forbids contacts between to collision channels.
See CollisionChannel for more information
Note
Implementations should support commutativity, i.e. calling
setChannelsCollidable(a, b, true)
has to have similar effects to callingsetChannelsCollidable(b, a, true)
.- Parameters:
channelA, channelB – [in] Channels to modify.
collidable – [in] Indicates whether the contact between channelA and channelB should be allowed.
-
virtual void resetChannelsCollisionSettings() = 0¶
Clears all channels collision settings made by setChannelsCollidable(). Inter-channel collision settings of underlying physics system msut be reverted to the default state.
-
virtual void setContactListener(nau::Ptr<IPhysicsContactListener> listener) = 0¶
Assign a contact listener that is to receive messages about contacts between bodies in the physical world.
- Parameters:
listener – [in] A pointer to the object to use as a listener.
-
virtual IPhysicsMaterial::Ptr createMaterial(eastl::string_view name, eastl::optional<TFloat> friction = eastl::nullopt, eastl::optional<TFloat> restitution = eastl::nullopt)¶
Creates and registers a physical material.
- Parameters:
name – [in] Name to register the material under.
friction – [in] Degree of how the body resists being dragged. It has to be between 0.0 (no friction) and 1.0 (the body will stick to the surface and stay immobile). You can pass
eastl::nullopt
if you don’t want the material to override body default friction.restitution – [in] Degree of body tougheness on collision. It has to be between 0.0 (completely inelastic collision response) and 1.0 (completely elastic collision response). You can pass
eastl::nullopt
if you don’t want the material to override body default restitution.
- Returns:
A pointer to the created material.
-
virtual eastl::optional<RayCastResult> castRay(const nau::physics::RayCastQuery &query) const = 0¶
Allows to cast a ray between to points and check if it hits any physical bodies.
- Parameters:
query – [in] RayCasting properties.
- Returns:
Hit data or
eastl::nullopt
is no hit has occurred.
-
virtual async::Task<eastl::vector<RayCastResult>> castRaysAsync(eastl::vector<physics::RayCastQuery> queries) const = 0¶
-
inline async::Task<RayCastResult> castRayAsync(physics::RayCastQuery query) const¶
-
inline virtual void drawDebug(nau::DebugRenderSystem &dr)¶
-
virtual void setGravity(const nau::math::vec3 &gravity) = 0¶
-
virtual void syncSceneState() = 0¶
Friends
- friend class PhysicsWorldState
-
using Ptr = nau::Ptr<IPhysicsWorld>¶