[Bf-blender-cvs] [a7bf4966e2d] blender2.8: Merge branch 'master' into blender2.8
Campbell Barton
noreply at git.blender.org
Tue Sep 25 05:29:08 CEST 2018
Commit: a7bf4966e2d691be90a55b1189846bfaa17a9ef7
Author: Campbell Barton
Date: Tue Sep 25 13:42:51 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBa7bf4966e2d691be90a55b1189846bfaa17a9ef7
Merge branch 'master' into blender2.8
===================================================================
===================================================================
diff --cc source/blender/editors/mesh/editmesh_extrude.c
index c66999b135e,e381cfdbdea..53c7a5867e8
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@@ -302,38 -295,26 +304,38 @@@ static int edbm_extrude_repeat_exec(bCo
float dvec[3], tmat[3][3], bmat[3][3];
short a;
- /* dvec */
- normalize_v3_v3_length(dvec, rv3d->persinv[2], offs);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
- /* base correction */
- copy_m3_m4(bmat, obedit->obmat);
- invert_m3_m3(tmat, bmat);
- mul_m3_v3(tmat, dvec);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- for (a = 0; a < steps; a++) {
- edbm_extrude_ex(obedit, em, BM_ALL_NOLOOP, BM_ELEM_SELECT, false, false, false);
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BMO_op_callf(
- em->bm, BMO_FLAG_DEFAULTS,
- "translate vec=%v verts=%hv",
- dvec, BM_ELEM_SELECT);
- }
+ /* dvec */
+ normalize_v3_v3_length(dvec, rv3d->persinv[2], offs);
- EDBM_mesh_normals_update(em);
+ /* base correction */
+ copy_m3_m4(bmat, obedit->obmat);
+ invert_m3_m3(tmat, bmat);
+ mul_m3_v3(tmat, dvec);
- EDBM_update_generic(em, true, true);
+ for (a = 0; a < steps; a++) {
- edbm_extrude_ex(obedit, em, BM_ALL_NOLOOP, BM_ELEM_SELECT, false, false);
++ edbm_extrude_ex(obedit, em, BM_ALL_NOLOOP, BM_ELEM_SELECT, false, false, false);
+
+ BMO_op_callf(
+ em->bm, BMO_FLAG_DEFAULTS,
+ "translate vec=%v verts=%hv",
+ dvec, BM_ELEM_SELECT);
+ }
+
+ EDBM_mesh_normals_update(em);
+
+ EDBM_update_generic(em, true, true);
+ }
+
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@@ -891,22 -472,12 +895,23 @@@ void MESH_OT_extrude_verts_indiv(wmOper
static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BKE_editmesh_from_object(obedit);
++ const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip");
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ if (em->bm->totedgesel == 0) {
+ continue;
+ }
- edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT);
- edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, false);
++ edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, use_normal_flip);
- EDBM_update_generic(em, true, true);
+ EDBM_update_generic(em, true, true);
+ }
+ MEM_freeN(objects);
return OPERATOR_FINISHED;
}
@@@ -1001,194 -565,147 +1007,194 @@@ static int edbm_dupli_extrude_cursor_in
zero_v3(center);
verts_len = 0;
- BM_ITER_MESH (v1, &iter, vc.em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v1, BM_ELEM_SELECT)) {
- add_v3_v3(center, v1->co);
- verts_len += 1;
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ ED_view3d_viewcontext_init_object(&vc, obedit);
+ const int local_verts_len = vc.em->bm->totvertsel;
+
+ if (vc.em->bm->totvertsel == 0) {
+ continue;
+ }
+
+ float local_center[3];
+ zero_v3(local_center);
+
+ BM_ITER_MESH(v1, &iter, vc.em->bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v1, BM_ELEM_SELECT)) {
+ add_v3_v3(local_center, v1->co);
+ }
}
+
+ mul_v3_fl(local_center, 1.0f / (float)local_verts_len);
+ mul_m4_v3(vc.obedit->obmat, local_center);
+ mul_v3_fl(local_center, (float)local_verts_len);
+
+ add_v3_v3(center, local_center);
+ verts_len += local_verts_len;
}
- /* call extrude? */
if (verts_len != 0) {
- const char extrude_htype = edbm_extrude_htype_from_em_select(vc.em);
- const bool rot_src = RNA_boolean_get(op->ptr, "rotate_source");
- BMEdge *eed;
- float mat[3][3];
- float vec[3], ofs[3];
- float nor[3] = {0.0, 0.0, 0.0};
+ mul_v3_fl(center, 1.0f / (float)verts_len);
+ }
- /* 2D normal calc */
- const float mval_f[2] = {(float)event->mval[0],
- (float)event->mval[1]};
+ /* Then we process the meshes. */
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ ED_view3d_viewcontext_init_object(&vc, obedit);
- mul_v3_fl(center, 1.0f / (float)verts_len);
+ if (verts_len != 0) {
+ if (vc.em->bm->totvertsel == 0) {
+ continue;
+ }
+ }
+ else if (obedit != object_active) {
+ continue;
+ }
- /* check for edges that are half selected, use for rotation */
- bool done = false;
- BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- float co1[2], co2[2];
-
- if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
- (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
- {
- /* 2D rotate by 90d while adding.
- * (x, y) = (y, -x)
- *
- * accumulate the screenspace normal in 2D,
- * with screenspace edge length weighting the result. */
- if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
- nor[0] += (co1[1] - co2[1]);
- nor[1] += -(co1[0] - co2[0]);
- }
- else {
- nor[0] += (co2[1] - co1[1]);
- nor[1] += -(co2[0] - co1[0]);
+ invert_m4_m4(vc.obedit->imat, vc.obedit->obmat);
+ ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
+
+ float local_center[3];
+ mul_v3_m4v3(local_center, vc.obedit->imat, center);
+
+ /* call extrude? */
+ if (verts_len != 0) {
+ const char extrude_htype = edbm_extrude_htype_from_em_select(vc.em);
+ BMEdge *eed;
+ float mat[3][3];
+ float vec[3], ofs[3];
+ float nor[3] = { 0.0, 0.0, 0.0 };
+
+ /* 2D normal calc */
+ const float mval_f[2] = { (float)event->mval[0],
+ (float)event->mval[1] };
+
+ /* check for edges that are half selected, use for rotation */
+ bool done = false;
+ BM_ITER_MESH(eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+ float co1[2], co2[2];
+
+ if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
+ {
+ /* 2D rotate by 90d while adding.
+ * (x, y) = (y, -x)
+ *
+ * accumulate the screenspace normal in 2D,
+ * with screenspace edge length weighting the result. */
+ if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
+ nor[0] += (co1[1] - co2[1]);
+ nor[1] += -(co1[0] - co2[0]);
+ }
+ else {
+ nor[0] += (co2[1] - co1[1]);
+ nor[1] += -(co2[0] - co1[0]);
+ }
+ done = true;
}
- done = true;
}
}
- }
- if (done) {
- float view_vec[3], cross[3];
+ if (done) {
+ float view_vec[3], cross[3];
- /* convert the 2D nomal into 3D */
- mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* worldspace */
- mul_mat3_m4_v3(vc.obedit->imat, nor); /* local space */
+ /* convert the 2D normal into 3D */
+ mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* worldspace */
+ mul_mat3_m4_v3(vc.obedit->imat, nor); /* local space */
- /* correct the normal to be aligned on the view plane */
- mul_v3_mat3_m4v3(view_vec, vc.obedit->imat, vc.rv3d->viewinv[2]);
- cross_v3_v3v3(cross, nor, view_vec);
- cross_v3_v3v3(nor, view_vec, cross);
- normalize_v3(nor);
- }
+ /* correct the normal to be aligned on the view plane */
+ mul_v3_mat3_m4v3(view_vec, vc.obedit->imat, vc.rv3d->viewinv[2]);
+ cross_v3_v3v3(cross, nor, view_vec);
+ cross_v3_v3v3(nor, view_vec, cross);
+ normalize_v3(nor);
+ }
+
+ /* center */
+ copy_v3_v3(ofs, local_center);
- /* center */
- copy_v3_v3(ofs, center);
+ mul_m4_v3(vc.obedit->obmat, ofs); /* view space */
+ ED_view3d_win_to_3d_int(vc.v3d, vc.ar, ofs, event->mval, ofs);
+ mul_m4_v3(vc.obedit->imat, ofs); // back in object space
- mul_m4_v3(vc.obedit->obmat, ofs); /* view space */
- ED_view3d_win_to_3d_int(vc.v3d, vc.ar, ofs, event->mval, ofs);
- mul_m4_v3(vc.obedit->imat, ofs); // back in object space
+ sub_v3_v3(ofs, local_center);
- sub_v3_v3(ofs, center);
+ /* calculate rotation */
+ unit_m3(mat);
+ if (done) {
+ float angle;
- /* calculate rotation */
- unit_m3(mat);
- if (done) {
- float angle;
+ normalize_v3_v3(vec, ofs);
- normalize_v3_v3(vec, ofs);
+ angle = angle_normalized_v3v3(vec, nor);
- angle = angle_normalized_v3v3(vec, nor);
+ if (angle != 0.0f) {
+ float axis[3];
- if (angle != 0.0f) {
- float axis[3];
+ cross_v3_v3v3(axis, nor, vec);
- cross_v3_v3v3(axis, nor, vec);
+ /* halve the rotation if its applied twice */
+ if (rot_src) {
+ angle *= 0.5f;
+ }
- /* halve the rotation if its applied twice */
- if (rot_src) {
- angle *= 0.5f;
+ axis_angle_to_mat3(mat, axis, angle);
}
+ }
+
+ if (rot_src) {
+ EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3",
+ BM_ELEM_SELECT, local_center, mat);
- axis_angle_to_mat3(mat, axis, angle);
+ /* also project the source, for retopo workflow */
+ if (use_proj) {
+ EDBM_project_snap_verts(C, vc.ar, vc.em);
+ }
}
- }
- edbm_extrude_ex(vc.obedit, vc.em, extrude_htype, BM_ELEM_SELECT, true, true);
- if (rot_src) {
++ edbm_extrude_ex(vc.obedit, vc.em, extrude_htype, BM_ELEM_SELECT, false, true, true);
EDBM_op_callf(vc.em, op, "rotate
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list