Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_buttons.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_transform.h" | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "view3d_intern.h" /* own include */ | #include "view3d_intern.h" /* own include */ | ||||
| /* ******************* view3d space & buttons ************** */ | /* ******************* view3d space & buttons ************** */ | ||||
| enum { | enum { | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
| #define TRANSFORM_MEDIAN_ARRAY_LEN (sizeof(TransformMedian) / sizeof(float)) | #define TRANSFORM_MEDIAN_ARRAY_LEN (sizeof(TransformMedian) / sizeof(float)) | ||||
| static TransformProperties *v3d_transform_props_ensure(View3D *v3d); | static TransformProperties *v3d_transform_props_ensure(View3D *v3d); | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Edit Mesh Partial Updates | /** \name Edit Mesh Partial Updates | ||||
| * \{ */ | * \{ */ | ||||
| static void *editmesh_partial_update_begin_fn(struct bContext *UNUSED(C), | static void *transform_update_begin_fn(struct bContext *C, | ||||
| const struct uiBlockInteraction_Params *params, | const struct uiBlockInteraction_Params *params, | ||||
| void *arg1) | void *UNUSED(arg1)) | ||||
| { | { | ||||
| const int retval_test = B_TRANSFORM_PANEL_MEDIAN; | const int retval_test = B_TRANSFORM_PANEL_MEDIAN; | ||||
| if (BLI_array_findindex( | if (BLI_array_findindex( | ||||
| params->unique_retval_ids, params->unique_retval_ids_len, &retval_test) == -1) { | params->unique_retval_ids, params->unique_retval_ids_len, &retval_test) == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| BMEditMesh *em = arg1; | return ED_transform_data_init(C); | ||||
| int verts_mask_count = 0; | |||||
| BMIter iter; | |||||
| BMVert *eve; | |||||
| int i; | |||||
| BLI_bitmap *verts_mask = BLI_BITMAP_NEW(em->bm->totvert, __func__); | |||||
| BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { | |||||
| if (!BM_elem_flag_test(eve, BM_ELEM_SELECT)) { | |||||
| continue; | |||||
| } | |||||
| BLI_BITMAP_ENABLE(verts_mask, i); | |||||
| verts_mask_count += 1; | |||||
| } | } | ||||
| BMPartialUpdate *bmpinfo = BM_mesh_partial_create_from_verts_group_single( | static void transform_update_end_fn(struct bContext *C, | ||||
| em->bm, | |||||
| &(BMPartialUpdate_Params){ | |||||
| .do_tessellate = true, | |||||
| .do_normals = true, | |||||
| }, | |||||
| verts_mask, | |||||
| verts_mask_count); | |||||
| MEM_freeN(verts_mask); | |||||
| return bmpinfo; | |||||
| } | |||||
| static void editmesh_partial_update_end_fn(struct bContext *UNUSED(C), | |||||
| const struct uiBlockInteraction_Params *UNUSED(params), | const struct uiBlockInteraction_Params *UNUSED(params), | ||||
| void *UNUSED(arg1), | void *UNUSED(arg1), | ||||
| void *user_data) | void *user_data) | ||||
| { | { | ||||
| BMPartialUpdate *bmpinfo = user_data; | struct TransInfo *t = user_data; | ||||
| if (bmpinfo == NULL) { | if (t == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| BM_mesh_partial_destroy(bmpinfo); | ED_transform_data_end(C, t); | ||||
| } | } | ||||
| static void editmesh_partial_update_update_fn( | static void transform_update_update_fn(struct bContext *C, | ||||
| struct bContext *C, | |||||
| const struct uiBlockInteraction_Params *UNUSED(params), | const struct uiBlockInteraction_Params *UNUSED(params), | ||||
| void *arg1, | void *UNUSED(arg1), | ||||
| void *user_data) | void *user_data) | ||||
| { | { | ||||
| BMPartialUpdate *bmpinfo = user_data; | struct TransInfo *t = user_data; | ||||
| if (bmpinfo == NULL) { | if (t == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| TransformProperties *tfp = v3d_transform_props_ensure(v3d); | TransformProperties *tfp = v3d_transform_props_ensure(v3d); | ||||
| if (tfp->tag_for_update == false) { | if (tfp->tag_for_update == false) { | ||||
| return; | return; | ||||
| } | } | ||||
| tfp->tag_for_update = false; | tfp->tag_for_update = false; | ||||
| BMEditMesh *em = arg1; | ED_transform_data_recalc(t); | ||||
| BKE_editmesh_looptri_and_normals_calc_with_partial(em, bmpinfo); | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* Helper function to compute a median changed value, | /* Helper function to compute a median changed value, | ||||
| * when the value should be clamped in [0.0, 1.0]. | * when the value should be clamped in [0.0, 1.0]. | ||||
| * Returns either 0.0, 1.0 (both can be applied directly), a positive scale factor | * Returns either 0.0, 1.0 (both can be applied directly), a positive scale factor | ||||
| * for scale down, or a negative one for scale up. | * for scale down, or a negative one for scale up. | ||||
| ▲ Show 20 Lines • Show All 719 Lines • ▼ Show 20 Lines | if (block) { /* buttons */ | ||||
| UI_block_align_end(block); | UI_block_align_end(block); | ||||
| if (ob->type == OB_MESH) { | if (ob->type == OB_MESH) { | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| BMEditMesh *em = me->edit_mesh; | BMEditMesh *em = me->edit_mesh; | ||||
| if (em != NULL) { | if (em != NULL) { | ||||
| UI_block_interaction_set(block, | UI_block_interaction_set(block, | ||||
| &(uiBlockInteraction_CallbackData){ | &(uiBlockInteraction_CallbackData){ | ||||
| .begin_fn = editmesh_partial_update_begin_fn, | .begin_fn = transform_update_begin_fn, | ||||
| .end_fn = editmesh_partial_update_end_fn, | .end_fn = transform_update_end_fn, | ||||
| .update_fn = editmesh_partial_update_update_fn, | .update_fn = transform_update_update_fn, | ||||
| .arg1 = em, | .arg1 = em, | ||||
| }); | }); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { /* apply */ | else { /* apply */ | ||||
| memcpy(&ve_median_basis, &tfp->ve_median, sizeof(tfp->ve_median)); | memcpy(&ve_median_basis, &tfp->ve_median, sizeof(tfp->ve_median)); | ||||
| ▲ Show 20 Lines • Show All 849 Lines • Show Last 20 Lines | |||||