Blender  V3.3
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

bool BKE_object_supports_vertex_groups (const struct Object *ob)
 
const struct ListBaseBKE_object_defgroup_list (const struct Object *ob)
 
struct ListBaseBKE_object_defgroup_list_mutable (struct Object *ob)
 
int BKE_object_defgroup_count (const struct Object *ob)
 
int BKE_object_defgroup_active_index_get (const struct Object *ob)
 
void BKE_object_defgroup_active_index_set (struct Object *ob, int new_index)
 
const struct ListBaseBKE_id_defgroup_list_get (const struct ID *id)
 
struct ListBaseBKE_id_defgroup_list_get_mutable (struct ID *id)
 
int BKE_id_defgroup_name_index (const struct ID *id, const char *name)
 
bool BKE_id_defgroup_name_find (const struct ID *id, const char *name, int *r_index, struct bDeformGroup **r_group)
 
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, bool use_default)
 
int * BKE_object_defgroup_flip_map_single (const struct Object *ob, int *flip_map_len, bool use_default, int defgroup)
 
int BKE_object_defgroup_flip_index (const struct Object *ob, int index, 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, int defgroup)
 
struct MDeformWeightBKE_defvert_ensure_index (struct MDeformVert *dv, int defgroup)
 
void BKE_defvert_add_index_notest (struct MDeformVert *dv, int defgroup, 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, 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, int defgroup)
 
float BKE_defvert_array_find_weight_safe (const struct MDeformVert *dvert, int index, 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, int vgroup_tot)
 
void BKE_defvert_mirror_subset (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool *vgroup_subset, int vgroup_tot, const int *flip_map, int flip_map_len)
 
void BKE_defvert_copy_index (struct MDeformVert *dvert_dst, int defgroup_dst, const struct MDeformVert *dvert_src, int defgroup_src)
 
void BKE_defvert_sync (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, bool use_ensure)
 
void BKE_defvert_sync_mapped (struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int *flip_map, int flip_map_len, bool use_ensure)
 
void BKE_defvert_remap (struct MDeformVert *dvert, const int *map, int map_len)
 
void BKE_defvert_flip (struct MDeformVert *dvert, const int *flip_map, int flip_map_len)
 
void BKE_defvert_flip_merged (struct MDeformVert *dvert, const int *flip_map, int flip_map_len)
 
void BKE_defvert_normalize (struct MDeformVert *dvert)
 
void BKE_defvert_normalize_subset (struct MDeformVert *dvert, const bool *vgroup_subset, int vgroup_tot)
 
void BKE_defvert_normalize_lock_single (struct MDeformVert *dvert, const bool *vgroup_subset, int vgroup_tot, uint def_nr_lock)
 
void BKE_defvert_normalize_lock_map (struct MDeformVert *dvert, const bool *vgroup_subset, int vgroup_tot, const bool *lock_flags, int defbase_tot)
 
void BKE_defvert_extract_vgroup_to_vertweights (const struct MDeformVert *dvert, int defgroup, int num_verts, bool invert_vgroup, float *r_weights)
 
void BKE_defvert_extract_vgroup_to_edgeweights (const struct MDeformVert *dvert, int defgroup, int num_verts, struct MEdge *edges, int num_edges, bool invert_vgroup, float *r_weights)
 
void BKE_defvert_extract_vgroup_to_loopweights (const struct MDeformVert *dvert, int defgroup, int num_verts, struct MLoop *loops, int num_loops, bool invert_vgroup, float *r_weights)
 
void BKE_defvert_extract_vgroup_to_polyweights (const struct MDeformVert *dvert, int defgroup, int num_verts, struct MLoop *loops, int num_loops, struct MPoly *polys, int num_polys, bool invert_vgroup, float *r_weights)
 
void BKE_defvert_weight_to_rgb (float r_rgb[3], float weight)
 
void BKE_defvert_blend_write (struct BlendWriter *writer, int count, const struct MDeformVert *dvlist)
 
void BKE_defvert_blend_read (struct BlendDataReader *reader, int count, struct MDeformVert *mdverts)
 
void BKE_defbase_blend_write (struct BlendWriter *writer, const ListBase *defbase)
 

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 133 of file BKE_deform.h.

Function Documentation

◆ BKE_defbase_blend_write()

void BKE_defbase_blend_write ( struct BlendWriter writer,
const ListBase defbase 
)

Definition at line 1557 of file deform.c.

References BLO_write_struct, and LISTBASE_FOREACH.

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

◆ 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 ( struct MDeformVert dv,
int  defgroup,
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 779 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(), blender::ed::geometry::geometry_attribute_convert_exec(), 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,
int  index,
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 710 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 simple_helper().

◆ 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,
const struct MDeformVert dvlist 
)

◆ 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 911 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 835 of file deform.c.

References MDeformVert::dw, MEM_SAFE_FREE, 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,
int  defgroup_dst,
const struct MDeformVert dvert_src,
int  defgroup_src 
)

Copy an index from one MDeformVert to another.

  • do nothing if neither are set.
  • add destination weight if needed.

Referenced by dvert_mirror_op(), and vgroup_copy_active_to_sel_single().

◆ BKE_defvert_copy_subset()

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

Overwrite weights filtered by vgroup_subset.

  • do nothing if neither are set.
  • add destination weight if needed

Referenced by vgroup_copy_active_to_sel().

◆ BKE_defvert_ensure_index()

struct MDeformWeight* BKE_defvert_ensure_index ( struct MDeformVert dv,
int  defgroup 
)

◆ BKE_defvert_extract_vgroup_to_edgeweights()

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

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

Referenced by BKE_object_data_transfer_ex().

◆ BKE_defvert_extract_vgroup_to_loopweights()

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

◆ BKE_defvert_extract_vgroup_to_polyweights()

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

◆ BKE_defvert_extract_vgroup_to_vertweights()

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

◆ BKE_defvert_find_index()

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

◆ BKE_defvert_find_shared()

int BKE_defvert_find_shared ( const struct MDeformVert dvert_a,
const struct MDeformVert dvert_b 
)
Returns
The first group index shared by both deform verts or -1 if none are found.

◆ BKE_defvert_find_weight()

float BKE_defvert_find_weight ( const struct MDeformVert dvert,
int  defgroup 
)

◆ BKE_defvert_flip()

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

◆ BKE_defvert_flip_merged()

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

◆ BKE_defvert_is_weight_zero()

bool BKE_defvert_is_weight_zero ( const struct MDeformVert dvert,
int  defgroup_tot 
)
Returns
true if has no weights.

Definition at line 858 of file deform.c.

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

Referenced by blender::draw::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 939 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(), blender::draw::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,
int  vgroup_tot,
const int *  flip_map,
int  flip_map_len 
)

Overwrite weights filtered by vgroup_subset and with mirroring specified by the flip map

  • do nothing if neither are set.
  • add destination weight if needed

Referenced by ED_vgroup_parray_mirror_sync().

◆ 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 multi-paint 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 894 of file deform.c.

References BKE_defvert_total_selected_weight().

Referenced by do_weight_paint_vertex_multi(), blender::draw::evaluate_vertex_weight(), weight_sample_invoke(), and wpaint_get_active_weight().

◆ BKE_defvert_normalize()

void BKE_defvert_normalize ( struct MDeformVert dvert)

Definition at line 264 of file deform.c.

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

◆ BKE_defvert_normalize_lock_map()

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

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

Definition at line 347 of file deform.c.

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

Referenced by paint_weight_gradient_exec(), and vgroup_normalize_all().

◆ BKE_defvert_normalize_lock_single()

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

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

Definition at line 293 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 ( struct MDeformVert dvert,
const bool vgroup_subset,
int  vgroup_tot 
)

◆ BKE_defvert_remap()

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

be sure all flip_map values are valid

Definition at line 215 of file deform.c.

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

Referenced by vgroup_do_remap().

◆ BKE_defvert_remove_group()

void BKE_defvert_remove_group ( struct MDeformVert dvert,
struct MDeformWeight dw 
)

◆ BKE_defvert_sync()

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

Only sync over matching weights, don't add or remove groups warning, loop within loop.

◆ BKE_defvert_sync_mapped()

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

be sure all flip_map values are valid

Referenced by mesh_defvert_mirror_update_internal().

◆ 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],
float  weight 
)

Definition at line 1518 of file deform.c.

References blend().

Referenced by psys_cache_edit_paths_iter().

◆ BKE_id_defgroup_list_get()

const struct ListBase* BKE_id_defgroup_list_get ( const struct ID id)

◆ BKE_id_defgroup_list_get_mutable()

struct ListBase* BKE_id_defgroup_list_get_mutable ( struct ID id)

Definition at line 493 of file deform.c.

References BKE_id_defgroup_list_get().

Referenced by BKE_object_defgroup_list_mutable().

◆ BKE_id_defgroup_name_find()

bool BKE_id_defgroup_name_find ( const struct ID id,
const char *  name,
int *  r_index,
struct bDeformGroup **  r_group 
)

◆ BKE_id_defgroup_name_index()

int BKE_id_defgroup_name_index ( const struct ID id,
const char *  name 
)

◆ BKE_object_defgroup_active_index_get()

int BKE_object_defgroup_active_index_get ( const struct Object ob)

◆ BKE_object_defgroup_active_index_set()

void BKE_object_defgroup_active_index_set ( struct Object ob,
int  new_index 
)

◆ BKE_object_defgroup_count()

int BKE_object_defgroup_count ( const struct Object ob)

◆ 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,
bool  use_default 
)

◆ BKE_object_defgroup_flip_map()

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

◆ BKE_object_defgroup_flip_map_single()

int* BKE_object_defgroup_flip_map_single ( const struct Object ob,
int *  flip_map_len,
bool  use_default,
int  defgroup 
)
Note
caller must free.

Referenced by ED_vgroup_mirror().

◆ BKE_object_defgroup_list()

const struct ListBase* BKE_object_defgroup_list ( const struct Object ob)

◆ BKE_object_defgroup_list_mutable()

struct ListBase* BKE_object_defgroup_list_mutable ( struct Object ob)

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

◆ BKE_object_supports_vertex_groups()

bool BKE_object_supports_vertex_groups ( const struct Object ob)