载入中...
搜索中...
未找到
JoltWorld.h
浏览该文件的文档.
1#pragma once
3namespace eve::physics::jolt {
4struct State;
5struct BodyState;
6struct ShapeState;
7struct QueryVolume;
8// Internal provider implementation; all operations inherit the neutral interface contract.
9class WorldBackend final : public IWorldBackend3D {
10public:
12 static bool isContactAllowed(const Shape3D&, const Shape3D&, double, double, double, float, float, float);
14 static bool isPairAllowed(const Shape3D&, const Shape3D&);
17 std::shared_ptr<State> state;
21 [[nodiscard]] eve::Result<int> castQuery(const QueryVolume&, float, float, float, int);
22 WorldBackend(World3D&, float, float, float, bool);
23 ~WorldBackend() override;
25 float anchorY, float anchorZ,
26 bool collideConnected) override;
28 bool collideConnected) override;
30 float axisY, float axisZ,
31 bool collideConnected) override;
34 float anchorAY, float anchorAZ, float anchorBX,
35 float anchorBY, float anchorBZ, float length,
36 bool collideConnected) override;
38 float anchorY, float anchorZ, float axisX,
39 float axisY, float axisZ,
40 bool collideConnected) override;
42 float anchorY, float anchorZ, float axisX,
43 float axisY, float axisZ,
44 bool collideConnected) override;
46 float anchorY, float anchorZ, float axisX,
47 float axisY, float axisZ,
48 bool collideConnected) override;
50 float anchorY, float anchorZ, float suspensionAxisX,
51 float suspensionAxisY, float suspensionAxisZ,
52 float wheelAxisX, float wheelAxisY, float wheelAxisZ,
53 bool collideConnected) override;
54 bool isValid() const noexcept override;
55 void destroy() noexcept override;
57 eve::Result<void> swapTopology(IWorldBackend3D& prepared) override;
58 uint64_t shapeKey(const Shape3D& shape) const override;
59 eve::Result<void> collectEvents() override;
60 eve::Result<std::unique_ptr<IBodyBackend3D>> createBody(std::string_view type, float x, float y, float z) override;
61 eve::Result<void> setContinuousCollisionEnabled(bool enabled) override;
62 eve::Result<bool> isContinuousCollisionEnabled() const override;
63 eve::Result<void> setRestitutionThreshold(float speed) override;
64 eve::Result<float> getRestitutionThreshold() const override;
65 eve::Result<void> setContactTuning(float hertz, float dampingRatio, float pushOutSpeed) override;
66 eve::Result<void> setContactRecycleDistance(float distance) override;
67 eve::Result<float> getContactRecycleDistance() const override;
68 eve::Result<void> setMaximumLinearSpeed(float speed) override;
69 eve::Result<float> getMaximumLinearSpeed() const override;
70 eve::Result<void> setWarmStartingEnabled(bool enabled) override;
71 eve::Result<bool> isWarmStartingEnabled() const override;
72 eve::Result<int> explode(float x, float y, float z, float radius, float falloff, float impulsePerArea,
73 int maskBits) override;
74 eve::Result<float> getBoundsMinX() const override;
75 eve::Result<float> getBoundsMinY() const override;
76 eve::Result<float> getBoundsMinZ() const override;
77 eve::Result<float> getBoundsMaxX() const override;
78 eve::Result<float> getBoundsMaxY() const override;
79 eve::Result<float> getBoundsMaxZ() const override;
80 eve::Result<int> getBodyCount() const override;
81 eve::Result<int> getShapeCount() const override;
82 eve::Result<int> getContactCount() const override;
83 eve::Result<int> getJointCount() const override;
84 eve::Result<int> getIslandCount() const override;
85 eve::Result<int> getAwakeContactCount() const override;
86 eve::Result<int> getRecycledContactCount() const override;
87 eve::Result<int> getStaticTreeHeight() const override;
88 eve::Result<int> getDynamicTreeHeight() const override;
89 eve::Result<int> getMemoryByteCount() const override;
90 eve::Result<int> getAwakeBodyCount() const override;
91 eve::Result<float> getProfileStepMs() const override;
92 eve::Result<float> getProfilePairsMs() const override;
93 eve::Result<float> getProfileCollideMs() const override;
94 eve::Result<float> getProfileSolveMs() const override;
95 eve::Result<float> getProfileBulletsMs() const override;
96 eve::Result<float> getProfileSensorsMs() const override;
97 eve::Result<void> setGravity(float gx, float gy, float gz) override;
98 eve::Result<float> getGravityX() const override;
99 eve::Result<float> getGravityY() const override;
100 eve::Result<float> getGravityZ() const override;
101 eve::Result<void> setHitEventThreshold(float speed) override;
102 eve::Result<float> getHitEventThreshold() const override;
103 eve::Result<CameraSphereHit3D> sphereCast(float x1, float y1, float z1, float x2, float y2, float z2, float radius,
104 uint64_t maskBits, int ignoredBodyId) const override;
105 eve::Result<int> rayCastFiltered(float x1, float y1, float z1, float x2, float y2, float z2,
106 uint64_t maskBits) override;
107 eve::Result<RayHit3D> rayCastOwned(float x1, float y1, float z1, float x2, float y2, float z2,
108 QueryFilter3D filter) override;
109 eve::Result<int> rayCastAll(float x1, float y1, float z1, float x2, float y2, float z2, int maxHits) override;
110 eve::Result<int> queryAABB(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) override;
111 eve::Result<BroadPhaseAabb3D> queryAabbBroadPhaseOwned(float minX, float minY, float minZ, float maxX, float maxY,
112 float maxZ, QueryFilter3D filter) override;
113 eve::Result<int> querySphere(float x, float y, float z, float radius) override;
114 eve::Result<int> queryCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius) override;
115 eve::Result<CapsuleOverlap3D> queryCapsuleOwned(float ax, float ay, float az, float bx, float by, float bz,
116 float radius, QueryFilter3D filter) override;
117 eve::Result<int> queryBox(float x, float y, float z, float width, float height, float depth, float qx, float qy,
118 float qz, float qw) override;
119 eve::Result<int> castSphereAll(float x, float y, float z, float radius, float dx, float dy, float dz,
120 int maxHits) override;
121 eve::Result<int> castCapsuleAll(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx,
122 float dy, float dz, int maxHits) override;
123 eve::Result<int> castBoxAll(float x, float y, float z, float width, float height, float depth, float qx, float qy,
124 float qz, float qw, float dx, float dy, float dz, int maxHits) override;
125 eve::Result<int> closestPoint(float x, float y, float z, float maxDistance) override;
126 eve::Result<void> setMoverUp(float x, float y, float z) override;
127 eve::Result<bool> moveCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx,
128 float dy, float dz) override;
129 eve::Result<CapsuleMove3D> moveCapsuleOwned(float ax, float ay, float az, float bx, float by, float bz,
130 float radius, float dx, float dy, float dz, QueryFilter3D filter,
131 CapsuleMovePolicy3D policy) override;
132 eve::Result<ClothContact3D> pointProbeFiltered(float x, float y, float z, float radius, uint64_t categoryBits,
133 uint64_t maskBits) const override;
134 eve::Result<BodyContacts3D> queryBodyContactsOwned(PhysicsBodyHandle body, int maxPoints) const override;
135};
136} // namespace eve::physics::jolt
double z
double y
double x
ShaderImageInput shape
std::uint32_t height
std::uint32_t width
float dampingRatio
bool collideConnected
float length
double radius
Definition MeleeHit.cpp:42
float distance
glm::dvec3 dx
glm::dvec3 dz
std::string body
float axisZ
Definition RockMesh.cpp:22
float axisY
Definition RockMesh.cpp:22
float axisX
Definition RockMesh.cpp:22
std::string filter
float dy
Definition Shadow.cpp:151
std::uint32_t depth
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Backend-neutral 3D rigid body in meter-space coordinates (+Y up by convention). Owned by a World3D; c...
Definition Body3D.h:31
Solver-independent control of a rigid body, exclusively owned by its facade. @ownership Implementatio...
Complete rigid-world execution boundary, bound once to an owning World3D facade. @ownership Owns exac...
3D shape (box/sphere/capsule) attached to a Body3D with material settings. Created via Body3D::new*Sh...
Definition Shape3D.h:34
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
eve::Result< int > rayCastFiltered(float x1, float y1, float z1, float x2, float y2, float z2, uint64_t maskBits) override
rayCastFiltered; uses the class ownership, thread and failure contract.
eve::Result< void > setWarmStartingEnabled(bool enabled) override
setWarmStartingEnabled; uses the class ownership, thread and failure contract.
eve::Result< bool > moveCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx, float dy, float dz) override
moveCapsule; uses the class ownership, thread and failure contract.
void destroy() noexcept override
Idempotent native teardown after all facades have been invalidated.
Definition JoltWorld.cpp:91
eve::Result< int > castCapsuleAll(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx, float dy, float dz, int maxHits) override
castCapsuleAll; uses the class ownership, thread and failure contract.
eve::Result< CapsuleOverlap3D > queryCapsuleOwned(float ax, float ay, float az, float bx, float by, float bz, float radius, QueryFilter3D filter) override
queryCapsuleOwned; uses the class ownership, thread and failure contract.
eve::Result< int > getAwakeContactCount() const override
getAwakeContactCount; uses the class ownership, thread and failure contract.
eve::Result< int > queryAABB(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) override
queryAABB; uses the class ownership, thread and failure contract.
eve::Result< int > getIslandCount() const override
getIslandCount; uses the class ownership, thread and failure contract.
eve::Result< int > getStaticTreeHeight() const override
getStaticTreeHeight; uses the class ownership, thread and failure contract.
eve::Result< void > setContactRecycleDistance(float distance) override
setContactRecycleDistance; uses the class ownership, thread and failure contract.
eve::Result< float > getGravityZ() const override
getGravityZ; uses the class ownership, thread and failure contract.
eve::Result< std::unique_ptr< IJointBackend3D > > newDistanceJoint(Body3D &bodyA, Body3D &bodyB, float anchorAX, float anchorAY, float anchorAZ, float anchorBX, float anchorBY, float anchorBZ, float length, bool collideConnected) override
Creates an owning Distance constraint; bodies are synchronous non-owning inputs. @cost One native con...
eve::Result< void > setContinuousCollisionEnabled(bool enabled) override
setContinuousCollisionEnabled; uses the class ownership, thread and failure contract.
eve::Result< CapsuleMove3D > moveCapsuleOwned(float ax, float ay, float az, float bx, float by, float bz, float radius, float dx, float dy, float dz, QueryFilter3D filter, CapsuleMovePolicy3D policy) override
moveCapsuleOwned; uses the class ownership, thread and failure contract.
eve::Result< int > getAwakeBodyCount() const override
getAwakeBodyCount; uses the class ownership, thread and failure contract.
eve::Result< bool > isContinuousCollisionEnabled() const override
isContinuousCollisionEnabled; uses the class ownership, thread and failure contract.
eve::Result< float > getContactRecycleDistance() const override
getContactRecycleDistance; uses the class ownership, thread and failure contract.
eve::Result< void > setMaximumLinearSpeed(float speed) override
setMaximumLinearSpeed; uses the class ownership, thread and failure contract.
eve::Result< std::unique_ptr< IJointBackend3D > > newWeldJoint(Body3D &bodyA, Body3D &bodyB, float anchorX, float anchorY, float anchorZ, bool collideConnected) override
Creates an owning Weld constraint; bodies are synchronous non-owning inputs. @cost One native constra...
eve::Result< bool > isWarmStartingEnabled() const override
isWarmStartingEnabled; uses the class ownership, thread and failure contract.
eve::Result< float > getMaximumLinearSpeed() const override
getMaximumLinearSpeed; uses the class ownership, thread and failure contract.
eve::Result< int > overlapQuery(const QueryVolume &, QueryFilter3D)
Internal synchronous projection of an ephemeral cooked query volume.
eve::Result< std::unique_ptr< IJointBackend3D > > newSphericalJoint(Body3D &bodyA, Body3D &bodyB, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, bool collideConnected) override
Creates an owning Spherical constraint; bodies are synchronous non-owning inputs. @cost One native co...
eve::Result< std::unique_ptr< IJointBackend3D > > newParallelJoint(Body3D &bodyA, Body3D &bodyB, float axisX, float axisY, float axisZ, bool collideConnected) override
Creates an owning Parallel constraint; bodies are synchronous non-owning inputs. @cost One native con...
eve::Result< float > getBoundsMaxY() const override
getBoundsMaxY; uses the class ownership, thread and failure contract.
eve::Result< int > getDynamicTreeHeight() const override
getDynamicTreeHeight; uses the class ownership, thread and failure contract.
eve::Result< void > setRestitutionThreshold(float speed) override
setRestitutionThreshold; uses the class ownership, thread and failure contract.
eve::Result< float > getBoundsMaxZ() const override
getBoundsMaxZ; uses the class ownership, thread and failure contract.
eve::Result< int > castQuery(const QueryVolume &, float, float, float, int)
Internal synchronous sweep; owning native data is projected into facade caches.
eve::Result< std::unique_ptr< IJointBackend3D > > newPrismaticJoint(Body3D &bodyA, Body3D &bodyB, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, bool collideConnected) override
Creates an owning Prismatic constraint; bodies are synchronous non-owning inputs. @cost One native co...
std::shared_ptr< State > state
Definition JoltWorld.h:17
eve::Result< float > getProfileBulletsMs() const override
getProfileBulletsMs; uses the class ownership, thread and failure contract.
eve::Result< std::unique_ptr< IJointBackend3D > > newFilterJoint(Body3D &bodyA, Body3D &bodyB) override
Creates an owning Filter constraint; bodies are synchronous non-owning inputs. @cost One native const...
eve::Result< void > setGravity(float gx, float gy, float gz) override
setGravity; uses the class ownership, thread and failure contract.
eve::Result< float > getBoundsMinX() const override
getBoundsMinX; uses the class ownership, thread and failure contract.
eve::Result< int > castBoxAll(float x, float y, float z, float width, float height, float depth, float qx, float qy, float qz, float qw, float dx, float dy, float dz, int maxHits) override
castBoxAll; uses the class ownership, thread and failure contract.
eve::Result< BroadPhaseAabb3D > queryAabbBroadPhaseOwned(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, QueryFilter3D filter) override
queryAabbBroadPhaseOwned; uses the class ownership, thread and failure contract.
eve::Result< void > setMoverUp(float x, float y, float z) override
setMoverUp; uses the class ownership, thread and failure contract.
eve::Result< float > getProfileCollideMs() const override
getProfileCollideMs; uses the class ownership, thread and failure contract.
eve::Result< float > getGravityY() const override
getGravityY; uses the class ownership, thread and failure contract.
eve::Result< float > getProfileStepMs() const override
getProfileStepMs; uses the class ownership, thread and failure contract.
static bool isPairAllowed(const Shape3D &, const Shape3D &)
Reads explicit body/shape pair exclusions for solid and sensor contacts without callbacks.
eve::Result< RayHit3D > rayCastOwned(float x1, float y1, float z1, float x2, float y2, float z2, QueryFilter3D filter) override
rayCastOwned; uses the class ownership, thread and failure contract.
eve::Result< float > getBoundsMaxX() const override
getBoundsMaxX; uses the class ownership, thread and failure contract.
eve::Result< std::unique_ptr< IJointBackend3D > > newWheelJoint(Body3D &bodyA, Body3D &bodyB, float anchorX, float anchorY, float anchorZ, float suspensionAxisX, float suspensionAxisY, float suspensionAxisZ, float wheelAxisX, float wheelAxisY, float wheelAxisZ, bool collideConnected) override
Creates an owning Wheel constraint; bodies are synchronous non-owning inputs. @cost One native constr...
eve::Result< std::unique_ptr< IBodyBackend3D > > createBody(std::string_view type, float x, float y, float z) override
Creates an owning body backend without publishing an engine wrapper. @cost One native body allocation...
eve::Result< SimulationBackendSelection > selectSimulation() override
Builds the separate CPU/accelerator step driver; driver borrows this world's stable state.
eve::Result< std::unique_ptr< IJointBackend3D > > newMotorJoint(Body3D &bodyA, Body3D &bodyB, bool collideConnected) override
Creates an owning Motor constraint; bodies are synchronous non-owning inputs. @cost One native constr...
eve::Result< float > getProfilePairsMs() const override
getProfilePairsMs; uses the class ownership, thread and failure contract.
eve::Result< ClothContact3D > pointProbeFiltered(float x, float y, float z, float radius, uint64_t categoryBits, uint64_t maskBits) const override
pointProbeFiltered; uses the class ownership, thread and failure contract.
eve::Result< void > setContactTuning(float hertz, float dampingRatio, float pushOutSpeed) override
setContactTuning; uses the class ownership, thread and failure contract.
eve::Result< int > queryBox(float x, float y, float z, float width, float height, float depth, float qx, float qy, float qz, float qw) override
queryBox; uses the class ownership, thread and failure contract.
eve::Result< int > getRecycledContactCount() const override
getRecycledContactCount; uses the class ownership, thread and failure contract.
eve::Result< int > explode(float x, float y, float z, float radius, float falloff, float impulsePerArea, int maskBits) override
explode; uses the class ownership, thread and failure contract.
eve::Result< float > getBoundsMinY() const override
getBoundsMinY; uses the class ownership, thread and failure contract.
eve::Result< float > getRestitutionThreshold() const override
getRestitutionThreshold; uses the class ownership, thread and failure contract.
eve::Result< int > querySphere(float x, float y, float z, float radius) override
querySphere; uses the class ownership, thread and failure contract.
eve::Result< BodyContacts3D > queryBodyContactsOwned(PhysicsBodyHandle body, int maxPoints) const override
queryBodyContactsOwned; uses the class ownership, thread and failure contract.
bool isValid() const noexcept override
Native world liveness.
Definition JoltWorld.cpp:90
eve::Result< float > getHitEventThreshold() const override
getHitEventThreshold; uses the class ownership, thread and failure contract.
eve::Result< void > collectEvents() override
Collects solver events into the owner's queues without publishing callbacks.
eve::Result< std::unique_ptr< IJointBackend3D > > newRevoluteJoint(Body3D &bodyA, Body3D &bodyB, float anchorX, float anchorY, float anchorZ, float axisX, float axisY, float axisZ, bool collideConnected) override
Creates an owning Revolute constraint; bodies are synchronous non-owning inputs. @cost One native con...
eve::Result< void > swapTopology(IWorldBackend3D &prepared) override
Swaps prepared native topology while retaining stable step-driver contexts.
eve::Result< void > setHitEventThreshold(float speed) override
setHitEventThreshold; uses the class ownership, thread and failure contract.
eve::Result< int > closestPoint(float x, float y, float z, float maxDistance) override
closestPoint; uses the class ownership, thread and failure contract.
eve::Result< int > getShapeCount() const override
getShapeCount; uses the class ownership, thread and failure contract.
eve::Result< int > rayCastAll(float x1, float y1, float z1, float x2, float y2, float z2, int maxHits) override
rayCastAll; uses the class ownership, thread and failure contract.
eve::Result< int > getMemoryByteCount() const override
getMemoryByteCount; uses the class ownership, thread and failure contract.
static bool isContactAllowed(const Shape3D &, const Shape3D &, double, double, double, float, float, float)
Reads built-in pair overrides and prepared one-way planes synchronously; no user callbacks or locks.
eve::Result< int > getContactCount() const override
getContactCount; uses the class ownership, thread and failure contract.
eve::Result< int > castSphereAll(float x, float y, float z, float radius, float dx, float dy, float dz, int maxHits) override
castSphereAll; uses the class ownership, thread and failure contract.
eve::Result< CameraSphereHit3D > sphereCast(float x1, float y1, float z1, float x2, float y2, float z2, float radius, uint64_t maskBits, int ignoredBodyId) const override
sphereCast; uses the class ownership, thread and failure contract.
eve::Result< float > getProfileSolveMs() const override
getProfileSolveMs; uses the class ownership, thread and failure contract.
eve::Result< int > getJointCount() const override
getJointCount; uses the class ownership, thread and failure contract.
eve::Result< int > queryCapsule(float ax, float ay, float az, float bx, float by, float bz, float radius) override
queryCapsule; uses the class ownership, thread and failure contract.
eve::Result< float > getBoundsMinZ() const override
getBoundsMinZ; uses the class ownership, thread and failure contract.
eve::Result< float > getProfileSensorsMs() const override
getProfileSensorsMs; uses the class ownership, thread and failure contract.
eve::Result< float > getGravityX() const override
getGravityX; uses the class ownership, thread and failure contract.
eve::Result< int > getBodyCount() const override
getBodyCount; uses the class ownership, thread and failure contract.
uint64_t shapeKey(const Shape3D &shape) const override
Opaque native lookup key scoped to this world, used only by internal event history.
State
Lifecycle state of a generic transaction plan.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
bool enabled
Snapshot of current contacts; values survive later queries and world destruction.
Fixed-capacity deterministic result of one AABB broad-phase query.
CameraSphereHit3D public API.
Definition World3DTypes.h:5
Owning result of continuous capsule movement.
Per-call capsule mover classification policy; never mutates persistent World3D settings.
Owning summary of a capsule overlap query.
Result of a 3D point probe: deepest non-sensor shape within radius. Normal points from the shape towa...
Allocation-free owning three-dimensional physics value.
Definition RigidTypes3D.h:4
Query filter applied atomically for one owning query operation.
Owning snapshot of the closest ray intersection.
Result of choosing an optional accelerator or CPU alternate path.