85 if (dverts && dcount) {
136 {
ARM_GROUPS_AUTO,
"AUTOMATIC", 0,
"Automatic",
"Automatic weights from bones"},
141 "Weights from envelopes with user defined radius"},
146 ot->
name =
"Weight from Bones";
147 ot->
idname =
"PAINT_OT_weight_from_bones";
149 (
"Set the weights of the groups matching the attached armature's selected bones, "
150 "using the distance between the vertices and the bones");
162 ot->
srna,
"type", type_items, 0,
"Type",
"Method to use for assigning weights");
181 bool changed =
false;
213 if (v_idx_best != -1) {
220 bool *defbase_locked =
NULL, *defbase_unlocked =
NULL;
222 if (use_lock_relative) {
227 defbase_locked, defbase_unlocked, vgroup_active);
235 vc.
obact, defbase_tot, &defbase_tot_sel);
237 if (defbase_tot_sel > 1) {
240 vc.
obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
243 use_lock_relative = use_lock_relative &&
245 defbase_tot, defbase_locked, defbase_sel, defbase_tot_sel);
249 &me->
dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, is_normalized);
255 if (use_lock_relative) {
257 defbase_tot, defbase_locked, defbase_unlocked, defbase_locked, defbase_unlocked);
260 vgroup_weight, &me->
dvert[v_idx_best], defbase_tot, defbase_locked, defbase_unlocked);
266 CLAMP(vgroup_weight, 0.0f, 1.0f);
284 ot->
name =
"Weight Paint Sample Weight";
285 ot->
idname =
"PAINT_OT_weight_sample";
286 ot->
description =
"Use the mouse to sample a weight in the 3D view";
304 const int defbase_tot,
311 for (
dw = dvert->
dw; i > 0;
dw++, i--) {
337 int *groups =
MEM_callocN(defbase_tot *
sizeof(
int),
"groups");
341 const int mval[2] = {
367 if (found ==
false) {
377 item_tmp.identifier = item_tmp.
name = dg->
name;
418 ot->
name =
"Weight Paint Sample Group";
419 ot->
idname =
"PAINT_OT_weight_sample_group";
420 ot->
description =
"Select one of the vertex groups available under current mouse position";
450 int vgroup_active, vgroup_mirror = -1;
461 vgroup_active = ob->
actdef - 1;
471 for (index = 0, mp = me->
mpoly; index < me->totpoly; index++, mp++) {
497 if (vgroup_mirror != -1) {
518 for (index = me->
totvert; index != 0; index--, dv++) {
554 ot->
description =
"Fill the active vertex group with the current paint weight";
642 CLAMP(testw, 0.0f, 1.0f);
644 vs->
flag |= VGRAD_STORE_IS_MODIFIED;
648 if (vs->
flag & VGRAD_STORE_DW_EXIST) {
660 vs->
flag &= ~VGRAD_STORE_IS_MODIFIED;
666 const float UNUSED(co[3]),
667 const float UNUSED(no_f[3]),
668 const short UNUSED(no_s[3]))
673 if (vs->
sco[0] == FLT_MAX) {
683 const float UNUSED(no_f[3]),
684 const short UNUSED(no_s[3]))
715 vs->
flag = VGRAD_STORE_DW_EXIST;
719 vs->
flag = VGRAD_STORE_NOP;
742 if (vert_cache !=
NULL) {
775 const float sco_start[2] = {x_start, y_start};
776 const float sco_end[2] = {x_end, y_end};
777 const bool is_interactive = (gesture !=
NULL);
783 if (is_interactive) {
812 data.region = region;
815 data.sco_start = sco_start;
816 data.sco_end = sco_end;
817 data.sco_line_div = 1.0f /
len_v2v2(sco_start, sco_end);
820 data.vert_cache = vert_cache;
861 if (is_interactive ==
false) {
868 if (vgroup_validmap !=
NULL) {
870 for (
int i = 0; i < me->
totvert; i++) {
871 if ((
data.vert_cache->elem[i].flag & VGRAD_STORE_IS_MODIFIED) != 0) {
916 ot->
name =
"Weight Gradient";
917 ot->
idname =
"PAINT_OT_weight_gradient";
918 ot->
description =
"Draw a line to apply a weight gradient to selected vertices";
float BKE_brush_weight_get(const struct Scene *scene, const struct Brush *brush)
void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, float value)
float BKE_brush_curve_strength_clamped(struct Brush *br, float p, const float len)
struct Scene * CTX_data_scene(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
struct Mesh * BKE_mesh_from_object(struct Object *ob)
void BKE_mesh_flush_select_from_polys(struct Mesh *me)
void BKE_mesh_foreach_mapped_vert(struct Mesh *mesh, void(*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), void *userData, MeshForeachFlag flag)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Object * BKE_modifiers_is_deformed_by_armature(struct Object *ob)
struct Brush * BKE_paint_brush(struct Paint *paint)
void BKE_report(ReportList *reports, ReportType type, const char *message)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW(_tot, _alloc_string)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2])
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_fl(float r[2], float f)
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
#define CD_MASK_ORIGINDEX
#define ME_USING_MIRROR_X_VERTEX_GROUPS(_me)
#define ME_EDIT_PAINT_SEL_MODE(_me)
Object is a sort of wrapper for general info.
@ VP_FLAG_VGROUP_RESTRICT
#define SCE_SELECT_VERTEX
#define ARM_GROUPS_ENVELOPE
bool ED_mesh_pick_face_vert(struct bContext *C, struct Object *ob, const int mval[2], uint dist_px, uint *r_index)
#define ED_MESH_PICK_DEFAULT_VERT_DIST
int mesh_get_x_mirror_vert(struct Object *ob, struct Mesh *me_eval, int index, const bool use_topology)
bool ED_mesh_pick_face(struct bContext *C, struct Object *ob, const int mval[2], uint dist_px, uint *r_index)
#define ED_MESH_PICK_DEFAULT_FACE_DIST
bool ED_mesh_pick_vert(struct bContext *C, struct Object *ob, const int mval[2], uint dist_px, bool use_zbuf, uint *r_index)
void ED_region_tag_redraw(struct ARegion *region)
void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d)
@ V3D_PROJ_TEST_CLIP_NEAR
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *region, const float co[3], float r_co[2], const eV3DProjTest flag)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
void view3d_operator_needs_opengl(const struct bContext *C)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
void ED_object_vgroup_calc_from_armature(ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par, const int mode, const bool mirror)
const Depsgraph * depsgraph
static CCL_NAMESPACE_BEGIN const double alpha
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
bool mask_paint_poll(bContext *C)
@ WPAINT_GRADIENT_TYPE_RADIAL
@ WPAINT_GRADIENT_TYPE_LINEAR
bool ED_wpaint_ensure_data(struct bContext *C, struct ReportList *reports, enum eWPaintFlag flag, struct WPaintVGroupIndex *vgroup_index)
int ED_wpaint_mirror_vgroup_ensure(struct Object *ob, const int vgroup_active)
float ED_wpaint_blend_tool(const int tool, const float weight, const float paintval, const float alpha)
bool weight_paint_mode_poll(struct bContext *C)
bool weight_paint_poll_ignore_tool(bContext *C)
void PAINT_OT_weight_set(wmOperatorType *ot)
static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
static bool weight_paint_set(Object *ob, float paintweight)
static void wpaint_prev_create(struct WPaintPrev *wpp, MDeformVert *dverts, int dcount)
struct WPGradient_userData WPGradient_userData
struct WPGradient_vertStore WPGradient_vertStore
struct WPGradient_vertStoreBase WPGradient_vertStoreBase
static void gradientVertInit__mapFunc(void *userData, int index, const float co[3], const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
static int weight_from_bones_exec(bContext *C, wmOperator *op)
static int weight_paint_set_exec(bContext *C, wmOperator *op)
static bool weight_paint_sample_enum_itemf__helper(const MDeformVert *dvert, const int defbase_tot, int *groups)
static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_weight_sample(wmOperatorType *ot)
static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void gradientVert_update(WPGradient_userData *grad_data, int index)
static void wpaint_prev_destroy(struct WPaintPrev *wpp)
static bool weight_from_bones_poll(bContext *C)
static void wpaint_prev_init(struct WPaintPrev *wpp)
static void gradientVertUpdate__mapFunc(void *userData, int index, const float UNUSED(co[3]), const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
void PAINT_OT_weight_from_bones(wmOperatorType *ot)
void PAINT_OT_weight_gradient(wmOperatorType *ot)
void PAINT_OT_weight_sample_group(wmOperatorType *ot)
static const EnumPropertyItem * weight_paint_sample_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int weight_sample_group_exec(bContext *C, wmOperator *op)
int RNA_int_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
const EnumPropertyItem DummyRNA_DEFAULT_items[]
const EnumPropertyItem DummyRNA_NULL_items[]
struct CurveMapping * curve
struct MDeformVert * dvert
struct CustomData_MeshMasks customdata_mask
struct ToolSettings * toolsettings
struct RegionView3D * rv3d
WPGradient_vertStoreBase * vert_cache
WPGradient_vertStore elem[0]
enum WPGradient_vertStore::@486 flag
@ VGRAD_STORE_IS_MODIFIED
struct MDeformVert * wpaint_prev
wmGenericUserData user_data
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmEvent * eventstate
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))