载入中...
搜索中...
未找到
BodyBackend3D.h
浏览该文件的文档.
1#pragma once
2#include <string>
3#include <vector>
4#include "common/Result.h"
7namespace eve::physics {
8class Body3D;
18public:
24 float density, float friction,
25 float restitution) = 0;
29 virtual void bindOwner(Body3D& owner) noexcept = 0;
30 virtual ~IBodyBackend3D() = default;
32 virtual bool isValid() const noexcept = 0;
34 virtual void destroy() noexcept = 0;
36 virtual void invalidate() noexcept = 0;
38 [[nodiscard]] virtual eve::Result<void> setPosition(float x, float y, float z) = 0;
40 [[nodiscard]] virtual eve::Result<float> getX() const = 0;
42 [[nodiscard]] virtual eve::Result<float> getY() const = 0;
44 [[nodiscard]] virtual eve::Result<float> getZ() const = 0;
46 [[nodiscard]] virtual eve::Result<void> setRotation(float qx, float qy, float qz, float qw) = 0;
48 [[nodiscard]] virtual eve::Result<float> getRotX() const = 0;
50 [[nodiscard]] virtual eve::Result<float> getRotY() const = 0;
52 [[nodiscard]] virtual eve::Result<float> getRotZ() const = 0;
54 [[nodiscard]] virtual eve::Result<float> getRotW() const = 0;
56 [[nodiscard]] virtual eve::Result<void> setLinearVelocity(float vx, float vy, float vz) = 0;
58 [[nodiscard]] virtual eve::Result<float> getLinearVelocityX() const = 0;
60 [[nodiscard]] virtual eve::Result<float> getLinearVelocityY() const = 0;
62 [[nodiscard]] virtual eve::Result<float> getLinearVelocityZ() const = 0;
64 [[nodiscard]] virtual eve::Result<float> getMass() const = 0;
66 [[nodiscard]] virtual eve::Result<void> setAngularVelocity(float wx, float wy, float wz) = 0;
68 [[nodiscard]] virtual eve::Result<float> getAngularVelocityX() const = 0;
70 [[nodiscard]] virtual eve::Result<float> getAngularVelocityY() const = 0;
72 [[nodiscard]] virtual eve::Result<float> getAngularVelocityZ() const = 0;
75 [[nodiscard]] virtual eve::Result<std::vector<float>> localToWorldPoint(float x, float y, float z) const = 0;
77 [[nodiscard]] virtual eve::Result<PhysicsVector3D> localToWorldPointOwned(float x, float y, float z) const = 0;
80 [[nodiscard]] virtual eve::Result<std::vector<float>> worldToLocalPoint(float x, float y, float z) const = 0;
82 [[nodiscard]] virtual eve::Result<PhysicsVector3D> worldToLocalPointOwned(float x, float y, float z) const = 0;
85 [[nodiscard]] virtual eve::Result<std::vector<float>> localToWorldVector(float x, float y, float z) const = 0;
87 [[nodiscard]] virtual eve::Result<PhysicsVector3D> localToWorldVectorOwned(float x, float y, float z) const = 0;
90 [[nodiscard]] virtual eve::Result<std::vector<float>> worldToLocalVector(float x, float y, float z) const = 0;
93 [[nodiscard]] virtual eve::Result<std::vector<float>> getLocalPointVelocity(float x, float y, float z) const = 0;
95 [[nodiscard]] virtual eve::Result<PhysicsVector3D> getLocalPointVelocityOwned(float x, float y, float z) const = 0;
98 [[nodiscard]] virtual eve::Result<std::vector<float>> getWorldPointVelocity(float x, float y, float z) const = 0;
100 [[nodiscard]] virtual eve::Result<void> applyForce(float fx, float fy, float fz) = 0;
102 [[nodiscard]] virtual eve::Result<void> applyForceAt(float fx, float fy, float fz, float x, float y, float z) = 0;
104 [[nodiscard]] virtual eve::Result<void> applyTorque(float tx, float ty, float tz) = 0;
106 [[nodiscard]] virtual eve::Result<void> applyLinearImpulse(float ix, float iy, float iz) = 0;
108 [[nodiscard]] virtual eve::Result<void> applyLinearImpulseAt(float ix, float iy, float iz, float x, float y,
109 float z) = 0;
111 [[nodiscard]] virtual eve::Result<void> applyAngularImpulse(float ix, float iy, float iz) = 0;
113 [[nodiscard]] virtual eve::Result<void> applyLocalForce(float fx, float fy, float fz, float x, float y,
114 float z) = 0;
116 [[nodiscard]] virtual eve::Result<void> applyLocalForceToCenter(float fx, float fy, float fz) = 0;
118 [[nodiscard]] virtual eve::Result<void> applyLocalTorque(float tx, float ty, float tz) = 0;
120 [[nodiscard]] virtual eve::Result<void> applyLocalLinearImpulse(float ix, float iy, float iz, float x, float y,
121 float z) = 0;
123 [[nodiscard]] virtual eve::Result<void> applyLocalLinearImpulseToCenter(float ix, float iy, float iz) = 0;
125 [[nodiscard]] virtual eve::Result<void> applyLocalAngularImpulse(float ix, float iy, float iz) = 0;
127 [[nodiscard]] virtual eve::Result<void> setTargetTransform(float x, float y, float z, float qx, float qy, float qz,
128 float qw, float timeStep) = 0;
130 [[nodiscard]] virtual eve::Result<void> setLinearDamping(float damping) = 0;
132 [[nodiscard]] virtual eve::Result<float> getLinearDamping() const = 0;
134 [[nodiscard]] virtual eve::Result<void> setAngularDamping(float damping) = 0;
136 [[nodiscard]] virtual eve::Result<float> getAngularDamping() const = 0;
138 [[nodiscard]] virtual eve::Result<void> setGravityScale(float scale) = 0;
140 [[nodiscard]] virtual eve::Result<float> getGravityScale() const = 0;
142 [[nodiscard]] virtual eve::Result<void> setSleepEnabled(bool enabled) = 0;
144 [[nodiscard]] virtual eve::Result<bool> isSleepEnabled() const = 0;
146 [[nodiscard]] virtual eve::Result<void> setSleepThreshold(float threshold) = 0;
148 [[nodiscard]] virtual eve::Result<float> getSleepThreshold() const = 0;
150 [[nodiscard]] virtual eve::Result<void> setMotionLocks(bool linearX, bool linearY, bool linearZ, bool angularX,
151 bool angularY, bool angularZ) = 0;
153 [[nodiscard]] virtual eve::Result<bool> isLinearXLocked() const = 0;
155 [[nodiscard]] virtual eve::Result<bool> isLinearYLocked() const = 0;
157 [[nodiscard]] virtual eve::Result<bool> isLinearZLocked() const = 0;
159 [[nodiscard]] virtual eve::Result<bool> isAngularXLocked() const = 0;
161 [[nodiscard]] virtual eve::Result<bool> isAngularYLocked() const = 0;
163 [[nodiscard]] virtual eve::Result<bool> isAngularZLocked() const = 0;
165 [[nodiscard]] virtual eve::Result<void> setMassProperties(float mass, float centerX, float centerY, float centerZ,
166 float inertiaXX, float inertiaYY, float inertiaZZ,
167 float inertiaXY, float inertiaXZ, float inertiaYZ) = 0;
169 [[nodiscard]] virtual eve::Result<void> resetMassProperties() = 0;
171 [[nodiscard]] virtual eve::Result<float> getInertiaXX() const = 0;
173 [[nodiscard]] virtual eve::Result<float> getInertiaYY() const = 0;
175 [[nodiscard]] virtual eve::Result<float> getInertiaZZ() const = 0;
177 [[nodiscard]] virtual eve::Result<float> getInertiaXY() const = 0;
179 [[nodiscard]] virtual eve::Result<float> getInertiaXZ() const = 0;
181 [[nodiscard]] virtual eve::Result<float> getInertiaYZ() const = 0;
183 [[nodiscard]] virtual eve::Result<float> getLocalCenterX() const = 0;
185 [[nodiscard]] virtual eve::Result<float> getLocalCenterY() const = 0;
187 [[nodiscard]] virtual eve::Result<float> getLocalCenterZ() const = 0;
189 [[nodiscard]] virtual eve::Result<float> getWorldCenterX() const = 0;
191 [[nodiscard]] virtual eve::Result<float> getWorldCenterY() const = 0;
193 [[nodiscard]] virtual eve::Result<float> getWorldCenterZ() const = 0;
195 [[nodiscard]] virtual eve::Result<void> setType(const std::string& bodyType) = 0;
197 [[nodiscard]] virtual eve::Result<std::string> getType() const = 0;
199 [[nodiscard]] virtual eve::Result<void> setFixedRotation(bool fixed) = 0;
201 [[nodiscard]] virtual eve::Result<bool> isFixedRotation() const = 0;
203 [[nodiscard]] virtual eve::Result<void> setActive(bool active) = 0;
205 [[nodiscard]] virtual eve::Result<bool> isActive() const = 0;
207 [[nodiscard]] virtual eve::Result<void> setBullet(bool bullet) = 0;
209 [[nodiscard]] virtual eve::Result<bool> isBullet() const = 0;
211 [[nodiscard]] virtual eve::Result<void> setAwake(bool awake) = 0;
213 [[nodiscard]] virtual eve::Result<bool> isAwake() const = 0;
214};
215} // namespace eve::physics
double z
double y
double x
bool & active
bool awake
float friction
float density
std::array< float, 3 > scale
std::shared_ptr< OceanGpuSpectrum > owner
Move-only, checked operation results for the common layer.
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...
virtual eve::Result< std::vector< float > > worldToLocalVector(float x, float y, float z) const =0
worldToLocalVector; inherits the class lifetime and failure contract. @cost Three scalar values copie...
virtual eve::Result< bool > isAngularXLocked() const =0
isAngularXLocked; inherits the class lifetime and failure contract.
virtual eve::Result< float > getAngularVelocityY() const =0
getAngularVelocityY; inherits the class lifetime and failure contract.
virtual eve::Result< void > resetMassProperties()=0
resetMassProperties; inherits the class lifetime and failure contract.
virtual eve::Result< float > getWorldCenterZ() const =0
getWorldCenterZ; inherits the class lifetime and failure contract.
virtual eve::Result< void > setSleepThreshold(float threshold)=0
setSleepThreshold; inherits the class lifetime and failure contract.
virtual eve::Result< std::vector< float > > localToWorldPoint(float x, float y, float z) const =0
localToWorldPoint; inherits the class lifetime and failure contract. @cost Three scalar values copied...
virtual eve::Result< float > getInertiaXZ() const =0
getInertiaXZ; inherits the class lifetime and failure contract.
virtual void invalidate() noexcept=0
Detaches before its parent world destroys the native body.
virtual eve::Result< void > applyLocalForce(float fx, float fy, float fz, float x, float y, float z)=0
applyLocalForce; inherits the class lifetime and failure contract.
virtual eve::Result< float > getInertiaXX() const =0
getInertiaXX; inherits the class lifetime and failure contract.
virtual ~IBodyBackend3D()=default
virtual eve::Result< bool > isLinearZLocked() const =0
isLinearZLocked; inherits the class lifetime and failure contract.
virtual eve::Result< void > setRotation(float qx, float qy, float qz, float qw)=0
setRotation; inherits the class lifetime and failure contract.
virtual eve::Result< PhysicsVector3D > localToWorldVectorOwned(float x, float y, float z) const =0
localToWorldVectorOwned; inherits the class lifetime and failure contract.
virtual eve::Result< std::vector< float > > getLocalPointVelocity(float x, float y, float z) const =0
getLocalPointVelocity; inherits the class lifetime and failure contract. @cost Three scalar values co...
virtual eve::Result< float > getInertiaYY() const =0
getInertiaYY; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyLinearImpulse(float ix, float iy, float iz)=0
applyLinearImpulse; inherits the class lifetime and failure contract.
virtual eve::Result< float > getZ() const =0
getZ; inherits the class lifetime and failure contract.
virtual eve::Result< std::vector< float > > getWorldPointVelocity(float x, float y, float z) const =0
getWorldPointVelocity; inherits the class lifetime and failure contract. @cost Three scalar values co...
virtual eve::Result< float > getX() const =0
getX; inherits the class lifetime and failure contract.
virtual eve::Result< void > setPosition(float x, float y, float z)=0
setPosition; inherits the class lifetime and failure contract.
virtual eve::Result< bool > isLinearYLocked() const =0
isLinearYLocked; inherits the class lifetime and failure contract.
virtual eve::Result< float > getAngularDamping() const =0
getAngularDamping; inherits the class lifetime and failure contract.
virtual eve::Result< void > setTargetTransform(float x, float y, float z, float qx, float qy, float qz, float qw, float timeStep)=0
setTargetTransform; inherits the class lifetime and failure contract.
virtual eve::Result< float > getAngularVelocityZ() const =0
getAngularVelocityZ; inherits the class lifetime and failure contract.
virtual eve::Result< bool > isActive() const =0
isActive; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyLocalLinearImpulse(float ix, float iy, float iz, float x, float y, float z)=0
applyLocalLinearImpulse; inherits the class lifetime and failure contract.
virtual eve::Result< void > setActive(bool active)=0
setActive; inherits the class lifetime and failure contract.
virtual eve::Result< void > setBullet(bool bullet)=0
setBullet; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyLinearImpulseAt(float ix, float iy, float iz, float x, float y, float z)=0
applyLinearImpulseAt; inherits the class lifetime and failure contract.
virtual eve::Result< float > getY() const =0
getY; inherits the class lifetime and failure contract.
virtual eve::Result< std::string > getType() const =0
getType; inherits the class lifetime and failure contract.
virtual eve::Result< float > getRotZ() const =0
getRotZ; inherits the class lifetime and failure contract.
virtual eve::Result< float > getRotX() const =0
getRotX; inherits the class lifetime and failure contract.
virtual bool isValid() const noexcept=0
Whether the native body remains alive.
virtual eve::Result< bool > isAwake() const =0
isAwake; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyLocalTorque(float tx, float ty, float tz)=0
applyLocalTorque; inherits the class lifetime and failure contract.
virtual eve::Result< std::vector< float > > worldToLocalPoint(float x, float y, float z) const =0
worldToLocalPoint; inherits the class lifetime and failure contract. @cost Three scalar values copied...
virtual eve::Result< void > setAwake(bool awake)=0
setAwake; inherits the class lifetime and failure contract.
virtual eve::Result< bool > isAngularYLocked() const =0
isAngularYLocked; inherits the class lifetime and failure contract.
virtual eve::Result< float > getAngularVelocityX() const =0
getAngularVelocityX; inherits the class lifetime and failure contract.
virtual eve::Result< float > getInertiaZZ() const =0
getInertiaZZ; inherits the class lifetime and failure contract.
virtual eve::Result< void > setLinearVelocity(float vx, float vy, float vz)=0
setLinearVelocity; inherits the class lifetime and failure contract.
virtual eve::Result< void > setMassProperties(float mass, float centerX, float centerY, float centerZ, float inertiaXX, float inertiaYY, float inertiaZZ, float inertiaXY, float inertiaXZ, float inertiaYZ)=0
setMassProperties; inherits the class lifetime and failure contract.
virtual eve::Result< float > getSleepThreshold() const =0
getSleepThreshold; inherits the class lifetime and failure contract.
virtual eve::Result< float > getLocalCenterX() const =0
getLocalCenterX; inherits the class lifetime and failure contract.
virtual eve::Result< void > setAngularDamping(float damping)=0
setAngularDamping; inherits the class lifetime and failure contract.
virtual eve::Result< PhysicsVector3D > getLocalPointVelocityOwned(float x, float y, float z) const =0
getLocalPointVelocityOwned; inherits the class lifetime and failure contract.
virtual eve::Result< PhysicsVector3D > worldToLocalPointOwned(float x, float y, float z) const =0
worldToLocalPointOwned; inherits the class lifetime and failure contract.
virtual eve::Result< float > getLocalCenterY() const =0
getLocalCenterY; inherits the class lifetime and failure contract.
virtual eve::Result< float > getLinearVelocityX() const =0
getLinearVelocityX; inherits the class lifetime and failure contract.
virtual eve::Result< float > getRotW() const =0
getRotW; inherits the class lifetime and failure contract.
virtual eve::Result< PhysicsVector3D > localToWorldPointOwned(float x, float y, float z) const =0
localToWorldPointOwned; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyAngularImpulse(float ix, float iy, float iz)=0
applyAngularImpulse; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyForceAt(float fx, float fy, float fz, float x, float y, float z)=0
applyForceAt; inherits the class lifetime and failure contract.
virtual eve::Result< bool > isFixedRotation() const =0
isFixedRotation; inherits the class lifetime and failure contract.
virtual eve::Result< bool > isLinearXLocked() const =0
isLinearXLocked; inherits the class lifetime and failure contract.
virtual eve::Result< float > getLocalCenterZ() const =0
getLocalCenterZ; inherits the class lifetime and failure contract.
virtual eve::Result< bool > isBullet() const =0
isBullet; inherits the class lifetime and failure contract.
virtual eve::Result< void > setLinearDamping(float damping)=0
setLinearDamping; inherits the class lifetime and failure contract.
virtual eve::Result< void > setFixedRotation(bool fixed)=0
setFixedRotation; inherits the class lifetime and failure contract.
virtual eve::Result< float > getRotY() const =0
getRotY; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyLocalForceToCenter(float fx, float fy, float fz)=0
applyLocalForceToCenter; inherits the class lifetime and failure contract.
virtual eve::Result< float > getInertiaYZ() const =0
getInertiaYZ; inherits the class lifetime and failure contract.
virtual eve::Result< float > getWorldCenterY() const =0
getWorldCenterY; inherits the class lifetime and failure contract.
virtual eve::Result< bool > isAngularZLocked() const =0
isAngularZLocked; inherits the class lifetime and failure contract.
virtual eve::Result< float > getMass() const =0
getMass; inherits the class lifetime and failure contract.
virtual eve::Result< float > getGravityScale() const =0
getGravityScale; inherits the class lifetime and failure contract.
virtual eve::Result< void > setType(const std::string &bodyType)=0
setType; inherits the class lifetime and failure contract.
virtual eve::Result< void > setSleepEnabled(bool enabled)=0
setSleepEnabled; inherits the class lifetime and failure contract.
virtual eve::Result< std::unique_ptr< IShapeBackend3D > > createShape(const ShapeGeometry3D &geometry, float density, float friction, float restitution)=0
Creates and owns one shape for this body; no input references are retained. @cost One geometry cook p...
virtual eve::Result< bool > isSleepEnabled() const =0
isSleepEnabled; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyForce(float fx, float fy, float fz)=0
applyForce; inherits the class lifetime and failure contract.
virtual void bindOwner(Body3D &owner) noexcept=0
Binds its exclusive facade owner for internal attribution, on the simulation thread....
virtual eve::Result< std::vector< float > > localToWorldVector(float x, float y, float z) const =0
localToWorldVector; inherits the class lifetime and failure contract. @cost Three scalar values copie...
virtual eve::Result< float > getLinearVelocityY() const =0
getLinearVelocityY; inherits the class lifetime and failure contract.
virtual eve::Result< float > getLinearDamping() const =0
getLinearDamping; inherits the class lifetime and failure contract.
virtual eve::Result< float > getInertiaXY() const =0
getInertiaXY; inherits the class lifetime and failure contract.
virtual eve::Result< void > setAngularVelocity(float wx, float wy, float wz)=0
setAngularVelocity; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyLocalAngularImpulse(float ix, float iy, float iz)=0
applyLocalAngularImpulse; inherits the class lifetime and failure contract.
virtual eve::Result< float > getLinearVelocityZ() const =0
getLinearVelocityZ; inherits the class lifetime and failure contract.
virtual eve::Result< void > setMotionLocks(bool linearX, bool linearY, bool linearZ, bool angularX, bool angularY, bool angularZ)=0
setMotionLocks; inherits the class lifetime and failure contract.
virtual eve::Result< float > getWorldCenterX() const =0
getWorldCenterX; inherits the class lifetime and failure contract.
virtual void destroy() noexcept=0
Releases the native body idempotently without callbacks; children must be detached first.
virtual eve::Result< void > applyTorque(float tx, float ty, float tz)=0
applyTorque; inherits the class lifetime and failure contract.
virtual eve::Result< void > applyLocalLinearImpulseToCenter(float ix, float iy, float iz)=0
applyLocalLinearImpulseToCenter; inherits the class lifetime and failure contract.
virtual eve::Result< void > setGravityScale(float scale)=0
setGravityScale; inherits the class lifetime and failure contract.
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36
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.