Blender  V2.93
Macros | Functions
BKE_deform.h File Reference

support for deformation groups and hooks. More...

Go to the source code of this file.

Macros

#define VERTEX_WEIGHT_LOCK_EPSILON   1e-6f
 

Functions

struct bDeformGroupBKE_object_defgroup_new (struct Object *ob, const char *name)
 
void BKE_defgroup_copy_list (struct ListBase *outbase, const struct ListBase *inbase)
 
struct bDeformGroupBKE_defgroup_duplicate (const struct bDeformGroup *ingroup)
 
struct bDeformGroupBKE_object_defgroup_find_name (const struct Object *ob, const char *name)
 
int * BKE_object_defgroup_flip_map (const struct Object *ob, int *flip_map_len, const bool use_default)
 
int * BKE_object_defgroup_flip_map_single (const struct Object *ob, int *flip_map_len, const bool use_default, int defgroup)
 
int BKE_object_defgroup_flip_index (const struct Object *ob, int index, const bool use_default)
 
int BKE_object_defgroup_name_index (const struct Object *ob, const char *name)
 
void BKE_object_defgroup_unique_name (struct bDeformGroup *dg, struct Object *ob)
 
struct MDeformWeightBKE_defvert_find_index (const struct MDeformVert *dv, const int defgroup)
 
struct MDeformWeightBKE_defvert_ensure_index (struct MDeformVert *dv, const int defgroup)
 
void BKE_defvert_add_index_notest (struct MDeformVert *dv, int defgroup, const float weight)
 
void BKE_defvert_remove_group (struct MDeformVert *dvert, struct MDeformWeight *dw)
 
void BKE_defvert_clear (struct MDeformVert *dvert)
 
int BKE_defvert_find_shared (const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b)
 
bool BKE_defvert_is_weight_zero (const struct MDeformVert *dvert, const int defgroup_tot)
 
void BKE_defvert_array_free_elems (struct MDeformVert *dvert, int totvert)
 
void BKE_defvert_array_free (struct MDeformVert *dvert, int totvert)
 
void BKE_defvert_array_copy (struct MDeformVert *dst, const struct MDeformVert *src, int totvert)
 
float BKE_defvert_find_weight (const struct MDeformVert *dvert, const int defgroup)
 
float BKE_defvert_array_find_weight_safe (const struct MDeformVert *dvert, const int index, const int defgroup)
 
float BKE_defvert_total_selected_weight (const struct MDeformVert *dv, int defbase_tot, const bool *defbase_sel)
 
float BKE_defvert_multipaint_collective_weight (const struct MDeformVert *dv, int defbase_tot, const bool *defbase_sel, int defbase_tot_sel, bool is_normalized)
 
float BKE_defvert_calc_lock_relative_weight (float weight, float locked_weight, float unlocked_weight)
 
float BKE_defvert_lock_relative_weight (float weight, const struct MDeformVert *dv, int defbase_tot, const bool *defbase_locked, const bool *defbase_unlocked)
 
void BKE_defvert_copy (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src)
 
void BKE_defvert_copy_subset (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool *vgroup_subset, const int vgroup_tot)
 
void BKE_defvert_mirror_subset (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool *vgroup_subset, const int vgroup_tot, const int *flip_map, const int flip_map_len)
 
void BKE_defvert_copy_index (struct MDeformVert *dvert_dst, const int defgroup_dst, const struct MDeformVert *dvert_src, const int defgroup_src)
 
void BKE_defvert_sync (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool use_ensure)
 
void BKE_defvert_sync_mapped (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int *flip_map, const int flip_map_len, const bool use_ensure)
 
void BKE_defvert_remap (struct MDeformVert *dvert, const int *map, const int map_len)
 
void BKE_defvert_flip (struct MDeformVert *dvert, const int *flip_map, const int flip_map_len)
 
void BKE_defvert_flip_merged (struct MDeformVert *dvert, const int *flip_map, const int flip_map_len)
 
void BKE_defvert_normalize (struct MDeformVert *dvert)
 
void BKE_defvert_normalize_subset (struct MDeformVert *dvert, const bool *vgroup_subset, const int vgroup_tot)
 
void BKE_defvert_normalize_lock_single (struct MDeformVert *dvert, const bool *vgroup_subset, const int vgroup_tot, const uint def_nr_lock)
 
void BKE_defvert_normalize_lock_map (struct MDeformVert *dvert, const bool *vgroup_subset, const int vgroup_tot, const bool *lock_flags, const int defbase_tot)
 
void BKE_defvert_extract_vgroup_to_vertweights (struct MDeformVert *dvert, const int defgroup, const int num_verts, float *r_weights, const bool invert_vgroup)
 
void BKE_defvert_extract_vgroup_to_edgeweights (struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MEdge *edges, const int num_edges, float *r_weights, const bool invert_vgroup)
 
void BKE_defvert_extract_vgroup_to_loopweights (struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MLoop *loops, const int num_loops, float *r_weights, const bool invert_vgroup)
 
void BKE_defvert_extract_vgroup_to_polyweights (struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MLoop *loops, const int num_loops, struct MPoly *polys, const int num_polys, float *r_weights, const bool invert_vgroup)
 
void BKE_defvert_weight_to_rgb (float r_rgb[3], const float weight)
 
void BKE_defvert_blend_write (struct BlendWriter *writer, int count, struct MDeformVert *dvlist)
 
void BKE_defvert_blend_read (struct BlendDataReader *reader, int count, struct MDeformVert *mdverts)
 

Detailed Description

support for deformation groups and hooks.

Definition in file BKE_deform.h.

Macro Definition Documentation

◆ VERTEX_WEIGHT_LOCK_EPSILON

#define VERTEX_WEIGHT_LOCK_EPSILON   1e-6f

Definition at line 84 of file BKE_deform.h.

Function Documentation

◆ BKE_defgroup_copy_list()

void BKE_defgroup_copy_list ( struct ListBase outbase,
const struct ListBase inbase 
)

◆ BKE_defgroup_duplicate()

struct bDeformGroup* BKE_defgroup_duplicate ( const struct bDeformGroup ingroup)

Referenced by vgroup_duplicate().

◆ BKE_defvert_add_index_notest()

void BKE_defvert_add_index_notest ( MDeformVert dvert,
int  defgroup,
const float  weight 
)

Adds the given vertex to the specified vertex group, with given weight.

Warning
this does NOT check for existing, assume caller already knows its not there.

Definition at line 726 of file deform.c.

References BLI_assert, MDeformWeight::def_nr, MDeformVert::dw, MEM_callocN, MEM_freeN, MDeformVert::totweight, and MDeformWeight::weight.

Referenced by ED_vgroup_nr_vert_add(), gpencil_vertex_group_invert_exec(), subdivide_base(), vgroups_datatransfer_interp(), and weightvg_update_vg().

◆ BKE_defvert_array_copy()

void BKE_defvert_array_copy ( struct MDeformVert dst,
const struct MDeformVert src,
int  totvert 
)

◆ BKE_defvert_array_find_weight_safe()

float BKE_defvert_array_find_weight_safe ( const struct MDeformVert dvert,
const int  index,
const int  defgroup 
)

Take care with this the rationale is:

  • if the object has no vertex group. act like vertex group isn't set and return 1.0,
  • if the vertex group exists but the 'defgroup' isn't found on this vertex, still return 0.0

This is a bit confusing, just saves some checks from the caller.

Definition at line 645 of file deform.c.

References BKE_defvert_find_weight(), and NULL.

Referenced by modifyMesh(), shrinkwrap_calc_nearest_surface_point_cb_ex(), shrinkwrap_calc_nearest_vertex_cb_ex(), shrinkwrap_calc_normal_projection_cb_ex(), and SimpleDeformModifier_do().

◆ BKE_defvert_array_free()

void BKE_defvert_array_free ( struct MDeformVert dvert,
int  totvert 
)

◆ BKE_defvert_array_free_elems()

void BKE_defvert_array_free_elems ( struct MDeformVert dvert,
int  totvert 
)

◆ BKE_defvert_blend_read()

void BKE_defvert_blend_read ( struct BlendDataReader reader,
int  count,
struct MDeformVert mdverts 
)

◆ BKE_defvert_blend_write()

void BKE_defvert_blend_write ( struct BlendWriter writer,
int  count,
struct MDeformVert dvlist 
)

Definition at line 1525 of file deform.c.

References BLO_write_struct_array, count, and NULL.

Referenced by CustomData_blend_write(), greasepencil_blend_write(), and lattice_blend_write().

◆ BKE_defvert_calc_lock_relative_weight()

float BKE_defvert_calc_lock_relative_weight ( float  weight,
float  locked_weight,
float  unlocked_weight 
)

Computes the display weight for the lock relative weight paint mode.

Returns
weight divided by 1-locked_weight with division by zero check

Definition at line 887 of file deform.c.

References VERTEX_WEIGHT_LOCK_EPSILON.

Referenced by BKE_defvert_lock_relative_weight(), do_weight_paint_vertex_multi(), and do_weight_paint_vertex_single().

◆ BKE_defvert_clear()

void BKE_defvert_clear ( struct MDeformVert dvert)

Definition at line 785 of file deform.c.

References MDeformVert::dw, MEM_freeN, NULL, and MDeformVert::totweight.

Referenced by bpy_bmdeformvert_clear().

◆ BKE_defvert_copy()

void BKE_defvert_copy ( struct MDeformVert dvert_dst,
const struct MDeformVert dvert_src 
)

◆ BKE_defvert_copy_index()

void BKE_defvert_copy_index ( struct MDeformVert dvert_dst,
const int  defgroup_dst,
const struct MDeformVert dvert_src,
const int  defgroup_src 
)

Referenced by dvert_mirror_op().

◆ BKE_defvert_copy_subset()

void BKE_defvert_copy_subset ( struct MDeformVert dvert_dst,
const struct MDeformVert dvert_src,
const bool *  vgroup_subset,
const int  vgroup_tot 
)

◆ BKE_defvert_ensure_index()

struct MDeformWeight* BKE_defvert_ensure_index ( MDeformVert dvert,
const int  defgroup 
)

◆ BKE_defvert_extract_vgroup_to_edgeweights()

void BKE_defvert_extract_vgroup_to_edgeweights ( MDeformVert dvert,
const int  defgroup,
const int  num_verts,
MEdge edges,
const int  num_edges,
float r_weights,
const bool  invert_vgroup 
)

The following three make basic interpolation, using temp vert_weights array to avoid looking up same weight several times.

Definition at line 1015 of file deform.c.

References BKE_defvert_extract_vgroup_to_vertweights(), copy_vn_fl(), MEM_freeN, MEM_mallocN, MEdge::v1, and MEdge::v2.

Referenced by BKE_object_data_transfer_ex().

◆ BKE_defvert_extract_vgroup_to_loopweights()

void BKE_defvert_extract_vgroup_to_loopweights ( struct MDeformVert dvert,
const int  defgroup,
const int  num_verts,
struct MLoop loops,
const int  num_loops,
float r_weights,
const bool  invert_vgroup 
)

◆ BKE_defvert_extract_vgroup_to_polyweights()

void BKE_defvert_extract_vgroup_to_polyweights ( struct MDeformVert dvert,
const int  defgroup,
const int  num_verts,
struct MLoop loops,
const int  num_loops,
struct MPoly polys,
const int  num_polys,
float r_weights,
const bool  invert_vgroup 
)

◆ BKE_defvert_extract_vgroup_to_vertweights()

void BKE_defvert_extract_vgroup_to_vertweights ( struct MDeformVert dvert,
const int  defgroup,
const int  num_verts,
float r_weights,
const bool  invert_vgroup 
)

◆ BKE_defvert_find_index()

struct MDeformWeight* BKE_defvert_find_index ( const struct MDeformVert dv,
const int  defgroup 
)

◆ BKE_defvert_find_shared()

int BKE_defvert_find_shared ( const struct MDeformVert dvert_a,
const struct MDeformVert dvert_b 
)

◆ BKE_defvert_find_weight()

float BKE_defvert_find_weight ( const struct MDeformVert dvert,
const int  defgroup 
)

◆ BKE_defvert_flip()

void BKE_defvert_flip ( struct MDeformVert dvert,
const int *  flip_map,
const int  flip_map_len 
)

◆ BKE_defvert_flip_merged()

void BKE_defvert_flip_merged ( struct MDeformVert dvert,
const int *  flip_map,
const int  flip_map_len 
)

◆ BKE_defvert_is_weight_zero()

bool BKE_defvert_is_weight_zero ( const struct MDeformVert dvert,
const int  defgroup_tot 
)

return true if has no weights

Definition at line 818 of file deform.c.

References MDeformWeight::def_nr, MDeformVert::dw, LIKELY, MDeformVert::totweight, and MDeformWeight::weight.

Referenced by evaluate_vertex_weight().

◆ BKE_defvert_lock_relative_weight()

float BKE_defvert_lock_relative_weight ( float  weight,
const struct MDeformVert dv,
int  defbase_tot,
const bool *  defbase_locked,
const bool *  defbase_unlocked 
)

Computes the display weight for the lock relative weight paint mode, using weight data.

Returns
weight divided by unlocked, or 1-locked_weight with division by zero check.

Definition at line 920 of file deform.c.

References BKE_defvert_calc_lock_relative_weight(), and BKE_defvert_total_selected_weight().

Referenced by do_weight_paint_vertex_multi(), do_weight_paint_vertex_single(), evaluate_vertex_weight(), weight_sample_invoke(), and wpaint_get_active_weight().

◆ BKE_defvert_mirror_subset()

void BKE_defvert_mirror_subset ( struct MDeformVert dvert_dst,
const struct MDeformVert dvert_src,
const bool *  vgroup_subset,
const int  vgroup_tot,
const int *  flip_map,
const int  flip_map_len 
)

◆ BKE_defvert_multipaint_collective_weight()

float BKE_defvert_multipaint_collective_weight ( const struct MDeformVert dv,
int  defbase_tot,
const bool *  defbase_sel,
int  defbase_tot_sel,
bool  is_normalized 
)
Returns
The representative weight of a multipaint group, used for viewport colors and actual painting.

Result equal to sum of weights with auto normalize, and average otherwise. Value is not clamped, since painting relies on multiplication being always commutative with the collective weight function.

Definition at line 865 of file deform.c.

References BKE_defvert_total_selected_weight().

Referenced by do_weight_paint_vertex_multi(), evaluate_vertex_weight(), weight_sample_invoke(), and wpaint_get_active_weight().

◆ BKE_defvert_normalize()

void BKE_defvert_normalize ( struct MDeformVert dvert)

Definition at line 304 of file deform.c.

References CLAMP, MDeformVert::dw, MDeformVert::totweight, and MDeformWeight::weight.

◆ BKE_defvert_normalize_lock_map()

void BKE_defvert_normalize_lock_map ( MDeformVert dvert,
const bool *  vgroup_subset,
const int  vgroup_tot,
const bool *  lock_flags,
const int  defbase_tot 
)

Same as BKE_defvert_normalize() if no locked vgroup is a member of the subset

Definition at line 393 of file deform.c.

References CLAMP, MDeformWeight::def_nr, MDeformVert::dw, max_ff(), MDeformVert::totweight, and MDeformWeight::weight.

Referenced by vgroup_normalize_all().

◆ BKE_defvert_normalize_lock_single()

void BKE_defvert_normalize_lock_single ( MDeformVert dvert,
const bool *  vgroup_subset,
const int  vgroup_tot,
const uint  def_nr_lock 
)

Same as BKE_defvert_normalize() if the locked vgroup is not a member of the subset

Definition at line 336 of file deform.c.

References CLAMP, MDeformWeight::def_nr, MDeformVert::dw, NULL, MDeformVert::totweight, and MDeformWeight::weight.

Referenced by paint_weight_gradient_exec(), and vgroup_normalize_all().

◆ BKE_defvert_normalize_subset()

void BKE_defvert_normalize_subset ( MDeformVert dvert,
const bool *  vgroup_subset,
const int  vgroup_tot 
)

◆ BKE_defvert_remap()

void BKE_defvert_remap ( MDeformVert dvert,
const int *  map,
const int  map_len 
)

be sure all flip_map values are valid

Definition at line 252 of file deform.c.

References BLI_assert, MDeformWeight::def_nr, MDeformVert::dw, and MDeformVert::totweight.

Referenced by vgroup_do_remap().

◆ BKE_defvert_remove_group()

void BKE_defvert_remove_group ( MDeformVert dvert,
MDeformWeight dw 
)

◆ BKE_defvert_sync()

void BKE_defvert_sync ( struct MDeformVert dvert_dst,
const struct MDeformVert dvert_src,
const bool  use_ensure 
)

◆ BKE_defvert_sync_mapped()

void BKE_defvert_sync_mapped ( struct MDeformVert dvert_dst,
const struct MDeformVert dvert_src,
const int *  flip_map,
const int  flip_map_len,
const bool  use_ensure 
)

◆ BKE_defvert_total_selected_weight()

float BKE_defvert_total_selected_weight ( const struct MDeformVert dv,
int  defbase_tot,
const bool *  defbase_sel 
)

◆ BKE_defvert_weight_to_rgb()

void BKE_defvert_weight_to_rgb ( float  r_rgb[3],
const float  weight 
)

Definition at line 1486 of file deform.c.

References blend().

Referenced by psys_cache_edit_paths_iter().

◆ BKE_object_defgroup_find_name()

struct bDeformGroup* BKE_object_defgroup_find_name ( const struct Object ob,
const char *  name 
)

◆ BKE_object_defgroup_flip_index()

int BKE_object_defgroup_flip_index ( const struct Object ob,
int  index,
const bool  use_default 
)

◆ BKE_object_defgroup_flip_map()

int* BKE_object_defgroup_flip_map ( const struct Object ob,
int *  flip_map_len,
const bool  use_default 
)

◆ BKE_object_defgroup_flip_map_single()

int* BKE_object_defgroup_flip_map_single ( const struct Object ob,
int *  flip_map_len,
const bool  use_default,
int  defgroup 
)

Referenced by ED_vgroup_mirror().

◆ BKE_object_defgroup_name_index()

int BKE_object_defgroup_name_index ( const struct Object ob,
const char *  name 
)

◆ BKE_object_defgroup_new()

struct bDeformGroup* BKE_object_defgroup_new ( struct Object ob,
const char *  name 
)

◆ BKE_object_defgroup_unique_name()

void BKE_object_defgroup_unique_name ( struct bDeformGroup dg,
struct Object ob 
)