45 int num,
float *new_w,
short falloff_type,
const bool do_invert,
CurveMapping *cmap,
RNG *rng)
68 for (i = 0; i < num; i++) {
73 switch (falloff_type) {
81 fac = 3.0f * fac * fac - 2.0f * fac * fac * fac;
87 fac =
sqrtf(2 * fac - fac * fac);
93 fac = (fac >= 0.5f) ? 1.0f : 0.0f;
102 new_w[i] = do_invert ? 1.0f - fac : fac;
117 const int tex_use_channel,
118 const int tex_mapping,
120 const char *text_map_bone,
121 const char *tex_uvlayer_name,
122 const bool invert_vgroup_mask)
133 if (texture !=
NULL) {
151 tex_co =
MEM_calloc_arrayN(verts_num,
sizeof(*tex_co),
"WeightVG Modifier, TEX mode, tex_co");
157 for (i = 0; i < num; i++) {
161 bool do_color_manage;
167 switch (tex_use_channel) {
169 org_w[i] = (new_w[i] * texres.
tin * fact) + (org_w[i] * (1.0f - (texres.
tin * fact)));
172 org_w[i] = (new_w[i] * texres.
trgba[0] * fact) +
173 (org_w[i] * (1.0f - (texres.
trgba[0] * fact)));
176 org_w[i] = (new_w[i] * texres.
trgba[1] * fact) +
177 (org_w[i] * (1.0f - (texres.
trgba[1] * fact)));
180 org_w[i] = (new_w[i] * texres.
trgba[2] * fact) +
181 (org_w[i] * (1.0f - (texres.
trgba[2] * fact)));
185 org_w[i] = (new_w[i] * hsv[0] * fact) + (org_w[i] * (1.0f - (hsv[0] * fact)));
189 org_w[i] = (new_w[i] * hsv[1] * fact) + (org_w[i] * (1.0f - (hsv[1] * fact)));
193 org_w[i] = (new_w[i] * hsv[2] * fact) + (org_w[i] * (1.0f - (hsv[2] * fact)));
196 org_w[i] = (new_w[i] * texres.
trgba[3] * fact) +
197 (org_w[i] * (1.0f - (texres.
trgba[3] * fact)));
200 org_w[i] = (new_w[i] * texres.
tin * fact) + (org_w[i] * (1.0f - (texres.
tin * fact)));
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];
288 w = (
w - min_w) * norm_fac;
295 if (do_rem &&
w < rem_thresh) {
303 else if (do_add &&
w > add_thresh) {
320 if (!has_mask_texture) {
324 if (!has_mask_vertex_group) {
336 if (has_mask_texture) {
337 uiItemR(layout,
ptr,
"mask_tex_use_channel", 0,
IFACE_(
"Channel"), ICON_NONE);
341 uiItemR(layout,
ptr,
"mask_tex_map_object", 0,
IFACE_(
"Object"), ICON_NONE);
346 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)
#define BLI_assert_unreachable()
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, 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 Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
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 uiTemplateID(uiLayout *layout, const struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter, bool live_icon, const char *text)
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.
ccl_gpu_kernel_postfix int ccl_global int * indices
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