58#include "RNA_prototypes.hh"
129#define TRANSFORM_MEDIAN_ARRAY_LEN (sizeof(TransformMedian) / sizeof(float))
143 params->unique_retval_ids,
params->unique_retval_ids_len, &retval_test) == -1)
150 int verts_mask_count = 0;
161 verts_mask_count += 1;
168 *em->
bm, update_params, verts_mask, verts_mask_count);
179 if (bmpinfo ==
nullptr) {
191 if (bmpinfo ==
nullptr) {
216 if (ve_median <= 0.0f) {
219 if (ve_median >= 1.0f) {
224 float median_new = ve_median;
225 float median_orig = ve_median - median;
228 CLAMP(median_orig, 0.0f, 1.0f);
229 CLAMP(median_new, 0.0f, 1.0f);
231 if (median_new <= median_orig) {
233 return median_new / median_orig;
237 return -(1.0f - median_new) / (1.0f - median_orig);
246static void apply_raw_diff(
float *val,
const int tot,
const float ve_median,
const float median)
248 *val = (tot == 1) ? ve_median : (*val + median);
253 const float ve_median[3],
254 const float median[3])
265 float *val,
const int tot,
const float ve_median,
const float median,
const float sca)
267 if (tot == 1 || ve_median == median) {
277 const float ve_median,
282 CLAMP(*val, 0.0f, 1.0f);
284 else if (
ELEM(sca, 0.0f, 1.0f)) {
288 *val = (sca > 0.0f) ? (*val * sca) : (1.0f + ((1.0f - *val) * sca));
289 CLAMP(*val, 0.0f, 1.0f);
316 int tot, totedgedata, totcurvedata, totlattdata, totcurvebweight;
317 bool has_meshdata =
false;
318 bool has_skinradius =
false;
322 tot = totedgedata = totcurvedata = totlattdata = totcurvebweight = 0;
343 has_skinradius = (cd_vert_skin_offset != -1);
345 if (
bm->totvertsel) {
351 if (cd_vert_bweight_offset != -1) {
355 if (cd_vert_crease_offset != -1) {
359 if (has_skinradius) {
368 if ((cd_edge_bweight_offset != -1) || (cd_edge_crease_offset != -1)) {
369 if (
bm->totedgesel) {
372 if (cd_edge_bweight_offset != -1) {
376 if (cd_edge_crease_offset != -1) {
386 totedgedata =
bm->totedgesel;
389 has_meshdata = (tot || totedgedata);
399 void *selp =
nullptr;
414 seltype = &RNA_BezierSplinePoint;
433 a = nu->pntsu * nu->pntsv;
445 seltype = &RNA_SplinePoint;
454 if (totcurvedata == 1) {
464 void *selp =
nullptr;
475 seltype = &RNA_LatticePoint;
482 if (totlattdata == 1) {
503 for (
int attribute_i : selection_names.
index_range()) {
505 const IndexMask selection = retrieve_selected_points(
506 curves, selection_names[attribute_i], memory);
511 tot += selection.
size();
513 [&](
const int point) {
add_v3_v3(median.
location, positions[attribute_i][point]); });
528 for (
int attribute_i : selection_names.
index_range()) {
530 const IndexMask selection = retrieve_selected_points(
531 curves, selection_names[attribute_i], memory);
536 tot += selection.
size();
538 [&](
const int point) {
add_v3_v3(median.
location, positions[attribute_i][point]); });
544 block,
UI_BTYPE_LABEL, 0,
IFACE_(
"Nothing selected"), 0, 130, 200, 20,
nullptr, 0, 0,
"");
557 median->
e_crease /= float(totedgedata);
563 if (has_skinradius) {
564 median->
skin[0] /= float(tot);
565 median->
skin[1] /= float(tot);
569 else if (totcurvedata) {
571 if (totcurvebweight) {
572 median->
b_weight /= float(totcurvebweight);
574 median->
weight /= float(totcurvedata);
575 median->
radius /= float(totcurvedata);
576 median->
tilt /= float(totcurvedata);
578 else if (totlattdata) {
580 median->
weight /= float(totlattdata);
587 const int butw = 200;
589 const int but_margin = 2;
598 c =
IFACE_(
"Control Point:");
611 uiDefBut(block,
UI_BTYPE_LABEL, 0, c, 0, yi -= buth, butw, buth,
nullptr, 0, 0,
"");
662 if (totcurvebweight == tot) {
686 yi -= buth + but_margin,
692 TIP_(
"Displays global values"));
705 TIP_(
"Displays local values"));
715 tot == 1 ?
IFACE_(
"Vertex Data:") :
IFACE_(
"Vertices Data:"),
717 yi -= buth + but_margin,
728 tot == 1 ?
IFACE_(
"Bevel Weight:") :
IFACE_(
"Mean Bevel Weight:"),
730 yi -= buth + but_margin,
736 TIP_(
"Vertex weight used by Bevel modifier"));
743 tot == 1 ?
IFACE_(
"Vertex Crease:") :
IFACE_(
"Mean Vertex Crease:"),
745 yi -= buth + but_margin,
751 TIP_(
"Weight used by the Subdivision Surface modifier"));
755 if (has_skinradius) {
760 tot == 1 ?
IFACE_(
"Radius X:") :
IFACE_(
"Mean Radius X:"),
762 yi -= buth + but_margin,
768 TIP_(
"X radius used by Skin modifier"));
774 tot == 1 ?
IFACE_(
"Radius Y:") :
IFACE_(
"Mean Radius Y:"),
776 yi -= buth + but_margin,
782 TIP_(
"Y radius used by Skin modifier"));
791 totedgedata == 1 ?
IFACE_(
"Edge Data:") :
IFACE_(
"Edges Data:"),
793 yi -= buth + but_margin,
804 totedgedata == 1 ?
IFACE_(
"Bevel Weight:") :
IFACE_(
"Mean Bevel Weight:"),
806 yi -= buth + but_margin,
812 TIP_(
"Edge weight used by Bevel modifier"));
819 totedgedata == 1 ?
IFACE_(
"Crease:") :
IFACE_(
"Mean Crease:"),
821 yi -= buth + but_margin,
827 TIP_(
"Weight used by the Subdivision Surface modifier"));
833 else if (totcurvedata) {
835 if (totcurvedata == 1) {
841 yi -= buth + but_margin,
857 yi -= buth + but_margin,
873 yi -= buth + but_margin,
885 else if (totcurvedata > 1) {
891 yi -= buth + but_margin,
897 TIP_(
"Weight used for Soft Body Goal"));
905 yi -= buth + but_margin,
911 TIP_(
"Radius of curve control points"));
919 yi -= buth + but_margin,
925 TIP_(
"Tilt of curve control points"));
932 else if (totlattdata) {
934 if (totlattdata == 1) {
940 yi -= buth + but_margin,
952 else if (totlattdata > 1) {
958 yi -= buth + but_margin,
964 TIP_(
"Weight used for Soft Body Goal"));
979 callback_data.
arg1 = em;
993 (
float *)&ve_median_basis,
994 (
float *)&median_basis,
998 const bool apply_vcos = (tot == 1) || (
len_squared_v3(median_basis.generic.location) != 0.0f);
1001 (apply_vcos || median_basis.mesh.bv_weight || median_basis.mesh.v_crease ||
1002 median_basis.mesh.skin[0] || median_basis.mesh.skin[1] || median_basis.mesh.be_weight ||
1003 median_basis.mesh.e_crease))
1013 int cd_vert_bweight_offset = -1;
1014 int cd_vert_crease_offset = -1;
1015 int cd_vert_skin_offset = -1;
1016 int cd_edge_bweight_offset = -1;
1017 int cd_edge_crease_offset = -1;
1019 float scale_bv_weight = 1.0f;
1020 float scale_v_crease = 1.0f;
1021 float scale_skin[2] = {1.0f, 1.0f};
1022 float scale_be_weight = 1.0f;
1023 float scale_e_crease = 1.0f;
1052 for (
int i = 0;
i < 2;
i++) {
1053 if (median->
skin[
i]) {
1057 if (ve_median->skin[
i] != median->
skin[
i]) {
1058 scale_skin[
i] = ve_median->skin[
i] / (ve_median->skin[
i] - median->
skin[
i]);
1069 if (cd_vert_bweight_offset != -1) {
1070 float *b_weight =
static_cast<float *
>(
1075 if (cd_vert_crease_offset != -1) {
1076 float *crease =
static_cast<float *
>(
1081 if (cd_vert_skin_offset != -1) {
1086 for (
int i = 0;
i < 2;
i++) {
1087 if (median->
skin[
i] != 0.0f) {
1089 &vs->
radius[
i], tot, ve_median->skin[
i], median->
skin[
i], scale_skin[
i]);
1130 float *b_weight =
static_cast<float *
>(
1136 float *crease =
static_cast<float *
>(
1145 (apply_vcos || median_basis.curve.b_weight || median_basis.curve.weight ||
1146 median_basis.curve.radius || median_basis.curve.tilt))
1149 *ve_median = &ve_median_basis.curve;
1159 for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) {
1180 else if (apply_vcos) {
1192 for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a--; bp++) {
1217 if ((nu->type ==
CU_BEZIER) && apply_vcos) {
1222 else if ((ob->
type ==
OB_LATTICE) && (apply_vcos || median_basis.lattice.weight)) {
1224 *ve_median = &ve_median_basis.lattice;
1263 for (
int attribute_i : selection_names.
index_range()) {
1264 const IndexMask selection = retrieve_selected_points(
1265 curves, selection_names[attribute_i], memory);
1291 for (
int attribute_i : selection_names.
index_range()) {
1292 const IndexMask selection = retrieve_selected_points(
1293 curves, selection_names[attribute_i], memory);
1303 curves.tag_positions_changed();
1310#undef TRANSFORM_MEDIAN_ARRAY_LEN
1321 const int butw = 200;
1343 for (
int i = 0;
i < 3;
i++) {
1345 const char text[3] = {char(
'X' +
i),
':',
'\0'};
1362 UI_but_disable(but,
"Can't edit this property from a linked data-block");
1369 for (
int i = 0;
i < 3;
i++) {
1371 axis_mask |= (1 <<
i);
1383#define B_VGRP_PNL_EDIT_SINGLE 8
1455 int subset_count, vgroup_tot;
1456 const bool *vgroup_validmap;
1464 row = &bcol->
row(
true);
1472 ob, subset_type, &vgroup_tot, &subset_count);
1479 if (vgroup_validmap[
i]) {
1485 row = &
split->row(
true);
1508 row = &
split->row(
true);
1514 vertex_weight = dw->
weight;
1537 icon = (locked) ? ICON_BLANK1 : ICON_PASTEDOWN;
1543 icon = (locked) ? ICON_LOCKED : ICON_X;
1557 row = &
col->row(
true);
1570 TIP_(
"Normalize weights of active vertex (if affected groups are unlocked)"));
1583 TIP_(
"Copy active vertex to other selected vertices (if affected groups are unlocked)"));
1596 if (
ptr->type == &RNA_PoseBone) {
1601 bone =
static_cast<Bone *
>(boneptr.
data);
1604 colsub = &
split->column(
true);
1606 colsub = &
split->column(
true);
1608 colsub->
label(
"", ICON_NONE);
1616 colsub = &
split->column(
true);
1618 colsub = &
split->column(
true);
1626 ICON_DECORATE_UNLOCKED);
1629 colsub->
label(
"", ICON_NONE);
1635 ICON_DECORATE_UNLOCKED);
1638 colsub = &
split->column(
true);
1640 colsub = &
split->column(
true);
1648 ICON_DECORATE_UNLOCKED);
1651 colsub->
label(
"", ICON_NONE);
1657 ICON_DECORATE_UNLOCKED);
1660 colsub = &
split->column(
true);
1662 colsub = &
split->column(
true);
1664 colsub->
label(
"", ICON_NONE);
1669 ICON_DECORATE_UNLOCKED);
1675 colsub = &
split->column(
true);
1677 colsub = &
split->column(
true);
1679 colsub->
label(
"", ICON_NONE);
1692 layout->
label(
IFACE_(
"No Bone Active"), ICON_NONE);
1715 layout->
label(
IFACE_(
"Nothing selected"), ICON_NONE);
1735 col->prop(&eboneptr,
"length",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
1744 if (!mball || !(mball->
lastelem)) {
1745 layout->
label(
IFACE_(
"Nothing selected"), ICON_NONE);
1909 if (ob ==
nullptr) {
1924 ot->name =
"Object Mode Menu";
1925 ot->idname =
"VIEW3D_OT_object_mode_pie_or_toggle";
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_active_if_bonecoll_visible(Object *ob) ATTR_WARN_UNUSED_RESULT
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void BKE_nurb_project_2d(Nurb *nu)
void BKE_nurb_handles_test(Nurb *nu, eNurbHandleTest_Mode handle_mode, bool use_around_local)
ListBase * BKE_curve_editNurbs_get(Curve *cu)
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_offset(const CustomData *data, eCustomDataType type)
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
void BKE_editmesh_looptris_and_normals_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
General operations, lookup, etc. for blender objects.
void BKE_object_dimensions_eval_cached_get(const Object *ob, float r_vec[3])
void BKE_object_dimensions_set_ex(Object *ob, const float value[3], int axis_mask, const float ob_scale_orig[3], const float ob_obmat_orig[4][4])
bool BKE_object_is_in_wpaint_select_vert(const Object *ob)
bool BKE_object_is_in_editmode_vgroup(const Object *ob)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Generic array manipulation API.
#define BLI_array_findindex(arr, arr_len, p)
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v3_fl(float r[3], float f)
void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, int size)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void copy_vn_fl(float *array_tar, int size, float val)
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE void add_v3_v3(float r[3], const float a[3])
char * STRNCPY(char(&dst)[N], const char *src)
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
void DEG_id_tag_update(ID *id, unsigned int flags)
Object is a sort of wrapper for general info.
#define OB_TYPE_SUPPORT_EDITMODE(_type)
#define OBEDIT_FROM_OBACT(ob)
MDeformVert * ED_mesh_active_dvert_get_only(Object *ob)
void ED_area_tag_redraw(ScrArea *area)
bool ED_operator_view3d_active(bContext *C)
static void split(const char *text, const char *seps, char ***str, int *count)
Read Guarded memory(de)allocation.
#define RNA_TRANSLATION_PREC_DEFAULT
void UI_but_func_set(uiBut *but, std::function< void(bContext &)> func)
void UI_but_disable(uiBut *but, const char *disabled_hint)
void UI_block_interaction_set(uiBlock *block, uiBlockInteraction_CallbackData *callbacks)
wmOperatorStatus UI_pie_menu_invoke(bContext *C, const char *idname, const wmEvent *event)
uiBut * uiDefBut(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_drawflag_enable(uiBut *but, int flag)
void UI_but_number_step_size_set(uiBut *but, float step_size)
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg)
PointerRNA * UI_but_operator_ptr_ensure(uiBut *but)
void UI_block_align_begin(uiBlock *block)
uiBut * uiDefButBitS(uiBlock *block, int type, int bit, int retval, blender::StringRef str, int x, int y, short width, short height, short *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_number_precision_set(uiBut *but, float precision)
uiBut * uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, wmOperatorCallContext opcontext, blender::StringRef str, int x, int y, short width, short height, std::optional< blender::StringRef > tip)
uiBut * uiDefButR(uiBlock *block, int type, int retval, std::optional< blender::StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, blender::StringRefNull propname, int index, float min, float max, std::optional< blender::StringRef > tip)
uiBut * uiDefButF(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, float *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_unit_type_set(uiBut *but, int unit_type)
void UI_but_flag_enable(uiBut *but, int flag)
void UI_block_align_end(uiBlock *block)
void uiLayoutSetActive(uiLayout *layout, bool active)
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
void uiLayoutSetEmboss(uiLayout *layout, blender::ui::EmbossType emboss)
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_flag_test(ele, hflag)
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const StringRef name)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
BMPartialUpdate * BM_mesh_partial_create_from_verts_group_single(BMesh &bm, const BMPartialUpdate_Params ¶ms, const BitSpan verts_mask, const int verts_mask_count)
void BM_mesh_partial_destroy(BMPartialUpdate *bmpinfo)
void foreach_index(Fn &&fn) const
constexpr IndexRange index_range() const
void resize(const int64_t new_size)
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
void tag_positions_changed()
#define ID_IS_EDITABLE(_id)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
void collection_hide_menu_draw(const bContext *C, uiLayout *layout)
bool mode_set(bContext *C, eObjectMode mode)
void vgroup_vert_active_mirror(Object *ob, int def_nr)
void parallel_for_each(Range &&range, const Function &function)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PointerRNA RNA_id_pointer_create(ID *id)
static const float tilt_limit
struct EditLatt * editlatt
MeshRuntimeHandle * runtime
ObjectRuntimeHandle * runtime
void(* draw)(const bContext *C, Panel *panel)
char idname[BKE_ST_MAXNAME]
bool(* poll)(const bContext *C, PanelType *pt)
char translation_context[BKE_ST_MAXNAME]
char category[BKE_ST_MAXNAME]
char label[BKE_ST_MAXNAME]
struct ToolSettings * toolsettings
void * properties_storage
void(* properties_storage_free)(void *properties_storage)
struct EditBone * act_edbone
bke::greasepencil::Drawing & drawing
uiBlockInteractionBeginFn begin_fn
uiBlockInteractionEndFn end_fn
uiBlockInteractionUpdateFn update_fn
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, wmOperatorCallContext context, eUI_Item_Flag flag)
uiBlock * absolute_block()
void label(blender::StringRef name, int icon)
uiLayout & column(bool align)
uiLayout & row(bool align)
uiLayout & split(float percentage, bool align)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)