载入中...
搜索中...
未找到
LocationProfile.cpp
浏览该文件的文档.
35 output = static_cast<float>(found->second.isDouble() ? found->second.asDouble() : found->second.asInt());
70 return Result<void>::failure(Diagnostic::error({}, "location poses must be finite", "scene.locationProfile"));
78 Diagnostic::error(DiagnosticCode::NotFound, "no saved startup location", "scene.locationProfile"));
85 if (bookmark.name.empty() || !finite(bookmark.camera) || (bookmark.player && !finite(*bookmark.player)))
91 Diagnostic::error(DiagnosticCode::Conflict, "bookmark name already exists", "scene.locationProfile"));
99 return Result<void>::failure(Diagnostic::error({}, "bookmark index is out of range", "scene.locationProfile"));
101 return Result<void>::failure(Diagnostic::error({}, "bookmark poses must be finite", "scene.locationProfile"));
112 if (index < 0 || index >= getBookmarkCount() || selectedIndex < 0 || selectedIndex >= getBookmarkCount())
133 Diagnostic::error(DiagnosticCode::NotFound, "location profile has no bookmarks", "scene.locationProfile"));
135 return Result<int>::failure(Diagnostic::error({}, "selection index is out of range", "scene.locationProfile"));
142 Diagnostic::error(DiagnosticCode::NotFound, "location profile has no bookmarks", "scene.locationProfile"));
144 return Result<int>::failure(Diagnostic::error({}, "selection index is out of range", "scene.locationProfile"));
175 bookmarks.emplace_back(Value::Object{{"name", bookmark.name}, {"camera", poseValue(bookmark.camera)},
190 Diagnostic::error(DiagnosticCode::ParseError, "invalid location profile schema", "scene.locationProfile"));
192 if (!root || !onlyFields(*root, {"schemaId", "schemaVersion", "saved", "bookmarks"})) return fail();
207 if (!object || !onlyFields(*object, {"name", "camera", "player", "controller", "scene"})) return fail();
208 const auto name=object->find("name"), camera=object->find("camera"), player=object->find("player");
217 if (!player->second.isNull()) { LocationPose pose; if (!parsePose(player->second,pose)) return fail(); bookmark.player=pose; }
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
Result< std::string > toJson() const
Serialize this value as deterministic compact JSON.
Definition Value.cpp:67
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
Caller-owned Pcg location and bookmark state. Mutable operations validate complete candidate data bef...
Definition LocationProfile.h:40
Result< std::string > serializeJson() const
Serialize schema eve.scene.location-profile version 1 as deterministic JSON.
Definition LocationProfile.cpp:171
Result< std::string > getBookmarkController(int index) const
Copy a bookmark controller name, or return InvalidArgument for an invalid index.
Definition LocationProfile.cpp:158
Result< int > addBookmark(LocationBookmark bookmark)
Add a uniquely named bookmark and return its index.
Definition LocationProfile.cpp:84
Result< int > removeBookmark(int index, int selectedIndex)
Remove one bookmark and return Pcg's adjusted selected index.
Definition LocationProfile.cpp:111
Result< std::string > getBookmarkName(int index) const
Copy a bookmark name, or return InvalidArgument for an invalid index.
Definition LocationProfile.cpp:152
Result< int > nextBookmark(int selectedIndex) const
Return the next wrapped selection, or NotFound for an empty profile.
Definition LocationProfile.cpp:139
Result< void > saveLocation(const LocationPose &camera, const std::optional< LocationPose > &player=std::nullopt)
Save the one-shot startup location, replacing the previous value atomically.
Definition LocationProfile.cpp:66
const LocationBookmark * bookmarkAt(int index) const noexcept
Borrow one bookmark.
Definition LocationProfile.cpp:148
Result< void > overrideBookmark(int index, const LocationSnapshot &snapshot, std::string controller, std::string scene)
Replace one bookmark while preserving its existing name.
Definition LocationProfile.cpp:96
Result< LocationSnapshot > loadLocation()
Consume the startup location and clear hasSaved exactly once, matching Pcg LoadLocation.
Definition LocationProfile.cpp:75
Result< std::string > getBookmarkScene(int index) const
Copy a bookmark scene name, or return InvalidArgument for an invalid index.
Definition LocationProfile.cpp:164
Result< void > restoreJson(std::string_view json)
Atomically restore schema version 1 JSON.
Definition LocationProfile.cpp:184
Result< LocationSnapshot > loadBookmark(int index) const
Copy a bookmark transform snapshot.
Definition LocationProfile.cpp:122
Result< int > previousBookmark(int selectedIndex) const
Return the previous wrapped selection, or NotFound for an empty profile.
Definition LocationProfile.cpp:130
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
Definition AvatarInstance.h:33
@ NotFound
@ ParseError
@ Conflict
One named Pcg location bookmark with optional player transform metadata.
Definition LocationProfile.h:22
std::optional< LocationPose > player
Definition LocationProfile.h:25
Provider-neutral position and quaternion stored by Pcg's location profile.
Definition LocationProfile.h:16
std::optional< LocationPose > player
Definition LocationProfile.h:33