47 int num,
float *new_w,
short falloff_type,
const bool do_invert,
CurveMapping *cmap,
RNG *rng)
71 for (i = 0; i <
num; i++) {
76 switch (falloff_type) {
84 fac = 3.0f * fac * fac - 2.0f * fac * fac * fac;
90 fac =
sqrtf(2 * fac - fac * fac);
96 fac = (fac >= 0.5f) ? 1.0f : 0.0f;
105 new_w[i] = do_invert ? 1.0f - fac : fac;
120 const int tex_use_channel,
121 const int tex_mapping,
123 const char *text_map_bone,
124 const char *tex_uvlayer_name,
125 const bool invert_vgroup_mask)
141 const int verts_num =
mesh->verts_num;
160 for (i = 0; i <
num; i++) {
161 int idx = indices ? indices[i] : i;
168 switch (tex_use_channel) {
170 org_w[i] = (new_w[i] * texres.
tin * fact) + (org_w[i] * (1.0f - (texres.
tin * fact)));
173 org_w[i] = (new_w[i] * texres.
trgba[0] * fact) +
174 (org_w[i] * (1.0f - (texres.
trgba[0] * fact)));
177 org_w[i] = (new_w[i] * texres.
trgba[1] * fact) +
178 (org_w[i] * (1.0f - (texres.
trgba[1] * fact)));
181 org_w[i] = (new_w[i] * texres.
trgba[2] * fact) +
182 (org_w[i] * (1.0f - (texres.
trgba[2] * fact)));
186 org_w[i] = (new_w[i] * hsv[0] * fact) + (org_w[i] * (1.0f - (hsv[0] * fact)));
190 org_w[i] = (new_w[i] * hsv[1] * fact) + (org_w[i] * (1.0f - (hsv[1] * fact)));
194 org_w[i] = (new_w[i] * hsv[2] * fact) + (org_w[i] * (1.0f - (hsv[2] * fact)));
197 org_w[i] = (new_w[i] * texres.
trgba[3] * fact) +
198 (org_w[i] * (1.0f - (texres.
trgba[3] * fact)));
201 org_w[i] = (new_w[i] * texres.
tin * fact) + (org_w[i] * (1.0f - (texres.
tin * fact)));
218 if (dvert ==
nullptr) {
223 for (i = 0; i <
num; i++) {
224 int idx = indices ? indices[i] : i;
225 const float f = (invert_vgroup_mask ?
229 org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f));
236 const float ifact = 1.0f - fact;
237 for (i = 0; i <
num; i++) {
238 org_w[i] = (new_w[i] * fact) + (org_w[i] * ifact);
248 const float *weights,
250 const float add_thresh,
252 const float rem_thresh,
253 const bool do_normalize)
257 float min_w = weights[0];
258 float norm_fac = 1.0f;
260 float max_w = weights[0];
261 for (i = 1; i <
num; i++) {
262 const float w = weights[i];
268 else if (
w > max_w) {
273 const float range = max_w - min_w;
275 norm_fac = 1.0f / range;
282 for (i = 0; i <
num; i++) {
283 float w = weights[i];
284 MDeformVert *dv = &dvert[indices ? indices[i] : i];
290 w = (
w - min_w) * norm_fac;
297 if (do_rem &&
w <= rem_thresh) {
305 else if (do_add &&
w >= add_thresh) {
314 bool has_mask_texture = mask_texture_ptr;
316 int mask_tex_mapping =
RNA_enum_get(ptr,
"mask_tex_mapping");
322 if (!has_mask_texture) {
324 layout, ptr, ob_ptr,
"mask_vertex_group",
"invert_mask_vertex_group", std::nullopt);
327 if (!has_mask_vertex_group) {
339 if (has_mask_texture) {
341 layout.
prop(ptr,
"mask_tex_mapping",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
349 ptr,
"mask_tex_uv_layer", &obj_data_ptr,
"uv_layers", std::nullopt, ICON_NONE);
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
char * STRNCPY(char(&dst)[N], const char *src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
@ MOD_WVG_MASK_TEX_USE_GREEN
@ MOD_WVG_MASK_TEX_USE_SAT
@ MOD_WVG_MASK_TEX_USE_HUE
@ MOD_WVG_MASK_TEX_USE_INT
@ MOD_WVG_MASK_TEX_USE_RED
@ MOD_WVG_MASK_TEX_USE_VAL
@ MOD_WVG_MASK_TEX_USE_BLUE
@ MOD_WVG_MASK_TEX_USE_ALPHA
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx)
int BKE_id_defgroup_name_index(const ID *id, StringRef name)
void BKE_curvemapping_init(CurveMapping *cumap)
float BKE_defvert_find_weight(const MDeformVert *dvert, int defgroup)
void modifier_vgroup_ui(ui::Layout &layout, PointerRNA *ptr, PointerRNA *ob_ptr, const StringRefNull vgroup_prop, const std::optional< StringRefNull > invert_vgroup_prop, const std::optional< StringRefNull > text)
ATTR_WARN_UNUSED_RESULT const size_t num
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int RNA_string_length(PointerRNA *ptr, const char *name)
void BKE_texture_get_value(struct Tex *texture, const float *tex_co, struct TexResult *texres, bool use_color_management)
void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, ui::Layout &layout)
void BKE_defvert_add_index_notest(MDeformVert *dv, int defgroup, float weight)
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_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 MOD_get_texture_coords(MappingInfoModifierData *dmd, const ModifierEvalContext *, Object *ob, Mesh *mesh, float(*cos)[3], float(*r_texco)[3])
void BKE_defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
void weightvg_do_map(int num, float *new_w, short falloff_type, const bool do_invert, CurveMapping *cmap, RNG *rng)
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
MDeformWeight * BKE_defvert_find_index(const MDeformVert *dv, int defgroup)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct Object * map_object
void prop_search(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchpropname, std::optional< StringRefNull > name, int icon, bool results_are_suggestions)
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)