[Bf-blender-cvs] [dbea6c3507a] sculpt-mode-features: Fix symmetry in pose brush, add radius preview.

Pablo Dobarro noreply at git.blender.org
Wed Aug 28 14:21:25 CEST 2019


Commit: dbea6c3507a0a94118429b012b3d088de7b0c26d
Author: Pablo Dobarro
Date:   Wed Aug 28 14:21:27 2019 +0200
Branches: sculpt-mode-features
https://developer.blender.org/rBdbea6c3507a0a94118429b012b3d088de7b0c26d

Fix symmetry in pose brush, add radius preview.

===================================================================

M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 8b010991e65..c49176d97dc 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1355,7 +1355,6 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
         quat_to_mat4(cursor_rot_mat4, quat);
 
         GPU_matrix_push_projection();
-        GPU_matrix_push();
         ED_view3d_draw_setup_view(CTX_wm_window(C),
                                   CTX_data_depsgraph_pointer(C),
                                   CTX_data_scene(C),
@@ -1364,6 +1363,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
                                   NULL,
                                   NULL,
                                   NULL);
+        GPU_matrix_push();
 
         if (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush->flag2 & BRUSH_GRAB_ACTIVE_VERTEX) {
           if (vc.obact->sculpt) {
@@ -1381,8 +1381,30 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
         immUniformColor3fvAlpha(outline_col, outline_alpha);
         imm_draw_circle_wire_3d(pos3d, 0, 0, rds, 40);
         GPU_matrix_pop();
-        GPU_matrix_pop_projection();
 
+        if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
+          float mat[3][3];
+          float viewNormal[3];
+          float viewDir[3] = {0.0f, 0.0f, 1.0f};
+
+          invert_m4_m4(vc.obact->imat, vc.obact->obmat);
+          copy_m3_m4(mat, vc.rv3d->viewinv);
+          mul_m3_v3(mat, viewDir);
+          copy_m3_m4(mat, vc.obact->imat);
+          mul_m3_v3(mat, viewDir);
+          normalize_v3_v3(viewNormal, viewDir);
+
+          GPU_matrix_push();
+          GPU_matrix_mul(cursor_mat4);
+          GPU_line_width(1.0f);
+          rotation_between_vecs_to_quat(quat, z_axis, viewNormal);
+          quat_to_mat4(cursor_rot_mat4, quat);
+          GPU_matrix_mul(cursor_rot_mat4);
+          imm_draw_circle_wire_3d(pos3d, 0, 0, rds, 40);
+          GPU_matrix_pop();
+        }
+
+        GPU_matrix_pop_projection();
         wmWindowViewport(win);
       }
       else {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 0284f0f6c9c..c190853d967 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -6616,7 +6616,8 @@ bool sculpt_stroke_get_geometry_info(bContext *C, StrokeGeometryInfo *out, const
   Object *ob;
   SculptSession *ss;
   float ray_start[3], ray_end[3], ray_normal[3], depth, face_normal[3], sampled_normal[3],
-      viewDir[3], mat[3][3];
+      mat[3][3];
+  float viewDir[3] = {0.0f, 0.0f, 1.0f};
   float nearest_vetex_co[3] = {0.0f};
   int totnode;
   bool original = false, hit = false;
@@ -9724,16 +9725,21 @@ EnumPropertyItem prop_sculpt_pivot_position_types[] = {
 
 static bool check_vertex_pivot_symmetry(float vco[3], float pco[3], char symm)
 {
+  bool is_in_symmetry_area = true;
   for (int i = 0; i < 3; i++) {
     char symm_it = 1 << i;
     if (symm & symm_it) {
       if (pco[i] == 0.0f) {
-        return vco[i] < 0.0f;
+        if (vco[i] > 0.0f) {
+          is_in_symmetry_area = false;
+        }
+      }
+      if (vco[i] * pco[i] < 0.0f) {
+        is_in_symmetry_area = false;
       }
-      return vco[i] * pco[i] >= 0.0f;
     }
   }
-  return true;
+  return is_in_symmetry_area;
 }
 
 static int sculpt_set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent *event)



More information about the Bf-blender-cvs mailing list