49 float3 target = initial_target;
56 segments[
i].initial_orig);
60 float3 current_head_position = segments[
i].orig + current_orientation * segments[
i].len;
63 float3 current_origin_position = target - current_head_position;
66 segments[
i].head = current_head_position;
67 segments[
i].orig += current_origin_position;
70 target = segments[
i].orig;
75 float3 anchor_diff = segments.
last().initial_orig - segments.
last().orig;
77 segments[
i].orig += anchor_diff;
78 segments[
i].head += anchor_diff;
89 segments[
i].initial_orig);
90 float initial_rotation[4];
91 float current_rotation[4];
108 add_v3_v3v3(segment.head, segment.initial_head, delta);
109 add_v3_v3v3(segment.orig, segment.initial_orig, delta);
138 float3 position = positions[
i];
143 translations[
i] = position - positions[
i];
189 add_arrays(translations, segment_translations);
197 position_data.deform(translations,
verts);
238 gather_data_grids(subdiv_ccg, segment.weights.as_span(), grids, segment_weights);
240 add_arrays(translations, segment_translations);
255 cache.
cloth_sim->deformation_pos.as_mutable_span());
294 add_arrays(translations, segment_translations);
338 for (
const int i :
verts.index_range()) {
342 neighbor_offsets[
i] = neighbor_data_with_fake.
size();
343 neighbor_data_with_fake.
extend(orig_neighbors);
344 const int neighbor = fake_neighbors[
verts[
i]];
346 neighbor_data_with_fake.
append(neighbor);
349 neighbor_offsets.
last() = neighbor_data_with_fake.
size();
353 const float3 &pose_initial_position,
388 for (
const int i :
verts.index_range()) {
389 const int vert =
verts[
i];
392 for (
const int neighbor : neighbors[
i]) {
393 max = std::max(
max, prev_mask[neighbor]);
396 if (
max > prev_mask[vert]) {
398 pose_factor[vert] =
max;
408 const float3 &pose_initial_position,
422 const int grid = grids[
i];
427 if (!grid_hidden.
is_empty() && grid_hidden[grid][offset]) {
430 const int vert = grid_range[offset];
442 max = std::max(
max, prev_mask[fake_neighbors[vert]]);
446 if (
max > prev_mask[vert]) {
447 const float3 &position = positions[vert];
448 pose_factor[vert] =
max;
460 const float3 &pose_initial_position,
480 max = std::max(
max, prev_mask[fake_neighbors[vert]]);
484 if (
max > prev_mask[vert]) {
485 const float3 position = bm_vert->co;
486 pose_factor[vert] =
max;
500 float pose_origin[3],
501 float pose_target[3],
503 float *r_pose_origin,
513 bool grow_next_iteration =
true;
516 while (grow_next_iteration) {
521 switch (pbvh.
type()) {
539 GrowFactorLocalData &tls = all_tls.local();
540 node_mask.slice(range).foreach_index([&](const int i) {
541 grow_factors_mesh(symm,
569 node_mask.slice(range).foreach_index([&](const int i) {
570 grow_factors_grids(symm,
591 node_mask.slice(range).foreach_index([&](const int i) {
593 symm, pose_target, fake_neighbors, prev_mask, nodes[i], pose_factor, gftd);
602 if (gftd.pos_count != 0) {
603 gftd.pos_avg /=
float(gftd.pos_count);
609 if (
len < prev_len) {
611 grow_next_iteration =
true;
614 grow_next_iteration =
false;
615 pose_factor.copy_from(prev_mask);
624 grow_next_iteration =
true;
627 grow_next_iteration =
false;
631 pose_factor.copy_from(prev_mask);
639 grow_next_iteration =
false;
649 for (
char i = 0;
i <= symm; ++
i) {
667 const float3 &initial_location,
674 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
686 float3 fallback_floodfill_origin = initial_location;
687 flood.
execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
688 r_pose_factor[to_v] = 1.0f;
690 const float3 co = positions_eval[to_v];
694 fallback_floodfill_origin = co;
710 r_pose_origin = pose_origin /
float(tot_co);
713 r_pose_origin = fallback_floodfill_origin;
719 const float3 &initial_location,
738 float3 fallback_floodfill_origin = initial_location;
741 const int to_v_i = to_v.
to_index(key);
743 r_pose_factor[to_v_i] = 1.0f;
745 const float3 &co = positions[to_v_i];
749 fallback_floodfill_origin = co;
767 r_pose_origin = pose_origin /
float(tot_co);
770 r_pose_origin = fallback_floodfill_origin;
776 const float3 &initial_location,
793 float3 fallback_floodfill_origin = initial_location;
796 r_pose_factor[to_v_i] = 1.0f;
802 fallback_floodfill_origin = co;
818 r_pose_origin = pose_origin /
float(tot_co);
821 r_pose_origin = fallback_floodfill_origin;
828 const float3 &initial_location,
840 depsgraph,
object, ss, initial_location, radius, pose_origin, r_pose_factor);
844 object, ss, initial_location, radius, pose_origin, r_pose_factor);
848 object, ss, initial_location, radius, pose_origin, r_pose_factor);
854 pose_origin += pose_dir * radius * pose_offset;
855 r_pose_origin = pose_origin;
859 if (pose_offset != 0.0f) {
865static std::unique_ptr<IKChain>
ik_chain_new(
const int totsegments,
const int totverts)
867 std::unique_ptr<IKChain> ik_chain = std::make_unique<IKChain>();
868 ik_chain->segments.reinitialize(totsegments);
880 for (
const int i : ik_chain.
segments.index_range()) {
882 head = initial_location;
890 ik_chain.
segments[
i].initial_orig = origin;
892 ik_chain.
segments[
i].initial_head = head;
916 const float3 &initial_location,
920 const float chain_segment_len = radius * (1.0f + brush.
pose_offset);
925 int nearest_vertex_index = -1;
927 switch (pbvh.
type()) {
929 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
937 std::numeric_limits<float>::max(),
939 nearest_vertex_index = *nearest;
945 pbvh, subdiv_ccg, initial_location, std::numeric_limits<float>::max(),
true);
947 nearest_vertex_index = nearest->to_index(key);
952 pbvh, initial_location, std::numeric_limits<float>::max(),
false);
967 pose_factor_grow[nearest_vertex_index] = 1.0f;
970 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(tot_segments, totvert);
979 ik_chain->segments[0].orig,
982 float3 next_chain_segment_target = ik_chain->segments[0].orig;
986 for (
int j = 0; j < totvert; j++) {
987 ik_chain->segments[0].weights[j] = pose_factor_grow[j];
988 pose_factor_grow_prev[j] = pose_factor_grow[j];
992 for (
const int i : ik_chain->segments.index_range().drop_front(1)) {
999 next_chain_segment_target,
1001 ik_chain->segments[
i].orig,
1003 next_chain_segment_target = ik_chain->segments[
i].orig;
1007 for (
int j = 0; j < totvert; j++) {
1008 ik_chain->segments[
i].weights[j] = pose_factor_grow[j] - pose_factor_grow_prev[j];
1010 pose_factor_grow_prev[j] = pose_factor_grow[j];
1025 struct SegmentData {
1043 vert_positions.
size());
1053 for (
const int i : ik_chain->segments.index_range()) {
1054 const bool is_first_iteration =
i == 0;
1060 visited_face_sets.
add(current_data.face_set);
1063 std::optional<SegmentData> next_segment_data;
1065 float3 face_set_boundary_accum(0);
1066 int face_set_boundary_count = 0;
1068 float3 fallback_accum(0);
1069 int fallback_count = 0;
1071 const float3 &pose_initial_co = vert_positions[current_data.vert];
1072 flood_fill.execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1073 const float3 &to_v_position = vert_positions[to_v];
1075 to_v_position, pose_initial_co, symm);
1081 pose_factor[to_v] = 1.0f;
1082 is_weighted[to_v].set();
1086 vert_to_face_map, face_sets, to_v);
1087 visited_face_sets.
add(visited_face_set);
1089 else if (symmetry_check) {
1091 visited_face_sets.
add(current_data.face_set);
1100 bool is_vertex_valid =
false;
1101 if (is_first_iteration) {
1102 for (
const int visited_face_set : visited_face_sets) {
1104 vert_to_face_map, face_sets, to_v, visited_face_set);
1109 vert_to_face_map, face_sets, to_v, current_data.face_set);
1112 if (!is_vertex_valid) {
1116 bool visit_next =
false;
1117 if (!is_weighted[to_v]) {
1118 pose_factor[to_v] = 1.0f;
1119 is_weighted[to_v].set();
1124 if (symmetry_check) {
1125 fallback_accum += to_v_position;
1136 bool count_as_boundary =
false;
1139 faces, corner_verts, vert_to_face_map, hide_poly, to_v, neighbors))
1142 vert_to_face_map, face_sets, neighbor_idx);
1146 !visited_face_sets.
contains(next_face_set_candidate))
1148 if (!next_segment_data) {
1149 next_segment_data = {neighbor_idx, next_face_set_candidate};
1151 count_as_boundary =
true;
1156 if (count_as_boundary) {
1157 face_set_boundary_accum += to_v_position;
1158 face_set_boundary_count++;
1163 if (face_set_boundary_count > 0) {
1164 ik_chain->segments[
i].orig = face_set_boundary_accum /
float(face_set_boundary_count);
1166 else if (fallback_count > 0) {
1167 ik_chain->segments[
i].orig = fallback_accum /
float(fallback_count);
1170 ik_chain->segments[
i].orig =
float3(0);
1173 current_data = *next_segment_data;
1186 struct SegmentData {
1191 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
1214 for (
const int i : ik_chain->segments.index_range()) {
1215 const bool is_first_iteration =
i == 0;
1220 visited_face_sets.
add(current_data.face_set);
1223 std::optional<SegmentData> next_segment_data;
1225 float3 face_set_boundary_accum(0);
1226 int face_set_boundary_count = 0;
1228 float3 fallback_accum(0);
1229 int fallback_count = 0;
1231 const float3 &pose_initial_co = positions[current_data.vert];
1236 const int to_v_i = to_v.
to_index(key);
1238 const float3 to_v_position = positions[to_v_i];
1240 to_v_position, pose_initial_co, symm) &&
1247 pose_factor[to_v_i] = 1.0f;
1248 is_weighted[to_v_i].set();
1253 visited_face_sets.
add(visited_face_set);
1255 else if (symmetry_check) {
1258 visited_face_sets.
add(current_data.face_set);
1267 bool is_vertex_valid =
false;
1268 if (is_first_iteration) {
1269 for (
const int visited_face_set : visited_face_sets) {
1271 subdiv_ccg, face_sets, to_v.
grid_index, visited_face_set);
1276 subdiv_ccg, face_sets, to_v.
grid_index, current_data.face_set);
1279 if (!is_vertex_valid) {
1283 bool visit_next =
false;
1284 if (!is_weighted[to_v_i]) {
1285 pose_factor[to_v_i] = 1.0f;
1286 is_weighted[to_v_i].set();
1291 if (symmetry_check) {
1292 fallback_accum += to_v_position;
1296 if (!symmetry_check ||
1298 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v))
1305 bool count_as_boundary =
false;
1314 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, neighbor) &&
1315 !visited_face_sets.
contains(next_face_set_candidate))
1317 if (!next_segment_data) {
1318 next_segment_data = {neighbor.
to_index(key), next_face_set_candidate};
1320 count_as_boundary =
true;
1325 if (count_as_boundary) {
1326 face_set_boundary_accum += to_v_position;
1327 face_set_boundary_count++;
1332 if (face_set_boundary_count > 0) {
1333 ik_chain->segments[
i].orig = face_set_boundary_accum /
float(face_set_boundary_count);
1335 else if (fallback_count > 0) {
1336 ik_chain->segments[
i].orig = fallback_accum /
float(fallback_count);
1339 ik_chain->segments[
i].orig =
float3(0);
1342 current_data = *next_segment_data;
1355 struct SegmentData {
1373 for (
const int i : ik_chain->segments.index_range()) {
1374 const bool is_first_iteration =
i == 0;
1380 visited_face_sets.
add(current_data.face_set);
1383 std::optional<SegmentData> next_segment_data;
1385 float3 face_set_boundary_accum(0);
1386 int face_set_boundary_count = 0;
1388 float3 fallback_accum(0);
1389 int fallback_count = 0;
1391 const float3 pose_initial_co = current_data.vert->co;
1395 const float3 to_v_position = to_v->
co;
1397 to_v_position, pose_initial_co, symm);
1403 pose_factor[to_v_i] = 1.0f;
1404 is_weighted[to_v_i].set();
1408 visited_face_sets.
add(visited_face_set);
1410 else if (symmetry_check) {
1412 visited_face_sets.
add(current_data.face_set);
1421 bool is_vertex_valid =
false;
1422 if (is_first_iteration) {
1423 for (
const int visited_face_set : visited_face_sets) {
1429 face_set_offset, *to_v, current_data.face_set);
1432 if (!is_vertex_valid) {
1436 bool visit_next =
false;
1437 if (!is_weighted[to_v_i]) {
1438 pose_factor[to_v_i] = 1.0f;
1439 is_weighted[to_v_i].set();
1444 if (symmetry_check) {
1445 fallback_accum += to_v_position;
1455 bool count_as_boundary =
false;
1463 !visited_face_sets.
contains(next_face_set_candidate))
1465 if (!next_segment_data) {
1466 next_segment_data = {neighbor, next_face_set_candidate};
1468 count_as_boundary =
true;
1473 if (count_as_boundary) {
1474 face_set_boundary_accum += to_v_position;
1475 face_set_boundary_count++;
1480 if (face_set_boundary_count > 0) {
1481 ik_chain->segments[
i].orig = face_set_boundary_accum /
float(face_set_boundary_count);
1483 else if (fallback_count > 0) {
1484 ik_chain->segments[
i].orig = fallback_accum /
float(fallback_count);
1487 ik_chain->segments[
i].orig =
float3(0);
1490 current_data = *next_segment_data;
1520 const int active_face_set,
1521 const int target_face_set)
1535 for (
const int vert : vert_positions.
index_range()) {
1536 if (floodfill_step[vert] != 0 &&
1540 sum += vert_positions[vert];
1547 const SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
1558 if (floodfill_step[index] != 0 &&
1562 sum += positions[index];
1571 BMesh &
bm = *
object.sculpt->bm;
1576 if (floodfill_step[vert] != 0 &&
1593 return std::nullopt;
1600 const float3 &initial_location)
1610 const int active_vert = std::get<int>(ss.
active_vert());
1616 floodfill_step[active_vert] = 1;
1620 int masked_face_set_it = 0;
1623 step_floodfill.
execute(
object, vert_to_face_map, [&](
int from_v,
int to_v) {
1624 floodfill_step[to_v] = floodfill_step[from_v] + 1;
1627 if (!visited_face_sets.
contains(to_face_set)) {
1633 visited_face_sets.
add(to_face_set);
1635 if (floodfill_step[to_v] >= masked_face_set_it) {
1636 masked_face_set = to_face_set;
1637 masked_face_set_it = floodfill_step[to_v];
1641 target_face_set = to_face_set;
1650 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1651 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1653 std::optional<float3> head = std::nullopt;
1654 if (target_face_set != masked_face_set) {
1656 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1659 ik_chain->segments[0].head = head.value_or(initial_location);
1660 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1665 weight_floodfill.
execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1666 fk_weights[to_v] = 1.0f;
1678 const float3 &initial_location)
1680 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
1690 const Span<int> grid_to_face_map = subdiv_ccg.grid_to_face_map;
1693 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, grids_num);
1701 floodfill_step[active_vert_index] = 1;
1705 int masked_face_set_it = 0;
1710 const int from_v_i = from_v.
to_index(key);
1711 const int to_v_i = to_v.
to_index(key);
1713 if (!is_duplicate) {
1714 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1717 floodfill_step[to_v_i] = floodfill_step[from_v_i];
1720 const int to_face_set = face_sets[grid_to_face_map[to_v.
grid_index]];
1721 if (!visited_face_sets.
contains(to_face_set)) {
1723 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v) &&
1725 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, from_v) &&
1729 visited_face_sets.
add(to_face_set);
1731 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1732 masked_face_set = to_face_set;
1733 masked_face_set_it = floodfill_step[to_v_i];
1737 target_face_set = to_face_set;
1743 subdiv_ccg, face_sets, to_v.
grid_index, active_face_set);
1747 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1748 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1750 std::optional<float3> head = std::nullopt;
1751 if (target_face_set != masked_face_set) {
1753 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1756 ik_chain->segments[0].head = head.value_or(initial_location);
1757 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1768 fk_weights[to_v_i] = 1.0f;
1770 subdiv_ccg, face_sets, to_v.
grid_index, masked_face_set);
1781 const float3 &initial_location)
1790 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, verts_num);
1799 floodfill_step[active_vert_index] = 1;
1803 int masked_face_set_it = 0;
1810 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1813 if (!visited_face_sets.
contains(to_face_set)) {
1819 visited_face_sets.
add(to_face_set);
1821 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1822 masked_face_set = to_face_set;
1823 masked_face_set_it = floodfill_step[to_v_i];
1827 target_face_set = to_face_set;
1836 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1837 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1839 std::optional<float3> head = std::nullopt;
1840 if (target_face_set != masked_face_set) {
1842 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1845 ik_chain->segments[0].head = head.value_or(initial_location);
1846 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1855 fk_weights[to_v_i] = 1.0f;
1867 const float3 &initial_location)
1885 const float3 &initial_location,
1888 std::unique_ptr<IKChain> ik_chain;
1892 if (use_fake_neighbors) {
1933 const float3 &initial_location,
1937 std::unique_ptr<SculptPoseIKChainPreview> preview = std::make_unique<SculptPoseIKChainPreview>();
1939 preview->initial_head_coords.reinitialize(chain.
segments.size());
1940 preview->initial_orig_coords.reinitialize(chain.
segments.size());
1941 for (
const int i : chain.
segments.index_range()) {
1942 preview->initial_head_coords[
i] = chain.
segments[
i].initial_head;
1943 preview->initial_orig_coords[
i] = chain.
segments[
i].initial_orig;
1961 ik_chain.
segments[0].initial_orig);
1964 const float segment_len = ik_chain.
segments[0].len;
2034 scale[0] = scale[1] =
sqrtf(1.0f / scale[2]);
2044 const float3 &grab_location)
2047 segment->head, symm, symm_area, grab_location);
2049 segment->orig, symm, symm_area, grab_location);
2096 for (
const int i : ik_chain.
segments.index_range()) {
2109 float pivot_local_space[4][4];
2126 for (
int scale_i = 0; scale_i < 3; scale_i++) {
2132 symm_orig[0] - symm_initial_orig[0],
2133 symm_orig[1] - symm_initial_orig[1],
2134 symm_orig[2] - symm_initial_orig[2]);
2138 ik_chain.
segments[
i].pivot_mat[symm_it].ptr(), symm_orig[0], symm_orig[1], symm_orig[2]);
2142 ik_chain.
segments[
i].pivot_mat[symm_it].ptr());
2147 switch (pbvh.
type()) {
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
int CCG_grid_xy_to_index(const int grid_size, const int x, const int y)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
#define SCULPT_FACE_SET_NONE
const Brush * BKE_paint_brush_for_read(const Paint *paint)
A BVH for high poly meshes.
const blender::Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(blender::bke::pbvh::BMeshNode *node)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
#define BLI_assert_unreachable()
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void mul_m4_m4_post(float R[4][4], const float B[4][4])
void unit_m4(float m[4][4])
void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q2[4])
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void quat_to_mat4(float m[4][4], const float q[4])
void axis_angle_normalized_to_quat(float r[4], const float axis[3], float angle)
void copy_qt_qt(float q[4], const float a[4])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
@ BRUSH_DEFORM_TARGET_CLOTH_SIM
@ BRUSH_DEFORM_TARGET_GEOMETRY
@ BRUSH_POSE_DEFORM_SQUASH_STRETCH
@ BRUSH_POSE_DEFORM_ROTATE_TWIST
@ BRUSH_POSE_DEFORM_SCALE_TRASLATE
@ BRUSH_USE_CONNECTED_ONLY
@ BRUSH_POSE_USE_LOCK_ROTATION
@ BRUSH_POSE_ORIGIN_FACE_SETS_FK
@ BRUSH_POSE_ORIGIN_TOPOLOGY
@ BRUSH_POSE_ORIGIN_FACE_SETS
Object is a sort of wrapper for general info.
#define BM_elem_index_get(ele)
int BM_mesh_elem_count(BMesh *bm, const char htype)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
BPy_StructRNA * depsgraph
static T sum(const btAlignedObjectArray< T > &items)
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr void fill(const T &value) const
constexpr Span< T > as_span() const
constexpr IndexRange index_range() const
constexpr T & last(const int64_t n=0) const
bool contains(const Key &key) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
void append(const T &value)
void extend(Span< T > array)
Span< T > as_span() const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef attribute_id) const
void tag_positions_changed(const IndexMask &node_mask)
Span< NodeT > nodes() const
void flush_bounds_to_parents()
IndexRange index_range() const
void foreach_index(Fn &&fn) const
VecBase< float, 3 > float3
IndexRange grid_range(const int grid_area, const int grid)
pbvh::Tree * pbvh_get(Object &object)
IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory)
void update_node_bounds_bmesh(BMeshNode &node)
void update_node_bounds_mesh(Span< float3 > positions, MeshNode &node)
void update_node_bounds_grids(int grid_area, Span< float3 > positions, GridsNode &node)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
void calc_vert_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::MeshNode &node, Span< int > verts, MutableSpan< float > factors)
void calc_grids_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::GridsNode &node, Span< int > grids, MutableSpan< float > factors)
int vert_face_set_get(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, const int vert)
bool vert_has_unique_face_set(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, int vert)
bool vert_has_face_set(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, const int vert, const int face_set)
int active_face_set_get(const Object &object)
Span< int > node_visible_verts(const bke::pbvh::MeshNode &node, const Span< bool > hide_vert, Vector< int > &indices)
void do_pose_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
static void grow_factors_bmesh(const ePaintSymmetryFlags symm, const float3 &pose_initial_position, const Span< int > fake_neighbors, const Span< float > prev_mask, bke::pbvh::BMeshNode &node, const MutableSpan< float > pose_factor, PoseGrowFactorData &gftd)
static std::unique_ptr< IKChain > ik_chain_init(const Depsgraph &depsgraph, Object &ob, SculptSession &ss, const Brush &brush, const float3 &initial_location, const float radius)
static BLI_NOINLINE void add_fake_neighbors(const Span< int > fake_neighbors, const Span< int > verts, const Span< int > orig_neighbor_data, MutableSpan< int > neighbor_offsets, Vector< int > &neighbor_data_with_fake)
static void solve_roll_chain(IKChain &ik_chain, const Brush &brush, const float roll)
static void calc_squash_stretch_deform(SculptSession &ss, const Brush &)
static std::unique_ptr< IKChain > ik_chain_init_face_sets(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const Brush &brush, const float radius)
static void solve_translate_chain(IKChain &ik_chain, const float delta[3])
static void calc_mesh(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const MeshAttributeData &attribute_data, const bke::pbvh::MeshNode &node, Object &object, BrushLocalData &tls, const PositionDeformData &position_data)
static void grow_factors_grids(const ePaintSymmetryFlags symm, const float3 &pose_initial_position, const SubdivCCG &subdiv_ccg, const Span< int > fake_neighbors, const Span< float > prev_mask, const bke::pbvh::GridsNode &node, const MutableSpan< float > pose_factor, PoseGrowFactorData &gftd)
static BLI_NOINLINE void calc_segment_translations(const Span< float3 > positions, const IKChainSegment &segment, const MutableSpan< float3 > translations)
static void calc_rotate_deform(SculptSession &ss, const Brush &brush)
static void calc_grids(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const bke::pbvh::GridsNode &node, Object &object, BrushLocalData &tls)
static bool vert_inside_brush_radius(const float3 &vertex, const float3 &br_co, float radius, char symm)
static int brush_num_effective_segments(const Brush &brush)
static std::unique_ptr< IKChain > ik_chain_init_face_sets_grids(Object &object, SculptSession &ss, const Brush &brush, const float radius)
static std::unique_ptr< IKChain > ik_chain_init_face_sets_fk_bmesh(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const float radius, const float3 &initial_location)
static std::unique_ptr< IKChain > ik_chain_init_face_sets_fk(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const float radius, const float3 &initial_location)
static float calc_scale_from_grab_delta(SculptSession &ss, const float3 &ik_target)
static void sculpt_pose_do_translate_deform(SculptSession &ss, const Brush &brush)
static void calc_scale_translate_deform(SculptSession &ss, const Brush &brush)
static void ik_chain_origin_heads_init(IKChain &ik_chain, const float3 &initial_location)
static std::unique_ptr< IKChain > ik_chain_init_face_sets_fk_mesh(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const float radius, const float3 &initial_location)
static void calc_pose_origin_and_factor_bmesh(Object &object, SculptSession &ss, const float3 &initial_location, float radius, float3 &r_pose_origin, MutableSpan< float > r_pose_factor)
static void calc_twist_deform(SculptSession &ss, const Brush &brush)
static void calc_scale_deform(SculptSession &ss, const Brush &brush)
static std::unique_ptr< IKChain > ik_chain_init_face_sets_fk_grids(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const float radius, const float3 &initial_location)
static std::unique_ptr< IKChain > ik_chain_new(const int totsegments, const int totverts)
static void calc_pose_origin_and_factor_mesh(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const float3 &initial_location, float radius, float3 &r_pose_origin, MutableSpan< float > r_pose_factor)
static std::optional< float3 > calc_average_face_set_center(const Depsgraph &depsgraph, Object &object, const Span< int > floodfill_step, const int active_face_set, const int target_face_set)
static std::unique_ptr< IKChain > ik_chain_init_face_sets_bmesh(Object &object, SculptSession &ss, const Brush &brush, const float radius)
static BLI_NOINLINE void add_arrays(const MutableSpan< float3 > a, const Span< float3 > b)
static void calc_rotate_twist_deform(SculptSession &ss, const Brush &brush)
static void solve_scale_chain(IKChain &ik_chain, const float scale[3])
static std::unique_ptr< IKChain > ik_chain_init_face_sets_mesh(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const Brush &brush, const float radius)
static void align_pivot_local_space(float r_mat[4][4], ePaintSymmetryFlags symm, ePaintSymmetryAreas symm_area, IKChainSegment *segment, const float3 &grab_location)
static void grow_factors_mesh(const ePaintSymmetryFlags symm, const float3 &pose_initial_position, 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< bool > hide_poly, const Span< int > fake_neighbors, const Span< float > prev_mask, const bke::pbvh::MeshNode &node, GrowFactorLocalData &tls, const MutableSpan< float > pose_factor, PoseGrowFactorData &gftd)
static void solve_ik_chain(IKChain &ik_chain, const float3 &initial_target, const bool use_anchor)
static void grow_pose_factor(const Depsgraph &depsgraph, Object &ob, SculptSession &ss, float pose_origin[3], float pose_target[3], float max_len, float *r_pose_origin, MutableSpan< float > pose_factor)
static std::unique_ptr< IKChain > ik_chain_init_topology(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const Brush &brush, const float3 &initial_location, const float radius)
static void calc_pose_origin_and_factor_grids(Object &object, SculptSession &ss, const float3 &initial_location, float radius, float3 &r_pose_origin, MutableSpan< float > r_pose_factor)
static void calc_bmesh(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, bke::pbvh::BMeshNode &node, Object &object, BrushLocalData &tls)
static void calc_pose_data(const Depsgraph &depsgraph, Object &object, SculptSession &ss, const float3 &initial_location, float radius, float pose_offset, float3 &r_pose_origin, MutableSpan< float > r_pose_factor)
std::unique_ptr< SculptPoseIKChainPreview > preview_ik_chain_init(const Depsgraph &depsgraph, Object &ob, SculptSession &ss, const Brush &brush, const float3 &initial_location, const float radius)
static void pose_brush_init(const Depsgraph &depsgraph, Object &ob, SculptSession &ss, const Brush &brush)
void blur_geometry_data_array(const Object &object, const int iterations, const MutableSpan< float > data)
void fill_factor_from_hide_and_mask(Span< bool > hide_vert, Span< float > mask, Span< int > verts, MutableSpan< float > r_factors)
MutableSpan< float3 > gather_grids_positions(const SubdivCCG &subdiv_ccg, const Span< int > grids, Vector< float3 > &positions)
void scatter_data_bmesh(Span< T > node_data, const Set< BMVert *, 0 > &verts, MutableSpan< T > dst)
void gather_bmesh_positions(const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions)
void gather_data_grids(const SubdivCCG &subdiv_ccg, Span< T > src, Span< int > grids, MutableSpan< T > node_data)
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)
GroupedSpan< int > calc_vert_neighbors(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face, Span< bool > hide_poly, Span< int > verts, Vector< int > &r_offset_data, Vector< int > &r_data)
Vector< BMVert *, 64 > BMeshNeighborVerts
void gather_data_bmesh(Span< T > src, const Set< BMVert *, 0 > &verts, MutableSpan< T > node_data)
void reset_translations_to_original(MutableSpan< float3 > translations, Span< float3 > positions, Span< float3 > orig_positions)
float3 symmetry_flip(const float3 &src, const ePaintSymmetryFlags symm)
void orig_position_data_gather_bmesh(const BMLog &bm_log, const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions, MutableSpan< float3 > normals)
void scale_translations(MutableSpan< float3 > translations, Span< float > factors)
Vector< int > find_symm_verts_mesh(const Depsgraph &depsgraph, const Object &object, const int original_vert, const float max_distance)
void clip_and_lock_translations(const Sculpt &sd, const SculptSession &ss, Span< float3 > positions, Span< int > verts, MutableSpan< float3 > translations)
void scatter_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
Span< BMVert * > vert_neighbors_get_bmesh(BMVert &vert, BMeshNeighborVerts &r_neighbors)
void apply_translations(Span< float3 > translations, Span< int > verts, MutableSpan< float3 > positions)
OrigPositionData orig_position_data_get_mesh(const Object &object, const bke::pbvh::MeshNode &node)
void gather_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
OrigPositionData orig_position_data_get_grids(const Object &object, const bke::pbvh::GridsNode &node)
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< 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)
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 scatter_data_grids(const SubdivCCG &subdiv_ccg, Span< T > node_data, Span< int > grids, MutableSpan< T > dst)
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)
T distance(const T &a, const T &b)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
VecBase< float, 4 > float4
VecBase< float, 3 > float3
ePaintSymmetryFlags SCULPT_mesh_symmetry_xyz_get(const Object &object)
Span< int > SCULPT_fake_neighbors_ensure(const Depsgraph &depsgraph, Object &ob, const float max_dist)
float3 SCULPT_flip_v3_by_symm_area(const float3 &vector, const ePaintSymmetryFlags symm, const ePaintSymmetryAreas symmarea, const float3 &pivot)
int SCULPT_vertex_count_get(const Object &object)
void SCULPT_fake_neighbors_free(Object &ob)
bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm)
ePaintSymmetryAreas SCULPT_get_vertex_symm_area(const float co[3])
void SCULPT_flip_quat_by_symm_area(float quat[4], const ePaintSymmetryFlags symm, const ePaintSymmetryAreas symmarea, const float pivot[3])
#define FAKE_NEIGHBOR_NONE
int pose_smooth_iterations
struct CurveMapping * curve_distance_falloff
float disconnected_distance_max
struct SculptSession * sculpt
blender::Array< int > fake_neighbor_index
blender::ed::sculpt_paint::StrokeCache * cache
ActiveVert active_vert() const
int active_vert_index() const
SculptFakeNeighbors fake_neighbors
int to_index(const CCGKey &key) const
static SubdivCCGCoord from_index(const CCGKey &key, int index)
SubdivCCGNeighborCoords coords
blender::BitGroupVector grid_hidden
blender::Array< blender::float3 > positions
Span< int > grids() const
Span< int > verts() const
VArraySpan< bool > hide_vert
std::unique_ptr< pose::IKChain > pose_ik_chain
std::unique_ptr< auto_mask::Cache > automasking
ePaintSymmetryFlags mirror_symmetry_pass
std::unique_ptr< cloth::SimulationData > cloth_sim
float3 orig_grab_location
void add_initial(BMVert *vertex)
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 execute(Object &object, GroupedSpan< int > vert_to_face_map, FunctionRef< bool(int from_v, int to_v)> func)
void add_initial(int vertex)
Vector< float3 > segment_translations
Vector< float > segment_weights
Vector< float3 > translations
Vector< float3 > positions
Vector< int > neighbor_data_with_fake
Vector< int > vert_indices
Vector< int > neighbor_data
Vector< int > neighbor_offsets
Array< IKChainSegment > segments
static PoseGrowFactorData join(const PoseGrowFactorData &a, const PoseGrowFactorData &b)