|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Characters and scene queries for the PhysX backend. More...
#include "./PhysXWorld.hpp"#include "../physics3d/Physics3DBindings.hpp"#include <algorithm>#include <limits>#include <cmath>
Go to the source code of this file.
Functions | |
| uint32_t | physics3d_addCharacter (uint32_t entity, float radius, float halfHeight, float px, float py, float pz, float maxSlope, float mass, uint32_t layer, float pushForce) |
| Registers a character: an upright capsule swept against the world. | |
| void | physics3d_removeCharacter (uint32_t characterId) |
| void | physics3d_moveCharacter (uint32_t characterId, float vx, float vy, float vz, float dt, float stepUp, float stepDown) |
| void | physics3d_setCharacterPosition (uint32_t characterId, float px, float py, float pz) |
| Puts a character somewhere, rather than moving it there. | |
| int | physics3d_overlapSphere (float px, float py, float pz, float radius, uint32_t layerMask) |
| Everything a sphere at this position overlaps. | |
| int | physics3d_overlapBox (float px, float py, float pz, float hx, float hy, float hz, uint32_t layerMask) |
| The same for a box, given its half-extents. | |
| int | physics3d_sphereCast (float px, float py, float pz, float radius, float dx, float dy, float dz, uint32_t layerMask) |
| int | physics3d_raycastAll (float ox, float oy, float oz, float dx, float dy, float dz, uint32_t layerMask, uint32_t maxHits) |
| int | physics3d_boxCast (float px, float py, float pz, float hx, float hy, float hz, float qx, float qy, float qz, float qw, float dx, float dy, float dz, uint32_t layerMask) |
| int | physics3d_capsuleCast (float px, float py, float pz, float radius, float halfHeight, float qx, float qy, float qz, float qw, float dx, float dy, float dz, uint32_t layerMask) |
| int | physics3d_raycast (float ox, float oy, float oz, float dx, float dy, float dz, uint32_t layerMask) |
| int | physics3d_raycastWith (float ox, float oy, float oz, float dx, float dy, float dz, uint32_t layerMask, uint32_t flags) |
| The world's nearest hit, or a character's when one is nearer and flags bit 0 asks for them. | |
Characters and scene queries for the PhysX backend.
A character is a PhysX capsule controller: swept, not solved, like Jolt's CharacterVirtual. The query layouts are the Jolt module's.
Definition in file PhysXQueries.cpp.
| uint32_t physics3d_addCharacter | ( | uint32_t | entity, |
| float | radius, | ||
| float | halfHeight, | ||
| float | px, | ||
| float | py, | ||
| float | pz, | ||
| float | maxSlope, | ||
| float | mass, | ||
| uint32_t | layer, | ||
| float | pushForce ) |
Registers a character: an upright capsule swept against the world.
| maxSlope | Steepest ground the character can stand on, in radians. |
Definition at line 259 of file PhysXQueries.cpp.
References esengine::physics3d_physx::defaultMaterial(), and esengine::physics3d_physx::KIND_CHARACTER.
| int physics3d_boxCast | ( | float | px, |
| float | py, | ||
| float | pz, | ||
| float | hx, | ||
| float | hy, | ||
| float | hz, | ||
| float | qx, | ||
| float | qy, | ||
| float | qz, | ||
| float | qw, | ||
| float | dx, | ||
| float | dy, | ||
| float | dz, | ||
| uint32_t | layerMask ) |
Definition at line 489 of file PhysXQueries.cpp.
References castShapeQuery(), and turnOf().
| int physics3d_capsuleCast | ( | float | px, |
| float | py, | ||
| float | pz, | ||
| float | radius, | ||
| float | halfHeight, | ||
| float | qx, | ||
| float | qy, | ||
| float | qz, | ||
| float | qw, | ||
| float | dx, | ||
| float | dy, | ||
| float | dz, | ||
| uint32_t | layerMask ) |
Definition at line 497 of file PhysXQueries.cpp.
References castShapeQuery(), physics3d_sphereCast(), and turnOf().
| void physics3d_moveCharacter | ( | uint32_t | characterId, |
| float | vx, | ||
| float | vy, | ||
| float | vz, | ||
| float | dt, | ||
| float | stepUp, | ||
| float | stepDown ) |
Definition at line 316 of file PhysXQueries.cpp.
References esengine::physics3d_physx::Character::controller, esengine::physics3d_physx::Character::grounded, esengine::physics3d_physx::Character::layer, noteCharacterMeetings(), esengine::physics3d::Layers::of(), and esengine::physics3d_physx::Character::verticalSpeed.
| int physics3d_overlapBox | ( | float | px, |
| float | py, | ||
| float | pz, | ||
| float | hx, | ||
| float | hy, | ||
| float | hz, | ||
| uint32_t | layerMask ) |
The same for a box, given its half-extents.
Definition at line 396 of file PhysXQueries.cpp.
| int physics3d_overlapSphere | ( | float | px, |
| float | py, | ||
| float | pz, | ||
| float | radius, | ||
| uint32_t | layerMask ) |
Everything a sphere at this position overlaps.
Writes (entity, px,py,pz) per hit into the query buffer and returns how many — the question a spawn point asks before it spawns.
Definition at line 390 of file PhysXQueries.cpp.
| int physics3d_raycast | ( | float | ox, |
| float | oy, | ||
| float | oz, | ||
| float | dx, | ||
| float | dy, | ||
| float | dz, | ||
| uint32_t | layerMask ) |
Nearest hit along the ray. Writes (entity, fraction, px,py,pz, nx,ny,nz) into the query buffer and returns 1; returns 0 and leaves it empty when nothing is hit.
Definition at line 510 of file PhysXQueries.cpp.
References physics3d_raycastWith().
| int physics3d_raycastAll | ( | float | ox, |
| float | oy, | ||
| float | oz, | ||
| float | dx, | ||
| float | dy, | ||
| float | dz, | ||
| uint32_t | layerMask, | ||
| uint32_t | maxHits ) |
Every body on a line, nearest first, at most maxHits of them: writes (entity, entry, exit, px,py,pz, nx,ny,nz) for each into the query buffer, where entry and exit are fractions of the line at which it goes into the body and out of it (1 where the line ends inside it), the point and normal where it goes in. Returns how many. What a shot that passes through thin cover needs: the second body, and how much of the first it crossed to get there.
Definition at line 445 of file PhysXQueries.cpp.
| int physics3d_raycastWith | ( | float | ox, |
| float | oy, | ||
| float | oz, | ||
| float | dx, | ||
| float | dy, | ||
| float | dz, | ||
| uint32_t | layerMask, | ||
| uint32_t | flags ) |
The world's nearest hit, or a character's when one is nearer and flags bit 0 asks for them.
physics3d_raycast with flags: bit 0 also meets characters (a shot, which must hit an enemy that walks). Plain physics3d_raycast stays blind to them: line of sight and a camera's boom ask about the world.
A CharacterVirtual is not a body, so the narrow phase cannot meet it; each capsule is cast against in its own space instead, which is what Jolt's own CharacterVirtual queries do. A ray that starts inside a capsule meets it at 0 — a shooter's own character is left out by its layer.
Definition at line 515 of file PhysXQueries.cpp.
References esengine::physics3d_physx::Character::controller, esengine::physics3d_physx::Character::entity, esengine::physics3d_physx::entityOf(), esengine::physics3d_physx::Character::layer, and physics3d_raycast().
Referenced by physics3d_raycast().
| void physics3d_removeCharacter | ( | uint32_t | characterId | ) |
Definition at line 307 of file PhysXQueries.cpp.
| void physics3d_setCharacterPosition | ( | uint32_t | characterId, |
| float | px, | ||
| float | py, | ||
| float | pz ) |
Puts a character somewhere, rather than moving it there.
The velocity goes with it. A CharacterVirtual carries its own vertical speed between steps, so a character teleported mid-fall would arrive still falling and drive itself through the floor it was placed on.
Definition at line 379 of file PhysXQueries.cpp.
| int physics3d_sphereCast | ( | float | px, |
| float | py, | ||
| float | pz, | ||
| float | radius, | ||
| float | dx, | ||
| float | dy, | ||
| float | dz, | ||
| uint32_t | layerMask ) |
Definition at line 402 of file PhysXQueries.cpp.
References castShapeQuery(), and esengine::physics3d_physx::entityOf().
Referenced by physics3d_capsuleCast().