载入中...
搜索中...
未找到
FieldBrushTool.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6#include "editor/EditorTool.h"
7
8#include <memory>
9
10namespace eve::editor {
11
14public:
16 virtual ~IFieldBrushOperation() = default;
17
19 virtual std::unique_ptr<IEditCommand> createCommand(IEditableTarget *target,
20 const BrushSampleBuffer &samples,
21 float strength) const = 0;
22};
23
26public:
28 explicit PaintIntFieldOperation(int value = 1) : value_(value) {}
30 void setValue(int value) { value_ = value; }
32 int value() const { return value_; }
34 std::unique_ptr<IEditCommand> createCommand(IEditableTarget *target,
35 const BrushSampleBuffer &samples,
36 float strength) const override;
37private:
38 int value_ = 1;
39};
40
43public:
45 std::unique_ptr<IEditCommand> createCommand(IEditableTarget *target,
46 const BrushSampleBuffer &samples,
47 float strength) const override;
48};
49
56public:
58 FieldBrushTool(std::string id, std::string label, const IBrushKernel *kernel,
61 const ToolDescriptor &descriptor() const override { return descriptor_; }
63 void setKernel(const IBrushKernel *kernel) { kernel_ = kernel; }
67 void setRadius(float radius);
69 void setStrength(float strength) { strength_ = strength; }
71 float radius() const { return radius_; }
73 float strength() const { return strength_; }
74
76 ToolResponse pointerEvent(EditorContext &context, const EditorPointerEvent &event) override;
78 void cancel(EditorContext &context) override;
80 void drawOverlay(EditorContext &context, IEditorOverlay &overlay) override;
82 void inspect(EditorContext &context, IEditorInspector &inspector) override;
83
84private:
85 bool stamp(EditorContext &context, float x, float y);
86
87 ToolDescriptor descriptor_;
88 const IBrushKernel *kernel_ = nullptr;
89 const IFieldBrushOperation *operation_ = nullptr;
90 float radius_ = 1.f;
91 float strength_ = 1.f;
92 float cursorX_ = 0.f;
93 float cursorY_ = 0.f;
94 bool stroking_ = false;
95 BrushSampleBuffer samples_;
96};
97
98} // namespace eve::editor
LogicalId target
ActionParameterOperation operation
double value
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
std::string label
#define EVENGINE_API_ORCHESTRATION
Definition Export.h:111
float radius
Heightmap stamp
const VegetationPresetContext & context
IEditableTarget public API.
Adds weighted strength to targets exposing IScalarFieldTarget.
Convenience sink for previews, tests and command construction.
Context supplied by EditorSession to tools.
Definition EditorTool.h:71
Generic stroke tool composed from a brush kernel and field operation.
const ToolDescriptor & descriptor() const override
Descriptor.
float radius() const
Radius.
float strength() const
Strength.
void setStrength(float strength)
Set the operation strength; negative values are permitted.
void setKernel(const IBrushKernel *kernel)
Replace the shape/falloff implementation used by later stamps.
void setOperation(const IFieldBrushOperation *operation)
Replace the edit semantics used by later stamps.
Shape protocol shared by tile, terrain, mask and custom tools.
Definition BrushKernel.h:66
UI-independent property editor used by tools to expose settings.
Sink implemented by a 2D or 3D viewport to render tool feedback.
Protocol implemented by every editor tool.
Definition EditorTool.h:110
Replaceable operation that converts brush samples into a command.
virtual ~IFieldBrushOperation()=default
Releases IFieldBrushOperation resources.
virtual std::unique_ptr< IEditCommand > createCommand(IEditableTarget *target, const BrushSampleBuffer &samples, float strength) const =0
Create one reversible command, or nullptr for an incompatible target.
Paints a fixed integer into targets exposing IIntFieldTarget.
int value() const
Return the integer written by this operation.
PaintIntFieldOperation(int value=1)
Paint int field operation.
void setValue(int value)
Change the integer written by subsequent stamps.
Pointer input normalized by an editor viewport adapter.
Definition EditorTool.h:20
UI-facing metadata supplied by a tool implementation.
Definition EditorTool.h:98
Result returned by a tool after processing input.
Definition EditorTool.h:50