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 for (
const int i : ik_chain->segments.index_range()) {
1055 const bool is_first_iteration =
i == 0;
1061 visited_face_sets.
add(current_data.face_set);
1064 std::optional<SegmentData> next_segment_data;
1066 float3 face_set_boundary_accum(0);
1067 int face_set_boundary_count = 0;
1069 float3 fallback_accum(0);
1070 int fallback_count = 0;
1072 const float3 &pose_initial_co = vert_positions[current_data.vert];
1073 flood_fill.execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1074 const float3 &to_v_position = vert_positions[to_v];
1076 to_v_position, pose_initial_co, symm);
1082 pose_factor[to_v] = 1.0f;
1083 is_weighted[to_v].set();
1087 vert_to_face_map, face_sets, to_v);
1088 visited_face_sets.
add(visited_face_set);
1090 else if (symmetry_check) {
1092 visited_face_sets.
add(current_data.face_set);
1101 bool is_vertex_valid =
false;
1102 if (is_first_iteration) {
1103 for (
const int visited_face_set : visited_face_sets) {
1105 vert_to_face_map, face_sets, to_v, visited_face_set);
1110 vert_to_face_map, face_sets, to_v, current_data.face_set);
1113 if (!is_vertex_valid) {
1117 bool visit_next =
false;
1118 if (!is_weighted[to_v]) {
1119 pose_factor[to_v] = 1.0f;
1120 is_weighted[to_v].set();
1125 if (symmetry_check) {
1126 fallback_accum += to_v_position;
1137 bool count_as_boundary =
false;
1140 faces, corner_verts, vert_to_face_map, hide_poly, to_v, neighbors))
1143 vert_to_face_map, face_sets, neighbor_idx);
1147 !visited_face_sets.
contains(next_face_set_candidate))
1149 if (!next_segment_data) {
1150 next_segment_data = {neighbor_idx, next_face_set_candidate};
1152 count_as_boundary =
true;
1157 if (count_as_boundary) {
1158 face_set_boundary_accum += to_v_position;
1159 face_set_boundary_count++;
1164 if (face_set_boundary_count > 0) {
1165 ik_chain->segments[
i].orig = face_set_boundary_accum / float(face_set_boundary_count);
1167 else if (fallback_count > 0) {
1168 ik_chain->segments[
i].orig = fallback_accum / float(fallback_count);
1171 ik_chain->segments[
i].orig =
float3(0);
1174 current_data = *next_segment_data;
1187 struct SegmentData {
1192 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
1215 for (
const int i : ik_chain->segments.index_range()) {
1216 const bool is_first_iteration =
i == 0;
1221 visited_face_sets.
add(current_data.face_set);
1224 std::optional<SegmentData> next_segment_data;
1226 float3 face_set_boundary_accum(0);
1227 int face_set_boundary_count = 0;
1229 float3 fallback_accum(0);
1230 int fallback_count = 0;
1232 const float3 &pose_initial_co = positions[current_data.vert];
1237 const int to_v_i = to_v.
to_index(key);
1239 const float3 to_v_position = positions[to_v_i];
1241 to_v_position, pose_initial_co, symm) &&
1248 pose_factor[to_v_i] = 1.0f;
1249 is_weighted[to_v_i].set();
1254 visited_face_sets.
add(visited_face_set);
1256 else if (symmetry_check) {
1259 visited_face_sets.
add(current_data.face_set);
1268 bool is_vertex_valid =
false;
1269 if (is_first_iteration) {
1270 for (
const int visited_face_set : visited_face_sets) {
1272 subdiv_ccg, face_sets, to_v.
grid_index, visited_face_set);
1277 subdiv_ccg, face_sets, to_v.
grid_index, current_data.face_set);
1280 if (!is_vertex_valid) {
1284 bool visit_next =
false;
1285 if (!is_weighted[to_v_i]) {
1286 pose_factor[to_v_i] = 1.0f;
1287 is_weighted[to_v_i].set();
1292 if (symmetry_check) {
1293 fallback_accum += to_v_position;
1297 if (!symmetry_check ||
1299 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v))
1306 bool count_as_boundary =
false;
1315 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, neighbor) &&
1316 !visited_face_sets.
contains(next_face_set_candidate))
1318 if (!next_segment_data) {
1319 next_segment_data = {neighbor.
to_index(key), next_face_set_candidate};
1321 count_as_boundary =
true;
1326 if (count_as_boundary) {
1327 face_set_boundary_accum += to_v_position;
1328 face_set_boundary_count++;
1333 if (face_set_boundary_count > 0) {
1334 ik_chain->segments[
i].orig = face_set_boundary_accum / float(face_set_boundary_count);
1336 else if (fallback_count > 0) {
1337 ik_chain->segments[
i].orig = fallback_accum / float(fallback_count);
1340 ik_chain->segments[
i].orig =
float3(0);
1343 current_data = *next_segment_data;
1356 struct SegmentData {
1374 for (
const int i : ik_chain->segments.index_range()) {
1375 const bool is_first_iteration =
i == 0;
1381 visited_face_sets.
add(current_data.face_set);
1384 std::optional<SegmentData> next_segment_data;
1386 float3 face_set_boundary_accum(0);
1387 int face_set_boundary_count = 0;
1389 float3 fallback_accum(0);
1390 int fallback_count = 0;
1392 const float3 pose_initial_co = current_data.vert->co;
1396 const float3 to_v_position = to_v->
co;
1398 to_v_position, pose_initial_co, symm);
1404 pose_factor[to_v_i] = 1.0f;
1405 is_weighted[to_v_i].set();
1409 visited_face_sets.
add(visited_face_set);
1411 else if (symmetry_check) {
1413 visited_face_sets.
add(current_data.face_set);
1422 bool is_vertex_valid =
false;
1423 if (is_first_iteration) {
1424 for (
const int visited_face_set : visited_face_sets) {
1430 face_set_offset, *to_v, current_data.face_set);
1433 if (!is_vertex_valid) {
1437 bool visit_next =
false;
1438 if (!is_weighted[to_v_i]) {
1439 pose_factor[to_v_i] = 1.0f;
1440 is_weighted[to_v_i].set();
1445 if (symmetry_check) {
1446 fallback_accum += to_v_position;
1456 bool count_as_boundary =
false;
1464 !visited_face_sets.
contains(next_face_set_candidate))
1466 if (!next_segment_data) {
1467 next_segment_data = {neighbor, next_face_set_candidate};
1469 count_as_boundary =
true;
1474 if (count_as_boundary) {
1475 face_set_boundary_accum += to_v_position;
1476 face_set_boundary_count++;
1481 if (face_set_boundary_count > 0) {
1482 ik_chain->segments[
i].orig = face_set_boundary_accum / float(face_set_boundary_count);
1484 else if (fallback_count > 0) {
1485 ik_chain->segments[
i].orig = fallback_accum / float(fallback_count);
1488 ik_chain->segments[
i].orig =
float3(0);
1491 current_data = *next_segment_data;
1521 const int active_face_set,
1522 const int target_face_set)
1536 for (
const int vert : vert_positions.
index_range()) {
1537 if (floodfill_step[vert] != 0 &&
1541 sum += vert_positions[vert];
1548 const SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
1559 if (floodfill_step[index] != 0 &&
1563 sum += positions[index];
1572 BMesh &
bm = *
object.sculpt->bm;
1577 if (floodfill_step[vert] != 0 &&
1594 return std::nullopt;
1601 const float3 &initial_location)
1611 const int active_vert = std::get<int>(ss.
active_vert());
1617 floodfill_step[active_vert] = 1;
1621 int masked_face_set_it = 0;
1624 step_floodfill.
execute(
object, vert_to_face_map, [&](
int from_v,
int to_v) {
1625 floodfill_step[to_v] = floodfill_step[from_v] + 1;
1628 if (!visited_face_sets.
contains(to_face_set)) {
1634 visited_face_sets.
add(to_face_set);
1636 if (floodfill_step[to_v] >= masked_face_set_it) {
1637 masked_face_set = to_face_set;
1638 masked_face_set_it = floodfill_step[to_v];
1642 target_face_set = to_face_set;
1651 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1652 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1654 std::optional<float3> head = std::nullopt;
1655 if (target_face_set != masked_face_set) {
1657 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1660 ik_chain->segments[0].head = head.value_or(initial_location);
1661 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1666 weight_floodfill.
execute(
object, vert_to_face_map, [&](
int ,
int to_v) {
1667 fk_weights[to_v] = 1.0f;
1679 const float3 &initial_location)
1681 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
1691 const Span<int> grid_to_face_map = subdiv_ccg.grid_to_face_map;
1694 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, grids_num);
1702 floodfill_step[active_vert_index] = 1;
1706 int masked_face_set_it = 0;
1711 const int from_v_i = from_v.
to_index(key);
1712 const int to_v_i = to_v.
to_index(key);
1714 if (!is_duplicate) {
1715 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1718 floodfill_step[to_v_i] = floodfill_step[from_v_i];
1721 const int to_face_set = face_sets[grid_to_face_map[to_v.
grid_index]];
1722 if (!visited_face_sets.
contains(to_face_set)) {
1724 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, to_v) &&
1726 faces, corner_verts, vert_to_face_map, face_sets, subdiv_ccg, from_v) &&
1730 visited_face_sets.
add(to_face_set);
1732 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1733 masked_face_set = to_face_set;
1734 masked_face_set_it = floodfill_step[to_v_i];
1738 target_face_set = to_face_set;
1744 subdiv_ccg, face_sets, to_v.
grid_index, active_face_set);
1748 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1749 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1751 std::optional<float3> head = std::nullopt;
1752 if (target_face_set != masked_face_set) {
1754 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1757 ik_chain->segments[0].head = head.value_or(initial_location);
1758 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1769 fk_weights[to_v_i] = 1.0f;
1771 subdiv_ccg, face_sets, to_v.
grid_index, masked_face_set);
1782 const float3 &initial_location)
1791 std::unique_ptr<IKChain> ik_chain =
ik_chain_new(1, verts_num);
1800 floodfill_step[active_vert_index] = 1;
1804 int masked_face_set_it = 0;
1811 floodfill_step[to_v_i] = floodfill_step[from_v_i] + 1;
1814 if (!visited_face_sets.
contains(to_face_set)) {
1820 visited_face_sets.
add(to_face_set);
1822 if (floodfill_step[to_v_i] >= masked_face_set_it) {
1823 masked_face_set = to_face_set;
1824 masked_face_set_it = floodfill_step[to_v_i];
1828 target_face_set = to_face_set;
1837 depsgraph,
object, floodfill_step, active_face_set, masked_face_set);
1838 ik_chain->segments[0].orig = origin.value_or(
float3(0));
1840 std::optional<float3> head = std::nullopt;
1841 if (target_face_set != masked_face_set) {
1843 depsgraph,
object, floodfill_step, active_face_set, target_face_set);
1846 ik_chain->segments[0].head = head.value_or(initial_location);
1847 ik_chain->grab_delta_offset = ik_chain->segments[0].head - initial_location;
1856 fk_weights[to_v_i] = 1.0f;
1868 const float3 &initial_location)
1886 const float3 &initial_location,
1889 std::unique_ptr<IKChain> ik_chain;
1893 if (use_fake_neighbors) {
1934 const float3 &initial_location,
1938 std::unique_ptr<SculptPoseIKChainPreview> preview = std::make_unique<SculptPoseIKChainPreview>();
1940 preview->initial_head_coords.reinitialize(chain.
segments.size());
1941 preview->initial_orig_coords.reinitialize(chain.
segments.size());
1942 for (
const int i : chain.
segments.index_range()) {
1943 preview->initial_head_coords[
i] = chain.
segments[
i].initial_head;
1944 preview->initial_orig_coords[
i] = chain.
segments[
i].initial_orig;
1962 ik_chain.
segments[0].initial_orig);
1965 const float segment_len = ik_chain.
segments[0].len;
2035 scale[0] = scale[1] =
sqrtf(1.0f / scale[2]);
2045 const float3 &grab_location)
2048 segment->head, symm, symm_area, grab_location);
2050 segment->orig, symm, symm_area, grab_location);
2097 for (
const int i : ik_chain.
segments.index_range()) {
2110 float pivot_local_space[4][4];
2127 for (
int scale_i = 0; scale_i < 3; scale_i++) {
2133 symm_orig[0] - symm_initial_orig[0],
2134 symm_orig[1] - symm_initial_orig[1],
2135 symm_orig[2] - symm_initial_orig[2]);
2139 ik_chain.
segments[
i].pivot_mat[symm_it].ptr(), symm_orig[0], symm_orig[1], symm_orig[2]);
2143 ik_chain.
segments[
i].pivot_mat[symm_it].ptr());
2148 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(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
Array< IKChainSegment > segments
static PoseGrowFactorData join(const PoseGrowFactorData &a, const PoseGrowFactorData &b)