49# define TIMEIT_BENCH(expr, id) (expr)
53#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
102 if (mesh ==
nullptr) {
111 if (mesh->verts_num <= 0) {
116 data->faces = mesh->faces();
117 data->corner_edges = mesh->corner_edges();
118 data->vert_normals = mesh->vert_normals();
120 data->sharp_faces = *attributes.
lookup<
bool>(
"sharp_face", AttrDomain::Face);
125 return data->bvh !=
nullptr;
128 if (mesh->faces_num <= 0) {
134 if (data->bvh ==
nullptr) {
139 data->face_normals = mesh->face_normals();
141 data->corner_normals = mesh->corner_normals();
163 const float edge_dir[3],
167 float *direction = vdata[index].
direction;
173 if (status[index] >= 0 ? status[index] == side :
dot_v3v3(direction, edge_dir) < 0) {
180 status[index] = (status[index] == 0) ? side : -1;
187 const Span<int> corner_verts = mesh.corner_verts();
188 const Span<int> corner_edges = mesh.corner_edges();
193 for (
const int edge : corner_edges) {
194 if (edge_mode[edge] < 2) {
200 BitVector<> edge_is_boundary(mesh.edges_num,
false);
202 int num_boundary_edges = 0;
203 for (
const int64_t i : edges.index_range()) {
204 if (edge_mode[i] == 1) {
205 edge_is_boundary[i].set();
206 num_boundary_edges++;
211 if (num_boundary_edges == 0) {
219 const Span<int3> corner_tris = mesh.corner_tris();
225 edges, corner_verts, corner_edges, corner_tris[i]);
227 for (
int j = 0; j < 3; j++) {
228 if (real_edges[j] >= 0 && edge_is_boundary[real_edges[j]]) {
229 tri_has_boundary[i].set();
236 Array<int> vert_boundary_id(mesh.verts_num, 0);
238 for (
const int64_t i : edges.index_range()) {
239 if (edge_is_boundary[i]) {
240 const int2 &edge = edges[i];
241 vert_boundary_id[edge[0]] = 1;
242 vert_boundary_id[edge[1]] = 1;
246 int boundary_verts_num = 0;
247 for (
const int64_t i : positions.index_range()) {
248 vert_boundary_id[i] = (vert_boundary_id[i] != 0) ? boundary_verts_num++ : -1;
255 for (
const int64_t i : edges.index_range()) {
256 if (edge_is_boundary[i]) {
257 const int2 &edge = edges[i];
260 sub_v3_v3v3(dir, positions[edge[1]], positions[edge[0]]);
263 merge_vert_dir(boundary_verts.
data(), vert_status, vert_boundary_id[edge[0]], dir, 1);
264 merge_vert_dir(boundary_verts.
data(), vert_status, vert_boundary_id[edge[1]], dir, 2);
270 for (
const int64_t i : positions.index_range()) {
271 int bidx = vert_boundary_id[i];
285 data.edge_is_boundary = std::move(edge_is_boundary);
286 data.tri_has_boundary = std::move(tri_has_boundary);
287 data.vert_boundary_id = std::move(vert_boundary_id);
288 data.boundary_verts = std::move(boundary_verts);
295 mesh.runtime->shrinkwrap_boundary_cache.ensure(
297 return mesh.runtime->shrinkwrap_boundary_cache.data();
323 weight = 1.0f - weight;
326 if (weight == 0.0f) {
344 if (nearest->index != -1) {
354 if (nearest->index != -1) {
357 if (nearest->dist_sq > FLT_EPSILON) {
358 const float dist =
sqrtf(nearest->dist_sq);
359 weight *= (dist - calc->
keepDist) / dist;
383 settings.use_threading = (calc->
numVerts > 10000);
384 settings.userdata_chunk = &nearest;
385 settings.userdata_chunk_size =
sizeof(nearest);
393 const float ray_radius,
403 float tmp_co[3], tmp_no[3];
404 const float *co, *no;
408 memcpy(&hit_tmp, hit,
sizeof(hit_tmp));
420#ifdef USE_DIST_CORRECT
432 tree->bvh, co, no, ray_radius, &hit_tmp,
tree->treeData.raycast_callback, &
tree->treeData);
434 if (hit_tmp.
index != -1) {
453#ifdef USE_DIST_CORRECT
460 memcpy(hit, &hit_tmp,
sizeof(hit_tmp));
476 float *proj_axis = data->proj_axis;
483 const float *tmp_co, *tmp_no;
487 weight = 1.0f - weight;
490 if (weight == 0.0f) {
558 if (proj_limit_squared != 0.0f) {
559 if (hit->index != -1 &&
len_squared_v3v3(hit->co, co) > proj_limit_squared) {
564 if (hit->index != -1) {
595 float proj_axis[3] = {0.0f, 0.0f, 0.0f};
605 Mesh *auxMesh =
nullptr;
656 aux_tree = &aux_tree_stack;
663 data.aux_tree = aux_tree;
664 data.proj_axis = proj_axis;
665 data.local2aux = &local2aux;
668 settings.use_threading = (calc->
numVerts > 10000);
669 settings.userdata_chunk = &hit;
670 settings.userdata_chunk_size =
sizeof(hit);
713 const float w[3] = {x[0], x[1], 1.0f - x[0] - x[1]};
714 interp_v3_v3v3v3(data->co_interp, data->vtri_co[0], data->vtri_co[1], data->vtri_co[2],
w);
715 interp_v3_v3v3v3(data->no_interp, data->vtri_no[0], data->vtri_no[1], data->vtri_no[2],
w);
726 madd_v3_v3v3fl(r_jacobian[0], data->c0_minus_c2, data->n0_minus_n2, x[2]);
727 madd_v3_v3v3fl(r_jacobian[1], data->c1_minus_c2, data->n1_minus_n2, x[2]);
743 if (x[0] + x[1] > 1.0f) {
744 x[0] = x[0] / (x[0] + x[1]);
756 const float epsilon = 1e-5f;
758 const float dir_epsilon = 0.5f;
759 bool fixed =
false, locked =
false;
764 float sum = x[0] + x[1];
765 float sstep = -(step[0] + step[1]);
767 if (
sum + sstep > 1.0f) {
768 float ldist = 1.0f -
sum;
771 if (ldist < epsilon *
float(
M_SQRT2)) {
772 float step_len =
len_v2(step);
775 if (step_len > epsilon && sstep > step_len * dir_epsilon *
float(
M_SQRT2)) {
781 fixed = locked =
true;
791 for (
int i = 0; i < 2; i++) {
792 if (step[i] > x[i]) {
794 if (x[i] < epsilon) {
795 float step_len =
len_v2(step);
798 if (step_len > epsilon && (locked || step[i] > step_len * dir_epsilon)) {
824 const float vtri_no[3][3],
825 const float point_co[3],
826 const float hit_co[3],
832 float dist =
sqrtf(hit_dist_sq);
835 float epsilon = magnitude_estimate * 1.0e-6f;
843 x[2] = (
dot_v3v3(tmp, r_hit_no) < 0) ? -dist : dist;
848 tri_data.vtri_no = vtri_no;
849 tri_data.point_co = point_co;
851 sub_v3_v3v3(tri_data.n0_minus_n2, vtri_no[0], vtri_no[2]);
852 sub_v3_v3v3(tri_data.n1_minus_n2, vtri_no[1], vtri_no[2]);
853 sub_v3_v3v3(tri_data.c0_minus_c2, vtri_co[0], vtri_co[2]);
854 sub_v3_v3v3(tri_data.c1_minus_c2, vtri_co[1], vtri_co[2]);
858#ifdef TRACE_TARGET_PROJECT
859 const bool trace =
true;
861 const bool trace =
false;
887 const float hit_co[3],
888 const float hit_no[3])
892 if (dist_sq < nearest->dist_sq) {
893#ifdef TRACE_TARGET_PROJECT
895 "#=#=#> %d (%.3f,%.3f,%.3f) %g < %g\n", index,
UNPACK3(hit_co), dist_sq, nearest->dist_sq);
897 nearest->index = index;
898 nearest->dist_sq = dist_sq;
917 const float *vedge_co[2] = {data->vert_positions[edge[0]], data->vert_positions[edge[1]]};
919#ifdef TRACE_TARGET_PROJECT
920 printf(
"EDGE %d (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)\n",
927 const int *vert_boundary_id =
tree->boundary->vert_boundary_id.data();
928 int bid1 = vert_boundary_id[edge[0]], bid2 = vert_boundary_id[edge[1]];
930 if (bid1 < 0 || bid2 < 0) {
936 float vedge_dir[2][3], dir[3];
938 copy_v3_v3(vedge_dir[0], boundary_verts[bid1].normal_plane);
939 copy_v3_v3(vedge_dir[1], boundary_verts[bid2].normal_plane);
943 if (
dot_v3v3(boundary_verts[bid1].direction, dir) < 0) {
946 if (
dot_v3v3(boundary_verts[bid2].direction, dir) < 0) {
951 float d0v0 =
dot_v3v3(vedge_dir[0], vedge_co[0]), d0v1 =
dot_v3v3(vedge_dir[0], vedge_co[1]);
952 float d1v0 =
dot_v3v3(vedge_dir[1], vedge_co[0]), d1v1 =
dot_v3v3(vedge_dir[1], vedge_co[1]);
953 float d0co =
dot_v3v3(vedge_dir[0], co);
955 float a = d0v1 - d0v0 + d1v0 - d1v1;
956 float b = 2 * d0v0 - d0v1 - d0co - d1v0 +
dot_v3v3(vedge_dir[1], co);
957 float c = d0co - d0v0;
958 float det =
b *
b - 4 * a * c;
961 const float epsilon = 1e-6f;
962 float sdet =
sqrtf(det);
963 float hit_co[3], hit_no[3];
965 for (
int i = (det > 0 ? 2 : 0); i >= 0; i -= 2) {
966 float x = (-
b + (
float(i) - 1) * sdet) / (2 * a);
968 if (x >= -epsilon && x <= 1.0f + epsilon) {
971 float vedge_no[2][3];
978 update_hit(nearest, index, co, hit_co, hit_no);
993 const int3 &tri = data->corner_tris[index];
994 const int tri_verts[3] = {
995 data->corner_verts[tri[0]],
996 data->corner_verts[tri[1]],
997 data->corner_verts[tri[2]],
999 const float *vtri_co[3] = {
1000 data->vert_positions[tri_verts[0]],
1001 data->vert_positions[tri_verts[1]],
1002 data->vert_positions[tri_verts[2]],
1004 float raw_hit_co[3], hit_co[3], hit_no[3], dist_sq, vtri_no[3][3];
1010#ifdef TRACE_TARGET_PROJECT
1011 printf(
"TRIANGLE %d (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f) %g %g\n",
1020 if (dist_sq >= nearest->dist_sq) {
1031 update_hit(nearest, index, co, hit_co, hit_no);
1034 else if (
tree->boundary &&
tree->boundary->has_boundary() &&
1035 tree->boundary->tri_has_boundary[index])
1037 const BitSpan is_boundary =
tree->boundary->edge_is_boundary;
1038 const int3 edges = bke::mesh::corner_tri_get_real_edges(
1039 data->edges, data->corner_verts,
tree->corner_edges, tri);
1041 for (
int i = 0; i < 3; i++) {
1042 if (edges[i] >= 0 && is_boundary[edges[i]]) {
1057#ifdef TRACE_TARGET_PROJECT
1058 printf(
"\n====== TARGET PROJECT START ======\n");
1064#ifdef TRACE_TARGET_PROJECT
1065 printf(
"====== TARGET PROJECT END: %d %g ======\n\n", nearest->index, nearest->dist_sq);
1068 if (nearest->index < 0) {
1098 weight = 1.0f - weight;
1101 if (weight == 0.0f) {
1119 if (nearest->index != -1) {
1122 nearest->index = -1;
1136 if (nearest->index != -1) {
1156 const float hit_co[3],
1157 const float hit_no[3],
1163 const int face_i =
tree->mesh->corner_tri_faces()[corner_tri_idx];
1166 if (
tree->sharp_faces.is_empty() ||
tree->sharp_faces[face_i]) {
1167 const int vert_indices[3] = {treeData->
corner_verts[tri[0]],
1170 float w[3], no[3][3], tmp_co[3];
1173 if (!
tree->corner_normals.is_empty()) {
1209 else if (!
tree->face_normals.is_empty()) {
1223 const float point_co[3],
1224 const float hit_co[3],
1225 const float hit_no[3],
1233 float dist =
len_v3(delta);
1236 if (dist < FLT_EPSILON) {
1237 if (forcesnap || goal_dist > 0) {
1238 madd_v3_v3v3fl(r_point_co, hit_co, hit_no, goal_dist * forcesign);
1248 if (forcesign == 0.0f) {
1253 if (forcesnap || dsign * dist * forcesign < goal_dist) {
1259 if (dist < dist_epsilon) {
1260#ifdef TRACE_TARGET_PROJECT
1261 printf(
"zero_factor %g = %g / %g\n", dist / dist_epsilon, dist, dist_epsilon);
1267 madd_v3_v3v3fl(r_point_co, hit_co, delta, goal_dist * forcesign);
1279 const float hit_co[3],
1280 const float hit_no[3],
1282 const float point_co[3],
1283 float r_point_co[3])
1290 if (goal_dist != 0) {
1307 if (goal_dist != 0) {
1317 if (goal_dist != 0) {
1327 printf(
"Unknown Shrinkwrap surface snap mode: %d\n", mode);
1346 settings.use_threading = (calc->
numVerts > 10000);
1347 settings.userdata_chunk = &nearest;
1348 settings.userdata_chunk_size =
sizeof(nearest);
1359 const int defgrp_index,
1360 float (*vertexCos)[3],
1381 calc.
vgroup = defgrp_index;
1384 if (smd->
target !=
nullptr) {
1400 calc.
vert_positions =
reinterpret_cast<float(*)[3]
>(mesh->vert_positions_for_write().data());
1470 const int defgrp_index,
1471 float (*vertexCos)[3],
1493 calc.
vgroup = defgrp_index;
1520 const int defgrp_index,
1541 calc.
vertexCos =
reinterpret_cast<float(*)[3]
>(positions.data());
1543 calc.
vgroup = defgrp_index;
1550 switch (
params.shrink_type) {
1589 reinterpret_cast<float(*)[3]
>(src_me->vert_positions_for_write().data()),
1591 src_me->tag_positions_changed();
1606 const float projLimitTolerance = 5.0f;
1613 calc.
vertexCos =
reinterpret_cast<float(*)[3]
>(src_me->vert_positions_for_write().data());
1618 calc.
vert_positions =
reinterpret_cast<float(*)[3]
>(src_me->vert_positions_for_write().data());
1628 src_me->tag_positions_changed();
void free_bvhtree_from_mesh(BVHTreeFromMesh *data)
BVHTree * BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, const Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
@ BVHTREE_FROM_CORNER_TRIS
DerivedMesh * CDDM_from_mesh(Mesh *mesh)
void BKE_mesh_wrapper_ensure_mdata(Mesh *mesh)
Mesh * BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval)
#define NULL_BVHTreeNearest
#define NULL_ShrinkwrapCalcData
DerivedMesh * subsurf_make_derived_from_derived(DerivedMesh *dm, SubsurfModifierData *smd, const Scene *scene, float(*vertCos)[3], SubsurfFlags flags)
@ BVH_NEAREST_OPTIMAL_ORDER
#define BVH_RAYCAST_DIST_MAX
int BLI_bvhtree_find_nearest(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
int BLI_bvhtree_ray_cast(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
int BLI_bvhtree_find_nearest_ex(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata, int flag)
MINLINE float signf(float f)
void interp_weights_tri_v3(float w[3], const float v1[3], const float v2[3], const float v3[3], const float co[3])
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
float mat4_to_scale(const float mat[4][4])
void BLI_space_transform_apply_normal(const struct SpaceTransform *data, float no[3])
void BLI_space_transform_apply(const struct SpaceTransform *data, float co[3])
void BLI_space_transform_invert_normal(const struct SpaceTransform *data, float no[3])
void BLI_space_transform_invert(const struct SpaceTransform *data, float co[3])
#define BLI_SPACE_TRANSFORM_SETUP(data, local, target)
bool BLI_newton3d_solve(Newton3D_DeltaFunc func_delta, Newton3D_JacobianFunc func_jacobian, Newton3D_CorrectionFunc func_correction, void *userdata, float epsilon, int max_iterations, bool trace, const float x_init[3], float result[3])
Solve a generic f(x) = 0 equation using Newton's method.
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void sub_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void add_v2_fl(float r[2], float f)
MINLINE void negate_v3(float r[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE float len_manhattan_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
Utility defines for timing/benchmarks.
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
@ GP_SHRINKWRAP_INVERT_VGROUP
@ MOD_SHRINKWRAP_TARGET_PROJECT
@ MOD_SHRINKWRAP_NEAREST_VERTEX
@ MOD_SHRINKWRAP_NEAREST_SURFACE
#define MOD_SHRINKWRAP_CULL_TARGET_MASK
@ MOD_SHRINKWRAP_ON_SURFACE
@ MOD_SHRINKWRAP_ABOVE_SURFACE
@ MOD_SHRINKWRAP_OUTSIDE_SURFACE
@ MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR
@ MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE
@ MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR
@ MOD_SHRINKWRAP_CULL_TARGET_BACKFACE
@ MOD_SHRINKWRAP_INVERT_VGROUP
@ MOD_SHRINKWRAP_INVERT_CULL_TARGET
@ MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS
@ MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS
@ MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS
@ MOD_SHRINKWRAP_PROJECT_OVER_NORMAL
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static T sum(const btAlignedObjectArray< T > &items)
constexpr const T * data() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
GAttributeReader lookup(const StringRef attribute_id) const
local_group_size(16, 16) .push_constant(Type b
CCL_NAMESPACE_BEGIN struct Options options
const Depsgraph * depsgraph
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
int3 corner_tri_get_real_edges(Span< int2 > edges, Span< int > corner_verts, Span< int > corner_edges, const int3 &corner_tri)
static void merge_vert_dir(ShrinkwrapBoundaryVertData *vdata, MutableSpan< int8_t > status, int index, const float edge_dir[3], signed char side)
const ShrinkwrapBoundaryData & boundary_cache_ensure(const Mesh &mesh)
static ShrinkwrapBoundaryData shrinkwrap_build_boundary_data(const Mesh &mesh)
static void target_project_edge(const ShrinkwrapTreeData *tree, int index, const float co[3], BVHTreeNearest *nearest, int eidx)
static void target_project_tri_clamp(float x[3])
static bool target_project_solve_point_tri(const float *vtri_co[3], const float vtri_no[3][3], const float point_co[3], const float hit_co[3], float hit_dist_sq, float r_hit_co[3], float r_hit_no[3])
void BKE_shrinkwrap_free_tree(ShrinkwrapTreeData *data)
void BKE_shrinkwrap_snap_point_to_surface(const ShrinkwrapTreeData *tree, const SpaceTransform *transform, int mode, int hit_idx, const float hit_co[3], const float hit_no[3], float goal_dist, const float point_co[3], float r_point_co[3])
static void mesh_corner_tris_target_project(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
void shrinkwrapGpencilModifier_deform(ShrinkwrapGpencilModifierData *mmd, Object *ob, MDeformVert *dvert, const int defgrp_index, float(*vertexCos)[3], int numVerts)
static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
static bool update_hit(BVHTreeNearest *nearest, int index, const float co[3], const float hit_co[3], const float hit_no[3])
static void shrinkwrap_snap_with_side(float r_point_co[3], const float point_co[3], const float hit_co[3], const float hit_no[3], float goal_dist, float forcesign, bool forcesnap)
bool BKE_shrinkwrap_project_normal(char options, const float vert[3], const float dir[3], const float ray_radius, const SpaceTransform *transf, ShrinkwrapTreeData *tree, BVHTreeRayHit *hit)
static void target_project_tri_deviation(void *userdata, const float x[3], float r_delta[3])
static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls)
void BKE_shrinkwrap_mesh_nearest_surface_deform(Depsgraph *depsgraph, Scene *scene, Object *ob_source, Object *ob_target)
static void shrinkwrap_calc_normal_projection_cb_ex(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls)
void BKE_shrinkwrap_remesh_target_project(Mesh *src_me, Mesh *target_me, Object *ob_target)
#define TIMEIT_BENCH(expr, id)
bool BKE_shrinkwrap_needs_normals(int shrinkType, int shrinkMode)
void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, const ModifierEvalContext *ctx, Scene *scene, Object *ob, Mesh *mesh, const MDeformVert *dvert, const int defgrp_index, float(*vertexCos)[3], int numVerts)
static void target_project_tri_jacobian(void *userdata, const float x[3], float r_jacobian[3][3])
void BKE_shrinkwrap_compute_smooth_normal(const ShrinkwrapTreeData *tree, const SpaceTransform *transform, int corner_tri_idx, const float hit_co[3], const float hit_no[3], float r_no[3])
bool BKE_shrinkwrap_init_tree(ShrinkwrapTreeData *data, Mesh *mesh, int shrinkType, int shrinkMode, bool force_normals)
void shrinkwrapParams_deform(const ShrinkwrapParams ¶ms, Object &object, ShrinkwrapTreeData &tree, const blender::Span< MDeformVert > dvert, const int defgrp_index, const blender::MutableSpan< blender::float3 > positions)
static bool target_project_tri_correct(void *, const float x[3], float step[3], float x_next[3])
void BKE_shrinkwrap_find_nearest_surface(ShrinkwrapTreeData *tree, BVHTreeNearest *nearest, float co[3], int type)
static void shrinkwrap_calc_nearest_surface_point_cb_ex(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls)
static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
blender::Span< blender::int3 > corner_tris
blender::Span< blender::float3 > vert_positions
blender::Span< int > corner_verts
BVHTree_NearestPointCallback nearest_callback
int(* getNumVerts)(DerivedMesh *dm)
float *(* getVertArray)(DerivedMesh *dm)
void(* release)(DerivedMesh *dm)
SpaceTransform * local2aux
ShrinkwrapTreeData * tree
ShrinkwrapCalcData * calc
ShrinkwrapTreeData * aux_tree
SpaceTransform local2target
float(* vert_positions)[3]
blender::Span< blender::float3 > vert_normals
const MDeformVert * dvert
ShrinkwrapTreeData * tree
ShrinkwrapModifierData * smd
struct Object * aux_target
struct ShrinkwrapTreeData * cache_data
struct Object * auxTarget
const float(* vtri_no)[3]