67 int num,
float *new_w,
short falloff_type,
const bool do_invert,
CurveMapping *cmap,
RNG *rng)
90 for (i = 0; i < num; i++) {
95 switch (falloff_type) {
103 fac = 3.0f * fac * fac - 2.0f * fac * fac * fac;
109 fac =
sqrtf(2 * fac - fac * fac);
115 fac = (fac >= 0.5f) ? 1.0f : 0.0f;
124 new_w[i] = do_invert ? 1.0f - fac : fac;
146 const int tex_use_channel,
147 const int tex_mapping,
149 const char *text_map_bone,
150 const char *tex_uvlayer_name,
151 const bool invert_vgroup_mask)
180 tex_co =
MEM_calloc_arrayN(numVerts,
sizeof(*tex_co),
"WeightVG Modifier, TEX mode, tex_co");
186 for (i = 0; i < num; i++) {
190 bool do_color_manage;
197 switch (tex_use_channel) {
199 org_w[i] = (new_w[i] * texres.
tin * fact) + (org_w[i] * (1.0f - (texres.
tin * fact)));
202 org_w[i] = (new_w[i] * texres.
tr * fact) + (org_w[i] * (1.0f - (texres.
tr * fact)));
205 org_w[i] = (new_w[i] * texres.
tg * fact) + (org_w[i] * (1.0f - (texres.
tg * fact)));
208 org_w[i] = (new_w[i] * texres.
tb * fact) + (org_w[i] * (1.0f - (texres.
tb * fact)));
212 org_w[i] = (new_w[i] * hsv[0] * fact) + (org_w[i] * (1.0f - (hsv[0] * fact)));
216 org_w[i] = (new_w[i] * hsv[1] * fact) + (org_w[i] * (1.0f - (hsv[1] * fact)));
220 org_w[i] = (new_w[i] * hsv[2] * fact) + (org_w[i] * (1.0f - (hsv[2] * fact)));
223 org_w[i] = (new_w[i] * texres.
ta * fact) + (org_w[i] * (1.0f - (texres.
ta * fact)));
226 org_w[i] = (new_w[i] * texres.
tin * fact) + (org_w[i] * (1.0f - (texres.
tin * fact)));
250 for (i = 0; i < num; i++) {
252 const float f = (invert_vgroup_mask ?
256 org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f));
263 const float ifact = 1.0f - fact;
264 for (i = 0; i < num; i++) {
265 org_w[i] = (new_w[i] * fact) + (org_w[i] * ifact);
281 const float *weights,
283 const float add_thresh,
285 const float rem_thresh,
286 const bool do_normalize)
290 float min_w = weights[0];
291 float norm_fac = 1.0f;
293 float max_w = weights[0];
294 for (i = 1; i < num; i++) {
295 const float w = weights[i];
301 else if (
w > max_w) {
306 const float range = max_w - min_w;
307 if (
fabsf(range) > FLT_EPSILON) {
308 norm_fac = 1.0f / range;
315 for (i = 0; i < num; i++) {
316 float w = weights[i];
322 w = (
w - min_w) * norm_fac;
329 if (do_rem &&
w < rem_thresh) {
337 else if (do_add &&
w > add_thresh) {
356 if (!has_mask_texture) {
360 if (!has_mask_vertex_group) {
372 if (has_mask_texture) {
373 uiItemR(layout,
ptr,
"mask_tex_use_channel", 0,
IFACE_(
"Channel"), ICON_NONE);
377 uiItemR(layout,
ptr,
"mask_tex_map_object", 0,
IFACE_(
"Object"), ICON_NONE);
382 layout,
ptr,
"mask_tex_uv_layer", &obj_data_ptr,
"uv_layers",
NULL, ICON_NONE);
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_get_layer(const struct CustomData *data, int type)
void BKE_texture_get_value(const struct Scene *scene, struct Tex *texture, const float *tex_co, struct TexResult *texres, bool use_color_management)
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
@ 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 char *vgroup_prop, const char *invert_vgroup_prop, const char *text)
void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx)
void MOD_get_texture_coords(MappingInfoModifierData *dmd, const ModifierEvalContext *UNUSED(ctx), 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_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_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, uiLayout *layout)
Group RGB to Bright Vector Camera CLAMP
void uiTemplateID(uiLayout *layout, const struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter, const bool live_icon, const char *text)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
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