Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_task.h"
#include "BLT_translation.h"
#include "DNA_brush_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "BKE_brush.h"
#include "BKE_ccg.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_multires.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pbvh.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_subdiv_ccg.h"
#include "DEG_depsgraph.h"
#include "WM_api.h"
#include "WM_message.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_sculpt.h"
#include "ED_view3d.h"
#include "paint_intern.h"
#include "sculpt_intern.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "bmesh.h"
#include <math.h>
#include <stdlib.h>
Go to the source code of this file.
Classes | |
struct | ExpandFloodFillData |
Typedefs | |
typedef struct ExpandFloodFillData | ExpandFloodFillData |
#define EXPAND_ACTIVE_COMPONENT_NONE -1 |
Used for defining an uninitialized active component index for an unused symmetry pass.
Definition at line 89 of file sculpt_expand.c.
#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 101 of file sculpt_expand.c.
#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 108 of file sculpt_expand.c.
#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 94 of file sculpt_expand.c.
#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 86 of file sculpt_expand.c.
typedef struct ExpandFloodFillData ExpandFloodFillData |
Topology: Initializes the falloff using a flood-fill operation, increasing the falloff value by 1 when visiting a new vertex.
anonymous enum |
Definition at line 111 of file sculpt_expand.c.
|
static |
Definition at line 434 of file sculpt_expand.c.
References data.
Referenced by sculpt_expand_topology_falloff_create(), and sculpt_expand_topology_from_state_boundary().
|
static |
Normals: Flood-fills the mesh and reduces the falloff depending on the normal difference between each vertex and the previous one. This creates falloff patterns that follow and snap to the hard edges of the object.
Definition at line 472 of file sculpt_expand.c.
References CLAMP, data, dot_v3v3(), powf, and SCULPT_vertex_normal_get().
Referenced by sculpt_expand_normal_falloff_create().
|
static |
Returns the active Face Sets ID from the enabled face or grid in the SculptSession.
Definition at line 1657 of file sculpt_expand.c.
References SculptSession::active_face_index, SculptSession::active_grid_index, BKE_pbvh_type(), BKE_subdiv_ccg_grid_to_face_index(), BLI_assert, ExpandCache::original_face_sets, SculptSession::pbvh, PBVH_BMESH, PBVH_FACES, PBVH_GRIDS, SCULPT_FACE_SET_NONE, and SculptSession::subdiv_ccg.
Referenced by sculpt_expand_modal().
|
static |
Returns a bitmap indexed by vertex index which contains if the vertex was enabled or not for a give expand_cache state.
Definition at line 345 of file sculpt_expand.c.
References BLI_BITMAP_NEW, BLI_BITMAP_SET, enabled, sculpt_expand_state_get(), and SCULPT_vertex_count_get().
Referenced by sculpt_expand_reposition_pivot(), sculpt_expand_resursion_step_add(), and sculpt_expand_snap_initialize_from_enabled().
|
static |
Returns a bitmap indexed by vertex index which contains if the vertex is in the boundary of the enabled vertices. This is defined as vertices that are enabled and at least have one connected vertex that is not enabled.
Definition at line 361 of file sculpt_expand.c.
References BLI_BITMAP_NEW, BLI_BITMAP_SET, BLI_BITMAP_TEST, SculptVertexNeighborIter::index, SCULPT_vertex_count_get(), SCULPT_vertex_is_boundary(), SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN, and SCULPT_VERTEX_NEIGHBORS_ITER_END.
Referenced by sculpt_expand_geodesics_from_state_boundary(), sculpt_expand_reposition_pivot(), and sculpt_expand_topology_from_state_boundary().
Boundary: This falloff mode uses the code from sculpt_boundary to initialize the closest mesh boundary to a falloff value of 0. Then, it propagates that falloff to the rest of the mesh so it stays parallel to the boundary, increasing the falloff value by 1 on each step.
Definition at line 574 of file sculpt_expand.c.
References BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, BLI_gsqueue_free(), BLI_gsqueue_is_empty(), BLI_gsqueue_new(), BLI_gsqueue_pop(), BLI_gsqueue_push(), SculptVertexNeighborIter::index, MEM_calloc_arrayN, MEM_freeN, NULL, SculptBoundary::num_vertices, queue, Object::sculpt, SCULPT_boundary_data_free(), SCULPT_boundary_data_init(), sculpt_expand_get_vertex_index_for_symmetry_pass(), SCULPT_is_symmetry_iteration_valid(), SCULPT_mesh_symmetry_xyz_get(), SCULPT_vertex_count_get(), SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN, SCULPT_VERTEX_NEIGHBORS_ITER_END, v, and SculptBoundary::vertices.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create().
|
static |
Functions to free a ExpandCache.
Definition at line 1081 of file sculpt_expand.c.
References BLI_gset_free(), ExpandCache::face_falloff, ExpandCache::initial_face_sets, MEM_SAFE_FREE, ExpandCache::nodes, NULL, ExpandCache::original_colors, ExpandCache::original_face_sets, ExpandCache::original_mask, ExpandCache::snap_enabled_face_sets, and ExpandCache::vert_falloff.
Referenced by sculpt_expand_cache_free().
|
static |
Definition at line 1096 of file sculpt_expand.c.
References SculptSession::expand_cache, NULL, and sculpt_expand_cache_data_free().
Referenced by sculpt_expand_cancel(), sculpt_expand_finish(), and sculpt_expand_invoke().
|
static |
Definition at line 1969 of file sculpt_expand.c.
References BKE_brush_color_get(), BKE_curvemapping_init(), BKE_paint_brush(), Brush::blend, ExpandCache::blend_mode, ExpandCache::brush, ExpandCache::brush_gradient, C, copy_v3_v3(), copy_v4_fl(), CTX_data_active_object(), CTX_data_scene(), CTX_data_tool_settings(), Brush::curve, ExpandCache::falloff_gradient, ExpandCache::fill_color, IMB_colormanagement_srgb_to_scene_linear_v3(), ExpandCache::invert, ExpandCache::loop_count, ExpandCache::max_geodesic_move_preview, ExpandCache::modify_active_face_set, ExpandCache::mtex, Brush::mtex, Sculpt::paint, ExpandCache::preserve, wmOperator::ptr, ExpandCache::reposition_pivot, RNA_boolean_get(), RNA_enum_get(), RNA_int_get(), SculptSession::scene, ExpandCache::scene, Object::sculpt, ToolSettings::sculpt, ExpandCache::target, and ExpandCache::texture_distortion_strength.
Referenced by sculpt_expand_invoke().
|
static |
Cancel operator callback.
Definition at line 1188 of file sculpt_expand.c.
References C, CTX_data_active_object(), SculptSession::expand_cache, Object::sculpt, sculpt_expand_cache_free(), sculpt_expand_restore_original_state(), and SCULPT_undo_push_end().
Referenced by sculpt_expand_modal(), and SCULPT_OT_expand().
|
static |
Callback to update vertex colors per PBVH node.
Definition at line 1273 of file sculpt_expand.c.
References BKE_pbvh_node_mark_update_color(), BKE_pbvh_vertex_iter_begin, BKE_pbvh_vertex_iter_end, ExpandCache::blend_mode, clamp_f(), data, enabled, equals_v4v4(), SculptSession::expand_cache, fade(), ExpandCache::fill_color, IMB_blend_color_float(), PBVHVertexIter::index, PBVHVertexIter::mask, mul_v4_v4fl(), node, ExpandCache::original_colors, SculptSession::pbvh, PBVH_ITER_ALL, sculpt_expand_gradient_value_get(), sculpt_expand_state_get(), SCULPT_vertex_color_get(), and SCULPT_vertex_color_set().
Referenced by sculpt_expand_update_for_vertex().
|
static |
Deletes the delete_id
Face Set ID from the mesh Face Sets and stores the result in r_face_set
. The faces that were using the delete_id
Face Set are filled using the content from their neighbors.
Definition at line 1877 of file sculpt_expand.c.
References blender::math::abs(), BLI_LINKSTACK_DECLARE, BLI_LINKSTACK_FREE, BLI_LINKSTACK_INIT, BLI_LINKSTACK_POP, BLI_LINKSTACK_PUSH, BLI_LINKSTACK_SIZE, BLI_LINKSTACK_SWAP, MeshElemMap::count, MeshElemMap::indices, l, MPoly::loopstart, mesh, Mesh::mloop, Mesh::mpoly, ExpandCache::original_face_sets, SculptSession::pmap, POINTER_AS_INT, POINTER_FROM_INT, queue, sculpt_expand_is_face_in_active_component(), SculptSession::totfaces, MPoly::totloop, and MLoop::v.
Referenced by sculpt_expand_invoke().
Topology diagonals. This falloff is similar to topology, but it also considers the diagonals of the base mesh faces when checking a vertex neighbor. For this reason, this is not implement using the general flood-fill and sculpt neighbors accessors.
Definition at line 635 of file sculpt_expand.c.
References BKE_pbvh_type(), BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, BLI_gsqueue_free(), BLI_gsqueue_is_empty(), BLI_gsqueue_new(), BLI_gsqueue_pop(), BLI_gsqueue_push(), MeshElemMap::count, Object::data, MeshElemMap::indices, l, MPoly::loopstart, MEM_calloc_arrayN, MEM_freeN, mesh, Mesh::mloop, SculptSession::mpoly, SculptSession::pbvh, PBVH_FACES, SculptSession::pmap, queue, Object::sculpt, sculpt_expand_get_vertex_index_for_symmetry_pass(), SCULPT_is_symmetry_iteration_valid(), SCULPT_mesh_symmetry_xyz_get(), SCULPT_vertex_count_get(), MPoly::totloop, v, and MLoop::v.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create().
Ensures that the SculptSession contains the required data needed for Expand.
Definition at line 1643 of file sculpt_expand.c.
References BKE_image_pool_new(), Object::sculpt, SCULPT_boundary_info_ensure(), SCULPT_connected_components_ensure(), SCULPT_vertex_random_access_ensure(), and SculptSession::tex_pool.
Referenced by sculpt_expand_invoke(), and sculpt_expand_modal().
|
static |
Restore the state of the Face Sets before a new update.
Definition at line 1376 of file sculpt_expand.c.
References SculptSession::face_sets, ExpandCache::initial_face_sets, ExpandCache::original_face_sets, sculpt_expand_is_face_in_active_component(), and SculptSession::totfaces.
Referenced by sculpt_expand_update_for_vertex().
|
static |
Update Face Set data. Not multi-threaded per node as nodes don't contain face arrays.
Definition at line 1249 of file sculpt_expand.c.
References BKE_pbvh_node_mark_redraw(), enabled, SculptSession::expand_cache, SculptSession::face_sets, ExpandCache::next_face_set, ExpandCache::nodes, ExpandCache::preserve, sculpt_expand_face_state_get(), SculptSession::totfaces, and ExpandCache::totnode.
Referenced by sculpt_expand_update_for_vertex().
|
static |
Main function to get the state of a face for the current state and settings of a ExpandCache. Returns true when the target data should be modified by expand.
Definition at line 258 of file sculpt_expand.c.
References ExpandCache::active_falloff, ExpandCache::all_enabled, BLI_gset_haskey(), enabled, ExpandCache::face_falloff, SculptSession::face_sets, ExpandCache::falloff_type, ExpandCache::initial_active_face_set, ExpandCache::invert, ExpandCache::loop_count, ExpandCache::max_face_falloff, ExpandCache::original_face_sets, POINTER_FROM_INT, SCULPT_EXPAND_FALLOFF_ACTIVE_FACE_SET, sculpt_expand_is_face_in_active_component(), SCULPT_EXPAND_LOOP_THRESHOLD, and ExpandCache::snap_enabled_face_sets.
Referenced by sculpt_expand_face_sets_update().
|
static |
Main function to initialize new falloff values in a ExpandCache given an initial vertex and a falloff type.
Definition at line 975 of file sculpt_expand.c.
References BKE_pbvh_type(), Object::data, ExpandCache::falloff_type, ExpandCache::initial_active_face_set, MEM_SAFE_FREE, SculptSession::pbvh, PBVH_FACES, Object::sculpt, sculpt_expand_boundary_topology_falloff_create(), sculpt_expand_diagonals_falloff_create(), SCULPT_EXPAND_FALLOFF_ACTIVE_FACE_SET, SCULPT_EXPAND_FALLOFF_BOUNDARY_FACE_SET, SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY, SCULPT_EXPAND_FALLOFF_GEODESIC, SCULPT_EXPAND_FALLOFF_NORMALS, SCULPT_EXPAND_FALLOFF_SPHERICAL, SCULPT_EXPAND_FALLOFF_TOPOLOGY, SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS, sculpt_expand_geodesic_falloff_create(), sculpt_expand_initialize_from_face_set_boundary(), sculpt_expand_mesh_face_falloff_from_vertex_falloff(), sculpt_expand_normal_falloff_create(), SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY, sculpt_expand_spherical_falloff_create(), SCULPT_EXPAND_TARGET_FACE_SETS, sculpt_expand_topology_falloff_create(), sculpt_expand_update_max_face_falloff_factor(), sculpt_expand_update_max_vert_falloff_value(), ExpandCache::target, v, and ExpandCache::vert_falloff.
Referenced by sculpt_expand_invoke(), sculpt_expand_modal(), and sculpt_expand_move_propagation_origin().
|
static |
Returns the falloff value of a vertex. This function includes texture distortion, which is not precomputed into the initial falloff values.
Definition at line 168 of file sculpt_expand.c.
References BKE_brush_sample_tex_3d(), ExpandCache::brush, ExpandCache::max_vert_falloff, Brush::mtex, usdtokens::rgba(), ExpandCache::scene, SCULPT_vertex_co_get(), MTex::tex, SculptSession::tex_pool, ExpandCache::texture_distortion_strength, v, and ExpandCache::vert_falloff.
Referenced by sculpt_expand_gradient_value_get(), and sculpt_expand_state_get().
|
static |
Finds and stores in the ExpandCache the sculpt connected component index for each symmetry pass needed for expand.
Definition at line 1553 of file sculpt_expand.c.
References ExpandCache::active_connected_components, SculptVertexInfo::connected_component, EXPAND_ACTIVE_COMPONENT_NONE, EXPAND_SYMM_AREAS, Object::sculpt, sculpt_expand_get_vertex_index_for_symmetry_pass(), SCULPT_is_symmetry_iteration_valid(), SCULPT_mesh_symmetry_xyz_get(), and SculptSession::vertex_info.
Referenced by sculpt_expand_set_initial_components_for_mouse().
Definition at line 1518 of file sculpt_expand.c.
References BKE_pbvh_node_mark_update_mask(), BKE_pbvh_search_gather(), C, CTX_data_active_object(), ED_workspace_status_text(), SculptSession::expand_cache, MEM_freeN, NULL, SculptSession::pbvh, Object::sculpt, sculpt_expand_cache_free(), SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_FACE_SETS, SCULPT_EXPAND_TARGET_MASK, SCULPT_flush_update_done(), SCULPT_undo_push_end(), SCULPT_UPDATE_COLOR, SCULPT_UPDATE_MASK, and ExpandCache::target.
Referenced by sculpt_expand_modal().
Definition at line 1324 of file sculpt_expand.c.
References C, CTX_data_active_object(), SculptSession::expand_cache, Object::sculpt, SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_FACE_SETS, SCULPT_EXPAND_TARGET_MASK, SCULPT_flush_update_step(), SCULPT_UPDATE_COLOR, SCULPT_UPDATE_MASK, and ExpandCache::target.
Referenced by sculpt_expand_update_for_vertex().
|
static |
Geodesic: Initializes the falloff with geodesic distances from the given active vertex, taking symmetry into account.
Definition at line 418 of file sculpt_expand.c.
References SCULPT_geodesic_from_vertex_and_symm(), and v.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create().
|
static |
Geodesic recursion: Initializes falloff values using geodesic distances from the boundary of the current vertices state.
Definition at line 811 of file sculpt_expand.c.
References BKE_pbvh_type(), BLI_assert, BLI_BITMAP_TEST, BLI_gset_add(), BLI_gset_free(), BLI_gset_int_new(), ExpandCache::face_falloff, MEM_freeN, MEM_SAFE_FREE, NULL, SculptSession::pbvh, PBVH_FACES, POINTER_FROM_INT, Object::sculpt, sculpt_expand_boundary_from_enabled(), SCULPT_geodesic_distances_create(), SCULPT_vertex_count_get(), and ExpandCache::vert_falloff.
Referenced by sculpt_expand_initialize_from_face_set_boundary(), and sculpt_expand_resursion_step_add().
|
static |
Utility function to get the closet vertex after flipping an original vertex position based on an symmetry pass iteration index.
Definition at line 397 of file sculpt_expand.c.
References flip_v3_v3(), NULL, Object::sculpt, SCULPT_EXPAND_VERTEX_NONE, SCULPT_nearest_vertex_get(), and SCULPT_vertex_co_get().
Referenced by sculpt_expand_boundary_topology_falloff_create(), sculpt_expand_diagonals_falloff_create(), sculpt_expand_find_active_connected_components_from_vert(), and sculpt_expand_spherical_falloff_create().
|
static |
For target modes that support gradients (such as sculpt masks or colors), this function returns the corresponding gradient value for an enabled vertex.
Definition at line 304 of file sculpt_expand.c.
References ExpandCache::active_falloff, BKE_brush_curve_strength(), BLI_assert, ExpandCache::brush, ExpandCache::brush_gradient, ExpandCache::falloff_gradient, ExpandCache::invert, ExpandCache::loop_count, sculpt_expand_falloff_value_vertex_get(), SCULPT_EXPAND_LOOP_THRESHOLD, sculpt_expand_max_vertex_falloff_get(), and v.
Referenced by sculpt_expand_colors_update_task_cb(), and sculpt_expand_mask_update_task_cb().
|
static |
Functions to get falloff values for faces from the values from the vertices. This is used for expanding Face Sets. Depending on the data type of the SculptSession, this needs to get the per face falloff value from the connected vertices of each face or from the grids stored per loops for each face.
Definition at line 746 of file sculpt_expand.c.
References BKE_pbvh_get_grid_key(), ExpandCache::face_falloff, usdtokens::g(), CCGKey::grid_area, l, MPoly::loopstart, mesh, Mesh::mpoly, SculptSession::pbvh, MPoly::totloop, Mesh::totpoly, and ExpandCache::vert_falloff.
Referenced by sculpt_expand_mesh_face_falloff_from_vertex_falloff().
|
static |
When internal falloff is set to true, the falloff will fill the active Face Set with a gradient, otherwise the active Face Set will be filled with a constant falloff of 0.0f.
Definition at line 914 of file sculpt_expand.c.
References BKE_pbvh_type(), BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, fabsf, MEM_freeN, min_ff(), SculptSession::pbvh, PBVH_FACES, Object::sculpt, sculpt_expand_geodesics_from_state_boundary(), sculpt_expand_topology_from_state_boundary(), SCULPT_vertex_count_get(), SCULPT_vertex_has_face_set(), SCULPT_vertex_has_unique_face_set(), and ExpandCache::vert_falloff.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create().
|
static |
Definition at line 2031 of file sculpt_expand.c.
References BKE_pbvh_search_gather(), BKE_pbvh_type(), BKE_sculpt_color_layer_create_if_needed(), BKE_sculpt_update_object_for_edit(), C, CTX_data_active_object(), CTX_data_ensure_evaluated_depsgraph(), CTX_data_tool_settings(), Object::data, depsgraph, SculptSession::expand_cache, ExpandCache::initial_active_vertex, ExpandCache::initial_face_sets, MEM_callocN, ExpandCache::modify_active_face_set, ExpandCache::next_face_set, ExpandCache::nodes, NULL, OPERATOR_CANCELLED, OPERATOR_RUNNING_MODAL, SculptSession::pbvh, PBVH_BMESH, wmOperator::ptr, RNA_enum_get(), Object::sculpt, ToolSettings::sculpt, sculpt_expand_cache_free(), sculpt_expand_cache_initial_config_set(), sculpt_expand_delete_face_set_id(), sculpt_expand_ensure_sculptsession_data(), SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY, sculpt_expand_falloff_factors_from_vertex_and_symm_create(), sculpt_expand_original_state_store(), sculpt_expand_set_initial_components_for_mouse(), SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_FACE_SETS, sculpt_expand_undo_push(), sculpt_expand_update_for_vertex(), SCULPT_undo_push_begin(), SCULPT_vertex_count_get(), SCULPT_vertex_is_boundary(), ExpandCache::target, ExpandCache::totnode, and WM_event_add_modal_handler().
Referenced by SCULPT_OT_expand().
|
static |
Returns true if the face is in a connected component with correctly initialized falloff values.
Definition at line 156 of file sculpt_expand.c.
References MPoly::loopstart, SculptSession::mloop, SculptSession::mpoly, sculpt_expand_is_vert_in_active_component(), and MLoop::v.
Referenced by sculpt_expand_delete_face_set_id(), sculpt_expand_face_sets_restore(), sculpt_expand_face_state_get(), and sculpt_expand_update_max_face_falloff_factor().
|
static |
Returns true if the vertex is in a connected component with correctly initialized falloff values.
Definition at line 141 of file sculpt_expand.c.
References ExpandCache::active_connected_components, SculptVertexInfo::connected_component, EXPAND_SYMM_AREAS, v, and SculptSession::vertex_info.
Referenced by sculpt_expand_is_face_in_active_component(), sculpt_expand_reposition_pivot(), sculpt_expand_state_get(), and sculpt_expand_update_max_vert_falloff_value().
|
static |
Callback to update mask data per PBVH node.
Definition at line 1204 of file sculpt_expand.c.
References BKE_pbvh_node_mark_update_mask(), BKE_pbvh_vertex_iter_begin, BKE_pbvh_vertex_iter_end, clamp_f(), data, enabled, SculptSession::expand_cache, PBVHVertexIter::index, PBVHVertexIter::mask, max_ff(), node, ExpandCache::original_mask, SculptSession::pbvh, PBVH_ITER_ALL, ExpandCache::preserve, sculpt_expand_gradient_value_get(), and sculpt_expand_state_get().
Referenced by sculpt_expand_update_for_vertex().
|
static |
Returns the maximum valid falloff value stored in the falloff array, taking the maximum possible texture distortion into account.
Definition at line 194 of file sculpt_expand.c.
References ExpandCache::brush, ExpandCache::max_vert_falloff, Brush::mtex, MTex::tex, and ExpandCache::texture_distortion_strength.
Referenced by sculpt_expand_gradient_value_get(), and sculpt_expand_state_get().
|
static |
Main function to update the faces falloff from a already calculated vertex falloff.
Definition at line 782 of file sculpt_expand.c.
References BKE_pbvh_type(), BLI_assert, ExpandCache::face_falloff, MEM_malloc_arrayN, mesh, NULL, SculptSession::pbvh, PBVH_FACES, PBVH_GRIDS, sculpt_expand_grids_to_faces_falloff(), sculpt_expand_vertex_to_faces_falloff(), Mesh::totpoly, and ExpandCache::vert_falloff.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create(), and sculpt_expand_resursion_step_add().
|
static |
Definition at line 1675 of file sculpt_expand.c.
References BKE_report(), BKE_sculpt_update_object_for_edit(), BLI_gset_add(), BLI_gset_free(), BLI_gset_int_new(), ExpandCache::brush, ExpandCache::brush_gradient, MTex::brush_map_mode, C, copy_v2_v2(), CTX_data_active_object(), CTX_data_depsgraph_pointer(), CTX_data_tool_settings(), depsgraph, ELEM, EVT_MODAL_MAP, SculptSession::expand_cache, ExpandCache::falloff_gradient, ExpandCache::falloff_type, ExpandCache::initial_active_vertex, ExpandCache::initial_mouse, ExpandCache::initial_mouse_move, ExpandCache::invert, ExpandCache::loop_count, max_ff(), ExpandCache::max_geodesic_move_preview, max_ii(), MOUSEMOVE, ExpandCache::move, ExpandCache::move_original_falloff_type, ExpandCache::move_preview_falloff_type, Brush::mtex, MTEX_MAP_MODE_3D, wmEvent::mval, NULL, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, ExpandCache::original_mouse_move, POINTER_FROM_INT, ExpandCache::preserve, wmOperator::reports, ExpandCache::reposition_pivot, RPT_WARNING, Object::sculpt, ToolSettings::sculpt, sculpt_expand_active_face_set_id_get(), sculpt_expand_cancel(), sculpt_expand_ensure_sculptsession_data(), sculpt_expand_falloff_factors_from_vertex_and_symm_create(), SCULPT_EXPAND_FALLOFF_GEODESIC, SCULPT_EXPAND_FALLOFF_SPHERICAL, SCULPT_EXPAND_FALLOFF_TOPOLOGY, SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS, sculpt_expand_finish(), SCULPT_EXPAND_MODAL_BRUSH_GRADIENT_TOGGLE, SCULPT_EXPAND_MODAL_CANCEL, SCULPT_EXPAND_MODAL_CONFIRM, SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC, SCULPT_EXPAND_MODAL_FALLOFF_SPHERICAL, SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY, SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS, SCULPT_EXPAND_MODAL_GRADIENT_TOGGLE, SCULPT_EXPAND_MODAL_INVERT, SCULPT_EXPAND_MODAL_LOOP_COUNT_DECREASE, SCULPT_EXPAND_MODAL_LOOP_COUNT_INCREASE, SCULPT_EXPAND_MODAL_MOVE_TOGGLE, SCULPT_EXPAND_MODAL_PRESERVE_TOGGLE, SCULPT_EXPAND_MODAL_RECURSION_STEP_GEODESIC, SCULPT_EXPAND_MODAL_RECURSION_STEP_TOPOLOGY, SCULPT_EXPAND_MODAL_SNAP_TOGGLE, SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_DECREASE, SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_INCREASE, sculpt_expand_move_propagation_origin(), SCULPT_EXPAND_RECURSION_GEODESICS, SCULPT_EXPAND_RECURSION_TOPOLOGY, sculpt_expand_reposition_pivot(), sculpt_expand_resursion_step_add(), sculpt_expand_snap_initialize_from_enabled(), sculpt_expand_target_vertex_update_and_get(), SCULPT_EXPAND_TEXTURE_DISTORTION_STEP, sculpt_expand_update_for_vertex(), SCULPT_vertex_count_get(), ExpandCache::snap, ExpandCache::snap_enabled_face_sets, MTex::tex, ExpandCache::texture_distortion_strength, wmEvent::type, UNPACK2, and wmEvent::val.
Referenced by SCULPT_OT_expand().
void sculpt_expand_modal_keymap | ( | wmKeyConfig * | keyconf | ) |
Definition at line 2111 of file sculpt_expand.c.
References wmKeyMap::modal_items, NULL, SCULPT_EXPAND_MODAL_BRUSH_GRADIENT_TOGGLE, SCULPT_EXPAND_MODAL_CANCEL, SCULPT_EXPAND_MODAL_CONFIRM, SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC, SCULPT_EXPAND_MODAL_FALLOFF_SPHERICAL, SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY, SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS, SCULPT_EXPAND_MODAL_GRADIENT_TOGGLE, SCULPT_EXPAND_MODAL_INVERT, SCULPT_EXPAND_MODAL_LOOP_COUNT_DECREASE, SCULPT_EXPAND_MODAL_LOOP_COUNT_INCREASE, SCULPT_EXPAND_MODAL_MOVE_TOGGLE, SCULPT_EXPAND_MODAL_PRESERVE_TOGGLE, SCULPT_EXPAND_MODAL_RECURSION_STEP_GEODESIC, SCULPT_EXPAND_MODAL_RECURSION_STEP_TOPOLOGY, SCULPT_EXPAND_MODAL_SNAP_TOGGLE, SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_DECREASE, SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_INCREASE, WM_modalkeymap_assign(), WM_modalkeymap_ensure(), and WM_modalkeymap_find().
Referenced by ED_keymap_paint().
|
static |
Displaces the initial mouse coordinates using the new mouse position to get a new active vertex. After that, initializes a new falloff of the same type with the new active vertex.
Definition at line 1617 of file sculpt_expand.c.
References add_v2_v2v2(), C, CTX_data_tool_settings(), ExpandCache::initial_active_vertex, ExpandCache::initial_mouse_move, ExpandCache::move_preview_falloff_type, wmEvent::mval, ExpandCache::original_mouse_move, ToolSettings::sculpt, sculpt_expand_falloff_factors_from_vertex_and_symm_create(), sculpt_expand_set_initial_components_for_mouse(), sub_v2_v2v2(), and UNPACK2.
Referenced by sculpt_expand_modal().
|
static |
Definition at line 495 of file sculpt_expand.c.
References ExpandFloodFillData::dists, ExpandFloodFillData::edge_factor, ExpandFloodFillData::edge_sensitivity, SculptVertexNeighborIter::index, mask_expand_normal_floodfill_cb(), MEM_callocN, MEM_malloc_arrayN, MEM_SAFE_FREE, ExpandFloodFillData::original_normal, Object::sculpt, SCULPT_floodfill_add_initial_with_symmetry(), SCULPT_floodfill_execute(), SCULPT_floodfill_free(), SCULPT_floodfill_init(), SCULPT_vertex_count_get(), SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN, SCULPT_VERTEX_NEIGHBORS_ITER_END, SCULPT_vertex_normal_get(), SculptVertexNeighborIter::size, and v.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create().
|
static |
Definition at line 1344 of file sculpt_expand.c.
References SculptSession::face_sets, ExpandCache::initial_face_sets, MEM_malloc_arrayN, ExpandCache::original_colors, ExpandCache::original_face_sets, ExpandCache::original_mask, Object::sculpt, SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_MASK, SCULPT_vertex_color_get(), SCULPT_vertex_count_get(), SCULPT_vertex_mask_get(), ExpandCache::target, and SculptSession::totfaces.
Referenced by sculpt_expand_invoke().
|
static |
Moves the sculpt pivot to the average point of the boundary enabled vertices of the current expand state. Take symmetry and active components into account.
Definition at line 1461 of file sculpt_expand.c.
References add_v3_v3(), BLI_BITMAP_TEST, C, Object::data, ExpandCache::falloff_type, ExpandCache::initial_active_vertex, ExpandCache::invert, MEM_freeN, mul_v3_v3fl(), NC_GEOM, ND_SELECT, SculptSession::pivot_pos, Object::sculpt, SCULPT_check_vertex_pivot_symmetry(), sculpt_expand_bitmap_from_enabled(), sculpt_expand_boundary_from_enabled(), SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY, sculpt_expand_is_vert_in_active_component(), SCULPT_mesh_symmetry_xyz_get(), SCULPT_vertex_co_get(), SCULPT_vertex_count_get(), and WM_event_add_notifier().
Referenced by sculpt_expand_modal().
|
static |
Definition at line 1122 of file sculpt_expand.c.
References BKE_pbvh_node_mark_redraw(), BKE_pbvh_search_gather(), BKE_pbvh_vertex_iter_begin, BKE_pbvh_vertex_iter_end, PBVHVertexIter::index, MEM_freeN, node, NULL, ExpandCache::original_colors, SculptSession::pbvh, PBVH_ITER_UNIQUE, and SCULPT_vertex_color_set().
Referenced by sculpt_expand_restore_original_state().
|
static |
Functions to restore the original state from the ExpandCache when canceling the operator.
Definition at line 1107 of file sculpt_expand.c.
References BKE_pbvh_node_mark_redraw(), BKE_pbvh_search_gather(), SculptSession::face_sets, MEM_freeN, node, NULL, ExpandCache::original_face_sets, SculptSession::pbvh, and SculptSession::totfaces.
Referenced by sculpt_expand_restore_original_state().
|
static |
Definition at line 1139 of file sculpt_expand.c.
References BKE_pbvh_node_mark_redraw(), BKE_pbvh_search_gather(), BKE_pbvh_vertex_iter_begin, BKE_pbvh_vertex_iter_end, PBVHVertexIter::index, PBVHVertexIter::mask, MEM_freeN, node, NULL, ExpandCache::original_mask, SculptSession::pbvh, and PBVH_ITER_UNIQUE.
Referenced by sculpt_expand_restore_original_state().
|
static |
Definition at line 1158 of file sculpt_expand.c.
References C, Object::sculpt, sculpt_expand_restore_color_data(), sculpt_expand_restore_face_set_data(), sculpt_expand_restore_mask_data(), SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_FACE_SETS, SCULPT_EXPAND_TARGET_MASK, SCULPT_flush_update_done(), SCULPT_flush_update_step(), SCULPT_tag_update_overlays(), SCULPT_UPDATE_COLOR, SCULPT_UPDATE_MASK, and ExpandCache::target.
Referenced by sculpt_expand_cancel().
|
static |
Main function to create a recursion step from the current ExpandCache state.
Definition at line 874 of file sculpt_expand.c.
References BKE_pbvh_type(), Object::data, MEM_freeN, SculptSession::pbvh, PBVH_FACES, Object::sculpt, sculpt_expand_bitmap_from_enabled(), sculpt_expand_geodesics_from_state_boundary(), sculpt_expand_mesh_face_falloff_from_vertex_falloff(), SCULPT_EXPAND_RECURSION_GEODESICS, SCULPT_EXPAND_RECURSION_TOPOLOGY, SCULPT_EXPAND_TARGET_FACE_SETS, sculpt_expand_topology_from_state_boundary(), sculpt_expand_update_max_face_falloff_factor(), sculpt_expand_update_max_vert_falloff_value(), ExpandCache::target, and ExpandCache::texture_distortion_strength.
Referenced by sculpt_expand_modal().
|
static |
Stores the active vertex, Face Set and mouse coordinates in the ExpandCache based on the current cursor position.
Definition at line 1580 of file sculpt_expand.c.
References C, copy_v2_v2(), Object::data, ED_sculpt_face_sets_find_next_available_id(), SculptSession::expand_cache, ExpandCache::initial_active_face_set, ExpandCache::initial_active_vertex, ExpandCache::initial_mouse, ExpandCache::modify_active_face_set, ExpandCache::next_face_set, Object::sculpt, SCULPT_active_face_set_get(), SCULPT_active_vertex_get(), sculpt_expand_find_active_connected_components_from_vert(), sculpt_expand_target_vertex_update_and_get(), SCULPT_EXPAND_VERTEX_NONE, and SCULPT_FACE_SET_NONE.
Referenced by sculpt_expand_invoke(), and sculpt_expand_move_propagation_origin().
|
static |
Adds to the snapping Face Set gset
all Face Sets which contain all enabled vertices for the current ExpandCache state. This improves the usability of snapping, as already enabled elements won't switch their state when toggling snapping with the modal key-map.
Definition at line 1035 of file sculpt_expand.c.
References BKE_pbvh_type(), BLI_BITMAP_TEST, BLI_gset_add(), BLI_gset_remove(), ExpandCache::invert, l, MPoly::loopstart, MEM_freeN, SculptSession::mloop, SculptSession::mpoly, NULL, ExpandCache::original_face_sets, SculptSession::pbvh, PBVH_FACES, POINTER_FROM_INT, sculpt_expand_bitmap_from_enabled(), ExpandCache::snap, ExpandCache::snap_enabled_face_sets, SculptSession::totfaces, MPoly::totloop, and MLoop::v.
Referenced by sculpt_expand_modal().
Spherical: Initializes the falloff based on the distance from a vertex, taking symmetry into account.
Definition at line 542 of file sculpt_expand.c.
References len_v3v3(), MEM_malloc_arrayN, min_ff(), Object::sculpt, sculpt_expand_get_vertex_index_for_symmetry_pass(), SCULPT_is_symmetry_iteration_valid(), SCULPT_mesh_symmetry_xyz_get(), SCULPT_vertex_co_get(), SCULPT_vertex_count_get(), and v.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create().
|
static |
Main function to get the state of a vertex for the current state and settings of a ExpandCache. Returns true when the target data should be modified by expand.
Definition at line 212 of file sculpt_expand.c.
References ExpandCache::active_falloff, ExpandCache::all_enabled, BLI_gset_haskey(), enabled, ExpandCache::invert, ExpandCache::loop_count, POINTER_FROM_INT, sculpt_expand_falloff_value_vertex_get(), sculpt_expand_is_vert_in_active_component(), SCULPT_EXPAND_LOOP_THRESHOLD, sculpt_expand_max_vertex_falloff_get(), SCULPT_vertex_face_set_get(), SCULPT_vertex_visible_get(), ExpandCache::snap, ExpandCache::snap_enabled_face_sets, and v.
Referenced by sculpt_expand_bitmap_from_enabled(), sculpt_expand_colors_update_task_cb(), and sculpt_expand_mask_update_task_cb().
|
static |
Updates the SculptSession cursor data and gets the active vertex if the cursor is over the mesh.
Definition at line 1447 of file sculpt_expand.c.
References C, Object::sculpt, SCULPT_active_vertex_get(), SCULPT_cursor_geometry_info_update(), and SCULPT_EXPAND_VERTEX_NONE.
Referenced by sculpt_expand_modal(), and sculpt_expand_set_initial_components_for_mouse().
|
static |
Definition at line 448 of file sculpt_expand.c.
References ExpandFloodFillData::dists, expand_topology_floodfill_cb(), MEM_calloc_arrayN, Object::sculpt, SCULPT_floodfill_add_initial_with_symmetry(), SCULPT_floodfill_execute(), SCULPT_floodfill_free(), SCULPT_floodfill_init(), SCULPT_vertex_count_get(), and v.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create().
|
static |
Topology recursion: Initializes falloff values using topology steps from the boundary of the current vertices state, increasing the value by 1 each time a new vertex is visited.
Definition at line 840 of file sculpt_expand.c.
References BLI_BITMAP_TEST, ExpandFloodFillData::dists, expand_topology_floodfill_cb(), ExpandCache::face_falloff, MEM_calloc_arrayN, MEM_freeN, MEM_SAFE_FREE, Object::sculpt, sculpt_expand_boundary_from_enabled(), SCULPT_floodfill_add_and_skip_initial(), SCULPT_floodfill_execute(), SCULPT_floodfill_free(), SCULPT_floodfill_init(), SCULPT_vertex_count_get(), and ExpandCache::vert_falloff.
Referenced by sculpt_expand_initialize_from_face_set_boundary(), and sculpt_expand_resursion_step_add().
|
static |
Does the undo sculpt push for the affected target data of the ExpandCache.
Definition at line 2005 of file sculpt_expand.c.
References BKE_pbvh_search_gather(), MEM_freeN, NULL, SculptSession::pbvh, Object::sculpt, SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_FACE_SETS, SCULPT_EXPAND_TARGET_MASK, SCULPT_UNDO_COLOR, SCULPT_UNDO_FACE_SETS, SCULPT_UNDO_MASK, SCULPT_undo_push_node(), and ExpandCache::target.
Referenced by sculpt_expand_invoke().
Definition at line 1391 of file sculpt_expand.c.
References ExpandCache::active_falloff, ExpandCache::all_enabled, BKE_pbvh_parallel_range_settings(), BLI_task_parallel_range(), C, CTX_data_tool_settings(), data, SculptSession::expand_cache, ExpandCache::max_vert_falloff, ExpandCache::nodes, Object::sculpt, ToolSettings::sculpt, sculpt_expand_colors_update_task_cb(), sculpt_expand_face_sets_restore(), sculpt_expand_face_sets_update(), sculpt_expand_flush_updates(), sculpt_expand_mask_update_task_cb(), SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_FACE_SETS, SCULPT_EXPAND_TARGET_MASK, SCULPT_EXPAND_VERTEX_NONE, ExpandCache::target, ExpandCache::totnode, and ExpandCache::vert_falloff.
Referenced by sculpt_expand_invoke(), and sculpt_expand_modal().
|
static |
Updates the max_falloff value for faces in a ExpandCache based on the current values of the falloff, skipping any invalid values initialized to FLT_MAX and not initialized components.
Definition at line 721 of file sculpt_expand.c.
References ExpandCache::face_falloff, ExpandCache::max_face_falloff, max_ff(), sculpt_expand_is_face_in_active_component(), and SculptSession::totfaces.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create(), and sculpt_expand_resursion_step_add().
|
static |
Updates the max_falloff value for vertices in a ExpandCache based on the current values of the falloff, skipping any invalid values initialized to FLT_MAX and not initialized components.
Definition at line 698 of file sculpt_expand.c.
References max_ff(), ExpandCache::max_vert_falloff, sculpt_expand_is_vert_in_active_component(), SCULPT_vertex_count_get(), and ExpandCache::vert_falloff.
Referenced by sculpt_expand_falloff_factors_from_vertex_and_symm_create(), and sculpt_expand_resursion_step_add().
|
static |
Definition at line 766 of file sculpt_expand.c.
References ExpandCache::face_falloff, l, MPoly::loopstart, mesh, Mesh::mloop, Mesh::mpoly, MPoly::totloop, Mesh::totpoly, MLoop::v, and ExpandCache::vert_falloff.
Referenced by sculpt_expand_mesh_face_falloff_from_vertex_falloff().
void SCULPT_OT_expand | ( | wmOperatorType * | ot | ) |
Definition at line 2179 of file sculpt_expand.c.
References wmOperatorType::cancel, wmOperatorType::description, wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::invoke, wmOperatorType::modal, wmOperatorType::name, NULL, OPTYPE_REGISTER, OPTYPE_UNDO, ot, wmOperatorType::poll, wmOperatorType::prop, RNA_def_boolean(), RNA_def_enum(), RNA_def_int(), sculpt_expand_cancel(), SCULPT_EXPAND_FALLOFF_ACTIVE_FACE_SET, SCULPT_EXPAND_FALLOFF_BOUNDARY_FACE_SET, SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY, SCULPT_EXPAND_FALLOFF_GEODESIC, SCULPT_EXPAND_FALLOFF_NORMALS, SCULPT_EXPAND_FALLOFF_SPHERICAL, SCULPT_EXPAND_FALLOFF_TOPOLOGY, SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS, sculpt_expand_invoke(), sculpt_expand_modal(), SCULPT_EXPAND_TARGET_COLORS, SCULPT_EXPAND_TARGET_FACE_SETS, SCULPT_EXPAND_TARGET_MASK, SCULPT_mode_poll(), and wmOperatorType::srna.
Referenced by ED_operatortypes_sculpt().