Blender  V3.3
Macros | Functions
MOD_weightvg_util.h File Reference

Go to the source code of this file.

Macros

#define MOD_WVG_ZEROFLOOR   1.0e-32f
 

Functions

void weightvg_do_map (int num, float *new_w, short falloff_type, bool do_invert, struct CurveMapping *cmap, struct RNG *rng)
 
void weightvg_do_mask (const ModifierEvalContext *ctx, int num, const int *indices, float *org_w, const float *new_w, Object *ob, struct Mesh *mesh, float fact, const char defgrp_name[MAX_VGROUP_NAME], struct Scene *scene, Tex *texture, int tex_use_channel, int tex_mapping, Object *tex_map_object, const char *text_map_bone, const char *tex_uvlayer_name, bool invert_vgroup_mask)
 
void weightvg_update_vg (struct MDeformVert *dvert, int defgrp_idx, struct MDeformWeight **dws, int num, const int *indices, const float *weights, bool do_add, float add_thresh, bool do_rem, float rem_thresh, bool do_normalize)
 
void weightvg_ui_common (const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, uiLayout *layout)
 

Macro Definition Documentation

◆ MOD_WVG_ZEROFLOOR

#define MOD_WVG_ZEROFLOOR   1.0e-32f

We cannot divide by zero (what a surprise...). So if -MOD_WEIGHTVGROUP_DIVMODE_ZEROFLOOR < weightf < MOD_WEIGHTVGROUP_DIVMODE_ZEROFLOOR, we clamp weightf to this value (or its negative version). Also used to avoid null power factor.

Definition at line 39 of file MOD_weightvg_util.h.

Function Documentation

◆ weightvg_do_map()

void weightvg_do_map ( int  num,
float new_w,
short  falloff_type,
bool  do_invert,
struct CurveMapping cmap,
struct RNG rng 
)

Maps new_w weights in place, using either one of the predefined functions, or a custom curve. Return values are in new_w. If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real vertex index (in case the weight tables do not cover the whole vertices...). cmap might be NULL, in which case curve mapping mode will return unmodified data.

Definition at line 44 of file MOD_weightvg_util.c.

References BKE_curvemapping_evaluateF(), BKE_curvemapping_init(), BLI_assert, BLI_assert_unreachable, BLI_rng_get_float(), ELEM, MOD_WVG_MAPPING_CURVE, MOD_WVG_MAPPING_NONE, MOD_WVG_MAPPING_RANDOM, MOD_WVG_MAPPING_ROOT, MOD_WVG_MAPPING_SHARP, MOD_WVG_MAPPING_SMOOTH, MOD_WVG_MAPPING_SPHERE, MOD_WVG_MAPPING_STEP, NULL, and sqrtf.

Referenced by do_map(), and modifyMesh().

◆ weightvg_do_mask()

void weightvg_do_mask ( const ModifierEvalContext ctx,
int  num,
const int *  indices,
float org_w,
const float new_w,
Object ob,
struct Mesh mesh,
float  fact,
const char  defgrp_name[MAX_VGROUP_NAME],
struct Scene scene,
Tex texture,
int  tex_use_channel,
int  tex_mapping,
Object tex_map_object,
const char *  text_map_bone,
const char *  tex_uvlayer_name,
bool  invert_vgroup_mask 
)

Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor. Return values are in org_w. If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real vertex index (in case the weight tables do not cover the whole vertices...). XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear.

Definition at line 106 of file MOD_weightvg_util.c.

References BKE_defvert_find_weight(), BKE_id_defgroup_name_index(), BKE_texture_get_value(), BLI_strncpy(), CD_MDEFORMVERT, CustomData_get_layer(), float(), Mesh::id, indices, MappingInfoModifierData::map_bone, MappingInfoModifierData::map_object, MEM_calloc_arrayN, MEM_freeN, mesh, MOD_get_texture_coords(), MOD_init_texture(), MOD_WVG_MASK_TEX_USE_ALPHA, MOD_WVG_MASK_TEX_USE_BLUE, MOD_WVG_MASK_TEX_USE_GREEN, MOD_WVG_MASK_TEX_USE_HUE, MOD_WVG_MASK_TEX_USE_INT, MOD_WVG_MASK_TEX_USE_RED, MOD_WVG_MASK_TEX_USE_SAT, MOD_WVG_MASK_TEX_USE_VAL, NULL, rgb_to_hsv_v(), scene, MappingInfoModifierData::texmapping, MappingInfoModifierData::texture, TexResult::tin, Mesh::totvert, TexResult::trgba, MappingInfoModifierData::uvlayer_name, and Mesh::vdata.

Referenced by modifyMesh().

◆ weightvg_ui_common()

void weightvg_ui_common ( const bContext C,
PointerRNA ob_ptr,
PointerRNA ptr,
uiLayout layout 
)

◆ weightvg_update_vg()

void weightvg_update_vg ( struct MDeformVert dvert,
int  defgrp_idx,
struct MDeformWeight **  dws,
int  num,
const int *  indices,
const float weights,
bool  do_add,
float  add_thresh,
bool  do_rem,
float  rem_thresh,
bool  do_normalize 
)

Applies weights to given vgroup (defgroup), and optionally add/remove vertices from the group. If dws is not NULL, it must be an array of MDeformWeight pointers of same length as weights (and defgrp_idx can then have any value). If indices is not NULL, it must be an array of same length as weights, mapping to the real vertex index (in case the weight array does not cover the whole vertices...).

Definition at line 242 of file MOD_weightvg_util.c.

References BKE_defvert_add_index_notest(), BKE_defvert_find_index(), BKE_defvert_remove_group(), CLAMP, fabsf, indices, NULL, w(), and MDeformWeight::weight.

Referenced by modifyMesh().