From f600b4bc67667b867899cac3725ac7ed44bfbfe3 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Tue, 6 Nov 2018 21:04:53 +0300 Subject: Shrinkwrap: new mode that projects along the target normal. The Nearest Surface Point shrink method, while fast, is neither smooth nor continuous: as the source point moves, the projected point can both stop and jump. This causes distortions in the deformation of the shrinkwrap modifier, and the motion of an animated object with a shrinkwrap constraint. This patch implements a new mode, which, instead of using the simple nearest point search, iteratively solves an equation for each triangle to find a point which has its interpolated normal point to or from the original vertex. Non-manifold boundary edges are treated as infinitely thin cylinders that cast normals in all perpendicular directions. Since this is useful for the constraint, and having multiple objects with constraints targeting the same guide mesh is a quite reasonable use case, rather than calculating the mesh boundary edge data over and over again, it is precomputed and cached in the mesh. Reviewers: mont29 Differential Revision: https://developer.blender.org/D3836 --- source/blender/makesdna/DNA_mesh_types.h | 3 +++ source/blender/makesdna/DNA_modifier_types.h | 1 + 2 files changed, 4 insertions(+) (limited to 'source/blender/makesdna') diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index c591b57002a..fda18e5cbd6 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -100,6 +100,9 @@ typedef struct Mesh_Runtime { /** 'BVHCache', for 'BKE_bvhutil.c' */ struct LinkNode *bvh_cache; + /** Non-manifold boundary data for Shrinkwrap Target Project. */ + struct ShrinkwrapBoundaryData *shrinkwrap_data; + /** Set by modifier stack if only deformed from original. */ char deformed_only; /** diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 6f8793bf0f7..4eb9f890be0 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -888,6 +888,7 @@ enum { MOD_SHRINKWRAP_NEAREST_SURFACE = 0, MOD_SHRINKWRAP_PROJECT = 1, MOD_SHRINKWRAP_NEAREST_VERTEX = 2, + MOD_SHRINKWRAP_TARGET_PROJECT = 3, }; /* Shrinkwrap->shrinkMode */ -- cgit v1.2.3