Blender  V3.3
Classes | Macros | Typedefs | Functions
BKE_shrinkwrap.h File Reference
#include "BKE_bvhutils.h"
#include "BLI_bitmap.h"

Go to the source code of this file.

Classes

struct  ShrinkwrapBoundaryVertData
 
struct  ShrinkwrapBoundaryData
 
struct  ShrinkwrapTreeData
 

Macros

#define NULL_ShrinkwrapCalcData
 
#define NULL_BVHTreeFromMesh
 
#define NULL_BVHTreeRayHit
 
#define NULL_BVHTreeNearest
 

Typedefs

typedef struct ShrinkwrapBoundaryVertData ShrinkwrapBoundaryVertData
 
typedef struct ShrinkwrapBoundaryData ShrinkwrapBoundaryData
 
typedef struct ShrinkwrapTreeData ShrinkwrapTreeData
 

Functions

void BKE_shrinkwrap_discard_boundary_data (struct Mesh *mesh)
 
void BKE_shrinkwrap_compute_boundary_data (struct Mesh *mesh)
 
bool BKE_shrinkwrap_needs_normals (int shrinkType, int shrinkMode)
 
bool BKE_shrinkwrap_init_tree (struct ShrinkwrapTreeData *data, Mesh *mesh, int shrinkType, int shrinkMode, bool force_normals)
 
void BKE_shrinkwrap_free_tree (struct ShrinkwrapTreeData *data)
 
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 shrinkwrapGpencilModifier_deform (struct ShrinkwrapGpencilModifierData *mmd, struct Object *ob, struct MDeformVert *dvert, int defgrp_index, float(*vertexCos)[3], int numVerts)
 
void BKE_shrinkwrap_mesh_nearest_surface_deform (struct bContext *C, struct Object *ob_source, struct Object *ob_target)
 
void BKE_shrinkwrap_remesh_target_project (struct Mesh *src_me, struct Mesh *target_me, struct Object *ob_target)
 
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_find_nearest_surface (struct ShrinkwrapTreeData *tree, struct BVHTreeNearest *nearest, float co[3], int type)
 
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])
 
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])
 

Macro Definition Documentation

◆ NULL_BVHTreeFromMesh

#define NULL_BVHTreeFromMesh
Value:
{ \
NULL, \
}

Definition at line 204 of file BKE_shrinkwrap.h.

◆ NULL_BVHTreeNearest

#define NULL_BVHTreeNearest
Value:
{ \
0, \
}

Definition at line 212 of file BKE_shrinkwrap.h.

◆ NULL_BVHTreeRayHit

#define NULL_BVHTreeRayHit
Value:
{ \
NULL, \
}

Definition at line 208 of file BKE_shrinkwrap.h.

◆ NULL_ShrinkwrapCalcData

#define NULL_ShrinkwrapCalcData
Value:
{ \
NULL, \
}

Definition at line 200 of file BKE_shrinkwrap.h.

Typedef Documentation

◆ ShrinkwrapBoundaryData

◆ ShrinkwrapBoundaryVertData

◆ ShrinkwrapTreeData

Function Documentation

◆ BKE_shrinkwrap_compute_boundary_data()

void BKE_shrinkwrap_compute_boundary_data ( struct Mesh mesh)

◆ BKE_shrinkwrap_compute_smooth_normal()

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] 
)

Compute a smooth normal of the target (if applicable) at the hit location.

Parameters
treeinformation about the mesh.
transformtransform from the hit coordinate space to the object space; may be null.
r_nooutput in hit coordinate space; may be shared with inputs.

Definition at line 1170 of file shrinkwrap.c.

References BLI_space_transform_apply(), BLI_space_transform_invert_normal(), MVert::co, copy_v3_v3(), float(), interp_v3_v3v3v3(), interp_weights_tri_v3(), BVHTreeFromMesh::loop, BVHTreeFromMesh::looptri, ME_SMOOTH, normalize_v3(), NULL, MLoopTri::poly, transform(), tree, MLoopTri::tri, MLoop::v, BVHTreeFromMesh::vert, and w().

Referenced by BKE_shrinkwrap_snap_point_to_surface(), and shrinkwrap_get_tarmat().

◆ BKE_shrinkwrap_discard_boundary_data()

void BKE_shrinkwrap_discard_boundary_data ( struct Mesh mesh)

Free boundary data for target project.

Definition at line 152 of file shrinkwrap.c.

References data, MEM_freeN, mesh, NULL, Mesh::runtime, and Mesh_Runtime::shrinkwrap_data.

Referenced by BKE_mesh_runtime_clear_geometry(), and BKE_shrinkwrap_compute_boundary_data().

◆ BKE_shrinkwrap_find_nearest_surface()

void BKE_shrinkwrap_find_nearest_surface ( struct ShrinkwrapTreeData tree,
struct BVHTreeNearest nearest,
float  co[3],
int  type 
)

◆ BKE_shrinkwrap_free_tree()

void BKE_shrinkwrap_free_tree ( struct ShrinkwrapTreeData data)

◆ BKE_shrinkwrap_init_tree()

bool BKE_shrinkwrap_init_tree ( struct ShrinkwrapTreeData data,
Mesh mesh,
int  shrinkType,
int  shrinkMode,
bool  force_normals 
)

◆ BKE_shrinkwrap_mesh_nearest_surface_deform()

void BKE_shrinkwrap_mesh_nearest_surface_deform ( struct bContext C,
struct Object ob_source,
struct Object ob_target 
)

◆ BKE_shrinkwrap_needs_normals()

bool BKE_shrinkwrap_needs_normals ( int  shrinkType,
int  shrinkMode 
)

Checks if the modifier needs target normals with these settings.

Definition at line 90 of file shrinkwrap.c.

References MOD_SHRINKWRAP_ABOVE_SURFACE, MOD_SHRINKWRAP_NEAREST_VERTEX, and MOD_SHRINKWRAP_TARGET_PROJECT.

Referenced by BKE_shrinkwrap_init_tree(), blender::deg::DepsgraphRelationBuilder::build_constraints(), and updateDepsgraph().

◆ BKE_shrinkwrap_project_normal()

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 
)

This function ray-cast a single vertex and updates the hit if the "hit" is considered valid.

Parameters
optionsOpts control whether an hit is valid or not. Supported options are:
transfTake into consideration the space_transform, that is: if transf was configured with SPACE_TRANSFORM_SETUP( &transf, ob1, ob2) then the input (vert, dir, BVHTreeRayHit) must be defined in ob1 coordinates space and the BVHTree must be built in ob2 coordinate space. Thus it provides an easy way to cast the same ray across several trees (where each tree was built on its own coords space).
Returns
true if "hit" was updated.

Referenced by shrinkwrap_get_tarmat().

◆ BKE_shrinkwrap_remesh_target_project()

void BKE_shrinkwrap_remesh_target_project ( struct Mesh src_me,
struct Mesh target_me,
struct Object ob_target 
)

◆ BKE_shrinkwrap_snap_point_to_surface()

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] 
)

Apply the shrink to surface modes to the given original coordinates and nearest point.

Parameters
treemesh data for smooth normals.
transformtransform from the hit coordinate space to the object space; may be null.
r_point_comay be the same memory location as point_co, hit_co, or hit_no.

Definition at line 1288 of file shrinkwrap.c.

References BKE_shrinkwrap_compute_smooth_normal(), copy_v3_v3(), madd_v3_v3v3fl(), MOD_SHRINKWRAP_ABOVE_SURFACE, MOD_SHRINKWRAP_INSIDE, MOD_SHRINKWRAP_ON_SURFACE, MOD_SHRINKWRAP_OUTSIDE, MOD_SHRINKWRAP_OUTSIDE_SURFACE, shrinkwrap_snap_with_side(), transform(), and tree.

Referenced by shrinkwrap_calc_nearest_surface_point_cb_ex(), shrinkwrap_calc_normal_projection_cb_ex(), and shrinkwrap_get_tarmat().

◆ shrinkwrapGpencilModifier_deform()

void shrinkwrapGpencilModifier_deform ( struct ShrinkwrapGpencilModifierData mmd,
struct Object ob,
struct MDeformVert dvert,
int  defgrp_index,
float(*)  vertexCos[3],
int  numVerts 
)

◆ shrinkwrapModifier_deform()

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 
)

Main shrink-wrap function (implementation of the shrink-wrap modifier).

Referenced by deformVerts(), and deformVertsEM().