载入中...
搜索中...
未找到
PrefabBoundsCatalog.cpp
浏览该文件的文档.
3namespace eve::asset_graphics {
5 auto bounds = prefab.localBounds();
6 if (!bounds.ok()) return Result<void>::failure(bounds.status());
8 if (!placement.ok()) return Result<void>::failure(placement.status());
9 if (prefab.sourceBuildId().isNil())
11 Diagnostic::error(DiagnosticCode::InvalidArgument, "prefab package build identity must not be nil"));
12 const VersionKey key{prefab.sourceAsset().id(), prefab.sourceBuildId()};
13 if (entries_.contains(key))
15 Diagnostic::error(DiagnosticCode::Conflict, "prefab bounds identity is already admitted"));
16 if (entries_.size() >= 4096)
18 Diagnostic::error(DiagnosticCode::PreconditionViolation, "prefab bounds catalogue budget exceeded"));
19 entries_.emplace(key, std::array{bounds.value(), placement.value()});
20 return Result<void>::success();
21}
23 PrefabRootPose rootPose) const {
25 return Result<std::array<float, 6>>::failure(
26 Diagnostic::error(DiagnosticCode::InvalidArgument, "unknown prefab root pose"));
27 const auto found = entries_.find({asset.id(), build});
28 if (found != entries_.end())
29 return Result<std::array<float, 6>>::success(found->second[static_cast<unsigned>(rootPose)]);
30 const auto firstVersion = entries_.lower_bound({asset.id(), PersistentId{}});
31 if (firstVersion == entries_.end() || firstVersion->first.first != asset.id())
32 return Result<std::array<float, 6>>::failure(
33 Diagnostic::error(DiagnosticCode::NotFound, "prefab bounds identity is not admitted"));
34 return Result<std::array<float, 6>>::failure(
35 Diagnostic::error(DiagnosticCode::Conflict, "prefab bounds package build is stale"));
36}
37} // namespace eve::asset_graphics
std::string prefab
SQObjectPtr key
Definition ECS.cpp:155
Placement placement
std::string build
bool found
Stable asset identity backed by PersistentId.
Definition ResourceRef.h:53
const PersistentId & id() const noexcept
Return the stable asset identity.
Definition ResourceRef.h:65
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Owning static-prefab GPU leases and immutable draw transforms; no ECS or Scene mutation....
Result< void > add(const EvpackStaticPrefab &prefab)
Admit one loaded prefab snapshot, including its verified package build identity.
Result< std::array< float, 6 > > localBounds(const AssetRef &asset, const PersistentId &build, PrefabRootPose rootPose=PrefabRootPose::Authored) const override
Resolve prefab-local min XYZ/max XYZ at an exact admitted package build identity.
Id128 public API.
Definition Identity.h:111
PrefabRootPose
Immutable prefab placement convention shared by geometry bounds and renderer preparation....
glm::vec4 bounds