Rumba C++ SDK
maquina::BrushSculpt Class Reference

#include <BrushSculpt.h>

Inheritance diagram for maquina::BrushSculpt:
maquina::BrushSculptPlugin maquina::BrushPlugin maquina::ToolPlugin maquina::NodePlugin

Public Types

enum  Operation {
  Operation::pull = 0, Operation::inflate, Operation::smooth_vertices, Operation::smooth_delta,
  Operation::relax, Operation::reset, Operation::flatten, Operation::pinch,
  Operation::grab, Operation::mirror, Operation::transfer, Operation::count
}
 
enum  SetBrushAttribute {
  SetBrushAttribute::none = 0, SetBrushAttribute::radius, SetBrushAttribute::amount, SetBrushAttribute::smoothness,
  SetBrushAttribute::flow
}
 
- Public Types inherited from maquina::BrushPlugin
enum  BrushType { BrushType::surface = 0, BrushType::geodesic, BrushType::volume, BrushType::fill }
 The different brush types. More...
 

Public Member Functions

 BrushSculpt (Node *node)
 
void on_mouse_move (const CameraContext &camera, const InteractionContext &interaction) final
 
void on_mouse_press (const CameraContext &camera, const InteractionContext &interaction) final
 
void on_mouse_release (const CameraContext &camera, const InteractionContext &interaction) final
 
void activate ()
 From ToolPlugin. More...
 
void deactivate ()
 
Array get_help (const char *tool) final
 
Array get_status (const char *tool) final
 
bool on_key_press (int32_t key, int32_t modifiers) final
 Called when a key is pressed while the tool is active. More...
 
bool on_key_release (int32_t key, int32_t modifiers) final
 Called when a key is released while the tool is active. More...
 
void stroke_begin (int modifiers)
 Called when the stroke is beginning. More...
 
void update_brush_matrix (const CameraContext &camera, const InteractionContext &interaction, bool &visible, Imath::M44f &brush_matrix, bool on_press) final
 Update the brush position and visibility. More...
 
void update_weights (bool first, const Imath::M44f &) final
 Update the brush weights. More...
 
float weight (float distance) final
 Convert a distance in weight. More...
 
float flow () final
 Get the brush accumulation flow. More...
 
std::shared_ptr< BrushSculptUserDatauser_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. More...
 
SceneConst delta_points () const
 Get the current delta points from the deformer. More...
 
void set_delta_points (const SceneConst &)
 Set delta points to the deformer. More...
 
SceneConst vertex_space () final
 Return a scene with for every geometries, an array of vertex space rotation matrices. More...
 
SceneConst reference () final
 Return the reference scene (as it with no modification, no animation) More...
 
bool preserve_edges () final
 Return true if the sculpt weight on edge vertices must be 0 or false if nothing special must be done on edges. More...
 
Operation operation (bool *invert=nullptr) const
 
- Public Member Functions inherited from maquina::BrushSculptPlugin
 BrushSculptPlugin (Node *node)
 
void deactivate () override
 
void stroke_begin (int modifiers) override
 Called when the stroke is beginning. More...
 
void stroke_update (bool first, bool finished) override
 Called when the brush moves or have been released. More...
 
- Public Member Functions inherited from maquina::BrushPlugin
 BrushPlugin (Node *node)
 
BrushPlugin operator= (const BrushPlugin &)=delete
 
bool override_selection () override
 
bool track_mouse () override
 
bool manipulates () override
 
virtual bool do_update_weights ()
 Does the weights have to be updated at every stroke_update() ? More...
 
virtual float radius ()
 Get the brush radius. More...
 
void set_radius (float radius)
 Set the brush radius. More...
 
virtual bool multi_objects ()
 Get the multi objects state. More...
 
virtual float geodesic_dt ()
 Get the geodesic dt. More...
 
virtual SceneConst scene ()
 Get the displayed scene. More...
 
virtual BrushType brush_type ()
 Get the brush type. More...
 
gsl::span< GeometryDatageometry_data ()
 Return the brush's geometry data. More...
 
Imath::V3f hit_pos_world () const
 Return the brush position in world space. More...
 
const Imath::V3fhit_normal_world () const
 Return the brush normal in world space. More...
 
Imath::V3f hit_pos_world_orig () const
 Returns the world space brush position at the beginning of the stroke. More...
 
const Imath::V3fhit_normal_world_orig () const
 Return the brush normal in world space at the beginning of the stroke. More...
 
const Imath::M44fbrush_matrix () const
 Return the brush matrix which transforms from the brush local space to the world space. More...
 
const Imath::M44fbrush_matrix_orig () const
 Return the brush matrix which transforms from the brush local space to the world space at the beginning of the stroke. More...
 
bool is_brush_visible () const
 Returns true is the brush is visible. More...
 
bool is_pressed () const
 Returns true is the brush is pressed by the user. More...
 
- Public Member Functions inherited from maquina::ToolPlugin
 ToolPlugin (Node *node)
 
- Public Member Functions inherited from maquina::NodePlugin
 NodePlugin (Node *node)
 
virtual ~NodePlugin ()
 
virtual void on_first_init (bool)
 Perform the one shot initialization tasks for this node. More...
 
virtual void on_delete (bool)
 Prepare the node to be deleted. More...
 
virtual void on_add_to_document ()
 Callback called when the node is added to the document. More...
 
virtual void on_remove_from_document ()
 Callback called when the node is removed from the document. More...
 
virtual void on_input_connection (const Plug &, const Plug &, bool)
 Callback called when an a connection has been done between an output plug and a plug of this node as input. More...
 
virtual void on_output_connection (const Plug &, const Plug &, bool)
 Callback called when an a connection has been done between a plug of this node as output and an input plug. More...
 
virtual void on_input_disconnection (const Plug &, const Plug &)
 Callback called when an a connection has been broken between an output plug and a plug of this node as input. More...
 
virtual void on_output_disconnection (const Plug &, const Plug &)
 Callback called when an a connection has been broken between a plug of this node as output and an input plug. More...
 
virtual void relationship (NodeSet &set) const
 Return the node relationships. More...
 
virtual std::shared_ptr< NodeDelegatenode_delegate () const
 Return a node delegate for this node. More...
 
virtual std::optional< Plugchannel_switch_output () const
 If that not is a channel switch node, return the output channel plug. More...
 
virtual std::vector< Plugchannel_switch_inputs () const
 Return the input channel plugs. More...
 
virtual std::optional< Plugchannel_switch_sub_channel (const std::string_view &sub_channel) const
 Return the plug for the sub channel name if available. More...
 
Node node () const
 Returns the Node interface for this object. More...
 
virtual std::string selection_path () const
 Returns the node delegate path to use to select that node. More...
 

Protected Attributes

int _modifiers
 
std::string _input_path
 
std::string _source_path
 
Imath::M44d _source_matrix
 
Imath::M44d _source_matrix_inv
 
Mesh _source_mesh
 
BufferV3i _source_topo
 
std::vector< uint32_t > _source_tri_to_face
 
SpanSpan< const uint32_t, const uint32_t > _source_topo_face
 
BVHTriangle _source_bvh_triangle
 
SparseBufferConstV3f _source_sculpt_data = SparseBufferConstV3f::default_value
 

Friends

class ::TransferSculptGeometryUserData
 

Member Enumeration Documentation

◆ Operation

Enumerator
pull 
inflate 
smooth_vertices 
smooth_delta 
relax 
reset 
flatten 
pinch 
grab 
mirror 
transfer 
count 

◆ SetBrushAttribute

Enumerator
none 
radius 
amount 
smoothness 
flow 

Constructor & Destructor Documentation

◆ BrushSculpt()

maquina::BrushSculpt::BrushSculpt ( Node node)

Member Function Documentation

◆ activate()

void maquina::BrushSculpt::activate ( )
virtual

From ToolPlugin.

Reimplemented from maquina::BrushPlugin.

◆ deactivate()

void maquina::BrushSculpt::deactivate ( )
virtual

Reimplemented from maquina::BrushPlugin.

◆ delta_points()

SceneConst maquina::BrushSculpt::delta_points ( ) const
virtual

Get the current delta points from the deformer.

Reimplemented from maquina::BrushSculptPlugin.

◆ flow()

float maquina::BrushSculpt::flow ( )
finalvirtual

Get the brush accumulation flow.

The flow value must be between ]0, 1].

The flow control how fast the accumulation buffer saturates to one along the strokes. A value of 1 fill the accumulation buffer after a single stroke.

A value close to 0 fill the accumulation buffer slowly.

The default implementation returns the value of the flow plug.

Called by BrushPlugin. To be implemented by the plug-in.

Reimplemented from maquina::BrushPlugin.

◆ get_help()

Array maquina::BrushSculpt::get_help ( const char *  tool)
finalvirtual

Reimplemented from maquina::ToolPlugin.

◆ get_status()

Array maquina::BrushSculpt::get_status ( const char *  tool)
finalvirtual

Reimplemented from maquina::ToolPlugin.

◆ on_key_press()

bool maquina::BrushSculpt::on_key_press ( int32_t  key,
int32_t  modifiers 
)
finalvirtual

Called when a key is pressed while the tool is active.

Returns true if the key event is accepted. The key code is a Qt::Key enum.

Reimplemented from maquina::ToolPlugin.

◆ on_key_release()

bool maquina::BrushSculpt::on_key_release ( int32_t  key,
int32_t  modifiers 
)
finalvirtual

Called when a key is released while the tool is active.

Returns true if the key event is accepted. The key code is a Qt::Key enum.

Reimplemented from maquina::ToolPlugin.

◆ on_mouse_move()

void maquina::BrushSculpt::on_mouse_move ( const CameraContext camera,
const InteractionContext interaction 
)
finalvirtual

Reimplemented from maquina::BrushPlugin.

◆ on_mouse_press()

void maquina::BrushSculpt::on_mouse_press ( const CameraContext camera,
const InteractionContext interaction 
)
finalvirtual

Reimplemented from maquina::BrushPlugin.

◆ on_mouse_release()

void maquina::BrushSculpt::on_mouse_release ( const CameraContext camera,
const InteractionContext interaction 
)
finalvirtual

Reimplemented from maquina::BrushPlugin.

◆ operation()

Operation maquina::BrushSculpt::operation ( bool *  invert = nullptr) const

◆ preserve_edges()

bool maquina::BrushSculpt::preserve_edges ( )
finalvirtual

Return true if the sculpt weight on edge vertices must be 0 or false if nothing special must be done on edges.

Reimplemented from maquina::BrushSculptPlugin.

◆ reference()

SceneConst maquina::BrushSculpt::reference ( )
finalvirtual

Return the reference scene (as it with no modification, no animation)

Reimplemented from maquina::BrushSculptPlugin.

◆ set_delta_points()

void maquina::BrushSculpt::set_delta_points ( const SceneConst )
virtual

Set delta points to the deformer.

Reimplemented from maquina::BrushSculptPlugin.

◆ stroke_begin()

void maquina::BrushSculpt::stroke_begin ( int  modifiers)
virtual

Called when the stroke is beginning.

Called by BrushPlugin::on_mouse_move. To be implemented by the plug-in.

Reimplemented from maquina::BrushPlugin.

◆ update_brush_matrix()

void maquina::BrushSculpt::update_brush_matrix ( const CameraContext camera,
const InteractionContext interaction,
bool &  visible,
Imath::M44f brush_matrix,
bool  on_press 
)
finalvirtual

Update the brush position and visibility.

The plug-in can override the default behavior to specify custom brush matrix and visibility state.

The default implementation computes a brush matrix by intersecting the editable geometries. Visible is set to true in case an intersection has been found, false otherwise.

Called by BrushPlugin. To be implemented by the plug-in.

Reimplemented from maquina::BrushPlugin.

◆ update_weights()

void maquina::BrushSculpt::update_weights ( bool  first,
const Imath::M44f previous_brush_matrix 
)
finalvirtual

Update the brush weights.

A plug-in can override this call to pre-compute data before the weight() calls.

Called by BrushPlugin::on_mouse_press and BrushPlugin::on_mouse_move. To be implemented by the plug-in.

Reimplemented from maquina::BrushPlugin.

◆ user_data()

std::shared_ptr<BrushSculptUserData> maquina::BrushSculpt::user_data ( const SparseBufferV3f delta_points,
const BrushPlugin::GeometryData geometry,
const BufferConstM33f vertex_space,
const std::shared_ptr< SceneConst > &  reference 
)
virtual

Create a BrushSculptUserData object for a geometry.

This method is implemented by the plug-in and is called by the BrushSculptPlugin object during the stroke_begin(). It must create and return a BrushSculptUserData derived object with all the needed data and the sculpting callback. It can return nullptr if no sculpting will be performed on this geometry.

Reimplemented from maquina::BrushSculptPlugin.

◆ vertex_space()

SceneConst maquina::BrushSculpt::vertex_space ( )
finalvirtual

Return a scene with for every geometries, an array of vertex space rotation matrices.

Reimplemented from maquina::BrushSculptPlugin.

◆ weight()

float maquina::BrushSculpt::weight ( float  )
finalvirtual

Convert a distance in weight.

The distance is in the same units than the radius. The plug-in can override the default behavior to propose complex weight functions to the user.

The default implementation returns 1.

Called by BrushPlugin::update_weights. To be implemented by the plug-in.

Reimplemented from maquina::BrushPlugin.

Friends And Related Function Documentation

◆ ::TransferSculptGeometryUserData

friend class ::TransferSculptGeometryUserData
friend

Member Data Documentation

◆ _input_path

std::string maquina::BrushSculpt::_input_path
protected

◆ _modifiers

int maquina::BrushSculpt::_modifiers
protected

◆ _source_bvh_triangle

BVHTriangle maquina::BrushSculpt::_source_bvh_triangle
protected

◆ _source_matrix

Imath::M44d maquina::BrushSculpt::_source_matrix
protected

◆ _source_matrix_inv

Imath::M44d maquina::BrushSculpt::_source_matrix_inv
protected

◆ _source_mesh

Mesh maquina::BrushSculpt::_source_mesh
protected

◆ _source_path

std::string maquina::BrushSculpt::_source_path
protected

◆ _source_sculpt_data

SparseBufferConstV3f maquina::BrushSculpt::_source_sculpt_data = SparseBufferConstV3f::default_value
protected

◆ _source_topo

BufferV3i maquina::BrushSculpt::_source_topo
protected

◆ _source_topo_face

SpanSpan<const uint32_t, const uint32_t> maquina::BrushSculpt::_source_topo_face
protected

◆ _source_tri_to_face

std::vector<uint32_t> maquina::BrushSculpt::_source_tri_to_face
protected

The documentation for this class was generated from the following file: