载入中...
搜索中...
未找到
Joint3D.h
浏览该文件的文档.
1#pragma once
2#include <array>
3#include "common/Export.h"
4#include "common/Result.h"
5
6
8
9#include <memory>
11
12#include <string>
13
14namespace eve::physics {
15namespace box3d {
16struct Access;
17}
18namespace box3d {
19class WorldBackend;
20}
21
22class Body3D;
23class World3D;
24
25
28public:
35
37 Joint3D(World3D *world, Body3D *bodyA, Body3D *bodyB, std::unique_ptr<IJointBackend3D> backend,
38 PhysicsJointHandle runtimeHandle, Kind kind, int id);
39 ~Joint3D();
40
41 Joint3D(const Joint3D &) = delete;
42 Joint3D &operator=(const Joint3D &) = delete;
43
45 int getId() const { return id_; }
47 [[nodiscard]] PhysicsJointHandle runtimeHandle() const noexcept { return runtimeHandle_; }
49 std::string getKind() const;
51 int getBodyAId() const;
53 int getBodyBId() const;
55 [[nodiscard]] World3D *getWorld() const noexcept { return world_; }
64 [[nodiscard]] eve::Result<JointFrames3D> localFrames() const;
65
67 void setCollideConnected(bool collide);
69 bool getCollideConnected() const;
71 void setForceThreshold(float threshold);
73 float getForceThreshold() const;
75 void setTorqueThreshold(float threshold);
77 float getTorqueThreshold() const;
78
80 float getConstraintForceX() const;
82 float getConstraintForceY() const;
84 float getConstraintForceZ() const;
86 float getConstraintTorqueX() const;
88 float getConstraintTorqueY() const;
90 float getConstraintTorqueZ() const;
92 float getLinearSeparation() const;
94 float getAngularSeparation() const;
95
97 void setDistanceLength(float length);
99 float getDistanceLength() const;
101 float getDistanceCurrentLength() const;
103 void setDistanceSpring(bool enabled, float hertz, float dampingRatio);
105 void setDistanceLimits(bool enabled, float minimum, float maximum);
107 void setDistanceMotor(bool enabled, float speed, float maxForce);
108
110 void setRevoluteSpring(bool enabled, float targetAngle, float hertz, float dampingRatio);
112 void setRevoluteLimits(bool enabled, float lower, float upper);
114 void setRevoluteMotor(bool enabled, float speed, float maxTorque);
116 float getRevoluteAngle() const;
118 float getRevoluteMotorTorque() const;
119
121 void setPrismaticSpring(bool enabled, float targetTranslation, float hertz,
122 float dampingRatio);
124 void setPrismaticLimits(bool enabled, float lower, float upper);
126 void setPrismaticMotor(bool enabled, float speed, float maxForce);
128 float getPrismaticTranslation() const;
130 float getPrismaticSpeed() const;
132 float getPrismaticMotorForce() const;
133
135 void setSphericalConeLimit(bool enabled, float angle);
137 void setSphericalTwistLimits(bool enabled, float lower, float upper);
139 void setSphericalMotor(bool enabled, float velocityX, float velocityY, float velocityZ,
140 float maxTorque);
142 float getSphericalConeAngle() const;
144 float getSphericalTwistAngle() const;
145
147 void setWheelSuspension(bool enabled, float hertz, float dampingRatio);
149 void setWheelSuspensionLimits(bool enabled, float lower, float upper);
151 void setWheelSpinMotor(bool enabled, float speed, float maxTorque);
153 void setWheelSteering(bool enabled, float targetAngle, float hertz, float dampingRatio,
154 float maxTorque);
156 void setWheelSteeringLimits(bool enabled, float lower, float upper);
158 float getWheelSpinSpeed() const;
160 float getWheelSpinTorque() const;
162 float getWheelSteeringAngle() const;
164 float getWheelSteeringTorque() const;
165
167 void setWeldLinearSpring(float hertz, float dampingRatio);
169 void setWeldAngularSpring(float hertz, float dampingRatio);
171 float getWeldLinearHertz() const;
173 float getWeldLinearDampingRatio() const;
175 float getWeldAngularHertz() const;
177 float getWeldAngularDampingRatio() const;
178
180 void setMotorLinearVelocity(float vx, float vy, float vz);
182 void setMotorAngularVelocity(float wx, float wy, float wz);
184 void setMotorVelocityLimits(float maxForce, float maxTorque);
186 void setMotorLinearSpring(float hertz, float dampingRatio, float maxForce);
188 void setMotorAngularSpring(float hertz, float dampingRatio, float maxTorque);
190 float getMotorLinearVelocityX() const;
192 float getMotorLinearVelocityY() const;
194 float getMotorLinearVelocityZ() const;
196 float getMotorAngularVelocityX() const;
198 float getMotorAngularVelocityY() const;
200 float getMotorAngularVelocityZ() const;
201
203 void setParallelSpring(float hertz, float dampingRatio, float maxTorque);
205 float getParallelHertz() const;
207 float getParallelDampingRatio() const;
209 float getParallelMaxTorque() const;
210
212 void destroy();
214 bool isValid() const;
216 void invalidate();
217
218private:
219 friend struct box3d::Access;
221 friend struct WorldSnapshotAccess;
223 friend class Body3D;
224 friend class World3D;
225
226 World3D *world_ = nullptr;
227 Body3D *bodyA_ = nullptr;
228 Body3D *bodyB_ = nullptr;
229 std::unique_ptr<IJointBackend3D> backend_{};
230 PhysicsJointHandle runtimeHandle_ = PhysicsJointHandle::invalid();
231 Kind kind_ = Kind::Distance;
232 int id_ = 0;
233};
234
235} // namespace eve::physics
#define EVENGINE_API_WORLD
Definition Export.h:109
float maxForce
float maximum[3]
float minimum[3]
void(* destroy)(void *)
float dampingRatio
float length
OceanRenderBackend backend
Process-local, generation-qualified handles owned by the physics domain.
Move-only, checked operation results for the common layer.
std::string kind
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
Script-facing joint owned by a World3D. Legacy scalar/void methods adapt the checked backend contract...
Definition Joint3D.h:27
Joint3D(const Joint3D &)=delete
PhysicsJointHandle runtimeHandle() const noexcept
Process-local generation-qualified handle owned by World3D.
Definition Joint3D.h:47
int getId() const
Stable world-local identifier.
Definition Joint3D.h:45
World3D * getWorld() const noexcept
Owning world, or null after joint destruction.
Definition Joint3D.h:55
Joint3D & operator=(const Joint3D &)=delete
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36
JointKind3D
Stable constraint kinds; numeric values are used by stress events.
bool enabled
Private bridge used exclusively by Box3D composition and native query code.
Definition Box3DBody.h:15