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() [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/gravityY Gravity vector in pixels/s^2. sleep Whether bodies may sleep when idle. meter Pixels per meter conversion factor. instanceId Stable save/network identity; nil creates a process-local generated identity.
引用了 eve::physics::detail::allocatePhysicsWorldHandle(), eve::detail::Id128< Tag >::isNil(), eve::physics::detail::makePhysicsWorldPersistentId(), status, toMeters() , 以及 eve::physics::World2D.
◆ ~World()
◆ World() [2/2]
|
delete |
成员函数说明
◆ backendDeterminism()
|
noexcept |
Replay/numeric guarantee declared by the selected backend.
◆ backendKind()
|
noexcept |
◆ backendSelectionStatus()
| eve::Status eve::physics::World::backendSelectionStatus | ( | ) | const |
◆ clearContactEvents()
| void eve::physics::World::clearContactEvents | ( | ) |
◆ destroy()
| void eve::physics::World::destroy | ( | ) |
Destroys the underlying Box2D world and resets event buffers.
引用了 b, clearContactEvents(), f, fixtures , 以及 eve::RuntimeHandle< PhysicsWorldHandleTag >::invalid().
被这些函数引用 ~World().
◆ destroyBody()
| void eve::physics::World::destroyBody | ( | Body * | body | ) |
Destroys a body (null is ignored).
引用了 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 |
◆ findBodyById()
| Body * eve::physics::World::findBodyById | ( | int | bodyId | ) | const |
Resolves a live body by its world-local stable event/query id.
被这些函数引用 newGearJoint().
◆ findJoint()
| Joint2D * eve::physics::World::findJoint | ( | PhysicsJointHandle | handle | ) | const |
Resolves a live joint handle; returns null when stale or foreign.
在文件 WorldJoints2D.cpp 第 72 行定义.
◆ forgetBody()
| void eve::physics::World::forgetBody | ( | Body * | body | ) |
被这些函数引用 eve::physics::Body::destroy() , 以及 eve::physics::Body::~Body().
◆ forgetFixture()
| void eve::physics::World::forgetFixture | ( | Fixture * | fixture | ) |
◆ 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 |
◆ getBeginContactBodyBId()
| int eve::physics::World::getBeginContactBodyBId | ( | int | index | ) | const |
◆ getBeginContactCount()
◆ getBeginContactFixtureATag()
| std::string eve::physics::World::getBeginContactFixtureATag | ( | int | index | ) | const |
◆ getBeginContactFixtureBTag()
| std::string eve::physics::World::getBeginContactFixtureBTag | ( | int | index | ) | const |
◆ getEndContactBodyAId()
| int eve::physics::World::getEndContactBodyAId | ( | int | index | ) | const |
◆ getEndContactBodyBId()
| int eve::physics::World::getEndContactBodyBId | ( | int | index | ) | const |
◆ getEndContactCount()
◆ getEndContactFixtureATag()
| std::string eve::physics::World::getEndContactFixtureATag | ( | int | index | ) | const |
◆ getEndContactFixtureBTag()
| std::string eve::physics::World::getEndContactFixtureBTag | ( | int | index | ) | const |
◆ getGravityX()
| float eve::physics::World::getGravityX | ( | ) | const |
引用了 toPixels().
◆ getGravityY()
| float eve::physics::World::getGravityY | ( | ) | const |
引用了 toPixels().
◆ getImpactBodyAId()
◆ getImpactBodyBId()
◆ getImpactCount()
◆ getImpactFixtureATag()
| std::string eve::physics::World::getImpactFixtureATag | ( | int | index | ) | const |
◆ getImpactFixtureBTag()
| std::string eve::physics::World::getImpactFixtureBTag | ( | int | index | ) | const |
◆ getImpactNormalImpulse()
| float eve::physics::World::getImpactNormalImpulse | ( | int | index | ) | const |
◆ getImpactNormalX()
◆ getImpactNormalY()
◆ getImpactPointX()
◆ getImpactPointY()
◆ getImpactRelativeNormalSpeed()
| float eve::physics::World::getImpactRelativeNormalSpeed | ( | int | index | ) | const |
◆ getImpactTangentImpulse()
| float eve::physics::World::getImpactTangentImpulse | ( | int | index | ) | const |
◆ getMeter()
|
inline |
被这些函数引用 drawDebug().
◆ getQueryBodyId()
◆ getQueryCount()
◆ getRayHitBodyId()
◆ getRayHitFraction()
|
inline |
◆ getRayHitNormalX()
◆ getRayHitNormalY()
◆ getRayHitX()
◆ getRayHitY()
◆ hasRayHit()
◆ isValid()
|
inline |
True while the underlying Box2D world is alive.
被这些函数引用 drawDebug(), findBody(), findBodyById(), findJoint(), newGearJoint(), pointProbe(), restore(), snapshot() , 以及 step().
◆ lifetimeToken()
|
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.
◆ 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.
引用了 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::Exception for 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::Exception for invalid bodies, anchors, length, or cross-world bodies.
在文件 WorldJoints2D.cpp 第 79 行定义.
引用了 eve::physics::Joint2D::Distance, eve::physics::Body::raw(), toMeters() , 以及 values.
◆ newGearJoint()
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::Exception for 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::Exception for 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::Exception for 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.
- 参数
-
direction Freewheel direction: +1 or -1. engagementTorque Maximum 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::Exception for 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::Exception for 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::Exception for invalid bodies or a zero/non-finite axis.
在文件 WorldJoints2D.cpp 第 131 行定义.
引用了 axisX, axisY, eve::physics::Body::raw(), toMeters(), values , 以及 eve::physics::Joint2D::Wheel.
◆ nextBodyId()
◆ nextBodyRuntimeHandle()
| PhysicsBodyHandle eve::physics::World::nextBodyRuntimeHandle | ( | ) |
◆ 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 | ) |
引用了 a, b , 以及 eve::platform_event::Variant::makeInt().
◆ onEndContact()
| void eve::physics::World::onEndContact | ( | b2Contact * | contact | ) |
引用了 a, b , 以及 eve::platform_event::Variant::makeInt().
◆ onPostSolve()
| void eve::physics::World::onPostSolve | ( | b2Contact * | contact, |
| const b2ContactImpulse * | impulse | ||
| ) |
引用了 count, found, eve::physics::World::ImpactEvent::normalImpulse, eve::physics::World::ImpactEvent::normalX, eve::physics::World::ImpactEvent::normalY, eve::physics::World::ImpactEvent::pointX, eve::physics::World::ImpactEvent::pointY, eve::physics::World::ImpactEvent::relativeNormalSpeed, eve::physics::World::ImpactEvent::tangentImpulse , 以及 toPixels().
◆ onPreSolve()
| void eve::physics::World::onPreSolve | ( | b2Contact * | contact, |
| const b2Manifold * | oldManifold | ||
| ) |
引用了 a, b, local, point , 以及 toPixels().
◆ operator=()
◆ persistentId()
|
inlinenoexcept |
◆ pointProbe()
| bool eve::physics::World::pointProbe | ( | float | x, |
| float | y, | ||
| float | radius, | ||
| ClothContact * | out | ||
| ) | const |
◆ queryAABB()
| int eve::physics::World::queryAABB | ( | float | x, |
| float | y, | ||
| float | w, | ||
| float | h | ||
| ) |
◆ raw() [1/2]
|
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.
被这些函数引用 eve::physics::Body::destroy(), eve::physics::Joint2D::destroy(), drawDebug(), forgetFixture(), eve::physics::Joint2D::isValid(), newBody() , 以及 eve::physics::Body::~Body().
◆ raw() [2/2]
|
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.
◆ 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*.
引用了 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.
- 参数
-
snapshot Versioned envelope produced for this world schema. hashProvider Provider 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()
|
inlinenoexcept |
Process-local identity used by PhysicsLink; invalid after destruction.
被这些函数引用 eve::pixelworld_physics::PixelTerrainCollisionCache::clearPhysics() , 以及 newBody().
◆ setGravity()
| void eve::physics::World::setGravity | ( | float | gx, |
| float | gy | ||
| ) |
◆ setMeter()
| void eve::physics::World::setMeter | ( | float | pixelsPerMeter | ) |
◆ simulationObservation()
|
noexcept |
Snapshot of completed backend steps and logical simulation time.
被这些函数引用 snapshot().
◆ simulationTick()
|
inlinenoexcept |
Current deterministic tick; save data should persist this value.
被这些函数引用 snapshot().
◆ snapshot()
| eve::Result< eve::SnapshotEnvelope > eve::physics::World::snapshot | ( | const eve::SnapshotHashProvider & | hashProvider | ) | const |
Captures a versioned, integrity-checked world snapshot.
- 参数
-
hashProvider Injected 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.
- 参数
-
step Tick and fixed duration supplied by SimulationClock or replay. settings Solver 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.
引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), isValid(), eve::PreconditionViolation, settings, eve::SimulationStep::tick , 以及 valid.
◆ toMeters()
| float eve::physics::World::toMeters | ( | float | pixels | ) | const |
Converts a pixel-space length to meters.
引用了 pixels.
被这些函数引用 eve::physics::Body::applyForce(), eve::physics::Body::applyForceAt(), eve::physics::Body::applyLinearImpulse(), newBody(), eve::physics::Body::newChainFixture(), eve::physics::Body::newCircleFixture(), newDistanceJoint(), eve::physics::Body::newPolygonFixture(), newPrismaticJoint(), eve::physics::Body::newRectangleFixtureAt(), newRevoluteJoint(), newWeldJoint(), newWheelJoint(), pointProbe(), queryAABB(), rayCast(), eve::physics::Joint2D::setDistanceLength(), setGravity(), eve::physics::Body::setLinearVelocity(), eve::physics::Joint2D::setMotorLimits(), eve::physics::Joint2D::setMotorLinearOffset(), eve::physics::Body::setPosition(), eve::physics::Joint2D::setPrismaticLimits(), eve::physics::Joint2D::setPrismaticMotor(), eve::physics::Fixture::testPoint() , 以及 World().
◆ toPixels()
| float eve::physics::World::toPixels | ( | float | meters | ) | const |
Converts a meter-space length to pixels.
被这些函数引用 eve::physics::Joint2D::getDistanceLength(), getGravityX(), getGravityY(), eve::physics::Body::getLinearSpeed(), eve::physics::Body::getLinearVelocityX(), eve::physics::Body::getLinearVelocityY(), eve::physics::Joint2D::getMotorLinearOffsetX(), eve::physics::Joint2D::getMotorLinearOffsetY(), eve::physics::Joint2D::getPrismaticSpeed(), eve::physics::Joint2D::getPrismaticTranslation(), eve::physics::Joint2D::getWheelTranslation(), eve::physics::Body::getWorldCenterX(), eve::physics::Body::getWorldCenterY(), eve::physics::Body::getX(), eve::physics::Body::getY(), onPostSolve(), onPreSolve() , 以及 rayCast().
◆ update()
| void eve::physics::World::update | ( | float | dt | ) |
Steps the simulation by dt seconds (5 velocity / 2 position iterations).
引用了 updateFull().
◆ updateFull()
| void eve::physics::World::updateFull | ( | float | dt, |
| int | velocityIterations, | ||
| int | positionIterations | ||
| ) |
◆ usedBackendFallback()
|
inlinenoexcept |
友元及相关函数文档
◆ Body
◆ Fixture
◆ Joint2D
◆ Mechanism2D
|
friend |
被这些函数引用 newCrankSlider(), newRatchet() , 以及 newShaft().
◆ WorldSnapshotAccess
|
friend |
该类的文档由以下文件生成:
- src/modules/physics/World.h
- src/modules/physics/World.cpp
- src/modules/physics/WorldDebugDraw.cpp
- src/modules/physics/WorldJoints2D.cpp
- src/modules/physics/WorldSnapshot.cpp