Blender V4.3
sculpt_expand.cc File Reference
#include "sculpt_expand.hh"
#include <cmath>
#include <cstdlib>
#include "MEM_guardedalloc.h"
#include "BLI_array_utils.hh"
#include "BLI_bit_vector.hh"
#include "BLI_linklist_stack.h"
#include "BLI_math_vector.hh"
#include "BLI_task.h"
#include "DNA_brush_types.h"
#include "DNA_object_types.h"
#include "BKE_attribute.hh"
#include "BKE_brush.hh"
#include "BKE_ccg.hh"
#include "BKE_colortools.hh"
#include "BKE_context.hh"
#include "BKE_image.hh"
#include "BKE_layer.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"
#include "BKE_paint.hh"
#include "BKE_pbvh_api.hh"
#include "BKE_report.hh"
#include "BKE_subdiv_ccg.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "ED_screen.hh"
#include "ED_sculpt.hh"
#include "paint_intern.hh"
#include "paint_mask.hh"
#include "sculpt_boundary.hh"
#include "sculpt_color.hh"
#include "sculpt_face_set.hh"
#include "sculpt_flood_fill.hh"
#include "sculpt_geodesic.hh"
#include "sculpt_intern.hh"
#include "sculpt_islands.hh"
#include "sculpt_smooth.hh"
#include "sculpt_undo.hh"
#include "IMB_colormanagement.hh"
#include "IMB_imbuf.hh"
#include "bmesh.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 
namespace  blender::ed
 
namespace  blender::ed::sculpt_paint
 
namespace  blender::ed::sculpt_paint::expand
 

Macros

#define SCULPT_EXPAND_VERTEX_NONE   -1
 
#define EXPAND_ACTIVE_COMPONENT_NONE   -1
 
#define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP   0.01f
 
#define SCULPT_EXPAND_LOOP_THRESHOLD   0.00001f
 
#define SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY   300
 

Enumerations

enum  {
  blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_CONFIRM = 1 , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_CANCEL , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_INVERT , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_PRESERVE_TOGGLE ,
  blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_GRADIENT_TOGGLE , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_FALLOFF_CYCLE , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_RECURSION_STEP_GEODESIC , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_RECURSION_STEP_TOPOLOGY ,
  blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_MOVE_TOGGLE , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS ,
  blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_FALLOFF_SPHERICAL , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_SNAP_TOGGLE , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_LOOP_COUNT_INCREASE , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_LOOP_COUNT_DECREASE ,
  blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_BRUSH_GRADIENT_TOGGLE , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_INCREASE , blender::ed::sculpt_paint::expand::SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_DECREASE
}
 

Functions

static bool blender::ed::sculpt_paint::expand::is_vert_in_active_component (const SculptSession &ss, const Cache &expand_cache, const int vert)
 
static bool blender::ed::sculpt_paint::expand::is_face_in_active_component (const Object &object, const OffsetIndices< int > faces, const Span< int > corner_verts, const Cache &expand_cache, const int f)
 
static float blender::ed::sculpt_paint::expand::falloff_value_vertex_get (const SculptSession &ss, const Cache &expand_cache, const float3 &position, const int vert)
 
static float blender::ed::sculpt_paint::expand::max_vert_falloff_get (const Cache &expand_cache)
 
static bool blender::ed::sculpt_paint::expand::vert_falloff_is_enabled (const SculptSession &ss, const Cache &expand_cache, const float3 &position, const int vert)
 
static bool blender::ed::sculpt_paint::expand::face_state_get (const Object &object, const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< bool > hide_poly, const Span< int > face_sets, const Cache &expand_cache, const int face)
 
static float blender::ed::sculpt_paint::expand::gradient_value_get (const SculptSession &ss, const Cache &expand_cache, const float3 &position, const int vert)
 
static BitVector blender::ed::sculpt_paint::expand::enabled_state_to_bitmap (const Depsgraph &depsgraph, const Object &object, const Cache &expand_cache)
 
static IndexMask blender::ed::sculpt_paint::expand::boundary_from_enabled (Object &object, const BitSpan enabled_verts, const bool use_mesh_boundary, IndexMaskMemory &memory)
 
static void blender::ed::sculpt_paint::expand::check_topology_islands (Object &ob, FalloffType falloff_type)
 
Vector< intblender::ed::sculpt_paint::find_symm_verts_mesh (const Depsgraph &depsgraph, const Object &object, const int original_vert, const float max_distance)
 
Vector< intblender::ed::sculpt_paint::find_symm_verts_grids (const Object &object, const int original_vert, const float max_distance)
 
Vector< intblender::ed::sculpt_paint::find_symm_verts_bmesh (const Object &object, const int original_vert, const float max_distance)
 
Vector< intblender::ed::sculpt_paint::find_symm_verts (const Depsgraph &depsgraph, const Object &object, const int original_vert, const float max_distance)
 
static Array< floatblender::ed::sculpt_paint::expand::geodesic_falloff_create (const Depsgraph &depsgraph, Object &ob, const IndexMask &initial_verts)
 
static Array< floatblender::ed::sculpt_paint::expand::geodesic_falloff_create (const Depsgraph &depsgraph, Object &ob, const int initial_vert)
 
static void blender::ed::sculpt_paint::expand::calc_topology_falloff_from_verts (Object &ob, const IndexMask &initial_verts, MutableSpan< float > distances)
 
static Array< floatblender::ed::sculpt_paint::expand::topology_falloff_create (const Depsgraph &depsgraph, Object &ob, const int initial_vert)
 
static Array< floatblender::ed::sculpt_paint::expand::normals_falloff_create (const Depsgraph &depsgraph, Object &ob, const int vert, const float edge_sensitivity, const int blur_steps)
 
static Array< floatblender::ed::sculpt_paint::expand::spherical_falloff_create (const Depsgraph &depsgraph, const Object &object, const int vert)
 
static Array< floatblender::ed::sculpt_paint::expand::boundary_topology_falloff_create (const Depsgraph &depsgraph, Object &ob, const int inititial_vert)
 
static Array< floatblender::ed::sculpt_paint::expand::diagonals_falloff_create (const Depsgraph &depsgraph, Object &ob, const int vert)
 
static void blender::ed::sculpt_paint::expand::update_max_vert_falloff_value (const Object &object, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::update_max_face_falloff_factor (const Object &object, Mesh &mesh, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::vert_to_face_falloff_grids (SculptSession &ss, Mesh *mesh, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::vert_to_face_falloff_mesh (Mesh *mesh, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::vert_to_face_falloff (Object &object, Mesh *mesh, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::geodesics_from_state_boundary (const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const BitSpan enabled_verts)
 
static void blender::ed::sculpt_paint::expand::topology_from_state_boundary (Object &ob, Cache &expand_cache, const BitSpan enabled_verts)
 
static void blender::ed::sculpt_paint::expand::resursion_step_add (const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const RecursionType recursion_type)
 
static void blender::ed::sculpt_paint::expand::init_from_face_set_boundary (const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const int active_face_set, const bool internal_falloff)
 
static void blender::ed::sculpt_paint::expand::calc_falloff_from_vert_and_symmetry (const Depsgraph &depsgraph, Cache &expand_cache, Object &ob, const int vert, FalloffType falloff_type)
 
static void blender::ed::sculpt_paint::expand::snap_init_from_enabled (const Depsgraph &depsgraph, const Object &object, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::expand_cache_free (SculptSession &ss)
 
static void blender::ed::sculpt_paint::expand::restore_face_set_data (Object &object, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::restore_color_data (Object &ob, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::write_mask_data (Object &object, const Span< float > mask)
 
static void blender::ed::sculpt_paint::expand::restore_original_state (bContext *C, Object &ob, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::sculpt_expand_cancel (bContext *C, wmOperator *)
 
static void blender::ed::sculpt_paint::expand::calc_new_mask_mesh (const SculptSession &ss, const Span< float3 > positions, const BitSpan enabled_verts, const Span< int > verts, const MutableSpan< float > mask)
 
static bool blender::ed::sculpt_paint::expand::update_mask_grids (const SculptSession &ss, const BitSpan enabled_verts, bke::pbvh::GridsNode &node, SubdivCCG &subdiv_ccg)
 
static bool blender::ed::sculpt_paint::expand::update_mask_bmesh (SculptSession &ss, const BitSpan enabled_verts, const int mask_offset, bke::pbvh::BMeshNode *node)
 
static void blender::ed::sculpt_paint::expand::face_sets_update (Object &object, Cache &expand_cache)
 
static bool blender::ed::sculpt_paint::expand::colors_update_task (const Depsgraph &depsgraph, Object &object, const Span< float3 > vert_positions, const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face_map, const Span< bool > hide_vert, const Span< float > mask, bke::pbvh::MeshNode *node, bke::GSpanAttributeWriter &color_attribute)
 
static void blender::ed::sculpt_paint::expand::original_state_store (Object &ob, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::face_sets_restore (Object &object, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::update_for_vert (bContext *C, Object &ob, const std::optional< int > vertex)
 
static std::optional< intblender::ed::sculpt_paint::expand::target_vert_update_and_get (bContext *C, Object &ob, const float mval[2])
 
static void blender::ed::sculpt_paint::expand::reposition_pivot (bContext *C, Object &ob, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::finish (bContext *C)
 
static void blender::ed::sculpt_paint::expand::find_active_connected_components_from_vert (const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const int initial_vertex)
 
static bool blender::ed::sculpt_paint::expand::set_initial_components_for_mouse (bContext *C, Object &ob, Cache &expand_cache, const float mval[2])
 
static void blender::ed::sculpt_paint::expand::move_propagation_origin (bContext *C, Object &ob, const wmEvent *event, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::ensure_sculptsession_data (Object &ob)
 
static int blender::ed::sculpt_paint::expand::active_face_set_id_get (Object &object, Cache &expand_cache)
 
static int blender::ed::sculpt_paint::expand::sculpt_expand_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static void blender::ed::sculpt_paint::expand::delete_face_set_id (int *r_face_sets, Object &object, Cache &expand_cache, Mesh *mesh, const int delete_id)
 
static void blender::ed::sculpt_paint::expand::cache_initial_config_set (bContext *C, wmOperator *op, Cache &expand_cache)
 
static void blender::ed::sculpt_paint::expand::undo_push (const Depsgraph &depsgraph, Object &ob, Cache &expand_cache)
 
static bool blender::ed::sculpt_paint::expand::any_nonzero_mask (const Object &object)
 
static int blender::ed::sculpt_paint::expand::sculpt_expand_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void blender::ed::sculpt_paint::expand::modal_keymap (wmKeyConfig *keyconf)
 
void blender::ed::sculpt_paint::expand::SCULPT_OT_expand (wmOperatorType *ot)
 

Macro Definition Documentation

◆ EXPAND_ACTIVE_COMPONENT_NONE

#define EXPAND_ACTIVE_COMPONENT_NONE   -1

Used for defining an uninitialized active component index for an unused symmetry pass.

Definition at line 92 of file sculpt_expand.cc.

Referenced by blender::ed::sculpt_paint::expand::find_active_connected_components_from_vert().

◆ SCULPT_EXPAND_LOOP_THRESHOLD

#define SCULPT_EXPAND_LOOP_THRESHOLD   0.00001f

This threshold offsets the required falloff value to start a new loop. This is needed because in some situations, vertices which have the same falloff value as max_falloff will start a new loop, which is undesired.

Definition at line 104 of file sculpt_expand.cc.

Referenced by blender::ed::sculpt_paint::expand::face_state_get(), blender::ed::sculpt_paint::expand::gradient_value_get(), and blender::ed::sculpt_paint::expand::vert_falloff_is_enabled().

◆ SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY

#define SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY   300

Defines how much changes in curvature in the mesh affect the falloff shape when using normal falloff. This default was found experimentally and it works well in most cases, but can be exposed for tweaking if needed.

Definition at line 111 of file sculpt_expand.cc.

Referenced by blender::ed::sculpt_paint::expand::calc_falloff_from_vert_and_symmetry().

◆ SCULPT_EXPAND_TEXTURE_DISTORTION_STEP

#define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP   0.01f

Defines how much each time the texture distortion is increased/decreased when using the modal key-map.

Definition at line 97 of file sculpt_expand.cc.

Referenced by blender::ed::sculpt_paint::expand::sculpt_expand_modal().

◆ SCULPT_EXPAND_VERTEX_NONE

#define SCULPT_EXPAND_VERTEX_NONE   -1

Used for defining an invalid vertex state (for example, when the cursor is not over the mesh).

Definition at line 89 of file sculpt_expand.cc.