Blender
V3.3
|
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_string.h"
#include "BLT_translation.h"
#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.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_deform.h"
#include "BKE_modifier.h"
#include "BKE_texture.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "MEM_guardedalloc.h"
#include "MOD_ui_common.h"
#include "MOD_util.h"
#include "MOD_weightvg_util.h"
#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 *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) |
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().
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().
void weightvg_ui_common | ( | const bContext * | C, |
PointerRNA * | ob_ptr, | ||
PointerRNA * | ptr, | ||
uiLayout * | layout | ||
) |
Common vertex weight mask interface elements for the modifier panels.
Definition at line 309 of file MOD_weightvg_util.c.
References C, IFACE_, MOD_DISP_MAP_OBJECT, MOD_DISP_MAP_UV, modifier_vgroup_ui(), NULL, OB_MESH, ptr, RNA_enum_get(), RNA_pointer_get(), RNA_pointer_is_null(), RNA_string_length(), UI_ITEM_R_SLIDER, uiItemPointerR(), uiItemR(), uiLayoutSetPropSep(), and uiTemplateID().
Referenced by influence_panel_draw().
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().