Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-11-06 21:04:53 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-11-06 21:20:17 +0300
commitf600b4bc67667b867899cac3725ac7ed44bfbfe3 (patch)
tree145927ae29bd2e5fe2b09228176a9644f143db6f /source/blender/blenkernel/BKE_shrinkwrap.h
parent0709fac41ef0a20955069fcd6609577189e96d5c (diff)
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
Diffstat (limited to 'source/blender/blenkernel/BKE_shrinkwrap.h')
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index d1a14003b04..04c0f1c5d9a 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -33,6 +33,7 @@
/* Shrinkwrap stuff */
#include "BKE_bvhutils.h"
+#include "BLI_bitmap.h"
/*
* Shrinkwrap is composed by a set of functions and options that define the type of shrink.
@@ -55,6 +56,34 @@ struct ShrinkwrapModifierData;
struct BVHTree;
struct SpaceTransform;
+/* Information about boundary edges in the mesh. */
+typedef struct ShrinkwrapBoundaryVertData {
+ /* Average direction of edges that meet here. */
+ float direction[3];
+
+ /* Closest vector to direction that is orthogonal to vertex normal. */
+ float normal_plane[3];
+} ShrinkwrapBoundaryVertData;
+
+typedef struct ShrinkwrapBoundaryData {
+ /* True if the edge belongs to exactly one face. */
+ const BLI_bitmap *edge_is_boundary;
+ /* True if the looptri has any boundary edges. */
+ const BLI_bitmap *looptri_has_boundary;
+
+ /* Mapping from vertex index to boundary vertex index, or -1.
+ * Used for compact storage of data about boundary vertices. */
+ const int *vert_boundary_id;
+ unsigned int num_boundary_verts;
+
+ /* Direction data about boundary vertices. */
+ const ShrinkwrapBoundaryVertData *boundary_verts;
+} ShrinkwrapBoundaryData;
+
+void BKE_shrinkwrap_discard_boundary_data(struct Mesh *mesh);
+void BKE_shrinkwrap_compute_boundary_data(struct Mesh *mesh);
+
+/* Information about a mesh and BVH tree. */
typedef struct ShrinkwrapTreeData {
Mesh *mesh;
@@ -62,6 +91,7 @@ typedef struct ShrinkwrapTreeData {
BVHTreeFromMesh treeData;
float (*clnors)[3];
+ ShrinkwrapBoundaryData *boundary;
} ShrinkwrapTreeData;
/* Checks if the modifier needs target normals with these settings. */
@@ -91,6 +121,10 @@ bool BKE_shrinkwrap_project_normal(
char options, const float vert[3], const float dir[3], const float ray_radius,
const struct SpaceTransform *transf, struct ShrinkwrapTreeData *tree, BVHTreeRayHit *hit);
+/* Maps the point to the nearest surface, either by simple nearest, or by target normal projection. */
+void BKE_shrinkwrap_find_nearest_surface(
+ struct ShrinkwrapTreeData *tree, struct BVHTreeNearest *nearest, float co[3], int type);
+
/* Computes a smooth normal of the target (if applicable) at the hit location. */
void BKE_shrinkwrap_compute_smooth_normal(
const struct ShrinkwrapTreeData *tree, const struct SpaceTransform *transform,