|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
#include "./PhysicsBindings.hpp"#include "./PhysicsContext.hpp"#include "./PhysicsTaskPool.hpp"#include "../../BoundarySpan.hpp"#include "../../../core/EntityPose2D.hpp"#include <algorithm>#include <cmath>
Go to the source code of this file.
Functions | |
| static bool | preSolveOneWayPlatform (b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Vec2 point, b2Vec2 normal, void *context) |
| void | physics_init (float gx, float gy, float timestep, int substeps, float contactHertz, float contactDampingRatio, float contactSpeed) |
| void | physics_setWorldConfig (int enableSleep, int enableContinuous, float restitutionThreshold, float maxLinearSpeed) |
| void | physics_shutdown () |
| void | physics_setOneWayPlatform (uint32_t entityId, float nx, float ny, int enable) |
| void | physics_setOneWayPlatformLocal (uint32_t entityId, float nx, float ny, int enable) |
| void | physics_createBody (uint32_t entityId, int bodyType, float x, float y, float angle, float gravityScale, float linearDamping, float angularDamping, int fixedRotation, int bullet) |
| void | physics_destroyBody (uint32_t entityId) |
| int | physics_hasBody (uint32_t entityId) |
| void | physics_setBodyEnabled (uint32_t entityId, int enabled) |
| void | physics_step (float dt) |
| void | physics_setBodyTransform (uint32_t entityId, float x, float y, float angle) |
| int | physics_setBodyTransforms (uintptr_t bufferPtr, int count, float ppu) |
| void | physics_setBodyTargetTransform (uint32_t entityId, float x, float y, float angle, float dt) |
| int | physics_getDynamicBodyCount () |
| int | physics_getBodyCount () |
| int | physics_getShapeCount () |
| int | physics_getJointCount () |
| int | physics_getTrackingRows () |
| uintptr_t | physics_getDynamicBodyTransforms () |
| static uint32_t | poseEntityAt (const std::vector< float > &buf, size_t offset) |
| static float | lerpAngleShortest (float a, float b, float t) |
| void | physics_capturePoses () |
| int | physics_getInterpolatedCount () |
| uintptr_t | physics_getInterpolatedTransforms (float alpha) |
| void | physics_collectEvents () |
| int | physics_getCollisionEnterCount () |
| uintptr_t | physics_getCollisionEnterBuffer () |
| int | physics_getHitEventCount () |
| uintptr_t | physics_getHitEventBuffer () |
| int | physics_getCollisionExitCount () |
| uintptr_t | physics_getCollisionExitBuffer () |
| int | physics_getSensorEnterCount () |
| uintptr_t | physics_getSensorEnterBuffer () |
| int | physics_getSensorExitCount () |
| uintptr_t | physics_getSensorExitBuffer () |
| void | physics_applyForce (uint32_t entityId, float forceX, float forceY) |
| void | physics_applyImpulse (uint32_t entityId, float impulseX, float impulseY) |
| void | physics_setLinearVelocity (uint32_t entityId, float vx, float vy) |
| uintptr_t | physics_getLinearVelocity (uint32_t entityId) |
| void | physics_setGravity (float gx, float gy) |
| uintptr_t | physics_getGravity () |
| void | physics_setAngularVelocity (uint32_t entityId, float omega) |
| float | physics_getAngularVelocity (uint32_t entityId) |
| void | physics_applyTorque (uint32_t entityId, float torque) |
| void | physics_applyAngularImpulse (uint32_t entityId, float impulse) |
| void | physics_updateBodyProperties (uint32_t entityId, int bodyType, float gravityScale, float linearDamping, float angularDamping, int fixedRotation, int bullet) |
| void | physics_setAwake (uint32_t entityId, int awake) |
| int | physics_isAwake (uint32_t entityId) |
| float | physics_getBodyMass (uint32_t entityId) |
| float | physics_getBodyInertia (uint32_t entityId) |
| uintptr_t | physics_getBodyCenterOfMass (uint32_t entityId) |
Variables | |
| static constexpr float | ONE_WAY_ALIGN_THRESHOLD = 0.95f |
|
static |
Shortest-arc angle interpolation (radians), matching the SDK's own lerpAngle.
Definition at line 379 of file PhysicsModuleEntry.cpp.
Referenced by physics_getInterpolatedTransforms().
| void physics_applyAngularImpulse | ( | uint32_t | entityId, |
| float | impulse ) |
Definition at line 721 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_applyForce | ( | uint32_t | entityId, |
| float | forceX, | ||
| float | forceY ) |
Definition at line 611 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_applyImpulse | ( | uint32_t | entityId, |
| float | impulseX, | ||
| float | impulseY ) |
Definition at line 621 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_applyTorque | ( | uint32_t | entityId, |
| float | torque ) |
Definition at line 713 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_capturePoses | ( | ) |
Promote the current snapshot to prev and refill it from the world. Called once per fixed step, after the step, so the pair always straddles one step.
Definition at line 393 of file PhysicsModuleEntry.cpp.
References g_ctx, and pushEntityBits().
| void physics_collectEvents | ( | ) |
Definition at line 475 of file PhysicsModuleEntry.cpp.
References entityFromShape(), g_ctx, and pushEntityBits().
| void physics_createBody | ( | uint32_t | entityId, |
| int | bodyType, | ||
| float | x, | ||
| float | y, | ||
| float | angle, | ||
| float | gravityScale, | ||
| float | linearDamping, | ||
| float | angularDamping, | ||
| int | fixedRotation, | ||
| int | bullet ) |
Definition at line 143 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_destroyBody | ( | uint32_t | entityId | ) |
Definition at line 175 of file PhysicsModuleEntry.cpp.
References g_ctx.
| float physics_getAngularVelocity | ( | uint32_t | entityId | ) |
Definition at line 703 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getBodyCenterOfMass | ( | uint32_t | entityId | ) |
Definition at line 800 of file PhysicsModuleEntry.cpp.
References findValidBody(), and g_massDataBuffer.
| int physics_getBodyCount | ( | ) |
Definition at line 315 of file PhysicsModuleEntry.cpp.
References g_ctx.
| float physics_getBodyInertia | ( | uint32_t | entityId | ) |
Definition at line 793 of file PhysicsModuleEntry.cpp.
References findValidBody().
| float physics_getBodyMass | ( | uint32_t | entityId | ) |
Definition at line 786 of file PhysicsModuleEntry.cpp.
References findValidBody().
| uintptr_t physics_getCollisionEnterBuffer | ( | ) |
Definition at line 564 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getCollisionEnterCount | ( | ) |
Definition at line 559 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getCollisionExitBuffer | ( | ) |
Definition at line 584 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getCollisionExitCount | ( | ) |
Definition at line 579 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getDynamicBodyCount | ( | ) |
Definition at line 307 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getDynamicBodyTransforms | ( | ) |
Definition at line 341 of file PhysicsModuleEntry.cpp.
References g_ctx, and pushEntityBits().
| uintptr_t physics_getGravity | ( | ) |
Definition at line 675 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getHitEventBuffer | ( | ) |
Definition at line 574 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getHitEventCount | ( | ) |
Definition at line 569 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getInterpolatedCount | ( | ) |
Definition at line 416 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getInterpolatedTransforms | ( | float | alpha | ) |
Interpolate the snapshot pair by alpha into a flat [entityBits, x, y, angle] buffer (physics space) and return it. With alpha = 1 this reproduces a direct post-step sync.
Definition at line 426 of file PhysicsModuleEntry.cpp.
References g_ctx, lerpAngleShortest(), and poseEntityAt().
| int physics_getJointCount | ( | ) |
Definition at line 327 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getLinearVelocity | ( | uint32_t | entityId | ) |
Definition at line 645 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getSensorEnterBuffer | ( | ) |
Definition at line 594 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getSensorEnterCount | ( | ) |
Definition at line 589 of file PhysicsModuleEntry.cpp.
References g_ctx.
| uintptr_t physics_getSensorExitBuffer | ( | ) |
Definition at line 604 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getSensorExitCount | ( | ) |
Definition at line 599 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getShapeCount | ( | ) |
Definition at line 320 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_getTrackingRows | ( | ) |
Rows in the side tables keyed by entity. They are invisible to gameplay and are exactly where a destroy path that forgets one map shows up.
Definition at line 334 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_hasBody | ( | uint32_t | entityId | ) |
Definition at line 201 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_init | ( | float | gx, |
| float | gy, | ||
| float | timestep, | ||
| int | substeps, | ||
| float | contactHertz, | ||
| float | contactDampingRatio, | ||
| float | contactSpeed ) |
Definition at line 64 of file PhysicsModuleEntry.cpp.
References g_ctx, and preSolveOneWayPlatform().
| int physics_isAwake | ( | uint32_t | entityId | ) |
Definition at line 776 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_setAngularVelocity | ( | uint32_t | entityId, |
| float | omega ) |
Definition at line 690 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_setAwake | ( | uint32_t | entityId, |
| int | awake ) |
Definition at line 768 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_setBodyEnabled | ( | uint32_t | entityId, |
| int | enabled ) |
Definition at line 209 of file PhysicsModuleEntry.cpp.
References findValidBody(), and g_ctx.
| void physics_setBodyTargetTransform | ( | uint32_t | entityId, |
| float | x, | ||
| float | y, | ||
| float | angle, | ||
| float | dt ) |
Definition at line 297 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_setBodyTransform | ( | uint32_t | entityId, |
| float | x, | ||
| float | y, | ||
| float | angle ) |
Definition at line 259 of file PhysicsModuleEntry.cpp.
References g_ctx.
| int physics_setBodyTransforms | ( | uintptr_t | bufferPtr, |
| int | count, | ||
| float | ppu ) |
Definition at line 268 of file PhysicsModuleEntry.cpp.
References esengine::boundarySpan(), and g_ctx.
| void physics_setGravity | ( | float | gx, |
| float | gy ) |
Definition at line 669 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_setLinearVelocity | ( | uint32_t | entityId, |
| float | vx, | ||
| float | vy ) |
Definition at line 631 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_setOneWayPlatform | ( | uint32_t | entityId, |
| float | nx, | ||
| float | ny, | ||
| int | enable ) |
Definition at line 113 of file PhysicsModuleEntry.cpp.
References g_ctx.
Referenced by physics_setOneWayPlatformLocal().
| void physics_setOneWayPlatformLocal | ( | uint32_t | entityId, |
| float | nx, | ||
| float | ny, | ||
| int | enable ) |
Definition at line 135 of file PhysicsModuleEntry.cpp.
References g_ctx, and physics_setOneWayPlatform().
| void physics_setWorldConfig | ( | int | enableSleep, |
| int | enableContinuous, | ||
| float | restitutionThreshold, | ||
| float | maxLinearSpeed ) |
Definition at line 91 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_shutdown | ( | ) |
Definition at line 105 of file PhysicsModuleEntry.cpp.
References g_ctx.
| void physics_step | ( | float | dt | ) |
Definition at line 233 of file PhysicsModuleEntry.cpp.
References g_ctx, and MAX_PHYSICS_STEPS_PER_FRAME.
| void physics_updateBodyProperties | ( | uint32_t | entityId, |
| int | bodyType, | ||
| float | gravityScale, | ||
| float | linearDamping, | ||
| float | angularDamping, | ||
| int | fixedRotation, | ||
| int | bullet ) |
Definition at line 731 of file PhysicsModuleEntry.cpp.
References g_ctx.
|
static |
The entity id packed into a flat pose buffer at float offset offset.
Definition at line 372 of file PhysicsModuleEntry.cpp.
Referenced by physics_getInterpolatedTransforms().
|
static |
Definition at line 32 of file PhysicsModuleEntry.cpp.
References entityFromShape(), g_ctx, and ONE_WAY_ALIGN_THRESHOLD.
Referenced by physics_init().
|
staticconstexpr |
Definition at line 25 of file PhysicsModuleEntry.cpp.
Referenced by preSolveOneWayPlatform().