[Bf-blender-cvs] [8d284d48544] retopo_transform: merged in master

jon denning noreply at git.blender.org
Sat Jul 16 13:00:39 CEST 2022


Commit: 8d284d485447984089c3494b8eb69e9c3ea60553
Author: jon denning
Date:   Tue Jul 5 17:01:42 2022 -0400
Branches: retopo_transform
https://developer.blender.org/rB8d284d485447984089c3494b8eb69e9c3ea60553

merged in master

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



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

diff --cc release/scripts/startup/bl_ui/space_view3d.py
index 869748a6452,5a38c4175a8..6b932e3df24
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@@ -6781,19 -6830,33 +6833,41 @@@ class VIEW3D_PT_snapping(Panel)
                  row.prop(tool_settings, "snap_target", expand=True)
  
              if obj:
 +                show_target_options = object_mode == 'EDIT' and obj.type not in {'LATTICE', 'META', 'FONT'}
                  col.label(text="Target Selection")
                  col_targetsel = col.column(align=True)
 -                if object_mode == 'EDIT' and obj.type not in {'LATTICE', 'META', 'FONT'}:
 +                if show_target_options:
-                     # active_use_self = True
-                     # active_use_self &= not (tool_settings.use_proportional_edit and obj.type == 'MESH')
-                     # active_use_self &= tool_settings.use_snap_edit
-                     col_targetsel.prop(tool_settings, "use_snap_self", text="Include Active", icon='EDITMODE_HLT')
-                     col_targetsel.prop(tool_settings, "use_snap_edit", text="Include Edited", icon='OUTLINER_DATA_MESH')
-                     col_targetsel.prop(tool_settings, "use_snap_nonedit", text="Include Non-Edited", icon='OUTLINER_OB_MESH')
-                 col_targetsel.prop(tool_settings, "use_snap_selectable", text="Exclude Non-Selectable", icon='RESTRICT_SELECT_OFF')
+                     col_targetsel.prop(
+                         tool_settings,
+                         "use_snap_self",
+                         text="Include Active",
+                         icon='EDITMODE_HLT',
+                     )
+                     col_targetsel.prop(
+                         tool_settings,
+                         "use_snap_edit",
+                         text="Include Edited",
+                         icon='OUTLINER_DATA_MESH',
+                     )
+                     col_targetsel.prop(
+                         tool_settings,
+                         "use_snap_nonedit",
+                         text="Include Non-Edited",
+                         icon='OUTLINER_OB_MESH',
+                     )
+                 col_targetsel.prop(
+                     tool_settings,
+                     "use_snap_selectable",
+                     text="Exclude Non-Selectable",
+                     icon='RESTRICT_SELECT_OFF',
+                 )
 +                if show_target_options:
-                     col_targetsel.prop(tool_settings, "use_snap_retopology_mode", text="Use Retopology Mode", icon='MOD_MESHDEFORM')
++                    col_targetsel.prop(
++                        tool_settings,
++                        "use_snap_retopology_mode",
++                        text="Use Retopology Mode",
++                        icon='MOD_MESHDEFORM',
++                    )
  
                  if object_mode in {'OBJECT', 'POSE', 'EDIT', 'WEIGHT_PAINT'}:
                      col.prop(tool_settings, "use_snap_align_rotation")
diff --cc source/blender/editors/transform/transform_snap.c
index ff65f78742a,22d062a71dc..e7556c23888
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@@ -128,12 -128,11 +128,11 @@@ bool activeSnap(const TransInfo *t
  
  bool activeSnap_SnappingIndividual(const TransInfo *t)
  {
-   if (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST) {
-     // Face Nearest snapping always snaps individual vertices
 -  if (activeSnap(t) && t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST) {
++  if (activeSnap(t) && (t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST)) {
      return true;
    }
  
-   if (t->tsnap.mode & SCE_SNAP_MODE_FACE_RAYCAST && !t->tsnap.project) {
 -  if (!t->tsnap.project) {
++  if ((t->tsnap.mode & SCE_SNAP_MODE_FACE_RAYCAST) && !t->tsnap.project) {
      return false;
    }
  
@@@ -511,13 -509,10 +509,14 @@@ void applySnappingIndividual(TransInfo 
          continue;
        }
  
 -      /* If both face ray-cast and face nearest methods are enabled, start with face ray-cast and
 -       * fallback to face nearest ray-cast does not hit. */
 -      bool hit = applyFaceProject(t, tc, td);
 +      /* If both face raycast and face nearest methods are enabled, start with face raycast and
 +       * fallback to face nearest raycast does not hit. */
 +      bool hit = false;
-       if (t->tsnap.flag & SCE_SNAP_PROJECT && t->tsnap.mode & SCE_SNAP_MODE_FACE_RAYCAST) {
-         hit = applyFaceProject_Individual(t, tc, td);
++      if (t->tsnap.flag & SCE_SNAP_PROJECT) {
++        /* Only raycast in this function if projecting individual elements. */
++        hit = applyFaceProject(t, tc, td);
 +      }
-       if (!hit && t->tsnap.mode & SCE_SNAP_MODE_FACE_NEAREST) {
+       if (!hit) {
          applyFaceNearest(t, tc, td);
        }
  #if 0 /* TODO: support this? */
@@@ -942,25 -926,21 +938,25 @@@ void initSnapping(TransInfo *t, wmOpera
        t->modifiers |= MOD_SNAP;
      }
  
 +    t->tsnap.target_select = SCE_SNAP_TARGET_ALL;
      t->tsnap.align = ((t->tsnap.flag & SCE_SNAP_ROTATE) != 0);
      t->tsnap.project = ((t->tsnap.flag & SCE_SNAP_PROJECT) != 0);
+     t->tsnap.peel = ((t->tsnap.flag & SCE_SNAP_PROJECT) != 0);
      SET_FLAG_FROM_TEST(t->tsnap.target_select,
-                        (t->settings->snap_flag & SCE_SNAP_NOT_TO_ACTIVE),
+                        (ts->snap_flag & SCE_SNAP_NOT_TO_ACTIVE),
                         SCE_SNAP_TARGET_NOT_ACTIVE);
      SET_FLAG_FROM_TEST(t->tsnap.target_select,
-                        !(t->settings->snap_flag & SCE_SNAP_TO_INCLUDE_EDITED),
+                        !(ts->snap_flag & SCE_SNAP_TO_INCLUDE_EDITED),
                         SCE_SNAP_TARGET_NOT_EDITED);
      SET_FLAG_FROM_TEST(t->tsnap.target_select,
-                        !(t->settings->snap_flag & SCE_SNAP_TO_INCLUDE_NONEDITED),
+                        !(ts->snap_flag & SCE_SNAP_TO_INCLUDE_NONEDITED),
                         SCE_SNAP_TARGET_NOT_NONEDITED);
      SET_FLAG_FROM_TEST(t->tsnap.target_select,
-                        (t->settings->snap_flag & SCE_SNAP_TO_ONLY_SELECTABLE),
+                        (ts->snap_flag & SCE_SNAP_TO_ONLY_SELECTABLE),
                         SCE_SNAP_TARGET_ONLY_SELECTABLE);
 +    SET_FLAG_FROM_TEST(t->tsnap.target_select,
 +                       (t->settings->snap_flag & SCE_SNAP_RETOPOLOGY_MODE),
 +                       SCE_SNAP_TARGET_RETOPOLOGY_MODE);
-     t->tsnap.peel = ((t->tsnap.flag & SCE_SNAP_PROJECT) != 0);
    }
  
    t->tsnap.source_select = snap_source;
diff --cc source/blender/editors/transform/transform_snap_object.cc
index 2bb39abfe25,817474f795e..cb121c0e547
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@@ -1296,9 -1272,9 +1296,9 @@@ static bool nearest_world_tree(SnapObje
          tree, nearest_cb, treedata, init_co_local, nullptr, nullptr, nullptr, &dist_sq);
    }
    else {
-     /* Note: when params->face_nearest_steps == 1, the return variables of function below contain
-      * the answer.  We could return immediately after updating r_loc, r_no, r_index, but that would
-      * also complicate the code.  Foregoing slight optimization for code clarity. */
+     /* NOTE: when `params->face_nearest_steps == 1`, the return variables of function below contain
 -     * the answer.  We could return immediately after updating r_loc, r_no, r_index, but that would
 -     * also complicate the code. Foregoing slight optimization for code clarity. */
++     * the answer.  We could return immediately after updating 'r_loc', 'r_no', 'r_index', but that
++     * would also complicate the code. Foregoing slight optimization for code clarity. */
      nearest_world_tree_co(
          tree, nearest_cb, treedata, curr_co_local, nullptr, nullptr, nullptr, &dist_sq);
    }
@@@ -1408,18 -1384,6 +1408,12 @@@ static void nearest_world_object_fn(Sna
  {
    struct NearestWorldObjUserData *dt = static_cast<NearestWorldObjUserData *>(data);
  
 +  const bool use_retopo_mode = params->snap_target_select & SCE_SNAP_TARGET_RETOPOLOGY_MODE;
 +  const bool is_object_edited = BKE_object_is_in_editmode(ob_eval);
-   /* TODO(gfxcoder): removed debug print */
-   printf("nearest_world_object_fn: obj:%s retopo:%s edit:%s\n",
-          ob_eval->id.name,
-          use_retopo_mode ? "t" : "f",
-          is_object_edited ? "t" : "f");
 +  if (use_retopo_mode && is_object_edited) {
-     printf("  skipped\n");
 +    return;
 +  }
 +
    bool retval = false;
    switch (ob_eval->type) {
      case OB_MESH: {
@@@ -3460,13 -3399,33 +3449,38 @@@ static eSnapMode transform_snap_context
  
    const RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
  
 -  bool use_occlusion_test = params->use_occlusion_test && !XRAY_ENABLED(v3d);
 +  const bool use_retopo_mode = params->snap_target_select & SCE_SNAP_TARGET_RETOPOLOGY_MODE;
 +  const bool use_occlusion_test = params->use_occlusion_test && !XRAY_ENABLED(v3d);
 +
 +  /* TODO(gfxcoder): removed debug print */
 +  printf("--- transform_snap_context_project_view3d_mixed_impl occlusion:%s ---\n",
 +         use_occlusion_test ? "t" : "f");
  
+   /* Note: if both face raycast and face nearest are enabled, first find result of nearest, then
+    * override with raycast. */
+   if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && !has_hit) {
+     has_hit = nearestWorldObjects(
+         sctx, params, init_co, prev_co, loc, no, &index, &ob_eval, obmat);
+ 
+     if (has_hit) {
+       retval = SCE_SNAP_MODE_FACE_NEAREST;
+ 
+       copy_v3_v3(r_loc, loc);
+       if (r_no) {
+         copy_v3_v3(r_no, no);
+       }
+       if (r_ob) {
+         *r_ob = ob_eval;
+       }
+       if (r_obmat) {
+         copy_m4_m4(r_obmat, obmat);
+       }
+       if (r_index) {
+         *r_index = index;
+       }
+     }
+   }
+ 
    if (snap_to_flag & SCE_SNAP_MODE_FACE_RAYCAST || use_occlusion_test) {
      float ray_start[3], ray_normal[3];
      if (!ED_view3d_win_to_ray_clipped_ex(



More information about the Bf-blender-cvs mailing list