25#include <PxPhysicsAPI.h>
29#include <unordered_map>
33#include <emscripten/emscripten.h>
35#define EMSCRIPTEN_KEEPALIVE
54 physx::PxRigidActor*
actor =
nullptr;
78 std::vector<const physx::PxRigidActor*>
touching;
79 std::unique_ptr<Body>
body;
87 physx::PxJoint*
joint =
nullptr;
94 physx::PxScene*
scene =
nullptr;
99 std::unordered_map<uint32_t, std::unique_ptr<Body>>
bodies;
102 std::unordered_map<uint32_t, std::unique_ptr<Character>>
characters;
105 std::unordered_map<uint32_t, Joint>
joints;
108 std::unordered_map<uint64_t, physx::PxMaterial*>
materials;
129 return (
masks[a] & (1u << b)) != 0 && (
masks[b] & (1u << a)) != 0;
132 auto found =
bodies.find(
id);
133 return found ==
bodies.end() ?
nullptr : found->second.get();
143inline uint32_t
entityOf(
const physx::PxActor* actor) {
144 if (actor ==
nullptr || actor->userData ==
nullptr)
return 0;
145 return static_cast<const Body*
>(actor->userData)->entity;
constexpr uint32_t LAYER_COUNT
Sixteen layers, the same number the Jolt backend and the 2D world name.
constexpr uint32_t KIND_CHARACTER
kKindWord bits.
PxMaterial * defaultMaterial()
Friction 0.6, no bounce: the default physics material.
uint32_t entityOf(const physx::PxActor *actor)
The entity an actor speaks for, or 0.
Context passed to every System::update call.
What the module knows about a body beyond what PhysX holds.
physx::PxRigidActor * actor
physx::PxVec3 kinematicVelocity
bool hasKinematicVelocity
physx::PxController * controller
std::unique_ptr< Body > body
std::vector< const physx::PxRigidActor * > touching
physx::PxVec3 groundNormal
float verticalSpeed
The vertical speed between moves; a controller does not fall on its own.
float maxForce
A slider's motor force, kept so turning the motor back on restores it.
physx::PxDefaultCpuDispatcher * dispatcher
std::vector< float > transformBuffer
physx::PxControllerManager * controllers
uint32_t masks[LAYER_COUNT]
std::vector< float > contactExitBuffer
bool collide(uint32_t a, uint32_t b) const
std::vector< float > contactEnterSpeedBuffer
std::vector< float > queryBuffer
std::vector< float > contactEnterBuffer
std::unordered_map< uint32_t, std::unique_ptr< Character > > characters
std::vector< float > sensorEnterBuffer
std::unordered_map< uint32_t, Joint > joints
std::vector< float > characterHitBuffer
std::unordered_map< uint64_t, physx::PxMaterial * > materials
std::vector< float > contactEnterMassBuffer
std::unordered_map< uint32_t, std::unique_ptr< Body > > bodies
std::vector< float > sensorExitBuffer