Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::physics3d::Context Struct Reference

Everything one world owns. Built by physics3d_init, torn down by shutdown. More...

#include <Physics3DContext.hpp>

Public Member Functions

bool isValid () const

Public Attributes

JPH::PhysicsSystem * system = nullptr
JPH::TempAllocatorImpl * temp = nullptr
JPH::JobSystemSingleThreaded * jobs = nullptr
JPH::Factory * factory = nullptr
BroadPhaseLayerInterfaceImpl broadPhaseLayers
ObjectVsBroadPhaseLayerFilterImpl objectVsBroadPhase
ObjectLayerPairFilterImpl objectPairs
std::unordered_map< uint32_t, uint32_t > entityOf
 Body -> the entity that owns it, so a readback names who moved.
std::vector< float > transformBuffer
 Refilled every step: (entity, px,py,pz, qx,qy,qz,qw) per active body.
std::vector< float > queryBuffer
 The last query's hits, in the shape its getter documents.
float solverStep = 1.0f / 60.0f
std::vector< float > contactEnterBuffer
std::vector< float > contactEnterSpeedBuffer
std::vector< float > contactEnterMassBuffer
std::vector< float > characterHitBuffer
bool characterHitsStale = false
std::vector< float > contactExitBuffer
std::vector< float > sensorEnterBuffer
std::vector< float > sensorExitBuffer
std::unordered_set< uint32_t > sensorBodies
std::unordered_map< uint32_t, JPH::Ref< JPH::TwoBodyConstraint > > constraints
std::unordered_map< uint32_t, uint32_t > jointGroupOf
std::unordered_map< uint32_t, std::vector< uint32_t > > jointGroupMembers
std::unordered_map< uint32_t, uint32_t > jointHolds
uint32_t nextJointGroup = 1
std::unordered_map< uint32_t, std::unique_ptr< JPH::CharacterVirtual > > characters
std::unordered_map< uint32_t, uint32_t > characterLayers
 A character is not a body, so its layer is not stored in one.
std::unordered_map< uint32_t, std::vector< uint32_t > > characterTouching
uint32_t nextCharacterId = 1
JPH::CharacterVsCharacterCollisionSimple characterVsCharacter

Detailed Description

Everything one world owns. Built by physics3d_init, torn down by shutdown.

Definition at line 110 of file Physics3DContext.hpp.

Member Function Documentation

◆ isValid()

bool esengine::physics3d::Context::isValid ( ) const
inline

Definition at line 177 of file Physics3DContext.hpp.

References system.

Member Data Documentation

◆ broadPhaseLayers

BroadPhaseLayerInterfaceImpl esengine::physics3d::Context::broadPhaseLayers

Definition at line 116 of file Physics3DContext.hpp.

◆ characterHitBuffer

std::vector<float> esengine::physics3d::Context::characterHitBuffer

What characters ran into, ten floats a meeting; read after the step, emptied by the next step's first move.

Definition at line 139 of file Physics3DContext.hpp.

◆ characterHitsStale

bool esengine::physics3d::Context::characterHitsStale = false

Definition at line 140 of file Physics3DContext.hpp.

◆ characterLayers

std::unordered_map<uint32_t, uint32_t> esengine::physics3d::Context::characterLayers

A character is not a body, so its layer is not stored in one.

Definition at line 168 of file Physics3DContext.hpp.

◆ characters

std::unordered_map<uint32_t, std::unique_ptr<JPH::CharacterVirtual> > esengine::physics3d::Context::characters

Characters are not bodies: a CharacterVirtual is swept against the world rather than solved in it, which is what lets it climb stairs and stay glued to a slope without inheriting momentum from whatever it stands on.

Definition at line 166 of file Physics3DContext.hpp.

◆ characterTouching

std::unordered_map<uint32_t, std::vector<uint32_t> > esengine::physics3d::Context::characterTouching

The bodies each character touched after its last move, so a meeting is told once, not every move it lasts.

Definition at line 170 of file Physics3DContext.hpp.

◆ characterVsCharacter

JPH::CharacterVsCharacterCollisionSimple esengine::physics3d::Context::characterVsCharacter

Characters are swept against the WORLD, and the world does not contain them: without this they walk through each other, which is the one pair of shapes a player notices passing through.

Definition at line 175 of file Physics3DContext.hpp.

◆ constraints

std::unordered_map<uint32_t, JPH::Ref<JPH::TwoBodyConstraint> > esengine::physics3d::Context::constraints

Joints, keyed by the entity whose component authored them — one per entity, the same ownership the 2D world uses.

Definition at line 152 of file Physics3DContext.hpp.

◆ contactEnterBuffer

std::vector<float> esengine::physics3d::Context::contactEnterBuffer

Refilled every step by the contact listener. Enter carries the geometry (entityA, entityB, nx,ny,nz, px,py,pz); exit only the pair, because at that moment Jolt has both bodies locked and one of them may already be gone.

Definition at line 133 of file Physics3DContext.hpp.

◆ contactEnterMassBuffer

std::vector<float> esengine::physics3d::Context::contactEnterMassBuffer

One meeting mass, in kilograms, for each contact in contactEnterBuffer.

Definition at line 137 of file Physics3DContext.hpp.

◆ contactEnterSpeedBuffer

std::vector<float> esengine::physics3d::Context::contactEnterSpeedBuffer

One closing speed for each contact in contactEnterBuffer.

Definition at line 135 of file Physics3DContext.hpp.

◆ contactExitBuffer

std::vector<float> esengine::physics3d::Context::contactExitBuffer

Definition at line 141 of file Physics3DContext.hpp.

◆ entityOf

std::unordered_map<uint32_t, uint32_t> esengine::physics3d::Context::entityOf

Body -> the entity that owns it, so a readback names who moved.

Definition at line 121 of file Physics3DContext.hpp.

◆ factory

JPH::Factory* esengine::physics3d::Context::factory = nullptr

Definition at line 114 of file Physics3DContext.hpp.

◆ jobs

JPH::JobSystemSingleThreaded* esengine::physics3d::Context::jobs = nullptr

Definition at line 113 of file Physics3DContext.hpp.

◆ jointGroupMembers

std::unordered_map<uint32_t, std::vector<uint32_t> > esengine::physics3d::Context::jointGroupMembers

Definition at line 157 of file Physics3DContext.hpp.

◆ jointGroupOf

std::unordered_map<uint32_t, uint32_t> esengine::physics3d::Context::jointGroupOf

Bodies a joint asked not to collide, in groups: Jolt filters per body, not per constraint, so the only way to say it is "these bodies are one assembly" — and joining two assemblies has to merge their members.

Definition at line 156 of file Physics3DContext.hpp.

◆ jointHolds

std::unordered_map<uint32_t, uint32_t> esengine::physics3d::Context::jointHolds

How many joints hold each body in its assembly, so a body leaves the group when the last joint holding it goes and can collide with its siblings again.

Definition at line 160 of file Physics3DContext.hpp.

◆ nextCharacterId

uint32_t esengine::physics3d::Context::nextCharacterId = 1

Definition at line 171 of file Physics3DContext.hpp.

◆ nextJointGroup

uint32_t esengine::physics3d::Context::nextJointGroup = 1

Definition at line 161 of file Physics3DContext.hpp.

◆ objectPairs

ObjectLayerPairFilterImpl esengine::physics3d::Context::objectPairs

Definition at line 118 of file Physics3DContext.hpp.

◆ objectVsBroadPhase

ObjectVsBroadPhaseLayerFilterImpl esengine::physics3d::Context::objectVsBroadPhase

Definition at line 117 of file Physics3DContext.hpp.

◆ queryBuffer

std::vector<float> esengine::physics3d::Context::queryBuffer

The last query's hits, in the shape its getter documents.

Definition at line 125 of file Physics3DContext.hpp.

◆ sensorBodies

std::unordered_set<uint32_t> esengine::physics3d::Context::sensorBodies

Which bodies are sensors, remembered at registration: OnContactRemoved cannot ask a body anything, so a sensor that stopped overlapping would otherwise be indistinguishable from a solid one.

Definition at line 148 of file Physics3DContext.hpp.

◆ sensorEnterBuffer

std::vector<float> esengine::physics3d::Context::sensorEnterBuffer

Definition at line 142 of file Physics3DContext.hpp.

◆ sensorExitBuffer

std::vector<float> esengine::physics3d::Context::sensorExitBuffer

Definition at line 143 of file Physics3DContext.hpp.

◆ solverStep

float esengine::physics3d::Context::solverStep = 1.0f / 60.0f

The length of the last solver step - a step's own, over its collision steps - which a constraint's impulse is divided by to give the force it held with.

Definition at line 128 of file Physics3DContext.hpp.

◆ system

JPH::PhysicsSystem* esengine::physics3d::Context::system = nullptr

Definition at line 111 of file Physics3DContext.hpp.

Referenced by isValid().

◆ temp

JPH::TempAllocatorImpl* esengine::physics3d::Context::temp = nullptr

Definition at line 112 of file Physics3DContext.hpp.

◆ transformBuffer

std::vector<float> esengine::physics3d::Context::transformBuffer

Refilled every step: (entity, px,py,pz, qx,qy,qz,qw) per active body.

Definition at line 123 of file Physics3DContext.hpp.


The documentation for this struct was generated from the following file: