50 float3 target = initial_target;
57 segments[i].initial_orig);
61 float3 current_head_position = segments[i].orig + current_orientation * segments[i].len;
64 float3 current_origin_position = target - current_head_position;
67 segments[i].head = current_head_position;
68 segments[i].orig += current_origin_position;
71 target = segments[i].orig;
76 float3 anchor_diff = segments.
last().initial_orig - segments.
last().orig;
78 segments[i].orig += anchor_diff;
79 segments[i].head += anchor_diff;
90 segments[i].initial_orig);
91 float initial_rotation[4];
92 float current_rotation[4];
109 add_v3_v3v3(segment.head, segment.initial_head, delta);
110 add_v3_v3v3(segment.orig, segment.initial_orig, delta);
145 translations[i] =
position - positions[i];
188 add_arrays(translations, segment_translations);
196 position_data.deform(translations, verts);
201 translations.
as_span(), verts, cache.
cloth_sim->deformation_pos.as_mutable_span());
237 gather_data_grids(subdiv_ccg, segment.weights.as_span(), grids, segment_weights);
239 add_arrays(translations, segment_translations);
254 cache.
cloth_sim->deformation_pos.as_mutable_span());
293 add_arrays(translations, segment_translations);
306 translations.
as_span(), verts, cache.
cloth_sim->deformation_pos.as_mutable_span());
339 const Span<int> orig_neighbors = orig_neighbor_data.
slice(offsets[i]);
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,
390 const int vert = verts[i];
393 for (
const int neighbor : neighbors[i]) {
394 max = std::max(
max, prev_mask[neighbor]);
397 if (
max > prev_mask[vert]) {
399 pose_factor[vert] =
max;
409 const float3 &pose_initial_position,
423 const int grid = grids[i];
428 if (!grid_hidden.
is_empty() && grid_hidden[grid][offset]) {
443 max = std::max(
max, prev_mask[fake_neighbors[vert]]);
447 if (
max > prev_mask[vert]) {
449 pose_factor[vert] =
max;
461 const float3 &pose_initial_position,
472 for (
BMVert *bm_vert : verts) {
481 max = std::max(
max, prev_mask[fake_neighbors[vert]]);
485 if (
max > prev_mask[vert]) {
487 pose_factor[vert] =
max;
501 float pose_origin[3],
502 float pose_target[3],
504 float *r_pose_origin,
515 bool grow_next_iteration =
true;
518 while (grow_next_iteration) {
523 switch (
pbvh.type()) {
541 GrowFactorLocalData &tls = all_tls.local();
542 node_mask.slice(range).foreach_index([&](const int i) {
543 grow_factors_mesh(symm,
571 node_mask.slice(range).foreach_index([&](const int i) {
572 grow_factors_grids(symm,
593 node_mask.slice(range).foreach_index([&](const int i) {
595 symm, pose_target, fake_neighbors, prev_mask, nodes[i], pose_factor, gftd);
604 if (gftd.pos_count != 0) {
605 gftd.pos_avg /=
float(gftd.pos_count);
611 if (
len < prev_len) {
613 grow_next_iteration =
true;
616 grow_next_iteration =
false;
617 pose_factor.copy_from(prev_mask);
623 float len = math::distance(gftd.pos_avg,
float3(pose_target));
626 grow_next_iteration =
true;
629 grow_next_iteration =
false;
633 pose_factor.copy_from(prev_mask);
641 grow_next_iteration =
false;
651 for (
char i = 0; i <= symm; ++i) {
669 const float3 &initial_location,
688 float3 fallback_floodfill_origin = initial_location;
689 flood.
execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
690 r_pose_factor[to_v] = 1.0f;
692 const float3 co = positions_eval[to_v];
696 fallback_floodfill_origin = co;
712 r_pose_origin = pose_origin /
float(tot_co);
715 r_pose_origin = fallback_floodfill_origin;
721 const float3 &initial_location,
740 float3 fallback_floodfill_origin = initial_location;
743 const int to_v_i = to_v.
to_index(key);
745 r_pose_factor[to_v_i] = 1.0f;
747 const float3 &co = positions[to_v_i];
751 fallback_floodfill_origin = co;
769 r_pose_origin = pose_origin /
float(tot_co);
772 r_pose_origin = fallback_floodfill_origin;
778 const float3 &initial_location,
795 float3 fallback_floodfill_origin = initial_location;
798 r_pose_factor[to_v_i] = 1.0f;
804 fallback_floodfill_origin = co;
820 r_pose_origin = pose_origin /
float(tot_co);
823 r_pose_origin = fallback_floodfill_origin;
830 const float3 &initial_location,
843 depsgraph,
object, ss, initial_location, radius, pose_origin, r_pose_factor);
847 object, ss, initial_location, radius, pose_origin, r_pose_factor);
851 object, ss, initial_location, radius, pose_origin, r_pose_factor);
857 pose_origin += pose_dir * radius * pose_offset;
858 r_pose_origin = pose_origin;
862 if (pose_offset != 0.0f) {
863 grow_pose_factor(depsgraph,
object, ss, pose_origin, pose_origin, 0,
nullptr, r_pose_factor);
868static std::unique_ptr<IKChain>
ik_chain_new(
const int totsegments,
const int totverts)
870 std::unique_ptr<IKChain> ik_chain = std::make_unique<IKChain>();
871 ik_chain->segments.reinitialize(totsegments);
883 for (
const int i : ik_chain.
segments.index_range()) {
885 head = initial_location;
889 head = ik_chain.
segments[i - 1].orig;
893 ik_chain.
segments[i].initial_orig = origin;
895 ik_chain.
segments[i].initial_head = head;
912 return brush.pose_ik_segments;
919 const float3 &initial_location,
923 const float chain_segment_len = radius * (1.0f +
brush.pose_offset);
928 int nearest_vertex_index = -1;
929 switch (
pbvh.type()) {
939 std::numeric_limits<float>::max(),
942 nearest_vertex_index = *nearest;
949 pbvh, subdiv_ccg, initial_location, std::numeric_limits<float>::max(),
true);
952 nearest_vertex_index = nearest->to_index(key);
958 pbvh, initial_location, std::numeric_limits<float>::max(),
false);
966 if (nearest_vertex_index == -1) {
979 pose_factor_grow[nearest_vertex_index] = 1.0f;
982 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(tot_segments, totvert);
991 ik_chain->segments[0].orig,
994 float3 next_chain_segment_target = ik_chain->segments[0].orig;
998 for (
int j = 0; j < totvert; j++) {
999 ik_chain->segments[0].weights[j] = pose_factor_grow[j];
1000 pose_factor_grow_prev[j] = pose_factor_grow[j];
1004 for (
const int i : ik_chain->segments.index_range().drop_front(1)) {
1011 next_chain_segment_target,
1013 ik_chain->segments[i].orig,
1015 next_chain_segment_target = ik_chain->segments[i].orig;
1019 for (
int j = 0; j < totvert; j++) {
1020 ik_chain->segments[i].weights[j] = pose_factor_grow[j] - pose_factor_grow_prev[j];
1022 pose_factor_grow_prev[j] = pose_factor_grow[j];
1037 struct SegmentData {
1055 vert_positions.
size());
1061 SegmentData current_data = {std::get<int>(ss.
active_vert()), face_set_none_id};
1065 int num_valid_segments = 0;
1066 for (
const int i : ik_chain->segments.index_range()) {
1067 num_valid_segments++;
1068 const bool is_first_iteration = i == 0;
1074 visited_face_sets.
add(current_data.face_set);
1077 std::optional<SegmentData> next_segment_data;
1079 float3 face_set_boundary_accum(0);
1080 int face_set_boundary_count = 0;
1082 float3 fallback_accum(0);
1083 int fallback_count = 0;
1085 const float3 &pose_initial_co = vert_positions[current_data.vert];
1086 flood_fill.execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1087 const float3 &to_v_position = vert_positions[to_v];
1089 to_v_position, pose_initial_co, symm);
1093 if (current_data.face_set == face_set_none_id) {
1095 pose_factor[to_v] = 1.0f;
1096 is_weighted[to_v].set();
1100 vert_to_face_map, face_sets, to_v);
1101 visited_face_sets.
add(visited_face_set);
1103 else if (symmetry_check) {
1105 vert_to_face_map, face_sets, to_v);
1106 visited_face_sets.
add(current_data.face_set);
1115 bool is_vertex_valid =
false;
1116 if (is_first_iteration) {
1117 for (
const int visited_face_set : visited_face_sets) {
1119 vert_to_face_map, face_sets, to_v, visited_face_set);
1124 vert_to_face_map, face_sets, to_v, current_data.face_set);
1127 if (!is_vertex_valid) {
1131 bool visit_next =
false;
1132 if (!is_weighted[to_v]) {
1133 pose_factor[to_v] = 1.0f;
1134 is_weighted[to_v].set();
1139 if (symmetry_check) {
1140 fallback_accum += to_v_position;
1151 bool count_as_boundary =
false;
1154 faces, corner_verts, vert_to_face_map, hide_poly, to_v, neighbors))
1157 vert_to_face_map, face_sets, neighbor_idx);
1161 !visited_face_sets.
contains(next_face_set_candidate))
1163 if (!next_segment_data) {
1164 next_segment_data = {neighbor_idx, next_face_set_candidate};
1166 count_as_boundary =
true;
1171 if (count_as_boundary) {
1172 face_set_boundary_accum += to_v_position;
1173 face_set_boundary_count++;
1178 if (face_set_boundary_count > 0) {
1179 ik_chain->segments[i].orig = face_set_boundary_accum /
float(face_set_boundary_count);
1181 else if (fallback_count > 0) {
1182 ik_chain->segments[i].orig = fallback_accum /
float(fallback_count);
1185 ik_chain->segments[i].orig =
float3(0);
1188 if (!next_segment_data) {
1195 current_data = *next_segment_data;
1198 ik_chain->segments.
resize(num_valid_segments);
1209 struct SegmentData {
1214 const Mesh &
mesh = *id_cast<const Mesh *>(
object.
data);
1237 int num_valid_segments = 0;
1238 for (
const int i : ik_chain->segments.index_range()) {
1239 num_valid_segments++;
1240 const bool is_first_iteration = i == 0;
1245 visited_face_sets.
add(current_data.face_set);
1248 std::optional<SegmentData> next_segment_data;
1250 float3 face_set_boundary_accum(0);
1251 int face_set_boundary_count = 0;
1253 float3 fallback_accum(0);
1254 int fallback_count = 0;
1256 const float3 &pose_initial_co = positions[current_data.vert];
1261 const int to_v_i = to_v.
to_index(key);
1263 const float3 to_v_position = positions[to_v_i];
1265 to_v_position, pose_initial_co, symm) &&
1270 if (current_data.face_set == face_set_none_id) {
1272 pose_factor[to_v_i] = 1.0f;
1273 is_weighted[to_v_i].set();
1278 visited_face_sets.
add(visited_face_set);
1280 else if (symmetry_check) {
1283 visited_face_sets.
add(current_data.face_set);
1292 bool is_vertex_valid =
false;
1293 if (is_first_iteration) {
1294 for (
const int visited_face_set : visited_face_sets) {
1296 subdiv_ccg, face_sets, to_v.
grid_index, visited_face_set);
1301 subdiv_ccg, face_sets, to_v.
grid_index, current_data.face_set);
1304 if (!is_vertex_valid) {
1308 bool visit_next =
false;
1309 if (!is_weighted[to_v_i]) {
1310 pose_factor[to_v_i] = 1.0f;
1311 is_weighted[to_v_i].set();
1316 if (symmetry_check) {
1317 fallback_accum += to_v_position;
1321 if (!symmetry_check ||
1323 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v))
1330 bool count_as_boundary =
false;
1339 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, neighbor) &&
1340 !visited_face_sets.
contains(next_face_set_candidate))
1342 if (!next_segment_data) {
1343 next_segment_data = {neighbor.
to_index(key), next_face_set_candidate};
1345 count_as_boundary =
true;
1350 if (count_as_boundary) {
1351 face_set_boundary_accum += to_v_position;
1352 face_set_boundary_count++;
1357 if (face_set_boundary_count > 0) {
1358 ik_chain->segments[i].orig = face_set_boundary_accum /
float(face_set_boundary_count);
1360 else if (fallback_count > 0) {
1361 ik_chain->segments[i].orig = fallback_accum /
float(fallback_count);
1364 ik_chain->segments[i].orig =
float3(0);
1367 if (!next_segment_data) {
1374 current_data = *next_segment_data;
1377 ik_chain->segments.resize(num_valid_segments);
1388 struct SegmentData {
1402 SegmentData current_data = {std::get<BMVert *>(ss.
active_vert()), face_set_none_id};
1406 int num_valid_segments = 0;
1407 for (
const int i : ik_chain->segments.index_range()) {
1408 num_valid_segments++;
1409 const bool is_first_iteration = i == 0;
1415 visited_face_sets.
add(current_data.face_set);
1418 std::optional<SegmentData> next_segment_data;
1420 float3 face_set_boundary_accum(0);
1421 int face_set_boundary_count = 0;
1423 float3 fallback_accum(0);
1424 int fallback_count = 0;
1426 const float3 pose_initial_co = current_data.vert->co;
1430 const float3 to_v_position = to_v->
co;
1432 to_v_position, pose_initial_co, symm);
1436 if (current_data.face_set == face_set_none_id) {
1438 pose_factor[to_v_i] = 1.0f;
1439 is_weighted[to_v_i].set();
1443 visited_face_sets.
add(visited_face_set);
1445 else if (symmetry_check) {
1447 visited_face_sets.
add(current_data.face_set);
1456 bool is_vertex_valid =
false;
1457 if (is_first_iteration) {
1458 for (
const int visited_face_set : visited_face_sets) {
1464 face_set_offset, *to_v, current_data.face_set);
1467 if (!is_vertex_valid) {
1471 bool visit_next =
false;
1472 if (!is_weighted[to_v_i]) {
1473 pose_factor[to_v_i] = 1.0f;
1474 is_weighted[to_v_i].set();
1479 if (symmetry_check) {
1480 fallback_accum += to_v_position;
1490 bool count_as_boundary =
false;
1498 !visited_face_sets.
contains(next_face_set_candidate))
1500 if (!next_segment_data) {
1501 next_segment_data = {neighbor, next_face_set_candidate};
1503 count_as_boundary =
true;
1508 if (count_as_boundary) {
1509 face_set_boundary_accum += to_v_position;
1510 face_set_boundary_count++;
1515 if (face_set_boundary_count > 0) {
1516 ik_chain->segments[i].orig = face_set_boundary_accum /
float(face_set_boundary_count);
1518 else if (fallback_count > 0) {
1519 ik_chain->segments[i].orig = fallback_accum /
float(fallback_count);
1522 ik_chain->segments[i].orig =
float3(0);
1525 if (!next_segment_data) {
1532 current_data = *next_segment_data;
1535 ik_chain->segments.resize(num_valid_segments);
1564 const int active_face_set,
1565 const int target_face_set)
1580 for (
const int vert : vert_positions.
index_range()) {
1581 if (floodfill_step[vert] != 0 &&
1585 sum += vert_positions[vert];
1592 const SubdivCCG &subdiv_ccg = *
object.runtime->sculpt_session->subdiv_ccg;
1603 if (floodfill_step[
index] != 0 &&
1607 sum += positions[
index];
1616 BMesh &
bm = *
object.runtime->sculpt_session->bm;
1621 if (floodfill_step[vert] != 0 &&
1635 return sum /
float(count);
1638 return std::nullopt;
1645 const float3 &initial_location)
1655 const int active_vert = std::get<int>(ss.
active_vert());
1661 floodfill_step[active_vert] = 1;
1663 int masked_face_set = face_set_none_id;
1664 int target_face_set = face_set_none_id;
1665 int masked_face_set_it = 0;
1668 step_floodfill.
execute(
object, vert_to_face_map, [&](
int from_v,
int to_v) {
1669 floodfill_step[to_v] = floodfill_step[from_v] + 1;
1672 if (!visited_face_sets.
contains(to_face_set)) {
1678 visited_face_sets.
add(to_face_set);
1680 if (floodfill_step[to_v] >= masked_face_set_it) {
1681 masked_face_set = to_face_set;
1682 masked_face_set_it = floodfill_step[to_v];
1685 if (target_face_set == face_set_none_id) {
1686 target_face_set = to_face_set;
1695 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1696 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1698 std::optional<float3> head = std::nullopt;
1699 if (target_face_set != masked_face_set) {
1701 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1704 ik_chain->segments[0].head = head.value_or(initial_location);
1705 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1710 weight_floodfill.
execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1711 fk_weights[to_v] = 1.0f;
1723 const float3 &initial_location)
1725 const Mesh &
mesh = *id_cast<const Mesh *>(
object.
data);
1735 const Span<int> grid_to_face_map = subdiv_ccg.grid_to_face_map;
1738 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, grids_num);
1746 floodfill_step[active_vert_index] = 1;
1748 int masked_face_set = face_set_none_id;
1749 int target_face_set = face_set_none_id;
1750 int masked_face_set_it = 0;
1755 const int from_v_i = from_v.
to_index(key);
1756 const int to_v_i = to_v.
to_index(key);
1758 if (!is_duplicate) {
1759 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1762 floodfill_step[to_v_i] = floodfill_step[from_v_i];
1765 const int to_face_set = face_sets[grid_to_face_map[to_v.
grid_index]];
1766 if (!visited_face_sets.
contains(to_face_set)) {
1768 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v) &&
1770 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, from_v) &&
1774 visited_face_sets.
add(to_face_set);
1776 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1777 masked_face_set = to_face_set;
1778 masked_face_set_it = floodfill_step[to_v_i];
1781 if (target_face_set == face_set_none_id) {
1782 target_face_set = to_face_set;
1788 subdiv_ccg, face_sets, to_v.
grid_index, active_face_set);
1792 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1793 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1795 std::optional<float3> head = std::nullopt;
1796 if (target_face_set != masked_face_set) {
1798 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1801 ik_chain->segments[0].head = head.value_or(initial_location);
1802 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1813 fk_weights[to_v_i] = 1.0f;
1815 subdiv_ccg, face_sets, to_v.
grid_index, masked_face_set);
1826 const float3 &initial_location)
1835 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, verts_num);
1844 floodfill_step[active_vert_index] = 1;
1846 int masked_face_set = face_set_none_id;
1847 int target_face_set = face_set_none_id;
1848 int masked_face_set_it = 0;
1855 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1858 if (!visited_face_sets.
contains(to_face_set)) {
1864 visited_face_sets.
add(to_face_set);
1866 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1867 masked_face_set = to_face_set;
1868 masked_face_set_it = floodfill_step[to_v_i];
1871 if (target_face_set == face_set_none_id) {
1872 target_face_set = to_face_set;
1881 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1882 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1884 std::optional<float3> head = std::nullopt;
1885 if (target_face_set != masked_face_set) {
1887 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1890 ik_chain->segments[0].head = head.value_or(initial_location);
1891 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1900 fk_weights[to_v_i] = 1.0f;
1912 const float3 &initial_location)
1931 const float3 &initial_location,
1934 std::unique_ptr<IKChain> ik_chain;
1938 if (use_fake_neighbors) {
1945 switch (
brush.pose_origin_type) {
1985 const float3 &initial_location,
1989 depsgraph, ob, ss,
brush, initial_location, radius);
1994 std::unique_ptr<SculptPoseIKChainPreview> preview = std::make_unique<SculptPoseIKChainPreview>();
1996 preview->initial_head_coords.reinitialize(chain->segments.size());
1997 preview->initial_orig_coords.reinitialize(chain->segments.size());
1998 for (
const int i : chain->segments.index_range()) {
1999 preview->initial_head_coords[i] = chain->segments[i].initial_head;
2000 preview->initial_orig_coords[i] = chain->segments[i].initial_orig;
2018 ik_chain.
segments[0].initial_orig);
2021 const float segment_len = ik_chain.
segments[0].len;
2098 scale.x = signed_scale;
2099 scale.y = signed_scale;
2112 const float3 &grab_location)
2148 switch (
brush.pose_deform_type) {
2165 for (
const int i : ik_chain.
segments.index_range()) {
2178 float pivot_local_space[4][4];
2195 for (
int scale_i = 0; scale_i < 3; scale_i++) {
2197 ik_chain.
segments[i].scale[scale_i]);
2201 symm_orig[0] - symm_initial_orig[0],
2202 symm_orig[1] - symm_initial_orig[1],
2203 symm_orig[2] - symm_initial_orig[2]);
2207 ik_chain.
segments[i].pivot_mat[symm_it].ptr(), symm_orig[0], symm_orig[1], symm_orig[2]);
2211 ik_chain.
segments[i].pivot_mat[symm_it].ptr());
2216 switch (
pbvh.type()) {
2255 pbvh.tag_positions_changed(node_mask);
2256 pbvh.flush_bounds_to_parents();
A BVH for high poly meshes.
Object is a sort of wrapper for general info.
#define PRF_scope(category)
#define BLI_assert_unreachable()
#define BM_elem_index_get(ele)
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
void fill(const T &value) const
constexpr IndexRange()=default
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 resize(const int64_t new_size)
void extend(Span< T > array)
Span< T > as_span() const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef name) const
IndexRange index_range() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline void copy_v3_v3(ccl_private float *r, const float3 val)
#define FAKE_NEIGHBOR_NONE
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)
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 vert_face_set_max_get(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, const int vert)
int vert_face_set_get(const SubdivCCG &subdiv_ccg, const Span< int > face_sets, const int grid)
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, bke::pbvh::MESH_LEAF_LIMIT > &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 calc_mesh(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const MeshAttributeData &attribute_data, const bke::pbvh::MeshNode &node, Object &object, const PositionDeformData &position_data)
static void solve_translate_chain(IKChain &ik_chain, const float delta[3])
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 bool pose_brush_init(const Depsgraph &depsgraph, Object &ob, SculptSession &ss, const Brush &brush)
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)
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)
bool check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm)
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
int vertex_count_get(const Object &object)
ePaintSymmetryAreas get_vertex_symm_area(const float co[3])
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)
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)
void fake_neighbors_free(Object &ob)
float3 flip_v3_by_symm_area(const float3 &vector, const ePaintSymmetryFlags symm, const ePaintSymmetryAreas symmarea, const float3 &pivot)
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)
Span< int > fake_neighbors_ensure(const Depsgraph &depsgraph, Object &ob, const float max_dist)
void flip_quat_by_symm_area(float quat[4], const ePaintSymmetryFlags symm, const ePaintSymmetryAreas symmarea, const float pivot[3])
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)
constexpr ParallelGrainSize grain_size(int grain_size)
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)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q2[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void axis_angle_normalized_to_quat(float r[4], const float axis[3], float angle)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
@ BRUSH_USE_CONNECTED_ONLY
@ BRUSH_POSE_USE_LOCK_ROTATION
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
MINLINE void mul_v3_fl(float r[3], float f)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
@ BRUSH_POSE_DEFORM_SQUASH_STRETCH
@ BRUSH_POSE_DEFORM_SCALE_TRANSLATE
@ BRUSH_POSE_DEFORM_ROTATE_TWIST
VecBase< float, 4 > float4
@ BRUSH_POSE_ORIGIN_TOPOLOGY
@ BRUSH_POSE_ORIGIN_FACE_SETS_FK
@ BRUSH_POSE_ORIGIN_FACE_SETS
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 copy_qt_qt(float q[4], const float a[4])
BMesh const char void * data
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
int BM_mesh_elem_count(BMesh *bm, const char htype)
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
void unit_m4(float m[4][4])
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
int CCG_grid_xy_to_index(const int grid_size, const int x, const int y)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
void mul_m4_m4_post(float R[4][4], const float B[4][4])
@ BRUSH_DEFORM_TARGET_CLOTH_SIM
@ BRUSH_DEFORM_TARGET_GEOMETRY
VecBase< float, 3 > float3
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(bke::pbvh::BMeshNode *node)
void quat_to_mat4(float m[4][4], const float q[4])
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ObjectRuntime * runtime
Array< int > fake_neighbor_index
ed::sculpt_paint::StrokeCache * cache
SculptFakeNeighbors fake_neighbors
ActiveVert active_vert() const
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
BitGroupVector grid_hidden
SculptSession * sculpt_session
VArraySpan< bool > hide_vert
StrokeToggleSettings toggle_settings
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
Vector< IKChainSegment > segments
static PoseGrowFactorData join(const PoseGrowFactorData &a, const PoseGrowFactorData &b)
void resize(int new_size)