载入中...
搜索中...
未找到
SceneRegions.cpp
浏览该文件的文档.
2#include <set>
5namespace eve::scene_editing {
7 using Value = editing::Value;
8 const auto* root = snapshot.getIf<Value::Object>();
9 const auto* sources = root && root->contains("sources") ? root->at("sources").getIf<Value::Object>() : nullptr;
10 if (!sources || !sources->contains(object.value()) || !sources->at(object.value()).getIf<Value::Object>())
11 return editing::failed<std::string>(editing::Status::NotFound, editing::RuleId("scene.region.source"),
12 "Region geometry requires an authored source");
13 const auto& source = *sources->at(object.value()).getIf<Value::Object>();
15 for (const auto* key : {"kind", "seed", "mesh_params", "path", "revision"})
16 if (source.contains(key)) geometry[key] = source.at(key);
17 return editing::applied<std::string>("eve.scene.geometry-recipe/1:" + editing::editorValueToJson(geometry));
18}
19editing::Result<editing::Value::Array> sceneVisibilityTargets(const std::vector<SceneRelation>& relations,
20 const editing::Value& snapshot) {
21 using Value = editing::Value;
23 std::set<std::pair<std::string, std::string>> seen;
24 for (const auto& relation : relations) {
25 const bool occludes =
27 if (!occludes && relation.kind != SceneRelationKind::VisibleFraction) continue;
28 const auto& object = occludes ? relation.reference : relation.subject;
29 if (relation.region) {
32 if (revision.value() != relation.region->geometryRevision)
33 return editing::failed<Value::Array>(
34 editing::Status::Conflict, editing::RuleId("scene.region.stale"),
35 "Region geometry revision changed; explicitly rebind the region before preview");
36 }
37 if (relation.kind == SceneRelationKind::ProjectedOverlap && seen.emplace(relation.subject.value(), "").second)
38 targets.emplace_back(relation.subject.value());
39 if (!seen.emplace(object.value(), relation.region ? relation.region->id : "").second) continue;
40 if (relation.region)
41 targets.emplace_back(Value::Object{{"object", object.value()},
42 {"region", editing::toEditingValue(relation.region->toValue())}});
43 else
44 targets.emplace_back(object.value());
45 }
46 return editing::applied<Value::Array>(std::move(targets));
47}
48} // namespace eve::scene_editing
int root
Definition AnimSmr.cpp:119
std::uint64_t revision
SQObjectPtr key
Definition ECS.cpp:155
std::vector< FieldTarget > targets
std::int32_t second
std::string relation
Snapshot snapshot
std::vector< std::pair< std::uint64_t, OceanBoatReceipt > > sources
Object::Ptr value
std::string geometry
std::string_view source
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
Deterministic owning value tree shared by authoring hosts.
std::vector< Value > Array
std::map< std::string, Value > Object
std::string editorValueToJson(const EditorValue &value)
Serialize an EditorValue to deterministic compact JSON.
Value toEditingValue(const eve::Value &value)
To editing value.
editing::Result< editing::Value::Array > sceneVisibilityTargets(const std::vector< SceneRelation > &relations, const editing::Value &snapshot)
Build bounded raster targets and reject regions whose source geometry changed. @thread Owner thread; ...
editing::Result< std::string > sceneGeometryRevision(const editing::Value &snapshot, const editing::ObjectId &object)
Derive a stable geometry recipe revision from the authoritative document source. @thread Owner thread...