[Bf-blender-cvs] [d175eb6c30b] master: Fix Text Editor highlight of assert and async

2022-07-18 Thread Henrik Dick
Commit: d175eb6c30b0eb9630669522c643debf6a183efd
Author: Henrik Dick
Date:   Mon Jul 18 23:33:30 2022 +0200
Branches: master
https://developer.blender.org/rBd175eb6c30b0eb9630669522c643debf6a183efd

Fix Text Editor highlight of assert and async

Due to the ordering of the checks, assert and async were not highlighted
in the editor, even though they were in the list of keywords.

Differential Revision: http://developer.blender.org/D15483

===

M   source/blender/editors/space_text/text_format_py.c

===

diff --git a/source/blender/editors/space_text/text_format_py.c 
b/source/blender/editors/space_text/text_format_py.c
index aa361f07932..28f536ffa98 100644
--- a/source/blender/editors/space_text/text_format_py.c
+++ b/source/blender/editors/space_text/text_format_py.c
@@ -59,9 +59,9 @@ static int txtfmt_py_find_builtinfunc(const char *string)
   /* clang-format off */
 
   if(STR_LITERAL_STARTSWITH(string, "and",  len)) { i = len;
-  } else if (STR_LITERAL_STARTSWITH(string, "as",   len)) { i = len;
   } else if (STR_LITERAL_STARTSWITH(string, "assert",   len)) { i = len;
   } else if (STR_LITERAL_STARTSWITH(string, "async",len)) { i = len;
+  } else if (STR_LITERAL_STARTSWITH(string, "as",   len)) { i = len;
   } else if (STR_LITERAL_STARTSWITH(string, "await",len)) { i = len;
   } else if (STR_LITERAL_STARTSWITH(string, "break",len)) { i = len;
   } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = 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] [fd7384a751b] master: Merge branch 'blender-v3.2-release'

2022-05-02 Thread Henrik Dick
Commit: fd7384a751b6cbf6f64ecee1427f4ddf4a107f51
Author: Henrik Dick
Date:   Mon May 2 22:18:21 2022 +0200
Branches: master
https://developer.blender.org/rBfd7384a751b6cbf6f64ecee1427f4ddf4a107f51

Merge branch 'blender-v3.2-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] [62ef1c08af9] blender-v3.2-release: GPencil: Fix envelope modifier deform mode thickness

2022-05-02 Thread Henrik Dick
Commit: 62ef1c08af9a62104201e062f2b9a374c056e53b
Author: Henrik Dick
Date:   Mon May 2 22:13:38 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB62ef1c08af9a62104201e062f2b9a374c056e53b

GPencil: Fix envelope modifier deform mode thickness

The thickness in the deform mode was just correct if the radius when
drawing a stroke was set to 20. Now all factors that influence the
stroke thickness are considered in deform mode.

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

===

M   source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
index 8b0a6ee84a2..e5604005240 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
@@ -152,8 +152,12 @@ static float calc_radius_limit(
   return radius_limit;
 }
 
-static void apply_stroke_envelope(
-bGPDstroke *gps, int spread, const int def_nr, const bool invert_vg, const 
float thickness)
+static void apply_stroke_envelope(bGPDstroke *gps,
+  int spread,
+  const int def_nr,
+  const bool invert_vg,
+  const float thickness,
+  const float pixfactor)
 {
   const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
   if (is_cyclic) {
@@ -282,9 +286,7 @@ static void apply_stroke_envelope(
 }
 
 float fac = use_dist * weight;
-/* The 50 is an internal constant for the default pixel size. The result 
can be messed up if
- * #bGPdata.pixfactor is not default, but I think modifiers shouldn't 
access that. */
-point->pressure += fac * 50.0f * GP_DEFAULT_PIX_FACTOR;
+point->pressure += fac * pixfactor;
 interp_v3_v3v3(>x, >x, new_center, fac / len_v3v3(closest, 
closest2));
   }
 
@@ -326,8 +328,14 @@ static void deformStroke(GpencilModifierData *md,
 return;
   }
 
-  apply_stroke_envelope(
-  gps, mmd->spread, def_nr, (mmd->flag & GP_ENVELOPE_INVERT_VGROUP) != 0, 
mmd->thickness);
+  bGPdata *gpd = (bGPdata *)ob->data;
+  const float pixfactor = 1000.0f / ((gps->thickness + gpl->line_change) * 
gpd->pixfactor);
+  apply_stroke_envelope(gps,
+mmd->spread,
+def_nr,
+(mmd->flag & GP_ENVELOPE_INVERT_VGROUP) != 0,
+mmd->thickness,
+pixfactor);
 }
 
 static void add_stroke(Object *ob,

___
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] [1be8a1260cf] temp-T96710-pbvh-pixels: GPencil: Add skip option to envelope modifier

2022-04-08 Thread Henrik Dick
Commit: 1be8a1260cf0b64c9963a99549774a8524c0aa0c
Author: Henrik Dick
Date:   Thu Apr 7 17:41:49 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB1be8a1260cf0b64c9963a99549774a8524c0aa0c

GPencil: Add skip option to envelope modifier

This patch adds an option to only use every n-th segment of the
envelope result. This can be used to reduce the complexity of the
result.

Differential Revision: http://developer.blender.org/D14503

===

M   source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
M   source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
index f8ac8d95493..d9881f5b7ae 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
@@ -332,18 +332,17 @@ static void add_stroke(Object *ob,
bGPDstroke *gps,
const int point_index,
const int connection_index,
-   const int size,
+   const int size2,
+   const int size1,
const int mat_nr,
const float thickness,
const float strength,
ListBase *results)
 {
+  const int size = size1 + size2;
   bGPdata *gpd = ob->data;
   bGPDstroke *gps_dst = BKE_gpencil_stroke_new(mat_nr, size, gps->thickness);
 
-  const int size1 = size == 4 ? 2 : 1;
-  const int size2 = size - size1;
-
   memcpy(_dst->points[0], >points[connection_index], size1 * 
sizeof(bGPDspoint));
   memcpy(_dst->points[size1], >points[point_index], size2 * 
sizeof(bGPDspoint));
 
@@ -369,35 +368,36 @@ static void add_stroke_cyclic(Object *ob,
   bGPDstroke *gps,
   const int point_index,
   const int connection_index,
+  const int size,
   const int mat_nr,
   const float thickness,
   const float strength,
   ListBase *results)
 {
   bGPdata *gpd = ob->data;
-  bGPDstroke *gps_dst = BKE_gpencil_stroke_new(mat_nr, 4, gps->thickness);
+  bGPDstroke *gps_dst = BKE_gpencil_stroke_new(mat_nr, size * 2, 
gps->thickness);
+  if (gps->dvert != NULL) {
+gps_dst->dvert = MEM_malloc_arrayN(size * 2, sizeof(MDeformVert), 
__func__);
+  }
 
-  int connection_index2 = (connection_index + 1) % gps->totpoints;
-  int point_index2 = (point_index + 1) % gps->totpoints;
+  for (int i = 0; i < size; i++) {
+int a = (connection_index + i) % gps->totpoints;
+int b = (point_index + i) % gps->totpoints;
 
-  gps_dst->points[0] = gps->points[connection_index];
-  gps_dst->points[1] = gps->points[connection_index2];
-  gps_dst->points[2] = gps->points[point_index];
-  gps_dst->points[3] = gps->points[point_index2];
-  for (int i = 0; i < 4; i++) {
+gps_dst->points[i] = gps->points[a];
+gps_dst->points[size + i] = gps->points[b];
+
+if (gps->dvert != NULL) {
+  BKE_defvert_array_copy(_dst->dvert[i], >dvert[a], 1);
+  BKE_defvert_array_copy(_dst->dvert[size + i], >dvert[b], 1);
+}
+  }
+  for (int i = 0; i < size * 2; i++) {
 gps_dst->points[i].pressure *= thickness;
 gps_dst->points[i].strength *= strength;
 memset(_dst->points[i].runtime, 0, sizeof(bGPDspoint_Runtime));
   }
 
-  if (gps->dvert != NULL) {
-gps_dst->dvert = MEM_malloc_arrayN(4, sizeof(MDeformVert), __func__);
-BKE_defvert_array_copy(_dst->dvert[0], >dvert[connection_index], 
1);
-BKE_defvert_array_copy(_dst->dvert[1], >dvert[connection_index2], 
1);
-BKE_defvert_array_copy(_dst->dvert[2], >dvert[point_index], 1);
-BKE_defvert_array_copy(_dst->dvert[3], >dvert[point_index2], 1);
-  }
-
   BLI_addtail(results, gps_dst);
 
   /* Calc geometry data. */
@@ -459,31 +459,41 @@ static void generate_geometry(GpencilModifierData *md, 
Object *ob, bGPDlayer *gp
 
 const int mat_nr = mmd->mat_nr < 0 ? gps->mat_nr : min_ii(mmd->mat_nr, 
ob->totcol - 1);
 if (mmd->mode == GP_ENVELOPE_FILLS) {
+  const int skip = min_ii(mmd->skip, min_ii(mmd->spread / 2, 
gps->totpoints - 2));
   if (gps->flag & GP_STROKE_CYCLIC) {
 for (int i = 0; i < gps->totpoints; i++) {
-  const int connection_index = (i + mmd->spread) % gps->totpoints;

[Bf-blender-cvs] [f8c21937d2b] master: GPencil: Add skip option to envelope modifier

2022-04-07 Thread Henrik Dick
Commit: f8c21937d2ba1140533c5e6f70426099f9680609
Author: Henrik Dick
Date:   Thu Apr 7 17:41:49 2022 +0200
Branches: master
https://developer.blender.org/rBf8c21937d2ba1140533c5e6f70426099f9680609

GPencil: Add skip option to envelope modifier

This patch adds an option to only use every n-th segment of the
envelope result. This can be used to reduce the complexity of the
result.

Differential Revision: http://developer.blender.org/D14503

===

M   source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
M   source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
index f8ac8d95493..d9881f5b7ae 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
@@ -332,18 +332,17 @@ static void add_stroke(Object *ob,
bGPDstroke *gps,
const int point_index,
const int connection_index,
-   const int size,
+   const int size2,
+   const int size1,
const int mat_nr,
const float thickness,
const float strength,
ListBase *results)
 {
+  const int size = size1 + size2;
   bGPdata *gpd = ob->data;
   bGPDstroke *gps_dst = BKE_gpencil_stroke_new(mat_nr, size, gps->thickness);
 
-  const int size1 = size == 4 ? 2 : 1;
-  const int size2 = size - size1;
-
   memcpy(_dst->points[0], >points[connection_index], size1 * 
sizeof(bGPDspoint));
   memcpy(_dst->points[size1], >points[point_index], size2 * 
sizeof(bGPDspoint));
 
@@ -369,35 +368,36 @@ static void add_stroke_cyclic(Object *ob,
   bGPDstroke *gps,
   const int point_index,
   const int connection_index,
+  const int size,
   const int mat_nr,
   const float thickness,
   const float strength,
   ListBase *results)
 {
   bGPdata *gpd = ob->data;
-  bGPDstroke *gps_dst = BKE_gpencil_stroke_new(mat_nr, 4, gps->thickness);
+  bGPDstroke *gps_dst = BKE_gpencil_stroke_new(mat_nr, size * 2, 
gps->thickness);
+  if (gps->dvert != NULL) {
+gps_dst->dvert = MEM_malloc_arrayN(size * 2, sizeof(MDeformVert), 
__func__);
+  }
 
-  int connection_index2 = (connection_index + 1) % gps->totpoints;
-  int point_index2 = (point_index + 1) % gps->totpoints;
+  for (int i = 0; i < size; i++) {
+int a = (connection_index + i) % gps->totpoints;
+int b = (point_index + i) % gps->totpoints;
 
-  gps_dst->points[0] = gps->points[connection_index];
-  gps_dst->points[1] = gps->points[connection_index2];
-  gps_dst->points[2] = gps->points[point_index];
-  gps_dst->points[3] = gps->points[point_index2];
-  for (int i = 0; i < 4; i++) {
+gps_dst->points[i] = gps->points[a];
+gps_dst->points[size + i] = gps->points[b];
+
+if (gps->dvert != NULL) {
+  BKE_defvert_array_copy(_dst->dvert[i], >dvert[a], 1);
+  BKE_defvert_array_copy(_dst->dvert[size + i], >dvert[b], 1);
+}
+  }
+  for (int i = 0; i < size * 2; i++) {
 gps_dst->points[i].pressure *= thickness;
 gps_dst->points[i].strength *= strength;
 memset(_dst->points[i].runtime, 0, sizeof(bGPDspoint_Runtime));
   }
 
-  if (gps->dvert != NULL) {
-gps_dst->dvert = MEM_malloc_arrayN(4, sizeof(MDeformVert), __func__);
-BKE_defvert_array_copy(_dst->dvert[0], >dvert[connection_index], 
1);
-BKE_defvert_array_copy(_dst->dvert[1], >dvert[connection_index2], 
1);
-BKE_defvert_array_copy(_dst->dvert[2], >dvert[point_index], 1);
-BKE_defvert_array_copy(_dst->dvert[3], >dvert[point_index2], 1);
-  }
-
   BLI_addtail(results, gps_dst);
 
   /* Calc geometry data. */
@@ -459,31 +459,41 @@ static void generate_geometry(GpencilModifierData *md, 
Object *ob, bGPDlayer *gp
 
 const int mat_nr = mmd->mat_nr < 0 ? gps->mat_nr : min_ii(mmd->mat_nr, 
ob->totcol - 1);
 if (mmd->mode == GP_ENVELOPE_FILLS) {
+  const int skip = min_ii(mmd->skip, min_ii(mmd->spread / 2, 
gps->totpoints - 2));
   if (gps->flag & GP_STROKE_CYCLIC) {
 for (int i = 0; i < gps->totpoints; i++) {
-  const int connection_index = (i + mmd->spread) % gps->totpoints;
- 

[Bf-blender-cvs] [0e0977f3e68] master: GPencil: Fix sculpt mask ignoring one point strokes

2022-03-29 Thread Henrik Dick
Commit: 0e0977f3e68b2ac1fd021b5dc6ca10e5b9a25da1
Author: Henrik Dick
Date:   Tue Mar 29 16:22:52 2022 +0200
Branches: master
https://developer.blender.org/rB0e0977f3e68b2ac1fd021b5dc6ca10e5b9a25da1

GPencil: Fix sculpt mask ignoring one point strokes

The check for the selected status was missing in the case
where the stroke one has one point.

Differential Revision: http://developer.blender.org/D14490

===

M   source/blender/editors/gpencil/gpencil_sculpt_paint.c

===

diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c 
b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 1e7159392e2..7de579993c1 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -1442,20 +1442,22 @@ static bool 
gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso,
   if (gps->totpoints == 1) {
 bGPDspoint pt_temp;
 pt = >points[0];
-gpencil_point_to_parent_space(gps->points, diff_mat, _temp);
-gpencil_point_to_xy(gsc, gps, _temp, [0], [1]);
-
-pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
-/* Do bound-box check first. */
-if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, 
pc1[0], pc1[1])) {
-  /* only check if point is inside */
-  int mval_i[2];
-  round_v2i_v2fl(mval_i, gso->mval);
-  if (len_v2v2_int(mval_i, pc1) <= radius) {
-/* apply operation to this point */
-if (pt_active != NULL) {
-  rot_eval = gpencil_sculpt_rotation_eval_get(gso, gps, pt, 0);
-  changed = apply(gso, gps_active, rot_eval, 0, radius, pc1);
+if (GPENCIL_ANY_SCULPT_MASK(gso->mask) && (pt->flag & GP_SPOINT_SELECT) != 
0) {
+  gpencil_point_to_parent_space(gps->points, diff_mat, _temp);
+  gpencil_point_to_xy(gsc, gps, _temp, [0], [1]);
+
+  pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
+  /* Do bound-box check first. */
+  if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, 
pc1[0], pc1[1])) {
+/* only check if point is inside */
+int mval_i[2];
+round_v2i_v2fl(mval_i, gso->mval);
+if (len_v2v2_int(mval_i, pc1) <= radius) {
+  /* apply operation to this point */
+  if (pt_active != NULL) {
+rot_eval = gpencil_sculpt_rotation_eval_get(gso, gps, pt, 0);
+changed = apply(gso, gps_active, rot_eval, 0, radius, pc1);
+  }
 }
   }
 }

___
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] [d4e1458db3a] master: GPencil: Improve smooth operation

2022-03-25 Thread Henrik Dick
Commit: d4e1458db3a0e0eaf80219dc8e6d10cb27620793
Author: Henrik Dick
Date:   Fri Mar 25 11:51:45 2022 +0100
Branches: master
https://developer.blender.org/rBd4e1458db3a0e0eaf80219dc8e6d10cb27620793

GPencil: Improve smooth operation

This patch makes the grease pencil smooth operation symmetric.
It also increases the performance a lot if strong smoothing is
required. Additionally there is an option for the position smooth
operation to keep the shape closer to the original for more iterations.

Since the result differs from the previous algorithm, versioning is used
to change the iterations and factor to match the old result.

Differential Revision: http://developer.blender.org/D14325

===

M   source/blender/blenkernel/BKE_gpencil_geom.h
M   source/blender/blenkernel/intern/gpencil_geom.cc
M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/editors/gpencil/gpencil_edit.c
M   source/blender/editors/gpencil/gpencil_fill.c
M   source/blender/editors/gpencil/gpencil_interpolate.c
M   source/blender/editors/gpencil/gpencil_paint.c
M   source/blender/editors/gpencil/gpencil_sculpt_paint.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
M   source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesrna/intern/rna_brush.c
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h 
b/source/blender/blenkernel/BKE_gpencil_geom.h
index 4127030e96f..ad3b1971ca9 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -220,30 +220,78 @@ bool BKE_gpencil_stroke_sample(struct bGPdata *gpd,
  * \param gps: Stroke to smooth
  * \param i: Point index
  * \param inf: Amount of smoothing to apply
+ * \param iterations: Radius of points to consider, equivalent to iterations
  * \param smooth_caps: Apply smooth to stroke extremes
+ * \param keep_shape: Smooth out fine details first
+ * \param r_gps: Stroke to put the result into
  */
-bool BKE_gpencil_stroke_smooth_point(struct bGPDstroke *gps, int i, float inf, 
bool smooth_caps);
+bool BKE_gpencil_stroke_smooth_point(struct bGPDstroke *gps,
+ int point_index,
+ float influence,
+ int iterations,
+ bool smooth_caps,
+ bool keep_shape,
+ struct bGPDstroke *r_gps);
 /**
  * Apply smooth strength to stroke point.
  * \param gps: Stroke to smooth
  * \param point_index: Point index
  * \param influence: Amount of smoothing to apply
+ * \param iterations: Radius of points to consider, equivalent to iterations
+ * \param r_gps: Stroke to put the result into
  */
-bool BKE_gpencil_stroke_smooth_strength(struct bGPDstroke *gps, int 
point_index, float influence);
+bool BKE_gpencil_stroke_smooth_strength(struct bGPDstroke *gps,
+int point_index,
+float influence,
+int iterations,
+struct bGPDstroke *r_gps);
 /**
  * Apply smooth for thickness to stroke point (use pressure).
  * \param gps: Stroke to smooth
  * \param point_index: Point index
  * \param influence: Amount of smoothing to apply
+ * \param iterations: Radius of points to consider, equivalent to iterations
+ * \param r_gps: Stroke to put the result into
  */
-bool BKE_gpencil_stroke_smooth_thickness(struct bGPDstroke *gps, int 
point_index, float influence);
+bool BKE_gpencil_stroke_smooth_thickness(struct bGPDstroke *gps,
+ int point_index,
+ float influence,
+ int iterations,
+ struct bGPDstroke *r_gps);
 /**
- * Apply smooth for UV rotation to stroke point (use pressure).
+ * Apply smooth for UV rotation/factor to stroke point.
  * \param gps: Stroke to smooth
  * \param point_index: Point index
  * \param influence: Amount of smoothing to apply
+ * \param iterations: Radius of points to consider, equivalent to iterations
+ * \param r_gps: Stroke to put the result into
  */
-bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, int point_index, 
float influence);
+bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps,
+  int point_index,
+  float influence,
+  int iterations,
+  struct

[Bf-blender-cvs] [cee6af00567] master: GPencil: New Envelope Modifier

2022-03-24 Thread Henrik Dick
Commit: cee6af00567f454983d0bd3f6508e0213c91fb1c
Author: Henrik Dick
Date:   Thu Mar 24 13:01:46 2022 +0100
Branches: master
https://developer.blender.org/rBcee6af00567f454983d0bd3f6508e0213c91fb1c

GPencil: New Envelope Modifier

This new modifier creates a shape known as envelope. It connects all
points that are n points apart. There is also a mode which fits a
single stroke to the envelope shape that is determined by that rule.

For more details, refer to the patch.

Reviewed By: NicksBest, antoniov, frogstomp, mendio

Differential Revision: http://developer.blender.org/D14341

===

M   source/blender/gpencil_modifiers/CMakeLists.txt
M   source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
M   source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
A   source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
M   source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesdna/intern/dna_defaults.c
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt 
b/source/blender/gpencil_modifiers/CMakeLists.txt
index 752d4aea61c..6108629183c 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -37,6 +37,7 @@ set(SRC
   intern/MOD_gpencilbuild.c
   intern/MOD_gpencilcolor.c
   intern/MOD_gpencildash.c
+  intern/MOD_gpencilenvelope.c
   intern/MOD_gpencilhook.c
   intern/MOD_gpencillattice.c
   intern/MOD_gpencillength.c
diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h 
b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
index ff280b9ca0d..e88d864a86e 100644
--- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
+++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
@@ -35,6 +35,7 @@ extern GpencilModifierTypeInfo 
modifierType_Gpencil_WeightAngle;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Lineart;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Dash;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Shrinkwrap;
+extern GpencilModifierTypeInfo modifierType_Gpencil_Envelope;
 
 /* MOD_gpencil_util.c */
 void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index e766615101a..6cf7f6f11e5 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -56,6 +56,7 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo 
*types[])
   INIT_GP_TYPE(Lineart);
   INIT_GP_TYPE(Dash);
   INIT_GP_TYPE(Shrinkwrap);
+  INIT_GP_TYPE(Envelope);
 #undef INIT_GP_TYPE
 }
 
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
new file mode 100644
index 000..0f736cac464
--- /dev/null
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
@@ -0,0 +1,629 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2017 Blender Foundation. */
+
+/** \file
+ * \ingroup modifiers
+ */
+
+#include 
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_math_geom.h"
+#include "BLI_utildefines.h"
+
+#include "BLT_translation.h"
+
+#include "DNA_defaults.h"
+#include "DNA_gpencil_modifier_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+
+#include "BKE_colortools.h"
+#include "BKE_context.h"
+#include "BKE_deform.h"
+#include "BKE_gpencil.h"
+#include "BKE_gpencil_geom.h"
+#include "BKE_gpencil_modifier.h"
+#include "BKE_lib_query.h"
+#include "BKE_modifier.h"
+#include "BKE_screen.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "RNA_access.h"
+
+#include "MOD_gpencil_modifiertypes.h"
+#include "MOD_gpencil_ui_common.h"
+#include "MOD_gpencil_util.h"
+
+#include "MEM_guardedalloc.h"
+
+static void initData(GpencilModifierData *md)
+{
+  EnvelopeGpencilModifierData *gpmd = (EnvelopeGpencilModifierData *)md;
+
+  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+  MEMCPY_STRUCT_AFTER(gpmd, 
DNA_struct_default_get(EnvelopeGpencilModifierData), modifier);
+}
+
+static void copyData(const GpencilModi

[Bf-blender-cvs] [dd161ff7a40] master: Complex Solidify: handle vertex creases

2022-03-24 Thread Henrik Dick
Commit: dd161ff7a40c721c16bf43c34e172c9fcf9cddf7
Author: Henrik Dick
Date:   Thu Mar 24 12:30:48 2022 +0100
Branches: master
https://developer.blender.org/rBdd161ff7a40c721c16bf43c34e172c9fcf9cddf7

Complex Solidify: handle vertex creases

This implements the same interpolation method as for bevel weights
now for vertex and edge creases as well to improve the flexibility.

Differential Revision: http://developer.blender.org/D14170

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index ff25c1afd49..7c1cf326c60 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1982,6 +1982,18 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 result->dvert = dvert;
   }
 
+  /* Get vertex crease layer and ensure edge creases are active if vertex 
creases are found, since
+   * they will introduce edge creases in the used custom interpolation method. 
*/
+  const float *vertex_crease = CustomData_get_layer(>vdata, CD_CREASE);
+  if (vertex_crease) {
+result->cd_flag |= ME_CDFLAG_EDGE_CREASE;
+/* delete all vertex creases in the result if a rim is used. */
+if (do_rim) {
+  CustomData_free_layers(>vdata, CD_CREASE, result->totvert);
+  result->cd_flag &= ~ME_CDFLAG_VERT_CREASE;
+}
+  }
+
   /* Make_new_verts. */
   {
 gs_ptr = orig_vert_groups_arr;
@@ -2105,6 +2117,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 EdgeGroup *g2 = gs;
 EdgeGroup *last_g = NULL;
 EdgeGroup *first_g = NULL;
+char mv_crease = vertex_crease ? (char)(vertex_crease[i] * 255.0f) : 0;
 /* Data calculation cache. */
 char max_crease;
 char last_max_crease = 0;
@@ -2174,7 +2187,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
   medge[edge_index].v2 = g->new_vert;
   medge[edge_index].flag = ME_EDGEDRAW | ME_EDGERENDER |
((last_flag | flag) & (ME_SEAM | 
ME_SHARP));
-  medge[edge_index].crease = min_cc(last_max_crease, max_crease);
+  medge[edge_index].crease = max_cc(mv_crease, 
min_cc(last_max_crease, max_crease));
   medge[edge_index++].bweight = max_cc(mv->bweight,
min_cc(last_max_bweight, 
max_bweight));
 }
@@ -2202,7 +2215,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
   medge[edge_index].v2 = first_g->new_vert;
   medge[edge_index].flag = ME_EDGEDRAW | ME_EDGERENDER |
((last_flag | first_flag) & (ME_SEAM | 
ME_SHARP));
-  medge[edge_index].crease = min_cc(last_max_crease, 
first_max_crease);
+  medge[edge_index].crease = max_cc(mv_crease,
+min_cc(last_max_crease, 
first_max_crease));
   medge[edge_index++].bweight = max_cc(mv->bweight,
min_cc(last_max_bweight, 
first_max_bweight));

___
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] [acd7a648b17] master: GPencil: Add Scale Thickness to Pivot Point Pie Menu similar to Only Locations

2022-03-24 Thread Henrik Dick
Commit: acd7a648b17acd6514eae6302c9a8c56346b44a1
Author: Henrik Dick
Date:   Thu Mar 24 11:22:10 2022 +0100
Branches: master
https://developer.blender.org/rBacd7a648b17acd6514eae6302c9a8c56346b44a1

GPencil: Add Scale Thickness to Pivot Point Pie Menu similar to Only Locations

In my opinion Scale Thickness feels similar to Only Locations and was missing 
from the pie menu in grease pencil edit mode, so here I added it.

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

===

M   release/scripts/startup/bl_ui/space_view3d.py

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index b9415d00871..f40d96e30a0 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5297,6 +5297,8 @@ class VIEW3D_MT_pivot_pie(Menu):
 pie.prop_enum(context.scene.tool_settings, "transform_pivot_point", 
value='ACTIVE_ELEMENT')
 if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
 pie.prop(context.scene.tool_settings, 
"use_transform_pivot_point_align")
+if mode in {'EDIT_GPENCIL'}:
+pie.prop(context.scene.tool_settings.gpencil_sculpt, 
"use_scale_thickness")
 
 
 class VIEW3D_MT_orientations_pie(Menu):

___
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] [8d4244691a2] master: GPencil: lower bounds for gap in dot dash modifier

2022-03-24 Thread Henrik Dick
Commit: 8d4244691a2d54fb746f253633f546d85a16a014
Author: Henrik Dick
Date:   Thu Mar 24 10:51:14 2022 +0100
Branches: master
https://developer.blender.org/rB8d4244691a2d54fb746f253633f546d85a16a014

GPencil: lower bounds for gap in dot dash modifier

This patch maximizes the possible bounds for the dash and
gap parameters in the dot dash modifier. This makes e.g.
chopping up lines without gaps possible.

Differential Revision: http://developer.blender.org/D14428

===

M   source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
index 439073752da..25c7fdca9f6 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
@@ -97,12 +97,13 @@ static bool stroke_dash(const bGPDstroke *gps,
   int new_stroke_offset = 0;
   int trim_start = 0;
 
+  int sequence_length = 0;
   for (int i = 0; i < dmd->segments_len; i++) {
-if (dmd->segments[i].dash + real_gap(>segments[i]) < 1) {
-  BLI_assert_unreachable();
-  /* This means there's a part that doesn't have any length, can't do 
dot-dash. */
-  return false;
-}
+sequence_length += dmd->segments[i].dash + real_gap(>segments[i]);
+  }
+  if (sequence_length < 1) {
+/* This means the whole segment has no length, can't do dot-dash. */
+return false;
   }
 
   const DashGpencilModifierSegment *const first_segment = >segments[0];
@@ -204,9 +205,10 @@ static void apply_dash_for_frame(
dmd->flag & GP_LENGTH_INVERT_PASS,
dmd->flag & GP_LENGTH_INVERT_LAYERPASS,
dmd->flag & GP_LENGTH_INVERT_MATERIAL)) 
{
-  stroke_dash(gps, dmd, );
-  BLI_remlink(>strokes, gps);
-  BKE_gpencil_free_stroke(gps);
+  if (stroke_dash(gps, dmd, )) {
+BLI_remlink(>strokes, gps);
+BKE_gpencil_free_stroke(gps);
+  }
 }
   }
   bGPDstroke *gps_dash;
@@ -232,6 +234,18 @@ static void bakeModifier(Main *UNUSED(bmain),
 
 /*  */
 
+static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams))
+{
+  DashGpencilModifierData *dmd = (DashGpencilModifierData *)md;
+
+  int sequence_length = 0;
+  for (int i = 0; i < dmd->segments_len; i++) {
+sequence_length += dmd->segments[i].dash + real_gap(>segments[i]);
+  }
+  /* This means the whole segment has no length, can't do dot-dash. */
+  return sequence_length < 1;
+}
+
 /* Generic "generateStrokes" callback */
 static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, 
Object *ob)
 {
@@ -362,7 +376,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Dash = {
 
 /* initData */ initData,
 /* freeData */ freeData,
-/* isDisabled */ NULL,
+/* isDisabled */ isDisabled,
 /* updateDepsgraph */ NULL,
 /* dependsOnTime */ NULL,
 /* foreachIDLink */ foreachIDLink,
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c 
b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 33c0b29f6d0..fbc622a73a8 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -3676,7 +3676,7 @@ static void rna_def_modifier_gpencildash(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "gap", PROP_INT, PROP_NONE);
-  RNA_def_property_range(prop, 1, INT16_MAX);
+  RNA_def_property_range(prop, 0, INT16_MAX);
   RNA_def_property_ui_text(prop, "Gap", "The number of points skipped after 
this segment");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");

___
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] [236ef11a074] master: GPencil: Fix cyclic flag cleared by simplify modifier

2022-03-17 Thread Henrik Dick
Commit: 236ef11a0746a572e29e75fd1095d9621b567b41
Author: Henrik Dick
Date:   Thu Mar 17 14:09:29 2022 +0100
Branches: master
https://developer.blender.org/rB236ef11a0746a572e29e75fd1095d9621b567b41

GPencil: Fix cyclic flag cleared by simplify modifier

Change the sample mode to don't duplicate the last vertex of the
stroke and instead use the cyclic flag to close previously cyclic
strokes. This is necessary for the following modifiers.

Reviewed By: NicksBest

Differential Revision: http://developer.blender.org/D14359

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc 
b/source/blender/blenkernel/intern/gpencil_geom.cc
index e4ed2a40f10..a5eff1f9d5a 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -451,6 +451,10 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
   }
   /* TODO: Implement feature point preservation. */
   int count = stroke_march_count(gps, dist, sharp_threshold);
+  const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
+  if (is_cyclic) {
+count--;
+  }
 
   bGPDspoint *new_pt = (bGPDspoint *)MEM_callocN(sizeof(bGPDspoint) * count,
  "gp_stroke_points_sampled");
@@ -499,6 +503,9 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
  _result,
  _from,
  _to)) > -1) {
+if (is_cyclic && next_point_index == 0) {
+  break; /* last point finished */
+}
 pt2 = _pt[i];
 copy_v3_v3(>x, last_coord);
 new_pt[i].pressure = pressure;
@@ -533,10 +540,9 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
 gps->dvert = new_dv;
   }
 
+  BLI_assert(i == count);
   gps->totpoints = i;
 
-  gps->flag &= (~GP_STROKE_CYCLIC);
-
   /* Calc geometry data. */
   BKE_gpencil_stroke_geometry_update(gpd, gps);

___
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] [4045b3d7b68] master: GPencil: Fix offset modifier negative scale thickness

2022-03-14 Thread Henrik Dick
Commit: 4045b3d7b685aeeb6003d3f90b4a41f6337b6159
Author: Henrik Dick
Date:   Mon Mar 14 11:11:22 2022 +0100
Branches: master
https://developer.blender.org/rB4045b3d7b685aeeb6003d3f90b4a41f6337b6159

GPencil: Fix offset modifier negative scale thickness

If the scale in the offset modifier was set to a value lower than -1,
the object would get mirrored. The problem was, that the thickness
was set to 0 by that. This fix makes the thickness calculation only
use the absolute values.

Differential Revision: http://developer.blender.org/D14324

===

M   source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
index 3aaa032ef70..95c3f2c161f 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
@@ -152,7 +152,7 @@ static void deformStroke(GpencilModifierData *md,
 loc_eul_size_to_mat4(mat, loc, rot, scale);
 
 /* Apply scale to thickness. */
-float unit_scale = (scale[0] + scale[1] + scale[2]) / 3.0f;
+float unit_scale = (fabsf(scale[0]) + fabsf(scale[1]) + fabsf(scale[2])) / 
3.0f;
 pt->pressure *= unit_scale;
 
 mul_m4_v3(mat, >x);

___
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] [a6b5d5bfe83] master: GPencil: Simplify modifier minimal vert count fix

2022-03-13 Thread Henrik Dick
Commit: a6b5d5bfe83e9d692a268cfbc979df8906391e34
Author: Henrik Dick
Date:   Sun Mar 13 17:21:30 2022 +0100
Branches: master
https://developer.blender.org/rBa6b5d5bfe83e9d692a268cfbc979df8906391e34

GPencil: Simplify modifier minimal vert count fix

Lower the minimal vert count for all simplify modes.

Differential Revision: http://developer.blender.org/D14319

===

M   source/blender/blenkernel/intern/gpencil_geom.cc
M   source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c

===

diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc 
b/source/blender/blenkernel/intern/gpencil_geom.cc
index 2160d567db5..e4ed2a40f10 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -2032,7 +2032,7 @@ void BKE_gpencil_stroke_simplify_adaptive(bGPdata *gpd, 
bGPDstroke *gps, float e
 
 void BKE_gpencil_stroke_simplify_fixed(bGPdata *gpd, bGPDstroke *gps)
 {
-  if (gps->totpoints < 5) {
+  if (gps->totpoints < 4) {
 return;
   }
 
@@ -2047,7 +2047,7 @@ void BKE_gpencil_stroke_simplify_fixed(bGPdata *gpd, 
bGPDstroke *gps)
 
   /* resize gps */
   int newtot = (gps->totpoints - 2) / 2;
-  if (((gps->totpoints - 2) % 2) > 0) {
+  if ((gps->totpoints % 2) != 0) {
 newtot++;
   }
   newtot += 2;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
index 365b9afe348..f94b5d05291 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
@@ -64,7 +64,7 @@ static void deformStroke(GpencilModifierData *md,
   mmd->material,
   mmd->pass_index,
   mmd->layer_pass,
-  mmd->mode == GP_SIMPLIFY_SAMPLE ? 2 : 4,
+  mmd->mode == GP_SIMPLIFY_SAMPLE ? 2 : 3,
   gpl,
   gps,
   mmd->flag & GP_SIMPLIFY_INVERT_LAYER,

___
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] [c2e8e68b651] master: Fix T95963: change thresholds in complex solidify

2022-03-02 Thread Henrik Dick
Commit: c2e8e68b6517b91eb14270707d7182c1727861c4
Author: Henrik Dick
Date:   Wed Mar 2 12:14:22 2022 +0100
Branches: master
https://developer.blender.org/rBc2e8e68b6517b91eb14270707d7182c1727861c4

Fix T95963: change thresholds in complex solidify

This fix contains two parts. There was one critical mistake where
order of two indices was wrong when removing constraint planes from
the array. The other changes are improvements to the used thresholds
to keep everything numerically stable.

Differential Revision: http://developer.blender.org/D14183

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index e4f7a7b5473..ff25c1afd49 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1468,10 +1468,10 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 for (uint k = 0; k < queue_index; k++) {
   for (uint m = k + 1; m < queue_index; m++) {
 float p = dot_v3v3(planes_queue[k], planes_queue[m]);
-if (p <= min_p + FLT_EPSILON) {
+if (p < min_p) {
   min_p = p;
-  min_n0 = m;
-  min_n1 = k;
+  min_n0 = k;
+  min_n1 = m;
 }
   }
 }
@@ -1484,18 +1484,13 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
   swap_v4_v4(planes_queue[min_n0], planes_queue[1]);
 }
 /* Find the third most important/different normal. */
-min_p = 1;
-min_n1 = 0;
-float max_p = -1;
+min_p = 1.0f;
+min_n1 = 2;
+float max_p = -1.0f;
 for (uint k = 2; k < queue_index; k++) {
-  max_p = -1;
-  for (uint m = 0; m < 2; m++) {
-float p = dot_v3v3(planes_queue[m], planes_queue[k]);
-if (p > max_p + FLT_EPSILON) {
-  max_p = p;
-}
-  }
-  if (max_p <= min_p + FLT_EPSILON) {
+  max_p = max_ff(dot_v3v3(planes_queue[0], planes_queue[k]),
+ dot_v3v3(planes_queue[1], planes_queue[k]));
+  if (max_p <= min_p) {
 min_p = max_p;
 min_n1 = k;
   }
@@ -1503,7 +1498,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 swap_v4_v4(planes_queue[min_n1], planes_queue[2]);
   }
   /* Remove/average duplicate normals in planes_queue. */
-  while (queue_index > 0) {
+  while (queue_index > 2) {
 uint best_n0 = 0;
 uint best_n1 = 0;
 float best_p = -1.0f;
@@ -1515,12 +1510,14 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 if (p > best_p + FLT_EPSILON || (p >= best_p && ofs_diff < 
best_ofs_diff)) {
   best_p = p;
   best_ofs_diff = ofs_diff;
-  best_n0 = m;
-  best_n1 = k;
+  best_n0 = k;
+  best_n1 = m;
 }
   }
 }
-if (best_p < 0.999f) {
+/* Make sure there are no equal planes. This threshold is 
crucial for the
+ * methods below to work without numerical issues. */
+if (best_p < 0.98f) {
   break;
 }
 add_v3_v3(planes_queue[best_n0], planes_queue[best_n1]);
@@ -1549,6 +1546,10 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
   for (int m = 0; m < size; m++) {
 madd_v3_v3fl(mat[k], planes_queue[m], planes_queue[m][k]);
   }
+  /* Add a small epsilon to ensure the invert is going to work.
+   * This addition makes the inverse more stable and the 
results
+   * seem to get more precise. */
+  mat[k][k] += 5e-5f;
 }
 /* NOTE: this matrix invert fails if there is less than 3 
different normals. */
 invert_m3(mat);
@@ -1597,7 +1598,9 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 add_v3_v3v3(nor, planes_queue[0], planes_queue[1]);
 if (size == 3) {
   d = dot_v3v3(planes_queue[2], move

[Bf-blender-cvs] [6498688e274] master: GPencil: Improve subdivision modifier

2022-03-01 Thread Henrik Dick
Commit: 6498688e274836a66d9075edfe79fd3572334427
Author: Henrik Dick
Date:   Tue Mar 1 19:32:02 2022 +0100
Branches: master
https://developer.blender.org/rB6498688e274836a66d9075edfe79fd3572334427

GPencil: Improve subdivision modifier

The subdivision modifier for Grease Pencil handles closed strokes
correctly now and does converge to the same shape as the mesh
subdivision surface.

Differential Revision: http://developer.blender.org/D14218

===

M   source/blender/blenkernel/intern/gpencil_geom.cc
M   source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c

===

diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc 
b/source/blender/blenkernel/intern/gpencil_geom.cc
index 1823d84d48d..865bcebee25 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -2098,27 +2098,30 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, 
bGPDstroke *gps, int level, int
   MDeformVert *dvert_final = nullptr;
   MDeformVert *dvert_next = nullptr;
   int totnewpoints, oldtotpoints;
-  int i2;
+
+  bool cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
 
   for (int s = 0; s < level; s++) {
-totnewpoints = gps->totpoints - 1;
+totnewpoints = gps->totpoints;
+if (!cyclic) {
+  totnewpoints--;
+}
 /* duplicate points in a temp area */
-temp_points = (bGPDspoint *)MEM_dupallocN(gps->points);
+temp_points = gps->points;
 oldtotpoints = gps->totpoints;
 
 /* resize the points arrays */
 gps->totpoints += totnewpoints;
-gps->points = (bGPDspoint *)MEM_recallocN(gps->points, 
sizeof(*gps->points) * gps->totpoints);
+gps->points = (bGPDspoint *)MEM_malloc_arrayN(gps->totpoints, 
sizeof(*gps->points), __func__);
 if (gps->dvert != nullptr) {
-  temp_dverts = (MDeformVert *)MEM_dupallocN(gps->dvert);
-  gps->dvert = (MDeformVert *)MEM_recallocN(gps->dvert, 
sizeof(*gps->dvert) * gps->totpoints);
+  temp_dverts = gps->dvert;
+  gps->dvert = (MDeformVert *)MEM_malloc_arrayN(gps->totpoints, 
sizeof(*gps->dvert), __func__);
 }
 
 /* move points from last to first to new place */
-i2 = gps->totpoints - 1;
-for (int i = oldtotpoints - 1; i > 0; i--) {
+for (int i = 0; i < oldtotpoints; i++) {
   bGPDspoint *pt = _points[i];
-  bGPDspoint *pt_final = >points[i2];
+  bGPDspoint *pt_final = >points[i * 2];
 
   copy_v3_v3(_final->x, >x);
   pt_final->pressure = pt->pressure;
@@ -2131,18 +2134,16 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, 
bGPDstroke *gps, int level, int
 
   if (gps->dvert != nullptr) {
 dvert = _dverts[i];
-dvert_final = >dvert[i2];
+dvert_final = >dvert[i * 2];
 dvert_final->totweight = dvert->totweight;
 dvert_final->dw = dvert->dw;
   }
-  i2 -= 2;
 }
 /* interpolate mid points */
-i2 = 1;
-for (int i = 0; i < oldtotpoints - 1; i++) {
-  bGPDspoint *pt = _points[i];
-  bGPDspoint *next = _points[i + 1];
-  bGPDspoint *pt_final = >points[i2];
+for (int i = cyclic ? 0 : 1, j = cyclic ? oldtotpoints - 1 : 0; i < 
oldtotpoints; j = i, i++) {
+  bGPDspoint *pt = _points[j];
+  bGPDspoint *next = _points[i];
+  bGPDspoint *pt_final = >points[j * 2 + 1];
 
   /* add a half way point */
   interp_v3_v3v3(_final->x, >x, >x, 0.5f);
@@ -2155,9 +2156,9 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, 
bGPDstroke *gps, int level, int
   interp_v4_v4v4(pt_final->vert_color, pt->vert_color, next->vert_color, 
0.5f);
 
   if (gps->dvert != nullptr) {
-dvert = _dverts[i];
-dvert_next = _dverts[i + 1];
-dvert_final = >dvert[i2];
+dvert = _dverts[j];
+dvert_next = _dverts[i];
+dvert_final = >dvert[j * 2 + 1];
 
 dvert_final->totweight = dvert->totweight;
 dvert_final->dw = (MDeformWeight *)MEM_dupallocN(dvert->dw);
@@ -2172,8 +2173,6 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, 
bGPDstroke *gps, int level, int
   }
 }
   }
-
-  i2 += 2;
 }
 
 MEM_SAFE_FREE(temp_points);
@@ -2181,20 +2180,18 @@ void BKE_gpencil_stroke_subdivide(bGPdata *gpd, 
bGPDstroke *gps, int level, int
 
 /* Move points to smooth stroke (not simple type). */
 if (type != GP_SUBDIV_SIMPLE) {
-  /* duplicate points in a temp area with the new subdivide data */
-  temp_points = (bGPDspoint *)MEM_dupallocN(gps->points);
-
+  float mid[3];
   /* extreme points are not changed */
-  for (int i = 0; i < gps->totpoints - 2; i++) {
-bGPDspoint *pt = _points[i];
-bGPDspoint *next = _points[i + 1];
-bGPDspoint *pt

[Bf-blender-cvs] [8c932ab43c2] master: Fix T96032: add null check to constraint operators

2022-02-28 Thread Henrik Dick
Commit: 8c932ab43c28d476bd0bf671ef70448f075295ef
Author: Henrik Dick
Date:   Mon Feb 28 18:26:58 2022 +0100
Branches: master
https://developer.blender.org/rB8c932ab43c28d476bd0bf671ef70448f075295ef

Fix T96032: add null check to constraint operators

The constraint operators for delete, apply, copy and copy to selected
were missing null checks and could crash blender when called wrongly
from the python api.

Differential Revision: http://developer.blender.org/D14195

===

M   source/blender/editors/object/object_constraint.c

===

diff --git a/source/blender/editors/object/object_constraint.c 
b/source/blender/editors/object/object_constraint.c
index d717271b9cb..3f4ed27a175 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1443,6 +1443,11 @@ static int constraint_delete_exec(bContext *C, 
wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Object *ob = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, ob, 0);
+
+  if (con == NULL) {
+return OPERATOR_CANCELLED;
+  }
+
   ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL);
 
   /* Store name temporarily for report. */
@@ -1510,6 +1515,11 @@ static int constraint_apply_exec(bContext *C, wmOperator 
*op)
   Main *bmain = CTX_data_main(C);
   Object *ob = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, ob, 0);
+
+  if (con == NULL) {
+return OPERATOR_CANCELLED;
+  }
+
   bPoseChannel *pchan;
   ListBase *constraints = ED_object_constraint_list_from_constraint(ob, con, 
);
 
@@ -1602,6 +1612,11 @@ static int constraint_copy_exec(bContext *C, wmOperator 
*op)
   Main *bmain = CTX_data_main(C);
   Object *ob = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, ob, 0);
+
+  if (con == NULL) {
+return OPERATOR_CANCELLED;
+  }
+
   bPoseChannel *pchan;
   ListBase *constraints = ED_object_constraint_list_from_constraint(ob, con, 
);
 
@@ -1682,6 +1697,11 @@ static int constraint_copy_to_selected_exec(bContext *C, 
wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Object *obact = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, obact, 0);
+
+  if (con == NULL) {
+return OPERATOR_CANCELLED;
+  }
+
   bPoseChannel *pchan;
   ED_object_constraint_list_from_constraint(obact, con, );

___
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] [68586d2c183] master: Complex Solidify: improve constraints solver

2022-02-21 Thread Henrik Dick
Commit: 68586d2c183bb36464d8de4c50b1c23c47631a83
Author: Henrik Dick
Date:   Mon Feb 21 14:05:00 2022 +0100
Branches: master
https://developer.blender.org/rB68586d2c183bb36464d8de4c50b1c23c47631a83

Complex Solidify: improve constraints solver

The constraints solver is now able to handle more cases correctly.
Also the behavior of the boundary fixes is slightly changed if
the constraints thickness mode is used.

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

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index ed7acef4cdc..e4f7a7b5473 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1405,21 +1405,26 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 for (uint j = 0; g->valid; j++, g++) {
   if (!g->is_singularity) {
 float *nor = g->no;
+/* During vertex position calculation, the algorithm decides if it 
wants to disable the
+ * boundary fix to maintain correct thickness. If the used 
algorithm does not produce a
+ * free move direction (move_nor), it can use 
approximate_free_direction to decide on
+ * a movement direction based on the connected edges. */
 float move_nor[3] = {0, 0, 0};
 bool disable_boundary_fix = (smd->nonmanifold_boundary_mode ==
  
MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_NONE ||
  (g->is_orig_closed || g->split));
+bool approximate_free_direction = false;
 /* Constraints Method. */
 if (smd->nonmanifold_offset_mode == 
MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_CONSTRAINTS) {
   NewEdgeRef *first_edge = NULL;
   NewEdgeRef **edge_ptr = g->edges;
   /* Contains normal and offset [nx, ny, nz, ofs]. */
-  float(*normals_queue)[4] = MEM_malloc_arrayN(
-  g->edges_len + 1, sizeof(*normals_queue), "normals_queue in 
solidify");
+  float(*planes_queue)[4] = MEM_malloc_arrayN(
+  g->edges_len + 1, sizeof(*planes_queue), "planes_queue in 
solidify");
   uint queue_index = 0;
 
-  float face_nors[3][3];
-  float nor_ofs[3];
+  float fallback_nor[3];
+  float fallback_ofs = 0.0f;
 
   const bool cycle = (g->is_orig_closed && !g->split) || 
g->is_even_split;
   for (uint k = 0; k < g->edges_len; k++, edge_ptr++) {
@@ -1436,17 +1441,17 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
   }
 
   if (!null_faces[face->index]) {
-/* And normal to the queue. */
-mul_v3_v3fl(normals_queue[queue_index],
+/* And plane to the queue. */
+mul_v3_v3fl(planes_queue[queue_index],
 poly_nors[face->index],
 face->reversed ? -1 : 1);
-normals_queue[queue_index++][3] = ofs;
+planes_queue[queue_index++][3] = ofs;
   }
   else {
 /* Just use this approximate normal of the null face 
if there is no other
  * normal to use. */
-mul_v3_v3fl(face_nors[0], poly_nors[face->index], 
face->reversed ? -1 : 1);
-nor_ofs[0] = ofs;
+mul_v3_v3fl(fallback_nor, poly_nors[face->index], 
face->reversed ? -1 : 1);
+fallback_ofs = ofs;
   }
 }
   }
@@ -1455,131 +1460,170 @@ Mesh 
*MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
   }
 }
   }
-  uint face_nors_len = 0;
-  const float stop_explosion = 0.999f - fabsf(smd->offset_fac) * 
0.05f;
-  while (queue_index > 0) {
-if (face_nors_len == 0) {
-  if (queue_index <= 2) {
-for (uint k = 0; k < queue_index; k++) {
-  copy_v3_v3(face_nors[k], normals_queue[k]);
-  nor_ofs[k] = normals_queue[k][3];
+  if (queue_index > 2) {
+/* Find the two most different normals. */
+float min_p = 2.0f;
+uint min_n0 = 0;
+uint min_n1 = 0;
+  

[Bf-blender-cvs] [6804ab23811] master: Merge branch 'blender-v3.1-release'

2022-02-10 Thread Henrik Dick
Commit: 6804ab238114e0873c2a06b3865f44490f25de15
Author: Henrik Dick
Date:   Thu Feb 10 22:39:38 2022 +0100
Branches: master
https://developer.blender.org/rB6804ab238114e0873c2a06b3865f44490f25de15

Merge branch 'blender-v3.1-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] [39bac58cdf3] blender-v3.1-release: Fix: Enable edge bevel weight in solidify if needed

2022-02-10 Thread Henrik Dick
Commit: 39bac58cdf3f1db633913ea4838bf223bc15ec3b
Author: Henrik Dick
Date:   Thu Feb 10 22:29:10 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB39bac58cdf3f1db633913ea4838bf223bc15ec3b

Fix: Enable edge bevel weight in solidify if needed

Complex Solidify creates edge bevel weights on the rim if the
according vertex has some vertex bevel weight. If there are no
edge bevel weights, they were left disabled even if vertex bevel
weights are used.

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 1aa52d44509..5f6decdbe80 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1924,7 +1924,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
   int *origindex_edge = CustomData_get_layer(>edata, CD_ORIGINDEX);
   int *origindex_poly = CustomData_get_layer(>pdata, CD_ORIGINDEX);
 
-  if (bevel_convex != 0.0f) {
+  if (bevel_convex != 0.0f || (result->cd_flag & ME_CDFLAG_VERT_BWEIGHT) != 0) 
{
 /* make sure bweight is enabled */
 result->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
   }

___
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] [5cac5a1a690] blender-v3.1-release: Fix: Bevel vertex didn't use weights in some cases

2022-02-10 Thread Henrik Dick
Commit: 5cac5a1a690eb4818344e5d286b014c49b950c72
Author: Henrik Dick
Date:   Thu Feb 10 22:14:02 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB5cac5a1a690eb4818344e5d286b014c49b950c72

Fix: Bevel vertex didn't use weights in some cases

Bevel Vertices did not use vertex/bevel weights if the Width Type
was set to Width or Depth.

===

M   source/blender/bmesh/tools/bmesh_bevel.c

===

diff --git a/source/blender/bmesh/tools/bmesh_bevel.c 
b/source/blender/bmesh/tools/bmesh_bevel.c
index 2f471bf0b81..7933d5ae866 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -6293,10 +6293,10 @@ static BevVert *bevel_vert_construct(BMesh *bm, 
BevelParams *bp, BMVert *v)
   sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
   float z = fabsf(2.0f * sinf(angle_v3v3(vert_axis, edge_dir)));
   if (z < BEVEL_EPSILON) {
-e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so 
tiny bevel. */
+e->offset_l_spec = 0.01f * bv->offset; /* Undefined behavior, so 
tiny bevel. */
   }
   else {
-e->offset_l_spec = bp->offset / z;
+e->offset_l_spec = bv->offset / z;
   }
   break;
 }
@@ -6305,10 +6305,10 @@ static BevVert *bevel_vert_construct(BMesh *bm, 
BevelParams *bp, BMVert *v)
   sub_v3_v3v3(edge_dir, bv->v->co, v2->co);
   float z = fabsf(cosf(angle_v3v3(vert_axis, edge_dir)));
   if (z < BEVEL_EPSILON) {
-e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so 
tiny bevel. */
+e->offset_l_spec = 0.01f * bv->offset; /* Undefined behavior, so 
tiny bevel. */
   }
   else {
-e->offset_l_spec = bp->offset / z;
+e->offset_l_spec = bv->offset / z;
   }
   break;
 }

___
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] [94866ef84f1] master: Fix Bevel intersection continuity.

2022-02-06 Thread Henrik Dick
Commit: 94866ef84f1907116409f8fe9c1f313405d974e8
Author: Henrik Dick
Date:   Sun Feb 6 16:01:57 2022 -0500
Branches: master
https://developer.blender.org/rB94866ef84f1907116409f8fe9c1f313405d974e8

Fix Bevel intersection continuity.

This patch from Henrik Dick improves the continuity between the
grid forming corners and the edge polyons on multisegment bevels.
For details, see patch D13867.

===

M   source/blender/bmesh/tools/bmesh_bevel.c

===

diff --git a/source/blender/bmesh/tools/bmesh_bevel.c 
b/source/blender/bmesh/tools/bmesh_bevel.c
index 2f471bf0b81..55c63a13efb 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -451,6 +451,16 @@ static bool nearly_parallel_normalized(const float d1[3], 
const float d2[3])
   return compare_ff(fabsf(direction_dot), 1.0f, BEVEL_EPSILON_ANG_DOT);
 }
 
+/**
+ * calculate the determinant of a matrix formed by three vectors
+ * \return dot(a, cross(b, c)) = determinant(a, b, c)
+ */
+static float determinant_v3v3v3(const float a[3], const float b[3], const 
float c[3])
+{
+  return a[0] * b[1] * c[2] + a[1] * b[2] * c[0] + a[2] * b[0] * c[1] - a[0] * 
b[2] * c[1] -
+ a[1] * b[0] * c[2] - a[2] * b[1] * c[0];
+}
+
 /* Make a new BoundVert of the given kind, inserting it at the end of the 
circular linked
  * list with entry point bv->boundstart, and return it. */
 static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const 
float co[3])
@@ -4118,44 +4128,114 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh 
*vm_in)
   VMesh *vm_out = new_adj_vmesh(bp->mem_arena, n_boundary, ns_out, 
vm_in->boundstart);
 
   /* First we adjust the boundary vertices of the input mesh, storing in 
output mesh. */
+  BoundVert *bndv = vm_in->boundstart;
   for (int i = 0; i < n_boundary; i++) {
+float co1[3], co2[3], acc[3];
+EdgeHalf *e = bndv->elast;
+/* Generate tangents. This is hacked together and would ideally be done 
elsewere and then only
+ * used here. */
+float tangent[3], tangent2[3], normal[3];
+bool convex = true;
+bool orthogonal = false;
+float stretch = 0.0f;
+if (e) {
+  /* Projection direction is direction of the edge. */
+  sub_v3_v3v3(tangent, e->e->v1->co, e->e->v2->co);
+  if (e->is_rev) {
+negate_v3(tangent);
+  }
+  normalize_v3(tangent);
+  if (bndv->is_arc_start || bndv->is_patch_start) {
+BMFace *face = e->fnext;
+if (face) {
+  copy_v3_v3(normal, face->no);
+}
+else {
+  zero_v3(normal);
+}
+madd_v3_v3v3fl(co2, bndv->profile.middle, normal, 0.1f);
+  }
+  if (bndv->is_arc_start || bp->affect_type == BEVEL_AFFECT_VERTICES) {
+EdgeHalf *e1 = bndv->next->elast;
+BLI_assert(e1);
+sub_v3_v3v3(tangent2, e1->e->v1->co, e1->e->v2->co);
+if (e1->is_rev) {
+  negate_v3(tangent2);
+}
+normalize_v3(tangent2);
+
+convex = determinant_v3v3v3(tangent2, tangent, normal) < 0;
+
+add_v3_v3(tangent2, tangent);
+normalize_v3(tangent2);
+copy_v3_v3(tangent, tangent2);
+  }
+  /* Calculate a factor which determines how much the interpolated mesh is
+   * going to be stretched out into the direction of the tangent.
+   * It is currently using the difference along the tangent of the
+   * central point on the profile and the current center vertex position. 
*/
+  get_profile_point(bp, >profile, ns_in2, ns_in, co);
+  stretch = dot_v3v3(tangent, mesh_vert(vm_in, i, ns_in2, ns_in2)->co) - 
dot_v3v3(tangent, co);
+  stretch = fabsf(stretch);
+  /* Scale the tangent by stretch. The divide by ns_in2 comes from the 
Levin Paper. */
+  mul_v3_fl(tangent, stretch / ns_in2);
+  orthogonal = bndv->is_patch_start;
+}
+else if (bndv->prev->is_patch_start) {
+  /* If this is the second edge of a patch and therefore #e is NULL,
+   * then e->fprev has to be used/not NULL. */
+  BLI_assert(bndv->prev->elast);
+  BMFace *face = bndv->prev->elast->fnext;
+  if (face) {
+copy_v3_v3(normal, face->no);
+  }
+  else {
+zero_v3(normal);
+  }
+  orthogonal = true;
+}
+else {
+  /** Should only come here from make_cube_corner_adj_vmesh. */
+  sub_v3_v3v3(co1, mesh_vert(vm_in, i, 0, 0)->co, mesh_vert(vm_in, i, 0, 
1)->co);
+  sub_v3_v3v3(co2, mesh_vert(vm_in, i, 0, 1)->co, mesh_vert(vm_in, i, 0, 
2)->co);
+  cross_v3_v3v3(tangent, co1, co2);
+  /** The following constant is choosen to best match the old results. */
+  normalize_v3_length(tangent, 1.5f / ns_out);
+}
+/** Copy corner 

[Bf-blender-cvs] [631067e5597] master: Add support for a longest diagonal quad triangulation mode

2022-01-11 Thread Henrik Dick
Commit: 631067e5597dec9cb5641b69a410d03746b7fa05
Author: Henrik Dick
Date:   Tue Jan 11 18:49:08 2022 +0100
Branches: master
https://developer.blender.org/rB631067e5597dec9cb5641b69a410d03746b7fa05

Add support for a longest diagonal quad triangulation mode

The new triangulation mode for quads is the opposite of the current default
shortest diagonal mode. It is optimal for cloth simulations using quad meshes.

Differential Revision: http://developer.blender.org/D13777

===

M   source/blender/bmesh/intern/bmesh_opdefines.c
M   source/blender/bmesh/intern/bmesh_polygon.c
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/makesrna/intern/rna_nodetree.c

===

diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c 
b/source/blender/bmesh/intern/bmesh_opdefines.c
index 7865c79323d..85ea27b0f4e 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1186,6 +1186,7 @@ static BMO_FlagSet bmo_enum_triangulate_quad_method[] = {
   {MOD_TRIANGULATE_QUAD_FIXED, "FIXED"},
   {MOD_TRIANGULATE_QUAD_ALTERNATE, "ALTERNATE"},
   {MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORT_EDGE"},
+  {MOD_TRIANGULATE_QUAD_LONGEDGE, "LONG_EDGE"},
   {0, NULL},
 };
 
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c 
b/source/blender/bmesh/intern/bmesh_polygon.c
index e9eaf865e3c..e7280303c26 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -1007,6 +1007,7 @@ void BM_face_triangulate(BMesh *bm,
   break;
 }
 case MOD_TRIANGULATE_QUAD_SHORTEDGE:
+case MOD_TRIANGULATE_QUAD_LONGEDGE:
 case MOD_TRIANGULATE_QUAD_BEAUTY:
 default: {
   BMLoop *l_v3, *l_v4;
@@ -1023,6 +1024,12 @@ void BM_face_triangulate(BMesh *bm,
 d2 = len_squared_v3v3(l_v1->v->co, l_v3->v->co);
 split_24 = ((d2 - d1) > 0.0f);
   }
+  else if (quad_method == MOD_TRIANGULATE_QUAD_LONGEDGE) {
+float d1, d2;
+d1 = len_squared_v3v3(l_v4->v->co, l_v2->v->co);
+d2 = len_squared_v3v3(l_v1->v->co, l_v3->v->co);
+split_24 = ((d2 - d1) < 0.0f);
+  }
   else {
 /* first check if the quad is concave on either diagonal */
 const int flip_flag = is_quad_flip_v3(
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index fc041e257b0..1d0796bda8b 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1852,6 +1852,7 @@ enum {
   MOD_TRIANGULATE_QUAD_FIXED = 1,
   MOD_TRIANGULATE_QUAD_ALTERNATE = 2,
   MOD_TRIANGULATE_QUAD_SHORTEDGE = 3,
+  MOD_TRIANGULATE_QUAD_LONGEDGE = 4,
 };
 
 typedef struct LaplacianSmoothModifierData {
diff --git a/source/blender/makesdna/DNA_node_types.h 
b/source/blender/makesdna/DNA_node_types.h
index 29d61bcf2ff..114e350b582 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -2118,6 +2118,7 @@ typedef enum GeometryNodeTriangulateQuads {
   GEO_NODE_TRIANGULATE_QUAD_FIXED = 1,
   GEO_NODE_TRIANGULATE_QUAD_ALTERNATE = 2,
   GEO_NODE_TRIANGULATE_QUAD_SHORTEDGE = 3,
+  GEO_NODE_TRIANGULATE_QUAD_LONGEDGE = 4,
 } GeometryNodeTriangulateQuads;
 
 typedef enum GeometryNodePointInstanceType {
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index d46ae13b482..0f0734c8448 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -331,7 +331,12 @@ const EnumPropertyItem 
rna_enum_modifier_triangulate_quad_method_items[] = {
  "SHORTEST_DIAGONAL",
  0,
  "Shortest Diagonal",
- "Split the quads based on the distance between the vertices"},
+ "Split the quads along their shortest diagonal"},
+{MOD_TRIANGULATE_QUAD_LONGEDGE,
+ "LONGEST_DIAGONAL",
+ 0,
+ "Longest Diagonal",
+ "Split the quads along their longest diagonal"},
 {0, NULL, 0, NULL, NULL},
 };
 
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index e7307e6e058..ecbeadf1fa4 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9488,7 +9488,12 @@ static void def_geo_triangulate(StructRNA *srna)
"SHORTEST_DIAGONAL",
0,
"Shortest Diagonal",
-   "Split the quads based on the distance between the vertices"},
+   "Spl

[Bf-blender-cvs] [819b9bdfa15] blender-v3.0-release: Fix T92631: Fix negative thickness regression in complex solidify

2021-11-22 Thread Henrik Dick
Commit: 819b9bdfa156082f6778337909cea9ad0c60d84d
Author: Henrik Dick
Date:   Mon Nov 22 09:33:49 2021 -0500
Branches: blender-v3.0-release
https://developer.blender.org/rB819b9bdfa156082f6778337909cea9ad0c60d84d

Fix T92631: Fix negative thickness regression in complex solidify

This regression was introduced by D11832, but there was problems before
that as well. I seem to have missed it in review. See the differential
revision for a screenshot of the difference.

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

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index d4aaefcfe05..0cc1627afcd 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -74,6 +74,7 @@ static float angle_signed_on_axis_normalized_v3v3_v3(const 
float n[3],
 static float clamp_nonzero(const float value, const float epsilon)
 {
   BLI_assert(!(epsilon < 0.0f));
+  /* Return closest value with `abs(value) >= epsilon`. */
   if (value < 0.0f) {
 return min_ff(value, -epsilon);
   }
@@ -171,15 +172,22 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 
   float(*poly_nors)[3] = NULL;
 
+  /* #ofs_front and #ofs_back are the offset from the original
+   * surface along the normal, where #oft_front is along the positive
+   * and #oft_back is along the negative normal. */
   const float ofs_front = (smd->offset_fac + 1.0f) * 0.5f * smd->offset;
   const float ofs_back = ofs_front - smd->offset * smd->offset_fac;
-  const float ofs_front_clamped = clamp_nonzero(smd->offset > 0 ? ofs_front : 
ofs_back, 1e-5f);
-  const float ofs_back_clamped = clamp_nonzero(smd->offset > 0 ? ofs_back : 
ofs_front, 1e-5f);
+  /* #ofs_front_clamped and #ofs_back_clamped are the same as
+   * #ofs_front and #ofs_back, but never zero. */
+  const float ofs_front_clamped = clamp_nonzero(ofs_front, 1e-5f);
+  const float ofs_back_clamped = clamp_nonzero(ofs_back, 1e-5f);
   const float offset_fac_vg = smd->offset_fac_vg;
   const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg;
   const float offset = fabsf(smd->offset) * smd->offset_clamp;
   const bool do_angle_clamp = smd->flag & MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP;
-  const bool do_flip = (smd->flag & MOD_SOLIDIFY_FLIP) != 0;
+  /* #do_flip, flips the normals of the result. This is inverted if negative 
thickness
+   * is used, since simple soldify with negative thickness keeps the faces 
facing outside. */
+  const bool do_flip = ((smd->flag & MOD_SOLIDIFY_FLIP) != 0) == (smd->offset 
> 0);
   const bool do_rim = smd->flag & MOD_SOLIDIFY_RIM;
   const bool do_shell = ((smd->flag & MOD_SOLIDIFY_RIM) && (smd->flag & 
MOD_SOLIDIFY_NOSHELL)) ==
 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] [2e6a7353852] master: GPencil: Curvature support for length modifier

2021-09-21 Thread Henrik Dick (weasel)
Commit: 2e6a7353852f432f626269b3e7d9246701c690e2
Author: Henrik Dick (weasel)
Date:   Tue Sep 21 23:00:49 2021 +0800
Branches: master
https://developer.blender.org/rB2e6a7353852f432f626269b3e7d9246701c690e2

GPencil: Curvature support for length modifier

Extend the stroke following an approximated circluar/helical curve.

This can be used as an effect for lineart or on its own as helix generator.

Reviewed By: Sebastian Parborg (zeddb), Hans Goudey (HooglyBoogly), YimingWu 
(NicksBest), Antonio Vazquez (antoniov), Henrik Dick (weasel)

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

# 请为您的变更输入提交说明。以 '#' 开始的行将被忽略,而一个空的提交
# 说明将会终止提交。
#
# 位于分支 master
# 您的分支与上游分支 'origin/master' 一致。
#
# 要提交的变更:
#   修改: source/blender/blenkernel/BKE_gpencil_geom.h
#   修改: source/blender/blenkernel/intern/gpencil_geom.cc
#   修改: source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
#   修改: source/blender/makesdna/DNA_gpencil_modifier_defaults.h
#   修改: source/blender/makesdna/DNA_gpencil_modifier_types.h
#   修改: source/blender/makesrna/intern/rna_gpencil_modifier.c
#

===

M   source/blender/blenkernel/BKE_gpencil_geom.h
M   source/blender/blenkernel/intern/gpencil_geom.cc
M   source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
M   source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h 
b/source/blender/blenkernel/BKE_gpencil_geom.h
index d472fd6f02b..a9cd553a8fe 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -114,7 +114,12 @@ void BKE_gpencil_dissolve_points(struct bGPdata *gpd,
 bool BKE_gpencil_stroke_stretch(struct bGPDstroke *gps,
 const float dist,
 const float overshoot_fac,
-const short mode);
+const short mode,
+const bool follow_curvature,
+const int extra_point_count,
+const float segment_influence,
+const float max_angle,
+const bool invert_curvature);
 bool BKE_gpencil_stroke_trim_points(struct bGPDstroke *gps,
 const int index_from,
 const int index_to);
diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc 
b/source/blender/blenkernel/intern/gpencil_geom.cc
index 8ff026231f5..d7c906be18e 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -540,65 +540,242 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd, bGPDstroke 
*gps, const float dist,
   return true;
 }
 
+/**
+ * Give extra stroke points before and after the original tip points.
+ * \param gps: Target stroke
+ * \param count_before: how many extra points to be added before a stroke
+ * \param count_after: how many extra points to be added after a stroke
+ */
+static bool BKE_gpencil_stroke_extra_points(bGPDstroke *gps,
+const int count_before,
+const int count_after)
+{
+  bGPDspoint *pts = gps->points;
+
+  BLI_assert(count_before >= 0);
+  BLI_assert(count_after >= 0);
+  if (!count_before && !count_after) {
+return false;
+  }
+
+  const int new_count = count_before + count_after + gps->totpoints;
+
+  bGPDspoint *new_pts = (bGPDspoint *)MEM_mallocN(sizeof(bGPDspoint) * 
new_count, __func__);
+
+  for (int i = 0; i < count_before; i++) {
+memcpy(_pts[i], [0], sizeof(bGPDspoint));
+  }
+  memcpy(_pts[count_before], pts, sizeof(bGPDspoint) * gps->totpoints);
+  for (int i = new_count - count_after; i < new_count; i++) {
+memcpy(_pts[i], [gps->totpoints - 1], sizeof(bGPDspoint));
+  }
+
+  if (gps->dvert) {
+MDeformVert *new_dv = (MDeformVert *)MEM_mallocN(sizeof(MDeformVert) * 
new_count, __func__);
+
+for (int i = 0; i < new_count; i++) {
+  MDeformVert *dv = >dvert[CLAMPIS(i - count_before, 0, 
gps->totpoints - 1)];
+  int inew = i;
+  new_dv[inew].flag = dv->flag;
+  new_dv[inew].totweight = dv->totweight;
+  new_dv[inew].dw = (MDeformWeight *)MEM_mallocN(sizeof(MDeformWeight) * 
dv->totweight,
+ __func__);
+  memcpy(new_dv[inew].dw, dv->dw, sizeof(MDeformWeight) * dv->totweight);
+}
+BKE_gpencil_free_stroke_weights(gps);
+MEM_freeN(gps->dvert);
+gps->dvert = new_dv;
+  }
+
+  MEM_freeN(gps->points);

[Bf-blender-cvs] [9a41b44197a] master: Fix T91481: Grease Pencil Layer Double Transformations

2021-09-17 Thread Henrik Dick
Commit: 9a41b44197a61622446be7b3b6bf59933f8f7694
Author: Henrik Dick
Date:   Fri Sep 17 13:29:05 2021 +0200
Branches: master
https://developer.blender.org/rB9a41b44197a61622446be7b3b6bf59933f8f7694

Fix T91481: Grease Pencil Layer Double Transformations

Use the inverse of the grease pencil object. This patch fixes the issue for 
bones and objects.

Maniphest Tasks: T91481

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

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index a143645c2ee..82a44afbbb1 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -3063,13 +3063,12 @@ void BKE_gpencil_update_layer_transforms(const 
Depsgraph *depsgraph, Object *ob)
 Object *ob_parent = DEG_get_evaluated_object(depsgraph, gpl->parent);
 /* calculate new matrix */
 if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) {
-  copy_m4_m4(cur_mat, ob_parent->obmat);
+  mul_m4_m4m4(cur_mat, ob->imat, ob_parent->obmat);
 }
 else if (gpl->partype == PARBONE) {
   bPoseChannel *pchan = BKE_pose_channel_find_name(ob_parent->pose, 
gpl->parsubstr);
   if (pchan != NULL) {
-copy_m4_m4(cur_mat, ob->imat);
-mul_m4_m4m4(cur_mat, ob_parent->obmat, pchan->pose_mat);
+mul_m4_series(cur_mat, ob->imat, ob_parent->obmat, 
pchan->pose_mat);
   }
   else {
 unit_m4(cur_mat);

___
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] [28f773925af] master: Fix Constraints not updating on move in stack

2021-09-10 Thread Henrik Dick
Commit: 28f773925af01c1d9d23e58c7cce49efdc0b65a7
Author: Henrik Dick
Date:   Fri Sep 10 18:48:41 2021 +0200
Branches: master
https://developer.blender.org/rB28f773925af01c1d9d23e58c7cce49efdc0b65a7

Fix Constraints not updating on move in stack

Flag the changed object and its bones to update after moving a
constraint in the stack up or down. The two operators for move up and
move down seem to be unused, but I notices they had the same problem, so
I added the update there as well.

Reviewed By: sybren

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

===

M   source/blender/editors/object/object_constraint.c

===

diff --git a/source/blender/editors/object/object_constraint.c 
b/source/blender/editors/object/object_constraint.c
index e0419e0a4cc..c46e868899c 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1862,6 +1862,7 @@ static int constraint_move_down_exec(bContext *C, 
wmOperator *op)
 BLI_remlink(conlist, con);
 BLI_insertlinkafter(conlist, nextCon, con);
 
+ED_object_constraint_update(CTX_data_main(C), ob);
 WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
 
 return OPERATOR_FINISHED;
@@ -1917,6 +1918,7 @@ static int constraint_move_up_exec(bContext *C, 
wmOperator *op)
 BLI_remlink(conlist, con);
 BLI_insertlinkbefore(conlist, prevCon, con);
 
+ED_object_constraint_update(CTX_data_main(C), ob);
 WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
 
 return OPERATOR_FINISHED;
@@ -1970,6 +1972,8 @@ static int constraint_move_to_index_exec(bContext *C, 
wmOperator *op)
   if (con) {
 ED_object_constraint_move_to_index(ob, con, new_index);
 
+ED_object_constraint_update(CTX_data_main(C), ob);
+
 return OPERATOR_FINISHED;
   }

___
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] [54b72fe9ff2] master: GPencil: Fix Noise Modifier Randomize Panel disabled

2021-09-04 Thread Henrik Dick
Commit: 54b72fe9ff2a7a061423270db8d6853986bbb796
Author: Henrik Dick
Date:   Sat Sep 4 16:02:40 2021 +0200
Branches: master
https://developer.blender.org/rB54b72fe9ff2a7a061423270db8d6853986bbb796

GPencil: Fix Noise Modifier Randomize Panel disabled

Fix regression introduced in rB34b213d60472

Reviewed By: antoniov

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

===

M   source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
index 9e9eba3d61e..ae862ce3eda 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
@@ -324,7 +324,7 @@ static void random_panel_draw(const bContext *UNUSED(C), 
Panel *panel)
 
   uiLayoutSetPropSep(layout, true);
 
-  uiLayoutSetActive(layout, RNA_boolean_get(ptr, "random"));
+  uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_random"));
 
   uiItemR(layout, ptr, "step", 0, NULL, ICON_NONE);
 }

___
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] [c23b6596b91] master: GPencil: Fix subdivision modifier disabled on strokes with 2 points

2021-09-04 Thread Henrik Dick
Commit: c23b6596b91ceaf19d6e98bd66d7e67726821dc2
Author: Henrik Dick
Date:   Sat Sep 4 15:34:01 2021 +0200
Branches: master
https://developer.blender.org/rBc23b6596b91ceaf19d6e98bd66d7e67726821dc2

GPencil: Fix subdivision modifier disabled on strokes with 2 points

Fixes the regression introduces in rB29f3af952725 . The subdivision modifier 
used to work on two point strokes with simple mode but not with catmul clark. 
Now it will work with simple mode and in case of catmull clark mode it will 
still use simple mode on these strokes.

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

===

M   source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
index f444103ae3f..ee5ba7e92ca 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
@@ -76,16 +76,12 @@ static void deformStroke(GpencilModifierData *md,
   SubdivGpencilModifierData *mmd = (SubdivGpencilModifierData *)md;
   bGPdata *gpd = ob->data;
 
-  /* It makes sense when adding points to a straight line */
-  /* e.g. for creating thickness variation in later modifiers. */
-  const int minimum_vert = (mmd->flag & GP_SUBDIV_SIMPLE) ? 2 : 3;
-
   if (!is_stroke_affected_by_modifier(ob,
   mmd->layername,
   mmd->material,
   mmd->pass_index,
   mmd->layer_pass,
-  minimum_vert,
+  2,
   gpl,
   gps,
   mmd->flag & GP_SUBDIV_INVERT_LAYER,
@@ -95,7 +91,10 @@ static void deformStroke(GpencilModifierData *md,
 return;
   }
 
-  BKE_gpencil_stroke_subdivide(gpd, gps, mmd->level, mmd->type);
+  /* For strokes with less than 3 points, only the Simple Subdivision makes 
sense. */
+  short type = gps->totpoints < 3 ? GP_SUBDIV_SIMPLE : mmd->type;
+
+  BKE_gpencil_stroke_subdivide(gpd, gps, mmd->level, type);
 
   /* If the stroke is cyclic, must generate the closing geometry. */
   if (gps->flag & GP_STROKE_CYCLIC) {

___
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] [e76f04c8707] master: Fix T90742: Gpencil ghost point on selection

2021-08-30 Thread Henrik Dick
Commit: e76f04c87079de21bde0b2f6e79226eeeccb5aea
Author: Henrik Dick
Date:   Mon Aug 30 15:16:39 2021 +0200
Branches: master
https://developer.blender.org/rBe76f04c87079de21bde0b2f6e79226eeeccb5aea

Fix T90742: Gpencil ghost point on selection

Reviewed By: fclem, filedescriptor

Maniphest Tasks: T90742

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

===

M   source/blender/draw/intern/draw_cache_impl_gpencil.c

===

diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c 
b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index 6ed4148a7fe..e78e41b917a 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -446,6 +446,8 @@ static void gpencil_batches_ensure(Object *ob, 
GpencilBatchCache *cache, int cfr
 for (int i = 0; i < 2; i++) {
   iter.verts[iter.vert_len + i].mat = -1;
 }
+/* Also mark first vert as invalid. */
+iter.verts[0].mat = -1;
 
 /* Finish the IBO. */
 cache->ibo = GPU_indexbuf_build();

___
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] [20ef7713743] master: Modifier: smooth interpolation support

2021-08-26 Thread Henrik Dick
Commit: 20ef77137434efa1854cb1d6de70aa476b2674f9
Author: Henrik Dick
Date:   Fri Aug 27 11:32:44 2021 +1000
Branches: master
https://developer.blender.org/rB20ef77137434efa1854cb1d6de70aa476b2674f9

Modifier: smooth interpolation support

Add an option to the mask modifier to use the vertex weights to generate
smooth in between geometry, instead of just deleting non complete faces.

This can be used to make all sorts of smooth dissolve animations
directly with geometry, which are usually hacked together with shaders.
It also allows for implicit function plotting using geometry nodes and
boolean like operations on non manifold geometry with the proximity
modifier.

Reviewed By: campbellbarton

Ref D10979

===

M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_mask.cc

===

diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 1bebbc35747..13213f70fed 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -298,6 +298,7 @@ enum {
 /* Mask Modifier -> flag */
 enum {
   MOD_MASK_INV = (1 << 0),
+  MOD_MASK_SMOOTH = (1 << 1),
 };
 
 typedef struct ArrayModifierData {
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 486d8d13564..f11d845c582 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4431,6 +4431,12 @@ static void rna_def_modifier_mask(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Invert", "Use vertices that are not part of 
region defined");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+  prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MASK_SMOOTH);
+  RNA_def_property_ui_text(
+  prop, "Smooth", "Use vertex group weights to cut faces at the weight 
contour");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_FACTOR);
   RNA_def_property_float_sdna(prop, NULL, "threshold");
   RNA_def_property_range(prop, 0.0, 1.0);
diff --git a/source/blender/modifiers/intern/MOD_mask.cc 
b/source/blender/modifiers/intern/MOD_mask.cc
index 9aa8e3dd7c8..aca90e0533c 100644
--- a/source/blender/modifiers/intern/MOD_mask.cc
+++ b/source/blender/modifiers/intern/MOD_mask.cc
@@ -27,6 +27,7 @@
 
 #include "BLI_ghash.h"
 #include "BLI_listbase.h"
+#include "BLI_math.h"
 
 #include "BLT_translation.h"
 
@@ -214,6 +215,40 @@ static void computed_masked_edges(const Mesh *mesh,
   *r_num_masked_edges = num_masked_edges;
 }
 
+static void computed_masked_edges_smooth(const Mesh *mesh,
+ Span vertex_mask,
+ MutableSpan r_edge_map,
+ uint *r_num_masked_edges,
+ uint *r_num_add_vertices)
+{
+  BLI_assert(mesh->totedge == r_edge_map.size());
+
+  uint num_masked_edges = 0;
+  uint num_add_vertices = 0;
+  for (int i : IndexRange(mesh->totedge)) {
+const MEdge  = mesh->medge[i];
+
+/* only add if both verts will be in new mesh */
+bool v1 = vertex_mask[edge.v1];
+bool v2 = vertex_mask[edge.v2];
+if (v1 && v2) {
+  r_edge_map[i] = num_masked_edges;
+  num_masked_edges++;
+}
+else if (v1 != v2) {
+  r_edge_map[i] = -2;
+  num_add_vertices++;
+}
+else {
+  r_edge_map[i] = -1;
+}
+  }
+
+  num_masked_edges += num_add_vertices;
+  *r_num_masked_edges = num_masked_edges;
+  *r_num_add_vertices = num_add_vertices;
+}
+
 static void computed_masked_polygons(const Mesh *mesh,
  Span vertex_mask,
  Vector _masked_poly_indices,
@@ -224,7 +259,7 @@ static void computed_masked_polygons(const Mesh *mesh,
   BLI_assert(mesh->totvert == vertex_mask.size());
 
   r_masked_poly_indices.reserve(mesh->totpoly);
-  r_loop_starts.reserve(mesh->totloop);
+  r_loop_starts.reserve(mesh->totpoly);
 
   uint num_masked_loops = 0;
   for (int i : IndexRange(mesh->totpoly)) {
@@ -250,6 +285,76 @@ static void computed_masked_polygons(const Mesh *mesh,
   *r_num_masked_loops = num_masked_loops;
 }
 
+static void compute_interpolated_polygons(const Mesh *mesh,
+  Span vertex_mask,
+  uint num_add_vertices,
+  uint num_masked_loo

[Bf-blender-cvs] [e3098de2a1f] master: GPencil: Fix unreported switch direction not flipping weights

2021-08-17 Thread Henrik Dick
Commit: e3098de2a1fedd98d9f31d3cb562116f0945b7f9
Author: Henrik Dick
Date:   Tue Aug 17 22:16:16 2021 +0200
Branches: master
https://developer.blender.org/rBe3098de2a1fedd98d9f31d3cb562116f0945b7f9

GPencil:  Fix unreported switch direction not flipping weights

There was an unreported bug that switch direction would not switch the order of 
the vertex group weights. This caused join to do it wrong as well.

Changed to use `BLI_array_reverse` function here to reverse both the normal 
points and the weights, therefore simplifying the code.

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

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc 
b/source/blender/blenkernel/intern/gpencil_geom.cc
index f2042d3098c..0f218d6166c 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -31,6 +31,7 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "BLI_array_utils.h"
 #include "BLI_blenlib.h"
 #include "BLI_float3.hh"
 #include "BLI_ghash.h"
@@ -2817,46 +2818,12 @@ void BKE_gpencil_stroke_set_random_color(bGPDstroke 
*gps)
 /* Flip stroke. */
 void BKE_gpencil_stroke_flip(bGPDstroke *gps)
 {
-  int end = gps->totpoints - 1;
+  /* Reverse points. */
+  BLI_array_reverse(gps->points, gps->totpoints);
 
-  for (int i = 0; i < gps->totpoints / 2; i++) {
-bGPDspoint *point, *point2;
-bGPDspoint pt;
-
-/* save first point */
-point = >points[i];
-pt.x = point->x;
-pt.y = point->y;
-pt.z = point->z;
-pt.flag = point->flag;
-pt.pressure = point->pressure;
-pt.strength = point->strength;
-pt.time = point->time;
-copy_v4_v4(pt.vert_color, point->vert_color);
-
-/* replace first point with last point */
-point2 = >points[end];
-point->x = point2->x;
-point->y = point2->y;
-point->z = point2->z;
-point->flag = point2->flag;
-point->pressure = point2->pressure;
-point->strength = point2->strength;
-point->time = point2->time;
-copy_v4_v4(point->vert_color, point2->vert_color);
-
-/* replace last point with first saved before */
-point = >points[end];
-point->x = pt.x;
-point->y = pt.y;
-point->z = pt.z;
-point->flag = pt.flag;
-point->pressure = pt.pressure;
-point->strength = pt.strength;
-point->time = pt.time;
-copy_v4_v4(point->vert_color, pt.vert_color);
-
-end--;
+  /* Reverse vertex groups if available. */
+  if (gps->dvert) {
+BLI_array_reverse(gps->dvert, gps->totpoints);
   }
 }

___
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] [88dc274d053] master: GPencil: Convert from Mesh copying Vertex Groups

2021-08-17 Thread Henrik Dick
Commit: 88dc274d0533e3b4427a61718958bf84367b5077
Author: Henrik Dick
Date:   Tue Aug 17 20:04:27 2021 +0200
Branches: master
https://developer.blender.org/rB88dc274d0533e3b4427a61718958bf84367b5077

GPencil: Convert from Mesh copying Vertex Groups

This patch adds the missing ability to keep the vertex groups when converting 
to a grease pencil object. This is increadible useful to create rigged grease 
pencil objects which move together with rigged meshes.

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

===

M   source/blender/blenkernel/BKE_gpencil_geom.h
M   source/blender/blenkernel/intern/gpencil_geom.cc
M   source/blender/editors/gpencil/gpencil_mesh.c
M   source/blender/editors/object/object_add.c

===

diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h 
b/source/blender/blenkernel/BKE_gpencil_geom.h
index c1ccae7a437..29e3a74b1b2 100644
--- a/source/blender/blenkernel/BKE_gpencil_geom.h
+++ b/source/blender/blenkernel/BKE_gpencil_geom.h
@@ -169,7 +169,8 @@ bool BKE_gpencil_convert_mesh(struct Main *bmain,
   const float matrix[4][4],
   const int frame_offset,
   const bool use_seams,
-  const bool use_faces);
+  const bool use_faces,
+  const bool use_vgroups);
 
 void BKE_gpencil_stroke_uniform_subdivide(struct bGPdata *gpd,
   struct bGPDstroke *gps,
diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc 
b/source/blender/blenkernel/intern/gpencil_geom.cc
index f8a07939096..f2042d3098c 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.cc
+++ b/source/blender/blenkernel/intern/gpencil_geom.cc
@@ -2269,7 +2269,8 @@ static void gpencil_generate_edgeloops(Object *ob,
const int thickness,
const float offset,
const float matrix[4][4],
-   const bool use_seams)
+   const bool use_seams,
+   const bool use_vgroups)
 {
   Mesh *me = (Mesh *)ob->data;
   if (me->totedge == 0) {
@@ -2278,9 +2279,9 @@ static void gpencil_generate_edgeloops(Object *ob,
 
   /* Arrays for all edge vertices (forward and backward) that form a edge loop.
* This is reused for each edge-loop to create gpencil stroke. */
-  uint *stroke = (uint *)MEM_callocN(sizeof(uint) * me->totedge * 2, __func__);
-  uint *stroke_fw = (uint *)MEM_callocN(sizeof(uint) * me->totedge, __func__);
-  uint *stroke_bw = (uint *)MEM_callocN(sizeof(uint) * me->totedge, __func__);
+  uint *stroke = (uint *)MEM_mallocN(sizeof(uint) * me->totedge * 2, __func__);
+  uint *stroke_fw = (uint *)MEM_mallocN(sizeof(uint) * me->totedge, __func__);
+  uint *stroke_bw = (uint *)MEM_mallocN(sizeof(uint) * me->totedge, __func__);
 
   /* Create array with all edges. */
   GpEdge *gp_edges = (GpEdge *)MEM_callocN(sizeof(GpEdge) * me->totedge, 
__func__);
@@ -2311,11 +2312,6 @@ static void gpencil_generate_edgeloops(Object *ob,
   bool pending = true;
   int e = 0;
   while (pending) {
-/* Clear arrays of stroke. */
-memset(stroke_fw, 0, sizeof(uint) * me->totedge);
-memset(stroke_bw, 0, sizeof(uint) * me->totedge);
-memset(stroke, 0, sizeof(uint) * me->totedge * 2);
-
 gped = _edges[e];
 /* Look first unused edge. */
 if (gped->flag != 0) {
@@ -2330,7 +2326,7 @@ static void gpencil_generate_edgeloops(Object *ob,
 stroke_bw[0] = e;
 gped->flag = 1;
 
-/* Hash used to avoid loop over same vertice. */
+/* Hash used to avoid loop over same vertices. */
 GHash *v_table = BLI_ghash_int_new(__func__);
 /* Look forward edges. */
 int totedges = gpencil_walk_edge(v_table, gp_edges, me->totedge, 
stroke_fw, e, angle, false);
@@ -2354,38 +2350,41 @@ static void gpencil_generate_edgeloops(Object *ob,
 bGPDstroke *gps_stroke = BKE_gpencil_stroke_add(
 gpf_stroke, MAX2(stroke_mat_index, 0), array_len + 1, thickness * 
thickness, false);
 
+/* Create dvert data. */
+MDeformVert *me_dvert = me->dvert;
+if (use_vgroups && me_dvert) {
+  gps_stroke->dvert = (MDeformVert *)MEM_callocN(sizeof(MDeformVert) * 
(array_len + 1),
+ "gp_stroke_dverts");
+}
+
 /* Create first segment. */
 float fpt[3];
-uint v = stroke[0];
-gped = _edges[v];
-bGPDspoint *pt = _stroke->points[0];
-mul_v3_v3fl(fpt, gped->n1, offset);
-add_v3_v3v3(>x, gped->v1_co, fpt);
-mul_m4_v3(matrix, >x);
-
-pt->pressure = 1.0f;
-pt->strength = 1.0f;

[Bf-blender-cvs] [d6891d9bee2] master: Add Extras Dropdown Menu to Constraints

2021-08-12 Thread Henrik Dick
Commit: d6891d9bee2bd2073cb45e1ac9a04b2f03f05a9a
Author: Henrik Dick
Date:   Thu Aug 12 14:22:19 2021 +0200
Branches: master
https://developer.blender.org/rBd6891d9bee2bd2073cb45e1ac9a04b2f03f05a9a

Add Extras Dropdown Menu to Constraints

Add Apply Constraint, Duplicate Constraint, and Copy To Selected
operators, and include them in a menu similar to the menu for modifiers.
The shortcuts in the extras menu are also matched to modifiers.

All the here added operators are intended to work exactly like the
analogous ones for modifiers. That means the apply operator should apply
a constraint as if it was first in the list, just like modifiers do. I
have added the same warning message as for modifiers when that happens.

The decision to use this approach of appling the constraint as if it was
first, was made for consistency with modifiers. People are already used
to how it works there. Is also provides more intricate control over the
applied transforms, then just applying all constraints up to that one.
Apply all constraints is already kinda implemented in Bake Animation.

Reviewed By: HooglyBoogly, sybren, #user_interface

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

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py
M   
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M   source/blender/blenkernel/BKE_constraint.h
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/editors/interface/interface_templates.c
M   source/blender/editors/object/object_constraint.c
M   source/blender/editors/object/object_intern.h
M   source/blender/editors/object/object_ops.c
M   source/blender/makesrna/intern/rna_constraint.c

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 7abbbaddb5c..d9538930f33 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -775,6 +775,8 @@ def km_property_editor(_params):
 # Constraint panels
 ("constraint.delete", {"type": 'X', "value": 'PRESS'}, {"properties": 
[("report", True)]}),
 ("constraint.delete", {"type": 'DEL', "value": 'PRESS'}, 
{"properties": [("report", True)]}),
+("constraint.copy", {"type": 'D', "value": 'PRESS', "shift": True}, 
None),
+("constraint.apply", {"type": 'A', "value": 'PRESS', "ctrl": True}, 
{"properties": [("report", True)]}),
 ])
 
 return keymap
diff --git 
a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py 
b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index cb9970f600b..dba94d71a43 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -465,6 +465,7 @@ def km_property_editor(params):
 # Constraint panels
 ("constraint.delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, 
{"properties": [("report", True)]}),
 ("constraint.delete", {"type": 'DEL', "value": 'PRESS'}, 
{"properties": [("report", True)]}),
+("constraint.copy", {"type": 'D', "value": 'PRESS', "ctrl": True}, 
None),
 ])
 
 return keymap
diff --git a/source/blender/blenkernel/BKE_constraint.h 
b/source/blender/blenkernel/BKE_constraint.h
index 575df93a9fc..784b395dfa5 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -192,6 +192,28 @@ bool BKE_constraint_remove_ex(ListBase *list,
   bool clear_dep);
 bool BKE_constraint_remove(ListBase *list, struct bConstraint *con);
 
+bool BKE_constraint_apply_for_object(struct Depsgraph *depsgraph,
+ struct Scene *scene,
+ struct Object *ob,
+ struct bConstraint *con);
+bool BKE_constraint_apply_and_remove_for_object(struct Depsgraph *depsgraph,
+struct Scene *scene,
+ListBase /*bConstraint*/ 
*constraints,
+struct Object *ob,
+struct bConstraint *con);
+
+bool BKE_constraint_apply_for_pose(s

[Bf-blender-cvs] [2f39f7f8154] master: Modifier: use high quality normals for vertex offset

2021-08-10 Thread Henrik Dick
Commit: 2f39f7f81549cff0285c2f1934de5d2c743785d4
Author: Henrik Dick
Date:   Wed Aug 11 10:22:49 2021 +1000
Branches: master
https://developer.blender.org/rB2f39f7f81549cff0285c2f1934de5d2c743785d4

Modifier: use high quality normals for vertex offset

Using high quality normals for vertex offset when set
for higher precision offsets.

This was only used for calculating even-offset.

Reviewed By: campbellbarton

Ref D12176

===

M   source/blender/modifiers/intern/MOD_solidify_extrude.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c 
b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index e97190b1878..64e1eb92fda 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -507,8 +507,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, 
const ModifierEvalContex
   /* NOTE: copied vertex layers don't have flipped normals yet. do this after 
applying offset. */
   if ((smd->flag & MOD_SOLIDIFY_EVEN) == 0) {
 /* no even thickness, very simple */
-float scalar_short;
-float scalar_short_vgroup;
+float ofs_new_vgroup;
 
 /* for clamping */
 float *vert_lens = NULL;
@@ -597,7 +596,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, 
const ModifierEvalContex
   uint i_orig, i_end;
   bool do_shell_align;
 
-  scalar_short = scalar_short_vgroup = ofs_new / 32767.0f;
+  ofs_new_vgroup = ofs_new;
 
   INIT_VERT_ARRAY_OFFSETS(false);
 
@@ -606,36 +605,40 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, 
const ModifierEvalContex
 if (dvert) {
   MDeformVert *dv = [i];
   if (defgrp_invert) {
-scalar_short_vgroup = 1.0f - BKE_defvert_find_weight(dv, 
defgrp_index);
+ofs_new_vgroup = 1.0f - BKE_defvert_find_weight(dv, defgrp_index);
   }
   else {
-scalar_short_vgroup = BKE_defvert_find_weight(dv, defgrp_index);
+ofs_new_vgroup = BKE_defvert_find_weight(dv, defgrp_index);
   }
-  scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * 
offset_fac_vg_inv)) *
-scalar_short;
+  ofs_new_vgroup = (offset_fac_vg + (ofs_new_vgroup * 
offset_fac_vg_inv)) * ofs_new;
 }
 if (do_clamp && offset > FLT_EPSILON) {
   /* always reset because we may have set before */
   if (dvert == NULL) {
-scalar_short_vgroup = scalar_short;
+ofs_new_vgroup = ofs_new;
   }
   if (do_angle_clamp) {
 float cos_ang = cosf(((2 * M_PI) - vert_angs[i]) * 0.5f);
 if (cos_ang > 0) {
   float max_off = sqrtf(vert_lens[i]) * 0.5f / cos_ang;
   if (max_off < offset * 0.5f) {
-scalar_short_vgroup *= max_off / offset * 2;
+ofs_new_vgroup *= max_off / offset * 2;
   }
 }
   }
   else {
 if (vert_lens[i] < offset_sq) {
   float scalar = sqrtf(vert_lens[i]) / offset;
-  scalar_short_vgroup *= scalar;
+  ofs_new_vgroup *= scalar;
 }
   }
 }
-madd_v3v3short_fl(mv->co, mv->no, scalar_short_vgroup);
+if (vert_nors) {
+  madd_v3_v3fl(mv->co, vert_nors[i], ofs_new_vgroup);
+}
+else {
+  madd_v3v3short_fl(mv->co, mv->no, ofs_new_vgroup / 32767.0f);
+}
   }
 }
 
@@ -643,7 +646,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, 
const ModifierEvalContex
   uint i_orig, i_end;
   bool do_shell_align;
 
-  scalar_short = scalar_short_vgroup = ofs_orig / 32767.0f;
+  ofs_new_vgroup = ofs_orig;
 
   /* as above but swapped */
   INIT_VERT_ARRAY_OFFSETS(true);
@@ -653,36 +656,40 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, 
const ModifierEvalContex
 if (dvert) {
   MDeformVert *dv = [i];
   if (defgrp_invert) {
-scalar_short_vgroup = 1.0f - BKE_defvert_find_weight(dv, 
defgrp_index);
+ofs_new_vgroup = 1.0f - BKE_defvert_find_weight(dv, defgrp_index);
   }
   else {
-scalar_short_vgroup = BKE_defvert_find_weight(dv, defgrp_index);
+ofs_new_vgroup = BKE_defvert_find_weight(dv, defgrp_index);
   }
-  scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * 
offset_fac_vg_inv)) *
-scalar_short;
+  ofs_new_vgroup = (offset_fac_vg + (ofs_new_vgroup * 
offset_fac_vg_inv)) * ofs_orig;
 }
 if (do_clamp && offset > FLT_EPSILON) {
   /* always reset because we may have set before */
   if (dvert == NULL) {
-scalar_sho

[Bf-blender-cvs] [df2a19eac7d] master: Geometry Nodes: Add Convex Hull Node

2021-06-09 Thread Henrik Dick
Commit: df2a19eac7daf4943b22f74890cebd14eb811f4e
Author: Henrik Dick
Date:   Wed Jun 9 11:58:08 2021 -0500
Branches: master
https://developer.blender.org/rBdf2a19eac7daf4943b22f74890cebd14eb811f4e

Geometry Nodes: Add Convex Hull Node

This commit adds a node to output the convex hull of any input geometry
as a mesh, which is an enclosing geometry around a set of points.
All geometry types are supported, besides volumes.

The code supports operating on instances to avoid copying all input
geometry before the operation. The implementation uses the same backend
as the operation in edit mode, but uses Mesh directly instead of BMesh.

Attribute transfer is not supported currently, but would be a point of
improvement for the future if it can work in a predictable way on
different geometry input types.

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

===

M   intern/rigidbody/RBI_hull_api.h
M   intern/rigidbody/rb_convex_hull_api.cpp
M   release/scripts/startup/nodeitems_builtins.py
M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/node.cc
M   source/blender/nodes/CMakeLists.txt
M   source/blender/nodes/NOD_geometry.h
M   source/blender/nodes/NOD_static_types.h
A   source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc

===

diff --git a/intern/rigidbody/RBI_hull_api.h b/intern/rigidbody/RBI_hull_api.h
index 9d2dc5034db..3bd216b92cb 100644
--- a/intern/rigidbody/RBI_hull_api.h
+++ b/intern/rigidbody/RBI_hull_api.h
@@ -31,9 +31,13 @@ typedef struct plConvexHull__ {
 plConvexHull plConvexHullCompute(float (*coords)[3], int count);
 void plConvexHullDelete(plConvexHull hull);
 int plConvexHullNumVertices(plConvexHull hull);
+int plConvexHullNumLoops(plConvexHull hull);
 int plConvexHullNumFaces(plConvexHull hull);
 void plConvexHullGetVertex(plConvexHull hull, int n, float coords[3], int 
*original_index);
+void plConvexHullGetLoop(plConvexHull hull, int n, int *v_from, int *v_to);
+int plConvexHullGetReversedLoopIndex(plConvexHull hull, int n);
 int plConvexHullGetFaceSize(plConvexHull hull, int n);
+void plConvexHullGetFaceLoops(plConvexHull hull, int n, int *loops);
 void plConvexHullGetFaceVertices(plConvexHull hull, int n, int *vertices);
 
 #ifdef __cplusplus
diff --git a/intern/rigidbody/rb_convex_hull_api.cpp 
b/intern/rigidbody/rb_convex_hull_api.cpp
index c5893a4c808..03e7580a12b 100644
--- a/intern/rigidbody/rb_convex_hull_api.cpp
+++ b/intern/rigidbody/rb_convex_hull_api.cpp
@@ -39,6 +39,12 @@ int plConvexHullNumVertices(plConvexHull hull)
   return computer->vertices.size();
 }
 
+int plConvexHullNumLoops(plConvexHull hull)
+{
+  btConvexHullComputer *computer(reinterpret_cast(hull));
+  return computer->edges.size();
+}
+
 int plConvexHullNumFaces(plConvexHull hull)
 {
   btConvexHullComputer *computer(reinterpret_cast(hull));
@@ -55,6 +61,19 @@ void plConvexHullGetVertex(plConvexHull hull, int n, float 
coords[3], int *origi
   (*original_index) = computer->original_vertex_index[n];
 }
 
+void plConvexHullGetLoop(plConvexHull hull, int n, int *v_from, int *v_to)
+{
+  btConvexHullComputer *computer(reinterpret_cast(hull));
+  (*v_from) = computer->edges[n].getSourceVertex();
+  (*v_to) = computer->edges[n].getTargetVertex();
+}
+
+int plConvexHullGetReversedLoopIndex(plConvexHull hull, int n)
+{
+  btConvexHullComputer *computer(reinterpret_cast(hull));
+  return computer->edges[n].getReverseEdge() - >edges[0];
+}
+
 int plConvexHullGetFaceSize(plConvexHull hull, int n)
 {
   btConvexHullComputer *computer(reinterpret_cast(hull));
@@ -69,6 +88,19 @@ int plConvexHullGetFaceSize(plConvexHull hull, int n)
   return count;
 }
 
+void plConvexHullGetFaceLoops(plConvexHull hull, int n, int *loops)
+{
+  btConvexHullComputer *computer(reinterpret_cast(hull));
+  const btConvexHullComputer::Edge *e_orig, *e;
+  int count;
+
+  for (e_orig = >edges[computer->faces[n]], e = e_orig, count = 0;
+   count == 0 || e != e_orig;
+   e = e->getNextEdgeOfFace(), count++) {
+loops[count] = e - >edges[0];
+  }
+}
+
 void plConvexHullGetFaceVertices(plConvexHull hull, int n, int *vertices)
 {
   btConvexHullComputer *computer(reinterpret_cast(hull));
diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index cf125075b3b..5ff0e13f242 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -508,6 +508,7 @@ geometry_node_categories = [
 ]),
 GeometryNodeCategory("GEO_GEOMETRY", "Geometry", items=[
 NodeItem("GeometryNodeBoundBox"),
+NodeItem("GeometryNodeConvexHull"),
 NodeItem("GeometryNodeDeleteGeometry"),
 NodeItem("GeometryNodeTransform"),
 Node

[Bf-blender-cvs] [0447aedb960] master: UI: add non-linear slider support

2021-05-17 Thread Henrik Dick
Commit: 0447aedb960a1dc514fee8cd99d0eee43fae86ad
Author: Henrik Dick
Date:   Mon May 17 17:28:12 2021 +1000
Branches: master
https://developer.blender.org/rB0447aedb960a1dc514fee8cd99d0eee43fae86ad

UI: add non-linear slider support

This patch introduces non linear sliders. That means, that the movement
of the mouse doesn't map linearly to the value of the slider.

The following changes have been made.

- Free logarithmic sliders with maximum range of (`0 <= x < inf`)
- Logarithmic sliders with correct value indication bar.
- Free cubic sliders with maximum range of (`-inf < x < inf`)
- Cubic sliders with correct value indication bar.

Cubic mapping has been added as well, because it's used for brush sizes
in other applications (Krita for e.g.).

To make a slider have a different scale type use following line in RNA:
 `RNA_def_property_ui_scale_type(prop, PROP_SCALE_LOGARITHMIC);`
or:
 `RNA_def_property_ui_scale_type(prop, PROP_SCALE_CUBIC);`

Test the precision, step size and soft-min if you change the scale type
of a property as it will feel very different and may need tweaking.

Ref D9074

===

M   source/blender/editors/interface/interface.c
M   source/blender/editors/interface/interface_handlers.c
M   source/blender/editors/interface/interface_intern.h
M   source/blender/editors/interface/interface_widgets.c
M   source/blender/makesrna/RNA_access.h
M   source/blender/makesrna/RNA_define.h
M   source/blender/makesrna/RNA_types.h
M   source/blender/makesrna/intern/makesrna.c
M   source/blender/makesrna/intern/rna_access.c
M   source/blender/makesrna/intern/rna_define.c
M   source/blender/makesrna/intern/rna_internal_types.h

===

diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 90d604b3190..a31efefd99c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2327,6 +2327,14 @@ bool ui_but_is_float(const uiBut *but)
   return false;
 }
 
+PropertyScaleType ui_but_scale_type(const uiBut *but)
+{
+  if (but->rnaprop) {
+return RNA_property_ui_scale(but->rnaprop);
+  }
+  return PROP_SCALE_LINEAR;
+}
+
 bool ui_but_is_bool(const uiBut *but)
 {
   if (ELEM(but->type,
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index b196bb29ab7..282d470c7ea 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -125,6 +125,24 @@
  */
 #define UI_MAX_PASSWORD_STR 128
 
+/**
+ * This is a lower limit on the soft minimum of the range.
+ * Usually the derived lower limit from the visible precision is higher,
+ * so this number is the backup minimum.
+ *
+ * Logarithmic scale does not work with a minimum value of zero,
+ * but we want to support it anyway. It is set to 0.5e... for
+ * correct rounding since when the tweaked value is lower than
+ * the log minimum (lower limit), it will snap to 0.
+ */
+#define UI_PROP_SCALE_LOG_MIN 0.5e-8f
+/**
+ * This constant defines an offset for the precision change in
+ * snap rounding, when going to higher values. It is set to
+ * `0.5 - log10(3) = 0.03` to make the switch at `0.3` values.
+ */
+#define UI_PROP_SCALE_LOG_SNAP_OFFSET 0.03f
+
 /**
  * When #USER_CONTINUOUS_MOUSE is disabled or tablet input is used,
  * Use this as a maximum soft range for mapping cursor motion to the value.
@@ -3938,9 +3956,16 @@ static void ui_numedit_begin(uiBut *but, 
uiHandleButtonData *data)
 float softmin = but->softmin;
 float softmax = but->softmax;
 float softrange = softmax - softmin;
+const PropertyScaleType scale_type = ui_but_scale_type(but);
+
+float log_min = (scale_type == PROP_SCALE_LOG) ? max_ff(softmin, 
UI_PROP_SCALE_LOG_MIN) : 0.0f;
 
 if ((but->type == UI_BTYPE_NUM) && (ui_but_is_cursor_warp(but) == false)) {
   uiButNumber *number_but = (uiButNumber *)but;
+
+  if (scale_type == PROP_SCALE_LOG) {
+log_min = max_ff(log_min, powf(10, -number_but->precision) * 0.5f);
+  }
   /* Use a minimum so we have a predictable range,
* otherwise some float buttons get a large range. */
   const float value_step_float_min = 0.1f;
@@ -3989,7 +4014,31 @@ static void ui_numedit_begin(uiBut *but, 
uiHandleButtonData *data)
   }
 }
 
-data->dragfstart = (softrange == 0.0f) ? 0.0f : ((float)data->value - 
softmin) / softrange;
+if (softrange == 0.0f) {
+  data->dragfstart = 0.0f;
+}
+else {
+  switch (scale_type) {
+case PROP_SCALE_LINEAR: {
+  data->dragfstart = ((float)data->value - softmin) / softrange;
+  break;
+}
+case PROP_SCALE_LOG: {
+  BLI_assert(log_min !

[Bf-blender-cvs] [e95f71bf152] master: UI: use non-linear sliders

2021-05-17 Thread Henrik Dick
Commit: e95f71bf152ad227383c3512f848cd924512a68b
Author: Henrik Dick
Date:   Mon May 17 17:33:00 2021 +1000
Branches: master
https://developer.blender.org/rBe95f71bf152ad227383c3512f848cd924512a68b

UI: use non-linear sliders

* Boolean Modifier > Fast > Overlap Threshold (Logarithmic).
* Remesh Modifier > Voxel > Voxel Size (Logarithmic).
* Sculpt > Dyntopo > Detail Size (Cubic).

Ref D9074

===

M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/makesrna/intern/rna_sculpt_paint.c

===

diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index e3fb443951f..674e5845ccb 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -2781,7 +2781,8 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
   prop = RNA_def_property(srna, "double_threshold", PROP_FLOAT, PROP_DISTANCE);
   RNA_def_property_float_sdna(prop, NULL, "double_threshold");
   RNA_def_property_range(prop, 0, 1.0f);
-  RNA_def_property_ui_range(prop, 0, 1, 0.0001, 6);
+  RNA_def_property_ui_range(prop, 0, 1, 1.0, 6);
+  RNA_def_property_ui_scale_type(prop, PROP_SCALE_LOG);
   RNA_def_property_ui_text(
   prop, "Overlap Threshold", "Threshold for checking overlapping 
geometry");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
@@ -5530,6 +5531,7 @@ static void rna_def_modifier_remesh(BlenderRNA *brna)
   RNA_def_property_float_sdna(prop, NULL, "voxel_size");
   RNA_def_property_range(prop, 0.0001f, FLT_MAX);
   RNA_def_property_ui_range(prop, 0.0001, 2, 0.1, 3);
+  RNA_def_property_ui_scale_type(prop, PROP_SCALE_LOG);
   RNA_def_property_ui_text(prop,
"Voxel Size",
"Size of the voxel in object space used for volume 
evaluation. Lower "
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c 
b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 4481555b931..81acedb76f2 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -786,7 +786,8 @@ static void rna_def_sculpt(BlenderRNA *brna)
   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, 
"rna_Sculpt_ShowMask_update");
 
   prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL);
-  RNA_def_property_ui_range(prop, 0.5, 40.0, 10, 2);
+  RNA_def_property_ui_range(prop, 0.5, 40.0, 0.1, 2);
+  RNA_def_property_ui_scale_type(prop, PROP_SCALE_CUBIC);
   RNA_def_property_ui_text(
   prop, "Detail Size", "Maximum edge length for dynamic topology sculpting 
(in pixels)");
   RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a58a8296d9d] blender-v2.93-release: Fix T85470: Simple deform modifier causes artifacts at low angles

2021-04-30 Thread Henrik Dick
Commit: a58a8296d9da785920575725bbb41fd5481b5d2d
Author: Henrik Dick
Date:   Fri Apr 30 23:38:31 2021 +1000
Branches: blender-v2.93-release
https://developer.blender.org/rBa58a8296d9da785920575725bbb41fd5481b5d2d

Fix T85470: Simple deform modifier causes artifacts at low angles

The formula used to compute the bend did subtraction of two big numbers
to get the position. Changed to find the delta and add that,
by rearranging the formula into a more numerically stable form.

Reviewed By: mano-wii, campbellbarton

Ref D11074

===

M   source/blender/modifiers/intern/MOD_simpledeform.c

===

diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c 
b/source/blender/modifiers/intern/MOD_simpledeform.c
index ea31bdc6e31..951eacdecda 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -170,10 +170,12 @@ static void simpleDeform_bend(const float factor,
   sint = sinf(theta);
   cost = cosf(theta);
 
+  /* NOTE: the operations below a susceptible to float precision errors
+   * regarding the order of operations, take care when changing, see: T85470 */
   switch (axis) {
 case 0:
   r_co[0] = x;
-  r_co[1] = (y - 1.0f / factor) * cost + 1.0f / factor;
+  r_co[1] = y * cost + (1.0f - cost) / factor;
   r_co[2] = -(y - 1.0f / factor) * sint;
   {
 r_co[0] += dcut[0];
@@ -182,7 +184,7 @@ static void simpleDeform_bend(const float factor,
   }
   break;
 case 1:
-  r_co[0] = (x - 1.0f / factor) * cost + 1.0f / factor;
+  r_co[0] = x * cost + (1.0f - cost) / factor;
   r_co[1] = y;
   r_co[2] = -(x - 1.0f / factor) * sint;
   {
@@ -193,7 +195,7 @@ static void simpleDeform_bend(const float factor,
   break;
 default:
   r_co[0] = -(y - 1.0f / factor) * sint;
-  r_co[1] = (y - 1.0f / factor) * cost + 1.0f / factor;
+  r_co[1] = y * cost + (1.0f - cost) / factor;
   r_co[2] = z;
   {
 r_co[0] += cost * dcut[0];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [39bead4d51e] master: Fix simple solidify wrong custom data on large ngons

2021-03-30 Thread Henrik Dick
Commit: 39bead4d51e5e96188feab4fb45d453fc7b1f2a6
Author: Henrik Dick
Date:   Tue Mar 30 19:10:13 2021 +1100
Branches: master
https://developer.blender.org/rB39bead4d51e5e96188feab4fb45d453fc7b1f2a6

Fix simple solidify wrong custom data on large ngons

Fixes an unreported issue that vertex data on large ngons (>255)
is messed up due to type conversion to char and back to int.

Ref D10734

===

M   source/blender/modifiers/intern/MOD_solidify_extrude.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c 
b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 99069919120..a77a6e595ad 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -216,7 +216,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, 
const ModifierEvalContex
   numVerts, sizeof(*old_vert_arr), "old_vert_arr in solidify");
 
   uint *edge_users = NULL;
-  char *edge_order = NULL;
+  int *edge_order = NULL;
 
   float(*vert_nors)[3] = NULL;
   float(*poly_nors)[3] = NULL;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9b11a7776f2] master: Modifier: Add "Connected" mode to the weld modifier

2020-12-08 Thread Henrik Dick
Commit: 9b11a7776f2ab8ac42e835a17ed7566fd80a4b8c
Author: Henrik Dick
Date:   Wed Dec 9 11:10:15 2020 +1100
Branches: master
https://developer.blender.org/rB9b11a7776f2ab8ac42e835a17ed7566fd80a4b8c

Modifier: Add "Connected" mode to the weld modifier

Implement improvement from T73139 for merging along edges.
It is now called "Connected" mode, while the default is called "All".

With the recent performance improvement, the Connected Mode is in some
cases only double the speed than the usual merge all strategy but in
other cases it may be even faster. The bottleneck is somewhere further
down the line of merging geometry.

The motivation for this patch came from T80897, because the merging in
complex solidify is making it very slow.
Now merging can be removed from solidify without greater consequences,
as this is just a quicker and more advanced algorithm to do the same
thing that solidify currently does slowly.

Reviewed by: mano-wii, campbellbarton

Ref D8966

===

M   source/blender/makesdna/DNA_modifier_defaults.h
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_weld.c

===

diff --git a/source/blender/makesdna/DNA_modifier_defaults.h 
b/source/blender/makesdna/DNA_modifier_defaults.h
index f73f43ddade..793a229bdc5 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -801,6 +801,7 @@
 #define _DNA_DEFAULT_WeldModifierData \
   { \
 .merge_dist = 0.001f, \
+.mode = MOD_WELD_ALL_MODE, \
 .defgrp_name = "", \
   }
 
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index af7d7e9310f..d99564ff33e 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -2004,7 +2004,8 @@ typedef struct WeldModifierData {
   /* Name of vertex group to use to mask, MAX_VGROUP_NAME. */
   char defgrp_name[64];
 
-  short flag;
+  char mode;
+  char flag;
   char _pad[2];
 } WeldModifierData;
 
@@ -2013,6 +2014,12 @@ enum {
   MOD_WELD_INVERT_VGROUP = (1 << 0),
 };
 
+/* #WeldModifierData.mode */
+enum {
+  MOD_WELD_ALL_MODE = 0,
+  MOD_WELD_CONNECTED_MODE = 1,
+};
+
 typedef struct DataTransferModifierData {
   ModifierData modifier;
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index f0836ae59ad..4ce859ddce9 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -6231,6 +6231,12 @@ static void rna_def_modifier_weld(BlenderRNA *brna)
   StructRNA *srna;
   PropertyRNA *prop;
 
+  static const EnumPropertyItem mode_items[] = {
+  {MOD_WELD_ALL_MODE, "ALL", 0, "All", "Full merge by distance"},
+  {MOD_WELD_CONNECTED_MODE, "CONNECTED", 0, "Connected", "Only merge along 
the edges"},
+  {0, NULL, 0, NULL, NULL},
+  };
+
   srna = RNA_def_struct(brna, "WeldModifier", "Modifier");
   RNA_def_struct_ui_text(srna, "Weld Modifier", "Weld modifier");
   RNA_def_struct_sdna(srna, "WeldModifierData");
@@ -6238,6 +6244,11 @@ static void rna_def_modifier_weld(BlenderRNA *brna)
 
   RNA_define_lib_overridable(true);
 
+  prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_items(prop, mode_items);
+  RNA_def_property_ui_text(prop, "Mode", "Mode defines the merge rule");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
   RNA_def_property_float_sdna(prop, NULL, "merge_dist");
   RNA_def_property_range(prop, 0, FLT_MAX);
diff --git a/source/blender/modifiers/intern/MOD_weld.c 
b/source/blender/modifiers/intern/MOD_weld.c
index 1a25c24fedc..a50323a24ee 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -1567,6 +1567,12 @@ static bool bvhtree_weld_overlap_cb(void *userdata, int 
index_a, int index_b, in
 }
 #endif
 
+/** Use for #MOD_WELD_CONNECTED_MODE calculation. */
+struct WeldVertexCluster {
+  float co[3];
+  uint merged_verts;
+};
+
 static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const 
ModifierEvalContext *ctx, Mesh *mesh)
 {
   Mesh *result = mesh;
@@ -1606,6 +1612,7 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, 
const ModifierEvalContex
* This indicates which vert it is or is going to be merged. */
   uint *vert_dest_map = MEM_malloc_arrayN(totvert, sizeof(*vert_dest_map), 
__func__);
   uint vert_kill_len = 0;
+  if (wmd->mode == MOD_WELD_ALL_MODE)
 #ifdef USE_BVHT

[Bf-blender-cvs] [a6c4e39876d] master: Add Custom Object Space to Constraints

2020-12-03 Thread Henrik Dick
Commit: a6c4e39876d8a0765290312f6d8c0175274114cd
Author: Henrik Dick
Date:   Thu Dec 3 10:42:29 2020 +0100
Branches: master
https://developer.blender.org/rBa6c4e39876d8a0765290312f6d8c0175274114cd

Add Custom Object Space to Constraints

Add Custom Space to the list of space conversions for constraints.

Constraints can use World Space, Local Space, Pose Space, Local with
Parent, and now also Custom Space with a custom object to define the
evaluation space.

The Custom Space option uses the Local Space of an other
object/bone/vertex group. If selected on owner or target it will show a
box for object selection. If an armature is selected, then it will also
show a box for bone selection. If a mesh object is selected it will show
the option for using the local space of a vertex group.

Reviewed By: #animation_rigging, sybren, Severin, angavrilov

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

===

M   release/scripts/startup/bl_ui/properties_constraint.py
M   source/blender/blenkernel/BKE_constraint.h
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/blenkernel/intern/fcurve_driver.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesrna/intern/rna_constraint.c
M   source/blender/makesrna/intern/rna_object_api.c
M   tests/python/bl_constraints.py

===

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py 
b/release/scripts/startup/bl_ui/properties_constraint.py
index f46e9f9727f..71a7b056d07 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -85,14 +85,23 @@ class ConstraintButtonsPanel(Panel):
 row.operator("constraint.disable_keep_transform", text="", 
icon='CANCEL')
 
 @staticmethod
-def space_template(layout, con, target=True, owner=True):
+def space_template(layout, con, target=True, owner=True, separator=True):
 if target or owner:
-layout.separator()
+if separator:
+layout.separator()
 if target:
 layout.prop(con, "target_space", text="Target")
 if owner:
 layout.prop(con, "owner_space", text="Owner")
 
+if con.target_space == 'CUSTOM' or con.owner_space == 'CUSTOM':
+col = layout.column()
+col.prop(con, "space_object")
+if con.space_object and con.space_object.type == 'ARMATURE':
+col.prop_search(con, "space_subtarget", 
con.space_object.data, "bones", text="Bone")
+elif con.space_object and con.space_object.type in {'MESH', 
'LATTICE'}:
+col.prop_search(con, "space_subtarget", con.space_object, 
"vertex_groups", text="Vertex Group")
+
 @staticmethod
 def target_template(layout, con, subtargets=True):
 col = layout.column()
@@ -237,7 +246,7 @@ class ConstraintButtonsPanel(Panel):
 row.label(icon="BLANK1")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -306,7 +315,7 @@ class ConstraintButtonsPanel(Panel):
 row.prop_decorator(con, "max_z")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -375,7 +384,7 @@ class ConstraintButtonsPanel(Panel):
 row.prop_decorator(con, "max_z")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -483,7 +492,7 @@ class ConstraintButtonsPanel(Panel):
 
 layout.prop(con, "volume")
 
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -1117,7 +1126,7 @@ class ConstraintButtonsSubPanel(Panel):
 col = layout.column()
 col.active = not con.use_eval_time
 col.prop(con, "transform_channel", text="Channel")
-col.prop(con, "target_space")
+ConstraintButtonsPanel.space_template(col, con, target=True, 
owner=False, separator=False)
 
 sub = col.column(align=True)
 sub.prop(con, "min", text="Range Min")
diff --git a/sour

[Bf-blender-cvs] [31fda0363d5] temp-angavrilov-constraints: Add Custom Space to Constraints

2020-12-02 Thread Henrik Dick
Commit: 31fda0363d55f9b451427b6693591a1be062e905
Author: Henrik Dick
Date:   Mon Nov 23 19:26:53 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB31fda0363d55f9b451427b6693591a1be062e905

Add Custom Space to Constraints

Constraints can currently only use World Space, Local Space, Pose Space, Local 
with Parent.
This patch adds Custom Space with a custom object to define the evaluation 
space.

The Custom Space option uses the Local Space of an other object/bone/vertex 
group.
If selected on owner or target it will show a box for object selection.
If an armature is selected, then it will also show a box for bone selection.
If a mesh object is selected it will show the option for using the local space 
of a vertex group.

It looks like this in the UI:
{F8731291}

The motivation for this patch is the following situation.
If you have a copy location constraint in your armature you are already limited 
when you want to use a specific axis. It can be done, but its unneccessarily 
difficult (as far as I know). But the situation is close to impossible as soon 
as you have a root bone in your armature (which I was told you always want). I 
need to only copy the location along a custom axis for a lot of things. The 
same goes for copy rotation/scale and all the limit constraints because I need 
to make that axis relat [...]

Here is a demo video:
{F8498960}
This is the file of that video:
{F8647541}

This is the file for the tests included in this patch:
{F8699677}

File intended for acceptance test:
{F8879818}

Reviewed By: #animation_rigging, sybren, Severin, angavrilov

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

===

M   release/scripts/startup/bl_ui/properties_constraint.py
M   source/blender/blenkernel/BKE_constraint.h
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/blenkernel/intern/fcurve_driver.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesrna/intern/rna_constraint.c
M   source/blender/makesrna/intern/rna_object_api.c
M   tests/python/bl_constraints.py

===

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py 
b/release/scripts/startup/bl_ui/properties_constraint.py
index f46e9f9727f..71a7b056d07 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -85,14 +85,23 @@ class ConstraintButtonsPanel(Panel):
 row.operator("constraint.disable_keep_transform", text="", 
icon='CANCEL')
 
 @staticmethod
-def space_template(layout, con, target=True, owner=True):
+def space_template(layout, con, target=True, owner=True, separator=True):
 if target or owner:
-layout.separator()
+if separator:
+layout.separator()
 if target:
 layout.prop(con, "target_space", text="Target")
 if owner:
 layout.prop(con, "owner_space", text="Owner")
 
+if con.target_space == 'CUSTOM' or con.owner_space == 'CUSTOM':
+col = layout.column()
+col.prop(con, "space_object")
+if con.space_object and con.space_object.type == 'ARMATURE':
+col.prop_search(con, "space_subtarget", 
con.space_object.data, "bones", text="Bone")
+elif con.space_object and con.space_object.type in {'MESH', 
'LATTICE'}:
+col.prop_search(con, "space_subtarget", con.space_object, 
"vertex_groups", text="Vertex Group")
+
 @staticmethod
 def target_template(layout, con, subtargets=True):
 col = layout.column()
@@ -237,7 +246,7 @@ class ConstraintButtonsPanel(Panel):
 row.label(icon="BLANK1")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -306,7 +315,7 @@ class ConstraintButtonsPanel(Panel):
 row.prop_decorator(con, "max_z")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -375,7 +384,7 @@ class ConstraintButtonsPanel(Panel):
 row.prop_decorator(con, "max_z")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence

[Bf-blender-cvs] [ec39d8de4ad] master: Transform: Correct Mirror for Object Mode along arbitrary axis

2020-12-02 Thread Henrik Dick
Commit: ec39d8de4adf46161d81fb525a73278fe08a8704
Author: Henrik Dick
Date:   Wed Dec 2 09:09:26 2020 -0300
Branches: master
https://developer.blender.org/rBec39d8de4adf46161d81fb525a73278fe08a8704

Transform: Correct Mirror for Object Mode along arbitrary axis

This fixes T68521, T82334.

The object are not properly mirrored in object mode.

For mirroring an object that has an arbitrary rotation along the X axis
this is the procedure:
1. mirror x location.
2. negate x scale of the
3. negate y and z component of the rotation (independent of which rotation mode 
is used).

This knowledge applies now for all angles and axes to finally make the
mirror operation work in object mode.

The new mirror function has the downside that it can not (in this form)
be used with proportional editing.

This is no problem since the old behavior can still be replicated by
scaling with -1 along any axis.

The solution to get perfect mirrors can not work for scaling in general,
because in that case there could be scew created.

Reviewed By: mano-wii

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

===

M   source/blender/editors/transform/transform_mode.c
M   source/blender/editors/transform/transform_mode.h
M   source/blender/editors/transform/transform_mode_mirror.c
M   source/blender/editors/transform/transform_ops.c

===

diff --git a/source/blender/editors/transform/transform_mode.c 
b/source/blender/editors/transform/transform_mode.c
index af0a8e5e505..a4d999b868d 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -228,7 +228,7 @@ static void protectedAxisAngleBits(
   }
 }
 
-static void protectedSizeBits(short protectflag, float size[3])
+void protectedSizeBits(short protectflag, float size[3])
 {
   if (protectflag & OB_LOCK_SCALEX) {
 size[0] = 1.0f;
@@ -431,7 +431,7 @@ static void constraintRotLim(TransInfo *UNUSED(t), 
TransData *td)
   }
 }
 
-static void constraintSizeLim(TransInfo *t, TransData *td)
+void constraintSizeLim(TransInfo *t, TransData *td)
 {
   if (td->con && td->ext) {
 const bConstraintTypeInfo *cti = 
BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_SIZELIMIT);
diff --git a/source/blender/editors/transform/transform_mode.h 
b/source/blender/editors/transform/transform_mode.h
index df7d10d1028..7a05506e12c 100644
--- a/source/blender/editors/transform/transform_mode.h
+++ b/source/blender/editors/transform/transform_mode.h
@@ -44,7 +44,9 @@ int transform_mode_really_used(struct bContext *C, int mode);
 bool transdata_check_local_center(TransInfo *t, short around);
 bool transform_mode_is_changeable(const int mode);
 void protectedTransBits(short protectflag, float vec[3]);
+void protectedSizeBits(short protectflag, float size[3]);
 void constraintTransLim(TransInfo *t, TransData *td);
+void constraintSizeLim(TransInfo *t, TransData *td);
 void postInputRotation(TransInfo *t, float values[3]);
 void headerRotation(TransInfo *t, char *str, float final);
 void ElementRotation_ex(TransInfo *t,
diff --git a/source/blender/editors/transform/transform_mode_mirror.c 
b/source/blender/editors/transform/transform_mode_mirror.c
index 1440553de51..3aa99975fda 100644
--- a/source/blender/editors/transform/transform_mode_mirror.c
+++ b/source/blender/editors/transform/transform_mode_mirror.c
@@ -24,8 +24,10 @@
 #include 
 
 #include "BLI_math.h"
+#include "BLI_math_bits.h"
 #include "BLI_string.h"
 
+#include "BKE_armature.h"
 #include "BKE_context.h"
 
 #include "ED_screen.h"
@@ -41,9 +43,130 @@
 /** \name Transform (Mirror)
  * \{ */
 
+/**
+ * Mirrors an object by negating the scale of the object on the mirror axis, 
reflecting the
+ * location and adjusting the rotation.
+ *
+ * \param axis: Either the axis to mirror on (0 = x, 1 = y, 2 = z) in 
transform space or -1 for no
+ * axis mirror.
+ * \param flip: If true, a mirror on all axis will be performed additionally 
(point
+ * reflection).
+ */
+static void ElementMirror(TransInfo *t, TransDataContainer *tc, TransData *td, 
int axis, bool flip)
+{
+  if ((t->flag & T_V3D_ALIGN) == 0 && td->ext) {
+/* Size checked needed since the 3D cursor only uses rotation fields. */
+if (td->ext->size) {
+  float fsize[] = {1.0, 1.0, 1.0};
+
+  if (axis >= 0) {
+fsize[axis] = -fsize[axis];
+  }
+  if (flip) {
+negate_v3(fsize);
+  }
+
+  protectedSizeBits(td->protectflag, fsize);
+
+  mul_v3_v3v3(td->ext->size, td->ext->isize, fsize);
+
+  constraintSizeLim(t, td);
+}
+
+float rmat[3][3];
+if (axis >= 0) {
+  float imat[3][3];
+  mul_m3_m3m3(rmat, t->spacemtx_inv, td->axismtx);
+  rmat[axis][0] = -rmat[axis][0];
+  rmat[axis][

[Bf-blender-cvs] [f1190ff6c5e] temp-angavrilov-constraints: Add Custom Space to Constraints

2020-12-02 Thread Henrik Dick
Commit: f1190ff6c5ef5a74adab0efcc7631771d96eb4ed
Author: Henrik Dick
Date:   Mon Nov 23 19:26:53 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rBf1190ff6c5ef5a74adab0efcc7631771d96eb4ed

Add Custom Space to Constraints

Constraints can currently only use World Space, Local Space, Pose Space, Local 
with Parent.
This patch adds Custom Space with a custom object to define the evaluation 
space.

The Custom Space option uses the Local Space of an other object/bone/vertex 
group.
If selected on owner or target it will show a box for object selection.
If an armature is selected, then it will also show a box for bone selection.
If a mesh object is selected it will show the option for using the local space 
of a vertex group.

It looks like this in the UI:
{F8731291}

The motivation for this patch is the following situation.
If you have a copy location constraint in your armature you are already limited 
when you want to use a specific axis. It can be done, but its unneccessarily 
difficult (as far as I know). But the situation is close to impossible as soon 
as you have a root bone in your armature (which I was told you always want). I 
need to only copy the location along a custom axis for a lot of things. The 
same goes for copy rotation/scale and all the limit constraints because I need 
to make that axis relat [...]

Here is a demo video:
{F8498960}
This is the file of that video:
{F8647541}

This is the file for the tests included in this patch:
{F8699677}

File intended for acceptance test:
{F8879818}

Reviewed By: #animation_rigging, sybren, Severin, angavrilov

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

===

M   release/scripts/startup/bl_ui/properties_constraint.py
M   source/blender/blenkernel/BKE_constraint.h
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/blenkernel/intern/fcurve_driver.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesrna/intern/rna_constraint.c
M   source/blender/makesrna/intern/rna_object_api.c
M   tests/python/bl_constraints.py

===

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py 
b/release/scripts/startup/bl_ui/properties_constraint.py
index f46e9f9727f..71a7b056d07 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -85,14 +85,23 @@ class ConstraintButtonsPanel(Panel):
 row.operator("constraint.disable_keep_transform", text="", 
icon='CANCEL')
 
 @staticmethod
-def space_template(layout, con, target=True, owner=True):
+def space_template(layout, con, target=True, owner=True, separator=True):
 if target or owner:
-layout.separator()
+if separator:
+layout.separator()
 if target:
 layout.prop(con, "target_space", text="Target")
 if owner:
 layout.prop(con, "owner_space", text="Owner")
 
+if con.target_space == 'CUSTOM' or con.owner_space == 'CUSTOM':
+col = layout.column()
+col.prop(con, "space_object")
+if con.space_object and con.space_object.type == 'ARMATURE':
+col.prop_search(con, "space_subtarget", 
con.space_object.data, "bones", text="Bone")
+elif con.space_object and con.space_object.type in {'MESH', 
'LATTICE'}:
+col.prop_search(con, "space_subtarget", con.space_object, 
"vertex_groups", text="Vertex Group")
+
 @staticmethod
 def target_template(layout, con, subtargets=True):
 col = layout.column()
@@ -237,7 +246,7 @@ class ConstraintButtonsPanel(Panel):
 row.label(icon="BLANK1")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -306,7 +315,7 @@ class ConstraintButtonsPanel(Panel):
 row.prop_decorator(con, "max_z")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence(layout, con)
 
@@ -375,7 +384,7 @@ class ConstraintButtonsPanel(Panel):
 row.prop_decorator(con, "max_z")
 
 layout.prop(con, "use_transform_limit")
-layout.prop(con, "owner_space")
+self.space_template(layout, con, target=False, owner=True)
 
 self.draw_influence

[Bf-blender-cvs] [a9dc3fbef89] master: Fix T80893: Complex solidify special case with singularity

2020-10-05 Thread Henrik Dick
Commit: a9dc3fbef898720d564afaa57deedb483bb75ba8
Author: Henrik Dick
Date:   Fri Oct 2 00:21:22 2020 +0200
Branches: master
https://developer.blender.org/rBa9dc3fbef898720d564afaa57deedb483bb75ba8

Fix T80893: Complex solidify special case with singularity

Ref D8929

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 20db13d4540..fda1e3fe08b 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -2190,8 +2190,10 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 
 NewEdgeRef *edge1 = new_edges[0];
 NewEdgeRef *edge2 = new_edges[1];
-const bool v1_singularity = edge1->link_edge_groups[0]->is_singularity;
-const bool v2_singularity = edge1->link_edge_groups[1]->is_singularity;
+const bool v1_singularity = edge1->link_edge_groups[0]->is_singularity 
&&
+edge2->link_edge_groups[0]->is_singularity;
+const bool v2_singularity = edge1->link_edge_groups[1]->is_singularity 
&&
+edge2->link_edge_groups[1]->is_singularity;
 if (v1_singularity && v2_singularity) {
   continue;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ad16b2c5153] master: Fix T80895: Complex solidify compare edges by content

2020-10-05 Thread Henrik Dick
Commit: ad16b2c51532fd8f401d981e421367407bf84e94
Author: Henrik Dick
Date:   Fri Oct 2 00:17:53 2020 +0200
Branches: master
https://developer.blender.org/rBad16b2c51532fd8f401d981e421367407bf84e94

Fix T80895: Complex solidify compare edges by content

Even if the index of the edge is not equal the content can be equal
if it has been merged. So compare the content.

Ref D8931

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 463b55b1ccc..20db13d4540 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -619,7 +619,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
   uint *e_adj_faces_faces = e_adj_faces->faces;
   bool *e_adj_faces_reversed = e_adj_faces->faces_reversed;
   const uint faces_len = e_adj_faces->faces_len;
-  if (e != i) {
+  if (e_adj_faces_faces != adj_faces->faces) {
 /* Find index of e in #adj_faces. */
 for (face_index = 0;
  face_index < faces_len && 
e_adj_faces_faces[face_index] != face;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [72e741ee62b] master: Fix T80897: Complex solidify crash when special ngons are merged

2020-10-05 Thread Henrik Dick
Commit: 72e741ee62b54cbda9a7ad735cc2c6e4957c3af0
Author: Henrik Dick
Date:   Fri Oct 2 00:24:25 2020 +0200
Branches: master
https://developer.blender.org/rB72e741ee62b54cbda9a7ad735cc2c6e4957c3af0

Fix T80897: Complex solidify crash when special ngons are merged

This has serious performance implications as the additional check makes
it O(N^2) when there are a lot of merged vertices.
The goal is to move the merging to the weld modifier where it would
be much easier to optimize.

Ref D8946

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index fda1e3fe08b..47adb7ba0bd 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -366,41 +366,73 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 if (edge_adj_faces_len[i] > 0) {
   uint v1 = vm[ed->v1];
   uint v2 = vm[ed->v2];
-  if (v1 != v2) {
-if (v2 < v1) {
-  SWAP(uint, v1, v2);
-}
-sub_v3_v3v3(edgedir, orig_mvert_co[v2], orig_mvert_co[v1]);
-orig_edge_lengths[i] = len_squared_v3(edgedir);
-if (orig_edge_lengths[i] <= merge_tolerance_sqr) {
-  mul_v3_fl(edgedir,
-(combined_verts[v2] + 1) /
-(float)(combined_verts[v1] + combined_verts[v2] + 
2));
-  add_v3_v3(orig_mvert_co[v1], edgedir);
-  for (uint j = v2; j < numVerts; j++) {
-if (vm[j] == v2) {
-  vm[j] = v1;
-}
-  }
-  vert_adj_edges_len[v1] += vert_adj_edges_len[v2];
-  vert_adj_edges_len[v2] = 0;
-  combined_verts[v1] += combined_verts[v2] + 1;
+  if (v1 == v2) {
+continue;
+  }
 
-  if (do_shell) {
-numNewLoops -= edge_adj_faces_len[i] * 2;
+  if (v2 < v1) {
+SWAP(uint, v1, v2);
+  }
+  sub_v3_v3v3(edgedir, orig_mvert_co[v2], orig_mvert_co[v1]);
+  orig_edge_lengths[i] = len_squared_v3(edgedir);
+
+  if (orig_edge_lengths[i] <= merge_tolerance_sqr) {
+/* Merge verts. But first check if that would create a higher poly 
count. */
+/* This check is very slow. It would need the vertex edge links to 
get
+ * accelerated that are not yet available at this point. */
+bool can_merge = true;
+for (uint k = 0; k < numEdges && can_merge; k++) {
+  if (k != i && edge_adj_faces_len[k] > 0 &&
+  (ELEM(vm[orig_medge[k].v1], v1, v2) != 
ELEM(vm[orig_medge[k].v2], v1, v2))) {
+for (uint j = 0; j < edge_adj_faces[k]->faces_len && 
can_merge; j++) {
+  mp = orig_mpoly + edge_adj_faces[k]->faces[j];
+  uint changes = 0;
+  int cur = mp->totloop - 1;
+  for (int next = 0; next < mp->totloop && changes <= 2; 
next++) {
+uint cur_v = vm[orig_mloop[mp->loopstart + cur].v];
+uint next_v = vm[orig_mloop[mp->loopstart + next].v];
+changes += (ELEM(cur_v, v1, v2) != ELEM(next_v, v1, v2));
+cur = next;
+  }
+  can_merge = can_merge && changes <= 2;
+}
   }
-
-  edge_adj_faces_len[i] = 0;
-  MEM_freeN(edge_adj_faces[i]->faces);
-  MEM_freeN(edge_adj_faces[i]->faces_reversed);
-  MEM_freeN(edge_adj_faces[i]);
-  edge_adj_faces[i] = NULL;
 }
-else {
-  orig_edge_lengths[i] = sqrtf(orig_edge_lengths[i]);
+
+if (!can_merge) {
+  orig_edge_lengths[i] = 0.0f;
   vert_adj_edges_len[v1]++;
   vert_adj_edges_len[v2]++;
+  continue;
 }
+
+mul_v3_fl(edgedir,
+  (combined_verts[v2] + 1) /
+  (float)(combined_verts[v1] + combined_verts[v2] + 
2));
+add_v3_v3(orig_mvert_co[v1], edgedir);
+for (uint j = v2; j < numVerts; j++) {
+  if (vm[j] == v2) {
+vm[j] = v1;
+  }
+}
+vert_adj_edges_len[v1] += vert_adj_edges_len[v2];
+vert_adj_edges_len[v2] = 0;
+combined_verts[v1] += combined_verts[v2] + 1;
+
+if (do_shell) {
+  numNewLoops -= edge_adj_faces_len[i] * 2;
+}
+
+edge_adj_faces_l

[Bf-blender-cvs] [35708db5d2b] master: Modifiers: Use vertex group options for complex solidify flat faces

2020-10-05 Thread Henrik Dick
Commit: 35708db5d2b420cc628f71fb43387ce95b61ebbe
Author: Henrik Dick
Date:   Fri Oct 2 00:12:25 2020 +0200
Branches: master
https://developer.blender.org/rB35708db5d2b420cc628f71fb43387ce95b61ebbe

Modifiers: Use vertex group options for complex solidify flat faces

Ref D8945

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 6dd04745d07..463b55b1ccc 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1327,6 +1327,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
 scalar_vgroup = min_ff(BKE_defvert_find_weight(dv, defgrp_index), 
scalar_vgroup);
   }
 }
+scalar_vgroup = offset_fac_vg + (scalar_vgroup * offset_fac_vg_inv);
 face_weight[i] = scalar_vgroup;
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1454865ebb9] master: Fix T80269: Match material offset in solidify modes

2020-10-05 Thread Henrik Dick
Commit: 1454865ebb996bdcd9007abb440772335a285a36
Author: Henrik Dick
Date:   Thu Oct 1 23:54:04 2020 +0200
Branches: master
https://developer.blender.org/rB1454865ebb996bdcd9007abb440772335a285a36

Fix T80269: Match material offset in solidify modes

This commit to complex solidify swaps the side of the geometry which
is affected by the material offset when the normal flip option is
enabled. This matches simple solidify and is considered correct/useful.

Ref D8948

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 1e0269617ec..6dd04745d07 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -2391,7 +2391,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData 
*md,
   CustomData_copy_data(>pdata, >pdata, (int)(i / 2), 
(int)poly_index, 1);
   mpoly[poly_index].loopstart = (int)loop_index;
   mpoly[poly_index].totloop = (int)k;
-  mpoly[poly_index].mat_nr = fr->face->mat_nr + (fr->reversed ? 
mat_ofs : 0);
+  mpoly[poly_index].mat_nr = fr->face->mat_nr + (fr->reversed != 
do_flip ? mat_ofs : 0);
   CLAMP(mpoly[poly_index].mat_nr, 0, mat_nr_max);
   mpoly[poly_index].flag = fr->face->flag;
   if (fr->reversed != do_flip) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bea4505744f] master: Fix Tests for Weld Modifier with KD-Tree

2020-09-25 Thread Henrik Dick
Commit: bea4505744f0649925fe8e320cbd1150e1182725
Author: Henrik Dick
Date:   Fri Sep 25 15:17:02 2020 -0300
Branches: master
https://developer.blender.org/rBbea4505744f0649925fe8e320cbd1150e1182725

Fix Tests for Weld Modifier with KD-Tree

Fixes the failing tests and reintroduces the KD-Tree solution.

Reviewed By: mano-wii

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

===

M   source/blender/modifiers/intern/MOD_weld.c
M   source/tools
M   tests/python/modifiers.py

===

diff --git a/source/blender/modifiers/intern/MOD_weld.c 
b/source/blender/modifiers/intern/MOD_weld.c
index 16f1dcec907..46e4f147e20 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -29,7 +29,7 @@
 
 //#define USE_WELD_DEBUG
 //#define USE_WELD_NORMALS
-#define USE_BVHTREEKDOP
+//#define USE_BVHTREEKDOP
 
 #include "MEM_guardedalloc.h"
 
@@ -1696,7 +1696,7 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, 
const ModifierEvalContex
 
 BLI_kdtree_3d_balance(tree);
 vert_kill_len = BLI_kdtree_3d_calc_duplicates_fast(
-tree, wmd->merge_dist, false, (int *)vert_dest_map);
+tree, wmd->merge_dist, true, (int *)vert_dest_map);
 BLI_kdtree_3d_free(tree);
   }
 #endif
diff --git a/source/tools b/source/tools
index ff9928bc44e..2afbb8ec472 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit ff9928bc44e80ec30c78369bf1518599254a0032
+Subproject commit 2afbb8ec472cac5102eb239f57b006f8c9387685
diff --git a/tests/python/modifiers.py b/tests/python/modifiers.py
index 4bbcf226aba..ba156cef8ea 100644
--- a/tests/python/modifiers.py
+++ b/tests/python/modifiers.py
@@ -186,7 +186,7 @@ def main():
 ["testMergedWeld", "expectedMergedWeld",
  [ModifierSpec("weld", 'WELD', {"merge_threshold": 0.021})]],
 ["testMergedAllWeld", "expectedMergedAllWeld",
- [ModifierSpec("weld", 'WELD', {"merge_threshold": 1.1})]],
+ [ModifierSpec("weld", 'WELD', {"merge_threshold": 1.8})]],
 ["testMergedNoneWeld", "expectedMergedNoneWeld",
  [ModifierSpec("weld", 'WELD', {"merge_threshold": 0.019})]],

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [744f81c936c] master: Weld Modifier: Use KD Tree in detecting the geometry to be welded

2020-09-24 Thread Henrik Dick
Commit: 744f81c936cbd946d2eb8035b9714b5f6bfbdc8c
Author: Henrik Dick
Date:   Thu Sep 24 15:16:50 2020 -0300
Branches: master
https://developer.blender.org/rB744f81c936cbd946d2eb8035b9714b5f6bfbdc8c

Weld Modifier: Use KD Tree in detecting the geometry to be welded

This commit replaces the BVH Tree currently used by the Weld Modifier
with the KD Tree used by `Merge > By Distance`.

This changes the result of the Weld Modifier to more closely match
`Merge > By Distance`.

There is also a big performance advantage.

Here is an overview (models in D8995):

| 2.90 (Duplicate Limit = 0) | 2.90 (Duplicate Limit = 1) | master (BVH) 
(Duplicate Limit = 1) | patch (KD) |
| 1.69s| 0.17s | 0.12s | 0.029s |

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

===

M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_weld.c

===

diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 9a5b5b8c2ca..c0716388f28 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1978,12 +1978,11 @@ typedef struct WeldModifierData {
 
   /* The limit below which to merge vertices. */
   float merge_dist;
-  unsigned int max_interactions;
   /* Name of vertex group to use to mask, MAX_VGROUP_NAME. */
   char defgrp_name[64];
 
   short flag;
-  char _pad[6];
+  char _pad[2];
 } WeldModifierData;
 
 /* WeldModifierData->flag */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 2463f3c409f..8a82b37a1a8 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -6332,15 +6332,6 @@ static void rna_def_modifier_weld(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge 
vertices");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
-  prop = RNA_def_property(srna, "max_interactions", PROP_INT, PROP_UNSIGNED);
-  RNA_def_property_int_sdna(prop, NULL, "max_interactions");
-  RNA_def_property_ui_text(
-  prop,
-  "Duplicate Limit",
-  "For a better performance, limits the number of elements found per 
vertex. "
-  "(0 makes it infinite)");
-  RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
   RNA_def_property_ui_text(
diff --git a/source/blender/modifiers/intern/MOD_weld.c 
b/source/blender/modifiers/intern/MOD_weld.c
index d7d24062fc5..0932e54a7cf 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -27,12 +27,17 @@
  * - Review weight and vertex color interpolation.;
  */
 
+//#define USE_WELD_DEBUG
+//#define USE_WELD_NORMALS
+//#define USE_BVHTREEKDOP
+
 #include "MEM_guardedalloc.h"
 
 #include "BLI_utildefines.h"
 
 #include "BLI_alloca.h"
-#include "BLI_kdopbvh.h"
+#include "BLI_bitmap.h"
+#include "BLI_kdtree.h"
 #include "BLI_math.h"
 
 #include "BLT_translation.h"
@@ -43,7 +48,10 @@
 #include "DNA_object_types.h"
 #include "DNA_screen_types.h"
 
-#include "BKE_bvhutils.h"
+#ifdef USE_BVHTREEKDOP
+#  include "BKE_bvhutils.h"
+#endif
+
 #include "BKE_context.h"
 #include "BKE_deform.h"
 #include "BKE_mesh.h"
@@ -60,9 +68,6 @@
 #include "MOD_modifiertypes.h"
 #include "MOD_ui_common.h"
 
-//#define USE_WELD_DEBUG
-//#define USE_WELD_NORMALS
-
 /* Indicates when the element was not computed. */
 #define OUT_OF_CONTEXT (uint)(-1)
 /* Indicates if the edge or face will be collapsed. */
@@ -136,9 +141,6 @@ typedef struct WeldMesh {
   /* Group of vertices to be merged. */
   struct WeldGroup *vert_groups;
   uint *vert_groups_buffer;
-  /* From the original index of the vertex, this indicates which group it is 
or is going to be
-   * merged. */
-  uint *vert_groups_map;
 
   /* Group of edges to be merged. */
   struct WeldGroupEdge *edge_groups;
@@ -202,21 +204,6 @@ static bool 
weld_iter_loop_of_poly_begin(WeldLoopOfPolyIter *iter,
 
 static bool weld_iter_loop_of_poly_next(WeldLoopOfPolyIter *iter);
 
-static void weld_assert_vert_dest_map_setup(const BVHTreeOverlap *overlap,
-const uint overlap_len,
-const uint *vert_dest_map)
-{
-  const BVHTreeOverlap *overlap_iter = [0];
-  for (uint i = overlap_len; i--; ov

[Bf-blender-cvs] [8eda3ddc4f0] master: Weld Modifier: Performance improvement

2020-09-21 Thread Henrik Dick
Commit: 8eda3ddc4f047fcf7d8bd71d4fea958d8005ade8
Author: Henrik Dick
Date:   Mon Sep 21 12:30:49 2020 -0300
Branches: master
https://developer.blender.org/rB8eda3ddc4f047fcf7d8bd71d4fea958d8005ade8

Weld Modifier: Performance improvement

This commit contains the Performance improvement, that was originally
proposed in D8966.

It improves the performance of the Weld Modifier by a lot.

It had a loop with execution time O(N^2) which is now O(N*log(N)) at a
bare maximum.

===

M   source/blender/modifiers/intern/MOD_weld.c

===

diff --git a/source/blender/modifiers/intern/MOD_weld.c 
b/source/blender/modifiers/intern/MOD_weld.c
index 855f96df82f..d7d24062fc5 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -390,10 +390,7 @@ static void weld_vert_ctx_alloc_and_setup(const uint 
mvert_len,
   uint *r_wvert_len,
   uint *r_vert_kill_len)
 {
-  uint *v_dest_iter = _vert_dest_map[0];
-  for (uint i = mvert_len; i--; v_dest_iter++) {
-*v_dest_iter = OUT_OF_CONTEXT;
-  }
+  range_vn_u(r_vert_dest_map, mvert_len, 0);
 
   uint vert_kill_len = 0;
   const BVHTreeOverlap *overlap_iter = [0];
@@ -404,46 +401,36 @@ static void weld_vert_ctx_alloc_and_setup(const uint 
mvert_len,
 BLI_assert(indexA < indexB);
 
 uint va_dst = r_vert_dest_map[indexA];
+while (va_dst != r_vert_dest_map[va_dst]) {
+  va_dst = r_vert_dest_map[va_dst];
+}
 uint vb_dst = r_vert_dest_map[indexB];
-if (va_dst == OUT_OF_CONTEXT) {
-  if (vb_dst == OUT_OF_CONTEXT) {
-vb_dst = indexA;
-r_vert_dest_map[indexB] = vb_dst;
-  }
-  r_vert_dest_map[indexA] = vb_dst;
-  vert_kill_len++;
+while (vb_dst != r_vert_dest_map[vb_dst]) {
+  vb_dst = r_vert_dest_map[vb_dst];
 }
-else if (vb_dst == OUT_OF_CONTEXT) {
-  r_vert_dest_map[indexB] = va_dst;
-  vert_kill_len++;
+if (va_dst == vb_dst) {
+  continue;
 }
-else if (va_dst != vb_dst) {
-  uint v_new, v_old;
-  if (va_dst < vb_dst) {
-v_new = va_dst;
-v_old = vb_dst;
-  }
-  else {
-v_new = vb_dst;
-v_old = va_dst;
-  }
-  BLI_assert(r_vert_dest_map[v_old] == v_old);
-  BLI_assert(r_vert_dest_map[v_new] == v_new);
-  vert_kill_len++;
-
-  const BVHTreeOverlap *overlap_iter_b = [0];
-  for (uint j = i + 1; j--; overlap_iter_b++) {
-indexA = overlap_iter_b->indexA;
-indexB = overlap_iter_b->indexB;
-va_dst = r_vert_dest_map[indexA];
-vb_dst = r_vert_dest_map[indexB];
-if (ELEM(v_old, vb_dst, va_dst)) {
-  r_vert_dest_map[indexA] = v_new;
-  r_vert_dest_map[indexB] = v_new;
-}
-  }
-  BLI_assert(r_vert_dest_map[v_old] == v_new);
+if (va_dst > vb_dst) {
+  SWAP(uint, va_dst, vb_dst);
+}
+vert_kill_len++;
+r_vert_dest_map[vb_dst] = va_dst;
+  }
+
+  /* Fix #r_vert_dest_map for next step. */
+  for (uint i = 0; i < mvert_len; i++) {
+if (i == r_vert_dest_map[i]) {
+  r_vert_dest_map[i] = OUT_OF_CONTEXT;
+  continue;
+}
+
+uint v = i;
+while (v != r_vert_dest_map[v] && r_vert_dest_map[v] != OUT_OF_CONTEXT) {
+  v = r_vert_dest_map[v];
 }
+r_vert_dest_map[v] = v;
+r_vert_dest_map[i] = v;
   }
 
   /* Vert Context. */
@@ -453,7 +440,7 @@ static void weld_vert_ctx_alloc_and_setup(const uint 
mvert_len,
   wvert = MEM_mallocN(sizeof(*wvert) * mvert_len, __func__);
   wv = [0];
 
-  v_dest_iter = _vert_dest_map[0];
+  uint *v_dest_iter = _vert_dest_map[0];
   for (uint i = 0; i < mvert_len; i++, v_dest_iter++) {
 if (*v_dest_iter != OUT_OF_CONTEXT) {
   wv->vert_dest = *v_dest_iter;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7865185d986] blender-v2.83-release: Fix T75840: Add check for not generated edges

2020-04-20 Thread Henrik Dick
Commit: 7865185d986558b5fd40e669c91f86f1967f0304
Author: Henrik Dick
Date:   Mon Apr 20 16:15:53 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB7865185d986558b5fd40e669c91f86f1967f0304

Fix T75840: Add check for not generated edges

The value of `new_edge` is `SOLIDIFY_EMPTY_TAG=2^32-1` if the edge is not 
generated.
The code from D7334 was missing this check.

Reviewed By: mont29

Maniphest Tasks: T75840

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

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index e56ae82379e..3188bb59ae4 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -2012,9 +2012,11 @@ Mesh 
*MOD_solidify_nonmanifold_applyModifier(ModifierData *md,
 if (ed->crease > max_crease) {
   max_crease = ed->crease;
 }
-char bweight = medge[g->edges[k]->new_edge].bweight;
-if (bweight > max_bweight) {
-  max_bweight = bweight;
+if (g->edges[k]->new_edge != MOD_SOLIDIFY_EMPTY_TAG) {
+  char bweight = medge[g->edges[k]->new_edge].bweight;
+  if (bweight > max_bweight) {
+max_bweight = bweight;
+  }
 }
 flag |= ed->flag;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c1edbe79179] master: Fix mistake from last commit to solidify.

2020-04-15 Thread Henrik Dick
Commit: c1edbe791794e678ab8a986b559b9c117ed7b971
Author: Henrik Dick
Date:   Wed Apr 15 12:07:04 2020 +0200
Branches: master
https://developer.blender.org/rBc1edbe791794e678ab8a986b559b9c117ed7b971

Fix mistake from last commit to solidify.

While review the behaviour was changed accidentally.
Now Solidify just crashes everytime.

This is the fix for that.

Reviewed By: mont29

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

===

M   source/blender/modifiers/intern/MOD_solidify_extrude.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c 
b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 3ba64ce084f..1868bb17851 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -236,8 +236,8 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   const bool do_clamp = (smd->offset_clamp != 0.0f);
   const bool do_angle_clamp = do_clamp && (smd->flag & 
MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP) != 0;
   const bool do_bevel_convex = bevel_convex != 0.0f;
-  const bool do_rim = (smd->flag & MOD_SOLIDIFY_RIM) == 0;
-  const bool do_shell = do_rim && (smd->flag & MOD_SOLIDIFY_NOSHELL) == 0;
+  const bool do_rim = (smd->flag & MOD_SOLIDIFY_RIM) != 0;
+  const bool do_shell = !(do_rim && (smd->flag & MOD_SOLIDIFY_NOSHELL) != 0);
 
   /* weights */
   MDeformVert *dvert;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [51e73e99569] master: Fix crash whith Simple Solidify and Bevel Convex.

2020-04-15 Thread Henrik Dick
Commit: 51e73e99569d92068d26327aac636fc35db9dcff
Author: Henrik Dick
Date:   Wed Apr 15 10:57:03 2020 +0200
Branches: master
https://developer.blender.org/rB51e73e99569d92068d26327aac636fc35db9dcff

Fix crash whith Simple Solidify and Bevel Convex.

After recent changes, simple solidify modifier would crash with Fill Rim
turned off and Bevel Convex emabled.

Also fixes that simple solidify would not set the bevel weight flag so the
next modifier could use the bevel weights.

Simple cleanup with do_rim is also included.

Reviewed By: mont29

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

===

M   source/blender/modifiers/intern/MOD_solidify_extrude.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c 
b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 56ec7796b0d..3ba64ce084f 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -236,8 +236,8 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   const bool do_clamp = (smd->offset_clamp != 0.0f);
   const bool do_angle_clamp = do_clamp && (smd->flag & 
MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP) != 0;
   const bool do_bevel_convex = bevel_convex != 0.0f;
-  const bool do_shell = ((smd->flag & MOD_SOLIDIFY_RIM) && (smd->flag & 
MOD_SOLIDIFY_NOSHELL)) ==
-0;
+  const bool do_rim = (smd->flag & MOD_SOLIDIFY_RIM) == 0;
+  const bool do_shell = do_rim && (smd->flag & MOD_SOLIDIFY_NOSHELL) == 0;
 
   /* weights */
   MDeformVert *dvert;
@@ -274,7 +274,7 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   STACK_INIT(new_vert_arr, numVerts * 2);
   STACK_INIT(new_edge_arr, numEdges * 2);
 
-  if (smd->flag & MOD_SOLIDIFY_RIM) {
+  if (do_rim) {
 BLI_bitmap *orig_mvert_tag = BLI_BITMAP_NEW(numVerts, __func__);
 uint eidx;
 uint i;
@@ -373,6 +373,11 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   medge = result->medge;
   mvert = result->mvert;
 
+  if (do_bevel_convex) {
+/* Make sure bweight is enabled. */
+result->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT;
+  }
+
   if (do_shell) {
 CustomData_copy_data(>vdata, >vdata, 0, 0, (int)numVerts);
 CustomData_copy_data(>vdata, >vdata, 0, (int)numVerts, 
(int)numVerts);
@@ -534,6 +539,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   }
   if (do_bevel_convex) {
 edge_angs = MEM_malloc_arrayN(numEdges, sizeof(float), "edge_angs");
+if (!do_rim) {
+  edge_users = MEM_malloc_arrayN(numEdges, sizeof(*edge_users), 
"solid_mod edges");
+}
   }
   uint(*edge_user_pairs)[2] = MEM_malloc_arrayN(
   numEdges, sizeof(*edge_user_pairs), "edge_user_pairs");
@@ -578,6 +586,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   }
   if (do_bevel_convex) {
 edge_angs[i] = angle;
+if (!do_rim) {
+  edge_users[i] = INVALID_PAIR;
+}
   }
 }
   }
@@ -698,6 +709,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   }
 }
   }
+  if (!do_rim) {
+MEM_freeN(edge_users);
+  }
   MEM_freeN(edge_angs);
 }
 
@@ -810,6 +824,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   }
   if (do_bevel_convex) {
 edge_angs = MEM_malloc_arrayN(numEdges, sizeof(float), "edge_angs 
even");
+if (!do_rim) {
+  edge_users = MEM_malloc_arrayN(numEdges, sizeof(*edge_users), 
"solid_mod edges");
+}
   }
   uint(*edge_user_pairs)[2] = MEM_malloc_arrayN(
   numEdges, sizeof(*edge_user_pairs), "edge_user_pairs");
@@ -853,6 +870,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
 sub_v3_v3v3(e, orig_mvert[ed->v1].co, orig_mvert[ed->v2].co);
 normalize_v3(e);
 edge_angs[i] = angle_signed_on_axis_v3v3_v3(n0, n1, e);
+if (!do_rim) {
+  edge_users[i] = INVALID_PAIR;
+}
   }
 }
   }
@@ -916,6 +936,9 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   }
 }
   }
+  if (!do_rim) {
+MEM_freeN(edge_users);
+  }
   MEM_freeN(edge_angs);
 }
 
@@ -961,7 +984,7 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
   }
 
   /* must recalculate normals with vgroups since they can displace unevenly 
[#26888] */
-  if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || (smd->flag & 
MOD_SOLIDIFY_RIM) || dvert) {
+  if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || do_rim || dvert) {
 result->runtime.cd_dirty_vert |= CD

[Bf-blender-cvs] [cc9bee9162b] master: Add Complex Solidify option for thickness per face

2020-04-14 Thread Henrik Dick
Commit: cc9bee9162b022a42b720a127c65b433fcbd8c60
Author: Henrik Dick
Date:   Tue Apr 14 12:22:00 2020 +0200
Branches: master
https://developer.blender.org/rBcc9bee9162b022a42b720a127c65b433fcbd8c60

Add Complex Solidify option for thickness per face

Add an option to solidify complex which will make faces which have thickness
controlled by vertex weights flat/even, and parallel to their original face.

For each face it uses the minimal weight assigned to its vertices to control
the thickness.

This will help users for example in architecture or basic CAD design by finally
making solidify work there at all if altering thickness is needed.

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

Reviewed and minor cleanups by Batien Montagne (@mont29).

===

M   release/scripts/startup/bl_ui/properties_data_modifier.py
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index e099aee9bb6..571811e49d6 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1043,6 +1043,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 sub = col.row()
 sub.active = bool(md.vertex_group)
 sub.prop(md, "thickness_vertex_group", text="Factor")
+if solidify_mode == 'NON_MANIFOLD':
+sub = col.row()
+sub.active = bool(md.vertex_group)
+sub.prop(md, "use_flat_faces")
 
 if solidify_mode == 'EXTRUDE':
 col.label(text="Crease:")
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 225842e4b9e..9e58d7df042 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1192,6 +1192,7 @@ enum {
   MOD_SOLIDIFY_FLIP = (1 << 5),
   MOD_SOLIDIFY_NOSHELL = (1 << 6),
   MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP = (1 << 7),
+  MOD_SOLIDIFY_NONMANIFOLD_FLAT_FACES = (1 << 8),
 };
 
 /** #SolidifyModifierData.mode */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 5898bdd6b1a..e13b9caa90c 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4502,6 +4502,15 @@ static void rna_def_modifier_solidify(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Vertex Group Invert", "Invert the vertex 
group influence");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+  prop = RNA_def_property(srna, "use_flat_faces", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", 
MOD_SOLIDIFY_NONMANIFOLD_FLAT_FACES);
+  RNA_def_property_ui_text(prop,
+   "Flat Faces",
+   "Make faces use the minimal vertex weight assigned 
to their vertices"
+   "(ensures new faces remain parallel to their 
original ones, slow, "
+   "disable when not needed)");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
   prop = RNA_def_property(srna, "use_flip_normals", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_FLIP);
   RNA_def_property_ui_text(prop, "Flip Normals", "Invert the face direction");
diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 70aec2d797b..e56ae82379e 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -186,6 +186,8 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 
   MOD_get_vgroup(ctx->object, mesh, smd->defgrp_name, , _index);
 
+  const bool do_flat_faces = dvert && (smd->flag & 
MOD_SOLIDIFY_NONMANIFOLD_FLAT_FACES);
+
   orig_mvert = mesh->mvert;
   orig_medge = mesh->medge;
   orig_mloop = mesh->mloop;
@@ -1305,6 +1307,30 @@ Mesh 
*MOD_solidify_nonmanifold_applyModifier(ModifierData *md,
 
   /* Calculate EdgeGroup vertex coordinates. */
   {
+float *face_weight = NULL;
+
+if (do_flat_faces) {
+  face_weight = MEM_malloc_arrayN(numPolys, sizeof(*face_weight), 
"face_weight in solidify");
+
+  mp = orig_mpoly;
+  for (uint i = 0; i < numPolys; i++, mp++) {
+float scalar_vgroup = 1.0f;
+int loopend

[Bf-blender-cvs] [35b1cc806f7] master: Improve Solidify/Bevel Modifier cooperation

2020-04-14 Thread Henrik Dick
Commit: 35b1cc806f76d427139cc0eef1cdd9ef96b671ad
Author: Henrik Dick
Date:   Tue Apr 14 10:45:53 2020 +0200
Branches: master
https://developer.blender.org/rB35b1cc806f76d427139cc0eef1cdd9ef96b671ad

Improve Solidify/Bevel Modifier cooperation

Adds a slider to solidify which allows the user to add bevel weight on the 
outside
or remove bevel weight from the inside.

Also includes a very small improvment for working with subsurface modifier where
the rim edge in complex solidify will now also have a chance to get a crease if
there is only two adjacent edges.

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

Reviewing and minor cleanups: Bastien Montagne (@mont29).

===

M   release/scripts/startup/bl_ui/properties_data_modifier.py
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_solidify.c
M   source/blender/modifiers/intern/MOD_solidify_extrude.c
M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 62e19129923..e099aee9bb6 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1049,7 +1049,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 col.prop(md, "edge_crease_inner", text="Inner")
 col.prop(md, "edge_crease_outer", text="Outer")
 col.prop(md, "edge_crease_rim", text="Rim")
+col.label(text="Bevel:")
+col.prop(md, "bevel_convex")
 else:
+col.label(text="Bevel:")
+col.prop(md, "bevel_convex")
+col.separator()
 col.prop(md, "nonmanifold_merge_threshold")
 
 col = split.column()
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index 431fcb7a243..225842e4b9e 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1177,7 +1177,7 @@ typedef struct SolidifyModifierData {
   short mat_ofs_rim;
 
   float merge_tolerance;
-  char _pad1[4];
+  float bevel_convex;
 } SolidifyModifierData;
 
 /** #SolidifyModifierData.flag */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 5fc91622eba..5898bdd6b1a 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4531,6 +4531,13 @@ static void rna_def_modifier_solidify(BlenderRNA *brna)
   RNA_def_property_ui_text(
   prop, "Merge Threshold", "Distance within which degenerated geometry is 
merged");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  prop = RNA_def_property(srna, "bevel_convex", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "bevel_convex");
+  RNA_def_property_range(prop, -1.0, 1.0);
+  RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
+  RNA_def_property_ui_text(prop, "Bevel Convex", "Edge bevel weight to be 
added to outside edges");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 static void rna_def_modifier_screw(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_solidify.c 
b/source/blender/modifiers/intern/MOD_solidify.c
index 74d9df7d093..fc9719a5fb4 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -54,6 +54,7 @@ static void initData(ModifierData *md)
   smd->nonmanifold_offset_mode = 
MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_CONSTRAINTS;
   smd->nonmanifold_boundary_mode = MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_NONE;
   smd->merge_tolerance = 0.0001f;
+  smd->bevel_convex = 0.0f;
 }
 
 static void requiredDataMask(Object *UNUSED(ob),
diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c 
b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index ecd62e5e1fe..56ec7796b0d 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -224,15 +224,18 @@ Mesh *MOD_solidify_extrude_applyModifier(ModifierData *md,
 
   const bool need_poly_normals = (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) ||
  (smd->flag & MOD_SOLIDIFY_EVEN) ||
- (smd->flag & MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP);
+ (smd->flag & MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP) 
||
+ (smd->

[Bf-blender-cvs] [5cf72833429] master: Fix T75032: New complex solidify algorithm handles poorly merging threshold of small geometry details.

2020-04-13 Thread Henrik Dick
Commit: 5cf72833429f4c63d27ea0a72878af1fec6dcf4e
Author: Henrik Dick
Date:   Mon Apr 13 17:15:16 2020 +0200
Branches: master
https://developer.blender.org/rB5cf72833429f4c63d27ea0a72878af1fec6dcf4e

Fix T75032: New complex solidify algorithm handles poorly merging threshold of 
small geometry details.

* Implemented the algortihm that would merge vertices to the weighted
  center between them.
* Exposed the merge threshold to the user.

The new default tolerance is 0.0001 (versionning code ensures that
previous default value remains in use to avoid any change in existing
files).

Review and minor changes/cleanups from Bastien Montagne (@mont29).

===

M   release/scripts/startup/bl_ui/properties_data_modifier.py
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_solidify.c
M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 61151b3e02b..62e19129923 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1049,6 +1049,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 col.prop(md, "edge_crease_inner", text="Inner")
 col.prop(md, "edge_crease_outer", text="Outer")
 col.prop(md, "edge_crease_rim", text="Rim")
+else:
+col.prop(md, "nonmanifold_merge_threshold")
 
 col = split.column()
 
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index 5c99760dc9c..d53b6cde4ae 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4890,7 +4890,6 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
 
   if (!MAIN_VERSION_ATLEAST(bmain, 283, 12)) {
-
 /* Activate f-curve drawing in the sequencer. */
 for (bScreen *screen = bmain->screens.first; screen; screen = 
screen->id.next) {
   for (ScrArea *area = screen->areabase.first; area; area = area->next) {
@@ -4929,5 +4928,18 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
*/
   {
 /* Keep this block, even when empty. */
+
+/* Solidify modifier merge tolerance. */
+if (!DNA_struct_elem_find(fd->filesdna, "SolidifyModifierData", "float", 
"merge_tolerance")) {
+  for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+  if (md->type == eModifierType_Solidify) {
+SolidifyModifierData *smd = (SolidifyModifierData *)md;
+/* set to 0.0003 since that is what was used before, default now 
is 0.0001 */
+smd->merge_tolerance = 0.0003f;
+  }
+}
+  }
+}
   }
 }
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index b2b2a73848a..431fcb7a243 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1175,6 +1175,9 @@ typedef struct SolidifyModifierData {
   int flag;
   short mat_ofs;
   short mat_ofs_rim;
+
+  float merge_tolerance;
+  char _pad1[4];
 } SolidifyModifierData;
 
 /** #SolidifyModifierData.flag */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 176d8e6de91..2c4818eb972 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4523,6 +4523,13 @@ static void rna_def_modifier_solidify(BlenderRNA *brna)
   RNA_def_property_enum_items(prop, nonmanifold_boundary_mode_items);
   RNA_def_property_ui_text(prop, "Boundary Shape", "Selects the boundary 
adjustment algorithm");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+  prop = RNA_def_property(srna, "nonmanifold_merge_threshold", PROP_FLOAT, 
PROP_DISTANCE);
+  RNA_def_property_float_sdna(prop, NULL, "merge_tolerance");
+  RNA_def_property_range(prop, 0.0, 1.0);
+  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4);
+  RNA_def_property_ui_text(prop, "Merge Threshold", "Distance within which 
degenerated geometry is merged");
+  RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
 static void rna_def_modifier_screw(BlenderRNA *brna)
diff --git a/source/blender/modifiers/intern/MOD_solidify.c 
b/source/

[Bf-blender-cvs] [d8e2cc9f4d1] master: Fix missing Surface Deform strength versioning

2020-03-29 Thread Henrik Dick
Commit: d8e2cc9f4d10478861fa4a9e9c9eb49f4ebca09f
Author: Henrik Dick
Date:   Sun Mar 29 22:51:15 2020 +1100
Branches: master
https://developer.blender.org/rBd8e2cc9f4d10478861fa4a9e9c9eb49f4ebca09f

Fix missing Surface Deform strength versioning

===

M   source/blender/blenloader/intern/versioning_280.c

===

diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index eda13dce084..50b1e385dd4 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4852,6 +4852,18 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 wm->xr.session_settings.flag = XR_SESSION_USE_POSITION_TRACKING;
   }
 }
+
+/* Surface deform modifier strength*/
+if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", 
"float", "strength")) {
+  for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
+for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+  if (md->type == eModifierType_SurfaceDeform) {
+SurfaceDeformModifierData *sdmd = (SurfaceDeformModifierData *)md;
+sdmd->strength = 1.0f;
+  }
+}
+  }
+}
   }
 
   /**

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fc37318fe73] master: Screw Modifier: support 1-2 steps

2020-03-29 Thread Henrik Dick
Commit: fc37318fe7361bc4d3632213ddb567b790305710
Author: Henrik Dick
Date:   Sun Mar 29 20:23:24 2020 +1100
Branches: master
https://developer.blender.org/rBfc37318fe7361bc4d3632213ddb567b790305710

Screw Modifier: support 1-2 steps

The Screw Modifier had a lower limit for the steps value, which not only
was inconsistent between render and viewport steps, but also was capped
to 2 in UI and also in the code internally.

===

M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_screw.c

===

diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 45c4ad75995..455fb1c50c9 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4538,14 +4538,14 @@ static void rna_def_modifier_screw(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
 
   prop = RNA_def_property(srna, "steps", PROP_INT, PROP_UNSIGNED);
-  RNA_def_property_range(prop, 2, 1);
-  RNA_def_property_ui_range(prop, 3, 512, 1, -1);
+  RNA_def_property_range(prop, 1, 1);
+  RNA_def_property_ui_range(prop, 1, 512, 1, -1);
   RNA_def_property_ui_text(prop, "Steps", "Number of steps in the revolution");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
   prop = RNA_def_property(srna, "render_steps", PROP_INT, PROP_UNSIGNED);
-  RNA_def_property_range(prop, 2, 1);
-  RNA_def_property_ui_range(prop, 2, 512, 1, -1);
+  RNA_def_property_range(prop, 1, 1);
+  RNA_def_property_ui_range(prop, 1, 512, 1, -1);
   RNA_def_property_ui_text(prop, "Render Steps", "Number of steps in the 
revolution");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
diff --git a/source/blender/modifiers/intern/MOD_screw.c 
b/source/blender/modifiers/intern/MOD_screw.c
index 8921ddb894f..e832a23b4ed 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -352,12 +352,9 @@ static Mesh *applyModifier(ModifierData *md, const 
ModifierEvalContext *ctx, Mes
* Note! smaller then `FLT_EPSILON * 100`
* gives problems with float precision so its never closed. */
   if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) &&
-  fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f)) {
+  fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f) && 
step_tot > 3) {
 close = 1;
 step_tot--;
-if (step_tot < 3) {
-  step_tot = 3;
-}
 
 maxVerts = totvert * step_tot;/* -1 because we're joining back up */
 maxEdges = (totvert * step_tot) + /* these are the edges between new verts 
*/
@@ -368,8 +365,8 @@ static Mesh *applyModifier(ModifierData *md, const 
ModifierEvalContext *ctx, Mes
   }
   else {
 close = 0;
-if (step_tot < 3) {
-  step_tot = 3;
+if (step_tot < 2) {
+  step_tot = 2;
 }
 
 maxVerts = totvert * step_tot;  /* -1 because we're joining back 
up */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bb19d96bc5a] master: Fix solidify complex degenerate cases with duplicate faces

2020-03-23 Thread Henrik Dick
Commit: bb19d96bc5afa1b17520c49fb78e4410569966d1
Author: Henrik Dick
Date:   Tue Mar 24 16:17:22 2020 +1100
Branches: master
https://developer.blender.org/rBbb19d96bc5afa1b17520c49fb78e4410569966d1

Fix solidify complex degenerate cases with duplicate faces

The removal of duplicate faces that are created during the handling of
degenerate cases was implemented already but didn't work.
This patch should fix some crashes with the solidify complex mode
related to that.

See D7221 for details.

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 5f7fb364113..22fc56bdeaf 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -286,8 +286,6 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
   bool has_singularities = false;
 
   /* Vert edge adjacent map. */
-  uint *vert_adj_edges_len = MEM_calloc_arrayN(
-  numVerts, sizeof(*vert_adj_edges_len), "vert_adj_edges_len in solidify");
   OldVertEdgeRef **vert_adj_edges = MEM_calloc_arrayN(
   numVerts, sizeof(*vert_adj_edges), "vert_adj_edges in solidify");
 
@@ -335,6 +333,8 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 }
 
 float edgedir[3] = {0, 0, 0};
+uint *vert_adj_edges_len = MEM_calloc_arrayN(
+numVerts, sizeof(*vert_adj_edges_len), "vert_adj_edges_len in 
solidify");
 
 /* Calculate edge lengths and len vert_adj edges. */
 {
@@ -349,40 +349,40 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
   if (v1 != v2) {
 sub_v3_v3v3(edgedir, orig_mvert[v2].co, orig_mvert[v1].co);
 orig_edge_lengths[i] = len_squared_v3(edgedir);
-  }
-  if (v1 != v2 && orig_edge_lengths[i] <= FLT_EPSILON) {
-if (v2 > v1) {
-  for (uint j = v2; j < numVerts; j++) {
-if (vm[j] == v2) {
-  vm[j] = v1;
-  vert_adj_edges_len[v1] += vert_adj_edges_len[j];
-  vert_adj_edges_len[j] = 0;
+if (orig_edge_lengths[i] <= FLT_EPSILON) {
+  if (v2 > v1) {
+for (uint j = v2; j < numVerts; j++) {
+  if (vm[j] == v2) {
+vm[j] = v1;
+vert_adj_edges_len[v1] += vert_adj_edges_len[j];
+vert_adj_edges_len[j] = 0;
+  }
 }
   }
-}
-else if (v2 < v1) {
-  for (uint j = v1; j < numVerts; j++) {
-if (vm[j] == v1) {
-  vm[j] = v2;
-  vert_adj_edges_len[v2] += vert_adj_edges_len[j];
-  vert_adj_edges_len[j] = 0;
+  else if (v2 < v1) {
+for (uint j = v1; j < numVerts; j++) {
+  if (vm[j] == v1) {
+vm[j] = v2;
+vert_adj_edges_len[v2] += vert_adj_edges_len[j];
+vert_adj_edges_len[j] = 0;
+  }
 }
   }
+  if (do_shell) {
+numNewLoops -= edge_adj_faces_len[i] * 2;
+  }
+
+  edge_adj_faces_len[i] = 0;
+  MEM_freeN(edge_adj_faces[i]->faces);
+  MEM_freeN(edge_adj_faces[i]->faces_reversed);
+  MEM_freeN(edge_adj_faces[i]);
+  edge_adj_faces[i] = NULL;
 }
-if (do_shell) {
-  numNewLoops -= edge_adj_faces_len[i] * 2;
+else {
+  orig_edge_lengths[i] = sqrtf(orig_edge_lengths[i]);
+  vert_adj_edges_len[v1]++;
+  vert_adj_edges_len[v2]++;
 }
-
-edge_adj_faces_len[i] = 0;
-MEM_freeN(edge_adj_faces[i]->faces);
-MEM_freeN(edge_adj_faces[i]->faces_reversed);
-MEM_freeN(edge_adj_faces[i]);
-edge_adj_faces[i] = NULL;
-  }
-  else if (v1 != v2 && edge_adj_faces_len[i] > 0) {
-orig_edge_lengths[i] = sqrtf(orig_edge_lengths[i]);
-vert_adj_edges_len[v1]++;
-vert_adj_edges_len[v2]++;
   }
 }
   }
@@ -473,8 +473,8 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
   }
 }
 if (invalid_edge_index) {
-  /* Should never actually be executed. */
   if (j == 1) {
+/* Should never actually be executed. */
 vert_adj_edges[vs[0]]->edges_len--;
   }
  

[Bf-blender-cvs] [241248223a6] master: Change solidify's material offset in complex mode to conform with simple mode

2020-03-23 Thread Henrik Dick
Commit: 241248223a6445a2de77dfd7439ca52c419d28ee
Author: Henrik Dick
Date:   Mon Mar 23 15:35:53 2020 +0100
Branches: master
https://developer.blender.org/rB241248223a6445a2de77dfd7439ca52c419d28ee

Change solidify's material offset in complex mode to conform with simple mode

this patch will change the behaviour of the material offset in complex mode to 
fit simple mode output.
Previously in complex mode this would offset the material of the enire shell,
because when you read the tooltip it says material for new generated geometry.
In complex mode everything is new generated geometry though.
In simple mode on the other hand, this would give you a way to only change the 
inside faces
material. There may be cases in large modifier stacks where material offset 
like it is implemented
currently in complex mode may be useful, but it is much more useful in the way 
it is implemented
by simple mode.

Reviewed By: mont29

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

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 3cd045b73ae..9c99f9b1e88 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -2212,7 +2212,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
   CustomData_copy_data(>pdata, >pdata, (int)(i / 2), 
(int)poly_index, 1);
   mpoly[poly_index].loopstart = (int)loop_index;
   mpoly[poly_index].totloop = (int)k;
-  mpoly[poly_index].mat_nr = fr->face->mat_nr + mat_ofs;
+  mpoly[poly_index].mat_nr = fr->face->mat_nr + (fr->reversed ? 
mat_ofs : 0);
   CLAMP(mpoly[poly_index].mat_nr, 0, mat_nr_max);
   mpoly[poly_index].flag = fr->face->flag;
   if (fr->reversed != do_flip) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ee4645207f7] master: Fix T74195: Solidify Complex Dissolve Crash.

2020-03-23 Thread Henrik Dick
Commit: ee4645207f76a5d76902cec11906ddd3ae815baa
Author: Henrik Dick
Date:   Mon Mar 23 15:21:48 2020 +0100
Branches: master
https://developer.blender.org/rBee4645207f76a5d76902cec11906ddd3ae815baa

Fix T74195: Solidify Complex Dissolve Crash.

I also added a few more comments to the code as I gone along.

Maniphest Tasks: T74195

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

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 23053adfd5a..3cd045b73ae 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -243,6 +243,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
   if (mp->totloop > largest_ngon) {
 largest_ngon = (uint)mp->totloop;
   }
+  /* add to final mesh face count */
   if (do_shell) {
 numNewPolys += 2;
 numNewLoops += (uint)mp->totloop * 2;
@@ -272,7 +273,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
   /* Edge groups for every original vert. */
   EdgeGroup **orig_vert_groups_arr = MEM_calloc_arrayN(
   numVerts, sizeof(*orig_vert_groups_arr), "orig_vert_groups_arr in 
solidify");
-  /* Duplicate verts map. */
+  /* vertex map used to map duplicates. */
   uint *vm = MEM_malloc_arrayN(numVerts, sizeof(*vm), "orig_vert_map in 
solidify");
   for (uint i = 0; i < numVerts; i++) {
 vm[i] = i;
@@ -309,15 +310,15 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 BLI_assert(len > 0);
 uint *adj_faces = MEM_malloc_arrayN(
 len, sizeof(*adj_faces), "OldEdgeFaceRef::faces in solidify");
-bool *adj_faces_loops_reversed = MEM_malloc_arrayN(
-len, sizeof(*adj_faces_loops_reversed), 
"OldEdgeFaceRef::reversed in solidify");
+bool *adj_faces_reversed = MEM_malloc_arrayN(
+len, sizeof(*adj_faces_reversed), "OldEdgeFaceRef::reversed in 
solidify");
 adj_faces[0] = i;
 for (uint k = 1; k < len; k++) {
   adj_faces[k] = MOD_SOLIDIFY_EMPTY_TAG;
 }
-adj_faces_loops_reversed[0] = reversed;
+adj_faces_reversed[0] = reversed;
 OldEdgeFaceRef *ref = MEM_mallocN(sizeof(*ref), "OldEdgeFaceRef in 
solidify");
-*ref = (OldEdgeFaceRef){adj_faces, len, adj_faces_loops_reversed, 
1};
+*ref = (OldEdgeFaceRef){adj_faces, len, adj_faces_reversed, 1};
 edge_adj_faces[edge] = ref;
   }
   else {
@@ -339,6 +340,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 {
   bool *face_singularity = MEM_calloc_arrayN(
   numPolys, sizeof(*face_singularity), "face_sides_arr in solidify");
+  
   ed = orig_medge;
   for (uint i = 0; i < numEdges; i++, ed++) {
 if (edge_adj_faces_len[i] > 0) {
@@ -348,7 +350,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 sub_v3_v3v3(edgedir, orig_mvert[v2].co, orig_mvert[v1].co);
 orig_edge_lengths[i] = len_squared_v3(edgedir);
   }
-  if (v1 == v2 || orig_edge_lengths[i] <= FLT_EPSILON) {
+  if (v1 != v2 && orig_edge_lengths[i] <= FLT_EPSILON) {
 if (v2 > v1) {
   for (uint j = v2; j < numVerts; j++) {
 if (vm[j] == v2) {
@@ -370,40 +372,59 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 if (do_shell) {
   numNewLoops -= edge_adj_faces_len[i] * 2;
 }
-if (v1 == v2) {
-  /* Remove polys. */
-  for (uint j = 0; j < edge_adj_faces[i]->faces_len; j++) {
-const uint face = edge_adj_faces[i]->faces[j];
-if (!face_singularity[face]) {
-  bool is_singularity = true;
-  for (uint k = 0; k < orig_mpoly[face].totloop; k++) {
-if (vm[orig_mloop[((uint)orig_mpoly[face].loopstart) + 
k].v] != v1) {
-  is_singularity = false;
-  break;
-}
-  }
-  if (is_singularity) {
-face_singularity[face] = true;
-if (do_shell) {
-  numNewPolys -= 2;
-}
-  }
-}
-  }
-}
+
 edge_adj_faces_len[i] = 0;
 MEM_freeN(edge_adj_faces[i]->faces);
 MEM_freeN(edge_adj_faces

[Bf-blender-cvs] [9c190dea4c0] blender-v2.82-release: Fix solidify complex fixed thickness on flipped normal boundary

2020-01-28 Thread Henrik Dick
Commit: 9c190dea4c056a80edde885da3756b889527a8b4
Author: Henrik Dick
Date:   Wed Jan 29 14:28:03 2020 +1100
Branches: blender-v2.82-release
https://developer.blender.org/rB9c190dea4c056a80edde885da3756b889527a8b4

Fix solidify complex fixed thickness on flipped normal boundary

Fixed thickness with zero offset gave uneven results for complex
solidify cases (3+ faces sharing an edge).

See D6643 for steps to redo the error.

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 144ba25c8fa..799c1c966a3 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1407,7 +1407,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 disable_boundary_fix = true;
   }
 }
-/* Simple/Even Method. */
+/* Fixed/Even Method. */
 else {
   float total_angle = 0;
   float total_angle_back = 0;
@@ -1520,6 +1520,9 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 if (has_back && total_angle_back > FLT_EPSILON) {
   mul_v3_fl(nor_back, 1.0f / total_angle_back);
   add_v3_v3(nor, nor_back);
+  if (has_front && total_angle > FLT_EPSILON) {
+mul_v3_fl(nor, 0.5f);
+  }
 }
   }
   /* Set move_nor for boundary fix. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bda0c0847b5] blender-v2.82-release: Fix numerical instabilities of solidify with complex constraints

2020-01-21 Thread Henrik Dick
Commit: bda0c0847b5ef89b31d56b0d88705bafaef90616
Author: Henrik Dick
Date:   Wed Jan 22 06:02:12 2020 +1100
Branches: blender-v2.82-release
https://developer.blender.org/rBbda0c0847b5ef89b31d56b0d88705bafaef90616

Fix numerical instabilities of solidify with complex constraints

Sometimes on flat open vertices the thickness would suddenly start
to be jumping in powers of 2, also when bending a plane there is a
noticeable jump in the geometry.
When offset is set to -1 or 1 weird glitches happen.

See D6559 for test cases that failed.

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index be7bbb86e4d..144ba25c8fa 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -163,6 +163,8 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 
   const float ofs_front = (smd->offset_fac + 1.0f) * 0.5f * smd->offset;
   const float ofs_back = ofs_front - smd->offset * smd->offset_fac;
+  const float ofs_front_clamped = max_ff(1e-5f, fabsf(smd->offset > 0 ? 
ofs_front : ofs_back));
+  const float ofs_back_clamped = max_ff(1e-5f, fabsf(smd->offset > 0 ? 
ofs_back : ofs_front));
   const float offset_fac_vg = smd->offset_fac_vg;
   const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg;
   const float offset = fabsf(smd->offset) * smd->offset_clamp;
@@ -1262,15 +1264,16 @@ Mesh 
*MOD_solidify_nonmanifold_applyModifier(ModifierData *md,
 NewFaceRef *face = edge->faces[l];
 if (face && (first_edge == NULL ||
  (first_edge->faces[0] != face && 
first_edge->faces[1] != face))) {
+  const float ofs = face->reversed ? ofs_back_clamped : 
ofs_front_clamped;
   if (!null_faces[face->index]) {
 mul_v3_v3fl(normals_queue[queue_index],
 poly_nors[face->index],
 face->reversed ? -1 : 1);
-normals_queue[queue_index++][3] = face->reversed ? 
ofs_back : ofs_front;
+normals_queue[queue_index++][3] = ofs;
   }
   else {
 mul_v3_v3fl(face_nors[0], poly_nors[face->index], 
face->reversed ? -1 : 1);
-nor_ofs[0] = face->reversed ? ofs_back : ofs_front;
+nor_ofs[0] = ofs;
   }
 }
   }
@@ -1280,7 +1283,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 }
   }
   uint face_nors_len = 0;
-  const float stop_explosion = 1 - fabsf(smd->offset_fac) * 0.05f;
+  const float stop_explosion = 0.999f - fabsf(smd->offset_fac) * 
0.05f;
   while (queue_index > 0) {
 if (face_nors_len == 0) {
   if (queue_index <= 2) {
@@ -1371,50 +1374,23 @@ Mesh 
*MOD_solidify_nonmanifold_applyModifier(ModifierData *md,
   }
   MEM_freeN(normals_queue);
   /* When up to 3 constraint normals are found. */
-  float d, q;
-  switch (face_nors_len) {
-case 0:
-  mul_v3_v3fl(nor, face_nors[0], nor_ofs[0]);
-  disable_boundary_fix = true;
-  break;
-case 1:
-  mul_v3_v3fl(nor, face_nors[0], nor_ofs[0]);
-  disable_boundary_fix = true;
-  break;
-case 2:
-  q = dot_v3v3(face_nors[0], face_nors[1]);
-  d = 1.0f - q * q;
-  if (LIKELY(d > FLT_EPSILON) && q < stop_explosion) {
-d = 1.0f / d;
-mul_v3_fl(face_nors[0], (nor_ofs[0] - nor_ofs[1] * q) * d);
-mul_v3_fl(face_nors[1], (nor_ofs[1] - nor_ofs[0] * q) * d);
-add_v3_v3v3(nor, face_nors[0], face_nors[1]);
-  }
-  else {
-mul_v3_fl(face_nors[0], nor_ofs[0] * 0.5f);
-mul_v3_fl(face_nors[1], nor_ofs[1] * 0.5f);
-add_v3_v3v3(nor, face_nors[0], face_nors[1]);
-  }
-  if (!disable_boundary_fix) {
-cross_v3_v3v3(move_nor, face_nors[0], face_nors[1]);
-  }
-  break;
-case 3:
-  q = dot_v3v3(face_nors[0], face_nors[1]);
-  d = 1.0f - q * q;
-   

[Bf-blender-cvs] [71f39c45a7b] master: Fix numerical instabilities of solidify with complex constraints

2020-01-21 Thread Henrik Dick
Commit: 71f39c45a7b962ae7fa54dc2540768ec558377f3
Author: Henrik Dick
Date:   Wed Jan 22 06:02:12 2020 +1100
Branches: master
https://developer.blender.org/rB71f39c45a7b962ae7fa54dc2540768ec558377f3

Fix numerical instabilities of solidify with complex constraints

Sometimes on flat open vertices the thickness would suddenly start
to be jumping in powers of 2, also when bending a plane there is a
noticeable jump in the geometry.
When offset is set to -1 or 1 weird glitches happen.

See D6559 for test cases that failed.

===

M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c

===

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c 
b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index be7bbb86e4d..144ba25c8fa 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -163,6 +163,8 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 
   const float ofs_front = (smd->offset_fac + 1.0f) * 0.5f * smd->offset;
   const float ofs_back = ofs_front - smd->offset * smd->offset_fac;
+  const float ofs_front_clamped = max_ff(1e-5f, fabsf(smd->offset > 0 ? 
ofs_front : ofs_back));
+  const float ofs_back_clamped = max_ff(1e-5f, fabsf(smd->offset > 0 ? 
ofs_back : ofs_front));
   const float offset_fac_vg = smd->offset_fac_vg;
   const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg;
   const float offset = fabsf(smd->offset) * smd->offset_clamp;
@@ -1262,15 +1264,16 @@ Mesh 
*MOD_solidify_nonmanifold_applyModifier(ModifierData *md,
 NewFaceRef *face = edge->faces[l];
 if (face && (first_edge == NULL ||
  (first_edge->faces[0] != face && 
first_edge->faces[1] != face))) {
+  const float ofs = face->reversed ? ofs_back_clamped : 
ofs_front_clamped;
   if (!null_faces[face->index]) {
 mul_v3_v3fl(normals_queue[queue_index],
 poly_nors[face->index],
 face->reversed ? -1 : 1);
-normals_queue[queue_index++][3] = face->reversed ? 
ofs_back : ofs_front;
+normals_queue[queue_index++][3] = ofs;
   }
   else {
 mul_v3_v3fl(face_nors[0], poly_nors[face->index], 
face->reversed ? -1 : 1);
-nor_ofs[0] = face->reversed ? ofs_back : ofs_front;
+nor_ofs[0] = ofs;
   }
 }
   }
@@ -1280,7 +1283,7 @@ Mesh *MOD_solidify_nonmanifold_applyModifier(ModifierData 
*md,
 }
   }
   uint face_nors_len = 0;
-  const float stop_explosion = 1 - fabsf(smd->offset_fac) * 0.05f;
+  const float stop_explosion = 0.999f - fabsf(smd->offset_fac) * 
0.05f;
   while (queue_index > 0) {
 if (face_nors_len == 0) {
   if (queue_index <= 2) {
@@ -1371,50 +1374,23 @@ Mesh 
*MOD_solidify_nonmanifold_applyModifier(ModifierData *md,
   }
   MEM_freeN(normals_queue);
   /* When up to 3 constraint normals are found. */
-  float d, q;
-  switch (face_nors_len) {
-case 0:
-  mul_v3_v3fl(nor, face_nors[0], nor_ofs[0]);
-  disable_boundary_fix = true;
-  break;
-case 1:
-  mul_v3_v3fl(nor, face_nors[0], nor_ofs[0]);
-  disable_boundary_fix = true;
-  break;
-case 2:
-  q = dot_v3v3(face_nors[0], face_nors[1]);
-  d = 1.0f - q * q;
-  if (LIKELY(d > FLT_EPSILON) && q < stop_explosion) {
-d = 1.0f / d;
-mul_v3_fl(face_nors[0], (nor_ofs[0] - nor_ofs[1] * q) * d);
-mul_v3_fl(face_nors[1], (nor_ofs[1] - nor_ofs[0] * q) * d);
-add_v3_v3v3(nor, face_nors[0], face_nors[1]);
-  }
-  else {
-mul_v3_fl(face_nors[0], nor_ofs[0] * 0.5f);
-mul_v3_fl(face_nors[1], nor_ofs[1] * 0.5f);
-add_v3_v3v3(nor, face_nors[0], face_nors[1]);
-  }
-  if (!disable_boundary_fix) {
-cross_v3_v3v3(move_nor, face_nors[0], face_nors[1]);
-  }
-  break;
-case 3:
-  q = dot_v3v3(face_nors[0], face_nors[1]);
-  d = 1.0f - q * q;
-  float *free

[Bf-blender-cvs] [e45cfb574ee] master: Solidify Modifier: support non-manifold input

2019-11-03 Thread Henrik Dick
Commit: e45cfb574ee75b85de084d09fcb8325778806bd2
Author: Henrik Dick
Date:   Sun Nov 3 14:24:24 2019 +1100
Branches: master
https://developer.blender.org/rBe45cfb574ee75b85de084d09fcb8325778806bd2

Solidify Modifier: support non-manifold input

This adds a new mode to solidify to support non-manifold geometry
with edges using 3 or more faces as input, resulting in a manifold mesh.

Since the differences between these methods don't translate well
into short terms, they're named "Simple" and "Complex" in the UI.

This also adds clamp with respect to angles
to the existing solidify modifier calculation.

===

M   release/scripts/startup/bl_ui/properties_data_modifier.py
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/CMakeLists.txt
M   source/blender/modifiers/intern/MOD_solidify.c
A   source/blender/modifiers/intern/MOD_solidify_extrude.c
A   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
A   source/blender/modifiers/intern/MOD_solidify_util.h

===

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 124fe77cb52..3f1764faabe 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -954,11 +954,23 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 layout.label(text="Settings are inside the Physics tab")
 
 def SOLIDIFY(self, layout, ob, md):
+
+layout.row().prop(md, "solidify_mode")
+
+solidify_mode = md.solidify_mode
+
+if solidify_mode == 'NON_MANIFOLD':
+layout.prop(md, "nonmanifold_thickness_mode")
+layout.prop(md, "nonmanifold_boundary_mode")
+
 split = layout.split()
 
 col = split.column()
 col.prop(md, "thickness")
 col.prop(md, "thickness_clamp")
+row = col.row()
+row.active = md.thickness_clamp > 0.0
+row.prop(md, "use_thickness_angle_clamp")
 
 col.separator()
 
@@ -972,18 +984,22 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 sub.active = bool(md.vertex_group)
 sub.prop(md, "thickness_vertex_group", text="Factor")
 
-col.label(text="Crease:")
-col.prop(md, "edge_crease_inner", text="Inner")
-col.prop(md, "edge_crease_outer", text="Outer")
-col.prop(md, "edge_crease_rim", text="Rim")
+if solidify_mode == 'EXTRUDE':
+col.label(text="Crease:")
+col.prop(md, "edge_crease_inner", text="Inner")
+col.prop(md, "edge_crease_outer", text="Outer")
+col.prop(md, "edge_crease_rim", text="Rim")
 
 col = split.column()
 
 col.prop(md, "offset")
+
 col.prop(md, "use_flip_normals")
 
-col.prop(md, "use_even_offset")
-col.prop(md, "use_quality_normals")
+if solidify_mode == 'EXTRUDE':
+col.prop(md, "use_even_offset")
+col.prop(md, "use_quality_normals")
+
 col.prop(md, "use_rim")
 col_rim = col.column()
 col_rim.active = md.use_rim
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index cceeb9c71d5..9c4d7bcd3b1 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1115,7 +1115,13 @@ typedef struct SolidifyModifierData {
   float offset_fac_vg;
   /** Clamp offset based on surrounding geometry. */
   float offset_clamp;
-  char _pad[4];
+  char mode;
+
+  /** Variables for #MOD_SOLIDIFY_MODE_NONMANIFOLD. */
+  char nonmanifold_offset_mode;
+  char nonmanifold_boundary_mode;
+
+  char _pad;
   float crease_inner;
   float crease_outer;
   float crease_rim;
@@ -1124,6 +1130,7 @@ typedef struct SolidifyModifierData {
   short mat_ofs_rim;
 } SolidifyModifierData;
 
+/** #SolidifyModifierData.flag */
 enum {
   MOD_SOLIDIFY_RIM = (1 << 0),
   MOD_SOLIDIFY_EVEN = (1 << 1),
@@ -1134,6 +1141,27 @@ enum {
 #endif
   MOD_SOLIDIFY_FLIP = (1 << 5),
   MOD_SOLIDIFY_NOSHELL = (1 << 6),
+  MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP = (1 << 7),
+};
+
+/** #SolidifyModifierData.mode */
+enum {
+  MOD_SOLIDIFY_MODE_EXTRUDE = 0,
+  MOD_SOLIDIFY_MODE_NONMANIFOLD = 1,
+};
+
+/** #SolidifyModifierData.nonmanifold_offset_mode */
+enum {
+  MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_FIXED = 0,
+  MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_EVEN = 1,