Blender  V3.3
BKE_shrinkwrap.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright Blender Foundation. All rights reserved. */
3 #pragma once
4 
9 /* Shrinkwrap stuff */
10 #include "BKE_bvhutils.h"
11 #include "BLI_bitmap.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /*
18  * Shrinkwrap is composed by a set of functions and options that define the type of shrink.
19  *
20  * 3 modes are available:
21  * - Nearest vertex.
22  * - Nearest surface.
23  * - Normal projection.
24  *
25  * #ShrinkwrapCalcData encapsulates all needed data for shrink-wrap functions.
26  * (So that you don't have to pass an enormous amount of arguments to functions)
27  */
28 
29 struct BVHTree;
30 struct MDeformVert;
31 struct Mesh;
32 struct ModifierEvalContext;
33 struct Object;
36 struct SpaceTransform;
37 
38 /* Information about boundary edges in the mesh. */
40  /* Average direction of edges that meet here. */
41  float direction[3];
42 
43  /* Closest vector to direction that is orthogonal to vertex normal. */
44  float normal_plane[3];
46 
47 typedef struct ShrinkwrapBoundaryData {
48  /* True if the edge belongs to exactly one face. */
50  /* True if the looptri has any boundary edges. */
52 
53  /* Mapping from vertex index to boundary vertex index, or -1.
54  * Used for compact storage of data about boundary vertices. */
55  const int *vert_boundary_id;
56  unsigned int num_boundary_verts;
57 
58  /* Direction data about boundary vertices. */
61 
67 
68 /* Information about a mesh and BVH tree. */
69 typedef struct ShrinkwrapTreeData {
71 
74 
75  const float (*pnors)[3];
76  const float (*clnors)[3];
79 
83 bool BKE_shrinkwrap_needs_normals(int shrinkType, int shrinkMode);
84 
89  Mesh *mesh,
90  int shrinkType,
91  int shrinkMode,
92  bool force_normals);
93 
98 
103  const struct ModifierEvalContext *ctx,
104  struct Scene *scene,
105  struct Object *ob,
106  struct Mesh *mesh,
107  struct MDeformVert *dvert,
108  int defgrp_index,
109  float (*vertexCos)[3],
110  int numVerts);
111 /* Implementation of the Shrinkwrap Grease Pencil modifier. */
113  struct Object *ob,
114  struct MDeformVert *dvert,
115  int defgrp_index,
116  float (*vertexCos)[3],
117  int numVerts);
118 
123  struct Object *ob_source,
124  struct Object *ob_target);
125 
129 void BKE_shrinkwrap_remesh_target_project(struct Mesh *src_me,
130  struct Mesh *target_me,
131  struct Object *ob_target);
132 
151  const float vert[3],
152  const float dir[3],
153  float ray_radius,
154  const struct SpaceTransform *transf,
155  struct ShrinkwrapTreeData *tree,
156  BVHTreeRayHit *hit);
157 
162  struct BVHTreeNearest *nearest,
163  float co[3],
164  int type);
165 
174  const struct SpaceTransform *transform,
175  int looptri_idx,
176  const float hit_co[3],
177  const float hit_no[3],
178  float r_no[3]);
179 
188  const struct SpaceTransform *transform,
189  int mode,
190  int hit_idx,
191  const float hit_co[3],
192  const float hit_no[3],
193  float goal_dist,
194  const float point_co[3],
195  float r_point_co[3]);
196 
197 /*
198  * NULL initializes to local data
199  */
200 #define NULL_ShrinkwrapCalcData \
201  { \
202  NULL, \
203  }
204 #define NULL_BVHTreeFromMesh \
205  { \
206  NULL, \
207  }
208 #define NULL_BVHTreeRayHit \
209  { \
210  NULL, \
211  }
212 #define NULL_BVHTreeNearest \
213  { \
214  0, \
215  }
216 
217 #ifdef __cplusplus
218 }
219 #endif
typedef float(TangentPoint)[2]
struct ShrinkwrapBoundaryData ShrinkwrapBoundaryData
void BKE_shrinkwrap_find_nearest_surface(struct ShrinkwrapTreeData *tree, struct BVHTreeNearest *nearest, float co[3], int type)
Definition: shrinkwrap.c:1066
bool BKE_shrinkwrap_project_normal(char options, const float vert[3], const float dir[3], float ray_radius, const struct SpaceTransform *transf, struct ShrinkwrapTreeData *tree, BVHTreeRayHit *hit)
void BKE_shrinkwrap_remesh_target_project(struct Mesh *src_me, struct Mesh *target_me, struct Object *ob_target)
Definition: shrinkwrap.c:1550
struct ShrinkwrapBoundaryVertData ShrinkwrapBoundaryVertData
void BKE_shrinkwrap_mesh_nearest_surface_deform(struct bContext *C, struct Object *ob_source, struct Object *ob_target)
Definition: shrinkwrap.c:1525
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])
Definition: shrinkwrap.c:1170
bool BKE_shrinkwrap_needs_normals(int shrinkType, int shrinkMode)
Definition: shrinkwrap.c:90
void BKE_shrinkwrap_compute_boundary_data(struct Mesh *mesh)
Definition: shrinkwrap.c:323
void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, const struct ModifierEvalContext *ctx, struct Scene *scene, struct Object *ob, struct Mesh *mesh, struct MDeformVert *dvert, int defgrp_index, float(*vertexCos)[3], int numVerts)
void BKE_shrinkwrap_discard_boundary_data(struct Mesh *mesh)
Definition: shrinkwrap.c:152
bool BKE_shrinkwrap_init_tree(struct ShrinkwrapTreeData *data, Mesh *mesh, int shrinkType, int shrinkMode, bool force_normals)
Definition: shrinkwrap.c:97
void BKE_shrinkwrap_free_tree(struct ShrinkwrapTreeData *data)
Definition: shrinkwrap.c:147
struct ShrinkwrapTreeData ShrinkwrapTreeData
void BKE_shrinkwrap_snap_point_to_surface(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])
Definition: shrinkwrap.c:1288
void shrinkwrapGpencilModifier_deform(struct ShrinkwrapGpencilModifierData *mmd, struct Object *ob, struct MDeformVert *dvert, int defgrp_index, float(*vertexCos)[3], int numVerts)
Definition: shrinkwrap.c:1476
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
#define C
Definition: RandGen.cpp:25
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
CCL_NAMESPACE_BEGIN struct Options options
Scene scene
void * tree
const int * vert_boundary_id
const ShrinkwrapBoundaryVertData * boundary_verts
const BLI_bitmap * looptri_has_boundary
const BLI_bitmap * edge_is_boundary
unsigned int num_boundary_verts
const float(* clnors)[3]
const float(* pnors)[3]
BVHTreeFromMesh treeData
ShrinkwrapBoundaryData * boundary