载入中...
搜索中...
未找到
VolumeBrushTool.h
浏览该文件的文档.
1#pragma once
2
3#include "editor/EditorTool.h"
4
5#include <string>
6#include <vector>
7
8namespace eve::editor {
9
10class IBrushFalloff;
11
14 int x = 0;
15 int y = 0;
16 int z = 0;
17 float weight = 0.f;
18};
19
22public:
24 virtual ~IVolumeBrushKernel() = default;
26 virtual void sample(float x, float y, float z, float radius,
27 std::vector<VolumeBrushPoint>& out) const = 0;
28};
29
32public:
34 explicit SphereVolumeBrushKernel(const IBrushFalloff* falloff = nullptr) : falloff_(falloff) {}
36 void setFalloff(const IBrushFalloff* falloff) { falloff_ = falloff; }
38 void sample(float x, float y, float z, float radius,
39 std::vector<VolumeBrushPoint>& out) const override;
40
41private:
42 const IBrushFalloff* falloff_ = nullptr;
43};
44
47public:
49 explicit BoxVolumeBrushKernel(const IBrushFalloff* falloff = nullptr) : falloff_(falloff) {}
51 void setFalloff(const IBrushFalloff* falloff) { falloff_ = falloff; }
53 void sample(float x, float y, float z, float radius,
54 std::vector<VolumeBrushPoint>& out) const override;
55
56private:
57 const IBrushFalloff* falloff_ = nullptr;
58};
59
62public:
64 explicit PaintIntVolumeOperation(int value = 1);
66 void setValue(int value);
68 int value() const { return value_; }
70 std::unique_ptr<IEditCommand> createCommand(IEditableTarget* target,
71 const std::vector<VolumeBrushPoint>& points) const;
72
73private:
74 int value_ = 1;
75};
76
78class VolumeBrushTool final : public IEditorTool {
79public:
81 VolumeBrushTool(std::string id, std::string label);
83 const ToolDescriptor& descriptor() const override { return descriptor_; }
85 void setKernel(const IVolumeBrushKernel* kernel) { kernel_ = kernel; }
89 void setRadius(float radius);
91 float radius() const { return radius_; }
95 void cancel(EditorContext& context) override;
97 void inspect(EditorContext& context, IEditorInspector& inspector) override;
98
99private:
100 bool stamp(EditorContext& context, float x, float y, float z);
101
102 ToolDescriptor descriptor_;
103 const IVolumeBrushKernel* kernel_ = nullptr;
104 const PaintIntVolumeOperation* operation_ = nullptr;
105 float radius_ = 0.5f;
106 bool stroking_ = false;
107 std::vector<VolumeBrushPoint> points_;
108};
109
110} // namespace eve::editor
LogicalId target
ActionParameterOperation operation
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
std::string label
float radius
std::shared_ptr< const std::vector< glm::vec2 > > points
Heightmap stamp
const VegetationPresetContext & context
IEditableTarget public API.
Axis-aligned cubic volume kernel using a non-owning falloff strategy.
void setFalloff(const IBrushFalloff *falloff)
Replace the edge falloff used by later samples.
BoxVolumeBrushKernel(const IBrushFalloff *falloff=nullptr)
Create a box kernel with an optional non-owning falloff.
void sample(float x, float y, float z, float radius, std::vector< VolumeBrushPoint > &out) const override
Sample.
Context supplied by EditorSession to tools.
Definition EditorTool.h:71
Replaceable mapping from normalized distance to brush strength.
Definition BrushKernel.h:36
UI-independent property editor used by tools to expose settings.
Protocol implemented by every editor tool.
Definition EditorTool.h:110
Shape protocol for sparse volume painting.
virtual void sample(float x, float y, float z, float radius, std::vector< VolumeBrushPoint > &out) const =0
Emit weighted integer cells around one center.
virtual ~IVolumeBrushKernel()=default
Releases IVolumeBrushKernel resources.
Paints one integer value into targets exposing IIntVolumeTarget.
void setValue(int value)
Set the value written by subsequent stamps.
int value() const
Return the value written by this operation.
std::unique_ptr< IEditCommand > createCommand(IEditableTarget *target, const std::vector< VolumeBrushPoint > &points) const
Build a reversible command for weighted cells.
Spherical volume kernel using a non-owning falloff strategy.
void sample(float x, float y, float z, float radius, std::vector< VolumeBrushPoint > &out) const override
Sample.
void setFalloff(const IBrushFalloff *falloff)
Replace the radial falloff used by later samples.
SphereVolumeBrushKernel(const IBrushFalloff *falloff=nullptr)
Create a spherical kernel with an optional non-owning falloff.
Generic 3D stroke tool composed from a volume kernel and paint operation.
void setKernel(const IVolumeBrushKernel *kernel)
Replace the volume kernel used by later stamps.
void setOperation(const PaintIntVolumeOperation *operation)
Replace the integer operation used by later stamps.
float radius() const
Return radius in target voxel coordinates.
void inspect(EditorContext &context, IEditorInspector &inspector) override
Inspect.
void cancel(EditorContext &context) override
Cancel.
ToolResponse pointerEvent(EditorContext &context, const EditorPointerEvent &event) override
Pointer event.
void setRadius(float radius)
Set radius in target voxel coordinates.
const ToolDescriptor & descriptor() const override
Descriptor.
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
One weighted integer coordinate emitted by a three-dimensional kernel.