|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Joints: what holds two 3D bodies to each other. More...
#include "./Physics3DBindings.hpp"#include "./Physics3DContext.hpp"#include <Jolt/Physics/Body/BodyLock.h>#include <Jolt/Physics/Collision/GroupFilter.h>#include <Jolt/Physics/Constraints/DistanceConstraint.h>#include <Jolt/Physics/Constraints/FixedConstraint.h>#include <Jolt/Physics/Constraints/HingeConstraint.h>#include <Jolt/Physics/Constraints/PointConstraint.h>#include <Jolt/Physics/Constraints/SliderConstraint.h>#include <Jolt/Physics/Constraints/SwingTwistConstraint.h>#include <Jolt/Physics/Constraints/SixDOFConstraint.h>#include <algorithm>#include <cmath>
Go to the source code of this file.
Classes | |
| struct | Context |
| Everything one world owns. Built by physics3d_init, torn down by shutdown. More... | |
Functions | |
| uint32_t | physics3d_addSwingTwistJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB, float px, float py, float pz, float ax, float ay, float az, float nx, float ny, float nz, float normalHalf, float planeHalf, float twistMin, float twistMax, int collideConnected) |
| Both frames coincide at creation, so limits are relative to the authored pose. | |
| uint32_t | physics3d_addSixDOFJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB, float px, float py, float pz, float ax, float ay, float az, float nx, float ny, float nz, int translationMotion, int rotationMotion, float lx, float ly, float lz, float hx, float hy, float hz, float rx, float ry, float rz, float sx, float sy, float sz, int collideConnected) |
| Axis motion is packed as two bits per axis: 0 locked, 1 limited, 2 free. | |
| void | physics3d_setAdvancedJointMotor (uint32_t entity, int enable, float vx, float vy, float vz, float wx, float wy, float wz, float maxForce, float maxTorque) |
| Live velocity/force changes do not rebuild the joint or reset its zero pose. | |
| uint32_t | physics3d_addPointJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB, float px, float py, float pz, int collideConnected) |
| A shared point, free to turn on all three axes — a chain link, a ragdoll limb. | |
| uint32_t | physics3d_addHingeJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB, float px, float py, float pz, float ax, float ay, float az, int enableLimit, float lowerAngle, float upperAngle, int enableMotor, float motorSpeed, float maxTorque, int collideConnected) |
| uint32_t | physics3d_addSliderJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB, float px, float py, float pz, float ax, float ay, float az, int enableLimit, float lower, float upper, int enableMotor, float motorSpeed, float maxForce, int collideConnected) |
| One axis of travel — a lift, a piston, a sliding door. | |
| uint32_t | physics3d_addDistanceJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB, float ax, float ay, float az, float bx, float by, float bz, float minLength, float maxLength, float frequency, float damping, int collideConnected) |
| uint32_t | physics3d_addFixedJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB, int collideConnected) |
| No freedom at all: the two move as one, until something breaks them apart. | |
| void | physics3d_removeJoint (uint32_t entity, uint32_t bodyA, uint32_t bodyB) |
| static void | wakeEnds (Constraint *constraint) |
| A joint changed under two sleeping bodies does nothing until they wake: they are woken. | |
| void | physics3d_setJointMotor (uint32_t entity, int enable, float speed) |
| Drive an existing hinge or slider from gameplay, without rebuilding the joint. | |
| void | physics3d_setJointLimits (uint32_t entity, int enable, float lower, float upper) |
| void | physics3d_setJointMotorLimit (uint32_t entity, float limit) |
| void | physics3d_setDistanceJoint (uint32_t entity, float minLength, float maxLength, float frequency, float damping) |
| int | physics3d_jointForce (uint32_t entity) |
| float | physics3d_jointValue (uint32_t entity) |
Joints: what holds two 3D bodies to each other.
A door, a rope, a lift, a ragdoll — none of them are a body and a shape, they are two bodies and a rule about how they may move relative to each other. Basic rules include a point they share, an axis they turn about, an axis they slide along, a distance they keep, and no freedom at all. Swing/twist and six-axis constraints add per-axis limits.
Anchors and axes arrive in WORLD space, taken at the moment the joint is made. That is also what sets the zero of every limit: both bodies are given the same reference axis, so "0" means the pose the scene was authored in and a door's limits read the way an author wrote them.
Definition in file Physics3DConstraints.cpp.
| uint32_t physics3d_addDistanceJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB, | ||
| float | ax, | ||
| float | ay, | ||
| float | az, | ||
| float | bx, | ||
| float | by, | ||
| float | bz, | ||
| float | minLength, | ||
| float | maxLength, | ||
| float | frequency, | ||
| float | damping, | ||
| int | collideConnected ) |
A distance kept between two points — a rope (max only), a rod (min = max), or a spring when a frequency is given.
Definition at line 359 of file Physics3DConstraints.cpp.
| uint32_t physics3d_addFixedJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB, | ||
| int | collideConnected ) |
No freedom at all: the two move as one, until something breaks them apart.
Definition at line 383 of file Physics3DConstraints.cpp.
| uint32_t physics3d_addHingeJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB, | ||
| float | px, | ||
| float | py, | ||
| float | pz, | ||
| float | ax, | ||
| float | ay, | ||
| float | az, | ||
| int | enableLimit, | ||
| float | lowerAngle, | ||
| float | upperAngle, | ||
| int | enableMotor, | ||
| float | motorSpeed, | ||
| float | maxTorque, | ||
| int | collideConnected ) |
One axis of rotation, optionally limited and optionally driven — a door, a lever, a wheel with a motor.
Definition at line 298 of file Physics3DConstraints.cpp.
| uint32_t physics3d_addPointJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB, | ||
| float | px, | ||
| float | py, | ||
| float | pz, | ||
| int | collideConnected ) |
A shared point, free to turn on all three axes — a chain link, a ragdoll limb.
Definition at line 284 of file Physics3DConstraints.cpp.
| uint32_t physics3d_addSixDOFJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB, | ||
| float | px, | ||
| float | py, | ||
| float | pz, | ||
| float | ax, | ||
| float | ay, | ||
| float | az, | ||
| float | nx, | ||
| float | ny, | ||
| float | nz, | ||
| int | translationMotion, | ||
| int | rotationMotion, | ||
| float | lx, | ||
| float | ly, | ||
| float | lz, | ||
| float | hx, | ||
| float | hy, | ||
| float | hz, | ||
| float | rx, | ||
| float | ry, | ||
| float | rz, | ||
| float | sx, | ||
| float | sy, | ||
| float | sz, | ||
| int | collideConnected ) |
Axis motion is packed as two bits per axis: 0 locked, 1 limited, 2 free.
Definition at line 218 of file Physics3DConstraints.cpp.
| uint32_t physics3d_addSliderJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB, | ||
| float | px, | ||
| float | py, | ||
| float | pz, | ||
| float | ax, | ||
| float | ay, | ||
| float | az, | ||
| int | enableLimit, | ||
| float | lower, | ||
| float | upper, | ||
| int | enableMotor, | ||
| float | motorSpeed, | ||
| float | maxForce, | ||
| int | collideConnected ) |
One axis of travel — a lift, a piston, a sliding door.
Definition at line 327 of file Physics3DConstraints.cpp.
| uint32_t physics3d_addSwingTwistJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB, | ||
| float | px, | ||
| float | py, | ||
| float | pz, | ||
| float | ax, | ||
| float | ay, | ||
| float | az, | ||
| float | nx, | ||
| float | ny, | ||
| float | nz, | ||
| float | normalHalf, | ||
| float | planeHalf, | ||
| float | twistMin, | ||
| float | twistMax, | ||
| int | collideConnected ) |
Both frames coincide at creation, so limits are relative to the authored pose.
Definition at line 190 of file Physics3DConstraints.cpp.
| int physics3d_jointForce | ( | uint32_t | entity | ) |
Definition at line 493 of file Physics3DConstraints.cpp.
| float physics3d_jointValue | ( | uint32_t | entity | ) |
What the joint is at right now — a hinge's angle, a slider's travel — so a game can watch a door swing without integrating it a second time.
Definition at line 550 of file Physics3DConstraints.cpp.
| void physics3d_removeJoint | ( | uint32_t | entity, |
| uint32_t | bodyA, | ||
| uint32_t | bodyB ) |
Definition at line 396 of file Physics3DConstraints.cpp.
| void physics3d_setAdvancedJointMotor | ( | uint32_t | entity, |
| int | enable, | ||
| float | vx, | ||
| float | vy, | ||
| float | vz, | ||
| float | wx, | ||
| float | wy, | ||
| float | wz, | ||
| float | maxForce, | ||
| float | maxTorque ) |
Live velocity/force changes do not rebuild the joint or reset its zero pose.
Definition at line 254 of file Physics3DConstraints.cpp.
| void physics3d_setDistanceJoint | ( | uint32_t | entity, |
| float | minLength, | ||
| float | maxLength, | ||
| float | frequency, | ||
| float | damping ) |
Definition at line 479 of file Physics3DConstraints.cpp.
| void physics3d_setJointLimits | ( | uint32_t | entity, |
| int | enable, | ||
| float | lower, | ||
| float | upper ) |
Definition at line 445 of file Physics3DConstraints.cpp.
| void physics3d_setJointMotor | ( | uint32_t | entity, |
| int | enable, | ||
| float | speed ) |
Drive an existing hinge or slider from gameplay, without rebuilding the joint.
Definition at line 421 of file Physics3DConstraints.cpp.
| void physics3d_setJointMotorLimit | ( | uint32_t | entity, |
| float | limit ) |
Definition at line 466 of file Physics3DConstraints.cpp.
|
static |
A joint changed under two sleeping bodies does nothing until they wake: they are woken.
Definition at line 411 of file Physics3DConstraints.cpp.
Referenced by physics3d_setDistanceJoint(), physics3d_setJointLimits(), and physics3d_setJointMotorLimit().