23#include <Jolt/Core/Factory.h>
24#include <Jolt/Core/JobSystemSingleThreaded.h>
25#include <Jolt/Core/TempAllocator.h>
26#include <Jolt/Physics/PhysicsSystem.h>
27#include <Jolt/Physics/Constraints/TwoBodyConstraint.h>
28#include <Jolt/Physics/Character/CharacterVirtual.h>
32#include <unordered_map>
33#include <unordered_set>
37#include <emscripten/emscripten.h>
39#define EMSCRIPTEN_KEEPALIVE
47static constexpr JPH::uint
COUNT = 16;
50static constexpr JPH::ObjectLayer
of(JPH::uint layer,
bool moving) {
51 return static_cast<JPH::ObjectLayer
>((layer << 1) | (moving ? 1u : 0u));
53static constexpr JPH::uint
indexOf(JPH::ObjectLayer layer) {
return layer >> 1; }
54static constexpr bool isMoving(JPH::ObjectLayer layer) {
return (layer & 1u) != 0; }
59static constexpr JPH::BroadPhaseLayer
STATIC(0);
60static constexpr JPH::BroadPhaseLayer
MOVING(1);
61static constexpr JPH::uint
COUNT(2);
70 bool collide(JPH::uint a, JPH::uint b)
const {
72 return (
masks[a] & (1u << b)) != 0 && (
masks[b] & (1u << a)) != 0;
82 bool ShouldCollide(JPH::ObjectLayer a, JPH::ObjectLayer b)
const override {
94#if defined(JPH_EXTERNAL_PROFILE) || defined(JPH_PROFILE_ENABLED)
95 const char* GetBroadPhaseLayerName(JPH::BroadPhaseLayer layer)
const override {
103 bool ShouldCollide(JPH::ObjectLayer a, JPH::BroadPhaseLayer b)
const override {
112 JPH::TempAllocatorImpl*
temp =
nullptr;
113 JPH::JobSystemSingleThreaded*
jobs =
nullptr;
152 std::unordered_map<uint32_t, JPH::Ref<JPH::TwoBodyConstraint>>
constraints;
166 std::unordered_map<uint32_t, std::unique_ptr<JPH::CharacterVirtual>>
characters;
JPH::uint GetNumBroadPhaseLayers() const override
JPH::BroadPhaseLayer GetBroadPhaseLayer(JPH::ObjectLayer layer) const override
bool ShouldCollide(JPH::ObjectLayer a, JPH::ObjectLayer b) const override
bool ShouldCollide(JPH::ObjectLayer a, JPH::BroadPhaseLayer b) const override
static constexpr JPH::uint COUNT(2)
static constexpr JPH::BroadPhaseLayer STATIC(0)
static constexpr JPH::BroadPhaseLayer MOVING(1)
static constexpr JPH::ObjectLayer of(JPH::uint layer, bool moving)
static constexpr JPH::ObjectLayer OBJECT_LAYER_COUNT
static constexpr JPH::uint indexOf(JPH::ObjectLayer layer)
static constexpr bool isMoving(JPH::ObjectLayer layer)
static constexpr JPH::uint COUNT
LayerMatrix & layerMatrix()
Everything one world owns. Built by physics3d_init, torn down by shutdown.
std::unordered_map< uint32_t, uint32_t > entityOf
Body -> the entity that owns it, so a readback names who moved.
std::vector< float > contactEnterBuffer
JPH::JobSystemSingleThreaded * jobs
std::vector< float > contactEnterSpeedBuffer
JPH::PhysicsSystem * system
std::vector< float > contactExitBuffer
ObjectVsBroadPhaseLayerFilterImpl objectVsBroadPhase
std::vector< float > contactEnterMassBuffer
std::unordered_map< uint32_t, uint32_t > jointHolds
std::vector< float > sensorExitBuffer
std::vector< float > queryBuffer
The last query's hits, in the shape its getter documents.
std::unordered_map< uint32_t, uint32_t > jointGroupOf
JPH::CharacterVsCharacterCollisionSimple characterVsCharacter
std::vector< float > characterHitBuffer
std::vector< float > transformBuffer
Refilled every step: (entity, px,py,pz, qx,qy,qz,qw) per active body.
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.
BroadPhaseLayerInterfaceImpl broadPhaseLayers
std::unordered_map< uint32_t, JPH::Ref< JPH::TwoBodyConstraint > > constraints
std::vector< float > sensorEnterBuffer
std::unordered_set< uint32_t > sensorBodies
JPH::TempAllocatorImpl * temp
std::unordered_map< uint32_t, std::vector< uint32_t > > jointGroupMembers
std::unordered_map< uint32_t, std::vector< uint32_t > > characterTouching
ObjectLayerPairFilterImpl objectPairs
bool collide(JPH::uint a, JPH::uint b) const
JPH::uint32 masks[Layers::COUNT]