载入中...
搜索中...
未找到
TargetingLineOfSightAdapter.cpp
浏览该文件的文档.
18 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "Physics LOS cannot register a null World3D"));
21 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "Physics LOS cannot register an invalid World3D"));
29 if (it->world == world) return eve::Result<void>::success(eve::Status::success(eve::StatusCode::NoOp));
40 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "Physics LOS cannot remove a null World3D"));
47eve::Result<sensing::LineOfSightResult> TargetingLineOfSightAdapter::query(const sensing::TargetLocation& from,
55 eve::DiagnosticCode::Unsupported, "Physics LOS supports only two valid World3D points in the same space"));
57 if (!std::isfinite(fromPoint->x()) || !std::isfinite(fromPoint->y()) || !std::isfinite(fromPoint->z()) ||
60 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "Physics LOS points must be finite"));
76 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "Physics LOS has no valid active World3D"));
78 activeWorld->rayCast(fromPoint->x(), fromPoint->y(), fromPoint->z(), toPoint->x(), toPoint->y(), toPoint->z());
80 return eve::Result<sensing::LineOfSightResult>::success(sensing::LineOfSightResult{false, std::nullopt});
81 return eve::Result<sensing::LineOfSightResult>::success(sensing::LineOfSightResult{true, std::nullopt});
Physics-to-sensing line-of-sight capability adapter.
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
Result< void > removeWorld(World3D *world)
Removes a previously registered world; repeated removal is a NoOp.
Definition TargetingLineOfSightAdapter.cpp:37
Result< sensing::LineOfSightResult > query(const sensing::TargetLocation &from, const sensing::TargetLocation &to) const override
Tests the segment between two same-space locations.
Definition TargetingLineOfSightAdapter.cpp:47
Result< void > addWorld(World3D *world)
Registers a borrowed live World3D as the sole active LOS world.
Definition TargetingLineOfSightAdapter.cpp:15
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:63
int rayCast(float x1, float y1, float z1, float x2, float y2, float z2)
Closest raycast from (x1,y1,z1) to (x2,y2,z2) in meters. Returns hit body id, or -1....
Definition World3D.cpp:1332
std::variant< WorldPoint, GridPoint > TargetLocation
Either a world point or a grid point, with the tag retained.
Definition Targeting.h:198
@ InvalidArgument
@ NotFound
@ Unsupported
@ Conflict
@ NoOp
@ Applied
Result of one injected line-of-sight query.
Definition Targeting.h:417