载入中...
搜索中...
未找到
JoltBody.h
浏览该文件的文档.
1#pragma once
3namespace eve::physics::jolt {
4struct State;
5struct BodyState;
6struct ShapeState;
7// Internal provider implementation; all operations inherit the neutral interface contract.
8class BodyBackend final : public IBodyBackend3D {
9public:
10 std::shared_ptr<BodyState> body;
11 explicit BodyBackend(std::shared_ptr<BodyState> value) : body(std::move(value)) {}
12 ~BodyBackend() override;
14 float friction, float restitution) override;
15 void bindOwner(Body3D& owner) noexcept override;
16 bool isValid() const noexcept override;
17 void destroy() noexcept override;
18 void invalidate() noexcept override;
19 eve::Result<void> setPosition(float x, float y, float z) override;
20 eve::Result<float> getX() const override;
21 eve::Result<float> getY() const override;
22 eve::Result<float> getZ() const override;
23 eve::Result<void> setRotation(float qx, float qy, float qz, float qw) override;
24 eve::Result<float> getRotX() const override;
25 eve::Result<float> getRotY() const override;
26 eve::Result<float> getRotZ() const override;
27 eve::Result<float> getRotW() const override;
28 eve::Result<void> setLinearVelocity(float vx, float vy, float vz) override;
29 eve::Result<float> getLinearVelocityX() const override;
30 eve::Result<float> getLinearVelocityY() const override;
31 eve::Result<float> getLinearVelocityZ() const override;
32 eve::Result<float> getMass() const override;
33 eve::Result<void> setAngularVelocity(float wx, float wy, float wz) override;
34 eve::Result<float> getAngularVelocityX() const override;
35 eve::Result<float> getAngularVelocityY() const override;
36 eve::Result<float> getAngularVelocityZ() const override;
37 eve::Result<std::vector<float>> localToWorldPoint(float x, float y, float z) const override;
38 eve::Result<PhysicsVector3D> localToWorldPointOwned(float x, float y, float z) const override;
39 eve::Result<std::vector<float>> worldToLocalPoint(float x, float y, float z) const override;
40 eve::Result<PhysicsVector3D> worldToLocalPointOwned(float x, float y, float z) const override;
41 eve::Result<std::vector<float>> localToWorldVector(float x, float y, float z) const override;
42 eve::Result<PhysicsVector3D> localToWorldVectorOwned(float x, float y, float z) const override;
43 eve::Result<std::vector<float>> worldToLocalVector(float x, float y, float z) const override;
44 eve::Result<std::vector<float>> getLocalPointVelocity(float x, float y, float z) const override;
45 eve::Result<PhysicsVector3D> getLocalPointVelocityOwned(float x, float y, float z) const override;
46 eve::Result<std::vector<float>> getWorldPointVelocity(float x, float y, float z) const override;
47 eve::Result<void> applyForce(float fx, float fy, float fz) override;
48 eve::Result<void> applyForceAt(float fx, float fy, float fz, float x, float y, float z) override;
49 eve::Result<void> applyTorque(float tx, float ty, float tz) override;
50 eve::Result<void> applyLinearImpulse(float ix, float iy, float iz) override;
51 eve::Result<void> applyLinearImpulseAt(float ix, float iy, float iz, float x, float y, float z) override;
52 eve::Result<void> applyAngularImpulse(float ix, float iy, float iz) override;
53 eve::Result<void> applyLocalForce(float fx, float fy, float fz, float x, float y, float z) override;
54 eve::Result<void> applyLocalForceToCenter(float fx, float fy, float fz) override;
55 eve::Result<void> applyLocalTorque(float tx, float ty, float tz) override;
56 eve::Result<void> applyLocalLinearImpulse(float ix, float iy, float iz, float x, float y, float z) override;
57 eve::Result<void> applyLocalLinearImpulseToCenter(float ix, float iy, float iz) override;
58 eve::Result<void> applyLocalAngularImpulse(float ix, float iy, float iz) override;
59 eve::Result<void> setTargetTransform(float x, float y, float z, float qx, float qy, float qz, float qw,
60 float timeStep) override;
61 eve::Result<void> setLinearDamping(float damping) override;
62 eve::Result<float> getLinearDamping() const override;
63 eve::Result<void> setAngularDamping(float damping) override;
64 eve::Result<float> getAngularDamping() const override;
65 eve::Result<void> setGravityScale(float scale) override;
66 eve::Result<float> getGravityScale() const override;
67 eve::Result<void> setSleepEnabled(bool enabled) override;
68 eve::Result<bool> isSleepEnabled() const override;
69 eve::Result<void> setSleepThreshold(float threshold) override;
70 eve::Result<float> getSleepThreshold() const override;
71 eve::Result<void> setMotionLocks(bool linearX, bool linearY, bool linearZ, bool angularX, bool angularY,
72 bool angularZ) override;
73 eve::Result<bool> isLinearXLocked() const override;
74 eve::Result<bool> isLinearYLocked() const override;
75 eve::Result<bool> isLinearZLocked() const override;
76 eve::Result<bool> isAngularXLocked() const override;
77 eve::Result<bool> isAngularYLocked() const override;
78 eve::Result<bool> isAngularZLocked() const override;
79 eve::Result<void> setMassProperties(float mass, float centerX, float centerY, float centerZ, float inertiaXX,
80 float inertiaYY, float inertiaZZ, float inertiaXY, float inertiaXZ,
81 float inertiaYZ) override;
82 eve::Result<void> resetMassProperties() override;
83 eve::Result<float> getInertiaXX() const override;
84 eve::Result<float> getInertiaYY() const override;
85 eve::Result<float> getInertiaZZ() const override;
86 eve::Result<float> getInertiaXY() const override;
87 eve::Result<float> getInertiaXZ() const override;
88 eve::Result<float> getInertiaYZ() const override;
89 eve::Result<float> getLocalCenterX() const override;
90 eve::Result<float> getLocalCenterY() const override;
91 eve::Result<float> getLocalCenterZ() const override;
92 eve::Result<float> getWorldCenterX() const override;
93 eve::Result<float> getWorldCenterY() const override;
94 eve::Result<float> getWorldCenterZ() const override;
95 eve::Result<void> setType(const std::string& bodyType) override;
96 eve::Result<std::string> getType() const override;
97 eve::Result<void> setFixedRotation(bool fixed) override;
98 eve::Result<bool> isFixedRotation() const override;
99 eve::Result<void> setActive(bool active) override;
100 eve::Result<bool> isActive() const override;
101 eve::Result<void> setBullet(bool bullet) override;
102 eve::Result<bool> isBullet() const override;
103 eve::Result<void> setAwake(bool awake) override;
104 eve::Result<bool> isAwake() const override;
105};
106} // namespace eve::physics::jolt
double z
double y
double x
bool & active
bool awake
float friction
float density
std::array< float, 3 > scale
std::shared_ptr< OceanGpuSpectrum > owner
Object::Ptr value
std::string geometry
double restitution
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...
eve::Result< float > getZ() const override
getZ; inherits the class lifetime and failure contract.
eve::Result< float > getSleepThreshold() const override
getSleepThreshold; inherits the class lifetime and failure contract.
eve::Result< float > getLocalCenterY() const override
getLocalCenterY; inherits the class lifetime and failure contract.
eve::Result< void > setActive(bool active) override
setActive; inherits the class lifetime and failure contract.
eve::Result< void > setMassProperties(float mass, float centerX, float centerY, float centerZ, float inertiaXX, float inertiaYY, float inertiaZZ, float inertiaXY, float inertiaXZ, float inertiaYZ) override
setMassProperties; inherits the class lifetime and failure contract.
eve::Result< float > getY() const override
getY; inherits the class lifetime and failure contract.
eve::Result< float > getInertiaXX() const override
getInertiaXX; inherits the class lifetime and failure contract.
eve::Result< float > getWorldCenterX() const override
getWorldCenterX; inherits the class lifetime and failure contract.
eve::Result< void > applyLocalTorque(float tx, float ty, float tz) override
applyLocalTorque; inherits the class lifetime and failure contract.
void destroy() noexcept override
Releases the native body idempotently without callbacks; children must be detached first.
Definition JoltBody.cpp:15
eve::Result< std::vector< float > > localToWorldPoint(float x, float y, float z) const override
localToWorldPoint; inherits the class lifetime and failure contract. @cost Three scalar values copied...
eve::Result< bool > isAngularZLocked() const override
isAngularZLocked; inherits the class lifetime and failure contract.
eve::Result< void > applyAngularImpulse(float ix, float iy, float iz) override
applyAngularImpulse; inherits the class lifetime and failure contract.
eve::Result< void > setGravityScale(float scale) override
setGravityScale; inherits the class lifetime and failure contract.
eve::Result< float > getAngularVelocityY() const override
getAngularVelocityY; inherits the class lifetime and failure contract.
eve::Result< float > getRotY() const override
getRotY; inherits the class lifetime and failure contract.
eve::Result< PhysicsVector3D > worldToLocalPointOwned(float x, float y, float z) const override
worldToLocalPointOwned; inherits the class lifetime and failure contract.
eve::Result< PhysicsVector3D > getLocalPointVelocityOwned(float x, float y, float z) const override
getLocalPointVelocityOwned; inherits the class lifetime and failure contract.
eve::Result< void > applyLinearImpulse(float ix, float iy, float iz) override
applyLinearImpulse; inherits the class lifetime and failure contract.
eve::Result< float > getMass() const override
getMass; inherits the class lifetime and failure contract.
eve::Result< float > getGravityScale() const override
getGravityScale; inherits the class lifetime and failure contract.
eve::Result< float > getAngularVelocityX() const override
getAngularVelocityX; inherits the class lifetime and failure contract.
BodyBackend(std::shared_ptr< BodyState > value)
Definition JoltBody.h:11
eve::Result< float > getLinearVelocityX() const override
getLinearVelocityX; inherits the class lifetime and failure contract.
eve::Result< void > setAngularDamping(float damping) override
setAngularDamping; inherits the class lifetime and failure contract.
eve::Result< bool > isSleepEnabled() const override
isSleepEnabled; inherits the class lifetime and failure contract.
eve::Result< float > getInertiaYY() const override
getInertiaYY; inherits the class lifetime and failure contract.
eve::Result< void > applyLocalLinearImpulseToCenter(float ix, float iy, float iz) override
applyLocalLinearImpulseToCenter; inherits the class lifetime and failure contract.
eve::Result< void > setPosition(float x, float y, float z) override
setPosition; inherits the class lifetime and failure contract.
eve::Result< PhysicsVector3D > localToWorldVectorOwned(float x, float y, float z) const override
localToWorldVectorOwned; inherits the class lifetime and failure contract.
eve::Result< bool > isAwake() const override
isAwake; inherits the class lifetime and failure contract.
eve::Result< void > setRotation(float qx, float qy, float qz, float qw) override
setRotation; inherits the class lifetime and failure contract.
eve::Result< bool > isLinearYLocked() const override
isLinearYLocked; inherits the class lifetime and failure contract.
eve::Result< void > setTargetTransform(float x, float y, float z, float qx, float qy, float qz, float qw, float timeStep) override
setTargetTransform; inherits the class lifetime and failure contract.
eve::Result< void > applyForceAt(float fx, float fy, float fz, float x, float y, float z) override
applyForceAt; inherits the class lifetime and failure contract.
eve::Result< void > setLinearVelocity(float vx, float vy, float vz) override
setLinearVelocity; inherits the class lifetime and failure contract.
eve::Result< void > setBullet(bool bullet) override
setBullet; inherits the class lifetime and failure contract.
eve::Result< void > setAngularVelocity(float wx, float wy, float wz) override
setAngularVelocity; inherits the class lifetime and failure contract.
eve::Result< bool > isActive() const override
isActive; inherits the class lifetime and failure contract.
eve::Result< float > getLinearVelocityZ() const override
getLinearVelocityZ; inherits the class lifetime and failure contract.
eve::Result< std::unique_ptr< IShapeBackend3D > > createShape(const ShapeGeometry3D &geometry, float density, float friction, float restitution) override
Creates and owns one shape for this body; no input references are retained. @cost One geometry cook p...
Definition JoltBody.cpp:29
eve::Result< float > getX() const override
getX; inherits the class lifetime and failure contract.
eve::Result< float > getRotX() const override
getRotX; inherits the class lifetime and failure contract.
eve::Result< float > getInertiaZZ() const override
getInertiaZZ; inherits the class lifetime and failure contract.
eve::Result< void > setType(const std::string &bodyType) override
setType; inherits the class lifetime and failure contract.
eve::Result< float > getInertiaXY() const override
getInertiaXY; inherits the class lifetime and failure contract.
eve::Result< float > getWorldCenterZ() const override
getWorldCenterZ; inherits the class lifetime and failure contract.
eve::Result< void > applyTorque(float tx, float ty, float tz) override
applyTorque; inherits the class lifetime and failure contract.
eve::Result< bool > isLinearZLocked() const override
isLinearZLocked; inherits the class lifetime and failure contract.
eve::Result< float > getAngularDamping() const override
getAngularDamping; inherits the class lifetime and failure contract.
eve::Result< void > applyLocalAngularImpulse(float ix, float iy, float iz) override
applyLocalAngularImpulse; inherits the class lifetime and failure contract.
eve::Result< float > getLocalCenterX() const override
getLocalCenterX; inherits the class lifetime and failure contract.
eve::Result< float > getRotW() const override
getRotW; inherits the class lifetime and failure contract.
eve::Result< void > setLinearDamping(float damping) override
setLinearDamping; inherits the class lifetime and failure contract.
eve::Result< float > getInertiaYZ() const override
getInertiaYZ; inherits the class lifetime and failure contract.
eve::Result< float > getInertiaXZ() const override
getInertiaXZ; inherits the class lifetime and failure contract.
eve::Result< std::vector< float > > getWorldPointVelocity(float x, float y, float z) const override
getWorldPointVelocity; inherits the class lifetime and failure contract. @cost Three scalar values co...
eve::Result< bool > isLinearXLocked() const override
isLinearXLocked; inherits the class lifetime and failure contract.
void invalidate() noexcept override
Detaches before its parent world destroys the native body.
Definition JoltBody.cpp:11
eve::Result< float > getAngularVelocityZ() const override
getAngularVelocityZ; inherits the class lifetime and failure contract.
eve::Result< void > setAwake(bool awake) override
setAwake; inherits the class lifetime and failure contract.
eve::Result< PhysicsVector3D > localToWorldPointOwned(float x, float y, float z) const override
localToWorldPointOwned; inherits the class lifetime and failure contract.
eve::Result< float > getLinearDamping() const override
getLinearDamping; inherits the class lifetime and failure contract.
eve::Result< bool > isAngularXLocked() const override
isAngularXLocked; inherits the class lifetime and failure contract.
std::shared_ptr< BodyState > body
Definition JoltBody.h:10
eve::Result< float > getLocalCenterZ() const override
getLocalCenterZ; inherits the class lifetime and failure contract.
eve::Result< std::vector< float > > worldToLocalVector(float x, float y, float z) const override
worldToLocalVector; inherits the class lifetime and failure contract. @cost Three scalar values copie...
eve::Result< bool > isBullet() const override
isBullet; inherits the class lifetime and failure contract.
eve::Result< bool > isAngularYLocked() const override
isAngularYLocked; inherits the class lifetime and failure contract.
void bindOwner(Body3D &owner) noexcept override
Binds its exclusive facade owner for internal attribution, on the simulation thread....
Definition JoltBody.cpp:10
eve::Result< void > applyLocalLinearImpulse(float ix, float iy, float iz, float x, float y, float z) override
applyLocalLinearImpulse; inherits the class lifetime and failure contract.
eve::Result< void > applyLocalForceToCenter(float fx, float fy, float fz) override
applyLocalForceToCenter; inherits the class lifetime and failure contract.
eve::Result< void > applyLinearImpulseAt(float ix, float iy, float iz, float x, float y, float z) override
applyLinearImpulseAt; inherits the class lifetime and failure contract.
bool isValid() const noexcept override
Whether the native body remains alive.
Definition JoltBody.cpp:9
eve::Result< float > getWorldCenterY() const override
getWorldCenterY; inherits the class lifetime and failure contract.
eve::Result< void > setSleepThreshold(float threshold) override
setSleepThreshold; inherits the class lifetime and failure contract.
eve::Result< std::string > getType() const override
getType; inherits the class lifetime and failure contract.
eve::Result< void > resetMassProperties() override
resetMassProperties; inherits the class lifetime and failure contract.
eve::Result< float > getLinearVelocityY() const override
getLinearVelocityY; inherits the class lifetime and failure contract.
eve::Result< std::vector< float > > localToWorldVector(float x, float y, float z) const override
localToWorldVector; inherits the class lifetime and failure contract. @cost Three scalar values copie...
eve::Result< bool > isFixedRotation() const override
isFixedRotation; inherits the class lifetime and failure contract.
eve::Result< void > setMotionLocks(bool linearX, bool linearY, bool linearZ, bool angularX, bool angularY, bool angularZ) override
setMotionLocks; inherits the class lifetime and failure contract.
eve::Result< float > getRotZ() const override
getRotZ; inherits the class lifetime and failure contract.
eve::Result< std::vector< float > > worldToLocalPoint(float x, float y, float z) const override
worldToLocalPoint; inherits the class lifetime and failure contract. @cost Three scalar values copied...
eve::Result< void > setSleepEnabled(bool enabled) override
setSleepEnabled; inherits the class lifetime and failure contract.
eve::Result< void > applyForce(float fx, float fy, float fz) override
applyForce; inherits the class lifetime and failure contract.
eve::Result< void > setFixedRotation(bool fixed) override
setFixedRotation; inherits the class lifetime and failure contract.
eve::Result< void > applyLocalForce(float fx, float fy, float fz, float x, float y, float z) override
applyLocalForce; inherits the class lifetime and failure contract.
eve::Result< std::vector< float > > getLocalPointVelocity(float x, float y, float z) const override
getLocalPointVelocity; inherits the class lifetime and failure contract. @cost Three scalar values co...
State
Lifecycle state of a generic transaction plan.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
bool enabled
Allocation-free owning three-dimensional physics value.
Definition RigidTypes3D.h:4
Owning, backend-independent shape source; metres, local quaternion XYZW.