Blender V4.3
BKE_shrinkwrap.hh File Reference
#include "BKE_bvhutils.hh"
#include "BLI_array.hh"
#include "BLI_bit_vector.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_offset_indices.hh"
#include "BLI_span.hh"
#include "BLI_virtual_array.hh"

Go to the source code of this file.

Classes

struct  ShrinkwrapBoundaryVertData
 
class  ShrinkwrapBoundaryData
 
struct  ShrinkwrapTreeData
 
struct  ShrinkwrapParams
 

Namespaces

namespace  blender
 
namespace  blender::bke
 
namespace  blender::bke::shrinkwrap
 

Macros

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

Functions

const ShrinkwrapBoundaryDatablender::bke::shrinkwrap::boundary_cache_ensure (const Mesh &mesh)
 
bool BKE_shrinkwrap_needs_normals (int shrinkType, int shrinkMode)
 
bool BKE_shrinkwrap_init_tree (ShrinkwrapTreeData *data, Mesh *mesh, int shrinkType, int shrinkMode, bool force_normals)
 
void BKE_shrinkwrap_free_tree (ShrinkwrapTreeData *data)
 
void shrinkwrapModifier_deform (ShrinkwrapModifierData *smd, const ModifierEvalContext *ctx, Scene *scene, Object *ob, Mesh *mesh, const MDeformVert *dvert, int defgrp_index, float(*vertexCos)[3], int numVerts)
 
void shrinkwrapGpencilModifier_deform (ShrinkwrapGpencilModifierData *mmd, Object *ob, MDeformVert *dvert, int defgrp_index, float(*vertexCos)[3], int numVerts)
 
void shrinkwrapParams_deform (const ShrinkwrapParams &params, Object &object, ShrinkwrapTreeData &tree, blender::Span< MDeformVert > dvert, int defgrp_index, blender::MutableSpan< blender::float3 > positions)
 
void BKE_shrinkwrap_mesh_nearest_surface_deform (Depsgraph *depsgraph, Scene *scene, Object *ob_source, Object *ob_target)
 
void BKE_shrinkwrap_remesh_target_project (Mesh *src_me, Mesh *target_me, Object *ob_target)
 
bool BKE_shrinkwrap_project_normal (char options, const float vert[3], const float dir[3], float ray_radius, const SpaceTransform *transf, ShrinkwrapTreeData *tree, BVHTreeRayHit *hit)
 
void BKE_shrinkwrap_find_nearest_surface (ShrinkwrapTreeData *tree, BVHTreeNearest *nearest, float co[3], int type)
 
void BKE_shrinkwrap_compute_smooth_normal (const ShrinkwrapTreeData *tree, const SpaceTransform *transform, int tri_idx, const float hit_co[3], const float hit_no[3], float r_no[3])
 
void BKE_shrinkwrap_snap_point_to_surface (const ShrinkwrapTreeData *tree, const 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, \
}
#define NULL

Definition at line 248 of file BKE_shrinkwrap.hh.

Referenced by followtrack_project_to_depth_object_if_needed().

◆ NULL_BVHTreeNearest

#define NULL_BVHTreeNearest
Value:
{ \
0, \
}

Definition at line 256 of file BKE_shrinkwrap.hh.

Referenced by shrinkwrap_calc_nearest_surface_point(), and shrinkwrap_calc_nearest_vertex().

◆ NULL_BVHTreeRayHit

#define NULL_BVHTreeRayHit
Value:
{ \
NULL, \
}

Definition at line 252 of file BKE_shrinkwrap.hh.

◆ NULL_ShrinkwrapCalcData

Function Documentation

◆ BKE_shrinkwrap_compute_smooth_normal()

void BKE_shrinkwrap_compute_smooth_normal ( const ShrinkwrapTreeData * tree,
const SpaceTransform * transform,
int tri_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 1153 of file shrinkwrap.cc.

References BLI_space_transform_apply(), BLI_space_transform_invert_normal(), copy_v3_v3(), BVHTreeFromMesh::corner_tris, BVHTreeFromMesh::corner_verts, interp_v3_v3v3v3(), interp_weights_tri_v3(), normalize_v3(), tree, BVHTreeFromMesh::vert_positions, and w().

Referenced by BKE_shrinkwrap_snap_point_to_surface(), and shrinkwrap_get_tarmat().

◆ BKE_shrinkwrap_find_nearest_surface()

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

Maps the point to the nearest surface, either by simple nearest, or by target normal projection.

Definition at line 1049 of file shrinkwrap.cc.

References BLI_bvhtree_find_nearest(), BLI_bvhtree_find_nearest_ex(), BVH_NEAREST_OPTIMAL_ORDER, mesh_corner_tris_target_project(), MOD_SHRINKWRAP_TARGET_PROJECT, BVHTreeFromMesh::nearest_callback, printf, and tree.

Referenced by shrinkwrap_calc_nearest_surface_point_cb_ex(), and shrinkwrap_get_tarmat().

◆ BKE_shrinkwrap_free_tree()

◆ BKE_shrinkwrap_init_tree()

◆ BKE_shrinkwrap_mesh_nearest_surface_deform()

void BKE_shrinkwrap_mesh_nearest_surface_deform ( Depsgraph * depsgraph,
Scene * scene,
Object * ob_source,
Object * ob_target )

◆ BKE_shrinkwrap_needs_normals()

bool BKE_shrinkwrap_needs_normals ( int shrinkType,
int shrinkMode )

◆ BKE_shrinkwrap_project_normal()

bool BKE_shrinkwrap_project_normal ( char options,
const float vert[3],
const float dir[3],
float ray_radius,
const SpaceTransform * transf,
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.

Definition at line 390 of file shrinkwrap.cc.

References BLI_assert, BLI_bvhtree_ray_cast(), BLI_space_transform_apply(), BLI_space_transform_apply_normal(), BLI_space_transform_invert(), BLI_space_transform_invert_normal(), BVHTreeRayHit::co, copy_v3_v3(), BVHTreeRayHit::dist, dot_v3v3(), BVHTreeRayHit::index, len_v3v3(), mat4_to_scale(), MOD_SHRINKWRAP_CULL_TARGET_BACKFACE, MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE, MOD_SHRINKWRAP_CULL_TARGET_MASK, BVHTreeRayHit::no, options, and tree.

Referenced by shrinkwrap_calc_normal_projection_cb_ex(), and shrinkwrap_get_tarmat().

◆ BKE_shrinkwrap_remesh_target_project()

◆ BKE_shrinkwrap_snap_point_to_surface()

void BKE_shrinkwrap_snap_point_to_surface ( const ShrinkwrapTreeData * tree,
const 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 1275 of file shrinkwrap.cc.

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, printf, shrinkwrap_snap_with_side(), 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 ( ShrinkwrapGpencilModifierData * mmd,
Object * ob,
MDeformVert * dvert,
int defgrp_index,
float(*) vertexCos[3],
int numVerts )

◆ shrinkwrapModifier_deform()

void shrinkwrapModifier_deform ( ShrinkwrapModifierData * smd,
const ModifierEvalContext * ctx,
Scene * scene,
Object * ob,
Mesh * mesh,
const MDeformVert * dvert,
int defgrp_index,
float(*) vertexCos[3],
int numVerts )

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

Definition at line 1353 of file shrinkwrap.cc.

References ShrinkwrapCalcData::aux_target, ShrinkwrapModifierData::auxTarget, BKE_modifier_get_evaluated_mesh_from_evaluated_object(), BKE_shrinkwrap_free_tree(), BKE_shrinkwrap_init_tree(), BLI_assert, BLI_SPACE_TRANSFORM_SETUP, CDDM_from_mesh(), DEG_get_evaluated_object(), ModifierEvalContext::depsgraph, ShrinkwrapCalcData::dvert, SubsurfModifierData::emCache, DerivedMesh::getNumVerts, DerivedMesh::getVertArray, ShrinkwrapCalcData::invert_vgroup, ShrinkwrapCalcData::keepDist, ShrinkwrapModifierData::keepDist, SubsurfModifierData::levels, ShrinkwrapCalcData::local2target, SubsurfModifierData::mCache, ME_CC_SUBSURF, MOD_SHRINKWRAP_INVERT_VGROUP, MOD_SHRINKWRAP_NEAREST_SURFACE, MOD_SHRINKWRAP_NEAREST_VERTEX, MOD_SHRINKWRAP_PROJECT, MOD_SHRINKWRAP_TARGET_PROJECT, Object::mode, NULL_ShrinkwrapCalcData, ShrinkwrapCalcData::numVerts, ShrinkwrapCalcData::ob, OB_MODE_EDIT, DerivedMesh::release, ShrinkwrapModifierData::shrinkMode, ShrinkwrapModifierData::shrinkOpts, ShrinkwrapModifierData::shrinkType, shrinkwrap_calc_nearest_surface_point(), shrinkwrap_calc_nearest_vertex(), shrinkwrap_calc_normal_projection(), ShrinkwrapCalcData::smd, SubsurfModifierData::subdivType, SUBSURF_IN_EDIT_MODE, subsurf_make_derived_from_derived(), ShrinkwrapModifierData::subsurfLevels, ShrinkwrapCalcData::target, ShrinkwrapModifierData::target, TIMEIT_BENCH, ShrinkwrapCalcData::tree, tree, ShrinkwrapCalcData::vert_normals, ShrinkwrapCalcData::vert_positions, ShrinkwrapCalcData::vertexCos, and ShrinkwrapCalcData::vgroup.

Referenced by BKE_shrinkwrap_mesh_nearest_surface_deform(), and deform_verts().

◆ shrinkwrapParams_deform()