45 int num,
float *new_w,
short falloff_type,
const bool do_invert,
CurveMapping *cmap,
RNG *rng)
69 for (
i = 0;
i <
num;
i++) {
74 switch (falloff_type) {
82 fac = 3.0f * fac * fac - 2.0f * fac * fac * fac;
88 fac =
sqrtf(2 * fac - fac * fac);
94 fac = (fac >= 0.5f) ? 1.0f : 0.0f;
103 new_w[
i] = do_invert ? 1.0f - fac : fac;
118 const int tex_use_channel,
119 const int tex_mapping,
121 const char *text_map_bone,
122 const char *tex_uvlayer_name,
123 const bool invert_vgroup_mask)
158 for (
i = 0;
i <
num;
i++) {
166 switch (tex_use_channel) {
168 org_w[
i] = (new_w[
i] * texres.
tin * fact) + (org_w[
i] * (1.0f - (texres.
tin * fact)));
171 org_w[
i] = (new_w[
i] * texres.
trgba[0] * fact) +
172 (org_w[
i] * (1.0f - (texres.
trgba[0] * fact)));
175 org_w[
i] = (new_w[
i] * texres.
trgba[1] * fact) +
176 (org_w[
i] * (1.0f - (texres.
trgba[1] * fact)));
179 org_w[
i] = (new_w[
i] * texres.
trgba[2] * fact) +
180 (org_w[
i] * (1.0f - (texres.
trgba[2] * fact)));
184 org_w[
i] = (new_w[
i] * hsv[0] * fact) + (org_w[
i] * (1.0f - (hsv[0] * fact)));
188 org_w[
i] = (new_w[
i] * hsv[1] * fact) + (org_w[
i] * (1.0f - (hsv[1] * fact)));
192 org_w[
i] = (new_w[
i] * hsv[2] * fact) + (org_w[
i] * (1.0f - (hsv[2] * fact)));
195 org_w[
i] = (new_w[
i] * texres.
trgba[3] * fact) +
196 (org_w[
i] * (1.0f - (texres.
trgba[3] * fact)));
199 org_w[
i] = (new_w[
i] * texres.
tin * fact) + (org_w[
i] * (1.0f - (texres.
tin * fact)));
217 if (dvert ==
nullptr) {
222 for (
i = 0;
i <
num;
i++) {
224 const float f = (invert_vgroup_mask ?
228 org_w[
i] = (new_w[
i] * f) + (org_w[
i] * (1.0f - f));
235 const float ifact = 1.0f - fact;
236 for (
i = 0;
i <
num;
i++) {
237 org_w[
i] = (new_w[
i] * fact) + (org_w[
i] * ifact);
247 const float *weights,
249 const float add_thresh,
251 const float rem_thresh,
252 const bool do_normalize)
256 float min_w = weights[0];
257 float norm_fac = 1.0f;
259 float max_w = weights[0];
260 for (
i = 1;
i <
num;
i++) {
261 const float w = weights[
i];
267 else if (
w > max_w) {
272 const float range = max_w - min_w;
273 if (
fabsf(range) > FLT_EPSILON) {
274 norm_fac = 1.0f / range;
281 for (
i = 0;
i <
num;
i++) {
282 float w = weights[
i];
289 w = (
w - min_w) * norm_fac;
296 if (do_rem &&
w <= rem_thresh) {
304 else if (do_add &&
w >= add_thresh) {
321 if (!has_mask_texture) {
323 layout,
ptr, ob_ptr,
"mask_vertex_group",
"invert_mask_vertex_group", std::nullopt);
326 if (!has_mask_vertex_group) {
338 if (has_mask_texture) {
348 layout,
ptr,
"mask_tex_uv_layer", &obj_data_ptr,
"uv_layers", std::nullopt, ICON_NONE);
CustomData interface, see also DNA_customdata_types.h.
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void BKE_texture_get_value(struct Tex *texture, const float *tex_co, struct TexResult *texres, bool use_color_management)
#define BLI_assert_unreachable()
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
ATTR_WARN_UNUSED_RESULT const size_t num
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * STRNCPY(char(&dst)[N], const char *src)
@ MOD_WVG_MASK_TEX_USE_SAT
@ MOD_WVG_MASK_TEX_USE_BLUE
@ MOD_WVG_MASK_TEX_USE_INT
@ MOD_WVG_MASK_TEX_USE_ALPHA
@ MOD_WVG_MASK_TEX_USE_RED
@ MOD_WVG_MASK_TEX_USE_HUE
@ MOD_WVG_MASK_TEX_USE_VAL
@ MOD_WVG_MASK_TEX_USE_GREEN
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
void modifier_vgroup_ui(uiLayout *layout, PointerRNA *ptr, PointerRNA *ob_ptr, const StringRefNull vgroup_prop, const std::optional< StringRefNull > invert_vgroup_prop, const std::optional< StringRefNull > text)
void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx)
void MOD_get_texture_coords(MappingInfoModifierData *dmd, const ModifierEvalContext *, Object *ob, Mesh *mesh, float(*cos)[3], float(*r_texco)[3])
void weightvg_do_map(int num, float *new_w, short falloff_type, const bool do_invert, CurveMapping *cmap, RNG *rng)
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_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)
@ UI_TEMPLATE_ID_FILTER_ALL
void uiTemplateID(uiLayout *layout, const bContext *C, PointerRNA *ptr, blender::StringRefNull propname, const char *newop, const char *openop, const char *unlinkop, int filter=UI_TEMPLATE_ID_FILTER_ALL, bool live_icon=false, std::optional< blender::StringRef > text=std::nullopt)
void uiItemPointerR(uiLayout *layout, PointerRNA *ptr, blender::StringRefNull propname, PointerRNA *searchptr, blender::StringRefNull searchpropname, std::optional< blender::StringRefNull > name, int icon)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
int RNA_string_length(PointerRNA *ptr, const char *name)
bool RNA_pointer_is_null(const PointerRNA *ptr)
int RNA_enum_get(PointerRNA *ptr, const char *name)
struct Object * map_object
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)