载入中...
搜索中...
未找到
FluidsEditorModule.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
9
10#include <simplesquirrel/simplesquirrel.hpp>
11
12#include <string_view>
13#include <utility>
14#include <vector>
15
17namespace {
18
19template <class Target>
22 auto target = std::make_unique<Target>(id.value());
23 const auto snapshot = request.find("snapshot");
24 if (snapshot != request.end()) {
25 auto loaded = target->loadSnapshot(snapshot->second);
26 if (!loaded.ok()) {
28 }
29 }
31 owned.target = std::move(target);
32 return eve::editing::applied<editor::AutomationOwnedTarget>(std::move(owned));
33}
34
35} // namespace
36
37std::vector<std::string_view> FluidsAutomationTargetFactory::types() const {
38 return {"fluid-simulation", "surface-fluid", "volume-fluid"};
39}
40
42 const editor::TargetId& target, std::string_view type, const editor::EditorValue::Object& request) {
43 if (type == "fluid-simulation") {
44 return makeTarget<fluids_editing::FluidSimulationTarget>(target, request);
45 }
46 if (type == "surface-fluid") {
47 return makeTarget<fluids_editing::SurfaceFluidTarget>(target, request);
48 }
49 if (type == "volume-fluid") {
50 return makeTarget<fluids_editing::VolumeFluidTarget>(target, request);
51 }
52 return eve::editing::failed<editor::AutomationOwnedTarget>(editor::EditorStatus::Unsupported,
53 editor::RuleId("editor.fluids.target-type"),
54 "Unsupported fluid editor target type");
55}
56
58
60 : factory_(std::make_unique<FluidsAutomationTargetFactory>()),
61 packageProvider_(std::make_unique<FluidsEditorPackageProvider>()) {
62 eve::cap::addListener<editor::IEditorAutomationTargetFactory>(factory_.get());
63 eve::cap::addListener<editing::IEditorPackageProvider>(packageProvider_.get());
64}
65
67 eve::cap::removeListener<editing::IEditorPackageProvider>(packageProvider_.get());
68 eve::cap::removeListener<editor::IEditorAutomationTargetFactory>(factory_.get());
69}
70
71void FluidsEditorModule::expose(ssq::Table& table) { table.addClass(name, FluidsEditorModule::create, false); }
72
73void FluidsEditorModule::expose(ssq::Class&) {}
74
75} // namespace eve::fluids_editor
LogicalId target
ActiveSource owned
std::string name
Definition ECS.cpp:154
const GltfImportRequest & request
Snapshot snapshot
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:27
std::unordered_set< std::string > loaded
Definition Plugins.cpp:24
Object::Ptr value
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
std::map< std::string, Value > Object
Creates schema-driven fluid documents for editor automation. @ownership Returned targets own their au...
std::vector< std::string_view > types() const override
Accepted fluid target type names (simulation, surface, volume).
editor::Result< editor::AutomationOwnedTarget > create(const editor::TargetId &target, std::string_view type, const editor::EditorValue::Object &request) override
Create a fluid document and optionally load its strict snapshot request field.
Composition adapter that publishes the fluid automation-target factory and EditorPackage....
~FluidsEditorModule() override
Releases FluidsEditorModule resources.
FluidsEditorModule()
Constructs a FluidsEditorModule.
Target plus optional borrowed-dependency owner returned by an automation factory.
std::unique_ptr< IEditableTarget > target