Blender V4.3
MOD_weightvg_util.cc File Reference
#include "BLI_utildefines.h"
#include "BLI_math_color.h"
#include "BLI_rand.h"
#include "BLI_string.h"
#include "BLT_translation.hh"
#include "DNA_color_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_colortools.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_modifier.hh"
#include "BKE_scene.hh"
#include "BKE_texture.h"
#include "UI_interface.hh"
#include "UI_resources.hh"
#include "RNA_access.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "MEM_guardedalloc.h"
#include "MOD_ui_common.hh"
#include "MOD_util.hh"
#include "MOD_weightvg_util.hh"
#include "RE_texture.h"

Go to the source code of this file.

Functions

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

Function Documentation

◆ weightvg_do_map()

void weightvg_do_map ( int num,
float * new_w,
short falloff_type,
bool do_invert,
CurveMapping * cmap,
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 46 of file MOD_weightvg_util.cc.

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, and sqrtf.

Referenced by do_map(), and modify_mesh().

◆ weightvg_do_mask()

void weightvg_do_mask ( const ModifierEvalContext * ctx,
int num,
const int * indices,
float * org_w,
const float * new_w,
Object * ob,
Mesh * mesh,
float fact,
const char defgrp_name[MAX_VGROUP_NAME],
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 109 of file MOD_weightvg_util.cc.

References BKE_defvert_find_weight(), BKE_id_defgroup_name_index(), BKE_texture_get_value(), CD_MDEFORMVERT, CustomData_get_layer(), float, MappingInfoModifierData::map_bone, MappingInfoModifierData::map_object, MEM_calloc_arrayN, MEM_freeN(), 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, rgb_to_hsv_v(), STRNCPY, MappingInfoModifierData::texmapping, MappingInfoModifierData::texture, texture, TexResult::tin, TexResult::trgba, and MappingInfoModifierData::uvlayer_name.

Referenced by modify_mesh(), modify_mesh(), and modify_mesh().

◆ weightvg_ui_common()

◆ weightvg_update_vg()

void weightvg_update_vg ( MDeformVert * dvert,
int defgrp_idx,
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 244 of file MOD_weightvg_util.cc.

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

Referenced by modify_mesh(), modify_mesh(), and modify_mesh().