Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Physics::Utils Namespace Reference

Namespaces

namespace  BroadPhaseLayers
namespace  Layers

Classes

class  BiMap
class  BPLayerInterfaceImpl
class  ContactCallback
class  ContactListenerImpl
 ContactListener implementation. More...
class  ObjectLayerPairFilterImpl
class  ObjectVsBroadPhaseLayerFilterImpl

Typedefs

using BaseCallback = FunctionUtils::BaseFunction<void, Engine::Core &, Engine::Entity &, Engine::Entity &>
 A utility class for handling contact callbacks in a physics engine.

Functions

JPH::Vec3 ToJoltVec3 (const glm::vec3 &v)
 Convert glm::vec3 to JPH::Vec3.
JPH::RVec3 ToJoltRVec3 (const glm::vec3 &v)
 Convert glm::vec3 to JPH::RVec3 (real vector, double precision).
JPH::Quat ToJoltQuat (const glm::quat &q)
 Convert glm::quat to JPH::Quat.
glm::vec3 FromJoltVec3 (const JPH::Vec3 &v)
 Convert JPH::Vec3 to glm::vec3.
glm::vec3 FromJoltRVec3 (const JPH::RVec3 &v)
 Convert JPH::RVec3 (real vector, double precision) to glm::vec3.
glm::quat FromJoltQuat (const JPH::Quat &q)
 Convert JPH::Quat to glm::quat.

Variables

static constexpr const uint32_t ENTITY_ID_MASK

Typedef Documentation

◆ BaseCallback

A utility class for handling contact callbacks in a physics engine.

Template Parameters
ComponentsThe components to check for in the entities involved in the contact.
Note
Callbacks will be called with the Core, as well as the two entities that collided.
The callback will be called once for each contact added.
The callback will be called only if the entities have the specified components.
If no components are specified, the callback will be called for all contacts.
If one component is specified, the callback will be called only if both entities have that component.
If two components are specified, the callback will be called only if one entity has the first component and the other entity has the second component.

Function Documentation

◆ FromJoltQuat()

glm::quat Physics::Utils::FromJoltQuat ( const JPH::Quat & q)
inline

Convert JPH::Quat to glm::quat.

◆ FromJoltRVec3()

glm::vec3 Physics::Utils::FromJoltRVec3 ( const JPH::RVec3 & v)
inline

Convert JPH::RVec3 (real vector, double precision) to glm::vec3.

Note
RVec3 is used for positions in Jolt to support large worlds. Conversion to float vec3 is safe for most game worlds.

◆ FromJoltVec3()

glm::vec3 Physics::Utils::FromJoltVec3 ( const JPH::Vec3 & v)
inline

Convert JPH::Vec3 to glm::vec3.

◆ ToJoltQuat()

JPH::Quat Physics::Utils::ToJoltQuat ( const glm::quat & q)
inline

Convert glm::quat to JPH::Quat.

◆ ToJoltRVec3()

JPH::RVec3 Physics::Utils::ToJoltRVec3 ( const glm::vec3 & v)
inline

Convert glm::vec3 to JPH::RVec3 (real vector, double precision).

Note
RVec3 is used by Jolt for constraint positions to support large worlds.

◆ ToJoltVec3()

JPH::Vec3 Physics::Utils::ToJoltVec3 ( const glm::vec3 & v)
inline

Convert glm::vec3 to JPH::Vec3.

Variable Documentation

◆ ENTITY_ID_MASK

const uint32_t Physics::Utils::ENTITY_ID_MASK
inlinestaticconstexpr
Initial value:
=
entt::entt_traits<uint32_t>::entity_mask
<< (sizeof(uint32_t) * 8 - std::popcount(entt::entt_traits<uint32_t>::entity_mask)) |
entt::entt_traits<uint32_t>::version_mask

EnTT divides the entity ID into two parts: the entity index and the version. The entity index is the index of the entity in the registry, and the version part is a counter that increments every time an entity with the same index is destroyed and recreated. When recreating an entity from an integer, we need to make sure that both parts are preserved.

With 32 bits the value of ENTITY_ID_MASK will be 0xFFFFFFFF.

Note: we have to shift the entity mask to the left by the number of bits it has, which means we have to compute the size of the type in bits (sizeof(type) * 8), substract the number of bits used by the entity mask (we get it using popcount) and then shift the entity mask to the left by that number of bits.