[Bf-blender-cvs] [604bd8799e8] soc-2017-normal-tools: Added snapping to rotate normal.
Rohan Rathi
noreply at git.blender.org
Tue Jul 18 15:12:02 CEST 2017
Commit: 604bd8799e88960bb3472178f25c4f3889b0c791
Author: Rohan Rathi
Date: Tue Jul 18 18:40:50 2017 +0530
Branches: soc-2017-normal-tools
https://developer.blender.org/rB604bd8799e88960bb3472178f25c4f3889b0c791
Added snapping to rotate normal.
Also added a ui function to point_normals which allows easier editing by creating a sphere box. Shown when align is enabled.
===================================================================
M release/datafiles/locale
M source/blender/editors/mesh/editmesh_tools.c
M source/blender/editors/transform/transform.c
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index c93ed11a47b..92f4a9d9f81 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit c93ed11a47b3016cf59711ec16de2e2e94c30e99
+Subproject commit 92f4a9d9f81d6de6f2b8d1d8531c298e8cc455f2
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index e915b30791e..e2ac9552c32 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -6294,15 +6294,7 @@ static int edbm_point_normals_exec(bContext *C, wmOperator *op)
BMIter viter;
int i = 0;
- zero_v3(center);
- BM_ITER_MESH(v, &viter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- add_v3_v3(center, v->co);
- i++;
- }
- }
- mul_v3_fl(center, 1.0f / (float)i);
-
+ copy_v3_v3(center, obedit->loc);
for (i = 0; i < ld->totloop; i++, t++) {
t->loc = center;
}
@@ -6310,7 +6302,6 @@ static int edbm_point_normals_exec(bContext *C, wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "target_location");
RNA_property_float_get_array(op->ptr, prop, target);
-
apply_point_normals(C, op, NULL, target);
EDBM_update_generic(em, true, false);
@@ -6319,6 +6310,31 @@ static int edbm_point_normals_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static void edbm_point_normals_ui(bContext *UNUSED(C), wmOperator *op)
+{
+ uiLayout *layout = op->layout, *row, *col;
+ PointerRNA ptr;
+
+ const bool align = RNA_boolean_get(op->ptr, "align");
+
+ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+
+ uiItemR(layout, &ptr, "point_away", 0, NULL, ICON_NONE);
+
+ uiItemR(layout, &ptr, "align", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(layout, false);
+
+ if (align) {
+ col = uiLayoutColumn(row, false);
+ uiItemR(col, &ptr, "target_location", UI_ITEM_R_EXPAND, "", ICON_NONE);
+ uiItemR(row, &ptr, "target_location", 0, "", ICON_NONE);
+ }
+ else {
+ col = uiLayoutColumn(layout, false);
+ uiItemR(col, &ptr, "target_location", UI_ITEM_R_EXPAND, "", ICON_NONE);
+ }
+}
+
void MESH_OT_point_normals(struct wmOperatorType *ot)
{
/* identifiers */
@@ -6330,6 +6346,7 @@ void MESH_OT_point_normals(struct wmOperatorType *ot)
ot->exec = edbm_point_normals_exec;
ot->invoke = edbm_point_normals_invoke;
ot->modal = edbm_point_normals_modal;
+ ot->ui = edbm_point_normals_ui;
ot->poll = ED_operator_editmesh_auto_smooth;
/* flags */
@@ -6342,9 +6359,10 @@ void MESH_OT_point_normals(struct wmOperatorType *ot)
prop = RNA_def_boolean(ot->srna, "align", false, "Align", "Align normal with mouse location");
RNA_def_property_flag(prop, PROP_HIDDEN);
- prop = RNA_def_property(ot->srna, "target_location", PROP_FLOAT, PROP_XYZ);
+ prop = RNA_def_property(ot->srna, "target_location", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_array(prop, 3);
- RNA_def_property_ui_text(prop, "Target Location", "Target location where normals will point");
+ RNA_def_property_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Target", "Target location where normals will point");
}
/********************** Split/Merge Loop Normals **********************/
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 0088ca51338..50a68f439fc 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -4267,6 +4267,13 @@ static void initNormalRotation(TransInfo *t)
setInputPostFct(&t->mouse, postInputRotation);
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
+ t->idx_max = 0;
+ t->num.idx_max = 0;
+ t->snap[0] = 0.0f;
+ t->snap[1] = DEG2RAD(5.0);
+ t->snap[2] = DEG2RAD(1.0);
+
+ copy_v3_fl(t->num.val_inc, t->snap[2]);
t->num.unit_sys = t->scene->unit.system;
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
@@ -4307,6 +4314,10 @@ static void applyNormalRotation(TransInfo *t, const int mval[2])
float angle = t->values[0];
copy_v3_v3(axis, t->axis);
+ snapGridIncrement(t, &angle);
+
+ applySnapping(t, &angle);
+
applyNumInput(&t->num, &angle);
headerRotation(t, str, angle);
More information about the Bf-blender-cvs
mailing list