载入中...
搜索中...
未找到

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.

在文件 Joint2D.h 第 58 行定义.

成员类型定义说明

◆ Kind

在文件 Joint2D.h 第 60 行定义.

构造及析构函数说明

◆ ~Joint2D()

eve::physics::Joint2D::~Joint2D ( )

Release this joint and dependent gears on the unlocked simulation owner thread.

在文件 Joint2D.cpp 第 33 行定义.

◆ Joint2D()

eve::physics::Joint2D::Joint2D ( const Joint2D &  )
delete

成员函数说明

◆ create()

Result< std::unique_ptr< Joint2D > > eve::physics::Joint2D::create ( World &  world,
Body &  a,
Body &  b,
const Joint2DSettings &  settings 
)
static

Create a constraint; rejects invalid input, foreign/dead bodies, Gear kind and locked worlds atomically.

返回
Owning wrapper or InvalidArgument/PreconditionViolation; caller owns the successful value.

在文件 Joint2D.cpp 第 61 行定义.

引用了 a, axis, b, d, handle, owned, point, raw, s, valid , 以及 w.

◆ createGear()

Result< std::unique_ptr< Joint2D > > eve::physics::Joint2D::createGear ( World &  world,
Joint2D &  first,
Joint2D &  second,
float  ratio 
)
static

Couple two revolute/prismatic joints in the same world with coordinate1 + ratio*coordinate2 constant.

参数
ratioFinite 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 行定义.

引用了 getId() , 以及 isValid().

◆ getBodyBId()

int eve::physics::Joint2D::getBodyBId ( ) const

Stable ID of attached body B, or -1 after invalidation.

在文件 Joint2D.cpp 第 50 行定义.

引用了 getId() , 以及 isValid().

◆ getCollideConnected()

bool eve::physics::Joint2D::getCollideConnected ( ) const

Whether attached bodies may collide.

在文件 Joint2D.cpp 第 63 行定义.

引用了 isValid().

◆ 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 行定义.

引用了 eve::physics::World::toPixels().

◆ 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 行定义.

引用了 eve::physics::World::findJoint().

◆ 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 行定义.

引用了 eve::physics::World::findJoint().

◆ getGearRatio()

float eve::physics::Joint2D::getGearRatio ( ) const

Current gear ratio.

在文件 Joint2D.cpp 第 240 行定义.

◆ getId()

int eve::physics::Joint2D::getId ( ) const
inlinenoexcept

World-local persistent topology id, retained after invalidation; not a runtime handle.

在文件 Joint2D.h 第 184 行定义.

被这些函数引用 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 行定义.

引用了 eve::physics::World::toPixels().

◆ getPrismaticTranslation()

float eve::physics::Joint2D::getPrismaticTranslation ( ) const

Current prismatic translation in pixels.

在文件 Joint2D.cpp 第 149 行定义.

引用了 eve::physics::World::toPixels().

◆ 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 行定义.

引用了 eve::physics::World::toPixels().

◆ getWorld()

World * eve::physics::Joint2D::getWorld ( ) const
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.

在文件 Joint2D.h 第 73 行定义.

◆ isValid()

bool eve::physics::Joint2D::isValid ( ) const
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()

Joint2DKind eve::physics::Joint2D::kind ( ) const
inlinenoexcept

Constraint kind, unchanged after invalidation.

在文件 Joint2D.h 第 186 行定义.

◆ operator=()

Joint2D & eve::physics::Joint2D::operator= ( const Joint2D &  )
delete

◆ raw()

b2Joint * eve::physics::Joint2D::raw ( ) const
inline

Internal borrowed solver joint; valid only while this wrapper is valid.

在文件 Joint2D.h 第 160 行定义.

被这些函数引用 eve::physics::WorldSnapshotAccess::restoreJoints2D().

◆ runtimeHandle()

PhysicsJointHandle eve::physics::Joint2D::runtimeHandle ( ) const
inlinenoexcept

Process-local generation handle; invalid after destruction, never serialized.

在文件 Joint2D.h 第 182 行定义.

被这些函数引用 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)

Enables or disables collision between the attached bodies.

在文件 Joint2D.cpp 第 54 行定义.

引用了 isValid().

◆ setDistanceLength()

void eve::physics::Joint2D::setDistanceLength ( float  lengthPixels)

Changes distance-joint rest length in pixels.

在文件 Joint2D.cpp 第 72 行定义.

引用了 eve::physics::World::toMeters().

◆ 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)

Changes gear ratio.

在文件 Joint2D.cpp 第 234 行定义.

引用了 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.

参数
maximumForceNonnegative 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)

Sets motor-joint angular offset in radians.

在文件 Joint2D.cpp 第 208 行定义.

引用了 finite.

◆ setMotorLimits()

void eve::physics::Joint2D::setMotorLimits ( float  maxForcePixels,
float  maxTorque 
)

Sets motor max force (pixel-force) and torque (N·m).

在文件 Joint2D.cpp 第 213 行定义.

引用了 eve::physics::World::toMeters().

◆ 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 
)

Configures revolute angular limits in radians.

在文件 Joint2D.cpp 第 98 行定义.

引用了 enabled , 以及 finite.

◆ 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 行定义.

引用了 enabled , 以及 finite.

◆ 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 行定义.

引用了 enabled , 以及 finite.

◆ setWheelSpring()

void eve::physics::Joint2D::setWheelSpring ( float  frequencyHz,
float  dampingRatio 
)

Configures wheel suspension spring.

在文件 Joint2D.cpp 第 175 行定义.

引用了 dampingRatio.

友元及相关函数文档

◆ Body

friend class Body
friend

在文件 Joint2D.h 第 206 行定义.

◆ Mechanism2D

friend class Mechanism2D
friend

在文件 Joint2D.h 第 207 行定义.

◆ PhysicsJointLink

friend struct PhysicsJointLink
friend

在文件 Joint2D.h 第 211 行定义.

◆ World

friend class World
friend

在文件 Joint2D.h 第 209 行定义.

◆ WorldSnapshotAccess

friend struct WorldSnapshotAccess
friend

在文件 Joint2D.h 第 210 行定义.


该类的文档由以下文件生成: