载入中...
搜索中...
未找到
voxel_editor.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
10
11#include <simplesquirrel/simplesquirrel.hpp>
12
13#include <stdexcept>
14#include <string>
15#include <string_view>
16#include <utility>
17#include <vector>
18
20namespace {
21
22const editor::EditorValue* field(const editor::EditorValue::Object& request, const char* key) {
23 const auto found = request.find(key);
24 return found == request.end() ? nullptr : &found->second;
25}
26
27} // namespace
28
30public:
31 std::vector<std::string_view> types() const override { return {"voxel-catalog", "voxel-model"}; }
32
34 const editor::TargetId& target, std::string_view, const editor::EditorValue::Object& request) override {
35 auto catalog = std::make_unique<voxel_editing::VoxelCatalogTarget>(target.value());
36 if (const editor::EditorValue* snapshot = field(request, "snapshot")) {
37 auto loaded = catalog->loadSnapshot(*snapshot);
38 if (!loaded.ok())
40 }
42 owned.target = std::move(catalog);
43 return eve::editing::applied<editor::AutomationOwnedTarget>(std::move(owned));
44 }
45};
46
48
50 auto* registry = eve::cap::query<editing::IEditingCommandRegistry>();
51 if (!registry || !voxel_editing::registerEditingCommands(*registry).ok())
52 throw std::runtime_error("Failed to register voxel editing commands");
53 eve::cap::addListener<editor::IEditorAutomationTargetFactory>(factory_.get());
54}
55
57 eve::cap::removeListener<editor::IEditorAutomationTargetFactory>(factory_.get());
58 if (auto* registry = eve::cap::query<editing::IEditingCommandRegistry>())
59 registry->unregisterOwner("voxel_editing").ignore("voxel editor adapter shutdown");
60}
61
62void VoxelEditorModule::expose(ssq::Table& table) {
63 auto module = table.addClass(name, VoxelEditorModule::create, false);
65}
66void VoxelEditorModule::expose(ssq::Class&) {}
67
68} // namespace eve::voxel_editor
LogicalId target
ActiveSource owned
const GltfImportRequest & request
std::uint32_t key
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
bool found
Squirrel adapter for the MagicaVoxel-style sculpt editor.
MagicaVoxel-style sculpted models: bounded occupancy grids and hull sockets.
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
Deterministic owning value tree shared by authoring hosts.
std::map< std::string, Value > Object
Multi-provider extension point for domain-specific automation target creation.
editor::Result< editor::AutomationOwnedTarget > create(const editor::TargetId &target, std::string_view, const editor::EditorValue::Object &request) override
Create a domain target from an automation request. @ownership Success transfers the target and any su...
std::vector< std::string_view > types() const override
Stable target type names this factory accepts.
Composition adapter that contributes MagicaVoxel-style sculpt commands and automation targets.
~VoxelEditorModule() override
Voxel editor module.
VoxelEditorModule()
Voxel editor module.
editing::Result< void > registerEditingCommands(editing::IEditingCommandRegistry &registry)
Register voxel-catalog planned commands with a generic editing host.
void exposeVoxelCatalogEditorScriptBindings(ssq::Table &table, ssq::Class &moduleClass)
Expose the script-owned VoxelCatalogEditor factory on VoxelEditorModule.
Target plus optional borrowed-dependency owner returned by an automation factory.
std::unique_ptr< IEditableTarget > target