Owning planar joint wrapper observing World-owned backend state. @ownership Caller/VM owns factory wrappers; World owns restored wrappers and all solver joints. @lifetime Body/world/source-joint destruction or restore invalidates observers; never retain a raw backend pointer. @thread All methods and destruction are simulation-owner-thread only, outside solver callbacks/step. @reentrancy No callbacks; no locks or reentrant world mutation. Inputs are borrowed only during calls. 更多...
#include <Joint2D.h>
Public 类型 | |
| using | Kind = Joint2DKind |
Public 成员函数 | |
| std::string | getKind () const |
| Joint kind string for script/debug. | |
| int | getBodyAId () const |
| Stable ID of attached body A, or -1 after invalidation. | |
| int | getBodyBId () const |
| Stable ID of attached body B, or -1 after invalidation. | |
| World * | getWorld () const |
| Owning world, or null after joint destruction. | |
| void | setCollideConnected (bool collide) |
| Enables or disables collision between the attached bodies. | |
| bool | getCollideConnected () const |
| Whether attached bodies may collide. | |
| void | setDistanceLength (float lengthPixels) |
| Changes distance-joint rest length in pixels. | |
| float | getDistanceLength () const |
| Distance-joint rest length in pixels. | |
| void | setDistanceSpring (float frequencyHz, float dampingRatio) |
| Configures distance spring frequency (Hz) and damping ratio. | |
| float | getDistanceFrequency () const |
| Distance spring frequency in Hertz. | |
| float | getDistanceDampingRatio () const |
| Distance spring damping ratio. | |
| void | setRevoluteLimits (bool enabled, float lower, float upper) |
| Configures revolute angular limits in radians. | |
| void | setRevoluteMotor (bool enabled, float speed, float maxTorque) |
| Configures the revolute motor in radians/second and newton-metres. | |
| float | getRevoluteAngle () const |
| Current revolute angle in radians. | |
| float | getRevoluteSpeed () const |
| Current revolute speed in radians/second. | |
| float | getRevoluteMotorTorque () const |
| Current revolute motor torque in newton-metres. | |
| void | setPrismaticLimits (bool enabled, float lowerPixels, float upperPixels) |
| Configures prismatic translation limits in pixels. | |
| void | setPrismaticMotor (bool enabled, float speedPixels, float maxForcePixels) |
| Configures a prismatic motor in pixels/second and pixel-force units. | |
| float | getPrismaticTranslation () const |
| Current prismatic translation in pixels. | |
| float | getPrismaticSpeed () const |
| Current prismatic speed in pixels/second. | |
| void | setWeldSpring (float frequencyHz, float dampingRatio) |
| Configures weld rotational spring frequency and damping. | |
| float | getWeldFrequency () const |
| Weld spring frequency in Hertz. | |
| float | getWeldDampingRatio () const |
| Weld spring damping ratio. | |
| void | setWheelSpring (float frequencyHz, float dampingRatio) |
| Configures wheel suspension spring. | |
| void | setWheelMotor (bool enabled, float speed, float maxTorque) |
| Configures wheel spin motor in radians/second and newton-metres. | |
| float | getWheelTranslation () const |
| Current wheel translation along the suspension axis in pixels. | |
| float | getWheelSpeed () const |
| Current wheel spin speed in radians/second. | |
| void | setMotorLinearOffset (float xPixels, float yPixels) |
| Sets motor-joint linear offset in pixels (bodyA frame). | |
| void | setMotorAngularOffset (float radians) |
| Sets motor-joint angular offset in radians. | |
| void | setMotorLimits (float maxForcePixels, float maxTorque) |
| Sets motor max force (pixel-force) and torque (N·m). | |
| float | getMotorLinearOffsetX () const |
| Motor linear offset X in pixels. | |
| float | getMotorLinearOffsetY () const |
| Motor linear offset Y in pixels. | |
| float | getMotorAngularOffset () const |
| Motor angular offset in radians. | |
| void | setGearRatio (float ratio) |
| Changes gear ratio. | |
| float | getGearRatio () const |
| Current gear ratio. | |
| Joint2D * | getGearJoint1 () const |
| First joint linked by a gear, or null. | |
| Joint2D * | getGearJoint2 () const |
| Second joint linked by a gear, or null. | |
| b2Joint * | raw () const |
| Internal borrowed solver joint; valid only while this wrapper is valid. | |
| void | destroy () |
| Legacy throwing destruction; delegates to destroyChecked(). | |
| ~Joint2D () | |
| Release this joint and dependent gears on the unlocked simulation owner thread. | |
| Joint2D (const Joint2D &)=delete | |
| Joint2D & | operator= (const Joint2D &)=delete |
| bool | isValid () const noexcept |
| True until wrapper release or a body/world/source-joint is destroyed. | |
| PhysicsJointHandle | runtimeHandle () const noexcept |
| Process-local generation handle; invalid after destruction, never serialized. | |
| int | getId () const noexcept |
| World-local persistent topology id, retained after invalidation; not a runtime handle. | |
| Joint2DKind | kind () const noexcept |
| Constraint kind, unchanged after invalidation. | |
| Result< void > | setMotor (bool enabled, float speed, float maximumForce) |
| Set revolute/prismatic/wheel motor; speed rad/s for revolute/wheel, m/s for prismatic. | |
| Result< void > | setLimits (bool enabled, float lower, float upper) |
| Set revolute angular or prismatic linear limits; lower <= upper. | |
| Result< Joint2DState > | sample (float dt) const |
| Read owning SI observation; dt must be the positive duration of the last completed solver step. | |
| Result< void > | destroyChecked () |
| Remove this constraint and dependent gears; repeat destruction is successful. | |
静态 Public 成员函数 | |
| static Result< std::unique_ptr< Joint2D > > | create (World &world, Body &a, Body &b, const Joint2DSettings &settings) |
| Create a constraint; rejects invalid input, foreign/dead bodies, Gear kind and locked worlds atomically. | |
| static Result< std::unique_ptr< Joint2D > > | createGear (World &world, Joint2D &first, Joint2D &second, float ratio) |
| Couple two revolute/prismatic joints in the same world with coordinate1 + ratio*coordinate2 constant. | |
友元 | |
| class | Body |
| class | Mechanism2D |
| class | World |
| struct | WorldSnapshotAccess |
| struct | PhysicsJointLink |
详细描述
Owning planar joint wrapper observing World-owned backend state. @ownership Caller/VM owns factory wrappers; World owns restored wrappers and all solver joints. @lifetime Body/world/source-joint destruction or restore invalidates observers; never retain a raw backend pointer. @thread All methods and destruction are simulation-owner-thread only, outside solver callbacks/step. @reentrancy No callbacks; no locks or reentrant world mutation. Inputs are borrowed only during calls.
Gear source identities use generation handles. Source-first destroys dependent gears; gear-first leaves sources intact. No state is reconstructed from pointer addresses.
成员类型定义说明
◆ Kind
构造及析构函数说明
◆ ~Joint2D()
| eve::physics::Joint2D::~Joint2D | ( | ) |
Release this joint and dependent gears on the unlocked simulation owner thread.
在文件 Joint2D.cpp 第 33 行定义.
◆ Joint2D()
|
delete |
成员函数说明
◆ create()
◆ createGear()
|
static |
Couple two revolute/prismatic joints in the same world with coordinate1 + ratio*coordinate2 constant.
- 参数
-
ratio Finite nonzero signed transmission ratio; mixed rotation/translation has length-dependent units.
- 返回
- Owning gear or structured failure. Source joints must have distinct dynamic body-B endpoints.
在文件 Joint2D.cpp 第 153 行定义.
引用了 a, b, d, handle, owned, ratio, raw, source , 以及 w.
被这些函数引用 eve::physics::World::newGearJoint().
◆ destroy()
| void eve::physics::Joint2D::destroy | ( | ) |
Legacy throwing destruction; delegates to destroyChecked().
在文件 Joint2D.cpp 第 26 行定义.
引用了 destroyChecked() , 以及 result.
◆ destroyChecked()
| Result< void > eve::physics::Joint2D::destroyChecked | ( | ) |
Remove this constraint and dependent gears; repeat destruction is successful.
- 返回
- PreconditionViolation when called during a locked solver step; no mutation then.
在文件 Joint2D.cpp 第 55 行定义.
被这些函数引用 destroy().
◆ getBodyAId()
| int eve::physics::Joint2D::getBodyAId | ( | ) | const |
Stable ID of attached body A, or -1 after invalidation.
在文件 Joint2D.cpp 第 47 行定义.
◆ getBodyBId()
| int eve::physics::Joint2D::getBodyBId | ( | ) | const |
Stable ID of attached body B, or -1 after invalidation.
在文件 Joint2D.cpp 第 50 行定义.
◆ getCollideConnected()
| bool eve::physics::Joint2D::getCollideConnected | ( | ) | const |
◆ getDistanceDampingRatio()
| float eve::physics::Joint2D::getDistanceDampingRatio | ( | ) | const |
Distance spring damping ratio.
在文件 Joint2D.cpp 第 93 行定义.
◆ getDistanceFrequency()
| float eve::physics::Joint2D::getDistanceFrequency | ( | ) | const |
Distance spring frequency in Hertz.
在文件 Joint2D.cpp 第 89 行定义.
◆ getDistanceLength()
| float eve::physics::Joint2D::getDistanceLength | ( | ) | const |
Distance-joint rest length in pixels.
在文件 Joint2D.cpp 第 77 行定义.
◆ getGearJoint1()
| Joint2D * eve::physics::Joint2D::getGearJoint1 | ( | ) | const |
First joint linked by a gear, or null.
- 返回
- Borrowed joint owned by World. @ownership World owns the joint; this wrapper only borrows it. @lifetime Valid until that joint or this gear is destroyed.
在文件 Joint2D.cpp 第 30 行定义.
◆ getGearJoint2()
| Joint2D * eve::physics::Joint2D::getGearJoint2 | ( | ) | const |
Second joint linked by a gear, or null.
- 返回
- Borrowed joint owned by World. @ownership World owns the joint; this wrapper only borrows it. @lifetime Valid until that joint or this gear is destroyed.
在文件 Joint2D.cpp 第 31 行定义.
◆ getGearRatio()
| float eve::physics::Joint2D::getGearRatio | ( | ) | const |
Current gear ratio.
在文件 Joint2D.cpp 第 240 行定义.
◆ getId()
|
inlinenoexcept |
World-local persistent topology id, retained after invalidation; not a runtime handle.
被这些函数引用 getBodyAId() , 以及 getBodyBId().
◆ getKind()
| std::string eve::physics::Joint2D::getKind | ( | ) | const |
Joint kind string for script/debug.
在文件 Joint2D.cpp 第 33 行定义.
◆ getMotorAngularOffset()
| float eve::physics::Joint2D::getMotorAngularOffset | ( | ) | const |
Motor angular offset in radians.
在文件 Joint2D.cpp 第 229 行定义.
◆ getMotorLinearOffsetX()
| float eve::physics::Joint2D::getMotorLinearOffsetX | ( | ) | const |
Motor linear offset X in pixels.
在文件 Joint2D.cpp 第 221 行定义.
引用了 eve::physics::World::toPixels() , 以及 x.
◆ getMotorLinearOffsetY()
| float eve::physics::Joint2D::getMotorLinearOffsetY | ( | ) | const |
Motor linear offset Y in pixels.
在文件 Joint2D.cpp 第 225 行定义.
引用了 eve::physics::World::toPixels() , 以及 y.
◆ getPrismaticSpeed()
| float eve::physics::Joint2D::getPrismaticSpeed | ( | ) | const |
Current prismatic speed in pixels/second.
在文件 Joint2D.cpp 第 153 行定义.
◆ getPrismaticTranslation()
| float eve::physics::Joint2D::getPrismaticTranslation | ( | ) | const |
Current prismatic translation in pixels.
在文件 Joint2D.cpp 第 149 行定义.
◆ getRevoluteAngle()
| float eve::physics::Joint2D::getRevoluteAngle | ( | ) | const |
Current revolute angle in radians.
在文件 Joint2D.cpp 第 117 行定义.
◆ getRevoluteMotorTorque()
| float eve::physics::Joint2D::getRevoluteMotorTorque | ( | ) | const |
Current revolute motor torque in newton-metres.
在文件 Joint2D.cpp 第 125 行定义.
◆ getRevoluteSpeed()
| float eve::physics::Joint2D::getRevoluteSpeed | ( | ) | const |
Current revolute speed in radians/second.
在文件 Joint2D.cpp 第 121 行定义.
◆ getWeldDampingRatio()
| float eve::physics::Joint2D::getWeldDampingRatio | ( | ) | const |
Weld spring damping ratio.
在文件 Joint2D.cpp 第 170 行定义.
◆ getWeldFrequency()
| float eve::physics::Joint2D::getWeldFrequency | ( | ) | const |
Weld spring frequency in Hertz.
在文件 Joint2D.cpp 第 166 行定义.
◆ getWheelSpeed()
| float eve::physics::Joint2D::getWheelSpeed | ( | ) | const |
Current wheel spin speed in radians/second.
在文件 Joint2D.cpp 第 196 行定义.
◆ getWheelTranslation()
| float eve::physics::Joint2D::getWheelTranslation | ( | ) | const |
Current wheel translation along the suspension axis in pixels.
在文件 Joint2D.cpp 第 192 行定义.
◆ getWorld()
|
inline |
Owning world, or null after joint destruction.
- 返回
- Borrowed world pointer. @ownership The returned world pointer is borrowed; wrapper ownership follows the factory contract. @lifetime Valid until World::destroy() or this joint's invalidation.
◆ isValid()
|
noexcept |
True until wrapper release or a body/world/source-joint is destroyed.
在文件 Joint2D.cpp 第 34 行定义.
被这些函数引用 eve::physics::PhysicsJointLink::fromJoint(), getBodyAId(), getBodyBId(), getCollideConnected() , 以及 setCollideConnected().
◆ kind()
|
inlinenoexcept |
◆ operator=()
◆ raw()
|
inline |
Internal borrowed solver joint; valid only while this wrapper is valid.
被这些函数引用 eve::physics::WorldSnapshotAccess::restoreJoints2D().
◆ runtimeHandle()
|
inlinenoexcept |
Process-local generation handle; invalid after destruction, never serialized.
被这些函数引用 eve::physics::World::forgetJoint().
◆ sample()
| Result< Joint2DState > eve::physics::Joint2D::sample | ( | float | dt | ) | const |
Read owning SI observation; dt must be the positive duration of the last completed solver step.
- 返回
- Solver observation or invalid input/stale diagnostic; never retains world references.
在文件 Joint2D.cpp 第 248 行定义.
引用了 dt, eve::physics::Joint2DState::kind, out , 以及 point.
◆ setCollideConnected()
| void eve::physics::Joint2D::setCollideConnected | ( | bool | collide | ) |
◆ setDistanceLength()
| void eve::physics::Joint2D::setDistanceLength | ( | float | lengthPixels | ) |
Changes distance-joint rest length in pixels.
在文件 Joint2D.cpp 第 72 行定义.
◆ setDistanceSpring()
| void eve::physics::Joint2D::setDistanceSpring | ( | float | frequencyHz, |
| float | dampingRatio | ||
| ) |
Configures distance spring frequency (Hz) and damping ratio.
在文件 Joint2D.cpp 第 81 行定义.
引用了 dampingRatio , 以及 distance.
◆ setGearRatio()
| void eve::physics::Joint2D::setGearRatio | ( | float | ratio | ) |
◆ setLimits()
| Result< void > eve::physics::Joint2D::setLimits | ( | bool | enabled, |
| float | lower, | ||
| float | upper | ||
| ) |
Set revolute angular or prismatic linear limits; lower <= upper.
- 返回
- Success or structured failure before mutation. Other kinds return Unsupported.
在文件 Joint2D.cpp 第 226 行定义.
引用了 enabled.
◆ setMotor()
| Result< void > eve::physics::Joint2D::setMotor | ( | bool | enabled, |
| float | speed, | ||
| float | maximumForce | ||
| ) |
Set revolute/prismatic/wheel motor; speed rad/s for revolute/wheel, m/s for prismatic.
- 参数
-
maximumForce Nonnegative maximum Nm for revolute/wheel, N for prismatic.
- 返回
- Success, StaleHandle, Unsupported kind or invalid input; failures do not mutate.
在文件 Joint2D.cpp 第 195 行定义.
引用了 enabled.
◆ setMotorAngularOffset()
| void eve::physics::Joint2D::setMotorAngularOffset | ( | float | radians | ) |
◆ setMotorLimits()
| void eve::physics::Joint2D::setMotorLimits | ( | float | maxForcePixels, |
| float | maxTorque | ||
| ) |
Sets motor max force (pixel-force) and torque (N·m).
在文件 Joint2D.cpp 第 213 行定义.
◆ setMotorLinearOffset()
| void eve::physics::Joint2D::setMotorLinearOffset | ( | float | xPixels, |
| float | yPixels | ||
| ) |
Sets motor-joint linear offset in pixels (bodyA frame).
在文件 Joint2D.cpp 第 201 行定义.
引用了 finite , 以及 eve::physics::World::toMeters().
◆ setPrismaticLimits()
| void eve::physics::Joint2D::setPrismaticLimits | ( | bool | enabled, |
| float | lowerPixels, | ||
| float | upperPixels | ||
| ) |
Configures prismatic translation limits in pixels.
在文件 Joint2D.cpp 第 130 行定义.
引用了 enabled, finite , 以及 eve::physics::World::toMeters().
◆ setPrismaticMotor()
| void eve::physics::Joint2D::setPrismaticMotor | ( | bool | enabled, |
| float | speedPixels, | ||
| float | maxForcePixels | ||
| ) |
Configures a prismatic motor in pixels/second and pixel-force units.
在文件 Joint2D.cpp 第 140 行定义.
引用了 enabled, finite , 以及 eve::physics::World::toMeters().
◆ setRevoluteLimits()
| void eve::physics::Joint2D::setRevoluteLimits | ( | bool | enabled, |
| float | lower, | ||
| float | upper | ||
| ) |
◆ setRevoluteMotor()
| void eve::physics::Joint2D::setRevoluteMotor | ( | bool | enabled, |
| float | speed, | ||
| float | maxTorque | ||
| ) |
Configures the revolute motor in radians/second and newton-metres.
在文件 Joint2D.cpp 第 108 行定义.
◆ setWeldSpring()
| void eve::physics::Joint2D::setWeldSpring | ( | float | frequencyHz, |
| float | dampingRatio | ||
| ) |
Configures weld rotational spring frequency and damping.
在文件 Joint2D.cpp 第 158 行定义.
引用了 dampingRatio.
◆ setWheelMotor()
| void eve::physics::Joint2D::setWheelMotor | ( | bool | enabled, |
| float | speed, | ||
| float | maxTorque | ||
| ) |
Configures wheel spin motor in radians/second and newton-metres.
在文件 Joint2D.cpp 第 183 行定义.
◆ setWheelSpring()
| void eve::physics::Joint2D::setWheelSpring | ( | float | frequencyHz, |
| float | dampingRatio | ||
| ) |
友元及相关函数文档
◆ Body
◆ Mechanism2D
|
friend |
◆ PhysicsJointLink
|
friend |
◆ World
◆ WorldSnapshotAccess
|
friend |
该类的文档由以下文件生成:
- src/modules/physics/Joint2D.h
- src/modules/physics/Joint2D.cpp
- src/modules/physics/mechanics/Joint2D.cpp