载入中...
搜索中...
未找到
eve::physics::Joint2D类 参考

Script-facing Box2D joint owned by a World. 更多...

#include <Joint2D.h>

Public 类型

enum class  Kind {
  Distance , Revolute , Prismatic , Weld ,
  Wheel , Motor , Gear
}
 Supported joint geometry. 更多...
 

Public 成员函数

 Joint2D (World *world, Body *bodyA, Body *bodyB, b2Joint *joint, PhysicsJointHandle runtimeHandle, Kind kind, int id)
 Internal wrapper constructor; use World::new*Joint.
 
 ~Joint2D ()
 
 Joint2D (const Joint2D &)=delete
 
Joint2D & operator= (const Joint2D &)=delete
 
int getId () const
 Stable world-local identifier.
 
PhysicsJointHandle runtimeHandle () const
 Process-local generation-qualified handle owned by World.
 
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.
 
void destroy ()
 Destroys the backend joint and invalidates this wrapper.
 
bool isValid () const
 Whether the backend joint still exists.
 
void invalidate ()
 Internal invalidation used by body/world destruction.
 
b2Joint * raw () const
 Internal raw Box2D joint.
 

友元

class Body
 
class World
 
class Mechanism2D
 

详细描述

Script-facing Box2D joint owned by a World.

Anchors, lengths and linear motor quantities use pixel space (same as Body). Angles and angular motors use radians.

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

成员枚举类型说明

◆ Kind

enum class eve::physics::Joint2D::Kind
strong

Supported joint geometry.

备注
Kind codes: 0 Distance, 1 Revolute, 2 Prismatic, 3 Weld, 4 Wheel, 5 Motor, 6 Gear.
枚举值
Distance 
Revolute 
Prismatic 
Weld 
Wheel 
Motor 
Gear 

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

构造及析构函数说明

◆ Joint2D() [1/2]

eve::physics::Joint2D::Joint2D ( World *  world,
Body *  bodyA,
Body *  bodyB,
b2Joint *  joint,
PhysicsJointHandle  runtimeHandle,
Kind  kind,
int  id 
)

Internal wrapper constructor; use World::new*Joint.

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

◆ ~Joint2D()

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

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

引用了 destroy().

◆ Joint2D() [2/2]

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

成员函数说明

◆ destroy()

void eve::physics::Joint2D::destroy ( )

Destroys the backend joint and invalidates this wrapper.

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

引用了 eve::physics::World::forgetJoint(), Gear, invalidate(), isValid() , 以及 eve::physics::World::raw().

被这些函数引用 ~Joint2D().

◆ getBodyAId()

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

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

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

引用了 eve::physics::Body::getId().

被这些函数引用 eve::physics::World::newGearJoint().

◆ getBodyBId()

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

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

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

引用了 eve::physics::Body::getId().

被这些函数引用 eve::physics::World::newGearJoint().

◆ getCollideConnected()

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

Whether attached bodies may collide.

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

引用了 isValid().

◆ getDistanceDampingRatio()

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

Distance spring damping ratio.

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

引用了 Distance.

◆ getDistanceFrequency()

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

Distance spring frequency in Hertz.

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

引用了 Distance.

◆ getDistanceLength()

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

Distance-joint rest length in pixels.

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

引用了 Distance , 以及 eve::physics::World::toPixels().

◆ getGearJoint1()

Joint2D * eve::physics::Joint2D::getGearJoint1 ( ) const
inline

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.h 第 129 行定义.

◆ getGearJoint2()

Joint2D * eve::physics::Joint2D::getGearJoint2 ( ) const
inline

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.h 第 136 行定义.

◆ getGearRatio()

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

Current gear ratio.

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

引用了 Gear.

◆ getId()

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

Stable world-local identifier.

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

◆ getKind()

std::string eve::physics::Joint2D::getKind ( ) const

Joint kind string for script/debug.

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

引用了 Distance, Gear, Motor, Prismatic, Revolute, Weld , 以及 Wheel.

被这些函数引用 eve::physics::World::newGearJoint().

◆ getMotorAngularOffset()

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

Motor angular offset in radians.

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

引用了 Motor.

◆ getMotorLinearOffsetX()

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

Motor linear offset X in pixels.

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

引用了 Motor, eve::physics::World::toPixels() , 以及 x.

◆ getMotorLinearOffsetY()

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

Motor linear offset Y in pixels.

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

引用了 Motor, eve::physics::World::toPixels() , 以及 y.

◆ getPrismaticSpeed()

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

Current prismatic speed in pixels/second.

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

引用了 Prismatic , 以及 eve::physics::World::toPixels().

◆ getPrismaticTranslation()

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

Current prismatic translation in pixels.

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

引用了 Prismatic , 以及 eve::physics::World::toPixels().

◆ getRevoluteAngle()

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

Current revolute angle in radians.

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

引用了 Revolute.

◆ getRevoluteMotorTorque()

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

Current revolute motor torque in newton-metres.

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

引用了 Revolute.

◆ getRevoluteSpeed()

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

Current revolute speed in radians/second.

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

引用了 Revolute.

◆ getWeldDampingRatio()

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

Weld spring damping ratio.

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

引用了 Weld.

◆ getWeldFrequency()

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

Weld spring frequency in Hertz.

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

引用了 Weld.

◆ getWheelSpeed()

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

Current wheel spin speed in radians/second.

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

引用了 Wheel.

◆ getWheelTranslation()

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

Current wheel translation along the suspension axis in pixels.

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

引用了 eve::physics::World::toPixels() , 以及 Wheel.

◆ getWorld()

World * eve::physics::Joint2D::getWorld ( ) const
inline

Owning world, or null after joint destruction.

返回
Borrowed world pointer. @ownership World owns this joint; the returned world pointer is borrowed. @lifetime Valid until World::destroy() or this joint's invalidation.

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

被这些函数引用 eve::physics::World::newGearJoint().

◆ invalidate()

void eve::physics::Joint2D::invalidate ( )

Internal invalidation used by body/world destruction.

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

引用了 eve::physics::World::forgetJoint() , 以及 eve::RuntimeHandle< PhysicsJointHandleTag >::invalid().

被这些函数引用 destroy().

◆ isValid()

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

Whether the backend joint still exists.

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

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

被这些函数引用 destroy(), getCollideConnected(), eve::physics::World::newGearJoint() , 以及 setCollideConnected().

◆ operator=()

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

◆ raw()

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

Internal raw Box2D joint.

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

被这些函数引用 eve::physics::World::newGearJoint().

◆ runtimeHandle()

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

Process-local generation-qualified handle owned by World.

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

被这些函数引用 eve::physics::World::forgetJoint().

◆ setCollideConnected()

void eve::physics::Joint2D::setCollideConnected ( bool  collide)

Enables or disables collision between the attached bodies.

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

引用了 isValid().

◆ setDistanceLength()

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

Changes distance-joint rest length in pixels.

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

引用了 Distance , 以及 eve::physics::World::toMeters().

◆ setDistanceSpring()

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

Configures distance spring frequency (Hz) and damping ratio.

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

引用了 Distance , 以及 distance.

◆ setGearRatio()

void eve::physics::Joint2D::setGearRatio ( float  ratio)

Changes gear ratio.

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

引用了 Gear.

◆ setMotorAngularOffset()

void eve::physics::Joint2D::setMotorAngularOffset ( float  radians)

Sets motor-joint angular offset in radians.

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

引用了 finite , 以及 Motor.

◆ setMotorLimits()

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

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

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

引用了 Motor , 以及 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 第 239 行定义.

引用了 finite, Motor , 以及 eve::physics::World::toMeters().

◆ setPrismaticLimits()

void eve::physics::Joint2D::setPrismaticLimits ( bool  enabled,
float  lowerPixels,
float  upperPixels 
)

Configures prismatic translation limits in pixels.

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

引用了 enabled, finite, Prismatic , 以及 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 第 178 行定义.

引用了 enabled, finite, Prismatic , 以及 eve::physics::World::toMeters().

◆ setRevoluteLimits()

void eve::physics::Joint2D::setRevoluteLimits ( bool  enabled,
float  lower,
float  upper 
)

Configures revolute angular limits in radians.

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

引用了 enabled, finite , 以及 Revolute.

◆ setRevoluteMotor()

void eve::physics::Joint2D::setRevoluteMotor ( bool  enabled,
float  speed,
float  maxTorque 
)

Configures the revolute motor in radians/second and newton-metres.

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

引用了 enabled, finite , 以及 Revolute.

◆ setWeldSpring()

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

Configures weld rotational spring frequency and damping.

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

引用了 Weld.

◆ setWheelMotor()

void eve::physics::Joint2D::setWheelMotor ( bool  enabled,
float  speed,
float  maxTorque 
)

Configures wheel spin motor in radians/second and newton-metres.

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

引用了 enabled, finite , 以及 Wheel.

◆ setWheelSpring()

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

Configures wheel suspension spring.

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

引用了 Wheel.

友元及相关函数文档

◆ Body

friend class Body
friend

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

◆ Mechanism2D

friend class Mechanism2D
friend

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

◆ World

friend class World
friend

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


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