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-10-03 19:09:43 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-10-17 17:55:34 +0300
commite5b18390fa591c8b37b9ef9884611b2888bab188 (patch)
tree78c9feebbe3d266f6c2960d9b6259743d51f60ed /source/blender/blenkernel/BKE_shrinkwrap.h
parentd31ea3b89aa8d583a6d089f96dff46c0759f8c8a (diff)
Shrinkwrap: implement the use of smooth normals in constraint & modifier.
- Use smooth normals to displace in Above Surface mode. - Add an option to align an axis to the normal in the constraint. I've seen people request the alignment feature, and it seems useful. For the actual aligning I use the damped track logic. In order to conveniently keep mesh data needed for normal computation together, a new data structure is introduced. Reviewers: mont29 Differential Revision: https://developer.blender.org/D3762
Diffstat (limited to 'source/blender/blenkernel/BKE_shrinkwrap.h')
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h39
1 files changed, 21 insertions, 18 deletions
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index 40f3808b94b..d1a14003b04 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -55,27 +55,25 @@ struct ShrinkwrapModifierData;
struct BVHTree;
struct SpaceTransform;
+typedef struct ShrinkwrapTreeData {
+ Mesh *mesh;
-typedef struct ShrinkwrapCalcData {
- ShrinkwrapModifierData *smd; //shrinkwrap modifier data
+ BVHTree *bvh;
+ BVHTreeFromMesh treeData;
- struct Object *ob; //object we are applying shrinkwrap to
+ float (*clnors)[3];
+} ShrinkwrapTreeData;
- struct MVert *vert; //Array of verts being projected (to fetch normals or other data)
- float (*vertexCos)[3]; //vertexs being shrinkwraped
- int numVerts;
+/* Checks if the modifier needs target normals with these settings. */
+bool BKE_shrinkwrap_needs_normals(int shrinkType, int shrinkMode);
- struct MDeformVert *dvert; //Pointer to mdeform array
- int vgroup; //Vertex group num
- bool invert_vgroup; /* invert vertex group influence */
+/* Initializes the mesh data structure from the given mesh and settings. */
+bool BKE_shrinkwrap_init_tree(struct ShrinkwrapTreeData *data, Mesh *mesh, int shrinkType, int shrinkMode, bool force_normals);
- struct Mesh *target; //mesh we are shrinking to
- struct SpaceTransform local2target; //transform to move between local and target space
-
- float keepDist; //Distance to keep above target surface (units are in local space)
-
-} ShrinkwrapCalcData;
+/* Frees the tree data if necessary. */
+void BKE_shrinkwrap_free_tree(struct ShrinkwrapTreeData *data);
+/* Implementation of the Shrinkwrap modifier */
void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Scene *scene, struct Object *ob, struct Mesh *mesh,
float (*vertexCos)[3], int numVerts);
@@ -91,12 +89,17 @@ void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Scene
*/
bool BKE_shrinkwrap_project_normal(
char options, const float vert[3], const float dir[3], const float ray_radius,
- const struct SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit,
- BVHTree_RayCastCallback callback, void *userdata);
+ const struct SpaceTransform *transf, struct ShrinkwrapTreeData *tree, BVHTreeRayHit *hit);
+
+/* 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,
+ int looptri_idx, const float hit_co[3], const float hit_no[3], float r_no[3]);
/* Apply the shrink to surface modes to the given original coordinates and nearest point. */
void BKE_shrinkwrap_snap_point_to_surface(
- int mode, const float hit_co[3], const float hit_no[3], float goal_dist,
+ const struct ShrinkwrapTreeData *tree, const struct 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]);
/*