载入中...
搜索中...
未找到
SplinePathBinder.cpp
浏览该文件的文档.
42SplinePathBinder::SplinePathBinder(std::string documentTarget) : documentTarget_(std::move(documentTarget)) {}
44Result<void> SplinePathBinder::bindResult(const SplinePathDocument& document, const StableId& point, std::string host,
47 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.spline.binding-target-mismatch"),
51 std::none_of(points.begin(), points.end(), [&](const auto& value) { return value.id == point; }))
52 return eve::editing::failed<void>(EditorStatus::NotFound, RuleId("editor.spline.binding-point-missing"),
55 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.spline.binding-identity-empty"),
67 return eve::editing::failed<void>(EditorStatus::NotFound, RuleId("editor.spline.binding-not-found"),
75 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.spline.binding-target-mismatch"),
83 return eve::editing::failed<void>(EditorStatus::Conflict, RuleId("editor.spline.binding-point-stale"),
89 if (!std::isfinite(pose.value().x) || !std::isfinite(pose.value().y) || !std::isfinite(pose.value().z))
90 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.spline.binding-pose-invalid"),
138 return eve::editing::failed<void>(EditorStatus::Unsupported, RuleId("editor.spline.binding-schema-unsupported"),
141 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.spline.binding-snapshot-invalid"),
152 !candidate.emplace(StableId(*point), SplinePointBinding{StableId(*point), *host, *object}).second)
153 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.spline.binding-snapshot-invalid"),
166editing::GizmoSnapshot failedSnapshot(const SplinePathDocument& document, const char* rule, std::string message) {
170 result.diagnostics.push_back(editing::ruleDiagnostic(DiagnosticCode::InvalidArgument, RuleId(rule),
175std::array<double, 3> position(const SplinePathControlPoint& point) { return {point.x, point.y, point.z}; }
181 std::sqrt(direction[0] * direction[0] + direction[1] * direction[1] + direction[2] * direction[2]);
184 output.primitives.push_back({std::move(id), "line", from, {}, direction, color, 0.0, length, dashed});
196editing::GizmoSnapshot SplinePathGizmoBuilder::build(const SplinePathDocument& document, int sampleCount,
205 if (!std::isfinite(style.nodeSize) || !std::isfinite(style.handleSize) || style.nodeSize <= 0.0 ||
215 {"spline.anchor." + point.id.value(), "sphere", anchor, {}, {}, {1.0, 0.72, 0.18, 1.0}, style.nodeSize});
226 const std::array<double, 3> incoming{point.x + point.inX, point.y + point.inY, point.z + point.inZ};
227 const std::array<double, 3> outgoing{point.x + point.outX, point.y + point.outY, point.z + point.outZ};
228 addLine(result, "spline.in-line." + point.id.value(), anchor, incoming, {0.95, 0.4, 0.3, 0.9}, true);
229 addLine(result, "spline.out-line." + point.id.value(), anchor, outgoing, {0.35, 0.9, 0.45, 0.9}, true);
231 {"spline.in." + point.id.value(), "sphere", incoming, {}, {}, {0.95, 0.4, 0.3, 1.0}, style.handleSize});
233 {"spline.out." + point.id.value(), "sphere", outgoing, {}, {}, {0.35, 0.9, 0.45, 1.0}, style.handleSize});
246 if (!polyline.ok()) return failedSnapshot(document, "editor.spline.gizmo-evaluate", polyline.status().describe());
255 addLine(result, "spline.chunk." + std::to_string(chunk) + ".segment." + std::to_string(sample - 1),
288Result<SplinePathDragPreview> SplinePathDragSession::beginDrag(double rayOriginX, double rayOriginY, double rayOriginZ,
294 EditorStatus::Rejected, RuleId("editor.spline.drag-target-required"), "Spline drag target is unavailable");
310 const std::array<double, 3> offset{origin[0] - primitive.position[0], origin[1] - primitive.position[1],
312 const double b = offset[0] * direction[0] + offset[1] * direction[1] + offset[2] * direction[2];
314 offset[0] * offset[0] + offset[1] * offset[1] + offset[2] * offset[2] - primitive.radius * primitive.radius;
327 EditorStatus::NotFound, RuleId("editor.spline.handle-not-hit"), "Pointer ray did not hit a spline handle");
333 std::find_if(points.begin(), points.end(), [&](const auto& point) { return point.id == activePoint_; });
336 EditorStatus::NotFound, RuleId("editor.spline.point-not-found"), "Picked spline point no longer exists");
344Result<SplinePathDragPreview> SplinePathDragSession::updateDrag(double rayOriginX, double rayOriginY, double rayOriginZ,
352 return eve::editing::failed<SplinePathDragPreview>(EditorStatus::Conflict, RuleId("editor.spline.drag-stale"),
362 direction[0] * dragPlaneNormal_[0] + direction[1] * dragPlaneNormal_[1] + direction[2] * dragPlaneNormal_[2];
395 return eve::editing::failed<DomainOperation>(EditorStatus::Rejected, RuleId("editor.spline.drag-not-active"),
399 return eve::editing::failed<DomainOperation>(EditorStatus::Conflict, RuleId("editor.spline.drag-stale"),
std::array< std::uint64_t, kPixelChunkSize *kPixelChunkSize > updated
Definition PixelWorld.cpp:53
virtual Result< SceneNodeInfo > getNodeIn(const std::string &host, const std::string &id) const =0
Look up one node in a named host.
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:514
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
const std::string & value() const noexcept
Returns the exact legacy or canonical compatibility spelling.
Definition Identity.h:365
Deterministic owning value tree shared by authoring hosts.
Definition EditingValue.h:23
Consumer-owned transform lookup contract used by spline binding.
Definition SplinePathBinder.h:21
Result< SplineBindingPose > resolve(const std::string &host, const std::string &object) const override
Resolve.
Definition SplinePathBinder.cpp:27
Result< void > loadSnapshot(const EditorValue &snapshot)
Atomically restore links for this binder's pinned target.
Definition SplinePathBinder.cpp:128
Result< void > bindResult(const SplinePathDocument &document, const StableId &point, std::string host, std::string object, const ISplineBindingTransformSource &source)
Validate and atomically install or replace one point binding.
Definition SplinePathBinder.cpp:44
EditorValue snapshotValue() const
Capture schema eve.procgen.splineBinder version one.
Definition SplinePathBinder.cpp:116
Result< void > refreshResult(SplinePathDocument &document, const ISplineBindingTransformSource &source) const
Resolve every link, then commit all point positions as one isolated document update.
Definition SplinePathBinder.cpp:72
Result< void > unbindResult(const StableId &point)
Remove one binding without touching its spline point.
Definition SplinePathBinder.cpp:65
std::vector< SplinePointBinding > bindings() const
Return deterministic bindings ordered by stable point id.
Definition SplinePathBinder.cpp:106
SplinePathBinder(std::string documentTarget)
Construct a binder pinned to one spline document target identity.
Definition SplinePathBinder.cpp:42
Owning spline authoring document with transactional operations and schema-versioned snapshots.
Definition SplinePathDocument.h:91
Result< DomainOperation > makeSetPoint(const SplinePathControlPoint &point) const override
Make set point.
Definition SplinePathDocument.cpp:481
Result< void > commitDomainState(std::unique_ptr< IDomainOperationTarget > candidate) override
Commits domain state.
Definition SplinePathDocument.cpp:472
std::vector< SplinePathControlPoint > points() const
Return points in deterministic order and stable-id tie order.
Definition SplinePathDocument.cpp:517
Result< void > applyDomainOperation(const DomainOperation &operation) override
Applies domain operation.
Definition SplinePathDocument.cpp:141
Result< procgen::SplinePath > compilePath() const
Compile an owning runtime spline without retaining document references.
Definition SplinePathDocument.cpp:530
const SplinePathSettings & settings() const noexcept
Return current interpolation and closure settings.
Definition SplinePathDocument.h:146
Result< SplinePathDragPreview > updateDrag(double rayOriginX, double rayOriginY, double rayOriginZ, double rayDirectionX, double rayDirectionY, double rayDirectionZ)
Project a pointer ray onto the original camera-facing drag plane and update only the draft.
Definition SplinePathBinder.cpp:344
void cancelDrag()
Discard transient state without changing the document.
Definition SplinePathBinder.cpp:407
Result< DomainOperation > finishDrag()
Produce one reversible point replacement operation without applying it.
Definition SplinePathBinder.cpp:393
SplinePathDragSession(SplinePathDocument *document, int sampleCount=64)
Create an idle session borrowing an authoritative spline document.
Definition SplinePathBinder.cpp:265
Result< SplinePathDragPreview > beginDrag(double rayOriginX, double rayOriginY, double rayOriginZ, double rayDirectionX, double rayDirectionY, double rayDirectionZ)
Pick the nearest anchor or Bezier handle sphere intersected by a world ray.
Definition SplinePathBinder.cpp:288
Builds sampled path, anchor and Bezier handle overlay primitives.
Definition SplinePathGizmo.h:30
editing::GizmoSnapshot build(const SplinePathDocument &document, int sampleCount=64, int maximumSamples=4096, SplineGizmoStyle style={}) const
Build an immutable overlay with bounded path sampling.
Definition SplinePathBinder.cpp:196
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Definition BuildingSnapshot.cpp:96
Diagnostic ruleDiagnostic(eve::DiagnosticCode code, RuleId rule, DiagnosticSeverity severity, std::string message)
Build an owning common diagnostic carrying an open editing rule identity.
Definition EditingResult.cpp:20
Definition HeightmapBrush.h:9
@ InvalidArgument
@ PreconditionViolation
Definition Container.h:602
Serializable snapshot of one scene node (value type, no scene types).
Definition SceneQuery.h:18
Renderer-neutral wire primitive for authoring viewport overlays.
Definition EditingGizmo.h:12
Immutable revision-tagged overlay snapshot consumed by any viewport renderer.
Definition EditingGizmo.h:27
Renderer-neutral appearance settings for spline viewport overlays.
Definition SplinePathGizmo.h:12
bool showPointLabels
Definition SplinePathGizmo.h:17
std::array< double, 4 > textColor
Definition SplinePathGizmo.h:16
std::array< double, 4 > lineColor
Definition SplinePathGizmo.h:15
Immutable renderer-neutral spline drag preview.
Definition SplinePathGizmo.h:21
EditorStatus status
Definition SplinePathGizmo.h:22
Persistent link from one spline control point to one scene transform identity.
Definition SplinePathBinder.h:44