71 if (dverts && dcount) {
122 {
ARM_GROUPS_AUTO,
"AUTOMATIC", 0,
"Automatic",
"Automatic weights from bones"},
127 "Weights from envelopes with user defined radius"},
132 ot->
name =
"Weight from Bones";
133 ot->
idname =
"PAINT_OT_weight_from_bones";
135 (
"Set the weights of the groups matching the attached armature's selected bones, "
136 "using the distance between the vertices and the bones");
148 ot->
srna,
"type", type_items, 0,
"Type",
"Method to use for assigning weights");
167 bool changed =
false;
199 if (v_idx_best != -1) {
206 bool *defbase_locked =
NULL, *defbase_unlocked =
NULL;
208 if (use_lock_relative) {
213 defbase_locked, defbase_unlocked, vgroup_active);
221 vc.
obact, defbase_tot, &defbase_tot_sel);
223 if (defbase_tot_sel > 1) {
226 vc.
obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
229 use_lock_relative = use_lock_relative &&
231 defbase_tot, defbase_locked, defbase_sel, defbase_tot_sel);
235 &me->
dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, is_normalized);
241 if (use_lock_relative) {
243 defbase_tot, defbase_locked, defbase_unlocked, defbase_locked, defbase_unlocked);
246 vgroup_weight, &me->
dvert[v_idx_best], defbase_tot, defbase_locked, defbase_unlocked);
252 CLAMP(vgroup_weight, 0.0f, 1.0f);
270 ot->
name =
"Weight Paint Sample Weight";
271 ot->
idname =
"PAINT_OT_weight_sample";
272 ot->
description =
"Use the mouse to sample a weight in the 3D view";
290 const int defbase_tot,
297 for (
dw = dvert->
dw; i > 0;
dw++, i--) {
323 int *groups =
MEM_callocN(defbase_tot *
sizeof(
int),
"groups");
327 const int mval[2] = {
353 if (found ==
false) {
363 item_tmp.identifier = item_tmp.
name = dg->
name;
405 ot->
name =
"Weight Paint Sample Group";
406 ot->
idname =
"PAINT_OT_weight_sample_group";
407 ot->
description =
"Select one of the vertex groups available under current mouse position";
437 int vgroup_active, vgroup_mirror = -1;
458 for (index = 0, mp = me->
mpoly; index < me->totpoly; index++, mp++) {
484 if (vgroup_mirror != -1) {
505 for (index = me->
totvert; index != 0; index--, dv++) {
541 ot->
description =
"Fill the active vertex group with the current paint weight";
629 CLAMP(testw, 0.0f, 1.0f);
631 vs->
flag |= VGRAD_STORE_IS_MODIFIED;
635 if (vs->
flag & VGRAD_STORE_DW_EXIST) {
647 vs->
flag &= ~VGRAD_STORE_IS_MODIFIED;
653 const float UNUSED(co[3]),
654 const float UNUSED(no[3]))
659 if (vs->
sco[0] == FLT_MAX) {
669 const float UNUSED(no[3]))
700 vs->
flag = VGRAD_STORE_DW_EXIST;
704 vs->
flag = VGRAD_STORE_NOP;
727 if (vert_cache !=
NULL) {
760 const float sco_start[2] = {x_start, y_start};
761 const float sco_end[2] = {x_end, y_end};
762 const bool is_interactive = (gesture !=
NULL);
768 if (is_interactive) {
797 data.region = region;
800 data.sco_start = sco_start;
801 data.sco_end = sco_end;
802 data.sco_line_div = 1.0f /
len_v2v2(sco_start, sco_end);
805 data.vert_cache = vert_cache;
846 if (is_interactive ==
false) {
854 if (vgroup_validmap !=
NULL) {
856 for (
int i = 0; i < me->
totvert; i++) {
857 if ((
data.vert_cache->elem[i].flag & VGRAD_STORE_IS_MODIFIED) != 0) {
858 if (lock_flags !=
NULL) {
860 &dvert[i], vgroup_validmap, vgroup_num, lock_flags, vgroup_num);
908 ot->
name =
"Weight Gradient";
909 ot->
idname =
"PAINT_OT_weight_gradient";
910 ot->
description =
"Draw a line to apply a weight gradient to selected vertices";
float BKE_brush_curve_strength_clamped(const struct Brush *br, float p, float len)
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)
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[3]), void *userData, MeshForeachFlag flag)
struct Mesh * mesh_get_eval_final(struct Depsgraph *depsgraph, const 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, eReportType type, const char *message)
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
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
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)
int mesh_get_x_mirror_vert(struct Object *ob, struct Mesh *me_eval, int index, bool use_topology)
void ED_region_tag_redraw(struct ARegion *region)
@ V3D_PROJ_TEST_CLIP_NEAR
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void view3d_operator_needs_opengl(const struct bContext *C)
void ED_view3d_init_mats_rv3d(const struct Object *ob, struct RegionView3D *rv3d)
_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 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 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
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)
float ED_wpaint_blend_tool(int tool, float weight, float paintval, float alpha)
@ 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)
bool weight_paint_mode_poll(struct bContext *C)
bool weight_paint_poll_ignore_tool(bContext *C)
int ED_wpaint_mirror_vgroup_ensure(struct Object *ob, int vgroup_active)
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 int weight_from_bones_exec(bContext *C, wmOperator *op)
static int weight_paint_set_exec(bContext *C, wmOperator *op)
static void gradientVertInit__mapFunc(void *userData, int index, const float co[3], const float UNUSED(no[3]))
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)
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 void gradientVertUpdate__mapFunc(void *userData, int index, const float UNUSED(co[3]), const float UNUSED(no[3]))
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_NULL_items[]
struct CurveMapping * curve
struct MDeformVert * dvert
ListBase vertex_group_names
int vertex_group_active_index
struct CustomData_MeshMasks customdata_mask
struct ToolSettings * toolsettings
struct RegionView3D * rv3d
WPGradient_vertStoreBase * vert_cache
WPGradient_vertStore elem[0]
@ VGRAD_STORE_IS_MODIFIED
enum WPGradient_vertStore::@511 flag
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))