载入中...
搜索中...
未找到
BoneCollider.cpp
浏览该文件的文档.
2
3#include <cmath>
4
6
8 if (colliderId.empty())
10 Diagnostic::error(DiagnosticCode::InvalidArgument, "bone collider id is empty", "colliderId"));
11 if (boneName.empty())
13 Diagnostic::error(DiagnosticCode::InvalidArgument, "bone collider bone name is empty", "boneName"));
14 if (!std::isfinite(radius) || radius < 0.f)
16 Diagnostic::error(DiagnosticCode::InvalidArgument, "bone collider radius is invalid", "radius"));
17 if (!std::isfinite(localOffset.x) || !std::isfinite(localOffset.y) || !std::isfinite(localOffset.z))
19 "bone collider local offset is invalid", "localOffset"));
20 if (!std::isfinite(endLocalOffset.x) || !std::isfinite(endLocalOffset.y) ||
21 !std::isfinite(endLocalOffset.z))
23 DiagnosticCode::InvalidArgument, "bone collider end local offset is invalid", "endLocalOffset"));
24 if (maxHits < 1)
26 Diagnostic::error(DiagnosticCode::InvalidArgument, "bone collider maxHits must be >= 1", "maxHits"));
27 if (ignoredBodyId < -1)
29 "bone collider ignoredBodyId is invalid", "ignoredBodyId"));
30
32 if (!endBoneName.empty())
34 DiagnosticCode::InvalidArgument, "sphere collider cannot declare an end bone", "endBoneName"));
35 if (halfHeight != 0.f)
37 DiagnosticCode::InvalidArgument, "sphere collider cannot declare halfHeight", "halfHeight"));
38 return Result<void>::success();
39 }
40
43 Diagnostic::error(DiagnosticCode::InvalidArgument, "bone collider shape kind is invalid", "kind"));
44
45 if (endBoneName.empty()) {
46 if (!std::isfinite(halfHeight) || halfHeight < 0.f)
48 DiagnosticCode::InvalidArgument, "capsule halfHeight is invalid", "halfHeight"));
49 } else if (halfHeight != 0.f) {
51 DiagnosticCode::InvalidArgument, "dual-socket capsule cannot declare halfHeight", "halfHeight"));
52 }
53 return Result<void>::success();
54}
55
56} // namespace eve::physics::trajectory
Authoring definitions for bone-bound collision proxies (UE5 Physics Asset style).
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
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
std::string endBoneName
Optional second attachment for dual-socket capsules. Empty means a single-bone capsule axis along loc...
std::string colliderId
Stable catalog id (e.g. weapon.blade, hand.L).
Result< void > validate() const
Reject empty ids, non-finite dimensions, or inconsistent shape fields.
std::string boneName
Primary / start attachment name resolved by IAttachmentPointSource.
int maxHits
Maximum World3D cast results retained per armed collider per frame.
float halfHeight
Half-length along local +Y for single-bone capsules; ignored otherwise.
AttachmentPoint localOffset
Local offset on boneName (sphere center or capsule start/center).
float radius
Non-negative finite collision radius in meters.
int ignoredBodyId
Optional body id ignored by sweeps (-1 = none).
AttachmentPoint endLocalOffset
Local offset on endBoneName for dual-socket capsules.