载入中...
搜索中...
未找到
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
 
struct  TriggerEvent
 Begin/end sensor overlap with an explicit sensor and visitor side. Populated when exactly one fixture in the contact is a sensor; both-sensor overlaps keep FixtureA as sensor. Non-sensor contacts stay in ContactEvent only. 更多...
 

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.
 
ResultRef< Joint2D > resolveJoint2D (int id) const
 Resolve a persistent joint id in this world, including snapshot-created joints.
 
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 getBeginTriggerCount () const
 Sensor/visitor begin overlaps collected during the last step (2D parity with World3D).
 
int getBeginTriggerSensorBodyId (int index) const
 
int getBeginTriggerVisitorBodyId (int index) const
 
std::string getBeginTriggerSensorFixtureTag (int index) const
 
std::string getBeginTriggerVisitorFixtureTag (int index) const
 
int getEndTriggerCount () const
 Sensor/visitor end overlaps collected during the last step.
 
int getEndTriggerSensorBodyId (int index) const
 
int getEndTriggerVisitorBodyId (int index) const
 
std::string getEndTriggerSensorFixtureTag (int index) const
 
std::string getEndTriggerVisitorFixtureTag (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
 
struct PortableWorldSnapshotAccess
 
class Body
 
class ForceBatch
 
class Joint2D
 
struct PhysicsJointLink
 
class Fixture
 
class Mechanism2D
 

详细描述

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

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

构造及析构函数说明

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

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

◆ ~World()

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

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

引用了 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 第 441 行定义.

引用了 eve::physics::ToleranceBounded.

◆ backendKind()

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

Selected CPU/GPU/mock backend family.

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

引用了 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 第 445 行定义.

◆ clearContactEvents()

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

Clears collected begin/end contact and impact event buffers.

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

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

◆ destroy()

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

Destroys the underlying Box2D world and resets event buffers.

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

引用了 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 第 509 行定义.

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

◆ findBody()

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

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

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

引用了 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 第 501 行定义.

引用了 body , 以及 isValid().

◆ findJoint()

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

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

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

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

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

◆ forgetBody()

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

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

引用了 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 第 36 行定义.

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

◆ forgetMechanism()

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

Internal: removes a mechanism wrapper from ownership bookkeeping.

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

◆ getBeginContactBodyAId()

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

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

引用了 index.

◆ getBeginContactBodyBId()

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

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

引用了 index.

◆ getBeginContactCount()

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

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

◆ getBeginContactFixtureATag()

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

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

引用了 index.

◆ getBeginContactFixtureBTag()

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

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

引用了 index.

◆ getBeginTriggerCount()

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

Sensor/visitor begin overlaps collected during the last step (2D parity with World3D).

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

◆ getBeginTriggerSensorBodyId()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::sensorBodyId.

◆ getBeginTriggerSensorFixtureTag()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::sensorFixtureTag.

◆ getBeginTriggerVisitorBodyId()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::visitorBodyId.

◆ getBeginTriggerVisitorFixtureTag()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::visitorFixtureTag.

◆ getEndContactBodyAId()

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

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

引用了 index.

◆ getEndContactBodyBId()

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

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

引用了 index.

◆ getEndContactCount()

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

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

◆ getEndContactFixtureATag()

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

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

引用了 index.

◆ getEndContactFixtureBTag()

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

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

引用了 index.

◆ getEndTriggerCount()

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

Sensor/visitor end overlaps collected during the last step.

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

◆ getEndTriggerSensorBodyId()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::sensorBodyId.

◆ getEndTriggerSensorFixtureTag()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::sensorFixtureTag.

◆ getEndTriggerVisitorBodyId()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::visitorBodyId.

◆ getEndTriggerVisitorFixtureTag()

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

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

引用了 index , 以及 eve::physics::World::TriggerEvent::visitorFixtureTag.

◆ getGravityX()

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

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

引用了 toPixels().

◆ getGravityY()

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

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

引用了 toPixels().

◆ getImpactBodyAId()

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

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

引用了 index.

◆ getImpactBodyBId()

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

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

引用了 index.

◆ getImpactCount()

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

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

◆ getImpactFixtureATag()

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

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

引用了 index.

◆ getImpactFixtureBTag()

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

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

引用了 index.

◆ getImpactNormalImpulse()

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

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

引用了 index.

◆ getImpactNormalX()

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

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

引用了 index.

◆ getImpactNormalY()

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

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

引用了 index.

◆ getImpactPointX()

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

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

引用了 index.

◆ getImpactPointY()

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

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

引用了 index.

◆ getImpactRelativeNormalSpeed()

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

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

引用了 index.

◆ getImpactTangentImpulse()

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

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

引用了 index.

◆ getMeter()

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

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

被这些函数引用 drawDebug().

◆ getQueryBodyId()

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

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

引用了 index.

◆ getQueryCount()

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

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

◆ getRayHitBodyId()

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

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

◆ getRayHitFraction()

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

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

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

◆ getRayHitNormalX()

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

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

◆ getRayHitNormalY()

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

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

◆ getRayHitX()

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

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

◆ getRayHitY()

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

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

◆ hasRayHit()

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

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

◆ isValid()

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

True while the underlying Box2D world is alive.

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

被这些函数引用 drawDebug(), findBody(), findBodyById(), findJoint(), 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 第 137 行定义.

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

引用了 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 第 156 行定义.

引用了 collideConnected, eve::physics::Mechanism2D::CrankSlider, frame, 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 第 78 行定义.

引用了 a, b, eve::physics::Distance, eve::physics::Joint2DSettings::kind, length, s , 以及 toMeters().

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

引用了 eve::physics::Joint2D::createGear(), first, ratio, result , 以及 second.

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

引用了 a, b, eve::physics::Joint2DSettings::kind, eve::physics::Motor , 以及 s.

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

引用了 a, b, eve::physics::Joint2DSettings::kind, eve::physics::Prismatic, s, toMeters(), x , 以及 y.

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

引用了 collideConnected, direction, frame, 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 第 87 行定义.

引用了 a, b, eve::physics::Joint2DSettings::kind, eve::physics::Revolute, s, toMeters(), x , 以及 y.

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

引用了 collideConnected, 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 第 102 行定义.

引用了 a, b, eve::physics::Joint2DSettings::kind, s, toMeters(), eve::physics::Weld, x , 以及 y.

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

引用了 a, b, eve::physics::Joint2DSettings::kind, s, toMeters(), eve::physics::Wheel, x , 以及 y.

◆ nextBodyId()

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

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

被这些函数引用 newBody().

◆ nextBodyRuntimeHandle()

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

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

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

被这些函数引用 newBody().

◆ nextJointId()

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

Internal: next stable joint id.

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

◆ nextJointRuntimeHandle()

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

Internal: next generation-qualified joint handle.

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

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

◆ nextMechanismId()

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

Internal: next stable mechanism id.

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

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

◆ onBeginContact()

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

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

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

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

◆ onEndContact()

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

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

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

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

◆ onPostSolve()

void eve::physics::World::onPostSolve ( b2Contact *  contact,
const b2ContactImpulse *  impulse 
)

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

引用了 contact, count, found, impulse, out , 以及 toPixels().

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

◆ onPreSolve()

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

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

引用了 a, b, contact, 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 第 139 行定义.

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

引用了 best, center, depth, eve::physics::World::ClothContact::hit, isValid(), normal, out, radius, shape, toMeters(), 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 第 814 行定义.

引用了 b, h, ids, toMeters(), w, 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 第 417 行定义.

被这些函数引用 eve::physics::Body::destroy(), drawDebug(), forgetFixture(), newBody(), restore(), snapshot() , 以及 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 第 426 行定义.

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

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

◆ resolveJoint2D()

ResultRef< Joint2D > eve::physics::World::resolveJoint2D ( int  id) const

Resolve a persistent joint id in this world, including snapshot-created joints.

返回
Borrowed reference or StaleHandle when absent. @ownership Caller/VM owns created wrappers; this world owns restored wrappers. @lifetime Borrow only until joint/body/world destruction or successful restore. Use PhysicsJointLink across steps. @thread Simulation owner thread; no callbacks or reentrant mutations. @cost Linear in live planar joint count; resolve during link rebuilding, retain the resulting handle.

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

引用了 id.

◆ 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 v3 reconstructs planar joints, supported fixture geometry/material/filter/tag and body damping/gravity/sleep. Mass is recomputed from fixture density. Raw backend mass overrides and edge fixtures are not represented. Solver warm-start impulses are not persisted; replay is tolerance-based. @lifetime Successful restore invalidates previous body, shape/fixture and joint wrappers and runtime handles. Resolve links against the rebuilt world; rejected restore leaves existing wrappers valid.

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

引用了 eve::physics::WorldSnapshotAccess::adopt(), eve::Applied, eve::physics::snapshot_detail::checkEnvelope(), clearContactEvents(), eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::physics::snapshot_detail::field(), eve::Value::getIf(), eve::physics::snapshot_detail::hasExactFields(), eve::SnapshotEnvelope::instanceId, eve::InvalidArgument, eve::detail::Id128< Tag >::isNil(), isValid(), eve::physics::snapshot_detail::kWorld2DSchema, eve::physics::snapshot_detail::kWorld2DType, eve::physics::snapshot_detail::matchBodyIds(), eve::physics::snapshot_detail::migratePlanarV2(), eve::physics::snapshot_detail::parseBodies2D(), eve::ParseError, eve::physics::snapshot_detail::parseObservation(), eve::SnapshotEnvelope::payload, eve::PreconditionViolation, eve::physics::snapshot_detail::prepareWorld2D(), raw(), eve::physics::snapshot_detail::readBool(), eve::physics::snapshot_detail::readFloat(), eve::physics::WorldSnapshotAccess::restoreJoints2D(), eve::SnapshotEnvelope::schemaVersion, eve::Status::success(), eve::Result< T >::success(), eve::detail::StrongUint64< Tag >::value() , 以及 eve::verifySnapshotEnvelope().

◆ runtimeHandle()

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

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

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

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

◆ setGravity()

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

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

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

引用了 toMeters().

◆ setMeter()

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

Changes the pixels-per-meter conversion.

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

◆ simulationObservation()

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

Snapshot of completed backend steps and logical simulation time.

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

被这些函数引用 snapshot().

◆ simulationTick()

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

Current deterministic tick; save data should persist this value.

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

被这些函数引用 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, fixture geometry and planar joint definitions.
备注
Schema v3 rejects unknown fields; v2 migrates with no joints. The provider is not retained; this call is owner-thread-only.

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

引用了 eve::physics::WorldSnapshotAccess::captureJoints2D(), eve::Diagnostic::error(), eve::Result< T >::failure(), isValid(), eve::physics::snapshot_detail::kSnapshot2DVersion, eve::physics::snapshot_detail::kWorld2DSchema, eve::physics::snapshot_detail::kWorld2DType, eve::physics::snapshot_detail::make2DPayload(), eve::makeSnapshotEnvelope(), payload, eve::PreconditionViolation, raw(), simulationObservation(), simulationTick() , 以及 eve::physics::snapshot_detail::snapshotSchema().

◆ 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. Pending ForceBatch submissions require this exact tick/duration; failure retains them for retry, success completes their receipts. @thread Simulation owner only; stepping is non-reentrant.

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

引用了 active, eve::Diagnostic::error(), eve::Result< T >::failure(), isValid(), eve::PreconditionViolation, result, 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 第 394 行定义.

引用了 dt , 以及 updateFull().

◆ updateFull()

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

Steps with explicit iteration counts.

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

引用了 dt, EV_PROFILE_MODULE, result , 以及 step.

被这些函数引用 update().

◆ usedBackendFallback()

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

Whether optional accelerator selection fell back to CPU.

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

友元及相关函数文档

◆ Body

friend class Body
friend

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

被这些函数引用 newBody().

◆ Fixture

friend class Fixture
friend

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

◆ ForceBatch

friend class ForceBatch
friend

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

◆ Joint2D

Joint2D
friend

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

◆ Mechanism2D

friend class Mechanism2D
friend

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

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

◆ PhysicsJointLink

friend struct PhysicsJointLink
friend

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

◆ PortableWorldSnapshotAccess

friend struct PortableWorldSnapshotAccess
friend

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

◆ WorldSnapshotAccess

friend struct WorldSnapshotAccess
friend

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


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