载入中...
搜索中...
未找到
FluidsEditorModule.cpp
浏览该文件的文档.
2
3#include "common/Capability.h"
7
8#include <simplesquirrel/simplesquirrel.hpp>
9
10#include <string_view>
11#include <utility>
12#include <vector>
13
15namespace {
16
17template <class Target>
20 auto target = std::make_unique<Target>(id.value());
21 const auto snapshot = request.find("snapshot");
22 if (snapshot != request.end()) {
23 auto loaded = target->loadSnapshot(snapshot->second);
24 if (!loaded.ok()) {
26 }
27 }
29 owned.target = std::move(target);
30 return eve::editing::applied<editor::AutomationOwnedTarget>(std::move(owned));
31}
32
33} // namespace
34
35std::vector<std::string_view> FluidsAutomationTargetFactory::types() const {
36 return {"fluid-simulation", "surface-fluid", "volume-fluid"};
37}
38
40 const editor::TargetId& target, std::string_view type, const editor::EditorValue::Object& request) {
41 if (type == "fluid-simulation") {
42 return makeTarget<fluids_editing::FluidSimulationTarget>(target, request);
43 }
44 if (type == "surface-fluid") {
45 return makeTarget<fluids_editing::SurfaceFluidTarget>(target, request);
46 }
47 if (type == "volume-fluid") {
48 return makeTarget<fluids_editing::VolumeFluidTarget>(target, request);
49 }
50 return eve::editing::failed<editor::AutomationOwnedTarget>(editor::EditorStatus::Unsupported,
51 editor::RuleId("editor.fluids.target-type"),
52 "Unsupported fluid editor target type");
53}
54
56
58 eve::cap::addListener<editor::IEditorAutomationTargetFactory>(factory_.get());
59}
60
62 eve::cap::removeListener<editor::IEditorAutomationTargetFactory>(factory_.get());
63}
64
65void FluidsEditorModule::expose(ssq::Table& table) { table.addClass(name, FluidsEditorModule::create, false); }
66
67void FluidsEditorModule::expose(ssq::Class&) {}
68
69} // namespace eve::fluids_editor
LogicalId target
double value
ActiveSource owned
const GltfImportRequest & request
std::string name
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
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
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. @ownership Owns the registere...
~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