77 if (dverts && dcount) {
128 {
ARM_GROUPS_AUTO,
"AUTOMATIC", 0,
"Automatic",
"Automatic weights from bones"},
133 "Weights from envelopes with user defined radius"},
134 {0,
nullptr, 0,
nullptr,
nullptr},
138 ot->name =
"Weight from Bones";
139 ot->idname =
"PAINT_OT_weight_from_bones";
141 (
"Set the weights of the groups matching the attached armature's selected bones, "
142 "using the distance between the vertices and the bones");
154 ot->srna,
"type", type_items, 0,
"Type",
"Method to use for assigning weights");
172 bool changed =
false;
176 const MDeformVert *dvert = mesh->deform_verts().data();
206 if (v_idx_best != -1) {
213 bool *defbase_locked =
nullptr, *defbase_unlocked =
nullptr;
215 if (use_lock_relative) {
220 defbase_locked, defbase_unlocked, vgroup_active);
228 vc.
obact, defbase_tot, &defbase_tot_sel);
230 if (defbase_tot_sel > 1) {
233 vc.
obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
236 use_lock_relative = use_lock_relative &&
238 defbase_tot, defbase_locked, defbase_sel, defbase_tot_sel);
242 &dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, is_normalized);
248 if (use_lock_relative) {
250 defbase_tot, defbase_locked, defbase_unlocked, defbase_locked, defbase_unlocked);
253 vgroup_weight, &dvert[v_idx_best], defbase_tot, defbase_locked, defbase_unlocked);
259 CLAMP(vgroup_weight, 0.0f, 1.0f);
277 ot->name =
"Weight Paint Sample Weight";
278 ot->idname =
"PAINT_OT_weight_sample";
279 ot->description =
"Use the mouse to sample a weight in the 3D view";
305 for (dw = dvert->
dw;
i > 0; dw++,
i--) {
309 groups[dw->
def_nr] =
true;
324 const MDeformVert *dverts = mesh->deform_verts().data();
353 for (
const int vert : corner_verts.
slice(
faces[index])) {
359 if (found ==
false) {
372 if (groups[
i] ==
false) {
386 ot->name =
"Weight Paint Sample Group";
387 ot->idname =
"PAINT_OT_weight_sample_group";
388 ot->description =
"Select one of the vertex groups available under current mouse position";
410 int vgroup_active, vgroup_mirror = -1;
418 MDeformVert *dvert = mesh->deform_verts_for_write().data();
420 if (mesh->
faces_num == 0 || dvert ==
nullptr) {
438 for (
const int i :
faces.index_range()) {
439 if ((paint_selmode ==
SCE_SELECT_FACE) && !(!select_poly.is_empty() && select_poly[
i])) {
443 for (
const int vert : corner_verts.
slice(
faces[
i])) {
444 if (!dvert[vert].
flag) {
446 !(!select_vert.
is_empty() && select_vert[vert]))
462 if (vgroup_mirror != -1) {
475 dvert[vert].
flag = 1;
482 for (
int index = mesh->
verts_num; index != 0; index--, dv++) {
516 ot->name =
"Set Weight";
517 ot->idname =
"PAINT_OT_weight_set";
518 ot->description =
"Fill the active vertex group with the current paint weight";
611 CLAMP(testw, 0.0f, 1.0f);
723 if (vert_cache !=
nullptr) {
726 MDeformVert *dvert = mesh->deform_verts_for_write().data();
754 MDeformVert *dverts = mesh->deform_verts_for_write().data();
759 const float sco_start[2] = {float(x_start), float(y_start)};
760 const float sco_end[2] = {float(x_end), float(y_end)};
761 const bool is_interactive = (gesture !=
nullptr);
767 if (is_interactive) {
799 data.region = region;
806 data.sco_start = sco_start;
807 data.sco_end = sco_end;
808 data.sco_line_div = 1.0f /
len_v2v2(sco_start, sco_end);
811 data.vert_cache = vert_cache;
812 data.vert_visit =
nullptr;
837 data.vert_visit =
nullptr;
846 if (is_interactive ==
false) {
854 if (vgroup_validmap !=
nullptr) {
858 if (lock_flags !=
nullptr) {
860 &dvert[
i], vgroup_validmap, vgroup_num, lock_flags, vgroup_num);
904 {0,
nullptr, 0,
nullptr,
nullptr},
910 ot->name =
"Weight Gradient";
911 ot->idname =
"PAINT_OT_weight_gradient";
912 ot->description =
"Draw a line to apply a weight gradient to selected vertices";
924 prop =
RNA_def_enum(
ot->srna,
"type", gradient_types, 0,
"Type",
"");
void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value)
float BKE_brush_weight_get(const Scene *scene, const Brush *brush)
float BKE_brush_curve_strength_clamped(const Brush *br, float p, float len)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
Mesh * BKE_mesh_from_object(Object *ob)
void BKE_mesh_foreach_mapped_vert(const Mesh *mesh, void(*func)(void *user_data, int index, const float co[3], const float no[3]), void *user_data, MeshForeachFlag flag)
Object * BKE_modifiers_is_deformed_by_armature(Object *ob)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
Brush * BKE_paint_brush(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)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
int BLI_listbase_count(const 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 v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_fl(float r[2], float f)
#define ENUM_OPERATORS(_type, _max)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
#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 ARM_GROUPS_ENVELOPE
#define ED_MESH_PICK_DEFAULT_VERT_DIST
int mesh_get_x_mirror_vert(Object *ob, Mesh *mesh_eval, int index, bool use_topology)
bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
#define ED_MESH_PICK_DEFAULT_FACE_DIST
bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], uint dist_px, bool use_zbuf, uint *r_index)
void ED_region_tag_redraw(ARegion *region)
@ V3D_PROJ_TEST_CLIP_NEAR
eV3DProjStatus ED_view3d_project_float_object(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void ED_view3d_init_mats_rv3d(const Object *ob, RegionView3D *rv3d)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
void view3d_operator_needs_gpu(const bContext *C)
Read Guarded memory(de)allocation.
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
uiPopupMenu * UI_popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
void uiLayoutSetOperatorContext(uiLayout *layout, wmOperatorCallContext opcontext)
@ OPTYPE_DEPENDS_ON_CURSOR
void ED_object_vgroup_calc_from_armature(ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par, const int mode, const bool mirror)
BMesh const char void * data
BPy_StructRNA * depsgraph
constexpr bool is_empty() const
constexpr int64_t size() const
constexpr Span slice(int64_t start, int64_t size) const
constexpr bool is_empty() const
GAttributeReader lookup(const StringRef attribute_id) const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
void * MEM_mallocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
void mesh_select_face_flush(Mesh &mesh)
float ED_wpaint_blend_tool(int tool, float weight, float paintval, float alpha)
int ED_wpaint_mirror_vgroup_ensure(Object *ob, int vgroup_active)
bool weight_paint_mode_poll(bContext *C)
bool weight_paint_mode_region_view3d_poll(bContext *C)
bool weight_paint_poll_ignore_tool(bContext *C)
bool ED_wpaint_ensure_data(bContext *C, ReportList *reports, enum eWPaintFlag flag, WPaintVGroupIndex *vgroup_index)
@ WPAINT_GRADIENT_TYPE_RADIAL
@ WPAINT_GRADIENT_TYPE_LINEAR
static bool weight_paint_sample_mark_groups(const MDeformVert *dvert, blender::MutableSpan< bool > groups)
static wmOperatorStatus paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_weight_set(wmOperatorType *ot)
static bool weight_paint_set(Object *ob, float paintweight)
static wmOperatorStatus weight_sample_group_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus weight_paint_set_exec(bContext *C, wmOperator *op)
void PAINT_OT_weight_sample(wmOperatorType *ot)
static void gradientVert_update(WPGradient_userData *grad_data, int index)
static void wpaint_prev_init(WPaintPrev *wpp)
static wmOperatorStatus paint_weight_gradient_exec(bContext *C, wmOperator *op)
static void gradientVertInit__mapFunc(void *user_data, int index, const float co[3], const float[3])
static bool weight_from_bones_poll(bContext *C)
static void gradientVertUpdate__mapFunc(void *user_data, int index, const float[3], const float[3])
static wmOperatorStatus paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_weight_from_bones(wmOperatorType *ot)
void PAINT_OT_weight_gradient(wmOperatorType *ot)
static wmOperatorStatus weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus weight_from_bones_exec(bContext *C, wmOperator *op)
static void wpaint_prev_destroy(WPaintPrev *wpp)
static void wpaint_prev_create(WPaintPrev *wpp, MDeformVert *dverts, int dcount)
void PAINT_OT_weight_sample_group(wmOperatorType *ot)
void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value)
int RNA_int_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
struct CurveMapping * curve
ListBase vertex_group_names
int vertex_group_active_index
struct ToolSettings * toolsettings
blender::VArray< bool > hide_vert
WPGradient_vertStoreBase * vert_cache
blender::VArraySpan< bool > select_vert
WPGradient_vertStore elem[0]
@ VGRAD_STORE_IS_MODIFIED
MDeformVert * wpaint_prev
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, wmOperatorCallContext context, eUI_Item_Flag flag)
wmGenericUserData user_data
struct ReportList * reports
struct wmOperatorType * type
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
std::string WM_operatortype_name(wmOperatorType *ot, PointerRNA *properties)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)