92#define SCULPT_EXPAND_VERTEX_NONE -1
95#define EXPAND_ACTIVE_COMPONENT_NONE -1
100#define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP 0.01f
107#define SCULPT_EXPAND_LOOP_THRESHOLD 0.00001f
114#define SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY 300
148 const Cache &expand_cache,
165 const Cache &expand_cache,
190 const Cache &expand_cache,
223 if (!mask_tex->
tex) {
232 const Cache &expand_cache,
237 const float loop_len = (max_falloff_factor / expand_cache.
loop_count) +
242 const float falloff_factor =
fmod(vertex_falloff_factor, loop_len);
244 return falloff_factor < active_factor;
256 const Cache &expand_cache,
259 if (!hide_poly.
is_empty() && hide_poly[face]) {
268 if (expand_cache.
invert) {
274 bool enabled =
false;
285 const float falloff_factor =
fmod(expand_cache.
face_falloff[face], loop_len);
286 enabled = falloff_factor < active_factor;
295 if (expand_cache.
invert) {
307 const Cache &expand_cache,
316 const float loop_len = (max_falloff_factor / expand_cache.
loop_count) +
321 const float falloff_factor =
fmod(vertex_falloff_factor, loop_len);
323 float linear_falloff;
325 if (expand_cache.
invert) {
328 BLI_assert((loop_len - active_factor) != 0.0f);
329 linear_falloff = (falloff_factor - active_factor) / (loop_len - active_factor);
332 linear_falloff = 1.0f - (falloff_factor / active_factor);
336 return linear_falloff;
350 const Cache &expand_cache)
356 if (!expand_cache.
invert) {
357 enabled_verts.
fill(
true);
359 return enabled_verts;
372 for (
const int vert : range) {
373 if (!hide_vert.
is_empty() && hide_vert[vert]) {
379 if (expand_cache.
snap) {
384 enabled_verts[vert].set(
391 const Mesh &base_mesh = *id_cast<const Mesh *>(
object.
data);
393 const Span<int> corner_verts = base_mesh.corner_verts();
403 for (
const int grid :
IndexRange(subdiv_ccg.grids_num)) {
406 const int vert = start + offset;
410 if (expand_cache.
snap) {
420 enabled_verts[vert].set(
true);
424 enabled_verts[vert].set(
440 if (expand_cache.
snap) {
451 if (expand_cache.
invert) {
454 return enabled_verts;
464 const bool use_mesh_boundary,
482 faces, corner_verts, vert_to_face_map, hide_poly, vert, neighbors))
484 if (!enabled_verts[neighbor]) {
489 if (use_mesh_boundary &&
500 const Mesh &base_mesh = *id_cast<const Mesh *>(
object.
data);
502 const Span<int> corner_verts = base_mesh.corner_verts();
511 if (!enabled_verts[neighbor.
to_index(key)]) {
576 const int original_vert,
577 const float max_distance)
581 const bool use_original =
false;
584 symm_verts.
append(original_vert);
591 const float3 location = positions[original_vert];
592 for (
int symm_it = 1; symm_it <= symm; symm_it++) {
598 pbvh, positions, hide_vert, symm_location, max_distance, use_original);
602 symm_verts.
append(*nearest);
605 std::ranges::sort(symm_verts);
610 const int original_vert,
611 const float max_distance)
615 const bool use_original =
false;
618 symm_verts.
append(original_vert);
624 const float3 location = positions[original_vert];
625 for (
int symm_it = 1; symm_it <= symm; symm_it++) {
631 pbvh, subdiv_ccg, symm_location, max_distance, use_original);
635 symm_verts.
append(nearest->to_index(key));
638 std::ranges::sort(symm_verts);
643 const int original_vert,
644 const float max_distance)
648 const bool use_original =
false;
651 symm_verts.
append(original_vert);
656 const float3 location = original_bm_vert->
co;
657 for (
int symm_it = 1; symm_it <= symm; symm_it++) {
663 pbvh, symm_location, max_distance, use_original);
670 std::ranges::sort(symm_verts);
676 const int original_vert,
677 const float max_distance)
680 switch (
pbvh.type()) {
694 const int original_vert,
695 const float max_distance)
698 switch (
pbvh.type()) {
712 const int original_vert,
713 const float max_distance)
717 const bool use_original =
false;
719 std::array<int, PAINT_SYMM_AREAS> symm_verts;
721 symm_verts[0] = original_vert;
728 const float3 location = positions[original_vert];
735 pbvh, positions, hide_vert, symm_location, max_distance, use_original);
739 symm_verts[symm_it] = *nearest;
746 const int original_vert,
747 const float max_distance)
751 const bool use_original =
false;
753 std::array<int, PAINT_SYMM_AREAS> symm_verts;
755 symm_verts[0] = original_vert;
761 const float3 location = positions[original_vert];
768 pbvh, subdiv_ccg, symm_location, max_distance, use_original);
772 symm_verts[symm_it] = nearest->to_index(key);
779 const int original_vert,
780 const float max_distance)
784 const bool use_original =
false;
786 std::array<int, PAINT_SYMM_AREAS> symm_verts;
788 symm_verts[0] = original_vert;
793 const float3 location = original_bm_vert->
co;
800 pbvh, symm_location, max_distance, use_original);
832 if (ss.edge_to_face_map.is_empty()) {
834 faces, corner_edges, edges.
size(), ss.edge_to_face_offsets, ss.edge_to_face_indices);
836 if (ss.vert_to_edge_map.is_empty()) {
838 edges,
mesh.verts_num, ss.vert_to_edge_offsets, ss.vert_to_edge_indices);
856 const int initial_vert)
880 switch (
pbvh.type()) {
884 flood.
execute(ob, vert_to_face_map, [&](
const int from_vert,
const int to_vert) {
885 distances[to_vert] = distances[from_vert] + 1.0f;
903 const int from_vert = from.
to_index(key);
904 const int to_vert = to.
to_index(key);
906 distances[to_vert] = distances[from_vert];
909 distances[to_vert] = distances[from_vert] + 1.0f;
923 distances[to_vert] = distances[from_vert] + 1.0f;
933 const int initial_vert)
953 const float edge_sensitivity,
954 const int blur_steps)
962 switch (
pbvh.type()) {
968 const float3 orig_normal = vert_normals[vert];
971 flood.
execute(ob, vert_to_face_map, [&](
const int from_vert,
const int to_vert) {
972 const float3 &from_normal = vert_normals[from_vert];
973 const float3 &to_normal = vert_normals[to_vert];
974 const float from_edge_factor = edge_factors[from_vert];
975 const float dist =
math::dot(orig_normal, to_normal) *
976 powf(from_edge_factor, edge_sensitivity);
977 edge_factors[to_vert] =
math::dot(to_normal, from_normal) * from_edge_factor;
978 dists[to_vert] = std::clamp(dist, 0.0f, 1.0f);
987 const float3 orig_normal = normals[vert];
994 const int from_vert = from.
to_index(key);
995 const int to_vert = to.
to_index(key);
997 edge_factors[to_vert] = edge_factors[from_vert];
998 dists[to_vert] = dists[from_vert];
1001 const float3 &from_normal = normals[from_vert];
1002 const float3 &to_normal = normals[to_vert];
1003 const float from_edge_factor = edge_factors[from_vert];
1004 const float dist =
math::dot(orig_normal, to_normal) *
1005 powf(from_edge_factor, edge_sensitivity);
1006 edge_factors[to_vert] =
math::dot(to_normal, from_normal) * from_edge_factor;
1007 dists[to_vert] = std::clamp(dist, 0.0f, 1.0f);
1016 const float3 orig_normal = orig_vert->
no;
1019 const float3 from_normal = from_bm_vert->
no;
1020 const float3 to_normal = to_bm_vert->
no;
1023 const float from_edge_factor = edge_factors[from_vert];
1024 const float dist =
math::dot(orig_normal, to_normal) *
1025 powf(from_edge_factor, edge_sensitivity);
1026 edge_factors[to_vert] =
math::dot(to_normal, from_normal) * from_edge_factor;
1027 dists[to_vert] = std::clamp(dist, 0.0f, 1.0f);
1036 for (
int i = 0; i < totvert; i++) {
1037 dists[i] = 1.0 - dists[i];
1057 switch (
pbvh.type()) {
1065 for (const int vert : range) {
1066 float dist = std::numeric_limits<float>::max();
1067 for (const float3 &location : locations) {
1068 dist = std::min(dist, math::distance(positions[vert], location));
1081 locations[i] = positions[symm_verts[i]];
1085 for (const int vert : range) {
1086 float dist = std::numeric_limits<float>::max();
1087 for (const float3 &location : locations) {
1088 dist = std::min(dist, math::distance(positions[vert], location));
1099 for (
const int i : symm_verts.index_range()) {
1104 for (const int vert : range) {
1105 float dist = std::numeric_limits<float>::max();
1106 for (const float3 &location : locations) {
1107 dist = std::min(dist,
1108 math::distance(float3(BM_vert_at_index(&bm, vert)->co), location));
1127 const int initial_vert)
1132 for (
const int vert : symm_verts) {
1134 depsgraph, ob,
nullptr, vert,
FLT_MAX))
1136 for (
const int vert :
boundary->verts) {
1137 boundary_verts[vert].set();
1178 std::queue<int> queue;
1179 for (
const int vert : symm_verts) {
1181 visited_verts[vert].set();
1184 if (queue.empty()) {
1189 while (!queue.empty()) {
1190 const int next_vert = queue.front();
1193 for (
const int face : vert_to_face_map[next_vert]) {
1194 for (
const int vert : corner_verts.
slice(faces[face])) {
1195 if (visited_verts[vert]) {
1198 dists[vert] = dists[next_vert] + 1.0f;
1199 visited_verts[vert].set();
1218 std::numeric_limits<float>::lowest(),
1220 for (
const int vert : range) {
1231 [](
const float a,
const float b) {
return std::max(a,
b); });
1245 std::numeric_limits<float>::lowest(),
1247 for (const int face : range) {
1248 if (expand_cache.face_falloff[face] == FLT_MAX) {
1251 if (!is_face_in_active_component(object, faces, corner_verts, expand_cache, face)) {
1254 max = std::max(max, expand_cache.face_falloff[face]);
1258 [](
const float a,
const float b) {
return std::max(a,
b); });
1273 for (const int face : range) {
1275 for (const int corner : faces[face]) {
1276 const int grid_loop_index = corner * key.grid_area;
1277 for (int g = 0; g < key.grid_area; g++) {
1278 accum += expand_cache.vert_falloff[grid_loop_index + g];
1281 expand_cache.face_falloff[face] = accum / (faces[face].size() * key.grid_area);
1292 for (const int face : range) {
1293 const Span<int> face_verts = corner_verts.slice(faces[face]);
1295 for (const int vert : face_verts) {
1296 accum += expand_cache.vert_falloff[vert];
1298 expand_cache.face_falloff[face] = accum / face_verts.size();
1333 Cache &expand_cache,
1351 Cache &expand_cache,
1370 Cache &expand_cache,
1385 switch (recursion_type) {
1410 Cache &expand_cache,
1411 const int active_face_set,
1412 const bool internal_falloff)
1419 switch (
pbvh.type()) {
1427 for (
const int vert : range) {
1429 vert_to_face_map, face_sets, vert, active_face_set);
1431 vert_to_face_map, face_sets, vert);
1437 const Mesh &base_mesh = *id_cast<const Mesh *>(ob.
data);
1439 const Span<int> corner_verts = base_mesh.corner_verts();
1447 for (
const int vert : range) {
1457 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, coord);
1467 for (
const int vert : range) {
1478 for (
int i = 0; i < totvert; i++) {
1479 if (!vert_has_unique_face_set[i]) {
1482 if (!vert_has_face_set[i]) {
1485 enabled_verts[i].set();
1495 if (internal_falloff) {
1496 for (
int i = 0; i < totvert; i++) {
1497 if (!(vert_has_face_set[i] && vert_has_unique_face_set[i])) {
1504 for (
int i = 0; i < totvert; i++) {
1508 const float additional_falloff =
fabsf(min_factor);
1509 for (
int i = 0; i < totvert; i++) {
1514 for (
int i = 0; i < totvert; i++) {
1515 if (!vert_has_face_set[i]) {
1528 Cache &expand_cache,
1538 switch (falloff_type) {
1592 Cache &expand_cache)
1598 const Mesh &
mesh = *id_cast<const Mesh *>(
object.
data);
1603 const bool prev_snap_state = expand_cache.
snap;
1604 const bool prev_invert_state = expand_cache.
invert;
1605 expand_cache.
snap =
false;
1606 expand_cache.
invert =
false;
1617 const bool any_disabled = std::any_of(face_verts.
begin(),
1619 [&](
const int vert) { return !enabled_verts[vert]; });
1626 expand_cache.
snap = prev_snap_state;
1627 expand_cache.
invert = prev_invert_state;
1645 *id_cast<Mesh *>(
object.
data));
1651 pbvh.tag_face_sets_changed(node_mask);
1667 for (
const int vert :
nodes[i].verts()) {
1674 color_attribute.
span);
1677 pbvh.tag_attribute_changed(node_mask,
mesh.active_color_attribute);
1678 color_attribute.
finish();
1687 switch (
pbvh.type()) {
1691 attributes.
remove(
".sculpt_mask");
1692 attributes.
add<
float>(
".sculpt_mask",
1702 for (
const int i :
mask.index_range()) {
1715 pbvh.tag_masks_changed(node_mask);
1722 switch (expand_cache.
target) {
1770 const int vert = verts[i];
1771 const bool enabled = enabled_verts[vert];
1785 if (expand_cache.
invert) {
1807 bool any_changed =
false;
1808 for (
const int grid :
node.grids()) {
1810 const float initial_mask = masks[vert];
1818 if (enabled_verts[vert]) {
1826 if (expand_cache.
invert) {
1834 if (new_mask == initial_mask) {
1838 masks[vert] =
clamp_f(new_mask, 0.0f, 1.0f);
1849 const Cache &expand_cache,
1850 const float old_mask,
1859 if (enabled_verts[vert_index]) {
1866 if (expand_cache.
invert) {
1873 return clamp_f(new_mask, 0.0f, 1.0f);
1878 const int mask_offset,
1884 bool any_changed =
false;
1887 float new_mask =
calc_new_mask_bmesh(ss, expand_cache, initial_mask, enabled_verts, vert);
1888 if (new_mask != initial_mask) {
1896 if (
calc_new_mask_bmesh(ss, expand_cache, old_mask[i], enabled_verts, vert) != old_mask[i]) {
1921 for (
const int f : face_sets.
span.index_range()) {
1923 object, faces, corner_verts, hide_poly, face_sets.
span, expand_cache, f);
1960 bool any_changed =
false;
1963 const int vert = verts[i];
1964 if (!hide_vert.
is_empty() && hide_vert[vert]) {
1969 faces, corner_verts, vert_to_face_map, color_attribute.
span, color_attribute.
domain, vert);
1973 if (enabled_verts[vert]) {
1980 if (!
mask.is_empty()) {
1993 if (initial_color == final_color) {
2003 color_attribute.
span);
2035 for (
int i = 0; i < totvert; i++) {
2037 faces, corner_verts, vert_to_face_map, colors, color_attribute.
domain, i);
2094 switch (expand_cache.
target) {
2096 switch (
pbvh.type()) {
2130 old_masks[i].resize(other.
size());
2132 for (
BMVert *vert : other) {
2142 ss, enabled_verts, mask_offset, old_masks[i].as_span(), &
nodes[i]);
2189 mesh.active_color_attribute);
2191 color_attribute.finish();
2208 return std::nullopt;
2221 const bool initial_invert_state = expand_cache.
invert;
2222 expand_cache.
invert =
false;
2232 ob, enabled_verts, use_mesh_boundary, memory);
2236 expand_cache.
invert = initial_invert_state;
2327 Cache &expand_cache,
2328 const int initial_vertex)
2339 int valid_index = 0;
2340 for (
int symm_it = 0; symm_it <= symm; symm_it++) {
2345 symm_verts[valid_index]);
2356 Cache &expand_cache,
2357 const float mval[2])
2363 if (!initial_vert) {
2372 if (last_active_vert_index == -1) {
2375 initial_vert = last_active_vert_index;
2407 Cache &expand_cache)
2448 return face_set_none_id;
2453 return face_set_none_id;
2464 return face_set_none_id;
2516 status.
item(
"/", 0);
2523 if (expand_cache->
brush) {
2525 if (mask_tex->
tex) {
2555 switch (event->
val) {
2573 if (!expand_cache.
brush) {
2583 if (expand_cache.
snap) {
2584 expand_cache.
snap =
false;
2590 expand_cache.
snap =
true;
2597 if (expand_cache.
move) {
2598 expand_cache.
move =
false;
2606 expand_cache.
move =
true;
2680 if (!expand_cache.
brush) {
2685 if (mask_tex->
tex ==
nullptr) {
2688 "Active brush does not contain any texture to distort the expand boundary");
2694 "Texture mapping not set to 3D, results may be unpredictable");
2710 if (expand_cache.
move) {
2715 if (expand_cache.
snap) {
2744 bool all_same_id =
true;
2749 if (r_face_sets[i] != delete_id) {
2750 all_same_id =
false;
2765 if (r_face_sets[i] == delete_id) {
2771 bool any_updated =
false;
2774 int other_id = delete_id;
2775 for (
const int vert : corner_verts.
slice(faces[f_index])) {
2776 for (
const int neighbor_face_index : vert_to_face_map[vert]) {
2781 if (r_face_sets[neighbor_face_index] != delete_id) {
2782 other_id = r_face_sets[neighbor_face_index];
2787 if (other_id != delete_id) {
2789 r_face_sets[f_index] = other_id;
2830 if (expand_cache.
brush) {
2853 switch (expand_cache.
target) {
2872 const Mesh &
mesh = *id_cast<const Mesh *>(
object.
data);
2875 if (
mask.is_empty()) {
2879 mask.begin(),
mask.end(), [&](
const float value) { return value > 0.0f; });
2884 if (
mask.is_empty()) {
2888 mask.begin(),
mask.end(), [&](
const float value) { return value > 0.0f; });
3009 switch (
pbvh.type()) {
3023 const Mesh &base_mesh = *id_cast<const Mesh *>(ob.
data);
3025 const Span<int> corner_verts = base_mesh.corner_verts();
3053 *depsgraph, *ss.
expand_cache, ob, initial_vert, falloff_type);
3075 "RECURSION_STEP_GEODESIC",
3077 "Geodesic recursion step",
3080 "RECURSION_STEP_TOPOLOGY",
3082 "Topology recursion Step",
3088 "FALLOFF_TOPOLOGY_DIAGONALS",
3090 "Diagonals Falloff",
3095 "LOOP_COUNT_INCREASE",
3097 "Loop Count Increase",
3100 "LOOP_COUNT_DECREASE",
3102 "Loop Count Decrease",
3105 "BRUSH_GRADIENT_TOGGLE",
3107 "Toggle Brush Gradient",
3110 "TEXTURE_DISTORTION_INCREASE",
3112 "Texture Distortion Increase",
3115 "TEXTURE_DISTORTION_DECREASE",
3117 "Texture Distortion Decrease",
3119 {0,
nullptr, 0,
nullptr,
nullptr},
3122 static const char *name =
"Sculpt Expand Modal";
3136 ot->
name =
"Expand";
3137 ot->
idname =
"SCULPT_OT_expand";
3138 ot->
description =
"Generic sculpt expand operator";
3156 {0,
nullptr, 0,
nullptr,
nullptr},
3163 {0,
nullptr, 0,
nullptr,
nullptr},
3168 prop_sculpt_expand_target_type_items,
3171 "Data that is going to be modified in the expand operation");
3175 prop_sculpt_expand_falloff_type_items,
3178 "Initial falloff of the expand operation");
3181 ot->
srna,
"invert",
false,
"Invert",
"Invert the expand active elements");
3183 "use_mask_preserve",
3185 "Preserve Previous",
3186 "Preserve the previous state of the target data");
3188 "use_falloff_gradient",
3191 "Expand Using a linear falloff");
3194 "use_modify_active",
3197 "Modify the active face set instead of creating a new one");
3201 "use_reposition_pivot",
3204 "Reposition the sculpt transform pivot to the boundary of the expand active area");
3207 "max_geodesic_move_preview",
3211 "Max Vertex Count for Geodesic Move Preview",
3212 "Maximum number of vertices in the mesh for using geodesic falloff when "
3213 "moving the origin of expand. If the total number of vertices is greater "
3214 "than this value, the falloff will be set to spherical when moving",
3221 "Fill in mask if nothing is already masked");
3223 "normal_falloff_smooth",
3228 "Blurring steps for normal falloff",
A BVH for high poly meshes.
BLI_LINKSTACK_*** wrapper macros for using a LinkNode to store a stack of pointers,...
#define BLI_LINKSTACK_PUSH(var, ptr)
#define BLI_LINKSTACK_DECLARE(var, type)
#define BLI_LINKSTACK_SIZE(var)
#define BLI_LINKSTACK_FREE(var)
#define BLI_LINKSTACK_INIT(var)
#define BLI_LINKSTACK_POP(var)
#define BLI_LINKSTACK_SWAP(var_a, var_b)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
#define BM_ELEM_CD_SET_FLOAT(ele, offset, f)
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_elem_index_get(ele)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
MutableSpan< T > as_mutable_span()
void fill(const T &value) const
void reinitialize(const int64_t new_size)
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
static IndexMask from_bits(BitSpan bits, LinearAllocator<> &memory)
static IndexMask from_indices(Span< T > indices, LinearAllocator<> &memory)
constexpr IndexRange()=default
MutableBoundedBitSpan()=default
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr const T * end() const
constexpr IndexRange index_range() const
constexpr const T * begin() const
constexpr bool is_empty() const
static VArray from_span(Span< T > values)
void append(const T &value)
IndexRange index_range() const
Span< T > as_span() const
void separator(float factor=1.0f)
void item(std::string text, int icon1, int icon2=0)
void opmodal(std::string text, const wmOperatorType *ot, int propvalue, bool inverted=false)
void fill(const bool value)
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef name) const
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
bool remove(const StringRef name)
constexpr bool is_empty() const
int64_t min_array_size() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexRange index_range() const
ccl_device_inline float2 fmod(const float2 a, const float b)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
void invert(BitSpanT &&data)
IndexRange grid_range(const int grid_area, const int grid)
GroupedSpan< int > build_edge_to_face_map(OffsetIndices< int > faces, Span< int > corner_edges, int edges_num, Array< int > &r_offsets, Array< int > &r_indices)
GroupedSpan< int > build_vert_to_edge_map(Span< int2 > edges, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
pbvh::Tree * pbvh_get(Object &object)
void update_mask_bmesh(const BMesh &bm, const IndexMask &node_mask, Tree &pbvh)
void update_mask_mesh(const Mesh &mesh, const IndexMask &node_mask, Tree &pbvh)
IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory)
void node_update_mask_bmesh(int mask_offset, BMeshNode &node)
void node_update_mask_grids(const CCGKey &key, Span< float > masks, GridsNode &node)
Span< float3 > vert_normals_eval(const Depsgraph &depsgraph, const Object &object_orig)
void update_mask_grids(const SubdivCCG &subdiv_ccg, const IndexMask &node_mask, Tree &pbvh)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
std::unique_ptr< SculptBoundary > data_init(const Depsgraph &depsgraph, Object &object, const Brush *brush, const int initial_vert, const float radius)
void ensure_boundary_info(Object &object)
bool vert_is_boundary(const GroupedSpan< int > vert_to_face_map, const Span< bool > hide_poly, const BitSpan boundary_verts, const int vert)
bke::GSpanAttributeWriter active_color_attribute_for_write(Mesh &mesh)
float4 color_vert_get(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face_map, GSpan color_attribute, bke::AttrDomain color_domain, int vert)
void color_vert_set(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face_map, bke::AttrDomain color_domain, int vert, const float4 &color, GMutableSpan color_attribute)
bke::GAttributeReader active_color_attribute(const Mesh &mesh)
static Array< float > geodesic_falloff_create(const Depsgraph &depsgraph, Object &ob, const IndexMask &initial_verts)
static float calc_new_mask_bmesh(const SculptSession &ss, const Cache &expand_cache, const float old_mask, const BitSpan enabled_verts, const BMVert *vert)
static void calc_falloff_from_vert_and_symmetry(const Depsgraph &depsgraph, Cache &expand_cache, Object &ob, const int vert, FalloffType falloff_type)
static bool any_nonzero_mask(const Object &object)
static void ensure_sculptsession_data(Object &ob)
static void vert_to_face_falloff_mesh(Mesh *mesh, Cache &expand_cache)
static Array< float > spherical_falloff_create(const Depsgraph &depsgraph, const Object &object, const int vert)
static wmOperatorStatus sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void calc_topology_falloff_from_verts(Object &ob, const IndexMask &initial_verts, MutableSpan< float > distances)
static void geodesics_from_state_boundary(const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const BitSpan enabled_verts)
static void undo_push(const Depsgraph &depsgraph, Object &ob, Cache &expand_cache)
static void topology_from_state_boundary(Object &ob, Cache &expand_cache, const BitSpan enabled_verts)
static void move_propagation_origin(bContext *C, Object &ob, const wmEvent *event, Cache &expand_cache)
static void check_topology_islands(Object &ob, FalloffType falloff_type)
static BitVector enabled_state_to_bitmap(const Depsgraph &depsgraph, const Object &object, const Cache &expand_cache)
static float falloff_value_vertex_get(const SculptSession &ss, const Cache &expand_cache, const float3 &position, const int vert)
static void sculpt_expand_status(bContext *C, wmOperator *op, Cache *expand_cache)
@ SCULPT_EXPAND_MODAL_GRADIENT_TOGGLE
@ SCULPT_EXPAND_MODAL_RECURSION_STEP_TOPOLOGY
@ SCULPT_EXPAND_MODAL_BRUSH_GRADIENT_TOGGLE
@ SCULPT_EXPAND_MODAL_FALLOFF_CYCLE
@ SCULPT_EXPAND_MODAL_LOOP_COUNT_INCREASE
@ SCULPT_EXPAND_MODAL_FALLOFF_SPHERICAL
@ SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC
@ SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY
@ SCULPT_EXPAND_MODAL_LOOP_COUNT_DECREASE
@ SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_DECREASE
@ SCULPT_EXPAND_MODAL_SNAP_TOGGLE
@ SCULPT_EXPAND_MODAL_PRESERVE_TOGGLE
@ SCULPT_EXPAND_MODAL_CANCEL
@ SCULPT_EXPAND_MODAL_RECURSION_STEP_GEODESIC
@ SCULPT_EXPAND_MODAL_INVERT
@ SCULPT_EXPAND_MODAL_TEXTURE_DISTORTION_INCREASE
@ SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS
@ SCULPT_EXPAND_MODAL_CONFIRM
@ SCULPT_EXPAND_MODAL_MOVE_TOGGLE
static wmOperatorStatus sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void original_state_store(Object &ob, Cache &expand_cache)
static void finish(bContext *C)
static void update_max_vert_falloff_value(const Object &object, Cache &expand_cache)
static void vert_to_face_falloff(Object &object, Mesh *mesh, Cache &expand_cache)
void modal_keymap(wmKeyConfig *keyconf)
static bool update_mask_grids(const SculptSession &ss, const BitSpan enabled_verts, bke::pbvh::GridsNode &node, SubdivCCG &subdiv_ccg)
static void init_from_face_set_boundary(const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const int active_face_set, const bool internal_falloff)
static std::optional< int > target_vert_update_and_get(bContext *C, Object &ob, const float mval[2])
static void restore_color_data(Object &ob, Cache &expand_cache)
static bool 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 bool is_vert_in_active_component(const SculptSession &ss, const Cache &expand_cache, const int vert)
static void expand_cache_free(SculptSession &ss)
static Array< float > normals_falloff_create(const Depsgraph &depsgraph, Object &ob, const int vert, const float edge_sensitivity, const int blur_steps)
static void delete_face_set_id(int *r_face_sets, Object &object, Cache &expand_cache, Mesh *mesh, const int delete_id)
static void reposition_pivot(bContext *C, Object &ob, Cache &expand_cache)
static void update_for_vert(bContext *C, Object &ob, const std::optional< int > vertex)
static void face_sets_restore(Object &object, Cache &expand_cache)
static void calc_new_mask_mesh(const SculptSession &ss, const Span< float3 > positions, const BitSpan enabled_verts, const Span< int > verts, const MutableSpan< float > mask)
static void face_sets_update(Object &object, Cache &expand_cache)
static void find_active_connected_components_from_vert(const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const int initial_vertex)
void SCULPT_OT_expand(wmOperatorType *ot)
static void update_max_face_falloff_factor(const Object &object, Mesh &mesh, Cache &expand_cache)
static void vert_to_face_falloff_grids(SculptSession &ss, Mesh *mesh, Cache &expand_cache)
static bool 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 Array< float > diagonals_falloff_create(const Depsgraph &depsgraph, Object &ob, const int vert)
static void restore_original_state(bContext *C, Object &ob, Cache &expand_cache)
static Array< float > topology_falloff_create(const Depsgraph &depsgraph, Object &ob, const int initial_vert)
static void resursion_step_add(const Depsgraph &depsgraph, Object &ob, Cache &expand_cache, const RecursionType recursion_type)
static IndexMask boundary_from_enabled(Object &object, const BitSpan enabled_verts, const bool use_mesh_boundary, IndexMaskMemory &memory)
static void cache_initial_config_set(bContext *C, wmOperator *op, Cache &expand_cache)
static Array< float > boundary_topology_falloff_create(const Depsgraph &depsgraph, Object &ob, const int initial_vert)
static float gradient_value_get(const SculptSession &ss, const Cache &expand_cache, const float3 &position, const int vert)
static bool vert_falloff_is_enabled(const SculptSession &ss, const Cache &expand_cache, const float3 &position, const int vert)
static bool 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 restore_face_set_data(Object &object, Cache &expand_cache)
static void sculpt_expand_cancel(bContext *C, wmOperator *)
static void snap_init_from_enabled(const Depsgraph &depsgraph, const Object &object, Cache &expand_cache)
static int active_face_set_id_get(Object &object, Cache &expand_cache)
static bool update_mask_bmesh(SculptSession &ss, const BitSpan enabled_verts, const int mask_offset, const Span< float > old_mask, bke::pbvh::BMeshNode *node)
static float max_vert_falloff_get(const Cache &expand_cache)
static void write_mask_data(Object &object, const Span< float > mask)
static bool set_initial_components_for_mouse(bContext *C, Object &ob, Cache &expand_cache, const float mval[2])
bool vert_has_unique_face_set(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, int vert)
bool coord_has_face_set(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, const SubdivCCG &subdiv_ccg, const SubdivCCGCoord coord, const int face_set)
bool vert_has_any_face_set(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, int vert, const Set< int > &allowed_face_sets)
bool vert_has_face_set(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, const int vert, const int face_set)
bool create_face_sets_mesh(Object &object)
Array< int > duplicate_face_sets(const Mesh &mesh)
bke::SpanAttributeWriter< int > ensure_face_sets_mesh(Mesh &mesh)
bool coord_has_any_face_set(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, const SubdivCCG &subdiv_ccg, const SubdivCCGCoord coord, const Set< int > &allowed_face_sets)
int find_next_available_id(const Mesh &mesh)
int active_face_set_get(const Object &object)
Array< float > distances_create(const Span< float3 > vert_positions, const Span< int2 > edges, const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_edge_map, const GroupedSpan< int > edge_to_face_map, const Span< bool > hide_poly, const Set< int > &initial_verts, const float limit_radius)
void ensure_cache(Object &object)
int vert_id_get(const SculptSession &ss, const int vert)
void update_mask_mesh(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, FunctionRef< void(MutableSpan< float >, Span< int >)> update_fn)
Array< float > duplicate_mask(const Object &object)
void clamp_mask(const MutableSpan< float > masks)
void blur_geometry_data_array(const Object &object, const int iterations, const MutableSpan< float > data)
void push_end(Object &ob)
void push_nodes(const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const Type type)
void push_begin(const Scene &scene, Object &ob, const wmOperator *op)
std::array< int, PAINT_SYMM_AREAS > find_all_symm_verts_bmesh(const Object &object, const int original_vert, const float max_distance)
void face_set_overlay_check(bContext &C, wmOperator &op)
bool check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm)
void vert_random_access_ensure(Object &object)
std::optional< int > nearest_vert_calc_mesh(const bke::pbvh::Tree &pbvh, const Span< float3 > vert_positions, const Span< bool > hide_vert, const float3 &location, const float max_distance, const bool use_original)
Vector< int > find_symm_verts_grids(const Object &object, const int original_vert, const float max_distance)
Vector< BMVert *, 64 > BMeshNeighborVerts
int vertex_count_get(const Object &object)
float3 symmetry_flip(const float3 &src, const ePaintSymmetryFlags symm)
ePaintSymmetryFlags mesh_symmetry_xyz_get(const Object &object)
Vector< int > find_symm_verts_mesh(const Depsgraph &depsgraph, const Object &object, const int original_vert, const float max_distance)
bool sculpt_mode_poll(bContext *C)
std::array< int, PAINT_SYMM_AREAS > find_all_symm_verts_grids(const Object &object, const int original_vert, const float max_distance)
Span< BMVert * > vert_neighbors_get_bmesh(BMVert &vert, BMeshNeighborVerts &r_neighbors)
void flush_update_step(bContext *C, const UpdateType update_type)
void flush_update_done(bContext *C, Object &ob, const UpdateType update_type)
std::optional< BMVert * > nearest_vert_calc_bmesh(const bke::pbvh::Tree &pbvh, const float3 &location, const float max_distance, const bool use_original)
std::optional< CursorGeometryInfo > cursor_geometry_info_update(bContext *C, const float2 &mval, const bool use_sampled_normal)
std::optional< SubdivCCGCoord > nearest_vert_calc_grids(const bke::pbvh::Tree &pbvh, const SubdivCCG &subdiv_ccg, const float3 &location, const float max_distance, const bool use_original)
Vector< int > find_symm_verts(const Depsgraph &depsgraph, const Object &object, const int original_vert, const float max_distance)
Span< int > vert_neighbors_get_mesh(const OffsetIndices< int > faces, const Span< int > corner_verts, const GroupedSpan< int > vert_to_face, const Span< bool > hide_poly, const int vert, Vector< int > &r_neighbors)
void mask_overlay_check(bContext &C, wmOperator &op)
std::array< int, PAINT_SYMM_AREAS > find_all_symm_verts_mesh(const Depsgraph &depsgraph, const Object &object, const int original_vert, const float max_distance)
void tag_update_overlays(bContext *C)
std::array< int, PAINT_SYMM_AREAS > find_all_symm_verts(const Depsgraph &depsgraph, const Object &object, const int original_vert, const float max_distance)
Vector< int > find_symm_verts_bmesh(const Object &object, const int original_vert, const float max_distance)
bool is_symmetry_iteration_valid(const char i, const char symm)
constexpr ParallelGrainSize grain_size(int grain_size)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
void parallel_for_aligned(const IndexRange range, const int64_t grain_size, const int64_t alignment, const Function &function)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
MINLINE float min_ff(float a, float b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int RNA_enum_get(PointerRNA *ptr, const char *name)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
MultiresModifierData * BKE_sculpt_multires_active(const Scene *scene, Object *ob)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
float BKE_brush_sample_tex_3d(const Paint *paint, const Brush *br, const MTex *mtex, const float3 &point, float4 &rgba, int thread, ImagePool *pool)
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void copy_v4_fl(float r[4], float f)
MINLINE int max_ii(int a, int b)
void BKE_subdiv_ccg_average_grids(SubdivCCG &subdiv_ccg)
Base * CTX_data_active_base(const bContext *C)
bool BM_vert_is_boundary(const BMVert *v)
void BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph, Main *bmain, Object *ob, MultiresModifierData *mmd)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
VecBase< float, 4 > float4
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
void BKE_curvemapping_init(CurveMapping *cumap)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_other_verts(bke::pbvh::BMeshNode *node)
void IMB_blend_color_float(float dst[4], const float src1[4], const float src2[4], IMB_BlendMode mode)
ToolSettings * CTX_data_tool_settings(const bContext *C)
VecBase< double, 3 > double3
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
const MTex * BKE_brush_mask_texture_get(const Brush *brush, PaintMode paint_mode)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void BKE_sculpt_color_layer_create_if_needed(Object *object)
int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG &subdiv_ccg, const int grid_index)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
Main * CTX_data_main(const bContext *C)
Paint * BKE_paint_get_active_from_context(const bContext *C)
MINLINE float max_ff(float a, float b)
void BKE_sculptsession_update_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
void BKE_subdiv_ccg_foreach_visible_grid_vert(const CCGKey &key, const BitGroupVector<> &grid_hidden, const int grid, const Fn &fn)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
Scene * CTX_data_scene(const bContext *C)
float3 BKE_brush_color_get(const Paint *paint, const Brush *brush)
ImagePool * BKE_image_pool_new()
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
@ OPTYPE_DEPENDS_ON_CURSOR
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
Object * CTX_data_active_object(const bContext *C)
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(bke::pbvh::BMeshNode *node)
void ED_workspace_status_text(bContext *C, const char *str)
View3D * CTX_wm_view3d(const bContext *C)
MINLINE float clamp_f(float value, float min, float max)
#define SCULPT_EXPAND_LOOP_THRESHOLD
#define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP
#define EXPAND_ACTIVE_COMPONENT_NONE
#define SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY
#define EXPAND_SYMM_AREAS
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct CurveMapping * curve_distance_falloff
eMTex_BrushMapMode brush_map_mode
bke::ObjectRuntime * runtime
std::unique_ptr< SculptBoundaryInfoCache > boundary_info_cache
std::optional< int > active_face_index
int last_active_vert_index() const
std::optional< int > active_grid_index
ed::sculpt_paint::expand::Cache * expand_cache
int active_vert_index() const
static SubdivCCGCoord from_index(const CCGKey &key, int index)
int to_index(const CCGKey &key) const
SubdivCCGNeighborCoords coords
Array< float3 > positions
SculptSession * sculpt_session
MutableVArraySpan< T > span
float2 original_mouse_move
std::unique_ptr< Set< int > > snap_enabled_face_sets
float2 initial_mouse_move
bool modify_active_face_set
FalloffType move_original_falloff_type
Array< float > face_falloff
int initial_active_face_set
Array< int > original_face_sets
Array< float > vert_falloff
Array< float4 > original_colors
Array< int > initial_face_sets
int normal_falloff_blur_steps
IndexMaskMemory node_mask_memory
FalloffType move_preview_falloff_type
int active_connected_islands[EXPAND_SYMM_AREAS]
int max_geodesic_move_preview
float texture_distortion_strength
Array< float > original_mask
void add_initial(BMVert *vertex)
void add_and_skip_initial(BMVert *vertex, int index)
void execute(Object &object, FunctionRef< bool(BMVert *from_v, BMVert *to_v)> func)
void execute(Object &object, const SubdivCCG &subdiv_ccg, FunctionRef< bool(SubdivCCGCoord from_v, SubdivCCGCoord to_v, bool is_duplicate)> func)
void add_initial(SubdivCCGCoord vertex)
void add_and_skip_initial(SubdivCCGCoord vertex, int index)
void execute(Object &object, GroupedSpan< int > vert_to_face_map, FunctionRef< bool(int from_v, int to_v)> func)
void add_and_skip_initial(int vertex)
void add_initial(int vertex)
void(*) cancel(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type