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);
139 float3 position = positions[
i];
144 translations[
i] = position - positions[
i];
190 add_arrays(translations, segment_translations);
239 gather_data_grids(subdiv_ccg, segment.weights.as_span(), grids, segment_weights);
241 add_arrays(translations, segment_translations);
256 cache.
cloth_sim->deformation_pos.as_mutable_span());
295 add_arrays(translations, segment_translations);
339 for (
const int i :
verts.index_range()) {
343 neighbor_offsets[
i] = neighbor_data_with_fake.
size();
344 neighbor_data_with_fake.
extend(orig_neighbors);
345 const int neighbor = fake_neighbors[
verts[
i]];
347 neighbor_data_with_fake.
append(neighbor);
350 neighbor_offsets.
last() = neighbor_data_with_fake.
size();
354 const float3 &pose_initial_position,
389 for (
const int i :
verts.index_range()) {
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]) {
431 const int vert = grid_range[offset];
443 max = std::max(
max, prev_mask[fake_neighbors[vert]]);
447 if (
max > prev_mask[vert]) {
448 const float3 &position = positions[vert];
449 pose_factor[vert] =
max;
461 const float3 &pose_initial_position,
481 max = std::max(
max, prev_mask[fake_neighbors[vert]]);
485 if (
max > prev_mask[vert]) {
486 const float3 position = bm_vert->co;
487 pose_factor[vert] =
max;
501 float pose_origin[3],
502 float pose_target[3],
504 float *r_pose_origin,
514 bool grow_next_iteration =
true;
517 while (grow_next_iteration) {
522 switch (pbvh.
type()) {
540 GrowFactorLocalData &tls = all_tls.local();
541 node_mask.slice(range).foreach_index([&](const int i) {
542 grow_factors_mesh(symm,
570 node_mask.slice(range).foreach_index([&](const int i) {
571 grow_factors_grids(symm,
592 node_mask.slice(range).foreach_index([&](const int i) {
594 symm, pose_target, fake_neighbors, prev_mask, nodes[i], pose_factor, gftd);
603 if (gftd.pos_count != 0) {
604 gftd.pos_avg /= float(gftd.pos_count);
610 if (
len < prev_len) {
612 grow_next_iteration =
true;
615 grow_next_iteration =
false;
616 pose_factor.copy_from(prev_mask);
625 grow_next_iteration =
true;
628 grow_next_iteration =
false;
632 pose_factor.copy_from(prev_mask);
640 grow_next_iteration =
false;
650 for (
char i = 0;
i <= symm; ++
i) {
668 const float3 &initial_location,
675 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
687 float3 fallback_floodfill_origin = initial_location;
688 flood.
execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
689 r_pose_factor[to_v] = 1.0f;
691 const float3 co = positions_eval[to_v];
695 fallback_floodfill_origin = co;
711 r_pose_origin = pose_origin / float(tot_co);
714 r_pose_origin = fallback_floodfill_origin;
720 const float3 &initial_location,
739 float3 fallback_floodfill_origin = initial_location;
742 const int to_v_i = to_v.
to_index(key);
744 r_pose_factor[to_v_i] = 1.0f;
746 const float3 &co = positions[to_v_i];
750 fallback_floodfill_origin = co;
768 r_pose_origin = pose_origin / float(tot_co);
771 r_pose_origin = fallback_floodfill_origin;
777 const float3 &initial_location,
794 float3 fallback_floodfill_origin = initial_location;
797 r_pose_factor[to_v_i] = 1.0f;
803 fallback_floodfill_origin = co;
819 r_pose_origin = pose_origin / float(tot_co);
822 r_pose_origin = fallback_floodfill_origin;
829 const float3 &initial_location,
841 depsgraph,
object, ss, initial_location, radius, pose_origin, r_pose_factor);
845 object, ss, initial_location, radius, pose_origin, r_pose_factor);
849 object, ss, initial_location, radius, pose_origin, r_pose_factor);
855 pose_origin += pose_dir * radius * pose_offset;
856 r_pose_origin = pose_origin;
860 if (pose_offset != 0.0f) {
866static std::unique_ptr<IKChain>
ik_chain_new(
const int totsegments,
const int totverts)
868 std::unique_ptr<IKChain> ik_chain = std::make_unique<IKChain>();
869 ik_chain->segments.reinitialize(totsegments);
881 for (
const int i : ik_chain.
segments.index_range()) {
883 head = initial_location;
891 ik_chain.
segments[
i].initial_orig = origin;
893 ik_chain.
segments[
i].initial_head = head;
917 const float3 &initial_location,
921 const float chain_segment_len = radius * (1.0f + brush.
pose_offset);
926 int nearest_vertex_index = -1;
928 switch (pbvh.
type()) {
930 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
938 std::numeric_limits<float>::max(),
940 nearest_vertex_index = *nearest;
946 pbvh, subdiv_ccg, initial_location, std::numeric_limits<float>::max(),
true);
948 nearest_vertex_index = nearest->to_index(key);
953 pbvh, initial_location, std::numeric_limits<float>::max(),
false);
968 pose_factor_grow[nearest_vertex_index] = 1.0f;
971 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(tot_segments, totvert);
980 ik_chain->segments[0].orig,
983 float3 next_chain_segment_target = ik_chain->segments[0].orig;
987 for (
int j = 0; j < totvert; j++) {
988 ik_chain->segments[0].weights[j] = pose_factor_grow[j];
989 pose_factor_grow_prev[j] = pose_factor_grow[j];
993 for (
const int i : ik_chain->segments.index_range().drop_front(1)) {
1000 next_chain_segment_target,
1002 ik_chain->segments[
i].orig,
1004 next_chain_segment_target = ik_chain->segments[
i].orig;
1008 for (
int j = 0; j < totvert; j++) {
1009 ik_chain->segments[
i].weights[j] = pose_factor_grow[j] - pose_factor_grow_prev[j];
1011 pose_factor_grow_prev[j] = pose_factor_grow[j];
1026 struct SegmentData {
1044 vert_positions.
size());
1054 int num_valid_segments = 0;
1055 for (
const int i : ik_chain->segments.index_range()) {
1056 num_valid_segments++;
1057 const bool is_first_iteration =
i == 0;
1063 visited_face_sets.
add(current_data.face_set);
1066 std::optional<SegmentData> next_segment_data;
1068 float3 face_set_boundary_accum(0);
1069 int face_set_boundary_count = 0;
1071 float3 fallback_accum(0);
1072 int fallback_count = 0;
1074 const float3 &pose_initial_co = vert_positions[current_data.vert];
1075 flood_fill.execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1076 const float3 &to_v_position = vert_positions[to_v];
1078 to_v_position, pose_initial_co, symm);
1084 pose_factor[to_v] = 1.0f;
1085 is_weighted[to_v].set();
1089 vert_to_face_map, face_sets, to_v);
1090 visited_face_sets.
add(visited_face_set);
1092 else if (symmetry_check) {
1094 visited_face_sets.
add(current_data.face_set);
1103 bool is_vertex_valid =
false;
1104 if (is_first_iteration) {
1105 for (
const int visited_face_set : visited_face_sets) {
1107 vert_to_face_map, face_sets, to_v, visited_face_set);
1112 vert_to_face_map, face_sets, to_v, current_data.face_set);
1115 if (!is_vertex_valid) {
1119 bool visit_next =
false;
1120 if (!is_weighted[to_v]) {
1121 pose_factor[to_v] = 1.0f;
1122 is_weighted[to_v].set();
1127 if (symmetry_check) {
1128 fallback_accum += to_v_position;
1139 bool count_as_boundary =
false;
1142 faces, corner_verts, vert_to_face_map, hide_poly, to_v, neighbors))
1145 vert_to_face_map, face_sets, neighbor_idx);
1149 !visited_face_sets.
contains(next_face_set_candidate))
1151 if (!next_segment_data) {
1152 next_segment_data = {neighbor_idx, next_face_set_candidate};
1154 count_as_boundary =
true;
1159 if (count_as_boundary) {
1160 face_set_boundary_accum += to_v_position;
1161 face_set_boundary_count++;
1166 if (face_set_boundary_count > 0) {
1167 ik_chain->segments[
i].orig = face_set_boundary_accum / float(face_set_boundary_count);
1169 else if (fallback_count > 0) {
1170 ik_chain->segments[
i].orig = fallback_accum / float(fallback_count);
1173 ik_chain->segments[
i].orig =
float3(0);
1176 if (!next_segment_data) {
1183 current_data = *next_segment_data;
1186 ik_chain->segments.
resize(num_valid_segments);
1197 struct SegmentData {
1202 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
1225 int num_valid_segments = 0;
1226 for (
const int i : ik_chain->segments.index_range()) {
1227 num_valid_segments++;
1228 const bool is_first_iteration =
i == 0;
1233 visited_face_sets.
add(current_data.face_set);
1236 std::optional<SegmentData> next_segment_data;
1238 float3 face_set_boundary_accum(0);
1239 int face_set_boundary_count = 0;
1241 float3 fallback_accum(0);
1242 int fallback_count = 0;
1244 const float3 &pose_initial_co = positions[current_data.vert];
1249 const int to_v_i = to_v.
to_index(key);
1251 const float3 to_v_position = positions[to_v_i];
1253 to_v_position, pose_initial_co, symm) &&
1260 pose_factor[to_v_i] = 1.0f;
1261 is_weighted[to_v_i].set();
1266 visited_face_sets.
add(visited_face_set);
1268 else if (symmetry_check) {
1271 visited_face_sets.
add(current_data.face_set);
1280 bool is_vertex_valid =
false;
1281 if (is_first_iteration) {
1282 for (
const int visited_face_set : visited_face_sets) {
1284 subdiv_ccg, face_sets, to_v.
grid_index, visited_face_set);
1289 subdiv_ccg, face_sets, to_v.
grid_index, current_data.face_set);
1292 if (!is_vertex_valid) {
1296 bool visit_next =
false;
1297 if (!is_weighted[to_v_i]) {
1298 pose_factor[to_v_i] = 1.0f;
1299 is_weighted[to_v_i].set();
1304 if (symmetry_check) {
1305 fallback_accum += to_v_position;
1309 if (!symmetry_check ||
1311 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v))
1318 bool count_as_boundary =
false;
1327 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, neighbor) &&
1328 !visited_face_sets.
contains(next_face_set_candidate))
1330 if (!next_segment_data) {
1331 next_segment_data = {neighbor.
to_index(key), next_face_set_candidate};
1333 count_as_boundary =
true;
1338 if (count_as_boundary) {
1339 face_set_boundary_accum += to_v_position;
1340 face_set_boundary_count++;
1345 if (face_set_boundary_count > 0) {
1346 ik_chain->segments[
i].orig = face_set_boundary_accum / float(face_set_boundary_count);
1348 else if (fallback_count > 0) {
1349 ik_chain->segments[
i].orig = fallback_accum / float(fallback_count);
1352 ik_chain->segments[
i].orig =
float3(0);
1355 if (!next_segment_data) {
1362 current_data = *next_segment_data;
1365 ik_chain->segments.resize(num_valid_segments);
1376 struct SegmentData {
1394 int num_valid_segments = 0;
1395 for (
const int i : ik_chain->segments.index_range()) {
1396 num_valid_segments++;
1397 const bool is_first_iteration =
i == 0;
1403 visited_face_sets.
add(current_data.face_set);
1406 std::optional<SegmentData> next_segment_data;
1408 float3 face_set_boundary_accum(0);
1409 int face_set_boundary_count = 0;
1411 float3 fallback_accum(0);
1412 int fallback_count = 0;
1414 const float3 pose_initial_co = current_data.vert->co;
1418 const float3 to_v_position = to_v->
co;
1420 to_v_position, pose_initial_co, symm);
1426 pose_factor[to_v_i] = 1.0f;
1427 is_weighted[to_v_i].set();
1431 visited_face_sets.
add(visited_face_set);
1433 else if (symmetry_check) {
1435 visited_face_sets.
add(current_data.face_set);
1444 bool is_vertex_valid =
false;
1445 if (is_first_iteration) {
1446 for (
const int visited_face_set : visited_face_sets) {
1452 face_set_offset, *to_v, current_data.face_set);
1455 if (!is_vertex_valid) {
1459 bool visit_next =
false;
1460 if (!is_weighted[to_v_i]) {
1461 pose_factor[to_v_i] = 1.0f;
1462 is_weighted[to_v_i].set();
1467 if (symmetry_check) {
1468 fallback_accum += to_v_position;
1478 bool count_as_boundary =
false;
1486 !visited_face_sets.
contains(next_face_set_candidate))
1488 if (!next_segment_data) {
1489 next_segment_data = {neighbor, next_face_set_candidate};
1491 count_as_boundary =
true;
1496 if (count_as_boundary) {
1497 face_set_boundary_accum += to_v_position;
1498 face_set_boundary_count++;
1503 if (face_set_boundary_count > 0) {
1504 ik_chain->segments[
i].orig = face_set_boundary_accum / float(face_set_boundary_count);
1506 else if (fallback_count > 0) {
1507 ik_chain->segments[
i].orig = fallback_accum / float(fallback_count);
1510 ik_chain->segments[
i].orig =
float3(0);
1513 if (!next_segment_data) {
1520 current_data = *next_segment_data;
1523 ik_chain->segments.resize(num_valid_segments);
1551 const int active_face_set,
1552 const int target_face_set)
1566 for (
const int vert : vert_positions.
index_range()) {
1567 if (floodfill_step[vert] != 0 &&
1571 sum += vert_positions[vert];
1578 const SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
1589 if (floodfill_step[index] != 0 &&
1593 sum += positions[index];
1602 BMesh &
bm = *
object.sculpt->bm;
1607 if (floodfill_step[vert] != 0 &&
1624 return std::nullopt;
1631 const float3 &initial_location)
1641 const int active_vert = std::get<int>(ss.
active_vert());
1647 floodfill_step[active_vert] = 1;
1651 int masked_face_set_it = 0;
1654 step_floodfill.
execute(
object, vert_to_face_map, [&](
int from_v,
int to_v) {
1655 floodfill_step[to_v] = floodfill_step[from_v] + 1;
1658 if (!visited_face_sets.
contains(to_face_set)) {
1664 visited_face_sets.
add(to_face_set);
1666 if (floodfill_step[to_v] >= masked_face_set_it) {
1667 masked_face_set = to_face_set;
1668 masked_face_set_it = floodfill_step[to_v];
1672 target_face_set = to_face_set;
1681 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1682 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1684 std::optional<float3> head = std::nullopt;
1685 if (target_face_set != masked_face_set) {
1687 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1690 ik_chain->segments[0].head = head.value_or(initial_location);
1691 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1696 weight_floodfill.
execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1697 fk_weights[to_v] = 1.0f;
1709 const float3 &initial_location)
1711 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
1721 const Span<int> grid_to_face_map = subdiv_ccg.grid_to_face_map;
1724 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, grids_num);
1732 floodfill_step[active_vert_index] = 1;
1736 int masked_face_set_it = 0;
1741 const int from_v_i = from_v.
to_index(key);
1742 const int to_v_i = to_v.
to_index(key);
1744 if (!is_duplicate) {
1745 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1748 floodfill_step[to_v_i] = floodfill_step[from_v_i];
1751 const int to_face_set = face_sets[grid_to_face_map[to_v.
grid_index]];
1752 if (!visited_face_sets.
contains(to_face_set)) {
1754 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v) &&
1756 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, from_v) &&
1760 visited_face_sets.
add(to_face_set);
1762 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1763 masked_face_set = to_face_set;
1764 masked_face_set_it = floodfill_step[to_v_i];
1768 target_face_set = to_face_set;
1774 subdiv_ccg, face_sets, to_v.
grid_index, active_face_set);
1778 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1779 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1781 std::optional<float3> head = std::nullopt;
1782 if (target_face_set != masked_face_set) {
1784 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1787 ik_chain->segments[0].head = head.value_or(initial_location);
1788 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1799 fk_weights[to_v_i] = 1.0f;
1801 subdiv_ccg, face_sets, to_v.
grid_index, masked_face_set);
1812 const float3 &initial_location)
1821 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, verts_num);
1830 floodfill_step[active_vert_index] = 1;
1834 int masked_face_set_it = 0;
1841 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1844 if (!visited_face_sets.
contains(to_face_set)) {
1850 visited_face_sets.
add(to_face_set);
1852 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1853 masked_face_set = to_face_set;
1854 masked_face_set_it = floodfill_step[to_v_i];
1858 target_face_set = to_face_set;
1867 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1868 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1870 std::optional<float3> head = std::nullopt;
1871 if (target_face_set != masked_face_set) {
1873 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1876 ik_chain->segments[0].head = head.value_or(initial_location);
1877 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1886 fk_weights[to_v_i] = 1.0f;
1898 const float3 &initial_location)
1916 const float3 &initial_location,
1919 std::unique_ptr<IKChain> ik_chain;
1923 if (use_fake_neighbors) {
1964 const float3 &initial_location,
1968 std::unique_ptr<SculptPoseIKChainPreview> preview = std::make_unique<SculptPoseIKChainPreview>();
1970 preview->initial_head_coords.reinitialize(chain.
segments.size());
1971 preview->initial_orig_coords.reinitialize(chain.
segments.size());
1972 for (
const int i : chain.
segments.index_range()) {
1973 preview->initial_head_coords[
i] = chain.
segments[
i].initial_head;
1974 preview->initial_orig_coords[
i] = chain.
segments[
i].initial_orig;
1992 ik_chain.
segments[0].initial_orig);
1995 const float segment_len = ik_chain.
segments[0].len;
2071 scale.x = signed_scale;
2072 scale.y = signed_scale;
2075 BLI_assert(std::isfinite(scale.x) && std::isfinite(scale.y) && std::isfinite(scale.z));
2085 const float3 &grab_location)
2088 segment->head, symm, symm_area, grab_location);
2090 segment->orig, symm, symm_area, grab_location);
2137 for (
const int i : ik_chain.
segments.index_range()) {
2150 float pivot_local_space[4][4];
2167 for (
int scale_i = 0; scale_i < 3; scale_i++) {
2173 symm_orig[0] - symm_initial_orig[0],
2174 symm_orig[1] - symm_initial_orig[1],
2175 symm_orig[2] - symm_initial_orig[2]);
2179 ik_chain.
segments[
i].pivot_mat[symm_it].ptr(), symm_orig[0], symm_orig[1], symm_orig[2]);
2183 ik_chain.
segments[
i].pivot_mat[symm_it].ptr());
2188 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 resize(const int64_t new_size)
void extend(Span< T > array)
Span< T > as_span() const
GAttributeReader lookup(const StringRef attribute_id) const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) 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
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
Vector< IKChainSegment > segments
static PoseGrowFactorData join(const PoseGrowFactorData &a, const PoseGrowFactorData &b)