载入中...
搜索中...
未找到
Rope3DCollision.cpp
浏览该文件的文档.
13Rope3D::Vec3 subtract(Rope3D::Vec3 a, Rope3D::Vec3 b) { return {a.x - b.x, a.y - b.y, a.z - b.z}; }
15Rope3D::Vec3 multiply(Rope3D::Vec3 value, float scale) { return {value.x * scale, value.y * scale, value.z * scale}; }
18bool finite(Rope3D::Vec3 value) { return std::isfinite(value.x) && std::isfinite(value.y) && std::isfinite(value.z); }
33eve::Result<RopeColliderId> Rope3D::addSphereCollider(float x, float y, float z, float colliderRadius) {
36 eve::DiagnosticCode::InvalidArgument, "Sphere position and radius must be finite and radius positive",
44 return eve::Result<RopeColliderId>::success(collider.id, eve::Status::success(eve::StatusCode::Applied));
47eve::Result<RopeColliderId> Rope3D::addPlaneCollider(float x, float y, float z, float nx, float ny, float nz) {
60 return eve::Result<RopeColliderId>::success(collider.id, eve::Status::success(eve::StatusCode::Applied));
63eve::Result<RopeColliderChange> Rope3D::moveSphereCollider(RopeColliderId id, float x, float y, float z) {
65 return eve::Result<RopeColliderChange>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
86 eve::DiagnosticCode::InvalidArgument, "Collider id must be valid", "physics.rope3d.collider.remove"));
139 world_->castSphere(particle.previous.x, particle.previous.y, particle.previous.z, radius_, sweep.x,
142 normal = {world_->getShapeCastNormalX(), world_->getShapeCastNormalY(), world_->getShapeCastNormalZ()};
150 if (world_->pointProbe(predicted.x, predicted.y, predicted.z, radius_, &contact) && contact.hit) {
162 sdf_->castSphere(particle.previous.x, particle.previous.y, particle.previous.z, radius_, sweep.x,
181 bodyVelocity = {body->getLinearVelocityX(), body->getLinearVelocityY(), body->getLinearVelocityZ()};
190 std::min(-(1.f + collisionRestitution_) * relativeNormalSpeed * reducedMass, particleMass_ * 20.f);
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
float getNormalZ() const
Z component of the most recently sampled collision normal.
Definition DistanceField3D.h:75
float getNormalX() const
X component of the most recently sampled collision normal.
Definition DistanceField3D.h:71
bool castSphere(float x, float y, float z, float radius, float deltaX, float deltaY, float deltaZ)
Sweep a sphere through the field and cache the earliest contact.
Definition DistanceField3D.cpp:265
float getNormalY() const
Y component of the most recently sampled collision normal.
Definition DistanceField3D.h:73
float getCastFraction() const
Fraction in [0,1] of the requested displacement at the last cast hit.
Definition DistanceField3D.h:147
bool checkSphere(float x, float y, float z, float radius)
Test a sphere against the solid (distance <= radius).
Definition DistanceField3D.cpp:203
float getPenetrationDepth() const
Non-negative overlap depth from the most recent overlap, cast, or move query.
Definition DistanceField3D.h:145
eve::Result< RopeColliderId > addSphereCollider(float x, float y, float z, float radius)
Adds a sphere collider owned by this rope.
Definition Rope3DCollision.cpp:33
void setCollisionRestitution(float restitution)
Sets particle/world normal restitution in [0,1].
Definition Rope3DCollision.cpp:27
eve::Result< RopeColliderChange > removeCollider(RopeColliderId id)
Removes a rope-owned analytic collider.
Definition Rope3DCollision.cpp:83
void setCollisionFriction(float friction)
Sets tangential contact damping in [0,1].
Definition Rope3DCollision.cpp:21
eve::Result< RopeColliderChange > moveSphereCollider(RopeColliderId id, float x, float y, float z)
Moves a previously created sphere without changing its radius.
Definition Rope3DCollision.cpp:63
eve::Result< RopeColliderId > addPlaneCollider(float x, float y, float z, float nx, float ny, float nz)
Adds a one-sided plane collider using a normalized outward normal.
Definition Rope3DCollision.cpp:47
float getShapeCastX() const
World-space contact point X from the last shape cast.
Definition World3D.h:690
int castSphere(float x, float y, float z, float radius, float dx, float dy, float dz)
Sweep a sphere through the world and return the earliest hit body id, or -1.
Definition World3D.cpp:1788
float getShapeCastZ() const
World-space contact point Z from the last shape cast.
Definition World3D.h:694
int getShapeCastBodyId() const
Stable body id from the last shape cast, or -1.
Definition World3D.h:680
float getShapeCastY() const
World-space contact point Y from the last shape cast.
Definition World3D.h:692
float getShapeCastFraction() const
Translation fraction in [0,1] at the earliest hit.
Definition World3D.h:702
Body3D * findBodyById(int bodyId) const
Resolves a live body by its world-local stable event/query id.
Definition World3D.cpp:926
bool pointProbe(float x, float y, float z, float radius, ClothContact3D *out) const
Probe the deepest non-sensor shape within radius of a meter-space point. Returns false when nothing i...
Definition World3D.cpp:2080
@ Unchanged
@ InvalidArgument
@ NotFound
@ Conflict
@ Applied
Stable identifier for a rope-owned analytic collider.
Definition Rope3D.h:19