78 if (dverts && dcount) {
129 {
ARM_GROUPS_AUTO,
"AUTOMATIC", 0,
"Automatic",
"Automatic weights from bones"},
134 "Weights from envelopes with user defined radius"},
135 {0,
nullptr, 0,
nullptr,
nullptr},
139 ot->name =
"Weight from Bones";
140 ot->idname =
"PAINT_OT_weight_from_bones";
142 (
"Set the weights of the groups matching the attached armature's selected bones, "
143 "using the distance between the vertices and the bones");
155 ot->srna,
"type", type_items, 0,
"Type",
"Method to use for assigning weights");
173 bool changed =
false;
177 const MDeformVert *dvert = mesh->deform_verts().data();
207 if (v_idx_best != -1) {
214 bool *defbase_locked =
nullptr, *defbase_unlocked =
nullptr;
216 if (use_lock_relative) {
221 defbase_locked, defbase_unlocked, vgroup_active);
229 vc.
obact, defbase_tot, &defbase_tot_sel);
231 if (defbase_tot_sel > 1) {
234 vc.
obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
237 use_lock_relative = use_lock_relative &&
239 defbase_tot, defbase_locked, defbase_sel, defbase_tot_sel);
243 &dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, is_normalized);
249 if (use_lock_relative) {
251 defbase_tot, defbase_locked, defbase_unlocked, defbase_locked, defbase_unlocked);
254 vgroup_weight, &dvert[v_idx_best], defbase_tot, defbase_locked, defbase_unlocked);
260 CLAMP(vgroup_weight, 0.0f, 1.0f);
278 ot->name =
"Weight Paint Sample Weight";
279 ot->idname =
"PAINT_OT_weight_sample";
280 ot->description =
"Use the mouse to sample a weight in the 3D view";
306 for (dw = dvert->
dw;
i > 0; dw++,
i--) {
310 groups[dw->
def_nr] =
true;
325 const MDeformVert *dverts = mesh->deform_verts().data();
354 for (
const int vert : corner_verts.
slice(
faces[index])) {
360 if (found ==
false) {
373 if (groups[
i] ==
false) {
388 ot->name =
"Weight Paint Sample Group";
389 ot->idname =
"PAINT_OT_weight_sample_group";
390 ot->description =
"Select one of the vertex groups available under current mouse position";
412 int vgroup_active, vgroup_mirror = -1;
420 MDeformVert *dvert = mesh->deform_verts_for_write().data();
422 if (mesh->
faces_num == 0 || dvert ==
nullptr) {
440 for (
const int i :
faces.index_range()) {
441 if ((paint_selmode ==
SCE_SELECT_FACE) && !(!select_poly.is_empty() && select_poly[
i])) {
445 for (
const int vert : corner_verts.
slice(
faces[
i])) {
446 if (!dvert[vert].
flag) {
448 !(!select_vert.
is_empty() && select_vert[vert]))
464 if (vgroup_mirror != -1) {
477 dvert[vert].
flag = 1;
484 for (
int index = mesh->
verts_num; index != 0; index--, dv++) {
517 ot->name =
"Set Weight";
518 ot->idname =
"PAINT_OT_weight_set";
519 ot->description =
"Fill the active vertex group with the current paint weight";
612 CLAMP(testw, 0.0f, 1.0f);
724 if (vert_cache !=
nullptr) {
727 MDeformVert *dvert = mesh->deform_verts_for_write().data();
755 MDeformVert *dverts = mesh->deform_verts_for_write().data();
760 const float sco_start[2] = {
float(x_start),
float(y_start)};
761 const float sco_end[2] = {
float(x_end),
float(y_end)};
762 const bool is_interactive = (gesture !=
nullptr);
768 if (is_interactive) {
800 data.region = region;
807 data.sco_start = sco_start;
808 data.sco_end = sco_end;
809 data.sco_line_div = 1.0f /
len_v2v2(sco_start, sco_end);
812 data.vert_cache = vert_cache;
813 data.vert_visit =
nullptr;
838 data.vert_visit =
nullptr;
847 if (is_interactive ==
false) {
856 std::memset(lock_flags, 0, vgroup_num);
857 lock_flags[
data.def_nr] =
true;
860 if (vgroup_validmap !=
nullptr) {
908 {0,
nullptr, 0,
nullptr,
nullptr},
914 ot->name =
"Weight Gradient";
915 ot->idname =
"PAINT_OT_weight_gradient";
916 ot->description =
"Draw a line to apply a weight gradient to selected vertices";
928 prop =
RNA_def_enum(
ot->srna,
"type", gradient_types, 0,
"Type",
"");
void BKE_brush_weight_set(Paint *paint, Brush *brush, float value)
float BKE_brush_curve_strength_clamped(const Brush *br, float p, float len)
float BKE_brush_weight_get(const Paint *paint, const Brush *brush)
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)
@ 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_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef attribute_id) 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 ED_wpaint_ensure_data(bContext *C, ReportList *reports, eWPaintFlag flag, WPaintVGroupIndex *vgroup_index)
bool weight_paint_mode_region_view3d_poll(bContext *C)
@ WPAINT_GRADIENT_TYPE_RADIAL
@ WPAINT_GRADIENT_TYPE_LINEAR
bool weight_paint_poll_ignore_tool(bContext *C)
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_distance_falloff
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
void operator_context_set(blender::wm::OpCallContext opcontext)
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, blender::wm::OpCallContext 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 *)