[Bf-blender-cvs] [a38d99e0b28] master: Fix (unreported): Transform gizmo not restoring when changing mode

2023-02-06 Thread Germano Cavalcante
Commit: a38d99e0b2893653c2622de1aa2423a309889a36
Author: Germano Cavalcante
Date:   Mon Feb 6 16:17:26 2023 -0300
Branches: master
https://developer.blender.org/rBa38d99e0b2893653c2622de1aa2423a309889a36

Fix (unreported): Transform gizmo not restoring when changing mode

When activating a rotation with the Transform gizmo for example, some
gizmos are hidden but they don't reappear when changing the mode.

Make sure the gizmos corresponding to the mode always reappear.

===

M   source/blender/editors/transform/transform_gizmo_3d.c

===

diff --git a/source/blender/editors/transform/transform_gizmo_3d.c 
b/source/blender/editors/transform/transform_gizmo_3d.c
index 42f7336cec1..abde9b2bb5d 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1081,7 +1081,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
   return totsel;
 }
 
-static void gizmo_get_idot(RegionView3D *rv3d, float r_idot[3])
+static void gizmo_get_idot(const RegionView3D *rv3d, float r_idot[3])
 {
   float view_vec[3], axis_vec[3];
   ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec);
@@ -2016,6 +2016,31 @@ static void gizmo_3d_draw_invoke(wmGizmoGroup *gzgroup,
 WM_gizmo_set_flag(axis_active, WM_GIZMO_HIDDEN, false);
 WM_gizmo_set_flag(ggd->gizmos[MAN_AXIS_ROT_C], WM_GIZMO_HIDDEN, false);
   }
+  else {
+/* We switch from a modal gizmo to another. So make sure the gizmos are 
visible and have the
+ * default properties. */
+
+const int twtype_expected = (axis_active_type == MAN_AXES_TRANSLATE ?
+ V3D_GIZMO_SHOW_OBJECT_TRANSLATE :
+ V3D_GIZMO_SHOW_OBJECT_SCALE);
+
+const int twtype = (ggd->twtype & twtype_expected) ? ggd->twtype : 
twtype_expected;
+
+float idot[3];
+gizmo_get_idot(rv3d, idot);
+MAN_ITER_AXES_BEGIN (axis, axis_idx) {
+  const short axis_type = gizmo_get_axis_type(axis_idx);
+  if (gizmo_is_axis_visible(rv3d, twtype, idot, axis_type, axis_idx)) {
+WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, false);
+gizmo_3d_setup_draw_default(axis, axis_idx);
+gizmo_3d_setup_draw_from_twtype(axis, axis_idx, twtype);
+  }
+  else {
+WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, true);
+  }
+}
+MAN_ITER_AXES_END;
+  }
 
   MAN_ITER_AXES_BEGIN (axis, axis_idx) {
 if (axis->flag & WM_GIZMO_HIDDEN) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [deaddbdcff2] master: Fix forced snap status being removed when changing transform mode

2023-02-06 Thread Germano Cavalcante
Commit: deaddbdcff2ac555429296b32ea632036edd6cb0
Author: Germano Cavalcante
Date:   Mon Feb 6 11:04:07 2023 -0300
Branches: master
https://developer.blender.org/rBdeaddbdcff2ac555429296b32ea632036edd6cb0

Fix forced snap status being removed when changing transform mode

The `SNAP_FORCED` setting is set to the operation and not the snap
status.

Therefore, this option should not be cleared along with the other
statuses when resetting snapping.

Move then the location of this setting to `TransInfo::modifiers`.

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform.h
M   source/blender/editors/transform/transform_snap.cc

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 7f16a5796ba..d05c78ff993 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1589,7 +1589,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 /* Update `ToolSettings` for properties that change during modal. */
 if (t->flag & T_MODAL) {
   /* Do we check for parameter? */
-  if (transformModeUseSnap(t) && !(t->tsnap.status & SNAP_FORCED)) {
+  if (transformModeUseSnap(t) && !(t->modifiers & MOD_SNAP_FORCED)) {
 if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) {
   /* Type is #eSnapFlag, but type must match various snap attributes 
in #ToolSettings. */
   short *snap_flag_ptr;
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 08f560d16e9..d548cf631f1 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -155,18 +155,18 @@ typedef enum {
   MOD_SNAP_INVERT = 1 << 3,
   MOD_CONSTRAINT_SELECT_PLANE = 1 << 4,
   MOD_NODE_ATTACH = 1 << 5,
+  MOD_SNAP_FORCED = 1 << 6,
 } eTModifier;
 ENUM_OPERATORS(eTModifier, MOD_NODE_ATTACH)
 
 /** #TransSnap.status */
 typedef enum eTSnap {
   SNAP_RESETTED = 0,
-  SNAP_FORCED = 1 << 0,
-  SNAP_SOURCE_FOUND = 1 << 1,
+  SNAP_SOURCE_FOUND = 1 << 0,
   /* Special flag for snap to grid. */
-  SNAP_TARGET_GRID_FOUND = 1 << 2,
-  SNAP_TARGET_FOUND = 1 << 3,
-  SNAP_MULTI_POINTS = 1 << 4,
+  SNAP_TARGET_GRID_FOUND = 1 << 1,
+  SNAP_TARGET_FOUND = 1 << 2,
+  SNAP_MULTI_POINTS = 1 << 3,
 } eTSnap;
 ENUM_OPERATORS(eTSnap, SNAP_MULTI_POINTS)
 
diff --git a/source/blender/editors/transform/transform_snap.cc 
b/source/blender/editors/transform/transform_snap.cc
index 8a1cb2d9788..425f97a23f4 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -147,7 +147,7 @@ bool transformModeUseSnap(const TransInfo *t)
 
 static bool doForceIncrementSnap(const TransInfo *t)
 {
-  if (t->tsnap.status & SNAP_FORCED) {
+  if (t->modifiers & MOD_SNAP_FORCED) {
 return false;
   }
 
@@ -808,7 +808,8 @@ void initSnapping(TransInfo *t, wmOperator *op)
   if ((prop = RNA_struct_find_property(op->ptr, "snap_point")) &&
   RNA_property_is_set(op->ptr, prop)) {
 RNA_property_float_get_array(op->ptr, prop, t->tsnap.snap_target);
-t->tsnap.status |= SNAP_FORCED | SNAP_TARGET_FOUND;
+t->modifiers |= MOD_SNAP_FORCED;
+t->tsnap.status |= SNAP_TARGET_FOUND;
   }
 
   /* snap align only defined in specific cases */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cc623ee7b0f] master: Transform: do not save settings when canceling the operation

2023-02-06 Thread Germano Cavalcante
Commit: cc623ee7b0fc5daf1811c096dd065e481ff3bd6d
Author: Germano Cavalcante
Date:   Mon Feb 6 11:17:14 2023 -0300
Branches: master
https://developer.blender.org/rBcc623ee7b0fc5daf1811c096dd065e481ff3bd6d

Transform: do not save settings when canceling the operation

If we are canceling, the settings must remain the same as before we
start the operation.

===

M   source/blender/editors/transform/transform.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index d05c78ff993..3c95d480b78 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1484,6 +1484,12 @@ static void drawTransformPixel(const struct bContext *C, 
ARegion *region, void *
 
 void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 {
+  if (t->state == TRANS_CANCEL) {
+/* No need to edit operator properties or tool settings if we are 
canceling the operation.
+ * These properties must match the original ones. */
+return;
+  }
+
   ToolSettings *ts = CTX_data_tool_settings(C);
   PropertyRNA *prop;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7beb487e9ad] master: Fix T104353: Crash on opening sculpting template

2023-02-06 Thread Germano Cavalcante
Commit: 7beb487e9ad1908c8a67ae7caf46e462c2ac611a
Author: Germano Cavalcante
Date:   Mon Feb 6 09:20:20 2023 -0300
Branches: master
https://developer.blender.org/rB7beb487e9ad1908c8a67ae7caf46e462c2ac611a

Fix T104353: Crash on opening sculpting template

`t->region` was `NULL`.

It can happen depending on the context.

Caused by rB19b63b932d2b.

===

M   source/blender/editors/transform/transform_gizmo_3d.c

===

diff --git a/source/blender/editors/transform/transform_gizmo_3d.c 
b/source/blender/editors/transform/transform_gizmo_3d.c
index 306502ab3bc..42f7336cec1 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -2688,7 +2688,7 @@ static wmGizmoGroup *gizmogroup_xform_find(TransInfo *t)
 
 void transform_gizmo_3d_model_from_constraint_and_mode_init(TransInfo *t)
 {
-  wmGizmo *gizmo_modal_current = WM_gizmomap_get_modal(t->region->gizmo_map);
+  wmGizmo *gizmo_modal_current = t->region ? 
WM_gizmomap_get_modal(t->region->gizmo_map) : NULL;
   if (!gizmo_modal_current || !ELEM(gizmo_modal_current->parent_gzgroup->type,
 g_GGT_xform_gizmo,
 g_GGT_xform_gizmo_context)) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [62fc0019791] master: Cleanup: silence warning

2023-02-03 Thread Germano Cavalcante
Commit: 62fc0019791c965ac668b7f50ea58d4d6665d32f
Author: Germano Cavalcante
Date:   Sat Feb 4 00:16:02 2023 -0300
Branches: master
https://developer.blender.org/rB62fc0019791c965ac668b7f50ea58d4d6665d32f

Cleanup: silence warning

```
warning C4457: declaration of 'fac' hides function parameter
message : see declaration of 'fac'
```

===

M   source/blender/editors/transform/transform_mode_edge_slide.c

===

diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c 
b/source/blender/editors/transform/transform_mode_edge_slide.c
index df081180118..3fcb56944d7 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -1375,16 +1375,16 @@ static void edge_slide_apply_elem(const 
TransDataEdgeSlideVert *sv,
  */
 if (sv->edge_len > FLT_EPSILON) {
   float co_a[3], co_b[3];
-  const float fac = min_ff(sv->edge_len, curr_length_fac) / sv->edge_len;
+  const float fac_final = min_ff(sv->edge_len, curr_length_fac) / 
sv->edge_len;
 
   add_v3_v3v3(co_a, sv->v_co_orig, sv->dir_side[0]);
   add_v3_v3v3(co_b, sv->v_co_orig, sv->dir_side[1]);
 
   if (use_flip) {
-interp_line_v3_v3v3v3(r_co, co_b, sv->v_co_orig, co_a, fac);
+interp_line_v3_v3v3v3(r_co, co_b, sv->v_co_orig, co_a, fac_final);
   }
   else {
-interp_line_v3_v3v3v3(r_co, co_a, sv->v_co_orig, co_b, fac);
+interp_line_v3_v3v3v3(r_co, co_a, sv->v_co_orig, co_b, fac_final);
   }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [06305e5ca80] master: Cleanup/refactor: split Edge and Vert Slide code into more specific functions

2023-02-03 Thread Germano Cavalcante
Commit: 06305e5ca800c048c69f18a24951f4bc87305610
Author: Germano Cavalcante
Date:   Fri Feb 3 11:29:16 2023 -0300
Branches: master
https://developer.blender.org/rB06305e5ca800c048c69f18a24951f4bc87305610

Cleanup/refactor: split Edge and Vert Slide code into more specific functions

This makes the code more readable.

In this commit also the `int curr_side_unclamp` member was moved to
`EdgeSlideParams` as it is a common value for all "Containers".

===

M   source/blender/editors/transform/transform_mode_edge_slide.c
M   source/blender/editors/transform/transform_mode_vert_slide.c

===

diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c 
b/source/blender/editors/transform/transform_mode_edge_slide.c
index f2ba8c4bd4d..df081180118 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -66,14 +66,14 @@ typedef struct EdgeSlideData {
 
   int mval_start[2], mval_end[2];
   int curr_sv_index;
-
-  /** when un-clamped - use this index: #TransDataEdgeSlideVert.dir_side */
-  int curr_side_unclamp;
 } EdgeSlideData;
 
 typedef struct EdgeSlideParams {
   float perc;
 
+  /** when un-clamped - use this index: #TransDataEdgeSlideVert.dir_side */
+  int curr_side_unclamp;
+
   bool use_even;
   bool flipped;
 } EdgeSlideParams;
@@ -1198,7 +1198,7 @@ void drawEdgeSlide(TransInfo *t)
 immEnd();
   }
   else if (is_clamp == false) {
-const int side_index = sld->curr_side_unclamp;
+const int side_index = slp->curr_side_unclamp;
 TransDataEdgeSlideVert *sv;
 int i;
 const int alpha_shade = -160;
@@ -1235,7 +1235,7 @@ void drawEdgeSlide(TransInfo *t)
 const int alpha_shade = -160;
 
 float co_dir[3];
-add_v3_v3v3(co_dir, curr_sv->v_co_orig, 
curr_sv->dir_side[sld->curr_side_unclamp]);
+add_v3_v3v3(co_dir, curr_sv->v_co_orig, 
curr_sv->dir_side[slp->curr_side_unclamp]);
 
 GPU_line_width(line_size);
 immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
@@ -1284,7 +1284,7 @@ static void edge_slide_snap_apply(TransInfo *t, float 
*value)
   side_index = perc < 0.0f;
 }
 else {
-  side_index = sld_active->curr_side_unclamp;
+  side_index = slp->curr_side_unclamp;
 }
   }
   else {
@@ -1336,57 +1336,30 @@ static void edge_slide_snap_apply(TransInfo *t, float 
*value)
   *value = perc;
 }
 
-static void doEdgeSlide(TransInfo *t, float perc)
+static void edge_slide_apply_elem(const TransDataEdgeSlideVert *sv,
+  const float fac,
+  const float curr_length_fac,
+  const int curr_side_unclamp,
+  const bool use_clamp,
+  const bool use_even,
+  const bool use_flip,
+  float r_co[3])
 {
-  EdgeSlideParams *slp = t->custom.mode.data;
-  EdgeSlideData *sld_active = edgeSlideFirstGet(t);
-
-  slp->perc = perc;
+  copy_v3_v3(r_co, sv->v_co_orig);
 
-  if (slp->use_even == false) {
-const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
-if (is_clamp) {
-  const int side_index = (perc < 0.0f);
-  const float perc_final = fabsf(perc);
-  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
-EdgeSlideData *sld = tc->custom.mode.data;
-
-if (sld == NULL) {
-  continue;
-}
-
-TransDataEdgeSlideVert *sv = sld->sv;
-for (int i = 0; i < sld->totsv; i++, sv++) {
-  madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, sv->dir_side[side_index], 
perc_final);
-}
-sld->curr_side_unclamp = side_index;
-  }
+  if (use_even == false) {
+if (use_clamp) {
+  const int side_index = (fac < 0.0f);
+  const float fac_final = fabsf(fac);
+  madd_v3_v3fl(r_co, sv->dir_side[side_index], fac_final);
 }
 else {
-  const float perc_init = fabsf(perc) *
-  ((sld_active->curr_side_unclamp == (perc < 
0.0f)) ? 1 : -1);
-  const int side_index = sld_active->curr_side_unclamp;
-  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
-EdgeSlideData *sld = tc->custom.mode.data;
-
-if (sld == NULL) {
-  continue;
-}
-
-TransDataEdgeSlideVert *sv = sld->sv;
-for (int i = 0; i < sld->totsv; i++, sv++) {
-  float dir_flip[3];
-  float perc_final = perc_init;
-  if (!is_zero_v3(sv->dir_side[side_index])) {
-copy_v3_v3(dir_flip, sv->dir_side[side_index]);
-  }
-  else {
-copy_v3_v3(dir_flip, sv->dir_side[!side_index]);
-perc_final *= -1;
-  }

[Bf-blender-cvs] [90f36fc50e1] master: Fix (unreported): snap to object origin not respecting clipping planes

2023-02-03 Thread Germano Cavalcante
Commit: 90f36fc50e1376e8575a379768cdd25a5882aa1b
Author: Germano Cavalcante
Date:   Fri Feb 3 17:16:25 2023 -0300
Branches: master
https://developer.blender.org/rB90f36fc50e1376e8575a379768cdd25a5882aa1b

Fix (unreported): snap to object origin not respecting clipping planes

There was an incorrect conversion for local clip planes although the
coordinates used are in world positions.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index ec41c2dd0dd..e81e37ef745 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -2390,31 +2390,26 @@ static eSnapMode snap_object_center(const 
SnapObjectContext *sctx,
   }
 
   /* for now only vertex supported */
-  if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) {
-DistProjectedAABBPrecalc neasrest_precalc;
-dist_squared_to_projected_aabb_precalc(
-_precalc, sctx->runtime.pmat, sctx->runtime.win_size, 
sctx->runtime.mval);
+  if ((sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) == 0) {
+return retval;
+  }
 
-float tobmat[4][4], clip_planes_local[MAX_CLIPPLANE_LEN][4];
-transpose_m4_m4(tobmat, obmat);
-for (int i = sctx->runtime.clip_plane_len; i--;) {
-  mul_v4_m4v4(clip_planes_local[i], tobmat, sctx->runtime.clip_plane[i]);
-}
-
-bool is_persp = sctx->runtime.view_proj == VIEW_PROJ_PERSP;
-float dist_px_sq = square_f(*dist_px);
-float co[3];
-copy_v3_v3(co, obmat[3]);
-if (test_projected_vert_dist(_precalc,
- clip_planes_local,
- sctx->runtime.clip_plane_len,
- is_persp,
- co,
- _px_sq,
- r_loc)) {
-  *dist_px = sqrtf(dist_px_sq);
-  retval = SCE_SNAP_MODE_VERTEX;
-}
+  DistProjectedAABBPrecalc neasrest_precalc;
+  dist_squared_to_projected_aabb_precalc(
+  _precalc, sctx->runtime.pmat, sctx->runtime.win_size, 
sctx->runtime.mval);
+
+  bool is_persp = sctx->runtime.view_proj == VIEW_PROJ_PERSP;
+  float dist_px_sq = square_f(*dist_px);
+
+  if (test_projected_vert_dist(_precalc,
+   sctx->runtime.clip_plane,
+   sctx->runtime.clip_plane_len,
+   is_persp,
+   obmat[3],
+   _px_sq,
+   r_loc)) {
+*dist_px = sqrtf(dist_px_sq);
+retval = SCE_SNAP_MODE_VERTEX;
   }
 
   if (retval) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [19b63b932d2] master: Fix transform gizmo not updating according to state

2023-02-03 Thread Germano Cavalcante
Commit: 19b63b932d2b799c7904ebaf59911aef4926dcbb
Author: Germano Cavalcante
Date:   Thu Jan 26 07:54:04 2023 -0300
Branches: master
https://developer.blender.org/rB19b63b932d2b799c7904ebaf59911aef4926dcbb

Fix transform gizmo not updating according to state

Whenever a transform operation is activated by gizmo, the gizmo
modal is maintained, but its drawing remains the same even if the
transform mode or constrain is changed.

So update the gizmo according to the mode or constrain set.

NOTE: Currently only 3D view gizmo is affected

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform.h
M   source/blender/editors/transform/transform_generics.c
M   source/blender/editors/transform/transform_gizmo_3d.c
M   source/blender/editors/transform/transform_mode.c
M   source/blender/windowmanager/gizmo/WM_gizmo_api.h
M   source/blender/windowmanager/gizmo/intern/wm_gizmo.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 3cff4c11cad..7f16a5796ba 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -862,6 +862,9 @@ static bool transform_event_modal_constraint(TransInfo *t, 
short modal_type)
 else {
   setUserConstraint(t, constraint_new, msg_3d);
 }
+
+/* Take the opportunity to update the gizmo. */
+transform_gizmo_3d_model_from_constraint_and_mode_set(t);
   }
   t->redraw |= TREDRAW_HARD;
   return true;
@@ -2057,6 +2060,8 @@ int transformEnd(bContext *C, TransInfo *t)
 viewRedrawPost(C, t);
 
 viewRedrawForce(C, t);
+
+transform_gizmo_3d_model_from_constraint_and_mode_restore(t);
   }
 
   t->context = NULL;
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 82ab9039db5..08f560d16e9 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -138,6 +138,9 @@ typedef enum {
 
   /** No cursor wrapping on region bounds */
   T_NO_CURSOR_WRAP = 1 << 23,
+
+  /** Do not display Xform gizmo even though it is available. */
+  T_NO_GIZMO = 1 << 24,
 } eTFlag;
 ENUM_OPERATORS(eTFlag, T_NO_CURSOR_WRAP);
 
@@ -734,6 +737,27 @@ void transform_final_value_get(const TransInfo *t, float 
*value, int value_num);
 bool gimbal_axis_pose(struct Object *ob, const struct bPoseChannel *pchan, 
float gmat[3][3]);
 bool gimbal_axis_object(struct Object *ob, float gmat[3][3]);
 
+/**
+ * Set the #T_NO_GIZMO flag.
+ *
+ * \note This maintains the conventional behavior of not displaying the gizmo 
if the operator has
+ * been triggered by shortcuts.
+ */
+void transform_gizmo_3d_model_from_constraint_and_mode_init(TransInfo *t);
+
+/**
+ * Change the gizmo and its orientation to match the transform state.
+ *
+ * \note This used while the modal operator is running so changes to the 
constraint or mode show
+ * the gizmo associated with that state, as if it had been the initial gizmo 
dragged.
+ */
+void transform_gizmo_3d_model_from_constraint_and_mode_set(TransInfo *t);
+
+/**
+ * Restores the non-modal state of the gizmo.
+ */
+void transform_gizmo_3d_model_from_constraint_and_mode_restore(TransInfo *t);
+
 /** \} */
 
 /*  */
diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index 53e346ee86a..d1f210ca772 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -640,6 +640,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 
   setTransformViewMatrices(t);
   initNumInput(>num);
+
+  transform_gizmo_3d_model_from_constraint_and_mode_init(t);
 }
 
 static void freeTransCustomData(TransInfo *t, TransDataContainer *tc, 
TransCustomData *custom_data)
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c 
b/source/blender/editors/transform/transform_gizmo_3d.c
index 28b39786bbc..306502ab3bc 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -70,9 +70,13 @@
 
 #include "GPU_state.h"
 
-static void gizmo_refresh_from_matrix(wmGizmoGroup *gzgroup,
-  const float twmat[4][4],
-  const float scale[3]);
+static wmGizmoGroupType *g_GGT_xform_gizmo = NULL;
+static wmGizmoGroupType *g_GGT_xform_gizmo_context = NULL;
+
+static void gizmogroup_refresh_from_matrix(wmGizmoGroup *gzgroup,
+   const float twmat[4][4],
+   const float scale[3],
+  

[Bf-blender-cvs] [9b86741ae75] master: FIx possible return of string without null character

2023-02-01 Thread Germano Cavalcante
Commit: 9b86741ae75ff6c697088b01773f94899f49ec10
Author: Germano Cavalcante
Date:   Wed Feb 1 15:29:21 2023 -0300
Branches: master
https://developer.blender.org/rB9b86741ae75ff6c697088b01773f94899f49ec10

FIx possible return of string without null character

`WM_modalkeymap_items_to_string` is expected to always return a string.

But in the special case of zero length, the returned string was not
terminated with `'\0'`.

This can cause problems with the header of the knife tool for example.
It always uses the returned string.

(This issue was observed when investigating T103804).

===

M   source/blender/windowmanager/intern/wm_keymap.c

===

diff --git a/source/blender/windowmanager/intern/wm_keymap.c 
b/source/blender/windowmanager/intern/wm_keymap.c
index 9e38884..f033a5d9970 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -1238,25 +1238,26 @@ int WM_modalkeymap_items_to_string(const wmKeyMap *km,
char *result,
const int result_len)
 {
+  BLI_assert(result_len > 0);
+
+  const wmKeyMapItem *kmi;
+  if (km == NULL || (kmi = WM_modalkeymap_find_propvalue(km, propvalue)) == 
NULL) {
+*result = '\0';
+return 0;
+  }
+
   int totlen = 0;
-  bool add_sep = false;
+  do {
+totlen += WM_keymap_item_to_string(kmi, compact, [totlen], 
result_len - totlen);
 
-  if (km) {
-const wmKeyMapItem *kmi;
-
-/* Find all shortcuts related to that propvalue! */
-for (kmi = WM_modalkeymap_find_propvalue(km, propvalue); kmi && totlen < 
(result_len - 2);
- kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue)) {
-  if (add_sep) {
-result[totlen++] = '/';
-result[totlen] = '\0';
-  }
-  else {
-add_sep = true;
-  }
-  totlen += WM_keymap_item_to_string(kmi, compact, [totlen], 
result_len - totlen);
+if ((kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue)) == NULL 
||
+totlen >= (result_len - 2)) {
+  break;
 }
-  }
+
+result[totlen++] = '/';
+result[totlen] = '\0';
+  } while (true);
 
   return totlen;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0050d6d3990] master: Cleanup: move function to file where it is used

2023-01-27 Thread Germano Cavalcante
Commit: 0050d6d39906649159a3d8f0bb95b3fc60dd2da7
Author: Germano Cavalcante
Date:   Fri Jan 27 14:10:43 2023 -0300
Branches: master
https://developer.blender.org/rB0050d6d39906649159a3d8f0bb95b3fc60dd2da7

Cleanup: move function to file where it is used

`drawLine` is only used for constraint, so it should be in
`transform_constraints.c`

===

M   source/blender/editors/transform/transform.h
M   source/blender/editors/transform/transform_constraints.c
M   source/blender/editors/transform/transform_generics.c

===

diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 637e4ef3b6e..82ab9039db5 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -809,8 +809,6 @@ void postTrans(struct bContext *C, TransInfo *t);
 void resetTransModal(TransInfo *t);
 void resetTransRestrictions(TransInfo *t);
 
-void drawLine(TransInfo *t, const float center[3], const float dir[3], char 
axis, short options);
-
 /* DRAWLINE options flags */
 #define DRAWLIGHT 1
 
diff --git a/source/blender/editors/transform/transform_constraints.c 
b/source/blender/editors/transform/transform_constraints.c
index f8e116e77b8..095c59f783b 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -735,6 +735,61 @@ void setUserConstraint(TransInfo *t, int mode, const char 
text_[])
 /** \name Drawing Constraints
  * \{ */
 
+static void drawLine(
+TransInfo *t, const float center[3], const float dir[3], char axis, short 
options)
+{
+  if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_SEQ)) {
+return;
+  }
+
+  float v1[3], v2[3], v3[3];
+  uchar col[3], col2[3];
+
+  if (t->spacetype == SPACE_VIEW3D) {
+View3D *v3d = t->view;
+
+copy_v3_v3(v3, dir);
+mul_v3_fl(v3, v3d->clip_end);
+
+sub_v3_v3v3(v2, center, v3);
+add_v3_v3v3(v1, center, v3);
+  }
+  else if (t->spacetype == SPACE_SEQ) {
+View2D *v2d = t->view;
+
+copy_v3_v3(v3, dir);
+float max_dist = max_ff(BLI_rctf_size_x(>cur), 
BLI_rctf_size_y(>cur));
+mul_v3_fl(v3, max_dist);
+
+sub_v3_v3v3(v2, center, v3);
+add_v3_v3v3(v1, center, v3);
+  }
+
+  GPU_matrix_push();
+
+  if (options & DRAWLIGHT) {
+col[0] = col[1] = col[2] = 220;
+  }
+  else {
+UI_GetThemeColor3ubv(TH_GRID, col);
+  }
+  UI_make_axis_color(col, col2, axis);
+
+  uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 
3, GPU_FETCH_FLOAT);
+
+  immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+  immUniformColor3ubv(col2);
+
+  immBegin(GPU_PRIM_LINES, 2);
+  immVertex3fv(pos, v1);
+  immVertex3fv(pos, v2);
+  immEnd();
+
+  immUnbindProgram();
+
+  GPU_matrix_pop();
+}
+
 void drawConstraint(TransInfo *t)
 {
   TransCon *tc = &(t->con);
diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index f09c919c8b7..53e346ee86a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -55,60 +55,6 @@
 
 /* ** GENERICS  */
 
-void drawLine(TransInfo *t, const float center[3], const float dir[3], char 
axis, short options)
-{
-  if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_SEQ)) {
-return;
-  }
-
-  float v1[3], v2[3], v3[3];
-  uchar col[3], col2[3];
-
-  if (t->spacetype == SPACE_VIEW3D) {
-View3D *v3d = t->view;
-
-copy_v3_v3(v3, dir);
-mul_v3_fl(v3, v3d->clip_end);
-
-sub_v3_v3v3(v2, center, v3);
-add_v3_v3v3(v1, center, v3);
-  }
-  else if (t->spacetype == SPACE_SEQ) {
-View2D *v2d = t->view;
-
-copy_v3_v3(v3, dir);
-float max_dist = max_ff(BLI_rctf_size_x(>cur), 
BLI_rctf_size_y(>cur));
-mul_v3_fl(v3, max_dist);
-
-sub_v3_v3v3(v2, center, v3);
-add_v3_v3v3(v1, center, v3);
-  }
-
-  GPU_matrix_push();
-
-  if (options & DRAWLIGHT) {
-col[0] = col[1] = col[2] = 220;
-  }
-  else {
-UI_GetThemeColor3ubv(TH_GRID, col);
-  }
-  UI_make_axis_color(col, col2, axis);
-
-  uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 
3, GPU_FETCH_FLOAT);
-
-  immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-  immUniformColor3ubv(col2);
-
-  immBegin(GPU_PRIM_LINES, 2);
-  immVertex3fv(pos, v1);
-  immVertex3fv(pos, v2);
-  immEnd();
-
-  immUnbindProgram();
-
-  GPU_matrix_pop();
-}
-
 void resetTransModal(TransInfo *t)
 {
   freeTransCustomDataForMode(t);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3b4486424a3] master: Fix repeated transform constraint orientations

2023-01-26 Thread Germano Cavalcante
Commit: 3b4486424a3299756dbe7eba923348c83304ca36
Author: Germano Cavalcante
Date:   Thu Jan 26 07:54:04 2023 -0300
Branches: master
https://developer.blender.org/rB3b4486424a3299756dbe7eba923348c83304ca36

Fix repeated transform constraint orientations

On some occasions, as in cases where transform operations are triggered
via gizmos, the constrain orientations that can be toggled with
multiple clicks of X, Y or Z were repeated.

There is no use in maintaining repeated orientations.

===

M   source/blender/editors/transform/transform_constraints.c
M   source/blender/editors/transform/transform_generics.c

===

diff --git a/source/blender/editors/transform/transform_constraints.c 
b/source/blender/editors/transform/transform_constraints.c
index 61adc98c258..f8e116e77b8 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -1001,6 +1001,9 @@ void postSelectConstraint(TransInfo *t)
 
 static void setNearestAxis2d(TransInfo *t)
 {
+  /* Clear any prior constraint flags. */
+  t->con.mode &= ~(CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+
   /* no correction needed... just use whichever one is lower */
   if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1])) {
 t->con.mode |= CON_AXIS1;
@@ -1014,6 +1017,9 @@ static void setNearestAxis2d(TransInfo *t)
 
 static void setNearestAxis3d(TransInfo *t)
 {
+  /* Clear any prior constraint flags. */
+  t->con.mode &= ~(CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+
   float zfac;
   float mvec[3], proj[3];
   float len[3];
@@ -1090,10 +1096,7 @@ static void setNearestAxis3d(TransInfo *t)
 
 void setNearestAxis(TransInfo *t)
 {
-  /* clear any prior constraint flags */
-  t->con.mode &= ~CON_AXIS0;
-  t->con.mode &= ~CON_AXIS1;
-  t->con.mode &= ~CON_AXIS2;
+  eTConstraint mode_prev = t->con.mode;
 
   /* constraint setting - depends on spacetype */
   if (t->spacetype == SPACE_VIEW3D) {
@@ -1105,7 +1108,9 @@ void setNearestAxis(TransInfo *t)
 setNearestAxis2d(t);
   }
 
-  projection_matrix_calc(t, t->con.pmtx);
+  if (mode_prev != t->con.mode) {
+projection_matrix_calc(t, t->con.pmtx);
+  }
 }
 
 /** \} */
diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index 968e2bca5b9..f09c919c8b7 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -440,6 +440,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 
   {
 short orient_types[3];
+short orient_type_apply = O_DEFAULT;
 float custom_matrix[3][3];
 
 int orient_type_scene = V3D_ORIENT_GLOBAL;
@@ -502,14 +503,23 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 t->is_orient_default_overwrite = true;
   }
 }
-else if (t->con.mode & CON_APPLY) {
-  orient_type_set = orient_type_scene;
-}
-else if (orient_type_scene == V3D_ORIENT_GLOBAL) {
-  orient_type_set = V3D_ORIENT_LOCAL;
+
+if (orient_type_set == -1) {
+  if (orient_type_scene == V3D_ORIENT_GLOBAL) {
+orient_type_set = V3D_ORIENT_LOCAL;
+  }
+  else {
+orient_type_set = V3D_ORIENT_GLOBAL;
+  }
+
+  if (t->con.mode & CON_APPLY) {
+orient_type_apply = O_SCENE;
+  }
 }
 else {
-  orient_type_set = V3D_ORIENT_GLOBAL;
+  if (t->con.mode & CON_APPLY) {
+orient_type_apply = O_SET;
+  }
 }
 
 BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
@@ -546,7 +556,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
   }
 }
 
-transform_orientations_current_set(t, (t->con.mode & CON_APPLY) ? 2 : 0);
+transform_orientations_current_set(t, orient_type_apply);
   }
 
   if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1ad11355a35] master: Transform: fix use of "snap_point" property

2023-01-24 Thread Germano Cavalcante
Commit: 1ad11355a3578dc24496417a517d3ce2faebb248
Author: Germano Cavalcante
Date:   Tue Jan 24 17:06:53 2023 -0300
Branches: master
https://developer.blender.org/rB1ad11355a3578dc24496417a517d3ce2faebb248

Transform: fix use of "snap_point" property

There is not much documentation on the "snap_point" property, but by
code it is possible to note that it serves to set a target snap point
and is of internal use as it is hidden from the Redo panel.

However, this property was still very dependent on Tools settings and
if set to an operator's call, it changes the scene configurations
inadequately.

Therefore,
- remove this dependency from UI for rotation and resize operators,
- do not change the state of the snap in the scene and
- cleanup the code.

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_snap.cc

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index c9cf572e9ad..3cff4c11cad 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1586,7 +1586,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 /* Update `ToolSettings` for properties that change during modal. */
 if (t->flag & T_MODAL) {
   /* Do we check for parameter? */
-  if (transformModeUseSnap(t)) {
+  if (transformModeUseSnap(t) && !(t->tsnap.status & SNAP_FORCED)) {
 if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) {
   /* Type is #eSnapFlag, but type must match various snap attributes 
in #ToolSettings. */
   short *snap_flag_ptr;
diff --git a/source/blender/editors/transform/transform_snap.cc 
b/source/blender/editors/transform/transform_snap.cc
index 2f5e1974d0b..8a1cb2d9788 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -147,6 +147,10 @@ bool transformModeUseSnap(const TransInfo *t)
 
 static bool doForceIncrementSnap(const TransInfo *t)
 {
+  if (t->tsnap.status & SNAP_FORCED) {
+return false;
+  }
+
   return !transformModeUseSnap(t);
 }
 
@@ -525,13 +529,7 @@ void transform_snap_mixed_apply(TransInfo *t, float *vec)
 return;
   }
 
-  if (t->tsnap.status & SNAP_FORCED) {
-t->tsnap.snap_source_fn(t);
-
-t->tsnap.snap_mode_apply_fn(t, vec);
-  }
-  else if (((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) 
!= 0) &&
-   transform_snap_is_active(t)) {
+  if (t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) {
 double current = PIL_check_seconds_timer();
 
 /* Time base quirky code to go around find-nearest slowness. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0f52aa0954e] master: Transform: Initialize 'transform_matrix' accordingly

2023-01-24 Thread Germano Cavalcante
Commit: 0f52aa0954e75195188499d1d334b5af5731dd29
Author: Germano Cavalcante
Date:   Tue Jan 24 16:44:31 2023 -0300
Branches: master
https://developer.blender.org/rB0f52aa0954e75195188499d1d334b5af5731dd29

Transform: Initialize 'transform_matrix' accordingly

Some transform modes are changeable, so callbacks should be reset
together.

Currently the unchanged `transform_matrix` callback is not a major
issue as it is only used for gizmos and gizmos stop updating when
changing the operator type.

===

M   source/blender/editors/transform/transform_mode_edge_slide.c
M   source/blender/editors/transform/transform_mode_resize.c
M   source/blender/editors/transform/transform_mode_vert_slide.c

===

diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c 
b/source/blender/editors/transform/transform_mode_edge_slide.c
index 6920deea574..f2ba8c4bd4d 100644
--- a/source/blender/editors/transform/transform_mode_edge_slide.c
+++ b/source/blender/editors/transform/transform_mode_edge_slide.c
@@ -1498,6 +1498,7 @@ void initEdgeSlide_ex(
   t->mode = TFM_EDGE_SLIDE;
   t->transform = applyEdgeSlide;
   t->handleEvent = handleEventEdgeSlide;
+  t->transform_matrix = NULL;
   t->tsnap.snap_mode_apply_fn = edge_slide_snap_apply;
   t->tsnap.snap_mode_distance_fn = transform_snap_distance_len_squared_fn;
 
diff --git a/source/blender/editors/transform/transform_mode_resize.c 
b/source/blender/editors/transform/transform_mode_resize.c
index 355da21c253..bf9fba2b1e7 100644
--- a/source/blender/editors/transform/transform_mode_resize.c
+++ b/source/blender/editors/transform/transform_mode_resize.c
@@ -285,6 +285,7 @@ void initResize(TransInfo *t, float mouse_dir_constraint[3])
 {
   t->mode = TFM_RESIZE;
   t->transform = applyResize;
+  t->transform_matrix = NULL;
   t->tsnap.snap_mode_apply_fn = ApplySnapResize;
   t->tsnap.snap_mode_distance_fn = ResizeBetween;
 
diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c 
b/source/blender/editors/transform/transform_mode_vert_slide.c
index 3483f2b2bfa..f6e8c64af8f 100644
--- a/source/blender/editors/transform/transform_mode_vert_slide.c
+++ b/source/blender/editors/transform/transform_mode_vert_slide.c
@@ -610,6 +610,7 @@ void initVertSlide_ex(TransInfo *t, bool use_even, bool 
flipped, bool use_clamp)
   t->mode = TFM_VERT_SLIDE;
   t->transform = applyVertSlide;
   t->handleEvent = handleEventVertSlide;
+  t->transform_matrix = NULL;
   t->tsnap.snap_mode_apply_fn = vert_slide_snap_apply;
   t->tsnap.snap_mode_distance_fn = transform_snap_distance_len_squared_fn;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [15575b953df] master: Merge By Distance: Optimize algorithm to find duplicate polygons

2023-01-23 Thread Germano Cavalcante
Commit: 15575b953dfaea29e64788ebc0ce00425401de49
Author: Germano Cavalcante
Date:   Fri Jan 20 00:03:22 2023 -0300
Branches: master
https://developer.blender.org/rB15575b953dfaea29e64788ebc0ce00425401de49

Merge By Distance: Optimize algorithm to find duplicate polygons

The most time-consuming operation in merge by distance is to find
duplicate faces (faces that are different but have the same vertices).

Therefore, some strategies were planned to optimize this algorithm:
- Store the corner indices in an array thus avoiding multiple calls of 
`weld_iter_loop_of_poly_next`;
- Create a map of polygons linked to edges instead of linked to vertices - this 
decreases the number of connections and reduces the calculation of the 
intersection of polygon indices.

There are other fields to optimize, like reusing the `wpolys` array
instead of creating a new array of corner offsets. And join some arrays
as members of the same struct to be used in the same buffer.
But for now, it is already a nice optimization. And the new
`poly_find_doubles` function can be reused in the future to create a
generic utility.

The result of the optimization varies greatly depending on the number
of polygons, the size of each polygon and the number of duplicates.
On average it was something around 2 times faster.

Worst case tested (old vs new): 0.1ms vs 0.3ms
Best case tested (old vs new): 10.0ms vs 3.2ms

Differential Revision: https://developer.blender.org/D17071

===

M   source/blender/geometry/intern/mesh_merge_by_distance.cc

===

diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc 
b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index 5374a6c08cd..f0ec847d44a 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -1,10 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
 #include "BLI_array.hh"
+#include "BLI_bit_vector.hh"
 #include "BLI_index_mask.hh"
 #include "BLI_kdtree.h"
 #include "BLI_math_vector.h"
 #include "BLI_math_vector.hh"
+#include "BLI_offset_indices.hh"
 #include "BLI_vector.hh"
 
 #include "DNA_mesh_types.h"
@@ -462,7 +464,7 @@ static Vector 
weld_edge_ctx_alloc_and_find_collapsed(Span medge
  * \return r_edge_kill_len: Number of edges to be destroyed by merging or 
collapsing.
  */
 static void weld_edge_find_doubles(int remain_edge_ctx_len,
-   MutableSpan r_vlinks,
+   int mvert_num,
MutableSpan r_edge_dest_map,
MutableSpan r_wedge,
int *r_edge_kill_len)
@@ -474,7 +476,8 @@ static void weld_edge_find_doubles(int remain_edge_ctx_len,
   /* Setup Edge Overlap. */
   int edge_double_len = 0;
 
-  r_vlinks.fill(0);
+  /* Add +1 to allow calculation of the length of the last group. */
+  Array v_links(mvert_num + 1, 0);
 
   for (WeldEdge  : r_wedge) {
 if (we.flag == ELEM_COLLAPSED) {
@@ -483,16 +486,16 @@ static void weld_edge_find_doubles(int 
remain_edge_ctx_len,
 }
 
 BLI_assert(we.vert_a != we.vert_b);
-r_vlinks[we.vert_a]++;
-r_vlinks[we.vert_b]++;
+v_links[we.vert_a]++;
+v_links[we.vert_b]++;
   }
 
   int link_len = 0;
-  for (const int i : IndexRange(r_vlinks.size() - 1)) {
-link_len += r_vlinks[i];
-r_vlinks[i] = link_len;
+  for (const int i : IndexRange(v_links.size() - 1)) {
+link_len += v_links[i];
+v_links[i] = link_len;
   }
-  r_vlinks.last() = link_len;
+  v_links.last() = link_len;
 
   BLI_assert(link_len > 0);
   Array link_edge_buffer(link_len);
@@ -507,8 +510,8 @@ static void weld_edge_find_doubles(int remain_edge_ctx_len,
 int dst_vert_a = we.vert_a;
 int dst_vert_b = we.vert_b;
 
-link_edge_buffer[--r_vlinks[dst_vert_a]] = i;
-link_edge_buffer[--r_vlinks[dst_vert_b]] = i;
+link_edge_buffer[--v_links[dst_vert_a]] = i;
+link_edge_buffer[--v_links[dst_vert_b]] = i;
   }
 
   for (const int i : r_wedge.index_range()) {
@@ -522,11 +525,11 @@ static void weld_edge_find_doubles(int 
remain_edge_ctx_len,
 int dst_vert_a = we.vert_a;
 int dst_vert_b = we.vert_b;
 
-const int link_a = r_vlinks[dst_vert_a];
-const int link_b = r_vlinks[dst_vert_b];
+const int link_a = v_links[dst_vert_a];
+const int link_b = v_links[dst_vert_b];
 
-int edges_len_a = r_vlinks[dst_vert_a + 1] - link_a;
-int edges_len_b = r_vlinks[dst_vert_b + 1] - link_b;
+int edges_len_a = v_links[dst_vert_a + 1] - link_a;
+int edges_len_b = v_links[dst_vert_b + 1] - link_b;
 
 if (edges_len_a <= 1 || edges_len_b <= 1) {
   continue;
@@ -1093,12 +1096,162 @@ static void 
weld_poly_loop_ctx_setup_colla

[Bf-blender-cvs] [25ce7056171] master: Merge by Distance: split code into more specialized functions

2023-01-19 Thread Germano Cavalcante
Commit: 25ce7056171f849b724ada0787b35504c3e16dca
Author: Germano Cavalcante
Date:   Thu Jan 19 12:31:40 2023 -0300
Branches: master
https://developer.blender.org/rB25ce7056171f849b724ada0787b35504c3e16dca

Merge by Distance: split code into more specialized functions

Split the algorithms that find duplicates.

This improves readability and helps us find areas for optimization.

It may also facilitate the implementation of generic utilities.

No functional changes.

Differential Revision: https://developer.blender.org/D16918

===

M   source/blender/geometry/intern/mesh_merge_by_distance.cc

===

diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc 
b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index b9addd8dd57..0d1cdf93133 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -15,7 +15,7 @@
 
 #include "GEO_mesh_merge_by_distance.hh"
 
-//#define USE_WELD_DEBUG
+// #define USE_WELD_DEBUG
 
 namespace blender::geometry {
 
@@ -404,13 +404,15 @@ static void weld_vert_groups_setup(Span wvert,
  * \return r_edge_dest_map: First step to create map of indices pointing edges 
that will be merged.
  * \return r_edge_ctx_map: Map of indices pointing original edges to weld 
context edges.
  */
-static Vector weld_edge_ctx_alloc(Span medge,
-Span vert_dest_map,
-MutableSpan r_edge_dest_map,
-MutableSpan r_edge_ctx_map)
+static Vector weld_edge_ctx_alloc_and_find_collapsed(Span 
medge,
+   Span 
vert_dest_map,
+   
MutableSpan r_edge_dest_map,
+   
MutableSpan r_edge_ctx_map,
+   int 
*r_edge_collapsed_len)
 {
   /* Edge Context. */
   int wedge_len = 0;
+  int edge_collapsed_len = 0;
 
   Vector wedge;
   wedge.reserve(medge.size());
@@ -426,8 +428,17 @@ static Vector weld_edge_ctx_alloc(Span 
medge,
   we.vert_b = (v_dest_2 != OUT_OF_CONTEXT) ? v_dest_2 : v2;
   we.edge_dest = OUT_OF_CONTEXT;
   we.edge_orig = i;
+
+  if (we.vert_a == we.vert_b) {
+we.flag = ELEM_COLLAPSED;
+edge_collapsed_len++;
+r_edge_dest_map[i] = ELEM_COLLAPSED;
+  }
+  else {
+r_edge_dest_map[i] = i;
+  }
+
   wedge.append(we);
-  r_edge_dest_map[i] = i;
   r_edge_ctx_map[i] = wedge_len++;
 }
 else {
@@ -436,6 +447,7 @@ static Vector weld_edge_ctx_alloc(Span 
medge,
 }
   }
 
+  *r_edge_collapsed_len = edge_collapsed_len;
   return wedge;
 }
 
@@ -449,30 +461,30 @@ static Vector weld_edge_ctx_alloc(Span 
medge,
  * \return r_wedge: Weld edges. `flag` and `edge_dest` members will be set 
here.
  * \return r_edge_kill_len: Number of edges to be destroyed by merging or 
collapsing.
  */
-static void weld_edge_ctx_setup(MutableSpan r_vlinks,
-MutableSpan r_edge_dest_map,
-MutableSpan r_wedge,
-int *r_edge_kill_len)
+static void weld_edge_find_doubles(int remain_edge_ctx_len,
+   MutableSpan r_vlinks,
+   MutableSpan r_edge_dest_map,
+   MutableSpan r_wedge,
+   int *r_edge_kill_len)
 {
+  if (remain_edge_ctx_len == 0) {
+return;
+  }
+
   /* Setup Edge Overlap. */
-  int edge_kill_len = 0;
+  int edge_double_len = 0;
 
   r_vlinks.fill(0);
 
   for (WeldEdge  : r_wedge) {
-int dst_vert_a = we.vert_a;
-int dst_vert_b = we.vert_b;
-
-if (dst_vert_a == dst_vert_b) {
-  BLI_assert(we.edge_dest == OUT_OF_CONTEXT);
-  r_edge_dest_map[we.edge_orig] = ELEM_COLLAPSED;
-  we.flag = ELEM_COLLAPSED;
-  edge_kill_len++;
+if (we.flag == ELEM_COLLAPSED) {
+  BLI_assert(r_edge_dest_map[we.edge_orig] == ELEM_COLLAPSED);
   continue;
 }
 
-r_vlinks[dst_vert_a]++;
-r_vlinks[dst_vert_b]++;
+BLI_assert(we.vert_a != we.vert_b);
+r_vlinks[we.vert_a]++;
+r_vlinks[we.vert_b]++;
   }
 
   int link_len = 0;
@@ -482,80 +494,79 @@ static void weld_edge_ctx_setup(MutableSpan r_vlinks,
   }
   r_vlinks.last() = link_len;
 
-  if (link_len > 0) {
-Array link_edge_buffer(link_len);
+  BLI_assert(link_len > 0);
+  Array link_edge_buffer(link_len);
 
-/* Use a reverse for loop to ensure that indexes are assigned in ascending 
order. */
-for (int i = r_wedge.size(); i--;) {
-  const WeldEdge  = r_wedge[i];
-  if (we.flag == ELEM_COLLAPSED) {
-continue;
- 

[Bf-blender-cvs] [dcb37959d46] master: Fix roation snap failing with zero angle

2023-01-17 Thread Germano Cavalcante
Commit: dcb37959d467cdf3d24e7e1d7ebec7c1a5e92925
Author: Germano Cavalcante
Date:   Tue Jan 17 17:21:39 2023 -0300
Branches: master
https://developer.blender.org/rBdcb37959d467cdf3d24e7e1d7ebec7c1a5e92925

Fix roation snap failing with zero angle

Due to precision issues, the cosine value calculated with
`dot_v3v3(start, end)` can be outside the -1, 1 range causing `acosf`
to return `nan(ind)`.

Use `angle_signed_on_axis_v3v3_v3` instead. It returns more accurate
values, deduplicates code, and avoids these `nan` issues.

===

M   source/blender/editors/transform/transform_mode_rotate.c

===

diff --git a/source/blender/editors/transform/transform_mode_rotate.c 
b/source/blender/editors/transform/transform_mode_rotate.c
index 0a49fdefd83..713902f6c62 100644
--- a/source/blender/editors/transform/transform_mode_rotate.c
+++ b/source/blender/editors/transform/transform_mode_rotate.c
@@ -171,27 +171,11 @@ static float RotationBetween(TransInfo *t, const float 
p1[3], const float p2[3])
 
   /* Angle around a constraint axis (error prone, will need debug). */
   if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
-float axis[3], tmp[3];
+float axis[3];
 
 t->con.applyRot(t, NULL, NULL, axis, NULL);
 
-project_v3_v3v3(tmp, end, axis);
-sub_v3_v3v3(end, end, tmp);
-
-project_v3_v3v3(tmp, start, axis);
-sub_v3_v3v3(start, start, tmp);
-
-normalize_v3(end);
-normalize_v3(start);
-
-cross_v3_v3v3(tmp, start, end);
-
-if (dot_v3v3(tmp, axis) < 0.0f) {
-  angle = -acosf(dot_v3v3(start, end));
-}
-else {
-  angle = acosf(dot_v3v3(start, end));
-}
+angle = -angle_signed_on_axis_v3v3_v3(start, end, axis);
   }
   else {
 float mtx[3][3];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [debd912bef5] master: Fix T103906: Crash when canceling transform operation with the mirror options set

2023-01-16 Thread Germano Cavalcante
Commit: debd912bef5ac0ba89eb4adae6756614eb9dfe4f
Author: Germano Cavalcante
Date:   Mon Jan 16 12:14:27 2023 -0300
Branches: master
https://developer.blender.org/rBdebd912bef5ac0ba89eb4adae6756614eb9dfe4f

Fix T103906: Crash when canceling transform operation with the mirror options 
set

Caused by rB3b761901b6d6.

Some mirror transdata values were not being initialized.

===

M   source/blender/editors/transform/transform_convert_mesh.c

===

diff --git a/source/blender/editors/transform/transform_convert_mesh.c 
b/source/blender/editors/transform/transform_convert_mesh.c
index 5e164dfd8ad..f7ce586df39 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -1563,7 +1563,7 @@ static void createTransEditVerts(bContext *UNUSED(C), 
TransInfo *t)
 
   if (mirror_data.vert_map) {
 tc->data_mirror_len = mirror_data.mirror_elem_len;
-tc->data_mirror = MEM_mallocN(mirror_data.mirror_elem_len * 
sizeof(*tc->data_mirror),
+tc->data_mirror = MEM_callocN(mirror_data.mirror_elem_len * 
sizeof(*tc->data_mirror),
   __func__);
 
 BM_ITER_MESH_INDEX (eve, , bm, BM_VERTS_OF_MESH, a) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d6d06432654] blender-v3.3-release: Fix T101196: constraint plane failing in side orthographic views

2023-01-12 Thread Germano Cavalcante
Commit: d6d064326549bf89a4d25b3e90a0671b10bbd5af
Author: Germano Cavalcante
Date:   Tue Sep 20 14:29:16 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBd6d064326549bf89a4d25b3e90a0671b10bbd5af

Fix T101196: constraint plane failing in side orthographic views

Caused due to an inaccuracy when the values of `in` and `out` are too
close.

The solution is to project the value of `in` directly onto the plane.

===

M   source/blender/editors/transform/transform_constraints.c

===

diff --git a/source/blender/editors/transform/transform_constraints.c 
b/source/blender/editors/transform/transform_constraints.c
index 658901a6991..d5274d3ae7d 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -337,25 +337,20 @@ static bool isPlaneProjectionViewAligned(const TransInfo 
*t, const float plane[4
   return fabsf(factor) < eps;
 }
 
-static void planeProjection(const TransInfo *t, const float in[3], float 
out[3])
+static void planeProjection(const TransInfo *t,
+const float plane[3],
+const float in[3],
+float out[3])
 {
-  float vec[3], factor, norm[3];
 
-  add_v3_v3v3(vec, in, t->center_global);
-  view_vector_calc(t, vec, norm);
+  float pos[3], view_vec[3], factor;
 
-  sub_v3_v3v3(vec, out, in);
+  add_v3_v3v3(pos, in, t->center_global);
+  view_vector_calc(t, pos, view_vec);
 
-  factor = dot_v3v3(vec, norm);
-  if (factor == 0.0f) {
-return; /* prevent divide by zero */
+  if (isect_ray_plane_v3(pos, view_vec, plane, , false)) {
+madd_v3_v3v3fl(out, in, view_vec, factor);
   }
-  factor = dot_v3v3(vec, vec) / factor;
-
-  copy_v3_v3(vec, norm);
-  mul_v3_fl(vec, factor);
-
-  add_v3_v3v3(out, in, vec);
 }
 
 static short transform_orientation_or_default(const TransInfo *t)
@@ -397,7 +392,6 @@ static void applyAxisConstraintVec(const TransInfo *t,
   copy_v3_v3(out, in);
   if (!td && t->con.mode & CON_APPLY) {
 bool is_snap_to_point = false, is_snap_to_edge = false, is_snap_to_face = 
false;
-mul_m3_v3(t->con.pmtx, out);
 
 if (activeSnap(t)) {
   if (validSnap(t)) {
@@ -410,8 +404,11 @@ static void applyAxisConstraintVec(const TransInfo *t,
   }
 }
 
-/* With snap points, a projection is alright, no adjustments needed. */
-if (!is_snap_to_point || is_snap_to_edge || is_snap_to_face) {
+if (is_snap_to_point) {
+  /* With snap points, a projection is alright, no adjustments needed. */
+  mul_m3_v3(t->con.pmtx, out);
+}
+else {
   const int dims = getConstraintSpaceDimension(t);
   if (dims == 2) {
 if (!is_zero_v3(out)) {
@@ -428,7 +425,10 @@ static void applyAxisConstraintVec(const TransInfo *t,
   else {
 /* View alignment correction. */
 if (!isPlaneProjectionViewAligned(t, plane)) {
-  planeProjection(t, in, out);
+  planeProjection(t, plane, in, out);
+}
+else {
+  mul_m3_v3(t->con.pmtx, out);
 }
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4ffbc6175e7] blender-v3.3-release: Fix T101964: Edge and face snapping no locking to axis

2023-01-12 Thread Germano Cavalcante
Commit: 4ffbc6175e70efed60caf241f883da9c9a1e4923
Author: Germano Cavalcante
Date:   Fri Oct 21 09:52:53 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB4ffbc6175e70efed60caf241f883da9c9a1e4923

Fix T101964: Edge and face snapping no locking to axis

In rBed6c8d82b804 it was wrongly assumed that the constraint functions
always apply the transformations.

But that is not the case for when axes are aligned.

The `mul_m3_v3(t->con.pmtx, out)` fallback is still required.

===

M   source/blender/editors/transform/transform_constraints.c

===

diff --git a/source/blender/editors/transform/transform_constraints.c 
b/source/blender/editors/transform/transform_constraints.c
index d5274d3ae7d..9edd9e34f8a 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -404,9 +404,11 @@ static void applyAxisConstraintVec(const TransInfo *t,
   }
 }
 
+/* Fallback for when axes are aligned. */
+mul_m3_v3(t->con.pmtx, out);
+
 if (is_snap_to_point) {
-  /* With snap points, a projection is alright, no adjustments needed. */
-  mul_m3_v3(t->con.pmtx, out);
+  /* Pass. With snap points, a projection is alright, no adjustments 
needed. */
 }
 else {
   const int dims = getConstraintSpaceDimension(t);
@@ -422,14 +424,9 @@ static void applyAxisConstraintVec(const TransInfo *t,
 /* Disabled, as it has not proven to be really useful. (See 
T82386). */
 // constraint_snap_plane_to_face(t, plane, out);
   }
-  else {
+  else if (!isPlaneProjectionViewAligned(t, plane)) {
 /* View alignment correction. */
-if (!isPlaneProjectionViewAligned(t, plane)) {
-  planeProjection(t, plane, in, out);
-}
-else {
-  mul_m3_v3(t->con.pmtx, out);
-}
+planeProjection(t, plane, in, out);
   }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [589d1be147b] master: Cleanup: rename variables to distinguish between target and source

2023-01-12 Thread Germano Cavalcante
Commit: 589d1be147b02444fed2ebcc4006524c08e929c8
Author: Germano Cavalcante
Date:   Thu Jan 12 10:16:25 2023 -0300
Branches: master
https://developer.blender.org/rB589d1be147b02444fed2ebcc4006524c08e929c8

Cleanup: rename variables to distinguish between target and source

From --> To

**Struct Members:**
|snapTarget|snap_source
|snapPoint|snap_target
|snapTargetGrid|snap_target_grid
|calcSnap|snap_target_fn
|targetSnap|snap_source_fn
|applySnap|snap_mode_apply_fn
|distance|snap_mode_distance_fn
|source_select|source_operation
|target_select|target_operation

**Functions:**
|snap_calc_view3d_fn|snap_target_view3d_fn
|snap_calc_uv_fn|snap_target_uv_fn
|snap_calc_node_fn|snap_target_node_fn
|snap_calc_sequencer_fn|snap_target_sequencer_fn
|TargetSnapMedian|snap_source_median_fn
|TargetSnapCenter|snap_source_center_fn
|TargetSnapClosest|snap_source_closest_fn
|TargetSnapActive|snap_source_active_fn

**Enums:**
|TARGET_INIT|SNAP_SOURCE_FOUND
|TARGET_GRID_INIT|SNAP_TARGET_GRID_FOUND
|POINT_INIT|SNAP_TARGET_FOUND
|MULTI_POINTS|SNAP_MULTI_POINTS

**Types:**
|eSnapSourceSelect|eSnapSourceOP
|eSnapTargetSelect|eSnapTargetOP

Also rename Select to Operation.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D16967

===

M   source/blender/editors/include/ED_transform_snap_object_context.h
M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform.h
M   source/blender/editors/transform/transform_constraints.c
M   source/blender/editors/transform/transform_mode_edge_seq_slide.c
M   source/blender/editors/transform/transform_mode_edge_slide.c
M   source/blender/editors/transform/transform_mode_resize.c
M   source/blender/editors/transform/transform_mode_rotate.c
M   source/blender/editors/transform/transform_mode_translate.c
M   source/blender/editors/transform/transform_mode_vert_slide.c
M   source/blender/editors/transform/transform_ops.c
M   source/blender/editors/transform/transform_snap.cc
M   source/blender/editors/transform/transform_snap_object.cc
M   source/blender/editors/transform/transform_snap_sequencer.c
M   source/blender/makesdna/DNA_scene_types.h

===

diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h 
b/source/blender/editors/include/ED_transform_snap_object_context.h
index f9ca578f282..99b7d95c74c 100644
--- a/source/blender/editors/include/ED_transform_snap_object_context.h
+++ b/source/blender/editors/include/ED_transform_snap_object_context.h
@@ -53,7 +53,7 @@ struct SnapObjectHitDepth {
 /** parameters that define which objects will be used to snap. */
 struct SnapObjectParams {
   /* Special context sensitive handling for the active or selected object. */
-  eSnapTargetSelect snap_target_select;
+  eSnapTargetOP snap_target_select;
   /* Geometry for snapping in edit mode. */
   eSnapEditType edit_mode_type;
   /* snap to the closest element, use when using more than one snap type */
diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index ff93bcaf8ca..c9cf572e9ad 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1573,9 +1573,9 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 if ((prop = RNA_struct_find_property(op->ptr, "snap_elements"))) {
   RNA_property_enum_set(op->ptr, prop, t->tsnap.mode);
   RNA_boolean_set(op->ptr, "use_snap_project", t->tsnap.project);
-  RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_select);
+  RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_operation);
 
-  eSnapTargetSelect target = t->tsnap.target_select;
+  eSnapTargetOP target = t->tsnap.target_operation;
   RNA_boolean_set(op->ptr, "use_snap_self", (target & 
SCE_SNAP_TARGET_NOT_ACTIVE) == 0);
   RNA_boolean_set(op->ptr, "use_snap_edit", (target & 
SCE_SNAP_TARGET_NOT_EDITED) == 0);
   RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & 
SCE_SNAP_TARGET_NOT_NONEDITED) == 0);
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 29df931e136..13362cee2b6 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -160,13 +160,13 @@ ENUM_OPERATORS(eTModifier, MOD_NODE_ATTACH)
 typedef enum eTSnap {
   SNAP_RESETTED = 0,
   SNAP_FORCED = 1 << 0,
-  TARGET_INIT = 1 << 1,
+  SNAP_SOURCE_FOUND = 1 << 1,
   /* Special flag for snap to grid. */
-  TARGET_GRID_INIT = 1 << 2,
-  POINT_INIT = 1 << 3,
-  MULTI_POINTS = 1 << 4,
+  SNAP_TARGET_GRID_FOUND = 1 << 2,
+  SNA

[Bf-blender-cvs] [cdfb21c7e24] blender-v3.3-release: Fix T102466: push/pull doesn't work if applied to many vertices

2023-01-12 Thread Germano Cavalcante
Commit: cdfb21c7e247976ccbfb8cb73f63a8238b930d1f
Author: Germano Cavalcante
Date:   Thu Nov 24 17:29:06 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBcdfb21c7e247976ccbfb8cb73f63a8238b930d1f

Fix T102466: push/pull doesn't work if applied to many vertices

The assignment of member`distance` was missing in rB2d4ec9049744.

===

M   source/blender/editors/transform/transform_mode_push_pull.c

===

diff --git a/source/blender/editors/transform/transform_mode_push_pull.c 
b/source/blender/editors/transform/transform_mode_push_pull.c
index 87309b45231..b7806b3519e 100644
--- a/source/blender/editors/transform/transform_mode_push_pull.c
+++ b/source/blender/editors/transform/transform_mode_push_pull.c
@@ -152,6 +152,8 @@ static void applyPushPull(TransInfo *t, const int 
UNUSED(mval[2]))
   struct TransDataArgs_PushPull data = {
   .t = t,
   .tc = tc,
+
+  .distance = distance,
   .axis_global = {UNPACK3(axis_global)},
   .is_lock_constraint = is_lock_constraint,
   .is_data_space = is_data_space,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0349a6e6e05] master: Fix disappearing snap indication in Measure tool

2023-01-11 Thread Germano Cavalcante
Commit: 0349a6e6e05ee5f3c941890a8ce4062615ecf5cc
Author: Germano Cavalcante
Date:   Wed Jan 11 23:00:51 2023 -0300
Branches: master
https://developer.blender.org/rB0349a6e6e05ee5f3c941890a8ce4062615ecf5cc

Fix disappearing snap indication in Measure tool

Snap cursor disappeared while dragging.

Regression in 2b32a2c3b

===

M   source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
M   source/blender/editors/space_view3d/view3d_gizmo_ruler.c

===

diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c 
b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index 4a5bad575e7..571a2b6ef61 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -242,7 +242,8 @@ static void snap_cursor_free(SnapGizmo3D *snap_gizmo)
 static bool snap_cursor_poll(ARegion *region, void *data)
 {
   SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)data;
-  if (!(snap_gizmo->gizmo.state & WM_GIZMO_STATE_HIGHLIGHT)) {
+  if (!(snap_gizmo->gizmo.state & WM_GIZMO_STATE_HIGHLIGHT) &&
+  !(snap_gizmo->gizmo.flag & WM_GIZMO_DRAW_VALUE)) {
 return false;
   }
 
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c 
b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index c94043f2397..b9a30eac3c6 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -301,10 +301,13 @@ static void ruler_state_set(RulerInfo *ruler_info, int 
state)
   }
 
   if (state == RULER_STATE_NORMAL) {
-/* pass */
+WM_gizmo_set_flag(ruler_info->snap_data.gizmo, WM_GIZMO_DRAW_VALUE, false);
   }
   else if (state == RULER_STATE_DRAG) {
 memset(_info->drag_state_prev, 0x0, 
sizeof(ruler_info->drag_state_prev));
+
+/* Force the snap cursor to appear even though it is not highlighted. */
+WM_gizmo_set_flag(ruler_info->snap_data.gizmo, WM_GIZMO_DRAW_VALUE, true);
   }
   else {
 BLI_assert(0);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2b32a2c3b21] master: Snap Gizmo: hide snap cursor if another gizmo is highlighted

2023-01-11 Thread Germano Cavalcante
Commit: 2b32a2c3b2193ccfe9062efd842f35798fca0cd5
Author: Germano Cavalcante
Date:   Wed Jan 11 18:52:30 2023 -0300
Branches: master
https://developer.blender.org/rB2b32a2c3b2193ccfe9062efd842f35798fca0cd5

Snap Gizmo: hide snap cursor if another gizmo is highlighted

===

M   source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c

===

diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c 
b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index 8f2cb016f86..4a5bad575e7 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -242,6 +242,10 @@ static void snap_cursor_free(SnapGizmo3D *snap_gizmo)
 static bool snap_cursor_poll(ARegion *region, void *data)
 {
   SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)data;
+  if (!(snap_gizmo->gizmo.state & WM_GIZMO_STATE_HIGHLIGHT)) {
+return false;
+  }
+
   if (snap_gizmo->gizmo.flag & WM_GIZMO_HIDDEN) {
 snap_cursor_free(snap_gizmo);
 return false;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [442b08aac0c] master: Snap Gizmo: support the WM_GIZMO_HIDDEN flag

2023-01-11 Thread Germano Cavalcante
Commit: 442b08aac0c77c5167b31e651b260dfa04155c1c
Author: Germano Cavalcante
Date:   Wed Jan 11 18:20:05 2023 -0300
Branches: master
https://developer.blender.org/rB442b08aac0c77c5167b31e651b260dfa04155c1c

Snap Gizmo: support the WM_GIZMO_HIDDEN flag

Support snap cursor removal in poll callback, this makes it possible to
delay cursor removal if the gizmo is hidden.

===

M   source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
M   source/blender/editors/include/ED_view3d.h
M   source/blender/editors/space_view3d/view3d_cursor_snap.c
M   source/blender/editors/space_view3d/view3d_placement.c
M   source/blender/windowmanager/intern/wm_event_system.cc

===

diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c 
b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index 5cac8b93b88..8f2cb016f86 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -227,23 +227,64 @@ static void gizmo_snap_rna_snap_elem_index_get_fn(struct 
PointerRNA *UNUSED(ptr)
 /** \} */
 
 /*  */
-/** \name GIZMO_GT_snap_3d
+/** \name Snap Cursor Utils
  * \{ */
 
-static void snap_gizmo_setup(wmGizmo *gz)
+static void snap_cursor_free(SnapGizmo3D *snap_gizmo)
+{
+  if (snap_gizmo->snap_state) {
+ED_view3d_cursor_snap_deactive(snap_gizmo->snap_state);
+snap_gizmo->snap_state = NULL;
+  }
+}
+
+/* XXX: Delayed snap cursor removal. */
+static bool snap_cursor_poll(ARegion *region, void *data)
+{
+  SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)data;
+  if (snap_gizmo->gizmo.flag & WM_GIZMO_HIDDEN) {
+snap_cursor_free(snap_gizmo);
+return false;
+  }
+
+  if (!WM_gizmomap_group_find_ptr(region->gizmo_map, 
snap_gizmo->gizmo.parent_gzgroup->type)) {
+/* Wrong viewport. */
+snap_cursor_free(snap_gizmo);
+return false;
+  }
+  return true;
+}
+
+static void snap_cursor_init(SnapGizmo3D *snap_gizmo)
 {
-  gz->flag |= WM_GIZMO_NO_TOOLTIP;
-  SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
   snap_gizmo->snap_state = ED_view3d_cursor_snap_active();
-  snap_gizmo->snap_state->gzgrp_type = gz->parent_gzgroup->type;
   snap_gizmo->snap_state->draw_point = true;
   snap_gizmo->snap_state->draw_plane = false;
 
-  rgba_float_to_uchar(snap_gizmo->snap_state->color_point, gz->color);
+  rgba_float_to_uchar(snap_gizmo->snap_state->color_point, 
snap_gizmo->gizmo.color);
+
+  snap_gizmo->snap_state->poll = snap_cursor_poll;
+  snap_gizmo->snap_state->poll_data = snap_gizmo;
 }
 
-static void snap_gizmo_draw(const bContext *UNUSED(C), wmGizmo *UNUSED(gz))
+/** \} */
+
+/*  */
+/** \name GIZMO_GT_snap_3d
+ * \{ */
+
+static void snap_gizmo_setup(wmGizmo *gz)
 {
+  gz->flag |= WM_GIZMO_NO_TOOLTIP;
+  snap_cursor_init((SnapGizmo3D *)gz);
+}
+
+static void snap_gizmo_draw(const bContext *UNUSED(C), wmGizmo *gz)
+{
+  SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
+  if (snap_gizmo->snap_state == NULL) {
+snap_cursor_init(snap_gizmo);
+  }
   /* All drawing is handled at the paint cursor. */
 }
 
@@ -292,10 +333,7 @@ static int snap_gizmo_invoke(bContext *UNUSED(C),
 
 static void snap_gizmo_free(wmGizmo *gz)
 {
-  SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
-  if (snap_gizmo->snap_state) {
-ED_view3d_cursor_snap_deactive(snap_gizmo->snap_state);
-  }
+  snap_cursor_free((SnapGizmo3D *)gz);
 }
 
 static void GIZMO_GT_snap_3d(wmGizmoType *gzt)
diff --git a/source/blender/editors/include/ED_view3d.h 
b/source/blender/editors/include/ED_view3d.h
index f475335..12313b3d244 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -320,7 +320,6 @@ typedef struct V3DSnapCursorState {
   uchar color_line[4];
   uchar color_point[4];
   uchar color_box[4];
-  struct wmGizmoGroupType *gzgrp_type; /* Force cursor to be drawn only when 
gizmo is available. */
   float *prevpoint;
   float box_dimensions[3];
   eSnapMode snap_elem_force; /* If SCE_SNAP_MODE_NONE, use scene settings. */
@@ -329,6 +328,9 @@ typedef struct V3DSnapCursorState {
   bool draw_point;
   bool draw_plane;
   bool draw_box;
+
+  bool (*poll)(struct ARegion *region, void *custom_poll_data);
+  void *poll_data;
 } V3DSnapCursorState;
 
 void ED_view3d_cursor_snap_state_default_set(V3DSnapCursorState *state);
diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c 
b/source/blender/editors/space_view3d/view3d_cursor_snap.c
index 771a964dbcd..875097b4827 100644
--- a/source/blender/editors/space_view3d/view3d_cursor_snap.c
+++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c
@@ -826,14 

[Bf-blender-cvs] [4d1f12212b1] master: Transform: deduplicate code

2023-01-11 Thread Germano Cavalcante
Commit: 4d1f12212b112330a9c78cd48d46f9679e9c1b6d
Author: Germano Cavalcante
Date:   Wed Jan 11 12:28:48 2023 -0300
Branches: master
https://developer.blender.org/rB4d1f12212b112330a9c78cd48d46f9679e9c1b6d

Transform: deduplicate code

Edge Bevel Weight and Edge Crease operations have the same code.

Only the name displayed in the header changes.

===

M   source/blender/editors/transform/CMakeLists.txt
M   source/blender/editors/transform/transform_mode.h
R054source/blender/editors/transform/transform_mode_edge_crease.c   
source/blender/editors/transform/transform_mode_customdata.c
D   source/blender/editors/transform/transform_mode_edge_bevelweight.c

===

diff --git a/source/blender/editors/transform/CMakeLists.txt 
b/source/blender/editors/transform/CMakeLists.txt
index 6c9b834d34b..bcd87ff9572 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -63,8 +63,7 @@ set(SRC
   transform_mode_boneenvelope.c
   transform_mode_boneroll.c
   transform_mode_curveshrinkfatten.c
-  transform_mode_edge_bevelweight.c
-  transform_mode_edge_crease.c
+  transform_mode_customdata.c
   transform_mode_edge_rotate_normal.c
   transform_mode_edge_seq_slide.c
   transform_mode_edge_slide.c
diff --git a/source/blender/editors/transform/transform_mode.h 
b/source/blender/editors/transform/transform_mode.h
index 063de87ebb2..b782d27a3c6 100644
--- a/source/blender/editors/transform/transform_mode.h
+++ b/source/blender/editors/transform/transform_mode.h
@@ -94,14 +94,11 @@ void initBoneRoll(TransInfo *t);
 
 void initCurveShrinkFatten(TransInfo *t);
 
-/* transform_mode_edge_bevelweight.c */
-
-void initBevelWeight(TransInfo *t);
-
-/* transform_mode_edge_crease.c */
+/* transform_mode_customdata.c */
 
 void initEgdeCrease(TransInfo *t);
 void initVertCrease(TransInfo *t);
+void initBevelWeight(TransInfo *t);
 
 /* transform_mode_edge_rotate_normal.c */
 
diff --git a/source/blender/editors/transform/transform_mode_edge_crease.c 
b/source/blender/editors/transform/transform_mode_customdata.c
similarity index 54%
rename from source/blender/editors/transform/transform_mode_edge_crease.c
rename to source/blender/editors/transform/transform_mode_customdata.c
index 2ced57860c5..fb4ee2484bc 100644
--- a/source/blender/editors/transform/transform_mode_edge_crease.c
+++ b/source/blender/editors/transform/transform_mode_customdata.c
@@ -27,64 +27,64 @@
 #include "transform_mode.h"
 
 /*  */
-/** \name Transform (Crease) Element
+/** \name Transform Element
  * \{ */
 
 /**
  * \note Small arrays / data-structures should be stored copied for faster 
memory access.
  */
-struct TransDataArgs_Crease {
+struct TransDataArgs_Value {
   const TransInfo *t;
   const TransDataContainer *tc;
-  float crease;
+  float value;
 };
 
-static void transdata_elem_crease(const TransInfo *UNUSED(t),
-  const TransDataContainer *UNUSED(tc),
-  TransData *td,
-  const float crease)
+static void transdata_elem_value(const TransInfo *UNUSED(t),
+ const TransDataContainer *UNUSED(tc),
+ TransData *td,
+ const float value)
 {
   if (td->val == NULL) {
 return;
   }
 
-  *td->val = td->ival + crease * td->factor;
+  *td->val = td->ival + value * td->factor;
   CLAMP(*td->val, 0.0f, 1.0f);
 }
 
-static void transdata_elem_crease_fn(void *__restrict iter_data_v,
- const int iter,
- const TaskParallelTLS *__restrict 
UNUSED(tls))
+static void transdata_elem_value_fn(void *__restrict iter_data_v,
+const int iter,
+const TaskParallelTLS *__restrict 
UNUSED(tls))
 {
-  struct TransDataArgs_Crease *data = iter_data_v;
+  struct TransDataArgs_Value *data = iter_data_v;
   TransData *td = >tc->data[iter];
   if (td->flag & TD_SKIP) {
 return;
   }
-  transdata_elem_crease(data->t, data->tc, td, data->crease);
+  transdata_elem_value(data->t, data->tc, td, data->value);
 }
 
 /** \} */
 
 /*  */
-/** \name Transform (Crease)
+/** \name Transform Value
  * \{ */
 
-static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
+static void apply_value_impl(TransInfo *t, const char *value_name)
 {
-  float crease;
+  float value;
   int i;
   char str[UI_MAX_DRAW_STR];
 
-  crease = t->values[0] + t->values_modal_offset[0];
+  value = t->values[0] + t->values_modal_offset[0];
 
-  CLAMP_

[Bf-blender-cvs] [5029f3e483d] master: Fix crease and bevel weight unaffected when transforming

2023-01-11 Thread Germano Cavalcante
Commit: 5029f3e483d9fe8395163670e2d6d00eb5bf1c9f
Author: Germano Cavalcante
Date:   Wed Jan 11 12:49:19 2023 -0300
Branches: master
https://developer.blender.org/rB5029f3e483d9fe8395163670e2d6d00eb5bf1c9f

Fix crease and bevel weight unaffected when transforming

Regression in 3b761901b

===

M   source/blender/editors/transform/transform_convert_mesh_edge.c

===

diff --git a/source/blender/editors/transform/transform_convert_mesh_edge.c 
b/source/blender/editors/transform/transform_convert_mesh_edge.c
index fd62b199345..f8ea8ea9f7d 100644
--- a/source/blender/editors/transform/transform_convert_mesh_edge.c
+++ b/source/blender/editors/transform/transform_convert_mesh_edge.c
@@ -103,8 +103,8 @@ static void createTransEdge(bContext *UNUSED(C), TransInfo 
*t)
 td->ext = NULL;
 
 fl_ptr = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_float_offset);
-td->loc = fl_ptr;
-td->iloc[0] = *fl_ptr;
+td->val = fl_ptr;
+td->ival = *fl_ptr;
 
 td++;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ad01cdd7fc9] master: Transform: improve safety when restoring data

2023-01-11 Thread Germano Cavalcante
Commit: ad01cdd7fc931c7e313eebc0027a05d96e36e66f
Author: Germano Cavalcante
Date:   Wed Jan 11 12:08:04 2023 -0300
Branches: master
https://developer.blender.org/rBad01cdd7fc931c7e313eebc0027a05d96e36e66f

Transform: improve safety when restoring data

===

M   source/blender/editors/transform/transform_generics.c

===

diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index 5d3e326d8b0..968e2bca5b9 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -811,13 +811,15 @@ void applyTransObjects(TransInfo *t)
 
 static void transdata_restore_basic(TransDataBasic *td_basic)
 {
-  /* TransData for crease has no loc */
-  if (td_basic->loc) {
-copy_v3_v3(td_basic->loc, td_basic->iloc);
+  if (td_basic->val) {
+*td_basic->val = td_basic->ival;
   }
 
-  if (td_basic->val && td_basic->val != td_basic->loc) {
-*td_basic->val = td_basic->ival;
+  /* TODO(mano-wii): Only use 3D or larger vectors in `td->loc`.
+   * If `loc` and `val` point to the same address, it may indicate that `loc` 
is not 3D which is
+   * not safe for `copy_v3_v3`. */
+  if (td_basic->loc && td_basic->val != td_basic->loc) {
+copy_v3_v3(td_basic->loc, td_basic->iloc);
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3b761901b6d] master: Fix T103783: crash when canceling vertex crease having vertex groups

2023-01-11 Thread Germano Cavalcante
Commit: 3b761901b6d6d5c089a89d0df9d8d12fd7f8e368
Author: Germano Cavalcante
Date:   Wed Jan 11 11:50:45 2023 -0300
Branches: master
https://developer.blender.org/rB3b761901b6d6d5c089a89d0df9d8d12fd7f8e368

Fix T103783: crash when canceling vertex crease having vertex groups

`transdata_restore_basic` uses `copy_v3_v3` to restore a pointer that is 1D.

===

M   source/blender/editors/transform/transform_convert_mesh_vert_cdata.c
M   source/blender/editors/transform/transform_data.h
M   source/blender/editors/transform/transform_generics.c
M   source/blender/editors/transform/transform_mode_edge_bevelweight.c
M   source/blender/editors/transform/transform_mode_edge_crease.c

===

diff --git 
a/source/blender/editors/transform/transform_convert_mesh_vert_cdata.c 
b/source/blender/editors/transform/transform_convert_mesh_vert_cdata.c
index 6145962acbf..0d29892cd5e 100644
--- a/source/blender/editors/transform/transform_convert_mesh_vert_cdata.c
+++ b/source/blender/editors/transform/transform_convert_mesh_vert_cdata.c
@@ -49,8 +49,8 @@ static void tc_mesh_cdata_transdata_create(TransDataBasic *td,
 {
   BLI_assert(BM_elem_flag_test(eve, BM_ELEM_HIDDEN) == 0);
 
-  td->loc = weight;
-  td->iloc[0] = *weight;
+  td->val = weight;
+  td->ival = *weight;
 
   if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
 td->flag |= TD_SELECTED;
@@ -268,7 +268,7 @@ static void tc_mesh_cdata_apply_to_mirror(TransInfo *t)
 if (tc->use_mirror_axis_any) {
   TransDataMirror *td_mirror = tc->data_mirror;
   for (int i = 0; i < tc->data_mirror_len; i++, td_mirror++) {
-td_mirror->loc[0] = td_mirror->loc_src[0];
+*td_mirror->val = td_mirror->loc_src[0];
   }
 }
   }
diff --git a/source/blender/editors/transform/transform_data.h 
b/source/blender/editors/transform/transform_data.h
index 195fab93f72..2518fef3b39 100644
--- a/source/blender/editors/transform/transform_data.h
+++ b/source/blender/editors/transform/transform_data.h
@@ -20,6 +20,10 @@ struct bConstraint;
   float iloc[3]; \
   /** Individual data center. */ \
   float center[3]; \
+  /** Value pointer for special transforms. */ \
+  float *val; \
+  /** Old value. */ \
+  float ival; \
   /** Various flags. */ \
   int flag
 
@@ -114,10 +118,6 @@ typedef struct TransData {
   float rdist;
   /** Factor of the transformation (for Proportional Editing). */
   float factor;
-  /** Value pointer for special transforms. */
-  float *val;
-  /** Old value. */
-  float ival;
   /** Transformation matrix from data space to global space. */
   float mtx[3][3];
   /** Transformation matrix from global space to data space. */
diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index 449a53573e6..5d3e326d8b0 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -815,16 +815,16 @@ static void transdata_restore_basic(TransDataBasic 
*td_basic)
   if (td_basic->loc) {
 copy_v3_v3(td_basic->loc, td_basic->iloc);
   }
+
+  if (td_basic->val && td_basic->val != td_basic->loc) {
+*td_basic->val = td_basic->ival;
+  }
 }
 
 static void restoreElement(TransData *td)
 {
   transdata_restore_basic((TransDataBasic *)td);
 
-  if (td->val && td->val != td->loc) {
-*td->val = td->ival;
-  }
-
   if (td->ext && (td->flag & TD_NO_EXT) == 0) {
 if (td->ext->rot) {
   copy_v3_v3(td->ext->rot, td->ext->irot);
diff --git a/source/blender/editors/transform/transform_mode_edge_bevelweight.c 
b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
index e96e74b596c..c46eee5eb56 100644
--- a/source/blender/editors/transform/transform_mode_edge_bevelweight.c
+++ b/source/blender/editors/transform/transform_mode_edge_bevelweight.c
@@ -44,11 +44,11 @@ static void transdata_elem_bevel_weight(const TransInfo 
*UNUSED(t),
 TransData *td,
 const float weight)
 {
-  if (td->loc == NULL) {
+  if (td->val == NULL) {
 return;
   }
-  *td->loc = td->iloc[0] + weight * td->factor;
-  CLAMP(*td->loc, 0.0f, 1.0f);
+  *td->val = td->ival + weight * td->factor;
+  CLAMP(*td->val, 0.0f, 1.0f);
 }
 
 static void transdata_elem_bevel_weight_fn(void *__restrict iter_data_v,
diff --git a/source/blender/editors/transform/transform_mode_edge_crease.c 
b/source/blender/editors/transform/transform_mode_edge_crease.c
index 1a3ccf30387..2ced57860c5 100644
--- a/source/blender/editors/transform/transform_mode_edge_crease.c
+++ b/source/blender/editors/transform/transform_mode_edge_crease.c
@@ -44,12 +44,12 @@ static void transdata_ele

[Bf-blender-cvs] [5bc71f22a24] master: Snap Gizmo: remove unused "snap_elements"

2023-01-10 Thread Germano Cavalcante
Commit: 5bc71f22a24a48780fe335c557f2f9bbc690eb85
Author: Germano Cavalcante
Date:   Tue Jan 10 15:56:17 2023 -0300
Branches: master
https://developer.blender.org/rB5bc71f22a24a48780fe335c557f2f9bbc690eb85

Snap Gizmo: remove unused "snap_elements"

This property was intended to keep the snap elements synchronized with the 
scene.

But another solution exists.

And this property is not even working correctly.

===

M   source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c

===

diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c 
b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index c5a542c0bf3..5cac8b93b88 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -41,17 +41,6 @@ typedef struct SnapGizmo3D {
   V3DSnapCursorState *snap_state;
 } SnapGizmo3D;
 
-static void snap_gizmo_snap_elements_update(SnapGizmo3D *snap_gizmo)
-{
-  wmGizmoProperty *gz_prop_snap;
-  gz_prop_snap = WM_gizmo_target_property_find(_gizmo->gizmo, 
"snap_elements");
-
-  if (gz_prop_snap->prop) {
-V3DSnapCursorState *snap_state = snap_gizmo->snap_state;
-snap_state->snap_elem_force |= RNA_property_enum_get(_prop_snap->ptr, 
gz_prop_snap->prop);
-  }
-}
-
 /*  */
 /** \name ED_gizmo_library specific API
  * \{ */
@@ -262,9 +251,6 @@ static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, 
const int mval[2])
 {
   SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
 
-  /* Snap Elements can change while the gizmo is active. Need to be updated 
somewhere. */
-  snap_gizmo_snap_elements_update(snap_gizmo);
-
   /* Snap values are updated too late at the cursor. Be sure to update ahead 
of time. */
   int x, y;
   {
@@ -404,9 +390,6 @@ static void GIZMO_GT_snap_3d(wmGizmoType *gzt)
 INT_MAX);
   RNA_def_property_int_array_funcs_runtime(
   prop, gizmo_snap_rna_snap_elem_index_get_fn, NULL, NULL);
-
-  /* Read/Write. */
-  WM_gizmotype_target_property_def(gzt, "snap_elements", PROP_ENUM, 1);
 }
 
 void ED_gizmotypes_snap_3d(void)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c6b4bd407ef] master: Cleanup: deduplicate conditions in transform code

2023-01-10 Thread Germano Cavalcante
Commit: c6b4bd407ef1068ba201c49d971213e5d6785e59
Author: Germano Cavalcante
Date:   Tue Jan 10 09:35:59 2023 -0300
Branches: master
https://developer.blender.org/rBc6b4bd407ef1068ba201c49d971213e5d6785e59

Cleanup: deduplicate conditions in transform code

The `t->spacetype` check is already done in `setSnappingCallback`.

===

M   source/blender/editors/transform/transform_snap.cc

===

diff --git a/source/blender/editors/transform/transform_snap.cc 
b/source/blender/editors/transform/transform_snap.cc
index 0eebe05fa0c..00ccf1ed632 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -741,12 +741,7 @@ static void initSnappingMode(TransInfo *t)
 t->tsnap.project = false;
   }
 
-  if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE, SPACE_SEQ)) {
-/* Not with camera selected in camera view. */
-if (!(t->options & CTX_CAMERA)) {
-  setSnappingCallback(t);
-}
-  }
+  setSnappingCallback(t);
 
   if (t->spacetype == SPACE_VIEW3D) {
 if (t->tsnap.object_context == nullptr) {
@@ -903,6 +898,10 @@ void freeSnapping(TransInfo *t)
 static void setSnappingCallback(TransInfo *t)
 {
   if (t->spacetype == SPACE_VIEW3D) {
+if (t->options & CTX_CAMERA) {
+  /* Not with camera selected in camera view. */
+  return;
+}
 t->tsnap.calcSnap = snap_calc_view3d_fn;
   }
   else if (t->spacetype == SPACE_IMAGE) {
@@ -924,6 +923,9 @@ static void setSnappingCallback(TransInfo *t)
 /* The target is calculated along with the snap point. */
 return;
   }
+  else {
+return;
+  }
 
   switch (t->tsnap.source_select) {
 case SCE_SNAP_SOURCE_CLOSEST:

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [92449e634ff] master: Fix duplicate code in 63b9a57f8bd8

2023-01-09 Thread Germano Cavalcante
Commit: 92449e634ff709856f75161b95a84d5b59097f7e
Author: Germano Cavalcante
Date:   Mon Jan 9 23:56:14 2023 -0300
Branches: master
https://developer.blender.org/rB92449e634ff709856f75161b95a84d5b59097f7e

Fix duplicate code in 63b9a57f8bd8

===

M   source/blender/editors/transform/transform_snap.cc

===

diff --git a/source/blender/editors/transform/transform_snap.cc 
b/source/blender/editors/transform/transform_snap.cc
index c2a0c0abc65..0eebe05fa0c 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -447,11 +447,11 @@ static void applyFaceNearest(TransInfo *t, 
TransDataContainer *tc, TransData *td
 
 bool transform_snap_project_individual_is_active(const TransInfo *t)
 {
-  if (!transform_snap_is_active(t) || (t->flag & T_NO_PROJECT)) {
+  if (!transform_snap_is_active(t)) {
 return false;
   }
 
-  if (!transform_snap_is_active(t) || (t->flag & T_NO_PROJECT)) {
+  if (t->flag & T_NO_PROJECT) {
 return false;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [63b9a57f8bd] master: Cleanup: use descriptive names for transform snapping functions

2023-01-09 Thread Germano Cavalcante
Commit: 63b9a57f8bd81135f8fc26a9bd219541a1f646f9
Author: Germano Cavalcante
Date:   Mon Jan 9 23:45:12 2023 -0300
Branches: master
https://developer.blender.org/rB63b9a57f8bd81135f8fc26a9bd219541a1f646f9

Cleanup: use descriptive names for transform snapping functions

activeSnap --> transform_snap_is_active
activeSnap_SnappingIndividual --> transform_snap_project_individual_is_active
activeSnap_SnappingAsGroup --> transform_snap_mixed_is_active
applySnappingIndividual --> transform_snap_project_individual_apply
applySnappingAsGroup --> transform_snap_mixed_apply

Also rearrange functions to be close to where they are used.

And use static when possible.

===

M   source/blender/editors/transform/transform_constraints.c
M   source/blender/editors/transform/transform_convert_armature.c
M   source/blender/editors/transform/transform_convert_curve.c
M   source/blender/editors/transform/transform_convert_lattice.c
M   source/blender/editors/transform/transform_convert_mball.c
M   source/blender/editors/transform/transform_convert_mesh.c
M   source/blender/editors/transform/transform_convert_node.cc
M   source/blender/editors/transform/transform_convert_object.c
M   source/blender/editors/transform/transform_convert_object_texspace.c
M   source/blender/editors/transform/transform_convert_particle.c
M   source/blender/editors/transform/transform_mode_edge_rotate_normal.c
M   source/blender/editors/transform/transform_mode_edge_seq_slide.c
M   source/blender/editors/transform/transform_mode_edge_slide.c
M   source/blender/editors/transform/transform_mode_resize.c
M   source/blender/editors/transform/transform_mode_rotate.c
M   source/blender/editors/transform/transform_mode_skin_resize.c
M   source/blender/editors/transform/transform_mode_translate.c
M   source/blender/editors/transform/transform_mode_vert_slide.c
M   source/blender/editors/transform/transform_snap.cc
M   source/blender/editors/transform/transform_snap.h
M   source/blender/editors/transform/transform_snap_animation.c

===

diff --git a/source/blender/editors/transform/transform_constraints.c 
b/source/blender/editors/transform/transform_constraints.c
index 4de000c96cf..b0db9398e80 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -393,7 +393,7 @@ static void applyAxisConstraintVec(const TransInfo *t,
   if (!td && t->con.mode & CON_APPLY) {
 bool is_snap_to_point = false, is_snap_to_edge = false, is_snap_to_face = 
false;
 
-if (activeSnap(t)) {
+if (transform_snap_is_active(t)) {
   if (validSnap(t)) {
 is_snap_to_edge = (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) != 0;
 is_snap_to_face = (t->tsnap.snapElem & SCE_SNAP_MODE_FACE_RAYCAST) != 
0;
diff --git a/source/blender/editors/transform/transform_convert_armature.c 
b/source/blender/editors/transform/transform_convert_armature.c
index 2e37f6b7c34..ada6d1c40b2 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -1193,7 +1193,7 @@ static void restoreBones(TransDataContainer *tc)
 static void recalcData_edit_armature(TransInfo *t)
 {
   if (t->state != TRANS_CANCEL) {
-applySnappingIndividual(t);
+transform_snap_project_individual_apply(t);
   }
 
   FOREACH_TRANS_DATA_CONTAINER (t, tc) {
diff --git a/source/blender/editors/transform/transform_convert_curve.c 
b/source/blender/editors/transform/transform_convert_curve.c
index 3a4098cf06f..58ed8ad7d33 100644
--- a/source/blender/editors/transform/transform_convert_curve.c
+++ b/source/blender/editors/transform/transform_convert_curve.c
@@ -419,7 +419,7 @@ static void createTransCurveVerts(bContext *UNUSED(C), 
TransInfo *t)
 static void recalcData_curve(TransInfo *t)
 {
   if (t->state != TRANS_CANCEL) {
-applySnappingIndividual(t);
+transform_snap_project_individual_apply(t);
   }
 
   FOREACH_TRANS_DATA_CONTAINER (t, tc) {
diff --git a/source/blender/editors/transform/transform_convert_lattice.c 
b/source/blender/editors/transform/transform_convert_lattice.c
index cb391b4930b..bc53ce02996 100644
--- a/source/blender/editors/transform/transform_convert_lattice.c
+++ b/source/blender/editors/transform/transform_convert_lattice.c
@@ -102,7 +102,7 @@ static void createTransLatticeVerts(bContext *UNUSED(C), 
TransInfo *t)
 static void recalcData_lattice(TransInfo *t)
 {
   if (t->state != TRANS_CANCEL) {
-applySnappingIndividual(t);
+transform_snap_project_individual_apply(t);
   }
 
   FOREACH_TRANS_DATA_CONTAINER (t, tc) {
diff --git a/source/blender/editors/transform/transform_convert_mball.c 
b/source/blender/editors/transform/transform_convert_mball

[Bf-blender-cvs] [fbc2c4c3317] master: Fix T102853: radius of spot and point lamps shares same value with area lamp size

2023-01-04 Thread Germano Cavalcante
Commit: fbc2c4c3317da40bc0c540fe31f41fe3f7802e48
Author: Germano Cavalcante
Date:   Wed Jan 4 11:48:52 2023 -0300
Branches: master
https://developer.blender.org/rBfbc2c4c3317da40bc0c540fe31f41fe3f7802e48

Fix T102853: radius of spot and point lamps shares same value with area lamp 
size

If we change the radius of a point or spot lamp, we also change the area lamp 
size.

As shown in T102853, this is bad for animating the lamp type.

The solution is to make the property point to another member of the DNA
struct `Light`.

Differential Revision: https://developer.blender.org/D16669

===

M   source/blender/blenkernel/BKE_blender_version.h
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenloader/intern/versioning_300.cc
M   source/blender/draw/engines/eevee/eevee_lights.c
M   source/blender/draw/engines/eevee_next/eevee_light.cc
M   source/blender/draw/engines/overlay/overlay_extra.cc
M   source/blender/io/collada/DocumentImporter.cpp
M   source/blender/io/collada/LightExporter.cpp
M   source/blender/io/usd/intern/usd_reader_light.cc
M   source/blender/io/usd/intern/usd_writer_light.cc
M   source/blender/makesdna/DNA_light_types.h
M   source/blender/makesrna/intern/rna_light.c

===

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 2ddda93c93b..c95c3a1a934 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 6
+#define BLENDER_FILE_SUBVERSION 7
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the 
file
diff --git a/source/blender/blenkernel/intern/object.cc 
b/source/blender/blenkernel/intern/object.cc
index 507d8f2a695..0622007d97d 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -2891,6 +2891,7 @@ void BKE_object_obdata_size_init(struct Object *ob, const 
float size)
 case OB_LAMP: {
   Light *lamp = (Light *)ob->data;
   lamp->dist *= size;
+  lamp->radius *= size;
   lamp->area_size *= size;
   lamp->area_sizey *= size;
   lamp->area_sizez *= size;
diff --git a/source/blender/blenloader/intern/versioning_300.cc 
b/source/blender/blenloader/intern/versioning_300.cc
index 4d9bbdfce77..38ecfaf41ea 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -28,6 +28,7 @@
 #include "DNA_curves_types.h"
 #include "DNA_genfile.h"
 #include "DNA_gpencil_modifier_types.h"
+#include "DNA_light_types.h"
 #include "DNA_lineart_types.h"
 #include "DNA_listBase.h"
 #include "DNA_mask_types.h"
@@ -3836,6 +3837,13 @@ void blo_do_versions_300(FileData *fd, Library * 
/*lib*/, Main *bmain)
   }
 }
   }
+
+  if (!MAIN_VERSION_ATLEAST(bmain, 305, 7)) {
+LISTBASE_FOREACH (Light *, light, >lights) {
+  light->radius = light->area_size;
+}
+  }
+
   /**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c 
b/source/blender/draw/engines/eevee/eevee_lights.c
index f8250f9520d..f1fde3cc22e 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -45,7 +45,7 @@ static void light_shape_parameters_set(EEVEE_Light *evli, 
const Light *la, const
 evli->sizey = scale[1] / scale[2];
 evli->spotsize = cosf(la->spotsize * 0.5f);
 evli->spotblend = (1.0f - evli->spotsize) * la->spotblend;
-evli->radius = max_ff(0.001f, la->area_size);
+evli->radius = max_ff(0.001f, la->radius);
   }
   else if (la->type == LA_AREA) {
 evli->sizex = max_ff(0.003f, la->area_size * scale[0] * 0.5f);
@@ -62,7 +62,7 @@ static void light_shape_parameters_set(EEVEE_Light *evli, 
const Light *la, const
 evli->radius = max_ff(0.001f, tanf(min_ff(la->sun_angle, DEG2RADF(179.9f)) 
/ 2.0f));
   }
   else {
-evli->radius = max_ff(0.001f, la->area_size);
+evli->radius = max_ff(0.001f, la->radius);
   }
 }
 
diff --git a/source/blender/draw/engines/eevee_next/eevee_light.cc 
b/source/blender/draw/engines/eevee_next/eevee_light.cc
index aa8268dbaa7..1c0e17470d7 100644
--- a/source/blender/draw/engines/eevee_next/eevee_light.cc
+++ b/source/blender/draw/engines/eevee_next/eevee_light.cc
@@ -178,7 +178,7 @@ void Light::shape_parameters_set(const ::Light *la, const 
float scale[3])

[Bf-blender-cvs] [22fec7b1a4a] master: Remove deprecated and long unused members of struct Light

2023-01-04 Thread Germano Cavalcante
Commit: 22fec7b1a4affb2e1261508db54d63b1ffcc37c7
Author: Germano Cavalcante
Date:   Wed Jan 4 11:22:57 2023 -0300
Branches: master
https://developer.blender.org/rB22fec7b1a4affb2e1261508db54d63b1ffcc37c7

Remove deprecated and long unused members of struct Light

The members `soft`, `bleedbias`, `bleedexp` and `contact_spread` were
deprecated in rBd8aaf25c23fa, and are no longer really used.

`soft` is only used by Collada as an extra value for exporting and
importing Blender files in collada.

`bleedexp` and `contact_spread` are only used in versioning to
initialize a default value.

Reviewed By: brecht, fclem

Differential Revision: https://developer.blender.org/D16834

===

M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/io/collada/DocumentImporter.cpp
M   source/blender/io/collada/LightExporter.cpp
M   source/blender/makesdna/DNA_light_defaults.h
M   source/blender/makesdna/DNA_light_types.h

===

diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index ffb87949234..09292841e91 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1782,12 +1782,6 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
 
   if (!MAIN_VERSION_ATLEAST(bmain, 280, 1)) {
-if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "bleedexp")) {
-  for (Light *la = bmain->lights.first; la; la = la->id.next) {
-la->bleedexp = 2.5f;
-  }
-}
-
 if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", 
"ratio")) {
   for (Camera *ca = bmain->cameras.first; ca; ca = ca->id.next) {
 ca->gpu_dof.ratio = 1.0f;
@@ -1820,7 +1814,6 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   for (Light *la = bmain->lights.first; la; la = la->id.next) {
 la->contact_dist = 0.2f;
 la->contact_bias = 0.03f;
-la->contact_spread = 0.2f;
 la->contact_thickness = 0.2f;
   }
 }
diff --git a/source/blender/io/collada/DocumentImporter.cpp 
b/source/blender/io/collada/DocumentImporter.cpp
index dae1c4ba894..51744953491 100644
--- a/source/blender/io/collada/DocumentImporter.cpp
+++ b/source/blender/io/collada/DocumentImporter.cpp
@@ -1017,7 +1017,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light 
*light)
 et->setData("clipsta", &(lamp->clipsta));
 et->setData("clipend", &(lamp->clipend));
 et->setData("bias", &(lamp->bias));
-et->setData("soft", &(lamp->soft));
 et->setData("bufsize", &(lamp->bufsize));
 et->setData("buffers", &(lamp->buffers));
 et->setData("area_shape", &(lamp->area_shape));
diff --git a/source/blender/io/collada/LightExporter.cpp 
b/source/blender/io/collada/LightExporter.cpp
index 33c041e790f..b5f9b56ba7c 100644
--- a/source/blender/io/collada/LightExporter.cpp
+++ b/source/blender/io/collada/LightExporter.cpp
@@ -129,7 +129,6 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light 
, Light *la)
   cla.addExtraTechniqueParameter("blender", "clipsta", la->clipsta);
   cla.addExtraTechniqueParameter("blender", "clipend", la->clipend);
   cla.addExtraTechniqueParameter("blender", "bias", la->bias);
-  cla.addExtraTechniqueParameter("blender", "soft", la->soft);
   cla.addExtraTechniqueParameter("blender", "bufsize", la->bufsize);
   cla.addExtraTechniqueParameter("blender", "samp", la->samp);
   cla.addExtraTechniqueParameter("blender", "buffers", la->buffers);
diff --git a/source/blender/makesdna/DNA_light_defaults.h 
b/source/blender/makesdna/DNA_light_defaults.h
index 7b03a51a727..b2cb7cfd686 100644
--- a/source/blender/makesdna/DNA_light_defaults.h
+++ b/source/blender/makesdna/DNA_light_defaults.h
@@ -28,10 +28,8 @@
 .bufsize = 512, \
 .clipsta = 0.05f, \
 .clipend = 40.0f, \
-.bleedexp = 2.5f, \
 .samp = 3, \
 .bias = 1.0f, \
-.soft = 3.0f, \
 .area_size = 0.25f, \
 .area_sizey = 0.25f, \
 .area_sizez = 0.25f, \
@@ -47,7 +45,6 @@
 .cascade_fade = 0.1f, \
 .contact_dist = 0.2f, \
 .contact_bias = 0.03f, \
-.contact_spread = 0.2f, \
 .contact_thickness = 0.2f, \
 .diff_fac = 1.0f, \
 .spec_fac = 1.0f, \
diff --git a/source/blender/makesdna/DNA_light_types.h 
b/source/blender/makesdna/DNA_light_types.h
index f1bf0580b94..86042369539 100644
--- a/source/blender/makesdna/DNA_light

[Bf-blender-cvs] [fb7f12dc407] master: Cleanup: hide 'UNUSED' macro definition for C++

2022-12-20 Thread Germano Cavalcante
Commit: fb7f12dc40780106fb159786fd3064bf80432a17
Author: Germano Cavalcante
Date:   Tue Dec 20 15:51:47 2022 -0300
Branches: master
https://developer.blender.org/rBfb7f12dc40780106fb159786fd3064bf80432a17

Cleanup: hide 'UNUSED' macro definition for C++

This may allow the `C4100` warning to be re-enabled in the MSVC for C++.

Differential Revision: https://developer.blender.org/D16828

===

M   source/blender/blenkernel/BKE_ccg.h
M   source/blender/blenkernel/intern/cloth.cc
M   source/blender/blenkernel/intern/data_transfer.cc
M   source/blender/blenkernel/intern/key.cc
M   source/blender/blenkernel/intern/layer.cc
M   source/blender/blenkernel/intern/linestyle.cc
M   source/blender/blenkernel/intern/material.cc
M   source/blender/blenkernel/intern/texture.cc
M   source/blender/blenlib/BLI_utildefines.h
M   source/blender/bmesh/intern/bmesh_mesh_normals.cc
M   source/blender/compositor/intern/COM_MetaData.h
M   source/blender/draw/engines/eevee/eevee_shaders.cc
M   source/blender/draw/engines/image/image_space_image.hh
M   source/blender/draw/intern/draw_cache_impl_curves.cc
M   source/blender/draw/intern/draw_cache_impl_gpencil.cc
M   source/blender/editors/geometry/geometry_attributes.cc
M   source/blender/editors/interface/interface_context_menu.cc
M   source/blender/editors/interface/interface_icons.cc
M   source/blender/editors/sculpt_paint/paint_cursor.cc
M   source/blender/editors/sculpt_paint/paint_image_proj.cc
M   source/blender/editors/space_buttons/buttons_texture.cc
M   source/blender/editors/space_clip/tracking_ops_orient.cc
M   source/blender/editors/transform/transform_snap.cc
M   source/blender/gpu/intern/gpu_codegen.cc
M   source/blender/modifiers/intern/MOD_displace.cc
M   source/blender/modifiers/intern/MOD_triangulate.cc
M   source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc
M   source/blender/nodes/intern/node_util.cc
M   source/blender/nodes/texture/node_texture_tree.cc
M   source/blender/nodes/texture/node_texture_util.cc
M   source/blender/nodes/texture/nodes/node_texture_at.cc
M   source/blender/nodes/texture/nodes/node_texture_bricks.cc
M   source/blender/nodes/texture/nodes/node_texture_checker.cc
M   source/blender/nodes/texture/nodes/node_texture_combine_color.cc
M   source/blender/nodes/texture/nodes/node_texture_compose.cc
M   source/blender/nodes/texture/nodes/node_texture_coord.cc
M   source/blender/nodes/texture/nodes/node_texture_curves.cc
M   source/blender/nodes/texture/nodes/node_texture_decompose.cc
M   source/blender/nodes/texture/nodes/node_texture_distance.cc
M   source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc
M   source/blender/nodes/texture/nodes/node_texture_image.cc
M   source/blender/nodes/texture/nodes/node_texture_invert.cc
M   source/blender/nodes/texture/nodes/node_texture_math.cc
M   source/blender/nodes/texture/nodes/node_texture_mixRgb.cc
M   source/blender/nodes/texture/nodes/node_texture_output.cc
M   source/blender/nodes/texture/nodes/node_texture_proc.cc
M   source/blender/nodes/texture/nodes/node_texture_rotate.cc
M   source/blender/nodes/texture/nodes/node_texture_scale.cc
M   source/blender/nodes/texture/nodes/node_texture_separate_color.cc
M   source/blender/nodes/texture/nodes/node_texture_texture.cc
M   source/blender/nodes/texture/nodes/node_texture_translate.cc
M   source/blender/nodes/texture/nodes/node_texture_valToNor.cc
M   source/blender/nodes/texture/nodes/node_texture_valToRgb.cc
M   source/blender/nodes/texture/nodes/node_texture_viewer.cc
M   source/blender/render/intern/engine.cc
M   source/blender/render/intern/multires_bake.cc

===

diff --git a/source/blender/blenkernel/BKE_ccg.h 
b/source/blender/blenkernel/BKE_ccg.h
index 786b84a0469..64b9870a8ea 100644
--- a/source/blender/blenkernel/BKE_ccg.h
+++ b/source/blender/blenkernel/BKE_ccg.h
@@ -83,7 +83,12 @@ BLI_INLINE CCGElem *CCG_elem_next(const CCGKey *key, CCGElem 
*elem);
 
 /* inline definitions follow */
 
-BLI_INLINE float *CCG_elem_co(const CCGKey *UNUSED(key), CCGElem *elem)
+BLI_INLINE float *CCG_elem_co(const CCGKey *
+#ifndef __cplusplus
+  UNUSED(key)
+#endif
+  ,
+  CCGElem *elem)
 {
   return (float *)elem;
 }
diff --git a/source/blender/blenkernel/intern/cloth.cc 
b/source/blender/blenkernel/intern/cloth.cc
index ecd21dcb570..73cf7e1f805 100644
--- a/source/blender/blenkernel/intern/cloth.cc
+++ b/source/blender/blenkernel/intern/cloth.cc
@@ -713,7 +713,7 @@ static float cloth_shrink_factor(ClothModifierData *clmd, 
ClothVertex *verts, in
 }
 
 static bool cloth_from_object(
-Object *ob

[Bf-blender-cvs] [cc139344425] master: Cleanup: convert 'MOD_mirror.c' to C++

2022-12-20 Thread Germano Cavalcante
Commit: cc139344425e91bb4262698c0a94d4171db7ff1a
Author: Germano Cavalcante
Date:   Tue Dec 20 15:08:18 2022 -0300
Branches: master
https://developer.blender.org/rBcc139344425e91bb4262698c0a94d4171db7ff1a

Cleanup: convert 'MOD_mirror.c' to C++

It will be useful to use the merge verts API in C++.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D16823

===

M   source/blender/modifiers/CMakeLists.txt
R089source/blender/modifiers/intern/MOD_mirror.c
source/blender/modifiers/intern/MOD_mirror.cc

===

diff --git a/source/blender/modifiers/CMakeLists.txt 
b/source/blender/modifiers/CMakeLists.txt
index 63be9581175..910876fa361 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -62,7 +62,7 @@ set(SRC
   intern/MOD_meshcache_util.c
   intern/MOD_meshdeform.c
   intern/MOD_meshsequencecache.cc
-  intern/MOD_mirror.c
+  intern/MOD_mirror.cc
   intern/MOD_multires.cc
   intern/MOD_nodes.cc
   intern/MOD_none.c
diff --git a/source/blender/modifiers/intern/MOD_mirror.c 
b/source/blender/modifiers/intern/MOD_mirror.cc
similarity index 89%
rename from source/blender/modifiers/intern/MOD_mirror.c
rename to source/blender/modifiers/intern/MOD_mirror.cc
index f1a36c04453..9e99a6b9a5e 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.cc
@@ -60,7 +60,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, 
IDWalkFunc walk, void *u
 static void updateDepsgraph(ModifierData *md, const 
ModifierUpdateDepsgraphContext *ctx)
 {
   MirrorModifierData *mmd = (MirrorModifierData *)md;
-  if (mmd->mirror_ob != NULL) {
+  if (mmd->mirror_ob != nullptr) {
 DEG_add_object_relation(ctx->node, mmd->mirror_ob, DEG_OB_COMP_TRANSFORM, 
"Mirror Modifier");
 DEG_add_depends_on_transform_relation(ctx->node, "Mirror Modifier");
   }
@@ -82,7 +82,7 @@ static Mesh *mirrorModifier__doMirror(MirrorModifierData 
*mmd, Object *ob, Mesh
 mmd, ob, result, 1, use_correct_order_on_merge);
 if (tmp != mesh) {
   /* free intermediate results */
-  BKE_id_free(NULL, tmp);
+  BKE_id_free(nullptr, tmp);
 }
   }
   if (mmd->flag & MOD_MIR_AXIS_Z) {
@@ -91,7 +91,7 @@ static Mesh *mirrorModifier__doMirror(MirrorModifierData 
*mmd, Object *ob, Mesh
 mmd, ob, result, 2, use_correct_order_on_merge);
 if (tmp != mesh) {
   /* free intermediate results */
-  BKE_id_free(NULL, tmp);
+  BKE_id_free(nullptr, tmp);
 }
   }
 
@@ -108,7 +108,7 @@ static Mesh *modifyMesh(ModifierData *md, const 
ModifierEvalContext *ctx, Mesh *
   return result;
 }
 
-static void panel_draw(const bContext *UNUSED(C), Panel *panel)
+static void panel_draw(const bContext * /*C*/, Panel *panel)
 {
   uiLayout *row, *col, *sub;
   uiLayout *layout = panel->layout;
@@ -141,7 +141,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel 
*panel)
 
   uiItemS(col);
 
-  uiItemR(col, ptr, "mirror_object", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "mirror_object", 0, nullptr, ICON_NONE);
 
   uiItemR(col, ptr, "use_clip", 0, IFACE_("Clipping"), ICON_NONE);
 
@@ -161,12 +161,12 @@ static void panel_draw(const bContext *UNUSED(C), Panel 
*panel)
   modifier_panel_end(layout, ptr);
 }
 
-static void data_panel_draw(const bContext *UNUSED(C), Panel *panel)
+static void data_panel_draw(const bContext * /*C*/, Panel *panel)
 {
   uiLayout *col, *row, *sub;
   uiLayout *layout = panel->layout;
 
-  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
+  PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
 
   uiLayoutSetPropSep(layout, true);
 
@@ -200,7 +200,7 @@ static void data_panel_draw(const bContext *UNUSED(C), 
Panel *panel)
 static void panelRegister(ARegionType *region_type)
 {
   PanelType *panel_type = modifier_panel_register(region_type, 
eModifierType_Mirror, panel_draw);
-  modifier_subpanel_register(region_type, "data", "Data", NULL, 
data_panel_draw, panel_type);
+  modifier_subpanel_register(region_type, "data", "Data", nullptr, 
data_panel_draw, panel_type);
 }
 
 ModifierTypeInfo modifierType_Mirror = {
@@ -218,24 +218,24 @@ ModifierTypeInfo modifierType_Mirror = {
 
 /* copyData */ BKE_modifier_copydata_generic,
 
-/* deformVerts */ NULL,
-/* deformMatrices */ NULL,
-/* deformVertsEM */ NULL,
-/* deformMatricesEM */ NULL,
+/* deformVerts */ nullptr,
+/* deformMatrices */ nullptr,
+/* deformVertsEM */ nullptr,
+/* deformMatricesEM */ nullptr,
 /* modifyMesh */ modifyMesh,
-/* modifyGeometrySet */ NULL,
+/* modifyGeometrySet */ nullptr,
 
 /* initData */ initData,
-/* requiredDataMask */ NULL,
-/* freeData */ N

[Bf-blender-cvs] [1a986f7ebad] master: Revert "Fix erratic mouse wrapping movement on Windows (2)"

2022-12-19 Thread Germano Cavalcante
Commit: 1a986f7ebad5ad49236ce312208a359a954ec496
Author: Germano Cavalcante
Date:   Mon Dec 19 10:06:47 2022 -0300
Branches: master
https://developer.blender.org/rB1a986f7ebad5ad49236ce312208a359a954ec496

Revert "Fix erratic mouse wrapping movement on Windows (2)"

This reverts commit a3a9459050a96e75138b3441c069898f211f179c.

And fixes T103337.

a3a9459050a9 has some flaws and it needs to go through review (See D16803).

Conflicts:
intern/ghost/intern/GHOST_SystemWin32.cpp

===

M   intern/ghost/intern/GHOST_SystemWin32.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index d1e0d138918..75a4cc8389a 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1061,16 +1061,11 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
 
   int32_t x_screen = screen_co[0], y_screen = screen_co[1];
   if (window->getCursorGrabModeIsWarp()) {
-static uint64_t last_warp_time = 0;
-{
-  /* WORKAROUND: Check the mouse event timestamp so we can ignore 
mouse-move events that were
-   * already in the queue before we changed the cursor position. */
-  MOUSEMOVEPOINT mp = {x_screen, y_screen};
-  ::GetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), , , 1, 
GMMP_USE_DISPLAY_POINTS);
-  if (mp.time <= last_warp_time) {
-return NULL;
-  }
-}
+/* WORKAROUND:
+ * Sometimes Windows ignores `SetCursorPos()` or `SendInput()` calls or 
the mouse event is
+ * outdated. Identify these cases by checking if the cursor is not yet 
within bounds. */
+static bool is_warping_x = false;
+static bool is_warping_y = false;
 
 int32_t x_new = x_screen;
 int32_t y_new = y_screen;
@@ -1117,35 +1112,31 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
 
 window->getCursorGrabAccum(x_accum, y_accum);
 if (x_new != x_screen || y_new != y_screen) {
-  /* WORKAROUND: Store the current time so that we ignore outdated 
mouse-move events. */
-  last_warp_time = ::GetTickCount64();
-
-  /* For more control over which timestamp to store in the event, we use 
`SendInput` instead of
-   * `SetCursorPos` here.
-   * It is quite unlikely to happen, but still possible that some event 
between
-   * `last_warp_time` and `GHOST_SystemWin32::setCursorPosition` is sent. 
*/
-  INPUT input[3] = {0};
-  input[0].type = INPUT_MOUSE;
-  input[0].mi.dx = (LONG)(x_new * (65535.0f / 
GetSystemMetrics(SM_CXSCREEN)));
-  input[0].mi.dy = (LONG)(y_new * (65535.0f / 
GetSystemMetrics(SM_CYSCREEN)));
-  input[0].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
-  input[0].mi.time = last_warp_time;
-
-  /* Send 3 events with a jitter to make sure Windows does not 
occasionally and
-   * inexplicably ignore `SetCursorPos` or `SendInput`. */
-  input[2] = input[1] = input[0];
-  input[1].mi.dx += 1;
-  ::SendInput(3, input, sizeof(INPUT));
-
-  x_accum += (x_screen - x_new);
-  y_accum += (y_screen - y_new);
+  system->setCursorPosition(x_new, y_new); /* wrap */
+
+  /* Do not update the accum values if we are an outdated or failed 
pos-warp event. */
+  if (!is_warping_x) {
+is_warping_x = x_new != x_screen;
+if (is_warping_x) {
+  x_accum += (x_screen - x_new);
+}
+  }
+
+  if (!is_warping_y) {
+is_warping_y = y_new != y_screen;
+if (is_warping_y) {
+  y_accum += (y_screen - y_new);
+}
+  }
   window->setCursorGrabAccum(x_accum, y_accum);
 
-  /* When wrapping we don't need to add an event because the `SendInput` 
call will cause new
-   * events after. */
+  /* When wrapping we don't need to add an event because the 
setCursorPosition call will cause
+   * a new event after. */
   return NULL;
 }
 
+is_warping_x = false;
+is_warping_y = false;
 x_screen += x_accum;
 y_screen += y_accum;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a3a9459050a] master: Fix erratic mouse wrapping movement on Windows (2)

2022-12-14 Thread Germano Cavalcante
Commit: a3a9459050a96e75138b3441c069898f211f179c
Author: Germano Cavalcante
Date:   Wed Dec 14 15:37:49 2022 -0300
Branches: master
https://developer.blender.org/rBa3a9459050a96e75138b3441c069898f211f179c

Fix erratic mouse wrapping movement on Windows (2)

This is a solution in response to the issues mentioned in comments on
rBe4f1d719080a and T103088.

Apparently the workaround of checking if the mouse is already inside
the area on the next event doesn't work for some tablets.

Perhaps the order of events or some very small jitter is causing this
issue on tablets. (Couldn't confirm).

Whatever the cause, the solution of checking the timestamp of the event
and thus ignoring the outdated ones is theoretically safer.

It is the same solution seen in MacOS.

Also calling `SendInput` 3 times every warp ensures that at least one
event is dispatched.

===

M   intern/ghost/intern/GHOST_SystemWin32.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 75a4cc8389a..8cb007a756a 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1061,11 +1061,16 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
 
   int32_t x_screen = screen_co[0], y_screen = screen_co[1];
   if (window->getCursorGrabModeIsWarp()) {
-/* WORKAROUND:
- * Sometimes Windows ignores `SetCursorPos()` or `SendInput()` calls or 
the mouse event is
- * outdated. Identify these cases by checking if the cursor is not yet 
within bounds. */
-static bool is_warping_x = false;
-static bool is_warping_y = false;
+static uint64_t last_warp_time = 0;
+{
+  /* WORKAROUND: Check the mouse event timestamp so we can ignore 
mousemove events that were
+   * already in the queue before we changed the cursor position. */
+  MOUSEMOVEPOINT mp = {x_screen, y_screen};
+  ::GetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), , , 1, 
GMMP_USE_DISPLAY_POINTS);
+  if (mp.time <= last_warp_time) {
+return NULL;
+  }
+}
 
 int32_t x_new = x_screen;
 int32_t y_new = y_screen;
@@ -1112,31 +1117,35 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
 
 window->getCursorGrabAccum(x_accum, y_accum);
 if (x_new != x_screen || y_new != y_screen) {
-  system->setCursorPosition(x_new, y_new); /* wrap */
-
-  /* Do not update the accum values if we are an outdated or failed 
pos-warp event. */
-  if (!is_warping_x) {
-is_warping_x = x_new != x_screen;
-if (is_warping_x) {
-  x_accum += (x_screen - x_new);
-}
-  }
-
-  if (!is_warping_y) {
-is_warping_y = y_new != y_screen;
-if (is_warping_y) {
-  y_accum += (y_screen - y_new);
-}
-  }
+  /* WORKAROUND: Store the current time so that we ignore outdated 
mousemove events. */
+  last_warp_time = ::GetTickCount64();
+
+  /* For more control over which timestamp to store in the event, we use 
`SendInput` instead of
+   * `SetCursorPos` here.
+   * It is quite unlikely to happen, but still possible that some event 
between
+   * `last_warp_time` and `GHOST_SystemWin32::setCursorPosition` is sent. 
*/
+  INPUT input[3] = {0};
+  input[0].type = INPUT_MOUSE;
+  input[0].mi.dx = (LONG)(x_new * (65535.0f / 
GetSystemMetrics(SM_CXSCREEN)));
+  input[0].mi.dy = (LONG)(y_new * (65535.0f / 
GetSystemMetrics(SM_CYSCREEN)));
+  input[0].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
+  input[0].mi.time = last_warp_time;
+
+  /* Send 3 events with a jitter to make sure Windows does not 
occasionally and
+   * inexplicably ignore `SetCursorPos` or `SendInput`. */
+  input[2] = input[1] = input[0];
+  input[1].mi.dx += 1;
+  ::SendInput(3, input, sizeof(INPUT));
+
+  x_accum += (x_screen - x_new);
+  y_accum += (y_screen - y_new);
   window->setCursorGrabAccum(x_accum, y_accum);
 
-  /* When wrapping we don't need to add an event because the 
setCursorPosition call will cause
-   * a new event after. */
+  /* When wrapping we don't need to add an event because the `SendInput` 
call will cause new
+   * events after. */
   return NULL;
 }
 
-is_warping_x = false;
-is_warping_y = false;
 x_screen += x_accum;
 y_screen += y_accum;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fe3110a2859] master: Fix FallbackCyclesBlitShader compilation error

2022-12-14 Thread Germano Cavalcante
Commit: fe3110a2859d84401dceda06fd41f3b082eae790
Author: Germano Cavalcante
Date:   Wed Dec 14 11:59:11 2022 -0300
Branches: master
https://developer.blender.org/rBfe3110a2859d84401dceda06fd41f3b082eae790

Fix FallbackCyclesBlitShader compilation error

Error: C0204: version directive must be first statement and may not be
repeated

===

M   intern/cycles/blender/display_driver.cpp

===

diff --git a/intern/cycles/blender/display_driver.cpp 
b/intern/cycles/blender/display_driver.cpp
index 3c347145117..60dd5e2c1d2 100644
--- a/intern/cycles/blender/display_driver.cpp
+++ b/intern/cycles/blender/display_driver.cpp
@@ -57,7 +57,6 @@ int BlenderDisplayShader::get_tex_coord_attrib_location()
 
 /* TODO move shaders to standalone .glsl file. */
 static const char *FALLBACK_VERTEX_SHADER =
-"#version 330\n"
 "uniform vec2 fullscreen;\n"
 "in vec2 texCoord;\n"
 "in vec2 pos;\n"
@@ -75,7 +74,6 @@ static const char *FALLBACK_VERTEX_SHADER =
 "}\n\0";
 
 static const char *FALLBACK_FRAGMENT_SHADER =
-"#version 330\n"
 "uniform sampler2D image_texture;\n"
 "in vec2 texCoord_interp;\n"
 "out vec4 fragColor;\n"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dba7837d449] master: Fix typo in rB2c5a525d6409

2022-12-14 Thread Germano Cavalcante
Commit: dba7837d449c6502600bd5bd907b89c7e860c7f0
Author: Germano Cavalcante
Date:   Wed Dec 14 09:21:49 2022 -0300
Branches: master
https://developer.blender.org/rBdba7837d449c6502600bd5bd907b89c7e860c7f0

Fix typo in rB2c5a525d6409

`MOD_MIR_AXIS_Y` -> `MOD_MIR_AXIS_Z`

This causes mirror-Z clipping to be non-functional.

===

M   source/blender/editors/transform/transform_convert.c

===

diff --git a/source/blender/editors/transform/transform_convert.c 
b/source/blender/editors/transform/transform_convert.c
index b5373b4fd6c..22f42d4ab5c 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1079,7 +1079,7 @@ void 
transform_convert_clip_mirror_modifier_apply(TransDataContainer *tc)
 continue;
   }
 
-  if ((mmd->flag & (MOD_MIR_AXIS_X | MOD_MIR_AXIS_Y | MOD_MIR_AXIS_Y)) == 
0) {
+  if ((mmd->flag & (MOD_MIR_AXIS_X | MOD_MIR_AXIS_Y | MOD_MIR_AXIS_Z)) == 
0) {
 continue;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2c5a525d640] master: Cleanup: indentation, remove and rename variables

2022-12-13 Thread Germano Cavalcante
Commit: 2c5a525d6409dec84c6ace8fb5d67d8f10f5889d
Author: Germano Cavalcante
Date:   Tue Dec 13 13:26:03 2022 -0300
Branches: master
https://developer.blender.org/rB2c5a525d6409dec84c6ace8fb5d67d8f10f5889d

Cleanup: indentation, remove and rename variables

The `transform_convert_clip_mirror_modifier_apply` code is made more readable 
by:
- decreasing indentation;
- removing `axis` and `tolerance` variables;
- renaming `int clip` to `bool is_clipping`;

===

M   source/blender/editors/transform/transform_convert.c

===

diff --git a/source/blender/editors/transform/transform_convert.c 
b/source/blender/editors/transform/transform_convert.c
index f9ad09b7a10..b5373b4fd6c 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1070,87 +1070,75 @@ void 
transform_convert_clip_mirror_modifier_apply(TransDataContainer *tc)
 {
   Object *ob = tc->obedit;
   ModifierData *md = ob->modifiers.first;
-  float tolerance[3] = {0.0f, 0.0f, 0.0f};
-  int axis = 0;
 
   for (; md; md = md->next) {
 if ((md->type == eModifierType_Mirror) && (md->mode & 
eModifierMode_Realtime)) {
   MirrorModifierData *mmd = (MirrorModifierData *)md;
 
-  if (mmd->flag & MOD_MIR_CLIPPING) {
-axis = 0;
-if (mmd->flag & MOD_MIR_AXIS_X) {
-  axis |= 1;
-  tolerance[0] = mmd->tolerance;
-}
-if (mmd->flag & MOD_MIR_AXIS_Y) {
-  axis |= 2;
-  tolerance[1] = mmd->tolerance;
-}
-if (mmd->flag & MOD_MIR_AXIS_Z) {
-  axis |= 4;
-  tolerance[2] = mmd->tolerance;
-}
-if (axis) {
-  float mtx[4][4], imtx[4][4];
-  int i;
+  if ((mmd->flag & MOD_MIR_CLIPPING) == 0) {
+continue;
+  }
 
-  if (mmd->mirror_ob) {
-float obinv[4][4];
+  if ((mmd->flag & (MOD_MIR_AXIS_X | MOD_MIR_AXIS_Y | MOD_MIR_AXIS_Y)) == 
0) {
+continue;
+  }
 
-invert_m4_m4(obinv, mmd->mirror_ob->object_to_world);
-mul_m4_m4m4(mtx, obinv, ob->object_to_world);
-invert_m4_m4(imtx, mtx);
-  }
+  float mtx[4][4], imtx[4][4];
 
-  TransData *td = tc->data;
-  for (i = 0; i < tc->data_len; i++, td++) {
-int clip;
-float loc[3], iloc[3];
+  if (mmd->mirror_ob) {
+float obinv[4][4];
 
-if (td->loc == NULL) {
-  break;
-}
+invert_m4_m4(obinv, mmd->mirror_ob->object_to_world);
+mul_m4_m4m4(mtx, obinv, ob->object_to_world);
+invert_m4_m4(imtx, mtx);
+  }
 
-if (td->flag & TD_SKIP) {
-  continue;
-}
+  TransData *td = tc->data;
+  for (int i = 0; i < tc->data_len; i++, td++) {
+float loc[3], iloc[3];
 
-copy_v3_v3(loc, td->loc);
-copy_v3_v3(iloc, td->iloc);
+if (td->loc == NULL) {
+  break;
+}
 
-if (mmd->mirror_ob) {
-  mul_m4_v3(mtx, loc);
-  mul_m4_v3(mtx, iloc);
-}
+if (td->flag & TD_SKIP) {
+  continue;
+}
 
-clip = 0;
-if (axis & 1) {
-  if (fabsf(iloc[0]) <= tolerance[0] || loc[0] * iloc[0] < 0.0f) {
-loc[0] = 0.0f;
-clip = 1;
-  }
-}
+copy_v3_v3(loc, td->loc);
+copy_v3_v3(iloc, td->iloc);
 
-if (axis & 2) {
-  if (fabsf(iloc[1]) <= tolerance[1] || loc[1] * iloc[1] < 0.0f) {
-loc[1] = 0.0f;
-clip = 1;
-  }
-}
-if (axis & 4) {
-  if (fabsf(iloc[2]) <= tolerance[2] || loc[2] * iloc[2] < 0.0f) {
-loc[2] = 0.0f;
-clip = 1;
-  }
-}
-if (clip) {
-  if (mmd->mirror_ob) {
-mul_m4_v3(imtx, loc);
-  }
-  copy_v3_v3(td->loc, loc);
-}
+if (mmd->mirror_ob) {
+  mul_m4_v3(mtx, loc);
+  mul_m4_v3(mtx, iloc);
+}
+
+bool is_clipping = false;
+if (mmd->flag & MOD_MIR_AXIS_X) {
+  if (fabsf(iloc[0]) <= mmd->tolerance || loc[0] * iloc[0] < 0.0f) {
+loc[0] = 0.0f;
+is_clipping = true;
+  }
+}
+
+if (mmd->flag & MOD_MIR_AXIS_Y) {
+  if (fabsf(iloc[1]) <= mmd->tolerance || loc[1] * iloc[1] < 0.0f) {
+loc[1] = 0.0f;
+is_clipping = true;
+  }
+}
+if (mmd->flag & MOD_MIR

[Bf-blender-cvs] [4dbb8e96c2e] master: Cleanup: silence warning

2022-12-08 Thread Germano Cavalcante
Commit: 4dbb8e96c2e16fd80fac9d9ed1b342c544a49256
Author: Germano Cavalcante
Date:   Thu Dec 8 08:53:05 2022 -0300
Branches: master
https://developer.blender.org/rB4dbb8e96c2e16fd80fac9d9ed1b342c544a49256

Cleanup: silence warning

Unused parameter in `mesh_merge_by_distance.cc`

===

M   source/blender/geometry/intern/mesh_merge_by_distance.cc

===

diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc 
b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index 5dce391c4f7..6116586a8cf 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -348,6 +348,7 @@ static void weld_vert_groups_setup(Span wvert,
* \endcode
*/
   BLI_assert(r_vert_groups_map.data() == vert_dest_map.data());
+  UNUSED_VARS_NDEBUG(vert_dest_map);
 
   const int vert_groups_len = wvert.size() - vert_kill_len;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [04693f90748] master: Mesh: small optimization and better readability in Merge by Distance

2022-12-07 Thread Germano Cavalcante
Commit: 04693f90748e6761fab626f4a66bd68ab9b2b55b
Author: Germano Cavalcante
Date:   Wed Dec 7 11:14:47 2022 -0300
Branches: master
https://developer.blender.org/rB04693f90748e6761fab626f4a66bd68ab9b2b55b

Mesh: small optimization and better readability in Merge by Distance

The optimization is done by removing the `len` member from the groups
and using fewer `for` loops.

But it's not a really impactful optimization.
Only 1.9% in the weld operation of a high poly mesh.
(disregarding getting the vertex map and all other operations on a
Blender frame).

The readability improvement comes from using more familiar types like
`int` and `int2` instead of `WeldGroup` and `WeldGroupEdge` structs.

===

M   source/blender/geometry/intern/mesh_merge_by_distance.cc

===

diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc 
b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index 2cafed66b83..5dce391c4f7 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -26,19 +26,6 @@ namespace blender::geometry {
 /* indicates whether an edge or vertex in groups_map will be merged. */
 #define ELEM_MERGED int(-2)
 
-/* Used to indicate a range in an array specifying a group. */
-struct WeldGroup {
-  int len;
-  int offs;
-};
-
-/* Edge groups that will be merged. Final vertices are also indicated. */
-struct WeldGroupEdge {
-  struct WeldGroup group;
-  int v1;
-  int v2;
-};
-
 struct WeldVert {
   /* Indices relative to the original Mesh. */
   int vert_dest;
@@ -83,22 +70,25 @@ struct WeldPoly {
   /* Final Polygon Size. */
   int loop_len;
   /* Group of loops that will be affected. */
-  struct WeldGroup loops;
+  struct {
+int len;
+int offs;
+  } loops;
 };
   };
 };
 
 struct WeldMesh {
   /* Group of vertices to be merged. */
-  Array vert_groups;
+  Array vert_groups_offs;
   Array vert_groups_buffer;
 
   /* Group of edges to be merged. */
-  Array edge_groups;
+  Array edge_groups_offs;
   Array edge_groups_buffer;
-  /* From the original index of the vertex, this indicates which group it is 
or is going to be
-   * merged. */
+  /* From the original edge index, this indicates which group it is going to 
be merged. */
   Array edge_groups_map;
+  Array edge_groups_verts;
 
   /* References all polygons and loops that will be affected. */
   Vector wloop;
@@ -342,53 +332,62 @@ static Vector 
weld_vert_ctx_alloc_and_setup(Span vert_dest_map,
  */
 static void weld_vert_groups_setup(Span wvert,
Span vert_dest_map,
+   const int vert_kill_len,
MutableSpan r_vert_groups_map,
Array _vert_groups_buffer,
-   Array _vert_groups_offs)
+   Array _vert_groups_offs)
 {
-  /* Get weld vert groups. */
+  /**
+   * Since `r_vert_groups_map` comes from `vert_dest_map`, we don't need to 
reset vertices out of
+   * context again.
+   *
+   * \code{.c}
+   * for (const int i : vert_dest_map.index_range()) {
+   *   r_vert_groups_map[i] = OUT_OF_CONTEXT;
+   * }
+   * \endcode
+   */
+  BLI_assert(r_vert_groups_map.data() == vert_dest_map.data());
+
+  const int vert_groups_len = wvert.size() - vert_kill_len;
+
+  /* Add +1 to allow calculation of the length of the last group. */
+  r_vert_groups_offs.reinitialize(vert_groups_len + 1);
+  r_vert_groups_offs.fill(0);
 
   int wgroups_len = 0;
-  for (const int i : vert_dest_map.index_range()) {
-const int vert_dest = vert_dest_map[i];
-if (vert_dest != OUT_OF_CONTEXT) {
-  if (vert_dest != i) {
-r_vert_groups_map[i] = ELEM_MERGED;
-  }
-  else {
-r_vert_groups_map[i] = wgroups_len;
-wgroups_len++;
-  }
+  for (const WeldVert  : wvert) {
+if (wv.vert_dest == wv.vert_orig) {
+  /* Indicate the index of the vertex group */
+  r_vert_groups_map[wv.vert_orig] = wgroups_len;
+  wgroups_len++;
 }
 else {
-  r_vert_groups_map[i] = OUT_OF_CONTEXT;
+  r_vert_groups_map[wv.vert_orig] = ELEM_MERGED;
 }
   }
 
-  r_vert_groups_offs.reinitialize(wgroups_len);
-  r_vert_groups_offs.fill({0, 0});
-
   for (const WeldVert  : wvert) {
 int group_index = r_vert_groups_map[wv.vert_dest];
-r_vert_groups_offs[group_index].len++;
+r_vert_groups_offs[group_index]++;
   }
 
   int offs = 0;
-  for (WeldGroup  : r_vert_groups_offs) {
-wg.offs = offs;
-offs += wg.len;
+  for (const int i : IndexRange(vert_groups_len)) {
+offs += r_vert_groups_offs[i];
+r_vert_groups_offs[i] = offs;
   }
+  r_vert_groups_offs[vert_groups_len] = offs;
 
   BLI_assert(offs == wvert.size());
 
   r_vert_groups_buffer.reinitialize(offs

[Bf-blender-cvs] [4e3494b5882] master: Cleanup: rename 'ofs' to 'offs'

2022-12-07 Thread Germano Cavalcante
Commit: 4e3494b5882e6ef81a20720b7f73bc884773b797
Author: Germano Cavalcante
Date:   Wed Dec 7 21:34:28 2022 -0300
Branches: master
https://developer.blender.org/rB4e3494b5882e6ef81a20720b7f73bc884773b797

Cleanup: rename 'ofs' to 'offs'

Also remove unnecessary `wegroups` variable.

Also, don't create the `wegroups` variable just to rename another one.

===

M   source/blender/geometry/intern/mesh_merge_by_distance.cc

===

diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc 
b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index e5968c092a1..2cafed66b83 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -29,7 +29,7 @@ namespace blender::geometry {
 /* Used to indicate a range in an array specifying a group. */
 struct WeldGroup {
   int len;
-  int ofs;
+  int offs;
 };
 
 /* Edge groups that will be merged. Final vertices are also indicated. */
@@ -284,10 +284,10 @@ static void weld_assert_poly_len(const WeldPoly *wp, 
const Span wloop)
   }
 
   int loop_len = wp->loop_len;
-  const WeldLoop *wl = [wp->loops.ofs];
+  const WeldLoop *wl = [wp->loops.offs];
   BLI_assert(wp->loop_start <= wl->loop_orig);
 
-  int end_wloop = wp->loops.ofs + wp->loops.len;
+  int end_wloop = wp->loops.offs + wp->loops.len;
   const WeldLoop *wl_end = [end_wloop - 1];
 
   int min_len = 0;
@@ -373,22 +373,22 @@ static void weld_vert_groups_setup(Span wvert,
 r_vert_groups_offs[group_index].len++;
   }
 
-  int ofs = 0;
+  int offs = 0;
   for (WeldGroup  : r_vert_groups_offs) {
-wg.ofs = ofs;
-ofs += wg.len;
+wg.offs = offs;
+offs += wg.len;
   }
 
-  BLI_assert(ofs == wvert.size());
+  BLI_assert(offs == wvert.size());
 
-  r_vert_groups_buffer.reinitialize(ofs);
+  r_vert_groups_buffer.reinitialize(offs);
   for (const WeldVert  : wvert) {
 int group_index = r_vert_groups_map[wv.vert_dest];
-r_vert_groups_buffer[r_vert_groups_offs[group_index].ofs++] = wv.vert_orig;
+r_vert_groups_buffer[r_vert_groups_offs[group_index].offs++] = 
wv.vert_orig;
   }
 
   for (WeldGroup  : r_vert_groups_offs) {
-wg.ofs -= wg.len;
+wg.offs -= wg.len;
   }
 }
 
@@ -477,7 +477,7 @@ static void weld_edge_ctx_setup(MutableSpan 
r_vlinks,
 
   int link_len = 0;
   for (WeldGroup  : r_vlinks) {
-vl.ofs = link_len;
+vl.offs = link_len;
 link_len += vl.len;
   }
 
@@ -493,13 +493,13 @@ static void weld_edge_ctx_setup(MutableSpan 
r_vlinks,
   int dst_vert_a = we.vert_a;
   int dst_vert_b = we.vert_b;
 
-  link_edge_buffer[r_vlinks[dst_vert_a].ofs++] = i;
-  link_edge_buffer[r_vlinks[dst_vert_b].ofs++] = i;
+  link_edge_buffer[r_vlinks[dst_vert_a].offs++] = i;
+  link_edge_buffer[r_vlinks[dst_vert_b].offs++] = i;
 }
 
 for (WeldGroup  : r_vlinks) {
   /* Fix offset */
-  vl.ofs -= vl.len;
+  vl.offs -= vl.len;
 }
 
 for (const int i : r_wedge.index_range()) {
@@ -523,8 +523,8 @@ static void weld_edge_ctx_setup(MutableSpan 
r_vlinks,
 continue;
   }
 
-  int *edges_ctx_a = _edge_buffer[link_a->ofs];
-  int *edges_ctx_b = _edge_buffer[link_b->ofs];
+  int *edges_ctx_a = _edge_buffer[link_a->offs];
+  int *edges_ctx_b = _edge_buffer[link_b->offs];
   int edge_orig = we.edge_orig;
 
   for (; edges_len_a--; edges_ctx_a++) {
@@ -579,7 +579,6 @@ static void weld_edge_groups_setup(const int medge_len,
   int wgroups_len = wedge.size() - edge_kill_len;
   r_edge_groups_offs.reinitialize(wgroups_len);
   r_edge_groups_offs.fill({{0}});
-  MutableSpan wegroups = r_edge_groups_offs;
 
   wgroups_len = 0;
   for (const int i : IndexRange(medge_len)) {
@@ -593,8 +592,8 @@ static void weld_edge_groups_setup(const int medge_len,
   }
   else {
 we->edge_dest = we->edge_orig;
-wegroups[wgroups_len].v1 = we->vert_a;
-wegroups[wgroups_len].v2 = we->vert_b;
+r_edge_groups_offs[wgroups_len].v1 = we->vert_a;
+r_edge_groups_offs[wgroups_len].v2 = we->vert_b;
 r_edge_groups_map[i] = wgroups_len;
 wgroups_len++;
   }
@@ -616,26 +615,26 @@ static void weld_edge_groups_setup(const int medge_len,
   continue;
 }
 int group_index = r_edge_groups_map[we.edge_dest];
-wegroups[group_index].group.len++;
+r_edge_groups_offs[group_index].group.len++;
   }
 
-  int ofs = 0;
-  for (WeldGroupEdge  : wegroups) {
-wegrp.group.ofs = ofs;
-ofs += wegrp.group.len;
+  int offs = 0;
+  for (WeldGroupEdge  : r_edge_groups_offs) {
+wegrp.group.offs = offs;
+offs += wegrp.group.len;
   }
 
-  r_edge_groups_buffer.reinitialize(ofs);
+  r_edge_groups_buffer.reinitialize(offs);
   for (const WeldEdge  : wedge) {
 if (we.flag == ELEM_COLLAPSED) {

[Bf-blender-cvs] [8410e7f8576] master: Cleanup: use more descriptive names for variables

2022-12-07 Thread Germano Cavalcante
Commit: 8410e7f8576db42077e492f6ceb35b41427ce835
Author: Germano Cavalcante
Date:   Wed Dec 7 12:33:48 2022 -0300
Branches: master
https://developer.blender.org/rB8410e7f8576db42077e492f6ceb35b41427ce835

Cleanup: use more descriptive names for variables

In the merge_by_distance code, `vert_dest_map` is modified to become a
vertex group map. But this is not clear from the code.

Also use the `_map` suffix on `vert_final` and `edge_final`.

And remove some unnecessary variables.

===

M   source/blender/geometry/intern/mesh_merge_by_distance.cc

===

diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc 
b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index 99cdb9cb7d9..f9fb613fbd2 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -41,7 +41,7 @@ struct WeldGroupEdge {
 };
 
 struct WeldVert {
-  /* Indexes relative to the original Mesh. */
+  /* Indices relative to the original Mesh. */
   int vert_dest;
   int vert_orig;
 };
@@ -50,7 +50,7 @@ struct WeldEdge {
   union {
 int flag;
 struct {
-  /* Indexes relative to the original Mesh. */
+  /* Indices relative to the original Mesh. */
   int edge_dest;
   int edge_orig;
   int vert_a;
@@ -63,7 +63,7 @@ struct WeldLoop {
   union {
 int flag;
 struct {
-  /* Indexes relative to the original Mesh. */
+  /* Indices relative to the original Mesh. */
   int vert;
   int edge;
   int loop_orig;
@@ -76,7 +76,7 @@ struct WeldPoly {
   union {
 int flag;
 struct {
-  /* Indexes relative to the original Mesh. */
+  /* Indices relative to the original Mesh. */
   int poly_dst;
   int poly_orig;
   int loop_start;
@@ -312,6 +312,11 @@ static void weld_assert_poly_len(const WeldPoly *wp, const 
Span wloop)
 /** \name Vert API
  * \{ */
 
+/**
+ * Create a Weld Verts Context.
+ *
+ * \return array with the context weld vertices.
+ */
 static Vector weld_vert_ctx_alloc_and_setup(Span vert_dest_map,
   const int vert_kill_len)
 {
@@ -329,11 +334,18 @@ static Vector 
weld_vert_ctx_alloc_and_setup(Span vert_dest_map,
   return wvert;
 }
 
+/**
+ * Create groups of vertices to merge.
+ *
+ * \return r_vert_groups_map: Map that points out the group of vertices that a 
vertex belongs to.
+ * \return r_vert_groups_buffer: Buffer containing the indices of all vertices 
that merge.
+ * \return r_vert_groups_offs: Array that indicates where each vertex group 
starts in the buffer.
+ */
 static void weld_vert_groups_setup(Span wvert,
Span vert_dest_map,
MutableSpan r_vert_groups_map,
Array _vert_groups_buffer,
-   Array _vert_groups)
+   Array _vert_groups_offs)
 {
   /* Get weld vert groups. */
 
@@ -354,17 +366,16 @@ static void weld_vert_groups_setup(Span wvert,
 }
   }
 
-  r_vert_groups.reinitialize(wgroups_len);
-  r_vert_groups.fill({0, 0});
-  MutableSpan wgroups = r_vert_groups;
+  r_vert_groups_offs.reinitialize(wgroups_len);
+  r_vert_groups_offs.fill({0, 0});
 
   for (const WeldVert  : wvert) {
 int group_index = r_vert_groups_map[wv.vert_dest];
-wgroups[group_index].len++;
+r_vert_groups_offs[group_index].len++;
   }
 
   int ofs = 0;
-  for (WeldGroup  : wgroups) {
+  for (WeldGroup  : r_vert_groups_offs) {
 wg.ofs = ofs;
 ofs += wg.len;
   }
@@ -374,10 +385,10 @@ static void weld_vert_groups_setup(Span wvert,
   r_vert_groups_buffer.reinitialize(ofs);
   for (const WeldVert  : wvert) {
 int group_index = r_vert_groups_map[wv.vert_dest];
-r_vert_groups_buffer[wgroups[group_index].ofs++] = wv.vert_orig;
+r_vert_groups_buffer[r_vert_groups_offs[group_index].ofs++] = wv.vert_orig;
   }
 
-  for (WeldGroup  : wgroups) {
+  for (WeldGroup  : r_vert_groups_offs) {
 wg.ofs -= wg.len;
   }
 }
@@ -388,6 +399,12 @@ static void weld_vert_groups_setup(Span wvert,
 /** \name Edge API
  * \{ */
 
+/**
+ * Alloc Weld Edges.
+ *
+ * \return r_edge_dest_map: First step to create map of indices pointing edges 
that will be merged.
+ * \return r_edge_ctx_map: Map of indices pointing original edges to weld 
context edges.
+ */
 static Vector weld_edge_ctx_alloc(Span medge,
 Span vert_dest_map,
 MutableSpan r_edge_dest_map,
@@ -423,15 +440,25 @@ static Vector weld_edge_ctx_alloc(Span 
medge,
   return wedge;
 }
 
+/**
+ * Configure Weld Edges.
+ *
+ * \param r_vlinks: An uninitialized buffer used to compute groups of 
WeldEdges attached to each
+ *  weld target vertex. It doesn't need to be passed

[Bf-blender-cvs] [81b9a475d37] master: Cleanup: remove inactive and outdated code

2022-12-07 Thread Germano Cavalcante
Commit: 81b9a475d379d799a330d1002f4f3324d4552def
Author: Germano Cavalcante
Date:   Wed Dec 7 19:55:12 2022 -0300
Branches: master
https://developer.blender.org/rB81b9a475d379d799a330d1002f4f3324d4552def

Cleanup: remove inactive and outdated code

`USE_WELD_NORMALS` no longer works

===

M   source/blender/geometry/intern/mesh_merge_by_distance.cc

===

diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc 
b/source/blender/geometry/intern/mesh_merge_by_distance.cc
index f9fb613fbd2..e5968c092a1 100644
--- a/source/blender/geometry/intern/mesh_merge_by_distance.cc
+++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc
@@ -16,7 +16,6 @@
 #include "GEO_mesh_merge_by_distance.hh"
 
 //#define USE_WELD_DEBUG
-//#define USE_WELD_NORMALS
 
 namespace blender::geometry {
 
@@ -1277,9 +1276,6 @@ static void customdata_weld(
   int j;
 
   float co[3] = {0.0f, 0.0f, 0.0f};
-#ifdef USE_WELD_NORMALS
-  float no[3] = {0.0f, 0.0f, 0.0f};
-#endif
   short flag = 0;
 
   /* interpolates a layer at a time */
@@ -1307,12 +1303,6 @@ static void customdata_weld(
 for (j = 0; j < count; j++) {
   MVert *mv_src = &((MVert *)src_data)[src_indices[j]];
   add_v3_v3(co, mv_src->co);
-#ifdef USE_WELD_NORMALS
-  short *mv_src_no = mv_src->no;
-  no[0] += mv_src_no[0];
-  no[1] += mv_src_no[1];
-  no[2] += mv_src_no[2];
-#endif
 }
   }
   else if (type == CD_MEDGE) {
@@ -1356,13 +1346,6 @@ static void customdata_weld(
   mul_v3_fl(co, fac);
 
   copy_v3_v3(mv->co, co);
-#ifdef USE_WELD_NORMALS
-  mul_v3_fl(no, fac);
-  short *mv_no = mv->no;
-  mv_no[0] = short(no[0]);
-  mv_no[1] = short(no[1]);
-  mv_no[2] = short(no[2]);
-#endif
 }
 else if (type == CD_MEDGE) {
   MEdge *me = &((MEdge *)layer_dst->data)[dest_index];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [294e41477b3] master: Fix T102961: mirrored vertices sometimes get locked in transform

2022-12-05 Thread Germano Cavalcante
Commit: 294e41477b326926fc258254a073ae5515bd8e9d
Author: Germano Cavalcante
Date:   Mon Dec 5 19:10:54 2022 -0300
Branches: master
https://developer.blender.org/rB294e41477b326926fc258254a073ae5515bd8e9d

Fix T102961: mirrored vertices sometimes get locked in transform

Two vertices within the threshold can mirror each other causing neither
to be transformed.

===

M   source/blender/editors/transform/transform_convert_mesh.c

===

diff --git a/source/blender/editors/transform/transform_convert_mesh.c 
b/source/blender/editors/transform/transform_convert_mesh.c
index 3192b1b6786..d8442175ab0 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -1231,6 +1231,12 @@ void transform_convert_mesh_mirrordata_calc(struct 
BMEditMesh *em,
  * It can happen when vertices occupy the same position. */
 continue;
   }
+  if (vert_map[i].flag & flag) {
+/* It's already a mirror.
+ * Avoid a mirror vertex dependency cycle.
+ * This can happen when the vertices are within the mirror threshold. 
*/
+continue;
+  }
 
   vert_map[i_mirr] = (struct MirrorDataVert){i, flag};
   mirror_elem_len++;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8fa8cea8e01] master: Fix PyGPU: return NULL instead of PyNone on error

2022-11-29 Thread Germano Cavalcante
Commit: 8fa8cea8e016b0c9e615501380a22adb02021599
Author: Germano Cavalcante
Date:   Tue Nov 29 13:59:52 2022 -0300
Branches: master
https://developer.blender.org/rB8fa8cea8e016b0c9e615501380a22adb02021599

Fix PyGPU: return NULL instead of PyNone on error 

Error in d7f124f06f3fda59523ed05f12d1f4af6a523ba6

===

M   source/blender/python/gpu/gpu_py.c

===

diff --git a/source/blender/python/gpu/gpu_py.c 
b/source/blender/python/gpu/gpu_py.c
index 34557f0115b..a3948ebad15 100644
--- a/source/blender/python/gpu/gpu_py.c
+++ b/source/blender/python/gpu/gpu_py.c
@@ -56,13 +56,13 @@ static const char g_error[] = "GPU API is not available in 
background mode";
 static PyObject *py_error__ml_meth(PyObject *UNUSED(self), PyObject 
*UNUSED(args))
 {
   PyErr_SetString(PyExc_SystemError, g_error);
-  Py_RETURN_NONE;
+  return NULL;
 }
 
 static PyObject *py_error__getter(PyObject *UNUSED(self), void *UNUSED(type))
 {
   PyErr_SetString(PyExc_SystemError, g_error);
-  Py_RETURN_NONE;
+  return NULL;
 }
 
 static int py_error__setter(PyObject *UNUSED(self), PyObject *value, void 
*UNUSED(type))

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d7f124f06f3] master: Fix T102845: GPU python crash in background mode

2022-11-29 Thread Germano Cavalcante
Commit: d7f124f06f3fda59523ed05f12d1f4af6a523ba6
Author: Germano Cavalcante
Date:   Tue Nov 29 13:55:37 2022 -0300
Branches: master
https://developer.blender.org/rBd7f124f06f3fda59523ed05f12d1f4af6a523ba6

Fix T102845: GPU python crash in background mode

`BPYGPU_IS_INIT_OR_ERROR_OBJ` is not implemented in all pygpu functions.

Instead of copying and pasting that call across the API when it has no
gpu context, override the methods with one that always reports error.

===

M   source/blender/python/gpu/gpu_py.c
M   source/blender/python/gpu/gpu_py.h
M   source/blender/python/gpu/gpu_py_api.c
M   source/blender/python/gpu/gpu_py_batch.c
M   source/blender/python/gpu/gpu_py_capabilities.c
M   source/blender/python/gpu/gpu_py_element.c
M   source/blender/python/gpu/gpu_py_framebuffer.c
M   source/blender/python/gpu/gpu_py_matrix.c
M   source/blender/python/gpu/gpu_py_offscreen.c
M   source/blender/python/gpu/gpu_py_platform.c
M   source/blender/python/gpu/gpu_py_select.c
M   source/blender/python/gpu/gpu_py_shader.c
M   source/blender/python/gpu/gpu_py_state.c
M   source/blender/python/gpu/gpu_py_texture.c
M   source/blender/python/gpu/gpu_py_types.c
M   source/blender/python/gpu/gpu_py_uniformbuffer.c

===

diff --git a/source/blender/python/gpu/gpu_py.c 
b/source/blender/python/gpu/gpu_py.c
index 987d2fbd627..34557f0115b 100644
--- a/source/blender/python/gpu/gpu_py.c
+++ b/source/blender/python/gpu/gpu_py.c
@@ -51,16 +51,72 @@ struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
 /** \name Utilities
  * \{ */
 
-bool bpygpu_is_init_or_error(void)
+static const char g_error[] = "GPU API is not available in background mode";
+
+static PyObject *py_error__ml_meth(PyObject *UNUSED(self), PyObject 
*UNUSED(args))
 {
-  if (!GPU_is_init()) {
-PyErr_SetString(PyExc_SystemError,
-"GPU functions for drawing are not available in background 
mode");
+  PyErr_SetString(PyExc_SystemError, g_error);
+  Py_RETURN_NONE;
+}
+
+static PyObject *py_error__getter(PyObject *UNUSED(self), void *UNUSED(type))
+{
+  PyErr_SetString(PyExc_SystemError, g_error);
+  Py_RETURN_NONE;
+}
+
+static int py_error__setter(PyObject *UNUSED(self), PyObject *value, void 
*UNUSED(type))
+{
+  PyErr_SetString(PyExc_SystemError, g_error);
+  return -1;
+}
+
+static PyObject *py_error__tp_new(PyTypeObject *UNUSED(type),
+  PyObject *UNUSED(args),
+  PyObject *UNUSED(kwds))
+{
+  PyErr_SetString(PyExc_SystemError, g_error);
+  return NULL;
+}
+
+PyObject *bpygpu_create_module(PyModuleDef *module_type)
+{
+  if (!GPU_is_init() && module_type->m_methods) {
+/* Replace all methods with an error method.
+ * That way when the method is called, an error will appear instead. */
+for (PyMethodDef *meth = module_type->m_methods; meth->ml_name; meth++) {
+  meth->ml_meth = py_error__ml_meth;
+}
+  }
 
-return false;
+  PyObject *module = PyModule_Create(module_type);
+
+  return module;
+}
+
+int bpygpu_finalize_type(PyTypeObject *py_type)
+{
+  if (!GPU_is_init()) {
+if (py_type->tp_methods) {
+  /* Replace all methods with an error method. */
+  for (PyMethodDef *meth = py_type->tp_methods; meth->ml_name; meth++) {
+meth->ml_meth = py_error__ml_meth;
+  }
+}
+if (py_type->tp_getset) {
+  /* Replace all getters and setter with a functions that always returns 
error. */
+  for (PyGetSetDef *getset = py_type->tp_getset; getset->name; getset++) {
+getset->get = py_error__getter;
+getset->set = py_error__setter;
+  }
+}
+if (py_type->tp_new) {
+  /* If initialized, return error. */
+  py_type->tp_new = py_error__tp_new;
+}
   }
 
-  return true;
+  return PyType_Ready(py_type);
 }
 
 /** \} */
diff --git a/source/blender/python/gpu/gpu_py.h 
b/source/blender/python/gpu/gpu_py.h
index 2914e370cdc..c0abb60d419 100644
--- a/source/blender/python/gpu/gpu_py.h
+++ b/source/blender/python/gpu/gpu_py.h
@@ -9,15 +9,5 @@
 extern struct PyC_StringEnumItems bpygpu_primtype_items[];
 extern struct PyC_StringEnumItems bpygpu_dataformat_items[];
 
-bool bpygpu_is_init_or_error(void);
-
-#define BPYGPU_IS_INIT_OR_ERROR_OBJ \
-  if (UNLIKELY(!bpygpu_is_init_or_error())) { \
-return NULL; \
-  } \
-  ((void)0)
-#define BPYGPU_IS_INIT_OR_ERROR_INT \
-  if (UNLIKELY(!bpygpu_is_init_or_error())) { \
-return -1; \
-  } \
-  ((void)0)
+PyObject *bpygpu_create_module(PyModuleDef *module_type);
+int bpygpu_finalize_type(PyTypeObject *py_type);
diff --git a/source/blender/python/gpu/gpu_py_api.c 
b/source/blender/python/gpu/gpu_py_api.c
index 8f5897be649..abba2e83cd6 100644
--- a/source/blender/python/gpu/gpu_py_api.c

[Bf-blender-cvs] [da363d831b8] master: Fix assert when calling transform operators in python handles

2022-11-28 Thread Germano Cavalcante
Commit: da363d831b865df8636189d98499f16613419685
Author: Germano Cavalcante
Date:   Mon Nov 28 15:49:18 2022 -0300
Branches: master
https://developer.blender.org/rBda363d831b865df8636189d98499f16613419685

Fix assert when calling transform operators in python handles

In these cases `t->spacetype` is `SPACE_EMPTY`.

Returning 0 is not problematic as this space does not support snapping
anyway.

===

M   source/blender/editors/transform/transform_snap.cc

===

diff --git a/source/blender/editors/transform/transform_snap.cc 
b/source/blender/editors/transform/transform_snap.cc
index 78752ec7846..014e909b5f4 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -627,10 +627,9 @@ static eSnapFlag snap_flag_from_spacetype(TransInfo *t)
   /* These editors have their own "Auto-Snap" activation option.
* See #getAnimEdit_SnapMode. */
   return eSnapFlag(0);
-default:
-  BLI_assert(false);
-  break;
   }
+  /* #SPACE_EMPTY.
+   * It can happen when the operator is called via a handle in 
`bpy.app.handlers`. */
   return eSnapFlag(0);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [19bb30baf60] master: Fix T102735: Knife tool does not work properly in perspective viewport

2022-11-28 Thread Germano Cavalcante
Commit: 19bb30baf6057d39a45f1e8693c6abcaceca84db
Author: Germano Cavalcante
Date:   Wed Nov 23 23:14:56 2022 -0300
Branches: master
https://developer.blender.org/rB19bb30baf6057d39a45f1e8693c6abcaceca84db

Fix T102735: Knife tool does not work properly in perspective viewport

Use `ED_view3d_win_to_3d` to unproject the first click coords.

This is the same function used in other tools like Draw Curve.

Differential revision: https://developer.blender.org/D16617

===

M   source/blender/editors/mesh/editmesh_knife.c

===

diff --git a/source/blender/editors/mesh/editmesh_knife.c 
b/source/blender/editors/mesh/editmesh_knife.c
index 369162e80a3..dbe77805dd8 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1897,17 +1897,9 @@ static void knife_start_cut(KnifeTool_OpData *kcd)
   kcd->mdata.is_stored = false;
 
   if (kcd->prev.vert == NULL && kcd->prev.edge == NULL) {
-float origin[3], origin_ofs[3];
 float ofs_local[3];
-
 negate_v3_v3(ofs_local, kcd->vc.rv3d->ofs);
-
-knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs);
-
-if (!isect_line_plane_v3(
-kcd->prev.cage, origin, origin_ofs, ofs_local, 
kcd->vc.rv3d->viewinv[2])) {
-  zero_v3(kcd->prev.cage);
-}
+ED_view3d_win_to_3d(kcd->vc.v3d, kcd->region, ofs_local, kcd->curr.mval, 
kcd->prev.cage);
 
 copy_v3_v3(kcd->prev.co, kcd->prev.cage); /* TODO: do we need this? */
 copy_v3_v3(kcd->curr.cage, kcd->prev.cage);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e968b4197b6] blender-v3.3-release: Fix T102257: Crash when making an Object as Effector set to Guide and trying to scrub the timeline

2022-11-28 Thread Germano Cavalcante
Commit: e968b4197b68538b64280178330e552880df19cf
Author: Germano Cavalcante
Date:   Wed Nov 9 12:09:55 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBe968b4197b68538b64280178330e552880df19cf

Fix T102257: Crash when making an Object as Effector set to Guide and trying to 
scrub the timeline

rB67e23b4b2967 revealed the bug. But the bug already existed before,
it just wasn't triggered.

Apparently the problem happens because the python code generated in
`initGuiding()` cannot be executed twice.

The second time the `initGuiding()` code is executed, the local python
variables are removed to make way for the others, but the reference to
one of the grids in a `Solver` object (name='solver_guiding2') is still
being used somewhere. So an error is raised and a crash is forced.

The solution is to prevent the python code in `initGuiding()` from being
executed twice.

When `FLUID_DOMAIN_ACTIVE_GUIDE` is in `fds->active_fields` this
indicates that the pointer in `mPhiGuideIn` has been set and the guiding
is already computed (does not need to be computed again).

Maniphest Tasks: T102257

Differential Revision: https://developer.blender.org/D16416

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index fc14c909f4d..56a2e14d5ec 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -58,7 +58,6 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingDiffusion = (fds->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid;
   mUsingViscosity = (fds->flags & FLUID_DOMAIN_USE_VISCOSITY) && mUsingLiquid;
   mUsingMVel = (fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
-  mUsingGuiding = (fds->flags & FLUID_DOMAIN_USE_GUIDE);
   mUsingDrops = (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
   mUsingBubbles = (fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && 
mUsingLiquid;
   mUsingFloats = (fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
@@ -68,6 +67,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingFire = (fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
   mUsingColors = (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingObstacle = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
+  mUsingGuiding = (fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE);
   mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
   mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [331de028ef7] blender-v3.3-release: Fix T101220: UV proportional editing not working correctly with UV Sync Selection

2022-11-28 Thread Germano Cavalcante
Commit: 331de028ef7dcebb63dd09345b311942d6e22f62
Author: Germano Cavalcante
Date:   Tue Sep 20 17:29:33 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB331de028ef7dcebb63dd09345b311942d6e22f62

Fix T101220: UV proportional editing not working correctly with UV Sync 
Selection

Regression introduced in rb2ba1cf4b40fc.

The `MLOOPUV_VERTSEL` flag only indicates UV selection without sync.

===

M   source/blender/editors/transform/transform_convert_mesh_uv.c

===

diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c 
b/source/blender/editors/transform/transform_convert_mesh_uv.c
index d95bc7b976f..bcd4c2a2b29 100644
--- a/source/blender/editors/transform/transform_convert_mesh_uv.c
+++ b/source/blender/editors/transform/transform_convert_mesh_uv.c
@@ -74,8 +74,12 @@ static void UVsToTransData(const float aspect[2],
 /**
  * \param dists: Store the closest connected distance to selected vertices.
  */
-static void uv_set_connectivity_distance(BMesh *bm, float *dists, const float 
aspect[2])
+static void uv_set_connectivity_distance(const ToolSettings *ts,
+ BMesh *bm,
+ float *dists,
+ const float aspect[2])
 {
+#define TMP_LOOP_SELECT_TAG BM_ELEM_TAG_ALT
   /* Mostly copied from #transform_convert_mesh_connectivity_distance. */
   BLI_LINKSTACK_DECLARE(queue, BMLoop *);
 
@@ -103,13 +107,15 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
   float dist;
   MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
 
-  bool uv_vert_sel = luv->flag & MLOOPUV_VERTSEL;
+  bool uv_vert_sel = uvedit_uv_select_test_ex(ts, l, cd_loop_uv_offset);
 
   if (uv_vert_sel) {
 BLI_LINKSTACK_PUSH(queue, l);
+BM_elem_flag_enable(l, TMP_LOOP_SELECT_TAG);
 dist = 0.0f;
   }
   else {
+BM_elem_flag_disable(l, TMP_LOOP_SELECT_TAG);
 dist = FLT_MAX;
   }
 
@@ -164,7 +170,7 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
 
 bool other_vert_sel, connected_vert_sel;
 
-other_vert_sel = luv_other->flag & MLOOPUV_VERTSEL;
+other_vert_sel = BM_elem_flag_test_bool(l_other, TMP_LOOP_SELECT_TAG);
 
 BM_ITER_ELEM (l_connected, _connected_iter, l_other->v, 
BM_LOOPS_OF_VERT) {
   if (l_connected == l_other) {
@@ -176,7 +182,7 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
   }
 
   MLoopUV *luv_connected = BM_ELEM_CD_GET_VOID_P(l_connected, 
cd_loop_uv_offset);
-  connected_vert_sel = luv_connected->flag & MLOOPUV_VERTSEL;
+  connected_vert_sel = BM_elem_flag_test_bool(l_connected, 
TMP_LOOP_SELECT_TAG);
 
   /* Check if this loop is connected in UV space.
* If the uv loops share the same selection state (if not, they are 
not connected as
@@ -232,6 +238,7 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
   BLI_LINKSTACK_FREE(queue_next);
 
   MEM_freeN(dists_prev);
+#undef TMP_LOOP_SELECT_TAG
 }
 
 static void createTransUVs(bContext *C, TransInfo *t)
@@ -339,7 +346,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
 if (is_prop_connected) {
   prop_dists = MEM_callocN(em->bm->totloop * sizeof(float), 
"TransObPropDists(UV Editing)");
 
-  uv_set_connectivity_distance(em->bm, prop_dists, t->aspect);
+  uv_set_connectivity_distance(t->settings, em->bm, prop_dists, t->aspect);
 }
 
 BM_ITER_MESH (efa, , em->bm, BM_FACES_OF_MESH) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [29bc410c8a6] blender-v3.3-release: Fix T89399: Mouse wrapping causes erratic movement

2022-11-28 Thread Germano Cavalcante
Commit: 29bc410c8a67fcdc65827e30741eec1c8463df06
Author: Germano Cavalcante
Date:   Thu Aug 18 09:32:49 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB29bc410c8a67fcdc65827e30741eec1c8463df06

Fix T89399: Mouse wrapping causes erratic movement

As mentioned in T89399, "the source of this bug is that cursor wrap
moves the cursor, but when it later checks the mouse position it hasn't
yet been updated, so it re-wraps".

As far as I could see, this happens for two reasons:
1. During the first warp, there are already other mousemove events in the queue 
with an outdated position.
2. Sometimes Windows occasionally and inexplicably ignores `SetCursorPos()` or 
`SendInput()` events. (See [1])

The solution consists in checking if the cursor is inside the bounds right 
after wrapping.
If it's not inside, it indicates that the wrapping either didn't work or the 
event is out of date.
In these cases do not change the "accum" values.

1. 
https://github.com/libsdl-org/SDL/blob/f317d619ccd22e60cebf1b09d716d3985359c981/src/video/windows/SDL_windowsmouse.c#L255)

Maniphest Tasks: T89399

Differential Revision: https://developer.blender.org/D15707

===

M   intern/ghost/intern/GHOST_SystemWin32.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 0d4016253fb..82eef4a2854 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1122,6 +1122,12 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
   system->getCursorPosition(x_screen, y_screen);
 
   if (window->getCursorGrabModeIsWarp()) {
+/* WORKAROUND:
+ * Sometimes Windows ignores `SetCursorPos()` or `SendInput()` calls or 
the mouse event is
+ * outdate. Identify these cases by checking if the cursor is not yet 
within bounds. */
+static bool is_warping_x = false;
+static bool is_warping_y = false;
+
 int32_t x_new = x_screen;
 int32_t y_new = y_screen;
 int32_t x_accum, y_accum;
@@ -1138,29 +1144,41 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
 
 window->getCursorGrabAccum(x_accum, y_accum);
 if (x_new != x_screen || y_new != y_screen) {
+  system->setCursorPosition(x_new, y_new); /* wrap */
+
+  /* Do not update the accum values if we are an outdated or failed 
pos-warp event. */
+  if (!is_warping_x) {
+is_warping_x = x_new != x_screen;
+if (is_warping_x) {
+  x_accum += (x_screen - x_new);
+}
+  }
+
+  if (!is_warping_y) {
+is_warping_y = y_new != y_screen;
+if (is_warping_y) {
+  y_accum += (y_screen - y_new);
+}
+  }
+  window->setCursorGrabAccum(x_accum, y_accum);
+
   /* When wrapping we don't need to add an event because the 
setCursorPosition call will cause
* a new event after. */
-  system->setCursorPosition(x_new, y_new); /* wrap */
-  window->setCursorGrabAccum(x_accum + (x_screen - x_new), y_accum + 
(y_screen - y_new));
-}
-else {
-  return new GHOST_EventCursor(system->getMilliSeconds(),
-   GHOST_kEventCursorMove,
-   window,
-   x_screen + x_accum,
-   y_screen + y_accum,
-   GHOST_TABLET_DATA_NONE);
+  return NULL;
 }
+
+is_warping_x = false;
+is_warping_y = false;
+x_screen += x_accum;
+y_screen += y_accum;
   }
-  else {
-return new GHOST_EventCursor(system->getMilliSeconds(),
- GHOST_kEventCursorMove,
- window,
- x_screen,
- y_screen,
- GHOST_TABLET_DATA_NONE);
-  }
-  return NULL;
+
+  return new GHOST_EventCursor(system->getMilliSeconds(),
+   GHOST_kEventCursorMove,
+   window,
+   x_screen,
+   y_screen,
+   GHOST_TABLET_DATA_NONE);
 }
 
 void GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM 
wParam, LPARAM lParam)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [832157cb02f] blender-v3.3-release: Fix T101928: transform operator properties saving wrong snap values

2022-11-28 Thread Germano Cavalcante
Commit: 832157cb02f1770439823f8fdf0dd8cccb57a7ca
Author: Germano Cavalcante
Date:   Wed Oct 19 10:56:33 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB832157cb02f1770439823f8fdf0dd8cccb57a7ca

Fix T101928: transform operator properties saving wrong snap values

The check for the flags should be `== 0` since they are describing a
negative state.

Thanks to @lone_noel for pointing out the error.

===

M   source/blender/editors/transform/transform.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 25a36477950..9a2acf9355a 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1591,9 +1591,9 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
   RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_select);
 
   eSnapTargetSelect target = t->tsnap.target_select;
-  RNA_boolean_set(op->ptr, "use_snap_self", (target & 
SCE_SNAP_TARGET_NOT_ACTIVE) != 0);
-  RNA_boolean_set(op->ptr, "use_snap_edit", (target & 
SCE_SNAP_TARGET_NOT_EDITED) != 0);
-  RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & 
SCE_SNAP_TARGET_NOT_NONEDITED) != 0);
+  RNA_boolean_set(op->ptr, "use_snap_self", (target & 
SCE_SNAP_TARGET_NOT_ACTIVE) == 0);
+  RNA_boolean_set(op->ptr, "use_snap_edit", (target & 
SCE_SNAP_TARGET_NOT_EDITED) == 0);
+  RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & 
SCE_SNAP_TARGET_NOT_NONEDITED) == 0);
   RNA_boolean_set(
   op->ptr, "use_snap_selectable", (target & 
SCE_SNAP_TARGET_ONLY_SELECTABLE) != 0);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [49129180b2c] master: Merge branch 'blender-v3.4-release'

2022-11-24 Thread Germano Cavalcante
Commit: 49129180b2c98fd7970e0601a7eee60a2dc78117
Author: Germano Cavalcante
Date:   Thu Nov 24 17:30:54 2022 -0300
Branches: master
https://developer.blender.org/rB49129180b2c98fd7970e0601a7eee60a2dc78117

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cdc1c60f5ba] blender-v3.4-release: Fix T102466: push/pull doesn't work if applied to many vertices

2022-11-24 Thread Germano Cavalcante
Commit: cdc1c60f5bacea96d679384ecf46d93eb74d3a93
Author: Germano Cavalcante
Date:   Thu Nov 24 17:29:06 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rBcdc1c60f5bacea96d679384ecf46d93eb74d3a93

Fix T102466: push/pull doesn't work if applied to many vertices

The assignment of member`distance` was missing in rB2d4ec9049744.

===

M   source/blender/editors/transform/transform_mode_push_pull.c

===

diff --git a/source/blender/editors/transform/transform_mode_push_pull.c 
b/source/blender/editors/transform/transform_mode_push_pull.c
index 87309b45231..b7806b3519e 100644
--- a/source/blender/editors/transform/transform_mode_push_pull.c
+++ b/source/blender/editors/transform/transform_mode_push_pull.c
@@ -152,6 +152,8 @@ static void applyPushPull(TransInfo *t, const int 
UNUSED(mval[2]))
   struct TransDataArgs_PushPull data = {
   .t = t,
   .tc = tc,
+
+  .distance = distance,
   .axis_global = {UNPACK3(axis_global)},
   .is_lock_constraint = is_lock_constraint,
   .is_data_space = is_data_space,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [50aad904b38] master: Merge branch 'blender-v3.4-release'

2022-11-23 Thread Germano Cavalcante
Commit: 50aad904b38b44a7d7c9491649476380bb2fab80
Author: Germano Cavalcante
Date:   Wed Nov 23 14:15:22 2022 -0300
Branches: master
https://developer.blender.org/rB50aad904b38b44a7d7c9491649476380bb2fab80

Merge branch 'blender-v3.4-release'

===



===

diff --cc source/blender/editors/transform/transform_snap.cc
index 7f73dee760d,4a26a736351..78752ec7846
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@@ -612,16 -609,26 +612,26 @@@ static bool bm_face_is_snap_target(BMFa
  static eSnapFlag snap_flag_from_spacetype(TransInfo *t)
  {
ToolSettings *ts = t->settings;
-   if (t->spacetype == SPACE_NODE) {
- return eSnapFlag(ts->snap_flag_node);
-   }
-   if (t->spacetype == SPACE_IMAGE) {
- return eSnapFlag(ts->snap_uv_flag);
-   }
-   if (t->spacetype == SPACE_SEQ) {
- return eSnapFlag(ts->snap_flag_seq);
-   }
-   return eSnapFlag(ts->snap_flag);
+   switch (t->spacetype) {
+ case SPACE_VIEW3D:
 -  return ts->snap_flag;
++  return eSnapFlag(ts->snap_flag);
+ case SPACE_NODE:
 -  return ts->snap_flag_node;
++  return eSnapFlag(ts->snap_flag_node);
+ case SPACE_IMAGE:
 -  return ts->snap_uv_flag;
++  return eSnapFlag(ts->snap_uv_flag);
+ case SPACE_SEQ:
 -  return ts->snap_flag_seq;
++  return eSnapFlag(ts->snap_flag_seq);
+ case SPACE_GRAPH:
+ case SPACE_ACTION:
+ case SPACE_NLA:
+   /* These editors have their own "Auto-Snap" activation option.
+* See #getAnimEdit_SnapMode. */
 -  return 0;
++  return eSnapFlag(0);
+ default:
+   BLI_assert(false);
+   break;
+   }
 -  return 0;
++  return eSnapFlag(0);
  }
  
  static eSnapMode snap_mode_from_spacetype(TransInfo *t)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [962e221cd32] blender-v3.4-release: Fix T102720: Snapping in 3dViewport affects Graph, Action and NLA editors

2022-11-23 Thread Germano Cavalcante
Commit: 962e221cd32cfad7759eb7f0485799dce2f57424
Author: Germano Cavalcante
Date:   Wed Nov 23 14:06:21 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rB962e221cd32cfad7759eb7f0485799dce2f57424

Fix T102720: Snapping in 3dViewport affects Graph, Action and NLA editors

These editors have their own "Auto-Snap" activation option.

So ignore the option in the 3D View in these cases.

The generic incremental snap function doesn't seem really useful in these cases.

If an incremental snap needs to be implemented, this should be a new option of 
`eAnimEdit_AutoSnap`.

===

M   source/blender/editors/transform/transform_snap.c

===

diff --git a/source/blender/editors/transform/transform_snap.c 
b/source/blender/editors/transform/transform_snap.c
index 11cb57dc911..4a26a736351 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -609,16 +609,26 @@ static bool bm_face_is_snap_target(BMFace *f, void 
*UNUSED(user_data))
 static eSnapFlag snap_flag_from_spacetype(TransInfo *t)
 {
   ToolSettings *ts = t->settings;
-  if (t->spacetype == SPACE_NODE) {
-return ts->snap_flag_node;
-  }
-  if (t->spacetype == SPACE_IMAGE) {
-return ts->snap_uv_flag;
-  }
-  if (t->spacetype == SPACE_SEQ) {
-return ts->snap_flag_seq;
+  switch (t->spacetype) {
+case SPACE_VIEW3D:
+  return ts->snap_flag;
+case SPACE_NODE:
+  return ts->snap_flag_node;
+case SPACE_IMAGE:
+  return ts->snap_uv_flag;
+case SPACE_SEQ:
+  return ts->snap_flag_seq;
+case SPACE_GRAPH:
+case SPACE_ACTION:
+case SPACE_NLA:
+  /* These editors have their own "Auto-Snap" activation option.
+   * See #getAnimEdit_SnapMode. */
+  return 0;
+default:
+  BLI_assert(false);
+  break;
   }
-  return ts->snap_flag;
+  return 0;
 }
 
 static eSnapMode snap_mode_from_spacetype(TransInfo *t)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ed82bbfc2c0] master: Cleanup: use designated initializers in C

2022-11-22 Thread Germano Cavalcante
Commit: ed82bbfc2c05108424bce1bdd40927df80085950
Author: Germano Cavalcante
Date:   Tue Nov 22 09:13:16 2022 -0300
Branches: master
https://developer.blender.org/rBed82bbfc2c05108424bce1bdd40927df80085950

Cleanup: use designated initializers in C

===

M   source/blender/blenkernel/intern/tracking.c

===

diff --git a/source/blender/blenkernel/intern/tracking.c 
b/source/blender/blenkernel/intern/tracking.c
index 106de7b96f4..d71c0cc4bf9 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -168,8 +168,8 @@ typedef struct TrackingCopyContext {
 static TrackingCopyContext tracking_copy_context_new(void)
 {
   TrackingCopyContext ctx = {
-  BLI_ghash_ptr_new(__func__), /* old_to_new_track_map */
-  BLI_ghash_ptr_new(__func__), /* old_to_new_plane_track_map */
+  .old_to_new_track_map = BLI_ghash_ptr_new(__func__),
+  .old_to_new_plane_track_map = BLI_ghash_ptr_new(__func__),
   };
   return ctx;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [02c61369589] master: Fix compile error with msvc

2022-11-22 Thread Germano Cavalcante
Commit: 02c613695896de49fe4ab35f7987fa00b5d69be8
Author: Germano Cavalcante
Date:   Tue Nov 22 09:13:16 2022 -0300
Branches: master
https://developer.blender.org/rB02c613695896de49fe4ab35f7987fa00b5d69be8

Fix compile error with msvc

error C2059: syntax error: '}'

===

M   source/blender/blenkernel/intern/tracking.c

===

diff --git a/source/blender/blenkernel/intern/tracking.c 
b/source/blender/blenkernel/intern/tracking.c
index dfb39c7bc37..106de7b96f4 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -167,9 +167,10 @@ typedef struct TrackingCopyContext {
 
 static TrackingCopyContext tracking_copy_context_new(void)
 {
-  TrackingCopyContext ctx = {};
-  ctx.old_to_new_track_map = BLI_ghash_ptr_new(__func__);
-  ctx.old_to_new_plane_track_map = BLI_ghash_ptr_new(__func__);
+  TrackingCopyContext ctx = {
+  BLI_ghash_ptr_new(__func__), /* old_to_new_track_map */
+  BLI_ghash_ptr_new(__func__), /* old_to_new_plane_track_map */
+  };
   return ctx;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5a05fa8f74d] master: Merge branch 'blender-v3.4-release'

2022-11-16 Thread Germano Cavalcante
Commit: 5a05fa8f74d35a478d85c211fac81ee49972e5a5
Author: Germano Cavalcante
Date:   Wed Nov 16 11:01:29 2022 -0300
Branches: master
https://developer.blender.org/rB5a05fa8f74d35a478d85c211fac81ee49972e5a5

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1a4a96a9d15] blender-v3.4-release: Fix allocated array size for MeshExtract_EdgeFac_Data

2022-11-16 Thread Germano Cavalcante
Commit: 1a4a96a9d15d1a42a17c0a00ed0307922f9fb4b7
Author: Germano Cavalcante
Date:   Wed Nov 16 10:52:47 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rB1a4a96a9d15d1a42a17c0a00ed0307922f9fb4b7

Fix allocated array size for MeshExtract_EdgeFac_Data

The array size is actually 1/4 of the currently allocated size.

Also, cleanup, use `uint8_t` instead of `uchar`.

No functional changes.

===

M   source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc

===

diff --git 
a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc 
b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
index a968bd07c87..438ca72310f 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
@@ -20,10 +20,10 @@ namespace blender::draw {
  * \{ */
 
 struct MeshExtract_EdgeFac_Data {
-  uchar *vbo_data;
+  uint8_t *vbo_data;
   bool use_edge_render;
   /* Number of loop per edge. */
-  uchar *edge_loop_count;
+  uint8_t *edge_loop_count;
 };
 
 static float loop_edge_factor_get(const float f_no[3],
@@ -59,8 +59,7 @@ static void extract_edge_fac_init(const MeshRenderData *mr,
   MeshExtract_EdgeFac_Data *data = static_cast(tls_data);
 
   if (mr->extract_type == MR_EXTRACT_MESH) {
-data->edge_loop_count = static_cast(
-MEM_callocN(sizeof(uint32_t) * mr->edge_len, __func__));
+data->edge_loop_count = MEM_cnew_array(mr->edge_len, __func__);
 
 /* HACK(@fclem): Detecting the need for edge render.
  * We could have a flag in the mesh instead or check the modifier stack. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cff78860ac3] master: Merge branch 'blender-v3.4-release'

2022-11-15 Thread Germano Cavalcante
Commit: cff78860ac3d5b4dc95c5f0e43d5aae244d0e443
Author: Germano Cavalcante
Date:   Tue Nov 15 12:08:05 2022 -0300
Branches: master
https://developer.blender.org/rBcff78860ac3d5b4dc95c5f0e43d5aae244d0e443

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [be40c67b56c] blender-v3.4-release: Fix T102512: Snapping Option Face Nearest is not working

2022-11-15 Thread Germano Cavalcante
Commit: be40c67b56cca91f7e53268d3fb541ca4e665b25
Author: Germano Cavalcante
Date:   Tue Nov 15 12:07:04 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rBbe40c67b56cca91f7e53268d3fb541ca4e665b25

Fix T102512: Snapping Option Face Nearest is not working

Caused by misuse of the `GS` macro.

Error in rB8f4e52b7e0dd

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index 87c467d44d8..48f1c381bb8 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -1305,7 +1305,7 @@ static eSnapMode 
nearest_world_object_fn(SnapObjectContext *sctx,
   return SCE_SNAP_MODE_NONE;
 }
   }
-  else if (GS(ob_data) != ID_ME) {
+  else if (GS(ob_data->name) != ID_ME) {
 return SCE_SNAP_MODE_NONE;
   }
   else if (is_object_active && ELEM(ob_eval->type, OB_CURVES_LEGACY, OB_SURF, 
OB_FONT)) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [77bc95bbd53] blender-v3.4-release: Fix T102257: Crash when making an Object as Effector set to Guide and trying to scrub the timeline

2022-11-09 Thread Germano Cavalcante
Commit: 77bc95bbd531712793f4e355132724c639bf7a99
Author: Germano Cavalcante
Date:   Wed Nov 9 12:09:55 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rB77bc95bbd531712793f4e355132724c639bf7a99

Fix T102257: Crash when making an Object as Effector set to Guide and trying to 
scrub the timeline

rB67e23b4b2967 revealed the bug. But the bug already existed before,
it just wasn't triggered.

Apparently the problem happens because the python code generated in
`initGuiding()` cannot be executed twice.

The second time the `initGuiding()` code is executed, the local python
variables are removed to make way for the others, but the reference to
one of the grids in a `Solver` object (name='solver_guiding2') is still
being used somewhere. So an error is raised and a crash is forced.

The solution is to prevent the python code in `initGuiding()` from being
executed twice.

When `FLUID_DOMAIN_ACTIVE_GUIDE` is in `fds->active_fields` this
indicates that the pointer in `mPhiGuideIn` has been set and the guiding
is already computed (does not need to be computed again).

Maniphest Tasks: T102257

Differential Revision: https://developer.blender.org/D16416

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 5708cdc81aa..d94c8943f78 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -58,7 +58,6 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingDiffusion = (fds->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid;
   mUsingViscosity = (fds->flags & FLUID_DOMAIN_USE_VISCOSITY) && mUsingLiquid;
   mUsingMVel = (fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
-  mUsingGuiding = (fds->flags & FLUID_DOMAIN_USE_GUIDE);
   mUsingDrops = (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
   mUsingBubbles = (fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && 
mUsingLiquid;
   mUsingFloats = (fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
@@ -68,6 +67,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingFire = (fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
   mUsingColors = (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingObstacle = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
+  mUsingGuiding = (fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE);
   mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
   mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [edc00429e8d] master: Fix T102257: Crash when making an Object as Effector set to Guide and trying to scrub the timeline

2022-11-09 Thread Germano Cavalcante
Commit: edc00429e8d70912eb830e132d8ba6c874252567
Author: Germano Cavalcante
Date:   Wed Nov 9 12:09:55 2022 -0300
Branches: master
https://developer.blender.org/rBedc00429e8d70912eb830e132d8ba6c874252567

Fix T102257: Crash when making an Object as Effector set to Guide and trying to 
scrub the timeline

rB67e23b4b2967 revealed the bug. But the bug already existed before,
it just wasn't triggered.

Apparently the problem happens because the python code generated in
`initGuiding()` cannot be executed twice.

The second time the `initGuiding()` code is executed, the local python
variables are removed to make way for the others, but the reference to
one of the grids in a `Solver` object (name='solver_guiding2') is still
being used somewhere. So an error is raised and a crash is forced.

The solution is to prevent the python code in `initGuiding()` from being
executed twice.

When `FLUID_DOMAIN_ACTIVE_GUIDE` is in `fds->active_fields` this
indicates that the pointer in `mPhiGuideIn` has been set and the guiding
is already computed (does not need to be computed again).

Maniphest Tasks: T102257

Differential Revision: https://developer.blender.org/D16416

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 5708cdc81aa..d94c8943f78 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -58,7 +58,6 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingDiffusion = (fds->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid;
   mUsingViscosity = (fds->flags & FLUID_DOMAIN_USE_VISCOSITY) && mUsingLiquid;
   mUsingMVel = (fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
-  mUsingGuiding = (fds->flags & FLUID_DOMAIN_USE_GUIDE);
   mUsingDrops = (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
   mUsingBubbles = (fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && 
mUsingLiquid;
   mUsingFloats = (fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
@@ -68,6 +67,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingFire = (fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
   mUsingColors = (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingObstacle = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
+  mUsingGuiding = (fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE);
   mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
   mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [403fc9a3f15] master: Merge branch 'blender-v3.4-release'

2022-11-07 Thread Germano Cavalcante
Commit: 403fc9a3f15591100d904d863f81bf1ff47d0d95
Author: Germano Cavalcante
Date:   Mon Nov 7 08:46:15 2022 -0300
Branches: master
https://developer.blender.org/rB403fc9a3f15591100d904d863f81bf1ff47d0d95

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8f4e52b7e0d] blender-v3.4-release: Fix T102053: snap fails with instances of geometry nodes

2022-11-07 Thread Germano Cavalcante
Commit: 8f4e52b7e0dd70d5ec52cbe31fd29418e8e2fa03
Author: Germano Cavalcante
Date:   Sun Nov 6 12:24:20 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rB8f4e52b7e0dd70d5ec52cbe31fd29418e8e2fa03

Fix T102053: snap fails with instances of geometry nodes

As instances are often generated geometries, we cannot rely on the data
provided by `DupliObject::ob`.

Use `DupliObject::ob_data` when possible.

This required a major refactor in the code as the output variables are
now gathered in context and easier to access.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index 2fab789afca..1663fd12586 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -35,6 +35,7 @@
 #include "BKE_layer.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_runtime.h"
+#include "BKE_mesh_wrapper.h"
 #include "BKE_object.h"
 #include "BKE_tracking.h"
 
@@ -125,6 +126,28 @@ struct SnapObjectContext {
 eSnapMode snap_to_flag;
 bool has_occlusion_plane; /* Ignore plane of occlusion in curves. */
   } runtime;
+
+  /* Output. */
+  struct {
+/* Location of snapped point on target surface. */
+float loc[3];
+/* Normal of snapped point on target surface. */
+float no[3];
+/* Index of snapped element on target object (-1 when no valid index is 
found). */
+int index;
+/* Matrix of target object (may not be #Object.object_to_world with 
dupli-instances). */
+float obmat[4][4];
+/* List of #SnapObjectHitDepth (caller must free). */
+ListBase *hit_list;
+/* Snapped object. */
+Object *ob;
+/* Snapped data. */
+ID *data;
+
+float dist_sq;
+
+bool is_edit;
+  } ret;
 };
 
 /** \} */
@@ -140,20 +163,20 @@ struct SnapObjectContext {
  * - In rare cases there is no evaluated mesh available and a null result 
doesn't imply an
  *   edit-mesh, so callers need to account for a null edit-mesh too, see: 
T96536.
  */
-static const Mesh *mesh_for_snap(Object *ob_eval, eSnapEditType 
edit_mode_type, bool *r_use_hide)
+static ID *data_for_snap(Object *ob_eval, eSnapEditType edit_mode_type, bool 
*r_use_hide)
 {
-  const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
   bool use_hide = false;
 
   switch (ob_eval->type) {
 case OB_MESH: {
+  Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
   if (BKE_object_is_in_editmode(ob_eval)) {
 if (edit_mode_type == SNAP_GEOM_EDIT) {
   return nullptr;
 }
 
-const Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
-const Mesh *editmesh_eval_cage = 
BKE_object_get_editmesh_eval_cage(ob_eval);
+Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
+Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval);
 
 if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) {
   if (editmesh_eval_final->runtime->wrapper_type == 
ME_WRAPPER_TYPE_BMESH) {
@@ -170,7 +193,10 @@ static const Mesh *mesh_for_snap(Object *ob_eval, 
eSnapEditType edit_mode_type,
   use_hide = true;
 }
   }
-  break;
+  if (r_use_hide) {
+*r_use_hide = use_hide;
+  }
+  return (ID *)me_eval;
 }
 default:
   break;
@@ -178,7 +204,7 @@ static const Mesh *mesh_for_snap(Object *ob_eval, 
eSnapEditType edit_mode_type,
   if (r_use_hide) {
 *r_use_hide = use_hide;
   }
-  return me_eval;
+  return (ID *)ob_eval->data;
 }
 
 /** \} */
@@ -368,12 +394,14 @@ static BVHTreeFromEditMesh 
*snap_object_data_editmesh_treedata_get(SnapObjectCon
 /** \name Iterator
  * \{ */
 
-using IterSnapObjsCallback = void (*)(SnapObjectContext *sctx,
-  const SnapObjectParams *params,
-  Object *ob_eval,
-  const float obmat[4][4],
-  bool is_object_active,
-  void *data);
+using IterSnapObjsCallback = eSnapMode (*)(SnapObjectContext *sctx,
+   const SnapObjectParams *params,
+   Object *ob_eval,
+   ID *ob_data,
+   const float obmat[4][4],
+   bool is_object_active,
+   bool use_hide,
+   void *data);
 
 static bool snap_object_is_snappable(const SnapObjectContext *sctx,
 

[Bf-blender-cvs] [7b845fb984e] blender-v3.4-release: Transform: remove SnapData cache for meshes

2022-11-07 Thread Germano Cavalcante
Commit: 7b845fb984ee9e593182594f7dd392a5c4efdcd7
Author: Germano Cavalcante
Date:   Thu Nov 3 16:33:41 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rB7b845fb984ee9e593182594f7dd392a5c4efdcd7

Transform: remove SnapData cache for meshes

All cache needed is already stored in `Mesh.runtime`.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index 24d76a50117..a75a94803f7 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -61,41 +61,6 @@ enum eViewProj {
   VIEW_PROJ_PERSP = -1,
 };
 
-/* SnapObjectContext.cache.mesh_map */
-struct SnapData_Mesh {
-  /* Loose edges, loose verts. */
-  BVHTree *bvhtree[2];
-  bool cached[2];
-
-  /* Looptris. */
-  BVHTreeFromMesh treedata_mesh;
-
-  const MPoly *poly;
-  bool has_looptris;
-  bool has_loose_edge;
-  bool has_loose_vert;
-
-  void clear()
-  {
-for (int i = 0; i < ARRAY_SIZE(this->bvhtree); i++) {
-  if (!this->cached[i]) {
-BLI_bvhtree_free(this->bvhtree[i]);
-  }
-  this->bvhtree[i] = nullptr;
-}
-free_bvhtree_from_mesh(>treedata_mesh);
-  }
-
-  ~SnapData_Mesh()
-  {
-this->clear();
-  }
-
-#ifdef WITH_CXX_GUARDEDALLOC
-  MEM_CXX_CLASS_ALLOC_FUNCS("SnapData_Mesh")
-#endif
-};
-
 /* SnapObjectContext.cache.editmesh_map */
 struct SnapData_EditMesh {
   /* Verts, Edges. */
@@ -134,7 +99,6 @@ struct SnapObjectContext {
 
   int flag;
 
-  Map> mesh_caches;
   Map> editmesh_caches;
 
   /* Filter data, returns true to check this value */
@@ -180,28 +144,36 @@ static const Mesh *mesh_for_snap(Object *ob_eval, 
eSnapEditType edit_mode_type,
 {
   const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
   bool use_hide = false;
-  if (BKE_object_is_in_editmode(ob_eval)) {
-if (edit_mode_type == SNAP_GEOM_EDIT) {
-  return nullptr;
-}
 
-const Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
-const Mesh *editmesh_eval_cage = 
BKE_object_get_editmesh_eval_cage(ob_eval);
+  switch (ob_eval->type) {
+case OB_MESH: {
+  if (BKE_object_is_in_editmode(ob_eval)) {
+if (edit_mode_type == SNAP_GEOM_EDIT) {
+  return nullptr;
+}
+
+const Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
+const Mesh *editmesh_eval_cage = 
BKE_object_get_editmesh_eval_cage(ob_eval);
 
-if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) {
-  if (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) 
{
-return nullptr;
-  }
-  me_eval = editmesh_eval_final;
-  use_hide = true;
-}
-else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) {
-  if (editmesh_eval_cage->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) {
-return nullptr;
+if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) {
+  if (editmesh_eval_final->runtime->wrapper_type == 
ME_WRAPPER_TYPE_BMESH) {
+return nullptr;
+  }
+  me_eval = editmesh_eval_final;
+  use_hide = true;
+}
+else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) {
+  if (editmesh_eval_cage->runtime->wrapper_type == 
ME_WRAPPER_TYPE_BMESH) {
+return nullptr;
+  }
+  me_eval = editmesh_eval_cage;
+  use_hide = true;
+}
   }
-  me_eval = editmesh_eval_cage;
-  use_hide = true;
+  break;
 }
+default:
+  break;
   }
   if (r_use_hide) {
 *r_use_hide = use_hide;
@@ -236,96 +208,31 @@ static void snap_editmesh_minmax(SnapObjectContext *sctx,
   }
 }
 
-static SnapData_Mesh *snap_object_data_mesh_get(SnapObjectContext *sctx,
-Object *ob_eval,
-const Mesh *me_eval,
-bool use_hide)
+static void snap_object_data_mesh_get(SnapObjectContext *sctx,
+  Object *ob_eval,
+  const Mesh *me_eval,
+  bool use_hide,
+  BVHTreeFromMesh *r_treedata)
 {
-  SnapData_Mesh *sod;
-  bool init = false;
-
   const Span verts = me_eval->verts();
   const Span edges = me_eval->edges();
   const Span polys = me_eval->polys();
   const Span loops = me_eval->loops();
 
-  if (std::unique_ptr *sod_p = 
sctx->mesh_caches.lookup_ptr(ob_eval)) {
-sod = sod_p->get();
-bool is_dirty = fa

[Bf-blender-cvs] [9ea82ce653c] blender-v3.4-release: Fix potentially uninitialized memory usage

2022-11-07 Thread Germano Cavalcante
Commit: 9ea82ce653c87ad96ecbc4ca01c59eb6a3280fd1
Author: Germano Cavalcante
Date:   Sun Nov 6 10:14:53 2022 -0300
Branches: blender-v3.4-release
https://developer.blender.org/rB9ea82ce653c87ad96ecbc4ca01c59eb6a3280fd1

Fix potentially uninitialized memory usage

`nearest_world_tree_co` allows null parameter, so the `index` variable
isn't really needed and doesn't even need to be initialized.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index a75a94803f7..2fab789afca 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -1187,14 +1187,13 @@ static bool nearest_world_tree(SnapObjectContext * 
/*sctx*/,
 
   float co_local[3];
   float no_local[3];
-  int index;
 
   copy_v3_v3(co_local, init_co_local);
 
   for (int i = 0; i < params->face_nearest_steps; i++) {
 add_v3_v3(co_local, delta_local);
 nearest_world_tree_co(
-tree, nearest_cb, treedata, co_local, co_local, no_local, , 
nullptr);
+tree, nearest_cb, treedata, co_local, co_local, no_local, r_index, 
nullptr);
   }
 
   mul_v3_m4v3(r_loc, obmat, co_local);
@@ -1204,10 +1203,6 @@ static bool nearest_world_tree(SnapObjectContext * 
/*sctx*/,
 normalize_v3(r_no);
   }
 
-  if (r_index) {
-*r_index = index;
-  }
-
   return true;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [688b408bbb9] master: Fix 'ED_transform_snap_object_project_ray_all' not return 'hit_list'

2022-11-07 Thread Germano Cavalcante
Commit: 688b408bbb9b92332752ee48b099f7898bf62462
Author: Germano Cavalcante
Date:   Mon Nov 7 08:37:51 2022 -0300
Branches: master
https://developer.blender.org/rB688b408bbb9b92332752ee48b099f7898bf62462

Fix 'ED_transform_snap_object_project_ray_all' not return 'hit_list'

Missed in rBff4f14b21a42.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index 54085295e9e..1663fd12586 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -3120,6 +3120,16 @@ bool 
ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx,
   sctx->runtime.depsgraph = depsgraph;
   sctx->runtime.v3d = v3d;
 
+  zero_v3(sctx->ret.loc);
+  zero_v3(sctx->ret.no);
+  sctx->ret.index = -1;
+  zero_m4(sctx->ret.obmat);
+  sctx->ret.hit_list = r_hit_list;
+  sctx->ret.ob = nullptr;
+  sctx->ret.data = nullptr;
+  sctx->ret.dist_sq = FLT_MAX;
+  sctx->ret.is_edit = false;
+
   if (ray_depth == -1.0f) {
 ray_depth = BVH_RAYCAST_DIST_MAX;
   }
@@ -3128,18 +3138,17 @@ bool 
ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx,
   float ray_depth_prev = ray_depth;
 #endif
 
-  bool retval = raycastObjects(sctx, params, ray_start, ray_normal, 
_depth);
-
-  /* meant to be readonly for 'all' hits, ensure it is */
+  if (raycastObjects(sctx, params, ray_start, ray_normal, _depth)) {
+if (sort) {
+  BLI_listbase_sort(r_hit_list, hit_depth_cmp);
+}
+/* meant to be readonly for 'all' hits, ensure it is */
 #ifdef DEBUG
-  BLI_assert(ray_depth_prev == ray_depth);
+BLI_assert(ray_depth_prev == ray_depth);
 #endif
-
-  if (sort) {
-BLI_listbase_sort(r_hit_list, hit_depth_cmp);
+return true;
   }
-
-  return retval;
+  return false;
 }
 
 /**

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ff4f14b21a4] master: Fix T102053: snap fails with instances of geometry nodes

2022-11-07 Thread Germano Cavalcante
Commit: ff4f14b21a42e65de49f073bba2e6de81569d07a
Author: Germano Cavalcante
Date:   Sun Nov 6 12:24:20 2022 -0300
Branches: master
https://developer.blender.org/rBff4f14b21a42e65de49f073bba2e6de81569d07a

Fix T102053: snap fails with instances of geometry nodes

As instances are often generated geometries, we cannot rely on the data
provided by `DupliObject::ob`.

Use `DupliObject::ob_data` when possible.

This required a major refactor in the code as the output variables are
now gathered in context and easier to access.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index 2fab789afca..54085295e9e 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -35,6 +35,7 @@
 #include "BKE_layer.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_runtime.h"
+#include "BKE_mesh_wrapper.h"
 #include "BKE_object.h"
 #include "BKE_tracking.h"
 
@@ -125,6 +126,28 @@ struct SnapObjectContext {
 eSnapMode snap_to_flag;
 bool has_occlusion_plane; /* Ignore plane of occlusion in curves. */
   } runtime;
+
+  /* Output. */
+  struct {
+/* Location of snapped point on target surface. */
+float loc[3];
+/* Normal of snapped point on target surface. */
+float no[3];
+/* Index of snapped element on target object (-1 when no valid index is 
found). */
+int index;
+/* Matrix of target object (may not be #Object.object_to_world with 
dupli-instances). */
+float obmat[4][4];
+/* List of #SnapObjectHitDepth (caller must free). */
+ListBase *hit_list;
+/* Snapped object. */
+Object *ob;
+/* Snapped data. */
+ID *data;
+
+float dist_sq;
+
+bool is_edit;
+  } ret;
 };
 
 /** \} */
@@ -140,20 +163,20 @@ struct SnapObjectContext {
  * - In rare cases there is no evaluated mesh available and a null result 
doesn't imply an
  *   edit-mesh, so callers need to account for a null edit-mesh too, see: 
T96536.
  */
-static const Mesh *mesh_for_snap(Object *ob_eval, eSnapEditType 
edit_mode_type, bool *r_use_hide)
+static ID *data_for_snap(Object *ob_eval, eSnapEditType edit_mode_type, bool 
*r_use_hide)
 {
-  const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
   bool use_hide = false;
 
   switch (ob_eval->type) {
 case OB_MESH: {
+  Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
   if (BKE_object_is_in_editmode(ob_eval)) {
 if (edit_mode_type == SNAP_GEOM_EDIT) {
   return nullptr;
 }
 
-const Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
-const Mesh *editmesh_eval_cage = 
BKE_object_get_editmesh_eval_cage(ob_eval);
+Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
+Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval);
 
 if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) {
   if (editmesh_eval_final->runtime->wrapper_type == 
ME_WRAPPER_TYPE_BMESH) {
@@ -170,7 +193,10 @@ static const Mesh *mesh_for_snap(Object *ob_eval, 
eSnapEditType edit_mode_type,
   use_hide = true;
 }
   }
-  break;
+  if (r_use_hide) {
+*r_use_hide = use_hide;
+  }
+  return (ID *)me_eval;
 }
 default:
   break;
@@ -178,7 +204,7 @@ static const Mesh *mesh_for_snap(Object *ob_eval, 
eSnapEditType edit_mode_type,
   if (r_use_hide) {
 *r_use_hide = use_hide;
   }
-  return me_eval;
+  return (ID *)ob_eval->data;
 }
 
 /** \} */
@@ -368,12 +394,14 @@ static BVHTreeFromEditMesh 
*snap_object_data_editmesh_treedata_get(SnapObjectCon
 /** \name Iterator
  * \{ */
 
-using IterSnapObjsCallback = void (*)(SnapObjectContext *sctx,
-  const SnapObjectParams *params,
-  Object *ob_eval,
-  const float obmat[4][4],
-  bool is_object_active,
-  void *data);
+using IterSnapObjsCallback = eSnapMode (*)(SnapObjectContext *sctx,
+   const SnapObjectParams *params,
+   Object *ob_eval,
+   ID *ob_data,
+   const float obmat[4][4],
+   bool is_object_active,
+   bool use_hide,
+   void *data);
 
 static bool snap_object_is_snappable(const SnapObjectContext *sctx,
 

[Bf-blender-cvs] [b2db324f60e] master: Fix potentially uninitialized memory usage

2022-11-07 Thread Germano Cavalcante
Commit: b2db324f60e666757d332ec786dac12d064873a0
Author: Germano Cavalcante
Date:   Sun Nov 6 10:14:53 2022 -0300
Branches: master
https://developer.blender.org/rBb2db324f60e666757d332ec786dac12d064873a0

Fix potentially uninitialized memory usage

`nearest_world_tree_co` allows null parameter, so the `index` variable
isn't really needed and doesn't even need to be initialized.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index a75a94803f7..2fab789afca 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -1187,14 +1187,13 @@ static bool nearest_world_tree(SnapObjectContext * 
/*sctx*/,
 
   float co_local[3];
   float no_local[3];
-  int index;
 
   copy_v3_v3(co_local, init_co_local);
 
   for (int i = 0; i < params->face_nearest_steps; i++) {
 add_v3_v3(co_local, delta_local);
 nearest_world_tree_co(
-tree, nearest_cb, treedata, co_local, co_local, no_local, , 
nullptr);
+tree, nearest_cb, treedata, co_local, co_local, no_local, r_index, 
nullptr);
   }
 
   mul_v3_m4v3(r_loc, obmat, co_local);
@@ -1204,10 +1203,6 @@ static bool nearest_world_tree(SnapObjectContext * 
/*sctx*/,
 normalize_v3(r_no);
   }
 
-  if (r_index) {
-*r_index = index;
-  }
-
   return true;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cad897de166] master: Transform: remove SnapData cache for meshes

2022-11-07 Thread Germano Cavalcante
Commit: cad897de1660b1c81971c58cbcea41100d5f930c
Author: Germano Cavalcante
Date:   Thu Nov 3 16:33:41 2022 -0300
Branches: master
https://developer.blender.org/rBcad897de1660b1c81971c58cbcea41100d5f930c

Transform: remove SnapData cache for meshes

All cache needed is already stored in `Mesh.runtime`.

===

M   source/blender/editors/transform/transform_snap_object.cc

===

diff --git a/source/blender/editors/transform/transform_snap_object.cc 
b/source/blender/editors/transform/transform_snap_object.cc
index 24d76a50117..a75a94803f7 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -61,41 +61,6 @@ enum eViewProj {
   VIEW_PROJ_PERSP = -1,
 };
 
-/* SnapObjectContext.cache.mesh_map */
-struct SnapData_Mesh {
-  /* Loose edges, loose verts. */
-  BVHTree *bvhtree[2];
-  bool cached[2];
-
-  /* Looptris. */
-  BVHTreeFromMesh treedata_mesh;
-
-  const MPoly *poly;
-  bool has_looptris;
-  bool has_loose_edge;
-  bool has_loose_vert;
-
-  void clear()
-  {
-for (int i = 0; i < ARRAY_SIZE(this->bvhtree); i++) {
-  if (!this->cached[i]) {
-BLI_bvhtree_free(this->bvhtree[i]);
-  }
-  this->bvhtree[i] = nullptr;
-}
-free_bvhtree_from_mesh(>treedata_mesh);
-  }
-
-  ~SnapData_Mesh()
-  {
-this->clear();
-  }
-
-#ifdef WITH_CXX_GUARDEDALLOC
-  MEM_CXX_CLASS_ALLOC_FUNCS("SnapData_Mesh")
-#endif
-};
-
 /* SnapObjectContext.cache.editmesh_map */
 struct SnapData_EditMesh {
   /* Verts, Edges. */
@@ -134,7 +99,6 @@ struct SnapObjectContext {
 
   int flag;
 
-  Map> mesh_caches;
   Map> editmesh_caches;
 
   /* Filter data, returns true to check this value */
@@ -180,28 +144,36 @@ static const Mesh *mesh_for_snap(Object *ob_eval, 
eSnapEditType edit_mode_type,
 {
   const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
   bool use_hide = false;
-  if (BKE_object_is_in_editmode(ob_eval)) {
-if (edit_mode_type == SNAP_GEOM_EDIT) {
-  return nullptr;
-}
 
-const Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
-const Mesh *editmesh_eval_cage = 
BKE_object_get_editmesh_eval_cage(ob_eval);
+  switch (ob_eval->type) {
+case OB_MESH: {
+  if (BKE_object_is_in_editmode(ob_eval)) {
+if (edit_mode_type == SNAP_GEOM_EDIT) {
+  return nullptr;
+}
+
+const Mesh *editmesh_eval_final = 
BKE_object_get_editmesh_eval_final(ob_eval);
+const Mesh *editmesh_eval_cage = 
BKE_object_get_editmesh_eval_cage(ob_eval);
 
-if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) {
-  if (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) 
{
-return nullptr;
-  }
-  me_eval = editmesh_eval_final;
-  use_hide = true;
-}
-else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) {
-  if (editmesh_eval_cage->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) {
-return nullptr;
+if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) {
+  if (editmesh_eval_final->runtime->wrapper_type == 
ME_WRAPPER_TYPE_BMESH) {
+return nullptr;
+  }
+  me_eval = editmesh_eval_final;
+  use_hide = true;
+}
+else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) {
+  if (editmesh_eval_cage->runtime->wrapper_type == 
ME_WRAPPER_TYPE_BMESH) {
+return nullptr;
+  }
+  me_eval = editmesh_eval_cage;
+  use_hide = true;
+}
   }
-  me_eval = editmesh_eval_cage;
-  use_hide = true;
+  break;
 }
+default:
+  break;
   }
   if (r_use_hide) {
 *r_use_hide = use_hide;
@@ -236,96 +208,31 @@ static void snap_editmesh_minmax(SnapObjectContext *sctx,
   }
 }
 
-static SnapData_Mesh *snap_object_data_mesh_get(SnapObjectContext *sctx,
-Object *ob_eval,
-const Mesh *me_eval,
-bool use_hide)
+static void snap_object_data_mesh_get(SnapObjectContext *sctx,
+  Object *ob_eval,
+  const Mesh *me_eval,
+  bool use_hide,
+  BVHTreeFromMesh *r_treedata)
 {
-  SnapData_Mesh *sod;
-  bool init = false;
-
   const Span verts = me_eval->verts();
   const Span edges = me_eval->edges();
   const Span polys = me_eval->polys();
   const Span loops = me_eval->loops();
 
-  if (std::unique_ptr *sod_p = 
sctx->mesh_caches.lookup_ptr(ob_eval)) {
-sod = sod_p->get();
-bool is_dirty = false;
-if (sod

[Bf-blender-cvs] [c2e36c09b99] master: Fix variable value assigned twice in succession

2022-10-31 Thread Germano Cavalcante
Commit: c2e36c09b993fc0678eaf6a65b2cbd8ea9132cdb
Author: Germano Cavalcante
Date:   Mon Oct 31 06:54:17 2022 -0300
Branches: master
https://developer.blender.org/rBc2e36c09b993fc0678eaf6a65b2cbd8ea9132cdb

Fix variable value assigned twice in succession

Error introduced in rBa7aa0f1a0c24

Mentioned in https://pvs-studio.com/en/blog/posts/cpp/1004/

It could cause the absolute snap to the y direction to fail in
some editor.

===

M   source/blender/editors/transform/transform.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 5b194ae7237..ad6ab625438 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1725,7 +1725,7 @@ static void initSnapSpatial(TransInfo *t, float 
r_snap[3], float *r_snap_precisi
 {
   /* Default values. */
   r_snap[0] = r_snap[1] = 1.0f;
-  r_snap[1] = 0.0f;
+  r_snap[2] = 0.0f;
   *r_snap_precision = 0.1f;
 
   if (t->spacetype == SPACE_VIEW3D) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f9c6e0c814b] blender-v3.3-release: Fix T101709: Proportional editing being disabled in NLA Editor redo panel

2022-10-26 Thread Germano Cavalcante
Commit: f9c6e0c814b673c31be162e8dbd9ac7c1bc7c5d8
Author: Germano Cavalcante
Date:   Tue Oct 11 12:47:19 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBf9c6e0c814b673c31be162e8dbd9ac7c1bc7c5d8

Fix T101709: Proportional editing being disabled in NLA Editor redo panel

Do not save the "use_proportional_edit" property if it is not supported.
This prevents it from being automatically disabled.

And hide "use_proportional_edit" in `SPACE_NLA`

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_ops.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 3dd5c7864c3..25a36477950 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1514,26 +1514,26 @@ void saveTransform(bContext *C, TransInfo *t, 
wmOperator *op)
 }
   }
 
-  bool use_prop_edit = false;
-  int prop_edit_flag = 0;
-  if (t->flag & T_PROP_EDIT_ALL) {
-if (t->flag & T_PROP_EDIT) {
-  use_prop_edit = true;
-}
-if (t->flag & T_PROP_CONNECTED) {
-  prop_edit_flag |= PROP_EDIT_CONNECTED;
-}
-if (t->flag & T_PROP_PROJECTED) {
-  prop_edit_flag |= PROP_EDIT_PROJECTED;
+  /* Save proportional edit settings.
+   * Skip saving proportional edit if it was not actually used. */
+  if (!(t->options & CTX_NO_PET)) {
+bool use_prop_edit = false;
+int prop_edit_flag = 0;
+if (t->flag & T_PROP_EDIT_ALL) {
+  if (t->flag & T_PROP_EDIT) {
+use_prop_edit = true;
+  }
+  if (t->flag & T_PROP_CONNECTED) {
+prop_edit_flag |= PROP_EDIT_CONNECTED;
+  }
+  if (t->flag & T_PROP_PROJECTED) {
+prop_edit_flag |= PROP_EDIT_PROJECTED;
+  }
 }
-  }
 
-  /* If modal, save settings back in scene if not set as operator argument */
-  if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) {
-/* save settings if not set in operator */
-
-/* skip saving proportional edit if it was not actually used */
-if (!(t->options & CTX_NO_PET)) {
+/* If modal, save settings back in scene if not set as operator argument */
+if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) {
+  /* save settings if not set in operator */
   if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) 
&&
   !RNA_property_is_set(op->ptr, prop)) {
 const Object *obact = OBACT(t->view_layer);
@@ -1571,6 +1571,14 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 ts->prop_mode = t->prop_mode;
   }
 }
+
+if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
+  RNA_property_boolean_set(op->ptr, prop, use_prop_edit);
+  RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & 
PROP_EDIT_CONNECTED);
+  RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & 
PROP_EDIT_PROJECTED);
+  RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
+  RNA_float_set(op->ptr, "proportional_size", t->prop_size);
+}
   }
 
   /* Save snapping settings. */
@@ -1630,14 +1638,6 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 }
   }
 
-  if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
-RNA_property_boolean_set(op->ptr, prop, use_prop_edit);
-RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & 
PROP_EDIT_CONNECTED);
-RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & 
PROP_EDIT_PROJECTED);
-RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
-RNA_float_set(op->ptr, "proportional_size", t->prop_size);
-  }
-
   if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
 RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0);
   }
diff --git a/source/blender/editors/transform/transform_ops.c 
b/source/blender/editors/transform/transform_ops.c
index 0f67dc41e3b..1d2bf102390 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -521,9 +521,7 @@ static int transform_invoke(bContext *C, wmOperator *op, 
const wmEvent *event)
   return OPERATOR_RUNNING_MODAL;
 }
 
-static bool transform_poll_property(const bContext *UNUSED(C),
-wmOperator *op,
-const PropertyRNA *prop)
+static bool transform_poll_property(const bContext *C, 

[Bf-blender-cvs] [4e9a8109b22] master: Fix T100571: Subdivision disabled with Orbit Around Selection

2022-10-24 Thread Germano Cavalcante
Commit: 4e9a8109b2219a9cddc3943d13a1d3ae231fdd50
Author: Germano Cavalcante
Date:   Mon Oct 24 14:51:07 2022 -0300
Branches: master
https://developer.blender.org/rB4e9a8109b2219a9cddc3943d13a1d3ae231fdd50

Fix T100571: Subdivision disabled with Orbit Around Selection

The bug has existed since crasy space was implemented.

rBbf8a26b7453d made the error even worse as the
`modifiers_disable_subsurf_temporary` function, which works like a
toggle, did not temporarily re-enable subsurf.

The main problem is that the derived mesh is modified but not marked as
dirty at the end.

===

M   source/blender/blenkernel/intern/crazyspace.cc

===

diff --git a/source/blender/blenkernel/intern/crazyspace.cc 
b/source/blender/blenkernel/intern/crazyspace.cc
index 190e2d3bb7e..f83c321c4ae 100644
--- a/source/blender/blenkernel/intern/crazyspace.cc
+++ b/source/blender/blenkernel/intern/crazyspace.cc
@@ -70,47 +70,48 @@ static void set_crazy_vertex_quat(float r_quat[4],
   sub_qt_qtqt(r_quat, q2, q1);
 }
 
-static bool modifiers_disable_subsurf_temporary(struct Scene *scene, Object 
*ob)
+static bool modifiers_disable_subsurf_temporary(Object *ob, const int 
cageIndex)
 {
-  bool disabled = false;
-  int cageIndex = BKE_modifiers_get_cage_index(scene, ob, nullptr, true);
+  bool changed = false;
 
   ModifierData *md = static_cast(ob->modifiers.first);
   for (int i = 0; md && i <= cageIndex; i++, md = md->next) {
 if (md->type == eModifierType_Subsurf) {
   md->mode ^= eModifierMode_DisableTemporary;
-  disabled = true;
+  changed = true;
 }
   }
 
-  return disabled;
+  return changed;
 }
 
 float (*BKE_crazyspace_get_mapped_editverts(struct Depsgraph *depsgraph, 
Object *obedit))[3]
 {
-  Scene *scene = DEG_get_input_scene(depsgraph);
   Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
   Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
-  Mesh *mesh_eval = static_cast(obedit_eval->data);
-  BMEditMesh *editmesh_eval = mesh_eval->edit_mesh;
+  const int cageIndex = BKE_modifiers_get_cage_index(scene_eval, obedit_eval, 
nullptr, true);
 
-  /* disable subsurf temporal, get mapped cos, and enable it */
-  if (modifiers_disable_subsurf_temporary(scene_eval, obedit_eval)) {
-/* Need to make new derived-mesh. */
+  /* Disable subsurf temporal, get mapped cos, and enable it. */
+  if (modifiers_disable_subsurf_temporary(obedit_eval, cageIndex)) {
+/* Need to make new cage.
+ * TODO: Avoid losing original evaluated geometry. */
 makeDerivedMesh(depsgraph, scene_eval, obedit_eval, _MASK_BAREMESH);
   }
 
-  /* now get the cage */
-  Mesh *mesh_eval_cage = editbmesh_get_eval_cage_from_orig(
-  depsgraph, scene, obedit, _MASK_BAREMESH);
+  /* Now get the cage. */
+  BMEditMesh *em_eval = BKE_editmesh_from_object(obedit_eval);
+  Mesh *mesh_eval_cage = editbmesh_get_eval_cage(
+  depsgraph, scene_eval, obedit_eval, em_eval, _MASK_BAREMESH);
 
-  const int nverts = editmesh_eval->bm->totvert;
+  const int nverts = em_eval->bm->totvert;
   float(*vertexcos)[3] = static_cast(
   MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map"));
   mesh_get_mapped_verts_coords(mesh_eval_cage, vertexcos, nverts);
 
-  /* set back the flag, no new cage needs to be built, transform does it */
-  modifiers_disable_subsurf_temporary(scene_eval, obedit_eval);
+  /* Set back the flag, and ensure new cage needs to be built. */
+  if (modifiers_disable_subsurf_temporary(obedit_eval, cageIndex)) {
+DEG_id_tag_update(>id, ID_RECALC_GEOMETRY);
+  }
 
   return vertexcos;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b7c5ce8c2d2] master: Transform: limit zero radius Shrink/Fatten to only 1 curve point

2022-10-23 Thread Germano Cavalcante
Commit: b7c5ce8c2d2df9a06527651cfc301d7f2d45633a
Author: Germano Cavalcante
Date:   Mon Oct 24 00:16:21 2022 -0300
Branches: master
https://developer.blender.org/rBb7c5ce8c2d2df9a06527651cfc301d7f2d45633a

Transform: limit zero radius Shrink/Fatten to only 1 curve point

rBb70bbfadfece allowed scaling of zero-radius points, but as it behaves
differently from other radius, it may not be suitable for multi-point
transformation.

===

M   source/blender/editors/transform/transform_mode_curveshrinkfatten.c

===

diff --git 
a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c 
b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
index 76ce7b29619..d8f04dea161 100644
--- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
@@ -101,12 +101,17 @@ void initCurveShrinkFatten(TransInfo *t)
 
   t->flag |= T_NO_CONSTRAINT;
 
-  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == 
RGN_TYPE_WINDOW)) {
-/* Save a factor to multiply the ratio and use in zero radius cases. */
+  float scale_factor = 0.0f;
+  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == 
RGN_TYPE_WINDOW) &&
+  t->data_len_all == 1 ||
+  (t->data_len_all == 3 && TRANS_DATA_CONTAINER_FIRST_OK(t)->data[0].val 
== NULL)) {
+/* For cases where only one point on the curve is being transformed and 
the radius of that
+ * point is zero, use the factor to multiply the offset of the ratio and 
allow scaling.
+ * Note that for bezier curves, 3 TransData equals 1 point in most cases. 
*/
 RegionView3D *rv3d = t->region->regiondata;
-float scale_factor = rv3d->pixsize * t->mouse.factor * t->zfac;
-t->custom.mode.data = POINTER_FROM_UINT(float_as_uint(scale_factor));
+scale_factor = rv3d->pixsize * t->mouse.factor * t->zfac;
   }
+  t->custom.mode.data = POINTER_FROM_UINT(float_as_uint(scale_factor));
 }
 
 /** \} */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [93afc50ac3e] master: Fix large incremental snap values in uv editor

2022-10-23 Thread Germano Cavalcante
Commit: 93afc50ac3effb384d2fdcdbe193fb9da6191f96
Author: Germano Cavalcante
Date:   Sun Oct 23 11:34:44 2022 -0300
Branches: master
https://developer.blender.org/rB93afc50ac3effb384d2fdcdbe193fb9da6191f96

Fix large incremental snap values in uv editor

Regression in rBa7aa0f1a0c24.

The default values of `t->snap` have been changed.

===

M   source/blender/editors/transform/transform_mode_translate.c

===

diff --git a/source/blender/editors/transform/transform_mode_translate.c 
b/source/blender/editors/transform/transform_mode_translate.c
index c751a68092f..59d34c3918b 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -686,8 +686,8 @@ void initTranslation(TransInfo *t)
   t->num.flag = 0;
   t->num.idx_max = t->idx_max;
 
-  t->snap[0] = 1.0;
-  t->snap[1] = t->snap_spatial_precision;
+  t->snap[0] = t->snap_spatial[0];
+  t->snap[1] = t->snap_spatial[0] * t->snap_spatial_precision;
 
   copy_v3_fl(t->num.val_inc, t->snap[0]);
   t->num.unit_sys = t->scene->unit.system;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b70bbfadfec] master: Fix T102000: Curve Shrink Fatten doesn't work for zero radius

2022-10-22 Thread Germano Cavalcante
Commit: b70bbfadfecec049ad1ac2de7a949198ca6c15bc
Author: Germano Cavalcante
Date:   Sat Oct 22 19:31:57 2022 -0300
Branches: master
https://developer.blender.org/rBb70bbfadfecec049ad1ac2de7a949198ca6c15bc

Fix T102000: Curve Shrink Fatten doesn't work for zero radius

Kind of intentional regression on rB2d1fe736fabd.

But the solution now is (theoretically) better than adding a hard coded
threshold.

For cases with zero radius, the new radius is now the offset of the
ratio projected onto the plane of the origin point.

===

M   source/blender/editors/transform/transform_mode_curveshrinkfatten.c

===

diff --git 
a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c 
b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
index f7f9e14b8ac..76ce7b29619 100644
--- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
+++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c
@@ -8,6 +8,7 @@
 #include 
 
 #include "BLI_math.h"
+#include "BLI_math_bits.h"
 #include "BLI_string.h"
 
 #include "BKE_context.h"
@@ -62,7 +63,14 @@ static void applyCurveShrinkFatten(TransInfo *t, const int 
UNUSED(mval[2]))
   }
 
   if (td->val) {
-*td->val = td->ival * ratio;
+if (td->ival == 0.0f && ratio > 1.0f) {
+  /* Allow Shrink/Fatten for zero radius. */
+  *td->val = (ratio - 1.0f) * 
uint_as_float(POINTER_AS_UINT(t->custom.mode.data));
+}
+else {
+  *td->val = td->ival * ratio;
+}
+
 /* apply PET */
 *td->val = interpf(*td->val, td->ival, td->factor);
 CLAMP_MIN(*td->val, 0.0f);
@@ -92,6 +100,13 @@ void initCurveShrinkFatten(TransInfo *t)
   t->num.unit_type[0] = B_UNIT_NONE;
 
   t->flag |= T_NO_CONSTRAINT;
+
+  if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == 
RGN_TYPE_WINDOW)) {
+/* Save a factor to multiply the ratio and use in zero radius cases. */
+RegionView3D *rv3d = t->region->regiondata;
+float scale_factor = rv3d->pixsize * t->mouse.factor * t->zfac;
+t->custom.mode.data = POINTER_FROM_UINT(float_as_uint(scale_factor));
+  }
 }
 
 /** \} */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [588db6152aa] master: Transform: remove unreachable code

2022-10-22 Thread Germano Cavalcante
Commit: 588db6152aaa8b8db55f8f3180787befc4238684
Author: Germano Cavalcante
Date:   Sat Oct 22 12:52:22 2022 -0300
Branches: master
https://developer.blender.org/rB588db6152aaa8b8db55f8f3180787befc4238684

Transform: remove unreachable code

The node grid snap only works with 2D coordinates, no transformation
matrix and no Objects.

Also rename `applyGridAbsolute` to `node_snap_grid_apply`.

===

M   source/blender/editors/transform/transform_convert_node.cc

===

diff --git a/source/blender/editors/transform/transform_convert_node.cc 
b/source/blender/editors/transform/transform_convert_node.cc
index 0b5dc73a051..6ab0e1fe701 100644
--- a/source/blender/editors/transform/transform_convert_node.cc
+++ b/source/blender/editors/transform/transform_convert_node.cc
@@ -16,7 +16,6 @@
 #include "BKE_context.h"
 #include "BKE_node.h"
 #include "BKE_node_tree_update.h"
-#include "BKE_object.h"
 #include "BKE_report.h"
 
 #include "ED_node.h"
@@ -159,7 +158,7 @@ static void createTransNodeData(bContext * /*C*/, TransInfo 
*t)
 /** \name Flush Transform Nodes
  * \{ */
 
-static void applyGridAbsolute(TransInfo *t)
+static void node_snap_grid_apply(TransInfo *t)
 {
   int i;
 
@@ -167,14 +166,14 @@ static void applyGridAbsolute(TransInfo *t)
 return;
   }
 
-  float grid_size[3];
-  copy_v3_v3(grid_size, t->snap_spatial);
+  float grid_size[2];
+  copy_v2_v2(grid_size, t->snap_spatial);
   if (t->modifiers & MOD_PRECISION) {
-mul_v3_fl(grid_size, t->snap_spatial_precision);
+mul_v2_fl(grid_size, t->snap_spatial_precision);
   }
 
   /* Early exit on unusable grid size. */
-  if (is_zero_v3(grid_size)) {
+  if (is_zero_v2(grid_size)) {
 return;
   }
 
@@ -182,7 +181,7 @@ static void applyGridAbsolute(TransInfo *t)
 TransData *td;
 
 for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
-  float iloc[3], loc[3], tvec[3];
+  float iloc[2], loc[2], tvec[2];
   if (td->flag & TD_SKIP) {
 continue;
   }
@@ -191,22 +190,13 @@ static void applyGridAbsolute(TransInfo *t)
 continue;
   }
 
-  copy_v3_v3(iloc, td->loc);
-  if (tc->use_local_mat) {
-mul_m4_v3(tc->mat, iloc);
-  }
-  else if (t->options & CTX_OBJECT) {
-BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob);
-copy_v3_v3(iloc, td->ob->obmat[3]);
-  }
+  copy_v2_v2(iloc, td->loc);
 
   loc[0] = roundf(iloc[0] / grid_size[0]) * grid_size[0];
   loc[1] = roundf(iloc[1] / grid_size[1]) * grid_size[1];
-  loc[2] = grid_size[2] ? roundf(iloc[2] / grid_size[2]) * grid_size[2] : 
iloc[2];
 
-  sub_v3_v3v3(tvec, loc, iloc);
-  mul_m3_v3(td->smtx, tvec);
-  add_v3_v3(td->loc, tvec);
+  sub_v2_v2v2(tvec, loc, iloc);
+  add_v2_v2(td->loc, tvec);
 }
   }
 }
@@ -244,7 +234,7 @@ static void flushTransNodes(TransInfo *t)
   }
 
   FOREACH_TRANS_DATA_CONTAINER (t, tc) {
-applyGridAbsolute(t);
+node_snap_grid_apply(t);
 
 /* flush to 2d vector from internally used 3d vector */
 for (int i = 0; i < tc->data_len; i++) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e16cea019ee] master: Cleanup: move grid snap functions to files where they are used

2022-10-22 Thread Germano Cavalcante
Commit: e16cea019ee184156a5c1849f2b7f2b762dc9a6e
Author: Germano Cavalcante
Date:   Sat Oct 22 12:27:59 2022 -0300
Branches: master
https://developer.blender.org/rBe16cea019ee184156a5c1849f2b7f2b762dc9a6e

Cleanup: move grid snap functions to files where they are used

===

M   source/blender/editors/transform/transform_convert_node.cc
M   source/blender/editors/transform/transform_mode_translate.c
M   source/blender/editors/transform/transform_snap.c
M   source/blender/editors/transform/transform_snap.h

===

diff --git a/source/blender/editors/transform/transform_convert_node.cc 
b/source/blender/editors/transform/transform_convert_node.cc
index eb5eb822d69..0b5dc73a051 100644
--- a/source/blender/editors/transform/transform_convert_node.cc
+++ b/source/blender/editors/transform/transform_convert_node.cc
@@ -16,6 +16,7 @@
 #include "BKE_context.h"
 #include "BKE_node.h"
 #include "BKE_node_tree_update.h"
+#include "BKE_object.h"
 #include "BKE_report.h"
 
 #include "ED_node.h"
@@ -155,9 +156,61 @@ static void createTransNodeData(bContext * /*C*/, 
TransInfo *t)
 /** \} */
 
 /*  */
-/** \name Node Transform Creation
+/** \name Flush Transform Nodes
  * \{ */
 
+static void applyGridAbsolute(TransInfo *t)
+{
+  int i;
+
+  if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | 
SCE_SNAP_MODE_GRID {
+return;
+  }
+
+  float grid_size[3];
+  copy_v3_v3(grid_size, t->snap_spatial);
+  if (t->modifiers & MOD_PRECISION) {
+mul_v3_fl(grid_size, t->snap_spatial_precision);
+  }
+
+  /* Early exit on unusable grid size. */
+  if (is_zero_v3(grid_size)) {
+return;
+  }
+
+  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+TransData *td;
+
+for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
+  float iloc[3], loc[3], tvec[3];
+  if (td->flag & TD_SKIP) {
+continue;
+  }
+
+  if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) {
+continue;
+  }
+
+  copy_v3_v3(iloc, td->loc);
+  if (tc->use_local_mat) {
+mul_m4_v3(tc->mat, iloc);
+  }
+  else if (t->options & CTX_OBJECT) {
+BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob);
+copy_v3_v3(iloc, td->ob->obmat[3]);
+  }
+
+  loc[0] = roundf(iloc[0] / grid_size[0]) * grid_size[0];
+  loc[1] = roundf(iloc[1] / grid_size[1]) * grid_size[1];
+  loc[2] = grid_size[2] ? roundf(iloc[2] / grid_size[2]) * grid_size[2] : 
iloc[2];
+
+  sub_v3_v3v3(tvec, loc, iloc);
+  mul_m3_v3(td->smtx, tvec);
+  add_v3_v3(td->loc, tvec);
+}
+  }
+}
+
 static void flushTransNodes(TransInfo *t)
 {
   using namespace blender::ed;
diff --git a/source/blender/editors/transform/transform_mode_translate.c 
b/source/blender/editors/transform/transform_mode_translate.c
index b7ffba6ad58..6461182afc1 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -170,7 +170,7 @@ static void transdata_elem_translate_fn(void *__restrict 
iter_data_v,
 /** \} */
 
 /*  */
-/** \name Transform (Translation)
+/** \name Transform (Translation) Header
  * \{ */
 
 static void translate_dist_to_str(char *r_str,
@@ -341,6 +341,96 @@ static void headerTranslation(TransInfo *t, const float 
vec[3], char str[UI_MAX_
   }
 }
 
+/** \} */
+
+/*  */
+/** \name Transform (Translation) Snapping
+ * \{ */
+
+static void translate_snap_target_grid_ensure(TransInfo *t)
+{
+  /* Only need to calculate once. */
+  if ((t->tsnap.status & TARGET_GRID_INIT) == 0) {
+if (t->data_type == _Cursor3D) {
+  /* Use a fallback when transforming the cursor.
+   * In this case the center is _not_ derived from the cursor which is 
being transformed. */
+  copy_v3_v3(t->tsnap.snapTargetGrid, 
TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->data->iloc);
+}
+else if (t->around == V3D_AROUND_CURSOR) {
+  /* Use a fallback for cursor selection,
+   * this isn't useful as a global center for absolute grid snapping
+   * since its not based on the position of the selection. */
+  tranform_snap_target_median_calc(t, t->tsnap.snapTargetGrid);
+}
+else {
+  copy_v3_v3(t->tsnap.snapTargetGrid, t->center_global);
+}
+t->tsnap.status |= TARGET_GRID_INIT;
+  }
+}
+
+static void translate_snap_grid_apply(TransInfo *t,
+const int max_index,
+const float grid_dist[3],
+

[Bf-blender-cvs] [a7aa0f1a0c2] master: Fix T101991: "Absolute Grid Snap" not working

2022-10-22 Thread Germano Cavalcante
Commit: a7aa0f1a0c240724e533a5b815c8c4d75b117902
Author: Germano Cavalcante
Date:   Sat Oct 22 12:00:01 2022 -0300
Branches: master
https://developer.blender.org/rBa7aa0f1a0c240724e533a5b815c8c4d75b117902

Fix T101991: "Absolute Grid Snap" not working

Error introduced in rB1edebb794b76.

In that commit it was kind of forgotten that the snap to grid is also
used in 3D views.

Also a refactoring and cleanup was applied to simplify the code.

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform.h
M   source/blender/editors/transform/transform_mode_translate.c
M   source/blender/editors/transform/transform_snap.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 919f4e5b85c..9fe8cd3df2e 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1721,13 +1721,17 @@ void saveTransform(bContext *C, TransInfo *t, 
wmOperator *op)
   }
 }
 
-static void initSnapSpatial(TransInfo *t, float r_snap[2], float r_snap_y[2])
+static void initSnapSpatial(TransInfo *t, float r_snap[3], float 
*r_snap_precision)
 {
+  /* Default values. */
+  r_snap[0] = r_snap[1] = 1.0f;
+  r_snap[1] = 0.0f;
+  *r_snap_precision = 0.1f;
+
   if (t->spacetype == SPACE_VIEW3D) {
 if (t->region->regiondata) {
   View3D *v3d = t->area->spacedata.first;
-  r_snap[0] = ED_view3d_grid_view_scale(t->scene, v3d, t->region, NULL) * 
1.0f;
-  r_snap[1] = r_snap[0] * 0.1f;
+  r_snap[0] = r_snap[1] = r_snap[2] = ED_view3d_grid_view_scale(t->scene, 
v3d, t->region, NULL);
 }
   }
   else if (t->spacetype == SPACE_IMAGE) {
@@ -1741,24 +1745,16 @@ static void initSnapSpatial(TransInfo *t, float 
r_snap[2], float r_snap_y[2])
 ED_space_image_grid_steps(sima, grid_steps_x, grid_steps_y, grid_size);
 /* Snapping value based on what type of grid is used (adaptive-subdividing 
or custom-grid). */
 r_snap[0] = ED_space_image_increment_snap_value(grid_size, grid_steps_x, 
zoom_factor);
-r_snap[1] = r_snap[0] / 2.0f;
-r_snap_y[0] = ED_space_image_increment_snap_value(grid_size, grid_steps_y, 
zoom_factor);
-r_snap_y[1] = r_snap_y[0] / 2.0f;
+r_snap[1] = ED_space_image_increment_snap_value(grid_size, grid_steps_y, 
zoom_factor);
+*r_snap_precision = 0.5f;
   }
   else if (t->spacetype == SPACE_CLIP) {
-r_snap[0] = 0.125f;
-r_snap[1] = 0.0625f;
+r_snap[0] = r_snap[1] = 0.125f;
+*r_snap_precision = 0.5f;
   }
   else if (t->spacetype == SPACE_NODE) {
 r_snap[0] = r_snap[1] = ED_node_grid_size();
   }
-  else if (t->spacetype == SPACE_GRAPH) {
-r_snap[0] = 1.0;
-r_snap[1] = 0.1f;
-  }
-  else {
-r_snap[0] = r_snap[1] = 1.0f;
-  }
 }
 
 bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent 
*event, int mode)
@@ -1898,7 +1894,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 
   initSnapping(t, op); /* Initialize snapping data AFTER mode flags */
 
-  initSnapSpatial(t, t->snap_spatial_x, t->snap_spatial_y);
+  initSnapSpatial(t, t->snap_spatial, >snap_spatial_precision);
 
   /* EVIL! posemode code can switch translation to rotate when 1 bone is 
selected.
* will be removed (ton) */
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 95686f12fe2..90f2795184b 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -555,9 +555,12 @@ typedef struct TransInfo {
   /** Snapping Gears. */
   float snap[2];
   /** Spatial snapping gears(even when rotating, scaling... etc). */
-  float snap_spatial_x[2];
-  /** Spatial snapping in the Y coordinate, for non-uniform grid in UV Editor. 
*/
-  float snap_spatial_y[2];
+  float snap_spatial[3];
+  /**
+   * Precision factor that is multiplied to snap_spatial when precision
+   * modifier is enabled for snap to grid or incremental snap.
+   */
+  float snap_spatial_precision;
   /** Mouse side of the current frame, 'L', 'R' or 'B' */
   char frame_side;
 
diff --git a/source/blender/editors/transform/transform_mode_translate.c 
b/source/blender/editors/transform/transform_mode_translate.c
index 91388ecd661..b7ffba6ad58 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -590,7 +590,8 @@ void initTranslation(TransInfo *t)
   t->num.flag = 0;
   t->num.idx_max = t->idx_max;
 
-  copy_v2_v2(t->snap, t->snap_spatial_x);
+  t->snap[0] = 1.0;
+  t->snap[1] = t->snap_spatial_precision;
 
   copy_v3_fl(t->num.val_inc, t->snap[0]);
   t->num.unit_sys = t->scene->unit.system

[Bf-blender-cvs] [9c20eda0add] master: Fix T101244: Empty point list in shader batch creation cause error

2022-10-21 Thread Germano Cavalcante
Commit: 9c20eda0add3e223cd473eb883806a04522d345b
Author: Germano Cavalcante
Date:   Fri Oct 21 14:24:18 2022 -0300
Branches: master
https://developer.blender.org/rB9c20eda0add3e223cd473eb883806a04522d345b

Fix T101244: Empty point list in shader batch creation cause error

Allow empty VBOs in Python GPUBatch creation.

===

M   release/scripts/modules/gpu_extras/batch.py

===

diff --git a/release/scripts/modules/gpu_extras/batch.py 
b/release/scripts/modules/gpu_extras/batch.py
index ba8e3879a8e..6c9ab52c1a3 100644
--- a/release/scripts/modules/gpu_extras/batch.py
+++ b/release/scripts/modules/gpu_extras/batch.py
@@ -34,13 +34,13 @@ def batch_for_shader(shader, type, content, *, 
indices=None):
 return 'I32'
 
 def recommended_attr_len(attr_name):
-item = content[attr_name][0]
 attr_len = 1
 try:
+item = content[attr_name][0]
 while True:
 attr_len *= len(item)
 item = item[0]
-except TypeError:
+except (TypeError, IndexError):
 pass
 return attr_len

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [048f1a1b8b7] master: GPU: remove unused member from FrameBuffer

2022-10-21 Thread Germano Cavalcante
Commit: 048f1a1b8b7ccf5b3d618a76a947941bf5d534f2
Author: Germano Cavalcante
Date:   Fri Oct 21 11:57:42 2022 -0300
Branches: master
https://developer.blender.org/rB048f1a1b8b7ccf5b3d618a76a947941bf5d534f2

GPU: remove unused member from FrameBuffer

Accidentally added in rB2510bd3a5f35d14f5e0e098c79a776916d273223

===

M   source/blender/gpu/intern/gpu_framebuffer_private.hh

===

diff --git a/source/blender/gpu/intern/gpu_framebuffer_private.hh 
b/source/blender/gpu/intern/gpu_framebuffer_private.hh
index 76e816e7f65..5afcc102e44 100644
--- a/source/blender/gpu/intern/gpu_framebuffer_private.hh
+++ b/source/blender/gpu/intern/gpu_framebuffer_private.hh
@@ -94,11 +94,6 @@ class FrameBuffer {
   void **py_ref = nullptr;
 #endif
 
- public:
-  /* Reference of a pointer that needs to be cleaned when deallocating the 
frame-buffer.
-   * Points to #BPyGPUFrameBuffer::fb */
-  void **ref = nullptr;
-
  public:
   FrameBuffer(const char *name);
   virtual ~FrameBuffer();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f0ebf696cbb] master: Fix T101964: Edge and face snapping no locking to axis

2022-10-21 Thread Germano Cavalcante
Commit: f0ebf696cbbb521f956c5b612037f4d11e87cb0d
Author: Germano Cavalcante
Date:   Fri Oct 21 09:52:53 2022 -0300
Branches: master
https://developer.blender.org/rBf0ebf696cbbb521f956c5b612037f4d11e87cb0d

Fix T101964: Edge and face snapping no locking to axis

In rBed6c8d82b804 it was wrongly assumed that the constraint functions
always apply the transformations.

But that is not the case for when axes are aligned.

The `mul_m3_v3(t->con.pmtx, out)` fallback is still required.

===

M   source/blender/editors/transform/transform_constraints.c

===

diff --git a/source/blender/editors/transform/transform_constraints.c 
b/source/blender/editors/transform/transform_constraints.c
index fa56456d8e7..7abf0e5c00c 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -404,9 +404,11 @@ static void applyAxisConstraintVec(const TransInfo *t,
   }
 }
 
+/* Fallback for when axes are aligned. */
+mul_m3_v3(t->con.pmtx, out);
+
 if (is_snap_to_point) {
-  /* With snap points, a projection is alright, no adjustments needed. */
-  mul_m3_v3(t->con.pmtx, out);
+  /* Pass. With snap points, a projection is alright, no adjustments 
needed. */
 }
 else {
   const int dims = getConstraintSpaceDimension(t);
@@ -422,14 +424,9 @@ static void applyAxisConstraintVec(const TransInfo *t,
 /* Disabled, as it has not proven to be really useful. (See 
T82386). */
 // constraint_snap_plane_to_face(t, plane, out);
   }
-  else {
+  else if (!isPlaneProjectionViewAligned(t, plane)) {
 /* View alignment correction. */
-if (!isPlaneProjectionViewAligned(t, plane)) {
-  planeProjection(t, plane, in, out);
-}
-else {
-  mul_m3_v3(t->con.pmtx, out);
-}
+planeProjection(t, plane, in, out);
   }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [425e7ca3421] master: Fix T101928: transform operator properties saving wrong snap values

2022-10-19 Thread Germano Cavalcante
Commit: 425e7ca3421d3a17651701d305140f490f5d2afc
Author: Germano Cavalcante
Date:   Wed Oct 19 10:56:33 2022 -0300
Branches: master
https://developer.blender.org/rB425e7ca3421d3a17651701d305140f490f5d2afc

Fix T101928: transform operator properties saving wrong snap values

The check for the flags should be `== 0` since they are describing a
negative state.

Thanks to @lone_noel for pointing out the error.

===

M   source/blender/editors/transform/transform.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 34e5b78c48f..919f4e5b85c 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1594,9 +1594,9 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
   RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_select);
 
   eSnapTargetSelect target = t->tsnap.target_select;
-  RNA_boolean_set(op->ptr, "use_snap_self", (target & 
SCE_SNAP_TARGET_NOT_ACTIVE) != 0);
-  RNA_boolean_set(op->ptr, "use_snap_edit", (target & 
SCE_SNAP_TARGET_NOT_EDITED) != 0);
-  RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & 
SCE_SNAP_TARGET_NOT_NONEDITED) != 0);
+  RNA_boolean_set(op->ptr, "use_snap_self", (target & 
SCE_SNAP_TARGET_NOT_ACTIVE) == 0);
+  RNA_boolean_set(op->ptr, "use_snap_edit", (target & 
SCE_SNAP_TARGET_NOT_EDITED) == 0);
+  RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & 
SCE_SNAP_TARGET_NOT_NONEDITED) == 0);
   RNA_boolean_set(
   op->ptr, "use_snap_selectable", (target & 
SCE_SNAP_TARGET_ONLY_SELECTABLE) != 0);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d57352b1147] master: Fix T101893: Auto merge affecting edge crease and bevel weight

2022-10-18 Thread Germano Cavalcante
Commit: d57352b1147642660c13aeb17a0c603593fc0dea
Author: Germano Cavalcante
Date:   Tue Oct 18 12:50:11 2022 -0300
Branches: master
https://developer.blender.org/rBd57352b1147642660c13aeb17a0c603593fc0dea

Fix T101893: Auto merge affecting edge crease and bevel weight

None of the special transformations in `special_aftertrans_update__mesh`
are really applicable or useful for edge crease and bevel weight.

===

M   source/blender/editors/transform/transform_convert.h
M   source/blender/editors/transform/transform_convert_mesh.c
M   source/blender/editors/transform/transform_convert_mesh_edge.c

===

diff --git a/source/blender/editors/transform/transform_convert.h 
b/source/blender/editors/transform/transform_convert.h
index 8466fd88e1d..4798d666d70 100644
--- a/source/blender/editors/transform/transform_convert.h
+++ b/source/blender/editors/transform/transform_convert.h
@@ -226,8 +226,6 @@ void transform_convert_mesh_crazyspace_transdata_set(const 
float mtx[3][3],
  struct TransData *r_td);
 void transform_convert_mesh_crazyspace_free(struct TransMeshDataCrazySpace 
*r_crazyspace_data);
 
-void special_aftertrans_update__mesh(bContext *C, TransInfo *t);
-
 /* transform_convert_mesh_edge.c */
 
 extern TransConvertTypeInfo TransConvertType_MeshEdge;
diff --git a/source/blender/editors/transform/transform_convert_mesh.c 
b/source/blender/editors/transform/transform_convert_mesh.c
index af7982f862a..7e237c9eb32 100644
--- a/source/blender/editors/transform/transform_convert_mesh.c
+++ b/source/blender/editors/transform/transform_convert_mesh.c
@@ -2068,7 +2068,7 @@ static void recalcData_mesh(TransInfo *t)
 /** \name Special After Transform Mesh
  * \{ */
 
-void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
+static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
 {
   const bool is_canceling = (t->state == TRANS_CANCEL);
   const bool use_automerge = !is_canceling && (t->flag & (T_AUTOMERGE | 
T_AUTOSPLIT)) != 0;
diff --git a/source/blender/editors/transform/transform_convert_mesh_edge.c 
b/source/blender/editors/transform/transform_convert_mesh_edge.c
index 7f26029850b..0ce4c592f53 100644
--- a/source/blender/editors/transform/transform_convert_mesh_edge.c
+++ b/source/blender/editors/transform/transform_convert_mesh_edge.c
@@ -125,5 +125,5 @@ TransConvertTypeInfo TransConvertType_MeshEdge = {
 /* flags */ T_EDIT,
 /* createTransData */ createTransEdge,
 /* recalcData */ recalcData_mesh_edge,
-/* special_aftertrans_update */ special_aftertrans_update__mesh,
+/* special_aftertrans_update */ NULL,
 };

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c98268d3f56] blender-v3.3-release: DRW: fix use of potentially uninitialized variable

2022-10-17 Thread Germano Cavalcante
Commit: c98268d3f56dd6d448584872c00aceda6b91ccfe
Author: Germano Cavalcante
Date:   Thu Oct 6 15:00:35 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBc98268d3f56dd6d448584872c00aceda6b91ccfe

DRW: fix use of potentially uninitialized variable

Bug introduced in rB6774cae3f25b.

This causes undefined behavior in `DRW_state_draw_support()` making
overlay depth drawing unpredictable.

===

M   source/blender/draw/DRW_engine.h
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/space_view3d/view3d_draw.c

===

diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index dec7a22aadb..8c5f1b70cc0 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -126,14 +126,10 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
 void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
  struct ARegion *region,
  struct View3D *v3d,
- struct GPUViewport *viewport);
-/**
- * Converted from #ED_view3d_draw_depth_gpencil (legacy drawing).
- */
-void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
- struct ARegion *region,
- struct View3D *v3d,
- struct GPUViewport *viewport);
+ struct GPUViewport *viewport,
+ const bool use_gpencil,
+ const bool use_basic,
+ const bool use_overlay);
 /**
  * Clears the Depth Buffer and draws only the specified object.
  */
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index b2422504825..fcada20e5fb 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2534,13 +2534,13 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
 /**
  * object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
  */
-static void drw_draw_depth_loop_impl(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport,
- const bool use_gpencil,
- const bool use_basic,
- const bool use_overlay)
+void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
+ ARegion *region,
+ View3D *v3d,
+ GPUViewport *viewport,
+ const bool use_gpencil,
+ const bool use_basic,
+ const bool use_overlay)
 {
   Scene *scene = DEG_get_evaluated_scene(depsgraph);
   RenderEngineType *engine_type = ED_view3d_engine_type(scene, 
v3d->shading.type);
@@ -2649,23 +2649,6 @@ static void drw_draw_depth_loop_impl(struct Depsgraph 
*depsgraph,
   drw_manager_exit();
 }
 
-void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport)
-{
-  drw_draw_depth_loop_impl(
-  depsgraph, region, v3d, viewport, false, true, DRW_state_draw_support());
-}
-
-void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport)
-{
-  drw_draw_depth_loop_impl(depsgraph, region, v3d, viewport, true, false, 
false);
-}
-
 void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d, 
const rcti *rect)
 {
   SELECTID_Context *sel_ctx = DRW_select_engine_context_get();
diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index df5ff163cf2..f854b5d18af 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2332,10 +2332,11 @@ void ED_view3d_depth_override(Depsgraph *depsgraph,
   if (viewport != NULL) {
 switch (mode) {
   case V3D_DEPTH_NO_GPENCIL:
-DRW_draw_depth_loop(depsgraph, region, v3d, viewport);
+DRW_draw_depth_loop(
+depsgraph, region, v3d, viewport, false, true, (v3d->flag2 & 
V3D_HIDE_OVERLAYS) == 0);
 break;
   case V3D_DEPTH_GPENCIL_ONLY:
-DRW_draw_depth_loop_gpencil(depsgraph, region, v3d, viewport);
+DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, false, 
false);
 break;
   case V3D_DEPTH_OBJECT_ONLY:
 DRW_draw_depth_object(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
Li

[Bf-blender-cvs] [65b42d8c575] master: Fix T101709: Proportional editing being disabled in NLA Editor redo panel

2022-10-11 Thread Germano Cavalcante
Commit: 65b42d8c57537098828fd6acca6793aa9a093474
Author: Germano Cavalcante
Date:   Tue Oct 11 12:47:19 2022 -0300
Branches: master
https://developer.blender.org/rB65b42d8c57537098828fd6acca6793aa9a093474

Fix T101709: Proportional editing being disabled in NLA Editor redo panel

Do not save the "use_proportional_edit" property if it is not supported.
This prevents it from being automatically disabled.

And hide "use_proportional_edit" in `SPACE_NLA`

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_ops.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 6f7eb317b42..93e99f97387 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1518,26 +1518,26 @@ void saveTransform(bContext *C, TransInfo *t, 
wmOperator *op)
 }
   }
 
-  bool use_prop_edit = false;
-  int prop_edit_flag = 0;
-  if (t->flag & T_PROP_EDIT_ALL) {
-if (t->flag & T_PROP_EDIT) {
-  use_prop_edit = true;
-}
-if (t->flag & T_PROP_CONNECTED) {
-  prop_edit_flag |= PROP_EDIT_CONNECTED;
-}
-if (t->flag & T_PROP_PROJECTED) {
-  prop_edit_flag |= PROP_EDIT_PROJECTED;
+  /* Save proportional edit settings.
+   * Skip saving proportional edit if it was not actually used. */
+  if (!(t->options & CTX_NO_PET)) {
+bool use_prop_edit = false;
+int prop_edit_flag = 0;
+if (t->flag & T_PROP_EDIT_ALL) {
+  if (t->flag & T_PROP_EDIT) {
+use_prop_edit = true;
+  }
+  if (t->flag & T_PROP_CONNECTED) {
+prop_edit_flag |= PROP_EDIT_CONNECTED;
+  }
+  if (t->flag & T_PROP_PROJECTED) {
+prop_edit_flag |= PROP_EDIT_PROJECTED;
+  }
 }
-  }
 
-  /* If modal, save settings back in scene if not set as operator argument */
-  if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) {
-/* save settings if not set in operator */
-
-/* skip saving proportional edit if it was not actually used */
-if (!(t->options & CTX_NO_PET)) {
+/* If modal, save settings back in scene if not set as operator argument */
+if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) {
+  /* save settings if not set in operator */
   if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit")) 
&&
   !RNA_property_is_set(op->ptr, prop)) {
 BKE_view_layer_synced_ensure(t->scene, t->view_layer);
@@ -1576,6 +1576,14 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 ts->prop_mode = t->prop_mode;
   }
 }
+
+if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
+  RNA_property_boolean_set(op->ptr, prop, use_prop_edit);
+  RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & 
PROP_EDIT_CONNECTED);
+  RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & 
PROP_EDIT_PROJECTED);
+  RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
+  RNA_float_set(op->ptr, "proportional_size", t->prop_size);
+}
   }
 
   /* Save snapping settings. */
@@ -1635,14 +1643,6 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 }
   }
 
-  if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
-RNA_property_boolean_set(op->ptr, prop, use_prop_edit);
-RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & 
PROP_EDIT_CONNECTED);
-RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & 
PROP_EDIT_PROJECTED);
-RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
-RNA_float_set(op->ptr, "proportional_size", t->prop_size);
-  }
-
   if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
 RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0);
   }
diff --git a/source/blender/editors/transform/transform_ops.c 
b/source/blender/editors/transform/transform_ops.c
index dbda9a26bbf..82791b2a9f5 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -523,9 +523,7 @@ static int transform_invoke(bContext *C, wmOperator *op, 
const wmEvent *event)
   return OPERATOR_RUNNING_MODAL;
 }
 
-static bool transform_poll_property(const bContext *UNUSED(C),
-wmOperator *op,
-const PropertyRNA *prop)
+static bool transform_poll_property(const bContext *C, wmOperator 

[Bf-blender-cvs] [0d0e2dc0a8d] master: DRW: fix use of potentially uninitialized variable

2022-10-06 Thread Germano Cavalcante
Commit: 0d0e2dc0a8de1ba8d5adb71d3495fc35d0f399ba
Author: Germano Cavalcante
Date:   Thu Oct 6 15:00:35 2022 -0300
Branches: master
https://developer.blender.org/rB0d0e2dc0a8de1ba8d5adb71d3495fc35d0f399ba

DRW: fix use of potentially uninitialized variable

Bug introduced in rB6774cae3f25b.

This causes undefined behavior in `DRW_state_draw_support()` making
overlay depth drawing unpredictable.

===

M   source/blender/draw/DRW_engine.h
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/space_view3d/view3d_draw.cc

===

diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index dec7a22aadb..8c5f1b70cc0 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -126,14 +126,10 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
 void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
  struct ARegion *region,
  struct View3D *v3d,
- struct GPUViewport *viewport);
-/**
- * Converted from #ED_view3d_draw_depth_gpencil (legacy drawing).
- */
-void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
- struct ARegion *region,
- struct View3D *v3d,
- struct GPUViewport *viewport);
+ struct GPUViewport *viewport,
+ const bool use_gpencil,
+ const bool use_basic,
+ const bool use_overlay);
 /**
  * Clears the Depth Buffer and draws only the specified object.
  */
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index b6ca56d36fc..3272edef750 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2592,13 +2592,13 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
 /**
  * object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
  */
-static void drw_draw_depth_loop_impl(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport,
- const bool use_gpencil,
- const bool use_basic,
- const bool use_overlay)
+void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
+ ARegion *region,
+ View3D *v3d,
+ GPUViewport *viewport,
+ const bool use_gpencil,
+ const bool use_basic,
+ const bool use_overlay)
 {
   Scene *scene = DEG_get_evaluated_scene(depsgraph);
   RenderEngineType *engine_type = ED_view3d_engine_type(scene, 
v3d->shading.type);
@@ -2714,23 +2714,6 @@ static void drw_draw_depth_loop_impl(struct Depsgraph 
*depsgraph,
   drw_manager_exit();
 }
 
-void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport)
-{
-  drw_draw_depth_loop_impl(
-  depsgraph, region, v3d, viewport, false, true, DRW_state_draw_support());
-}
-
-void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport)
-{
-  drw_draw_depth_loop_impl(depsgraph, region, v3d, viewport, true, false, 
false);
-}
-
 void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d, 
const rcti *rect)
 {
   SELECTID_Context *sel_ctx = DRW_select_engine_context_get();
diff --git a/source/blender/editors/space_view3d/view3d_draw.cc 
b/source/blender/editors/space_view3d/view3d_draw.cc
index 33129dfff5d..8a86889f2d0 100644
--- a/source/blender/editors/space_view3d/view3d_draw.cc
+++ b/source/blender/editors/space_view3d/view3d_draw.cc
@@ -2362,10 +2362,11 @@ void ED_view3d_depth_override(Depsgraph *depsgraph,
   if (viewport != nullptr) {
 switch (mode) {
   case V3D_DEPTH_NO_GPENCIL:
-DRW_draw_depth_loop(depsgraph, region, v3d, viewport);
+DRW_draw_depth_loop(
+depsgraph, region, v3d, viewport, false, true, (v3d->flag2 & 
V3D_HIDE_OVERLAYS) == 0);
 break;
   case V3D_DEPTH_GPENCIL_ONLY:
-DRW_draw_depth_loop_gpencil(depsgraph, region, v3d, viewport);
+DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, false, 
false);
 break;
   case V3D_DEPTH_OBJECT_ONLY:
 DRW_draw_depth_object(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
Li

[Bf-blender-cvs] [1c8374978d6] blender-v3.3-release: Fix T101343: useless Snapping menu in transform operators

2022-09-30 Thread Germano Cavalcante
Commit: 1c8374978d64a1a80da7b840d9e071654b699eeb
Author: Germano Cavalcante
Date:   Mon Sep 26 14:18:29 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB1c8374978d64a1a80da7b840d9e071654b699eeb

Fix T101343: useless Snapping menu in transform operators

Changes:
- Use the "snap_elements" property only for operators that support snapping to 
geometry.
- Remove unused properties:
  - "use_snap_to_same_target",
  - "snap_face_nearest_steps").
- Fix property with wrong name "use_snap_selectable_only" -> 
"use_snap_selectable"
- Fix use of dependent property flags.
- Remove redundant initialization of variables
- Simplify `poll_propety`. Only the "use_snap_project" is not hidden.

>>! In rBc484599687ba it's said:
>  These options are needed for Python tools to control snapping without 
> requiring the tool settings to be adjusted.
If that's the case, there doesn't seem to be any need to display them in the 
redo panel.  Therefore:
- Hide snapping properties in redo panel.

Many properties have been added that can be independent of ToolSettings. 
Therefore:
- Save snapping properties in the operator itself. For Redo.

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_ops.c
M   source/blender/editors/transform/transform_snap.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 8dcbf07b776..212b84a101a 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1573,40 +1573,59 @@ void saveTransform(bContext *C, TransInfo *t, 
wmOperator *op)
 }
   }
 
-  if (t->flag & T_MODAL) {
-/* do we check for parameter? */
-if (transformModeUseSnap(t)) {
-  if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) {
-/* Type is #eSnapFlag, but type must match various snap attributes in 
#ToolSettings. */
-short *snap_flag_ptr;
+  /* Save sanpping settings. */
+  if (prop = RNA_struct_find_property(op->ptr, "snap")) {
+RNA_property_boolean_set(op->ptr, prop, (t->modifiers & MOD_SNAP) != 0);
 
-wmMsgParams_RNA msg_key_params = {{0}};
-RNA_pointer_create(>scene->id, _ToolSettings, ts, 
_key_params.ptr);
+if (prop = RNA_struct_find_property(op->ptr, "snap_elements")) {
+  RNA_property_enum_set(op->ptr, prop, t->tsnap.mode);
+  RNA_boolean_set(op->ptr, "use_snap_project", t->tsnap.project);
+  RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_select);
 
-if (t->spacetype == SPACE_NODE) {
-  snap_flag_ptr = >snap_flag_node;
-  msg_key_params.prop = _ToolSettings_use_snap_node;
-}
-else if (t->spacetype == SPACE_IMAGE) {
-  snap_flag_ptr = >snap_uv_flag;
-  msg_key_params.prop = _ToolSettings_use_snap_uv;
-}
-else if (t->spacetype == SPACE_SEQ) {
-  snap_flag_ptr = >snap_flag_seq;
-  msg_key_params.prop = _ToolSettings_use_snap_sequencer;
-}
-else {
-  snap_flag_ptr = >snap_flag;
-  msg_key_params.prop = _ToolSettings_use_snap;
-}
+  eSnapTargetSelect target = t->tsnap.target_select;
+  RNA_boolean_set(op->ptr, "use_snap_self", (target & 
SCE_SNAP_TARGET_NOT_ACTIVE) != 0);
+  RNA_boolean_set(op->ptr, "use_snap_edit", (target & 
SCE_SNAP_TARGET_NOT_EDITED) != 0);
+  RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & 
SCE_SNAP_TARGET_NOT_NONEDITED) != 0);
+  RNA_boolean_set(
+  op->ptr, "use_snap_selectable", (target & 
SCE_SNAP_TARGET_ONLY_SELECTABLE) != 0);
+}
 
-if (t->modifiers & MOD_SNAP) {
-  *snap_flag_ptr |= SCE_SNAP;
-}
-else {
-  *snap_flag_ptr &= ~SCE_SNAP;
+/* Update `ToolSettings` for properties that change during modal. */
+if (t->flag & T_MODAL) {
+  /* Do we check for parameter? */
+  if (transformModeUseSnap(t)) {
+if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) {
+  /* Type is #eSnapFlag, but type must match various snap attributes 
in #ToolSettings. */
+  short *snap_flag_ptr;
+
+  wmMsgParams_RNA msg_key_params = {{0}};
+  RNA_pointer_create(>scene->id, _ToolSettings, ts, 
_key_params.ptr);
+
+  if (t->spacetype == SPACE_NODE) {
+snap_flag_ptr = >snap_flag_node;
+msg_key_params.prop = _ToolSettings_use_snap_node;
+  }
+  else if (t->spacetype == SPACE_IMAG

[Bf-blender-cvs] [6c3364052b7] blender-v3.3-release: Fix T101231: Console flooded with warnings when fluid type is Domain

2022-09-30 Thread Germano Cavalcante
Commit: 6c3364052b78b4e61586b30ebb1d6c15e3065a93
Author: Germano Cavalcante
Date:   Tue Sep 27 10:11:54 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB6c3364052b78b4e61586b30ebb1d6c15e3065a93

Fix T101231: Console flooded with warnings when fluid type is Domain

Although rB67e23b4b2967 turned the problem more recurrent, the warning
messages in the console always appear when `BKE_fluid_cache_free_all`
is called.

This is because of a bug in `BLI_filelist_dir_contents` as this function
calls `BLI_strdupcat` instead of `BLI_join_dirfile`

NOTE: Other places in Blender avoid this problem by making sure to add
a `SEP_STR` to the end of the directory.

Differential Revision: https://developer.blender.org/D16043

===

M   source/blender/blenlib/intern/BLI_filelist.c

===

diff --git a/source/blender/blenlib/intern/BLI_filelist.c 
b/source/blender/blenlib/intern/BLI_filelist.c
index c6178ebb3a0..d2b44ec3451 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -174,10 +174,10 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, 
const char *dirname)
 struct direntry *file = _ctx->files[dir_ctx->files_num];
 while (dlink) {
   char fullname[PATH_MAX];
+  BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name);
   memset(file, 0, sizeof(struct direntry));
   file->relname = dlink->name;
-  file->path = BLI_strdupcat(dirname, dlink->name);
-  BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name);
+  file->path = BLI_strdup(fullname);
   if (BLI_stat(fullname, >s) != -1) {
 file->type = file->s.st_mode;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b4e8d03e5cf] blender-v3.3-release: Fix typo and and incorrect property initialization

2022-09-30 Thread Germano Cavalcante
Commit: b4e8d03e5cfa30872c927814df3096dec5c23955
Author: Germano Cavalcante
Date:   Mon Sep 26 14:23:11 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBb4e8d03e5cfa30872c927814df3096dec5c23955

Fix typo and and incorrect property initialization

Error in rB236fda7faf58

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_ops.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 212b84a101a..3dd5c7864c3 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1573,7 +1573,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 }
   }
 
-  /* Save sanpping settings. */
+  /* Save snapping settings. */
   if (prop = RNA_struct_find_property(op->ptr, "snap")) {
 RNA_property_boolean_set(op->ptr, prop, (t->modifiers & MOD_SNAP) != 0);
 
diff --git a/source/blender/editors/transform/transform_ops.c 
b/source/blender/editors/transform/transform_ops.c
index aeb88e9298f..0f67dc41e3b 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -682,7 +682,7 @@ void Transform_Properties(struct wmOperatorType *ot, int 
flags)
   prop = RNA_def_boolean(ot->srna, "use_snap_nonedit", true, "Target: 
Include Non-Edited", "");
   RNA_def_property_flag(prop, PROP_HIDDEN);
   prop = RNA_def_boolean(
-  ot->srna, "use_snap_selectable", true, "Target: Exclude 
Non-Selectable", "");
+  ot->srna, "use_snap_selectable", false, "Target: Exclude 
Non-Selectable", "");
   RNA_def_property_flag(prop, PROP_HIDDEN);
 
   prop = RNA_def_float_vector(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [715c86d9e58] master: Fix T101231: Console flooded with warnings when fluid type is Domain

2022-09-27 Thread Germano Cavalcante
Commit: 715c86d9e58f44ed078dd61c1fed45739bf65723
Author: Germano Cavalcante
Date:   Tue Sep 27 10:11:54 2022 -0300
Branches: master
https://developer.blender.org/rB715c86d9e58f44ed078dd61c1fed45739bf65723

Fix T101231: Console flooded with warnings when fluid type is Domain

Although rB67e23b4b2967 turned the problem more recurrent, the warning
messages in the console always appear when `BKE_fluid_cache_free_all`
is called.

This is because of a bug in `BLI_filelist_dir_contents` as this function
calls `BLI_strdupcat` instead of `BLI_join_dirfile`

NOTE: Other places in Blender avoid this problem by making sure to add
a `SEP_STR` to the end of the directory.

Differential Revision: https://developer.blender.org/D16043

===

M   source/blender/blenlib/intern/BLI_filelist.c

===

diff --git a/source/blender/blenlib/intern/BLI_filelist.c 
b/source/blender/blenlib/intern/BLI_filelist.c
index 37636ef1cf1..4e532f90fb5 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -174,10 +174,10 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, 
const char *dirname)
 struct direntry *file = _ctx->files[dir_ctx->files_num];
 while (dlink) {
   char fullname[PATH_MAX];
+  BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name);
   memset(file, 0, sizeof(struct direntry));
   file->relname = dlink->name;
-  file->path = BLI_strdupcat(dirname, dlink->name);
-  BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name);
+  file->path = BLI_strdup(fullname);
   if (BLI_stat(fullname, >s) != -1) {
 file->type = file->s.st_mode;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [46cfd345e47] master: Fix typo and and incorrect property initialization

2022-09-26 Thread Germano Cavalcante
Commit: 46cfd345e475bb05caf029502f6c9c3a4e2cc469
Author: Germano Cavalcante
Date:   Mon Sep 26 14:23:11 2022 -0300
Branches: master
https://developer.blender.org/rB46cfd345e475bb05caf029502f6c9c3a4e2cc469

Fix typo and and incorrect property initialization

Error in rB236fda7faf58

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_ops.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 6ca33a591cc..716005333c8 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1578,7 +1578,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator 
*op)
 }
   }
 
-  /* Save sanpping settings. */
+  /* Save snapping settings. */
   if (prop = RNA_struct_find_property(op->ptr, "snap")) {
 RNA_property_boolean_set(op->ptr, prop, (t->modifiers & MOD_SNAP) != 0);
 
diff --git a/source/blender/editors/transform/transform_ops.c 
b/source/blender/editors/transform/transform_ops.c
index f15ad99dbc3..dbda9a26bbf 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -684,7 +684,7 @@ void Transform_Properties(struct wmOperatorType *ot, int 
flags)
   prop = RNA_def_boolean(ot->srna, "use_snap_nonedit", true, "Target: 
Include Non-Edited", "");
   RNA_def_property_flag(prop, PROP_HIDDEN);
   prop = RNA_def_boolean(
-  ot->srna, "use_snap_selectable", true, "Target: Exclude 
Non-Selectable", "");
+  ot->srna, "use_snap_selectable", false, "Target: Exclude 
Non-Selectable", "");
   RNA_def_property_flag(prop, PROP_HIDDEN);
 
   prop = RNA_def_float_vector(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [236fda7faf5] master: Fix T101343: useless Snapping menu in transform operators

2022-09-26 Thread Germano Cavalcante
Commit: 236fda7faf58921f9f4b6d0d0300313b0ab1976a
Author: Germano Cavalcante
Date:   Mon Sep 26 14:18:29 2022 -0300
Branches: master
https://developer.blender.org/rB236fda7faf58921f9f4b6d0d0300313b0ab1976a

Fix T101343: useless Snapping menu in transform operators

Changes:
- Use the "snap_elements" property only for operators that support snapping to 
geometry.
- Remove unused properties:
  - "use_snap_to_same_target",
  - "snap_face_nearest_steps").
- Fix property with wrong name "use_snap_selectable_only" -> 
"use_snap_selectable"
- Fix use of dependent property flags.
- Remove redundant initialization of variables
- Simplify `poll_propety`. Only the "use_snap_project" is not hidden.

>>! In rBc484599687ba it's said:
>  These options are needed for Python tools to control snapping without 
> requiring the tool settings to be adjusted.
If that's the case, there doesn't seem to be any need to display them in the 
redo panel.  Therefore:
- Hide snapping properties in redo panel.

Many properties have been added that can be independent of ToolSettings. 
Therefore:
- Save snapping properties in the operator itself. For Redo.

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_ops.c
M   source/blender/editors/transform/transform_snap.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 85bb8c1b31a..6ca33a591cc 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1578,40 +1578,59 @@ void saveTransform(bContext *C, TransInfo *t, 
wmOperator *op)
 }
   }
 
-  if (t->flag & T_MODAL) {
-/* do we check for parameter? */
-if (transformModeUseSnap(t)) {
-  if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) {
-/* Type is #eSnapFlag, but type must match various snap attributes in 
#ToolSettings. */
-short *snap_flag_ptr;
+  /* Save sanpping settings. */
+  if (prop = RNA_struct_find_property(op->ptr, "snap")) {
+RNA_property_boolean_set(op->ptr, prop, (t->modifiers & MOD_SNAP) != 0);
 
-wmMsgParams_RNA msg_key_params = {{0}};
-RNA_pointer_create(>scene->id, _ToolSettings, ts, 
_key_params.ptr);
+if (prop = RNA_struct_find_property(op->ptr, "snap_elements")) {
+  RNA_property_enum_set(op->ptr, prop, t->tsnap.mode);
+  RNA_boolean_set(op->ptr, "use_snap_project", t->tsnap.project);
+  RNA_enum_set(op->ptr, "snap_target", t->tsnap.source_select);
 
-if (t->spacetype == SPACE_NODE) {
-  snap_flag_ptr = >snap_flag_node;
-  msg_key_params.prop = _ToolSettings_use_snap_node;
-}
-else if (t->spacetype == SPACE_IMAGE) {
-  snap_flag_ptr = >snap_uv_flag;
-  msg_key_params.prop = _ToolSettings_use_snap_uv;
-}
-else if (t->spacetype == SPACE_SEQ) {
-  snap_flag_ptr = >snap_flag_seq;
-  msg_key_params.prop = _ToolSettings_use_snap_sequencer;
-}
-else {
-  snap_flag_ptr = >snap_flag;
-  msg_key_params.prop = _ToolSettings_use_snap;
-}
+  eSnapTargetSelect target = t->tsnap.target_select;
+  RNA_boolean_set(op->ptr, "use_snap_self", (target & 
SCE_SNAP_TARGET_NOT_ACTIVE) != 0);
+  RNA_boolean_set(op->ptr, "use_snap_edit", (target & 
SCE_SNAP_TARGET_NOT_EDITED) != 0);
+  RNA_boolean_set(op->ptr, "use_snap_nonedit", (target & 
SCE_SNAP_TARGET_NOT_NONEDITED) != 0);
+  RNA_boolean_set(
+  op->ptr, "use_snap_selectable", (target & 
SCE_SNAP_TARGET_ONLY_SELECTABLE) != 0);
+}
 
-if (t->modifiers & MOD_SNAP) {
-  *snap_flag_ptr |= SCE_SNAP;
-}
-else {
-  *snap_flag_ptr &= ~SCE_SNAP;
+/* Update `ToolSettings` for properties that change during modal. */
+if (t->flag & T_MODAL) {
+  /* Do we check for parameter? */
+  if (transformModeUseSnap(t)) {
+if (!(t->modifiers & MOD_SNAP) != !(t->tsnap.flag & SCE_SNAP)) {
+  /* Type is #eSnapFlag, but type must match various snap attributes 
in #ToolSettings. */
+  short *snap_flag_ptr;
+
+  wmMsgParams_RNA msg_key_params = {{0}};
+  RNA_pointer_create(>scene->id, _ToolSettings, ts, 
_key_params.ptr);
+
+  if (t->spacetype == SPACE_NODE) {
+snap_flag_ptr = >snap_flag_node;
+msg_key_params.prop = _ToolSettings_use_snap_node;
+  }
+  else if (t->spacetype == SPACE_IMAGE) {
+snap_flag_p

[Bf-blender-cvs] [81ec5ec3665] blender-v3.3-release: Fix T100899: Drag and Drop failing depending on window position

2022-09-22 Thread Germano Cavalcante
Commit: 81ec5ec36651af6bc2c0f64c57add589facefef2
Author: Germano Cavalcante
Date:   Tue Sep 13 21:56:01 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB81ec5ec36651af6bc2c0f64c57add589facefef2

Fix T100899: Drag and Drop failing depending on window position

Regression introduced in rBbbf87c4f7509, which now relies on OS coordinates for 
Drag and Drop.

These coordinates did not match on different OSs.

===

M   intern/ghost/intern/GHOST_SystemCocoa.mm

===

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index c247ef3daa0..5562db7d67f 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1123,6 +1123,7 @@ GHOST_TSuccess 
GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
 case GHOST_kEventDraggingEntered:
 case GHOST_kEventDraggingUpdated:
 case GHOST_kEventDraggingExited:
+  window->clientToScreenIntern(mouseX, mouseY, mouseX, mouseY);
   pushEvent(new GHOST_EventDragnDrop(
   getMilliSeconds(), eventType, draggedObjectType, window, mouseX, 
mouseY, NULL));
   break;
@@ -1331,6 +1332,8 @@ GHOST_TSuccess 
GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
   return GHOST_kFailure;
   break;
   }
+
+  window->clientToScreenIntern(mouseX, mouseY, mouseX, mouseY);
   pushEvent(new GHOST_EventDragnDrop(
   getMilliSeconds(), eventType, draggedObjectType, window, mouseX, 
mouseY, eventData));

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [62ffbc7d7ff] master: PyGPU: Allow single bool in 'GPUShader.uniform_bool' method

2022-09-21 Thread Germano Cavalcante
Commit: 62ffbc7d7ffabc823d9f43618c9877ec357ec485
Author: Germano Cavalcante
Date:   Wed Sep 21 21:53:51 2022 -0300
Branches: master
https://developer.blender.org/rB62ffbc7d7ffabc823d9f43618c9877ec357ec485

PyGPU: Allow single bool in 'GPUShader.uniform_bool' method

As with the other uniform methods, a single value is expected.

===

M   source/blender/python/gpu/gpu_py_shader.c

===

diff --git a/source/blender/python/gpu/gpu_py_shader.c 
b/source/blender/python/gpu/gpu_py_shader.c
index 43b50dbbef0..a57b00e671e 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -302,14 +302,14 @@ static PyObject 
*pygpu_shader_uniform_vector_int(BPyGPUShader *self, PyObject *a
 }
 
 PyDoc_STRVAR(pygpu_shader_uniform_bool_doc,
- ".. method:: uniform_bool(name, seq)\n"
+ ".. method:: uniform_bool(name, value)\n"
  "\n"
  "   Specify the value of a uniform variable for the current 
program object.\n"
  "\n"
  "   :arg name: Name of the uniform variable whose value is to be 
changed.\n"
  "   :type name: str\n"
- "   :arg seq: Value that will be used to update the specified 
uniform variable.\n"
- "   :type seq: sequence of bools\n");
+ "   :arg value: Value that will be used to update the specified 
uniform variable.\n"
+ "   :type value: bool or sequence of bools\n");
 static PyObject *pygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
 {
   const char *error_prefix = "GPUShader.uniform_bool";
@@ -325,15 +325,14 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader 
*self, PyObject *args)
 
   int values[4];
   int length;
-  int ret;
-  {
+  int ret = -1;
+  if (PySequence_Check(params.seq)) {
 PyObject *seq_fast = PySequence_Fast(params.seq, error_prefix);
 if (seq_fast == NULL) {
   PyErr_Format(PyExc_TypeError,
"%s: expected a sequence, got %s",
error_prefix,
Py_TYPE(params.seq)->tp_name);
-  ret = -1;
 }
 else {
   length = PySequence_Fast_GET_SIZE(seq_fast);
@@ -342,7 +341,6 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader 
*self, PyObject *args)
  "%s: invalid sequence length. expected 1..4, got %d",
  error_prefix,
  length);
-ret = -1;
   }
   else {
 ret = PyC_AsArray_FAST(
@@ -351,6 +349,15 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader 
*self, PyObject *args)
   Py_DECREF(seq_fast);
 }
   }
+  else if (((values[0] = (int)PyLong_AsLong(params.seq)) != -1) && 
ELEM(values[0], 0, 1)) {
+length = 1;
+ret = 0;
+  }
+  else {
+PyErr_Format(
+PyExc_ValueError, "expected a bool or sequence, got %s", 
Py_TYPE(params.seq)->tp_name);
+  }
+
   if (ret == -1) {
 return NULL;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


  1   2   3   4   5   6   7   8   9   10   >