Rumba C++ SDK
BrushSculptPlugin.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2019
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include "Maquina/BrushPlugin.h"
18 
19 namespace maquina
20 {
21 
23 
32 {
33 public:
34 
36 
41  {
42  public:
44  const SparseBufferV3f& delta_points,
45  const BrushPlugin::GeometryData& geometry,
46  const BufferConstM33f& vertex_space,
47  const std::shared_ptr<SceneConst>& reference
48  );
49 
50  // From UserData
51  maquina::StringView type_name() const override
52  {
53  return "BrushSculptUserData";
54  }
55 
57 
60  virtual bool sculpt_callback(gsl::span<Imath::V3f>& /* delta */, bool /* finished */) { return false; };
61 
63  std::shared_ptr<SparseBufferV3f> delta_points;
64 
66  std::vector<Imath::V3f> delta_points_orig;
67 
69  std::vector<Imath::V4f> accum;
70 
73 
75 
77  gsl::span<const Imath::M33f> vertex_space_span;
78 
80 
82  const std::shared_ptr<SceneConst> reference;
83 
85  Imath::V3f input_to_ref(size_t i, const Imath::V3f& l);
86 
88  Imath::V3f ref_to_input(size_t i, const Imath::V3f& l);
89 
91  std::vector<bool> vertex_on_edge;
92  };
93 
94  BrushSculptPlugin(Node* node);
95 
97 
101  virtual std::shared_ptr<BrushSculptUserData> user_data(
102  const SparseBufferV3f& delta_points,
103  const BrushPlugin::GeometryData& geometry,
104  const BufferConstM33f& vertex_space,
105  const std::shared_ptr<SceneConst>& reference
106  ) { return std::make_shared<BrushSculptUserData>(delta_points, geometry, vertex_space, reference); };
107 
109  virtual SceneConst delta_points() { return {}; }
110 
112  virtual void set_delta_points(const SceneConst& /* delta_points */) {}
113 
115  virtual SceneConst vertex_space() { return {}; };
116 
118  virtual SceneConst reference() { return {}; };
119 
121  virtual bool preserve_edges() { return false; }
122 
123  // From ToolPlugin
124  void deactivate() override;
125 
126  // From BrushPlugin
127  void stroke_begin(int modifiers) override;
128  void stroke_update(bool first, bool finished) override;
129 
130 private:
131 
132  void _stroke_init_data(GeometryData& geometry);
133  void _stroke_update(GeometryData& geometry, bool finished);
134 
135  // The edited attributes
136  Scene _delta_points;
137 };
138 
140 {
141  if(vertex_space_span.empty())
142  return l;
143 
144  return mul_dir(l, vertex_space_span[i].inverse());
145 }
146 
148 {
149  if(vertex_space_span.empty())
150  return l;
151 
152  return mul_dir(l, vertex_space_span[i]);
153 }
154 
155 }
const BrushPlugin::GeometryData & geometry
A ref on the GeometryData.
Definition: BrushSculptPlugin.h:72
std::vector< Imath::V3f > delta_points_orig
A copy of the fully expanded delta_points at the stroke start, in reference space.
Definition: BrushSculptPlugin.h:66
std::vector< Imath::V4f > accum
Accumulation buffer of the sculpt (delta*weight, weight)
Definition: BrushSculptPlugin.h:69
V mul_dir(const V &src, const M &m)
A faster alternative to multiply a direction by a 4x4 matrix, ignoring the homogeneous normalization...
Definition: Utils.h:38
MAQUINA_EXPORT Node reference(Node &root, const std::wstring &filepath, const std::string &reference_root_name="")
Reference the content of a file into the project.
Imath::V3f input_to_ref(size_t i, const Imath::V3f &l)
Convert a vertex from the local space to the reference space is ref matrices are available.
Definition: BrushSculptPlugin.h:139
Definition: ImathFrame.h:42
A mutable scene node value.
Definition: Scene.h:214
A readonly buffer for basic types like floats, integers, Imath::V3f, Imath::M44f..
Definition: Buffer.h:40
std::vector< bool > vertex_on_edge
true if the vertex is on an open edge.
Definition: BrushSculptPlugin.h:91
maquina::StringView type_name() const override
Definition: BrushSculptPlugin.h:51
gsl::span< const Imath::M33f > vertex_space_span
Definition: BrushSculptPlugin.h:77
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
virtual SceneConst vertex_space()
Return a scene with for every geometries, an array of vertex space rotation matrices.
Definition: BrushSculptPlugin.h:115
Base class for the sculpt brush plug-ins.
Definition: BrushSculptPlugin.h:31
virtual bool preserve_edges()
Return true if the sculpt weight on edge vertices must be 0 or false if nothing special must be done ...
Definition: BrushSculptPlugin.h:121
Definition: BrushPlugin.h:26
virtual bool sculpt_callback(gsl::span< Imath::V3f > &, bool)
The sculpt callback.
Definition: BrushSculptPlugin.h:60
const std::shared_ptr< SceneConst > reference
The scene node of the reference sculpt object.
Definition: BrushSculptPlugin.h:82
const BufferConstM33f vertex_space
The current vertex spaces.
Definition: BrushSculptPlugin.h:76
virtual SceneConst reference()
Return the reference scene (as it with no modification, no animation)
Definition: BrushSculptPlugin.h:118
#define MAQUINA_EXPORT
Definition: Export.h:31
An immutable scene node value.
Definition: Scene.h:35
virtual std::shared_ptr< BrushSculptUserData > user_data(const SparseBufferV3f &delta_points, const BrushPlugin::GeometryData &geometry, const BufferConstM33f &vertex_space, const std::shared_ptr< SceneConst > &reference)
Create a BrushSculptUserData object for a geometry.
Definition: BrushSculptPlugin.h:101
A writable SparseBuffer.
Definition: SparseBuffer.h:47
virtual void set_delta_points(const SceneConst &)
Set delta points to the deformer.
Definition: BrushSculptPlugin.h:112
Definition: UserData.h:26
The base sculpt brush data.
Definition: BrushSculptPlugin.h:40
Definition: BrushPlugin.h:169
Imath::V3f ref_to_input(size_t i, const Imath::V3f &l)
Convert a vertex from the local space to the reference space is ref matrices are available.
Definition: BrushSculptPlugin.h:147
virtual SceneConst delta_points()
Get the current delta points from the deformer.
Definition: BrushSculptPlugin.h:109
Base class of all Rumba nodes.
Definition: Node.h:36