载入中...
搜索中...
未找到
MeshModifierEditor.cpp
浏览该文件的文档.
2
4
5#include <utility>
6
8namespace {
9procgen_editing::Result<void> rejected(const char* rule, const char* message) {
10 return eve::editing::failed<void>(procgen_editing::EditorStatus::Rejected,
12}
13}
15
17 if (targetId_.empty()) return rejected("editor.mesh-modifier.target", "Mesh modifier target id is empty");
18 editor::EditorWorkspace candidate = workspace;
19 struct Panel { const char* id; const char* title; const char* region; const char* context; int order; };
20 constexpr Panel panels[] = {
21 {"meshModifier.graph", "Modifier Graph", "left", "graph", 100},
22 {"meshModifier.viewport", "Mesh Preview", "center", "mesh-preview", 100},
23 {"meshModifier.inspector", "Modifier Inspector", "right", "inspector", 100},
24 {"meshModifier.spline", "Spline", "bottom", "spline", 100},
25 {"meshModifier.sculpt", "Sculpt & Damage", "bottom", "sculpt", 110},
26 {"meshModifier.uvPaint", "UV Paint", "bottom", "uv-paint", 120},
27 {"meshModifier.merge", "Static Merge", "bottom", "merge", 130},
28 {"meshModifier.adhere", "Dynamic Adhere", "bottom", "adhere", 140},
29 };
30 for (const auto& panel : panels) {
31 editor::WorkspacePanelDescriptor descriptor{panel.id, panel.title, panel.region, "procgen.mesh-modifier",
32 panel.context, panel.order, true, true};
33 auto added = candidate.registerPanel(std::move(descriptor));
34 if (!added.ok()) return rejected("editor.mesh-modifier.workspace-conflict", "Could not install mesh modifier workspace");
35 }
36 auto activated = candidate.activatePanel(editor::StableId("meshModifier.viewport"));
37 if (!activated.ok()) return rejected("editor.mesh-modifier.workspace-activate", "Could not activate mesh preview");
38 auto selected = candidate.selectItem("meshModifier", {editor::SelectionDomain::Asset, editor::TargetId(targetId_),
39 editor::StableId(targetId_), "mesh"}, false);
40 if (!selected.ok()) return rejected("editor.mesh-modifier.workspace-selection", "Could not select mesh target");
41 workspace = std::move(candidate);
42 return eve::editing::applied<void>();
43}
44
46 std::string tool) {
47 std::string panel;
48 if (tool == "graph") panel = "meshModifier.graph";
49 else if (tool == "spline") panel = "meshModifier.spline";
50 else if (tool == "sculpt") panel = "meshModifier.sculpt";
51 else if (tool == "uvPaint") panel = "meshModifier.uvPaint";
52 else if (tool == "merge") panel = "meshModifier.merge";
53 else if (tool == "adhere") panel = "meshModifier.adhere";
54 else return rejected("editor.mesh-modifier.tool", "Unknown mesh modifier tool");
55 editor::EditorWorkspace candidate = workspace;
56 auto activated = candidate.activatePanel(editor::StableId(panel));
57 if (!activated.ok()) return rejected("editor.mesh-modifier.tool-panel", "Mesh modifier tool panel is unavailable");
58 auto mode = candidate.setModeId(editor::StableId("meshModifier." + tool));
59 if (!mode.ok()) return rejected("editor.mesh-modifier.tool-mode", "Could not set mesh modifier tool mode");
60 auto focus = candidate.focusItem("meshModifier", editor::StableId(panel), editor::StableId(targetId_));
61 if (!focus.ok()) return rejected("editor.mesh-modifier.tool-focus", "Could not focus mesh modifier tool");
62 workspace = std::move(candidate); activeTool_ = std::move(tool);
63 return eve::editing::applied<void>();
64}
65
67 std::uint64_t* destination = nullptr;
68 if (document == "graph") destination = &graphRevision_;
69 else if (document == "spline") destination = &splineRevision_;
70 else if (document == "mesh") destination = &meshRevision_;
71 else if (document == "paint") destination = &paintRevision_;
72 else return rejected("editor.mesh-modifier.document", "Unknown mesh modifier document");
73 if (revision < *destination) return rejected("editor.mesh-modifier.stale-revision", "Document revision cannot move backwards");
74 *destination = revision;
75 return eve::editing::applied<void>();
76}
77} // namespace eve::procgen_editor
std::string descriptor
std::string title
std::string message
std::vector< std::int32_t > order
std::uint64_t revision
std::string id
Definition PlayHost.cpp:108
std::uint32_t targetId
const VegetationPresetContext & context
Move-only operation result carrying either a value or Status.
Definition Result.h:155
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
Composition model shared by project-specific developer and runtime editors.
Result< EditorFocusSnapshot > focusItem(const std::string &channel, StableId surface, StableId item)
Focus a strongly identified surface and item without discarding diagnostics.
Result< SelectionSnapshot > selectItem(std::string channel, SelectionItem item, bool additive)
Select one already typed item without string domain parsing.
Result< WorkspacePanelDescriptor > registerPanel(WorkspacePanelDescriptor descriptor)
Register a checked owning panel descriptor.
Result< WorkspacePanelDescriptor > activatePanel(const StableId &id)
Activate a visible panel with structured not-found/rejected results.
Result< StableId > setModeId(StableId mode)
Set a strongly identified workspace mode.
procgen_editing::Result< void > configureWorkspace(editor::EditorWorkspace &workspace) const
Atomically install the complete mesh-modifier panel composition.
procgen_editing::Result< void > observeRevision(std::string document, std::uint64_t revision)
Observe an externally owned document revision without copying its state.
procgen_editing::Result< void > activateTool(editor::EditorWorkspace &workspace, std::string tool)
Activate graph, spline, sculpt, uvPaint, merge, or adhere and update semantic focus.
MeshModifierEditor(std::string targetId)
Construct a controller for one mesh document.
eve::editing::StableId StableId
Definition EditorIds.h:36
eve::editing::TargetId TargetId
Definition EditorIds.h:29
UI-neutral description of one composable editor panel.