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)
136 if (texture !=
nullptr) {
141 const int verts_num = mesh->verts_num;
154 tex_co =
static_cast<float(*)[3]
>(
MEM_calloc_arrayN(verts_num,
sizeof(*tex_co), __func__));
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)));
219 if (dvert ==
nullptr) {
224 for (i = 0; i < num; i++) {
225 int idx = indices ? indices[i] : i;
226 const float f = (invert_vgroup_mask ?
230 org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f));
237 const float ifact = 1.0f - fact;
238 for (i = 0; i < num; i++) {
239 org_w[i] = (new_w[i] * fact) + (org_w[i] * ifact);
249 const float *weights,
251 const float add_thresh,
253 const float rem_thresh,
254 const bool do_normalize)
258 float min_w = weights[0];
259 float norm_fac = 1.0f;
261 float max_w = weights[0];
262 for (i = 1; i < num; i++) {
263 const float w = weights[i];
269 else if (
w > max_w) {
274 const float range = max_w - min_w;
275 if (
fabsf(range) > FLT_EPSILON) {
276 norm_fac = 1.0f /
range;
283 for (i = 0; i < num; i++) {
284 float w = weights[i];
285 MDeformVert *dv = &dvert[indices ? indices[i] : i];
291 w = (
w - min_w) * norm_fac;
298 if (do_rem &&
w <= rem_thresh) {
306 else if (do_add &&
w >= add_thresh) {
323 if (!has_mask_texture) {
325 layout,
ptr, ob_ptr,
"mask_vertex_group",
"invert_mask_vertex_group",
nullptr);
328 if (!has_mask_vertex_group) {
340 if (has_mask_texture) {
350 layout,
ptr,
"mask_tex_uv_layer", &obj_data_ptr,
"uv_layers",
nullptr, 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])
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define STRNCPY(dst, 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 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 *, 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)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemPointerR(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
void uiTemplateID(uiLayout *layout, const bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter=UI_TEMPLATE_ID_FILTER_ALL, bool live_icon=false, const char *text=nullptr)
@ UI_TEMPLATE_ID_FILTER_ALL
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
local_group_size(16, 16) .push_constant(Type texture
draw_view in_light_buf[] float
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