diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_shrinkwrap.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index 9ec75c39fcf..e3d19a3d807 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -110,6 +110,11 @@ void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, float (*vertexCos)[3], int numVerts); +/* Used in editmesh_mask_extract.c to shrinkwrap the extracted mesh to the sculpt */ +void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C, + struct Object *ob_source, + struct Object *ob_target); + /* * This function casts a ray in the given BVHTree. * but it takes into consideration the space_transform, that is: diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 014a2c6d6ac..992ceda7b74 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -39,6 +39,7 @@ #include "BLI_task.h" #include "BLI_math_solvers.h" +#include "BKE_context.h" #include "BKE_shrinkwrap.h" #include "BKE_cdderivedmesh.h" #include "BKE_DerivedMesh.h" @@ -1480,3 +1481,28 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, ss_mesh->release(ss_mesh); } } + +void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C, + Object *ob_source, + Object *ob_target) +{ + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + struct Scene *sce = CTX_data_scene(C); + ShrinkwrapModifierData ssmd = {0}; + ModifierEvalContext ctx = {depsgraph, ob_source, 0}; + int totvert; + + ssmd.target = ob_target; + ssmd.shrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE; + ssmd.shrinkMode = MOD_SHRINKWRAP_ON_SURFACE; + ssmd.keepDist = 0.0f; + + Mesh *src_me = ob_source->data; + float(*vertexCos)[3] = BKE_mesh_vert_coords_alloc(src_me, &totvert); + + shrinkwrapModifier_deform(&ssmd, &ctx, sce, ob_source, src_me, NULL, -1, vertexCos, totvert); + + BKE_mesh_vert_coords_apply(src_me, vertexCos); + + MEM_freeN(vertexCos); +} |