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

Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity, raycasts, AABB queries and contact/impact events. 更多...

#include <World.h>

类

struct  ClothContact
 Result of a point probe: deepest non-sensor fixture within radius. Normal points from the shape toward the probed point (pixels). 更多...
 
struct  ContactEvent
 ContactEvent public API. 更多...
 
struct  ImpactEvent
 

Public 成员函数

 World (float gravityX, float gravityY, bool sleep, float meter, eve::PersistentId instanceId=eve::PersistentId::nil())
 Creates a physics world.
 
 ~World ()
 
 World (const World &)=delete
 
World & operator= (const World &)=delete
 
void update (float dt)
 Steps the simulation by dt seconds (5 velocity / 2 position iterations).
 
void updateFull (float dt, int velocityIterations, int positionIterations)
 Steps with explicit iteration counts.
 
eve::Result< void > step (const eve::SimulationStep &step, const SimulationSettings &settings={})
 Advances the domain with an injected deterministic simulation step.
 
SimulationObservation simulationObservation () const noexcept
 Snapshot of completed backend steps and logical simulation time.
 
SimulationBackendKind backendKind () const noexcept
 Selected CPU/GPU/mock backend family.
 
SimulationDeterminism backendDeterminism () const noexcept
 Replay/numeric guarantee declared by the selected backend.
 
eve::SimulationTick simulationTick () const noexcept
 Current deterministic tick; save data should persist this value.
 
PhysicsWorldHandle runtimeHandle () const noexcept
 Process-local identity used by PhysicsLink; invalid after destruction.
 
std::weak_ptr< const void > lifetimeToken () const noexcept
 Weak lifetime token for guarded cross-domain world observers.
 
eve::PersistentId persistentId () const noexcept
 Stable non-nil identity written to snapshot envelopes.
 
bool usedBackendFallback () const noexcept
 Whether optional accelerator selection fell back to CPU.
 
eve::Status backendSelectionStatus () const
 Returns the selection outcome, including an absent-capability warning.
 
eve::Result< eve::SnapshotEnvelope > snapshot (const eve::SnapshotHashProvider &hashProvider) const
 Captures a versioned, integrity-checked world snapshot.
 
eve::Result< void > restore (const eve::SnapshotEnvelope &snapshot, const eve::SnapshotHashProvider &hashProvider)
 Restores a verified snapshot without exposing partial state.
 
void setGravity (float gx, float gy)
 Sets the world gravity vector in pixels/s^2.
 
float getGravityX () const
 
float getGravityY () const
 
void setMeter (float pixelsPerMeter)
 Changes the pixels-per-meter conversion.
 
float getMeter () const
 
Body * newBody (const std::string &bodyType, float x, float y)
 Creates a body in pixel-space units.
 
Body * findBody (PhysicsBodyHandle handle) const
 Resolves a live body handle; returns null for a stale or foreign handle.
 
Body * findBodyById (int bodyId) const
 Resolves a live body by its world-local stable event/query id.
 
Joint2D * findJoint (PhysicsJointHandle handle) const
 Resolves a live joint handle; returns null when stale or foreign.
 
Joint2D * newDistanceJoint (Body *bodyA, Body *bodyB, float anchorAX, float anchorAY, float anchorBX, float anchorBY, float lengthPixels, bool collideConnected=false)
 Connects two pixel-space anchors with a distance constraint.
 
Joint2D * newRevoluteJoint (Body *bodyA, Body *bodyB, float anchorX, float anchorY, bool collideConnected=false)
 Creates a revolute hinge at a shared pixel-space anchor.
 
Joint2D * newPrismaticJoint (Body *bodyA, Body *bodyB, float anchorX, float anchorY, float axisX, float axisY, bool collideConnected=false)
 Creates a prismatic slider along a pixel-space axis.
 
Joint2D * newWeldJoint (Body *bodyA, Body *bodyB, float anchorX, float anchorY, bool collideConnected=false)
 Welds two bodies at a shared pixel-space anchor.
 
Joint2D * newWheelJoint (Body *bodyA, Body *bodyB, float anchorX, float anchorY, float axisX, float axisY, bool collideConnected=false)
 Creates a wheel joint with a pixel-space suspension axis.
 
Joint2D * newMotorJoint (Body *bodyA, Body *bodyB, bool collideConnected=false)
 Creates a motor joint that drives relative pose between bodies.
 
Joint2D * newGearJoint (Joint2D *joint1, Joint2D *joint2, float ratio)
 Creates a gear joint that couples two revolute or prismatic joints.
 
Mechanism2D * newShaft (Body *support, Body *rotor, float anchorX, float anchorY, bool collideConnected=false)
 Builds a shaft (support↔rotor revolute) with optional drive motor helpers.
 
Mechanism2D * newRatchet (Body *frame, Body *wheel, float anchorX, float anchorY, int direction, float engagementTorque, bool collideConnected=false)
 Builds a one-way ratchet around a revolute hinge.
 
Mechanism2D * newCrankSlider (Body *frame, Body *crank, Body *rod, Body *slider, float crankAnchorX, float crankAnchorY, float crankPinX, float crankPinY, float sliderPinX, float sliderPinY, float slideAxisX, float slideAxisY, bool collideConnected=false)
 Builds a planar crank-slider from frame, crank, connecting rod and slider bodies.
 
void destroyBody (Body *body)
 Destroys a body (null is ignored).
 
void destroy ()
 Destroys the underlying Box2D world and resets event buffers.
 
bool isValid () const
 True while the underlying Box2D world is alive.
 
bool pointProbe (float x, float y, float radius, ClothContact *out) const
 Probe the deepest non-sensor fixture within radius of a pixel point. Returns false when nothing is hit. Used by Cloth for particle-vs-body collision.
 
void drawDebug (graphics::Graphics *gfx)
 Optional: draw fixture AABBs via Graphics::drawSolidRect.
 
int rayCast (float x1, float y1, float x2, float y2)
 Closest raycast in pixel space from (x1,y1) to (x2,y2). Returns hit body id, or -1. Read hit details via getRayHit*.
 
bool hasRayHit () const
 
int getRayHitBodyId () const
 
float getRayHitX () const
 
float getRayHitY () const
 
float getRayHitNormalX () const
 
float getRayHitNormalY () const
 
float getRayHitFraction () const
 Fraction along the segment [0,1] of the closest hit.
 
int queryAABB (float x, float y, float w, float h)
 Query fixtures overlapping an axis-aligned box in pixel space (x,y,w,h). Returns match count; read ids with getQueryBodyId(i).
 
int getQueryCount () const
 
int getQueryBodyId (int index) const
 
int getBeginContactCount () const
 
int getBeginContactBodyAId (int index) const
 
int getBeginContactBodyBId (int index) const
 
std::string getBeginContactFixtureATag (int index) const
 
std::string getBeginContactFixtureBTag (int index) const
 
int getEndContactCount () const
 
int getEndContactBodyAId (int index) const
 
int getEndContactBodyBId (int index) const
 
std::string getEndContactFixtureATag (int index) const
 
std::string getEndContactFixtureBTag (int index) const
 
int getImpactCount () const
 
int getImpactBodyAId (int index) const
 
int getImpactBodyBId (int index) const
 
std::string getImpactFixtureATag (int index) const
 
std::string getImpactFixtureBTag (int index) const
 
float getImpactPointX (int index) const
 
float getImpactPointY (int index) const
 
float getImpactNormalX (int index) const
 
float getImpactNormalY (int index) const
 
float getImpactRelativeNormalSpeed (int index) const
 
float getImpactNormalImpulse (int index) const
 
float getImpactTangentImpulse (int index) const
 
void clearContactEvents ()
 Clears collected begin/end contact and impact event buffers.
 
float toMeters (float pixels) const
 Converts a pixel-space length to meters.
 
float toPixels (float meters) const
 Converts a meter-space length to pixels.
 
b2World * raw ()
 Exposes the underlying Box2D world for tightly-scoped backend integration.
 
const b2World * raw () const
 Exposes the underlying Box2D world for read-only backend integration.
 
void onBeginContact (b2Contact *contact)
 
void onEndContact (b2Contact *contact)
 
void onPreSolve (b2Contact *contact, const b2Manifold *oldManifold)
 
void onPostSolve (b2Contact *contact, const b2ContactImpulse *impulse)
 
void forgetBody (Body *body)
 
void forgetFixture (Fixture *fixture)
 
void forgetJoint (Joint2D *joint)
 Internal: removes a joint wrapper from ownership bookkeeping.
 
void forgetMechanism (Mechanism2D *mechanism)
 Internal: removes a mechanism wrapper from ownership bookkeeping.
 
int nextBodyId ()
 
PhysicsBodyHandle nextBodyRuntimeHandle ()
 
PhysicsJointHandle nextJointRuntimeHandle ()
 Internal: next generation-qualified joint handle.
 
int nextJointId ()
 Internal: next stable joint id.
 
int nextMechanismId ()
 Internal: next stable mechanism id.
 

友元

struct WorldSnapshotAccess
 
class Body
 
class Fixture
 
class Joint2D
 
class Mechanism2D
 

详细描述

Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity, raycasts, AABB queries and contact/impact events.

在文件 World.h 第 41 行定义.

构造及析构函数说明

◆ World() [1/2]

eve::physics::World::World ( float  gravityX,
float  gravityY,
bool  sleep,
float  meter,
eve::PersistentId  instanceId = eve::PersistentId::nil() 
)

Creates a physics world.

参数
gravityX/gravityYGravity vector in pixels/s^2.
sleepWhether bodies may sleep when idle.
meterPixels per meter conversion factor.
instanceIdStable save/network identity; nil creates a process-local generated identity.

在文件 World.cpp 第 217 行定义.

引用了 eve::physics::detail::allocatePhysicsWorldHandle(), eve::detail::Id128< Tag >::isNil(), eve::physics::detail::makePhysicsWorldPersistentId(), status, toMeters() , 以及 eve::physics::World2D.

◆ ~World()

eve::physics::World::~World ( )

在文件 World.cpp 第 238 行定义.

引用了 destroy().

◆ World() [2/2]

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

成员函数说明

◆ backendDeterminism()

SimulationDeterminism eve::physics::World::backendDeterminism ( ) const
noexcept

Replay/numeric guarantee declared by the selected backend.

在文件 World.cpp 第 393 行定义.

引用了 eve::physics::ToleranceBounded.

◆ backendKind()

SimulationBackendKind eve::physics::World::backendKind ( ) const
noexcept

Selected CPU/GPU/mock backend family.

在文件 World.cpp 第 389 行定义.

引用了 eve::physics::Cpu.

◆ backendSelectionStatus()

eve::Status eve::physics::World::backendSelectionStatus ( ) const

Returns the selection outcome, including an absent-capability warning.

返回
A copy safe for logging or policy inspection.

在文件 World.cpp 第 397 行定义.

◆ clearContactEvents()

void eve::physics::World::clearContactEvents ( )

Clears collected begin/end contact and impact event buffers.

在文件 World.cpp 第 643 行定义.

被这些函数引用 destroy() , 以及 restore().

◆ destroy()

void eve::physics::World::destroy ( )

Destroys the underlying Box2D world and resets event buffers.

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

引用了 b, clearContactEvents(), f, fixtures , 以及 eve::RuntimeHandle< PhysicsWorldHandleTag >::invalid().

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

◆ destroyBody()

void eve::physics::World::destroyBody ( Body *  body)

Destroys a body (null is ignored).

在文件 World.cpp 第 462 行定义.

引用了 body , 以及 eve::physics::Body::destroy().

◆ drawDebug()

void eve::physics::World::drawDebug ( graphics::Graphics *  gfx)

Optional: draw fixture AABBs via Graphics::drawSolidRect.

在文件 WorldDebugDraw.cpp 第 117 行定义.

引用了 binding, draw, eve::graphics::IGraphics2D::drawPrimitiveCanvas(), getMeter(), isValid(), raw() , 以及 world.

◆ findBody()

Body * eve::physics::World::findBody ( PhysicsBodyHandle  handle) const

Resolves a live body handle; returns null for a stale or foreign handle.

在文件 World.cpp 第 446 行定义.

引用了 body, handle , 以及 isValid().

◆ findBodyById()

Body * eve::physics::World::findBodyById ( int  bodyId) const

Resolves a live body by its world-local stable event/query id.

在文件 World.cpp 第 454 行定义.

引用了 body , 以及 isValid().

被这些函数引用 newGearJoint().

◆ findJoint()

Joint2D * eve::physics::World::findJoint ( PhysicsJointHandle  handle) const

Resolves a live joint handle; returns null when stale or foreign.

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

引用了 found, handle , 以及 isValid().

◆ forgetBody()

void eve::physics::World::forgetBody ( Body *  body)

在文件 World.cpp 第 467 行定义.

引用了 body , 以及 id.

被这些函数引用 eve::physics::Body::destroy() , 以及 eve::physics::Body::~Body().

◆ forgetFixture()

◆ forgetJoint()

void eve::physics::World::forgetJoint ( Joint2D *  joint)

Internal: removes a joint wrapper from ownership bookkeeping.

在文件 WorldJoints2D.cpp 第 45 行定义.

引用了 eve::RuntimeHandle< Tag >::isValid() , 以及 eve::physics::Joint2D::runtimeHandle().

被这些函数引用 eve::physics::Joint2D::destroy() , 以及 eve::physics::Joint2D::invalidate().

◆ forgetMechanism()

void eve::physics::World::forgetMechanism ( Mechanism2D *  mechanism)

Internal: removes a mechanism wrapper from ownership bookkeeping.

在文件 WorldJoints2D.cpp 第 57 行定义.

◆ getBeginContactBodyAId()

int eve::physics::World::getBeginContactBodyAId ( int  index) const

在文件 World.cpp 第 585 行定义.

引用了 index.

◆ getBeginContactBodyBId()

int eve::physics::World::getBeginContactBodyBId ( int  index) const

在文件 World.cpp 第 588 行定义.

引用了 index.

◆ getBeginContactCount()

int eve::physics::World::getBeginContactCount ( ) const
inline

在文件 World.h 第 339 行定义.

◆ getBeginContactFixtureATag()

std::string eve::physics::World::getBeginContactFixtureATag ( int  index) const

在文件 World.cpp 第 591 行定义.

引用了 index.

◆ getBeginContactFixtureBTag()

std::string eve::physics::World::getBeginContactFixtureBTag ( int  index) const

在文件 World.cpp 第 594 行定义.

引用了 index.

◆ getEndContactBodyAId()

int eve::physics::World::getEndContactBodyAId ( int  index) const

在文件 World.cpp 第 597 行定义.

引用了 index.

◆ getEndContactBodyBId()

int eve::physics::World::getEndContactBodyBId ( int  index) const

在文件 World.cpp 第 600 行定义.

引用了 index.

◆ getEndContactCount()

int eve::physics::World::getEndContactCount ( ) const
inline

在文件 World.h 第 344 行定义.

◆ getEndContactFixtureATag()

std::string eve::physics::World::getEndContactFixtureATag ( int  index) const

在文件 World.cpp 第 603 行定义.

引用了 index.

◆ getEndContactFixtureBTag()

std::string eve::physics::World::getEndContactFixtureBTag ( int  index) const

在文件 World.cpp 第 606 行定义.

引用了 index.

◆ getGravityX()

float eve::physics::World::getGravityX ( ) const

在文件 World.cpp 第 404 行定义.

引用了 toPixels().

◆ getGravityY()

float eve::physics::World::getGravityY ( ) const

在文件 World.cpp 第 409 行定义.

引用了 toPixels().

◆ getImpactBodyAId()

int eve::physics::World::getImpactBodyAId ( int  index) const

在文件 World.cpp 第 609 行定义.

引用了 index.

◆ getImpactBodyBId()

int eve::physics::World::getImpactBodyBId ( int  index) const

在文件 World.cpp 第 612 行定义.

引用了 index.

◆ getImpactCount()

int eve::physics::World::getImpactCount ( ) const
inline

在文件 World.h 第 350 行定义.

◆ getImpactFixtureATag()

std::string eve::physics::World::getImpactFixtureATag ( int  index) const

在文件 World.cpp 第 615 行定义.

引用了 index.

◆ getImpactFixtureBTag()

std::string eve::physics::World::getImpactFixtureBTag ( int  index) const

在文件 World.cpp 第 618 行定义.

引用了 index.

◆ getImpactNormalImpulse()

float eve::physics::World::getImpactNormalImpulse ( int  index) const

在文件 World.cpp 第 636 行定义.

引用了 index.

◆ getImpactNormalX()

float eve::physics::World::getImpactNormalX ( int  index) const

在文件 World.cpp 第 627 行定义.

引用了 index.

◆ getImpactNormalY()

float eve::physics::World::getImpactNormalY ( int  index) const

在文件 World.cpp 第 630 行定义.

引用了 index.

◆ getImpactPointX()

float eve::physics::World::getImpactPointX ( int  index) const

在文件 World.cpp 第 621 行定义.

引用了 index.

◆ getImpactPointY()

float eve::physics::World::getImpactPointY ( int  index) const

在文件 World.cpp 第 624 行定义.

引用了 index.

◆ getImpactRelativeNormalSpeed()

float eve::physics::World::getImpactRelativeNormalSpeed ( int  index) const

在文件 World.cpp 第 633 行定义.

引用了 index.

◆ getImpactTangentImpulse()

float eve::physics::World::getImpactTangentImpulse ( int  index) const

在文件 World.cpp 第 639 行定义.

引用了 index.

◆ getMeter()

float eve::physics::World::getMeter ( ) const
inline

在文件 World.h 第 161 行定义.

被这些函数引用 drawDebug().

◆ getQueryBodyId()

int eve::physics::World::getQueryBodyId ( int  index) const

在文件 World.cpp 第 726 行定义.

引用了 index.

◆ getQueryCount()

int eve::physics::World::getQueryCount ( ) const
inline

在文件 World.h 第 336 行定义.

◆ getRayHitBodyId()

int eve::physics::World::getRayHitBodyId ( ) const
inline

在文件 World.h 第 323 行定义.

◆ getRayHitFraction()

float eve::physics::World::getRayHitFraction ( ) const
inline

Fraction along the segment [0,1] of the closest hit.

在文件 World.h 第 329 行定义.

◆ getRayHitNormalX()

float eve::physics::World::getRayHitNormalX ( ) const
inline

在文件 World.h 第 326 行定义.

◆ getRayHitNormalY()

float eve::physics::World::getRayHitNormalY ( ) const
inline

在文件 World.h 第 327 行定义.

◆ getRayHitX()

float eve::physics::World::getRayHitX ( ) const
inline

在文件 World.h 第 324 行定义.

◆ getRayHitY()

float eve::physics::World::getRayHitY ( ) const
inline

在文件 World.h 第 325 行定义.

◆ hasRayHit()

bool eve::physics::World::hasRayHit ( ) const
inline

在文件 World.h 第 322 行定义.

◆ isValid()

bool eve::physics::World::isValid ( ) const
inline

True while the underlying Box2D world is alive.

在文件 World.h 第 306 行定义.

被这些函数引用 drawDebug(), findBody(), findBodyById(), findJoint(), newGearJoint(), pointProbe(), restore(), snapshot() , 以及 step().

◆ lifetimeToken()

std::weak_ptr< const void > eve::physics::World::lifetimeToken ( ) const
inlinenoexcept

Weak lifetime token for guarded cross-domain world observers.

返回
A weak token that expires before world teardown invalidates borrowed objects. @ownership The world owns the token; callers may retain only the weak projection. @lifetime Locking succeeds only while this wrapper is alive and has not been destroyed. @thread Acquire and lock on the owning physics thread; it is a lifetime guard, not a synchronization primitive. @reentrancy Does not invoke callbacks.

在文件 World.h 第 120 行定义.

◆ newBody()

Body * eve::physics::World::newBody ( const std::string &  bodyType,
float  x,
float  y 
)

Creates a body in pixel-space units.

返回
Borrowed nullable body owned by this world; null means creation failed. @ownership World owns the body and its fixtures; callers must destroy it through this API. @lifetime Valid until Body::destroy(), World::destroy(), or world teardown; use PhysicsBodyHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not re-enter structural world mutation while using the result.

在文件 World.cpp 第 431 行定义.

引用了 body, Body, nextBodyId(), nextBodyRuntimeHandle(), raw(), runtimeHandle(), toMeters(), x , 以及 y.

◆ newCrankSlider()

Mechanism2D * eve::physics::World::newCrankSlider ( Body *  frame,
Body *  crank,
Body *  rod,
Body *  slider,
float  crankAnchorX,
float  crankAnchorY,
float  crankPinX,
float  crankPinY,
float  sliderPinX,
float  sliderPinY,
float  slideAxisX,
float  slideAxisY,
bool  collideConnected = false 
)

Builds a planar crank-slider from frame, crank, connecting rod and slider bodies.

返回
Borrowed mechanism owned by this world. @ownership World owns the mechanism and its joints; body pointers are borrowed inputs. @lifetime Valid until Mechanism2D::destroy() or World::destroy(). @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate the input bodies re-entrantly.
异常
eve::Exceptionfor invalid body chains or a zero/non-finite slide axis.

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

引用了 eve::physics::Mechanism2D::CrankSlider, Mechanism2D, newPrismaticJoint(), newRevoluteJoint(), nextMechanismId() , 以及 values.

◆ newDistanceJoint()

Joint2D * eve::physics::World::newDistanceJoint ( Body *  bodyA,
Body *  bodyB,
float  anchorAX,
float  anchorAY,
float  anchorBX,
float  anchorBY,
float  lengthPixels,
bool  collideConnected = false 
)

Connects two pixel-space anchors with a distance constraint.

返回
Borrowed nullable joint owned by this world; null means creation failed. @ownership World owns the joint; body pointers are borrowed inputs. @lifetime Valid until Joint2D::destroy(), World::destroy(), or dependent body destruction; use PhysicsJointHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.
异常
eve::Exceptionfor invalid bodies, anchors, length, or cross-world bodies.

在文件 WorldJoints2D.cpp 第 79 行定义.

引用了 eve::physics::Joint2D::Distance, eve::physics::Body::raw(), toMeters() , 以及 values.

◆ newGearJoint()

Joint2D * eve::physics::World::newGearJoint ( Joint2D *  joint1,
Joint2D *  joint2,
float  ratio 
)

Creates a gear joint that couples two revolute or prismatic joints.

返回
Borrowed nullable joint owned by this world. @ownership World owns the gear; joint1/joint2 are borrowed and must outlive the gear or be destroyed first via Joint2D::destroy() / body teardown. @lifetime Valid until Joint2D::destroy(), World::destroy(), or dependent joint/body destruction; use PhysicsJointHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks.
异常
eve::Exceptionfor invalid/cross-world joints or a zero/non-finite ratio.

在文件 WorldJoints2D.cpp 第 151 行定义.

引用了 findBodyById(), eve::physics::Joint2D::Gear, eve::physics::Joint2D::getBodyAId(), eve::physics::Joint2D::getBodyBId(), eve::physics::Joint2D::getKind(), eve::physics::Joint2D::getWorld(), eve::physics::Joint2D::isValid(), isValid(), eve::physics::Body::raw() , 以及 eve::physics::Joint2D::raw().

◆ newMotorJoint()

Joint2D * eve::physics::World::newMotorJoint ( Body *  bodyA,
Body *  bodyB,
bool  collideConnected = false 
)

Creates a motor joint that drives relative pose between bodies.

返回
Borrowed nullable joint owned by this world. @ownership World owns the joint; body pointers are borrowed inputs. @lifetime Valid until Joint2D::destroy(), World::destroy(), or dependent body destruction; use PhysicsJointHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.
异常
eve::Exceptionfor invalid/cross-world bodies.

在文件 WorldJoints2D.cpp 第 143 行定义.

引用了 eve::physics::Joint2D::Motor , 以及 eve::physics::Body::raw().

◆ newPrismaticJoint()

Joint2D * eve::physics::World::newPrismaticJoint ( Body *  bodyA,
Body *  bodyB,
float  anchorX,
float  anchorY,
float  axisX,
float  axisY,
bool  collideConnected = false 
)

Creates a prismatic slider along a pixel-space axis.

返回
Borrowed nullable joint owned by this world. @ownership World owns the joint; body pointers are borrowed inputs. @lifetime Valid until Joint2D::destroy(), World::destroy(), or dependent body destruction; use PhysicsJointHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.
异常
eve::Exceptionfor invalid bodies or a zero/non-finite axis.

在文件 WorldJoints2D.cpp 第 108 行定义.

引用了 axisX, axisY, eve::physics::Joint2D::Prismatic, eve::physics::Body::raw(), toMeters() , 以及 values.

被这些函数引用 newCrankSlider().

◆ newRatchet()

Mechanism2D * eve::physics::World::newRatchet ( Body *  frame,
Body *  wheel,
float  anchorX,
float  anchorY,
int  direction,
float  engagementTorque,
bool  collideConnected = false 
)

Builds a one-way ratchet around a revolute hinge.

参数
directionFreewheel direction: +1 or -1.
engagementTorqueMaximum reverse-lock torque in newton-metres.
返回
Borrowed mechanism owned by this world. @ownership World owns the mechanism and its joints; body pointers are borrowed inputs. @lifetime Valid until Mechanism2D::destroy() or World::destroy(). @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.

在文件 WorldJoints2D.cpp 第 189 行定义.

引用了 direction, Mechanism2D, newRevoluteJoint(), nextMechanismId() , 以及 eve::physics::Mechanism2D::Ratchet.

◆ newRevoluteJoint()

Joint2D * eve::physics::World::newRevoluteJoint ( Body *  bodyA,
Body *  bodyB,
float  anchorX,
float  anchorY,
bool  collideConnected = false 
)

Creates a revolute hinge at a shared pixel-space anchor.

返回
Borrowed nullable joint owned by this world. @ownership World owns the joint; body pointers are borrowed inputs. @lifetime Valid until Joint2D::destroy(), World::destroy(), or dependent body destruction; use PhysicsJointHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.
异常
eve::Exceptionfor invalid/cross-world bodies or non-finite anchors.

在文件 WorldJoints2D.cpp 第 97 行定义.

引用了 eve::physics::Body::raw(), eve::physics::Joint2D::Revolute, toMeters() , 以及 values.

被这些函数引用 newCrankSlider(), newRatchet() , 以及 newShaft().

◆ newShaft()

Mechanism2D * eve::physics::World::newShaft ( Body *  support,
Body *  rotor,
float  anchorX,
float  anchorY,
bool  collideConnected = false 
)

Builds a shaft (support↔rotor revolute) with optional drive motor helpers.

返回
Borrowed mechanism owned by this world. @ownership World owns the mechanism and its joints; body pointers are borrowed inputs. @lifetime Valid until Mechanism2D::destroy() or World::destroy(). @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.

在文件 WorldJoints2D.cpp 第 178 行定义.

引用了 Mechanism2D, newRevoluteJoint(), nextMechanismId() , 以及 eve::physics::Mechanism2D::Shaft.

◆ newWeldJoint()

Joint2D * eve::physics::World::newWeldJoint ( Body *  bodyA,
Body *  bodyB,
float  anchorX,
float  anchorY,
bool  collideConnected = false 
)

Welds two bodies at a shared pixel-space anchor.

返回
Borrowed nullable joint owned by this world. @ownership World owns the joint; body pointers are borrowed inputs. @lifetime Valid until Joint2D::destroy(), World::destroy(), or dependent body destruction; use PhysicsJointHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.
异常
eve::Exceptionfor invalid/cross-world bodies or non-finite anchors.

在文件 WorldJoints2D.cpp 第 120 行定义.

引用了 eve::physics::Body::raw(), toMeters(), values , 以及 eve::physics::Joint2D::Weld.

◆ newWheelJoint()

Joint2D * eve::physics::World::newWheelJoint ( Body *  bodyA,
Body *  bodyB,
float  anchorX,
float  anchorY,
float  axisX,
float  axisY,
bool  collideConnected = false 
)

Creates a wheel joint with a pixel-space suspension axis.

返回
Borrowed nullable joint owned by this world. @ownership World owns the joint; body pointers are borrowed inputs. @lifetime Valid until Joint2D::destroy(), World::destroy(), or dependent body destruction; use PhysicsJointHandle across frames. @thread Call on the owning physics thread. @reentrancy Creation does not invoke callbacks; do not mutate either body re-entrantly.
异常
eve::Exceptionfor invalid bodies or a zero/non-finite axis.

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

引用了 axisX, axisY, eve::physics::Body::raw(), toMeters(), values , 以及 eve::physics::Joint2D::Wheel.

◆ nextBodyId()

int eve::physics::World::nextBodyId ( )

在文件 World.cpp 第 423 行定义.

被这些函数引用 newBody().

◆ nextBodyRuntimeHandle()

PhysicsBodyHandle eve::physics::World::nextBodyRuntimeHandle ( )

在文件 World.cpp 第 425 行定义.

引用了 eve::RuntimeHandle< PhysicsBodyHandleTag >::invalidIndex.

被这些函数引用 newBody().

◆ nextJointId()

int eve::physics::World::nextJointId ( )

Internal: next stable joint id.

在文件 WorldJoints2D.cpp 第 62 行定义.

◆ nextJointRuntimeHandle()

PhysicsJointHandle eve::physics::World::nextJointRuntimeHandle ( )

Internal: next generation-qualified joint handle.

在文件 WorldJoints2D.cpp 第 66 行定义.

引用了 eve::RuntimeHandle< PhysicsJointHandleTag >::invalidIndex.

◆ nextMechanismId()

int eve::physics::World::nextMechanismId ( )

Internal: next stable mechanism id.

在文件 WorldJoints2D.cpp 第 64 行定义.

被这些函数引用 newCrankSlider(), newRatchet() , 以及 newShaft().

◆ onBeginContact()

void eve::physics::World::onBeginContact ( b2Contact *  contact)

在文件 World.cpp 第 502 行定义.

引用了 a, b , 以及 eve::platform_event::Variant::makeInt().

被这些函数引用 eve::physics::ContactRelay::BeginContact().

◆ onEndContact()

void eve::physics::World::onEndContact ( b2Contact *  contact)

在文件 World.cpp 第 518 行定义.

引用了 a, b , 以及 eve::platform_event::Variant::makeInt().

被这些函数引用 eve::physics::ContactRelay::EndContact().

◆ onPostSolve()

◆ onPreSolve()

void eve::physics::World::onPreSolve ( b2Contact *  contact,
const b2Manifold *  oldManifold 
)

在文件 World.cpp 第 535 行定义.

引用了 a, b, local, point , 以及 toPixels().

被这些函数引用 eve::physics::ContactRelay::PreSolve().

◆ operator=()

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

◆ persistentId()

eve::PersistentId eve::physics::World::persistentId ( ) const
inlinenoexcept

Stable non-nil identity written to snapshot envelopes.

在文件 World.h 第 122 行定义.

◆ pointProbe()

bool eve::physics::World::pointProbe ( float  x,
float  y,
float  radius,
ClothContact *  out 
) const

Probe the deepest non-sensor fixture within radius of a pixel point. Returns false when nothing is hit. Used by Cloth for particle-vs-body collision.

在文件 World.cpp 第 308 行定义.

引用了 best, center, depth, eve::physics::World::ClothContact::hit, isValid(), normal, radius, shape, toMeters(), world, x , 以及 y.

◆ queryAABB()

int eve::physics::World::queryAABB ( float  x,
float  y,
float  w,
float  h 
)

Query fixtures overlapping an axis-aligned box in pixel space (x,y,w,h). Returns match count; read ids with getQueryBodyId(i).

在文件 World.cpp 第 695 行定义.

引用了 b, h, ids, toMeters(), w, world, x , 以及 y.

◆ raw() [1/2]

b2World * eve::physics::World::raw ( )
inline

Exposes the underlying Box2D world for tightly-scoped backend integration.

返回
Borrowed nullable backend pointer; never transfer or retain it across steps. @ownership World owns the Box2D world; callers must not delete the returned pointer. @lifetime Valid until World::destroy() or wrapper destruction. @thread Call only on the owning physics thread. @reentrancy Does not invoke callbacks; backend mutation must not re-enter world callbacks.

在文件 World.h 第 378 行定义.

被这些函数引用 eve::physics::Body::destroy(), eve::physics::Joint2D::destroy(), drawDebug(), forgetFixture(), eve::physics::Joint2D::isValid(), newBody() , 以及 eve::physics::Body::~Body().

◆ raw() [2/2]

const b2World * eve::physics::World::raw ( ) const
inline

Exposes the underlying Box2D world for read-only backend integration.

返回
Borrowed nullable backend pointer. @ownership World owns the Box2D world; callers must not delete it. @lifetime Valid until World::destroy() or wrapper destruction. @thread Call only on the owning physics thread. @reentrancy Does not invoke callbacks and is invalid across world mutation.

在文件 World.h 第 387 行定义.

◆ rayCast()

int eve::physics::World::rayCast ( float  x1,
float  y1,
float  x2,
float  y2 
)

Closest raycast in pixel space from (x1,y1) to (x2,y2). Returns hit body id, or -1. Read hit details via getRayHit*.

在文件 World.cpp 第 650 行定义.

引用了 b, best, hit, normal, point, toMeters(), toPixels() , 以及 world.

◆ restore()

eve::Result< void > eve::physics::World::restore ( const eve::SnapshotEnvelope &  snapshot,
const eve::SnapshotHashProvider &  hashProvider 
)

Restores a verified snapshot without exposing partial state.

参数
snapshotVersioned envelope produced for this world schema.
hashProviderProvider used to verify its content hash.
返回
Applied after replacing the live bodies and supported fixture geometry with the prepared snapshot state.
备注
The snapshot is borrowed for this call and runtime handles are never persisted or reused from its payload. Preparation is detached and failure leaves the live world unchanged. Schema v2 reconstructs circle, polygon, and chain geometry; edge fixtures and fixture material/filter metadata are not represented by this schema and unsupported input is rejected.

在文件 WorldSnapshot.cpp 第 859 行定义.

引用了 eve::physics::WorldSnapshotAccess::adopt(), eve::Applied, clearContactEvents(), eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Value::getIf(), eve::SnapshotEnvelope::instanceId, eve::InvalidArgument, eve::detail::Id128< Tag >::isNil(), isValid(), eve::ParseError, eve::SnapshotEnvelope::payload, eve::PreconditionViolation, eve::SnapshotEnvelope::schemaVersion, eve::Status::success(), eve::Result< T >::success(), eve::detail::StrongUint64< Tag >::value(), value , 以及 eve::verifySnapshotEnvelope().

◆ runtimeHandle()

PhysicsWorldHandle eve::physics::World::runtimeHandle ( ) const
inlinenoexcept

Process-local identity used by PhysicsLink; invalid after destruction.

在文件 World.h 第 111 行定义.

被这些函数引用 eve::pixelworld_physics::PixelTerrainCollisionCache::clearPhysics() , 以及 newBody().

◆ setGravity()

void eve::physics::World::setGravity ( float  gx,
float  gy 
)

Sets the world gravity vector in pixels/s^2.

在文件 World.cpp 第 399 行定义.

引用了 toMeters().

◆ setMeter()

void eve::physics::World::setMeter ( float  pixelsPerMeter)

Changes the pixels-per-meter conversion.

在文件 World.cpp 第 414 行定义.

◆ simulationObservation()

SimulationObservation eve::physics::World::simulationObservation ( ) const
noexcept

Snapshot of completed backend steps and logical simulation time.

在文件 World.cpp 第 385 行定义.

被这些函数引用 snapshot().

◆ simulationTick()

eve::SimulationTick eve::physics::World::simulationTick ( ) const
inlinenoexcept

Current deterministic tick; save data should persist this value.

在文件 World.h 第 109 行定义.

被这些函数引用 snapshot().

◆ snapshot()

eve::Result< eve::SnapshotEnvelope > eve::physics::World::snapshot ( const eve::SnapshotHashProvider &  hashProvider) const

Captures a versioned, integrity-checked world snapshot.

参数
hashProviderInjected digest provider used to seal the envelope.
返回
A snapshot containing the exact SimulationTick, body state, and fixture geometry topology.
备注
Schema v2 rejects unknown fields. The provider is not retained; this call is owner-thread-only.

在文件 WorldSnapshot.cpp 第 844 行定义.

引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), isValid(), eve::makeSnapshotEnvelope(), eve::PreconditionViolation, simulationObservation() , 以及 simulationTick().

◆ step()

eve::Result< void > eve::physics::World::step ( const eve::SimulationStep &  step,
const SimulationSettings &  settings = {} 
)

Advances the domain with an injected deterministic simulation step.

参数
stepTick and fixed duration supplied by SimulationClock or replay.
settingsSolver policy; the backend consumes it without hidden clamping.
返回
Applied when the step completed, or a structured rejection/failure.
备注
A rejected step leaves solver state and the current tick unchanged.

在文件 World.cpp 第 368 行定义.

引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), isValid(), eve::PreconditionViolation, settings, eve::SimulationStep::tick , 以及 valid.

◆ toMeters()

◆ toPixels()

◆ update()

void eve::physics::World::update ( float  dt)

Steps the simulation by dt seconds (5 velocity / 2 position iterations).

在文件 World.cpp 第 354 行定义.

引用了 updateFull().

◆ updateFull()

void eve::physics::World::updateFull ( float  dt,
int  velocityIterations,
int  positionIterations 
)

Steps with explicit iteration counts.

在文件 World.cpp 第 356 行定义.

引用了 EV_PROFILE_MODULE , 以及 step.

被这些函数引用 update().

◆ usedBackendFallback()

bool eve::physics::World::usedBackendFallback ( ) const
inlinenoexcept

Whether optional accelerator selection fell back to CPU.

在文件 World.h 第 124 行定义.

友元及相关函数文档

◆ Body

friend class Body
friend

在文件 World.h 第 412 行定义.

被这些函数引用 newBody().

◆ Fixture

friend class Fixture
friend

在文件 World.h 第 413 行定义.

◆ Joint2D

friend class Joint2D
friend

在文件 World.h 第 414 行定义.

◆ Mechanism2D

friend class Mechanism2D
friend

在文件 World.h 第 415 行定义.

被这些函数引用 newCrankSlider(), newRatchet() , 以及 newShaft().

◆ WorldSnapshotAccess

friend struct WorldSnapshotAccess
friend

在文件 World.h 第 411 行定义.


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