[Bf-blender-cvs] [1bed7209823] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained

2021-06-20 Thread YimingWu
Commit: 1bed7209823ad17ed3b5de7220ae4d32f02603aa
Author: YimingWu
Date:   Mon Jun 21 09:15:21 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB1bed7209823ad17ed3b5de7220ae4d32f02603aa

Merge remote-tracking branch 'origin/master' into temp-lineart-contained

===



===



___
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] [b2510b9e20a] master: Fix T89271: Selecting all vertices doesn't select all edges.

2021-06-20 Thread Jeroen Bakker
Commit: b2510b9e20a4b6ce6bee68e89a801c33b4c2bf9d
Author: Jeroen Bakker
Date:   Mon Jun 21 07:55:49 2021 +0200
Branches: master
https://developer.blender.org/rBb2510b9e20a4b6ce6bee68e89a801c33b4c2bf9d

Fix T89271: Selecting all vertices doesn't select all edges.

Mistake in recent commit {rBea4309925f1d2d2a224bd1dce12269a58ade9b62}.

===

M   source/blender/bmesh/intern/bmesh_marking.c

===

diff --git a/source/blender/bmesh/intern/bmesh_marking.c 
b/source/blender/bmesh/intern/bmesh_marking.c
index c58aaf17116..19d94613afe 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -345,10 +345,11 @@ void BM_mesh_select_mode_flush_ex(BMesh *bm, const short 
selectmode, eBMSelectio
 /* both loops only set edge/face flags and read off verts */
 BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
   const bool is_selected = BM_elem_flag_test(e, BM_ELEM_SELECT);
-  if (!is_selected &&
+  const bool is_hidden = BM_elem_flag_test(e, BM_ELEM_HIDDEN);
+  if (!is_hidden &&
   (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && 
BM_elem_flag_test(e->v2, BM_ELEM_SELECT))) {
 BM_elem_flag_enable(e, BM_ELEM_SELECT);
-bm->totedgesel += 1;
+bm->totedgesel += is_selected ? 0 : 1;
   }
   else {
 BM_elem_flag_disable(e, BM_ELEM_SELECT);

___
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] [feb6fd632f6] master: Cleanup: Rename spline interpolation functions

2021-06-20 Thread Hans Goudey
Commit: feb6fd632f6d6c645c715c5e5e8bcdb9b3eab057
Author: Hans Goudey
Date:   Sun Jun 20 22:05:57 2021 -0500
Branches: master
https://developer.blender.org/rBfeb6fd632f6d6c645c715c5e5e8bcdb9b3eab057

Cleanup: Rename spline interpolation functions

The names were slightly longer than they needed to be clear,
and when they are shorter they tend to fit on one line better.

===

M   source/blender/blenkernel/BKE_spline.hh
M   source/blender/blenkernel/intern/spline_base.cc
M   source/blender/blenkernel/intern/spline_bezier.cc
M   source/blender/blenkernel/intern/spline_nurbs.cc
M   source/blender/blenkernel/intern/spline_poly.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc

===

diff --git a/source/blender/blenkernel/BKE_spline.hh 
b/source/blender/blenkernel/BKE_spline.hh
index f4a27c91e67..b5d06da4651 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -49,7 +49,7 @@ using SplinePtr = std::unique_ptr;
  * evaluation happens in a layer on top of the evaluated points generated by 
the derived types.
  *
  * There are a few methods to evaluate a spline:
- *  1. #evaluated_positions and #interpolate_to_evaluated_points give data for 
the initial
+ *  1. #evaluated_positions and #interpolate_to_evaluated give data for the 
initial
  * evaluated points, depending on the resolution.
  *  2. #lookup_evaluated_factor and #lookup_evaluated_factor are meant for 
one-off lookups
  * along the length of a curve.
@@ -171,23 +171,23 @@ class Spline {
   blender::Array sample_uniform_index_factors(const int samples_size) 
const;
   LookupResult lookup_data_from_index_factor(const float index_factor) const;
 
-  void sample_based_on_index_factors(const blender::fn::GVArray &src,
- blender::Span index_factors,
- blender::fn::GMutableSpan dst) const;
+  void sample_with_index_factors(const blender::fn::GVArray &src,
+ blender::Span index_factors,
+ blender::fn::GMutableSpan dst) const;
   template
-  void sample_based_on_index_factors(const blender::VArray &src,
- blender::Span index_factors,
- blender::MutableSpan dst) const
+  void sample_with_index_factors(const blender::VArray &src,
+ blender::Span index_factors,
+ blender::MutableSpan dst) const
   {
-this->sample_based_on_index_factors(
+this->sample_with_index_factors(
 blender::fn::GVArray_For_VArray(src), index_factors, 
blender::fn::GMutableSpan(dst));
   }
   template
-  void sample_based_on_index_factors(blender::Span src,
- blender::Span index_factors,
- blender::MutableSpan dst) const
+  void sample_with_index_factors(blender::Span src,
+ blender::Span index_factors,
+ blender::MutableSpan dst) const
   {
-this->sample_based_on_index_factors(blender::VArray_For_Span(src), 
index_factors, dst);
+this->sample_with_index_factors(blender::VArray_For_Span(src), 
index_factors, dst);
   }
 
   /**
@@ -195,14 +195,13 @@ class Spline {
* evaluated points. For poly splines, the lifetime of the returned virtual 
array must not
* exceed the lifetime of the input data.
*/
-  virtual blender::fn::GVArrayPtr interpolate_to_evaluated_points(
+  virtual blender::fn::GVArrayPtr interpolate_to_evaluated(
   const blender::fn::GVArray &source_data) const = 0;
-  blender::fn::GVArrayPtr interpolate_to_evaluated_points(blender::fn::GSpan 
data) const;
+  blender::fn::GVArrayPtr interpolate_to_evaluated(blender::fn::GSpan data) 
const;
   template
-  blender::fn::GVArray_Typed 
interpolate_to_evaluated_points(blender::Span data) const
+  blender::fn::GVArray_Typed interpolate_to_evaluated(blender::Span 
data) const
   {
-return blender::fn::GVArray_Typed(
-this->interpolate_to_evaluated_points(blender::fn::GSpan(data)));
+return 
blender::fn::GVArray_Typed(this->interpolate_to_evaluated(blender::fn::GSpan(data)));
   }
 
  protected:
@@ -333,7 +332,7 @@ class BezierSpline final : public Spline {
   };
   InterpolationData interpolation_data_from_index_factor(const float 
index_factor) const;
 
-  virtual blender::fn::GVArrayPtr interpolate_to_evaluated_points(
+  virtual blender::fn::GVArrayPtr interpolate_to_evaluated(
   const blender::fn::GVArray &source_data) const override;
 
   void evaluate_segment(const int index,
@@ -456,7 +455,7 @@ class NURBSpline f

[Bf-blender-cvs] [a1c3e451002] master: Geometry Nodes: Multithread curve resample node

2021-06-20 Thread Hans Goudey
Commit: a1c3e451002b79b5822da78e9562f12a6f1b0cc6
Author: Hans Goudey
Date:   Sun Jun 20 21:57:47 2021 -0500
Branches: master
https://developer.blender.org/rBa1c3e451002b79b5822da78e9562f12a6f1b0cc6

Geometry Nodes: Multithread curve resample node

Optimize the node for the case of many splines. In a test file with
14000 splines, the node is 3x faster (72ms to 24ms) on an 8 core CPU.

===

M   source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc 
b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
index e879ec624c0..bf122bab613 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
@@ -138,19 +138,28 @@ static SplinePtr resample_spline(const Spline 
&input_spline, const int count)
 static std::unique_ptr resample_curve(const CurveEval &input_curve,
  const SampleModeParam 
&mode_param)
 {
-  std::unique_ptr output_curve = std::make_unique();
+  Span input_splines = input_curve.splines();
 
-  for (const SplinePtr &spline : input_curve.splines()) {
-if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_COUNT) {
-  BLI_assert(mode_param.count);
-  output_curve->add_spline(resample_spline(*spline, *mode_param.count));
-}
-else if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_LENGTH) {
-  BLI_assert(mode_param.length);
-  const float length = spline->length();
-  const int count = std::max(int(length / *mode_param.length), 1);
-  output_curve->add_spline(resample_spline(*spline, count));
-}
+  std::unique_ptr output_curve = std::make_unique();
+  output_curve->resize(input_splines.size());
+  MutableSpan output_splines = output_curve->splines();
+
+  if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_COUNT) {
+threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange 
range) {
+  for (const int i : range) {
+BLI_assert(mode_param.count);
+output_splines[i] = resample_spline(*input_splines[i], 
*mode_param.count);
+  }
+});
+  }
+  else if (mode_param.mode == GEO_NODE_CURVE_SAMPLE_LENGTH) {
+threading::parallel_for(input_splines.index_range(), 128, [&](IndexRange 
range) {
+  for (const int i : range) {
+const float length = input_splines[i]->length();
+const int count = std::max(int(length / *mode_param.length), 1);
+output_splines[i] = resample_spline(*input_splines[i], count);
+  }
+});
   }
 
   output_curve->attributes = input_curve.attributes;

___
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] [b45cee1aafd] master: Cleanup: use early return in view3d iterator callbacks

2021-06-20 Thread Campbell Barton
Commit: b45cee1aafdd04221e7991a0be155f0101345897
Author: Campbell Barton
Date:   Mon Jun 21 12:49:16 2021 +1000
Branches: master
https://developer.blender.org/rBb45cee1aafdd04221e7991a0be155f0101345897

Cleanup: use early return in view3d iterator callbacks

===

M   source/blender/editors/space_view3d/view3d_iterators.c

===

diff --git a/source/blender/editors/space_view3d/view3d_iterators.c 
b/source/blender/editors/space_view3d/view3d_iterators.c
index bdb2c3874db..190cc787eea 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -150,17 +150,17 @@ static void mesh_foreachScreenVert__mapFunc(void 
*userData,
 {
   foreachScreenVert_userData *data = userData;
   BMVert *eve = BM_vert_at_index(data->vc.em->bm, index);
+  if (UNLIKELY(BM_elem_flag_test(eve, BM_ELEM_HIDDEN))) {
+return;
+  }
 
-  if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
-float screen_co[2];
-
-if (ED_view3d_project_float_object(data->vc.region, co, screen_co, 
data->clip_flag) !=
-V3D_PROJ_RET_OK) {
-  return;
-}
-
-data->func(data->userData, eve, screen_co, index);
+  float screen_co[2];
+  if (ED_view3d_project_float_object(data->vc.region, co, screen_co, 
data->clip_flag) !=
+  V3D_PROJ_RET_OK) {
+return;
   }
+
+  data->func(data->userData, eve, screen_co, index);
 }
 
 void mesh_foreachScreenVert(
@@ -198,29 +198,30 @@ static void mesh_foreachScreenEdge__mapFunc(void 
*userData,
 {
   foreachScreenEdge_userData *data = userData;
   BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index);
+  if (UNLIKELY(BM_elem_flag_test(eed, BM_ELEM_HIDDEN))) {
+return;
+  }
 
-  if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
-float screen_co_a[2];
-float screen_co_b[2];
-eV3DProjTest clip_flag_nowin = data->clip_flag & ~V3D_PROJ_TEST_CLIP_WIN;
+  float screen_co_a[2];
+  float screen_co_b[2];
+  eV3DProjTest clip_flag_nowin = data->clip_flag & ~V3D_PROJ_TEST_CLIP_WIN;
 
-if (ED_view3d_project_float_object(data->vc.region, v0co, screen_co_a, 
clip_flag_nowin) !=
-V3D_PROJ_RET_OK) {
-  return;
-}
-if (ED_view3d_project_float_object(data->vc.region, v1co, screen_co_b, 
clip_flag_nowin) !=
-V3D_PROJ_RET_OK) {
-  return;
-}
+  if (ED_view3d_project_float_object(data->vc.region, v0co, screen_co_a, 
clip_flag_nowin) !=
+  V3D_PROJ_RET_OK) {
+return;
+  }
+  if (ED_view3d_project_float_object(data->vc.region, v1co, screen_co_b, 
clip_flag_nowin) !=
+  V3D_PROJ_RET_OK) {
+return;
+  }
 
-if (data->clip_flag & V3D_PROJ_TEST_CLIP_WIN) {
-  if (!BLI_rctf_isect_segment(&data->win_rect, screen_co_a, screen_co_b)) {
-return;
-  }
+  if (data->clip_flag & V3D_PROJ_TEST_CLIP_WIN) {
+if (!BLI_rctf_isect_segment(&data->win_rect, screen_co_a, screen_co_b)) {
+  return;
 }
-
-data->func(data->userData, eed, screen_co_a, screen_co_b, index);
   }
+
+  data->func(data->userData, eed, screen_co_a, screen_co_b, index);
 }
 
 void mesh_foreachScreenEdge(ViewContext *vc,
@@ -271,41 +272,42 @@ static void 
mesh_foreachScreenEdge_clip_bb_segment__mapFunc(void *userData,
 {
   foreachScreenEdge_userData *data = userData;
   BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index);
+  if (UNLIKELY(BM_elem_flag_test(eed, BM_ELEM_HIDDEN))) {
+return;
+  }
 
   BLI_assert(data->clip_flag & V3D_PROJ_TEST_CLIP_BB);
 
-  if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
-float v0co_clip[3];
-float v1co_clip[3];
+  float v0co_clip[3];
+  float v1co_clip[3];
 
-if (!clip_segment_v3_plane_n(v0co, v1co, data->vc.rv3d->clip_local, 4, 
v0co_clip, v1co_clip)) {
-  return;
-}
+  if (!clip_segment_v3_plane_n(v0co, v1co, data->vc.rv3d->clip_local, 4, 
v0co_clip, v1co_clip)) {
+return;
+  }
 
-float screen_co_a[2];
-float screen_co_b[2];
+  float screen_co_a[2];
+  float screen_co_b[2];
 
-/* Clipping already handled, no need to check in projection. */
-eV3DProjTest clip_flag_nowin = data->clip_flag &
-   ~(V3D_PROJ_TEST_CLIP_WIN | 
V3D_PROJ_TEST_CLIP_BB);
+  /* Clipping already handled, no need to check in projection. */
+  eV3DProjTest clip_flag_nowin = data->clip_flag &
+ ~(V3D_PROJ_TEST_CLIP_WIN | 
V3D_PROJ_TEST_CLIP_BB);
 
-if (ED_view3d_project_float_object(data->vc.region, v0co_clip, 
screen_co_a, clip_flag_nowin) !=
-V3D_PROJ_RET_OK) {
-  return;
-}
-if (ED_view3d_project_float_object(data->vc.region, v1co_clip, 
screen_co_b, clip_flag_nowin) !=
-V3D_PROJ_RET_OK) {
-  return;
-}
+  if (ED_view3d_project_float_object(data->vc.region, v0co_clip, screen_co_a, 
clip_flag_nowin) !=
+  V3D_PROJ_RET_OK) {
+return;
+  }
+  if (ED_view3d_project_float_object(data->vc.region, v1co_clip, screen_

[Bf-blender-cvs] [5df6b4004c9] master: Docs: improve imbuf.write docstring

2021-06-20 Thread Campbell Barton
Commit: 5df6b4004c9b03574dcb8056630d88ad5f1d1a0b
Author: Campbell Barton
Date:   Mon Jun 21 12:24:02 2021 +1000
Branches: master
https://developer.blender.org/rB5df6b4004c9b03574dcb8056630d88ad5f1d1a0b

Docs: improve imbuf.write docstring

The file path wasn't documented as being optional.

===

M   source/blender/python/generic/imbuf_py_api.c

===

diff --git a/source/blender/python/generic/imbuf_py_api.c 
b/source/blender/python/generic/imbuf_py_api.c
index 53e22314ec4..793b980295c 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -495,15 +495,16 @@ static PyObject *M_imbuf_load(PyObject *UNUSED(self), 
PyObject *args, PyObject *
   return Py_ImBuf_CreatePyObject(ibuf);
 }
 
-PyDoc_STRVAR(M_imbuf_write_doc,
- ".. function:: write(image, filepath)\n"
- "\n"
- "   Write an image.\n"
- "\n"
- "   :arg image: the image to write.\n"
- "   :type image: :class:`ImBuf`\n"
- "   :arg filepath: the filepath of the image.\n"
- "   :type filepath: string\n");
+PyDoc_STRVAR(
+M_imbuf_write_doc,
+".. function:: write(image, filepath=image.filepath)\n"
+"\n"
+"   Write an image.\n"
+"\n"
+"   :arg image: the image to write.\n"
+"   :type image: :class:`ImBuf`\n"
+"   :arg filepath: Optional filepath of the image (fallback to the images 
file path).\n"
+"   :type filepath: string\n");
 static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, 
PyObject *kw)
 {
   Py_ImBuf *py_imb;

___
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] [5f71b1edd5b] master: Delaunay add support for detecting and removing holes from output.

2021-06-20 Thread Howard Trickey
Commit: 5f71b1edd5bfe71b95f668548c6f9b7cfcf03a17
Author: Howard Trickey
Date:   Sun Jun 20 20:57:22 2021 -0400
Branches: master
https://developer.blender.org/rB5f71b1edd5bfe71b95f668548c6f9b7cfcf03a17

Delaunay add support for detecting and removing holes from output.

Adds two new output modes to the CDT api which detect and remove
holes. A hole is a face from which a ray shot to the outside
intersects an even number of constraint edges, except we don't
count constraint edges in the same connected region of faces,
where a region is connected via non-constraint edges.

These modes are useful for filling in outlines meant to represent
text characters and the like.

Original patch was from Erik Abrahamsson, modified by me to work
with the "valid Bmesh" output type too. I also added tests
for the new modes.

===

M   source/blender/blenlib/BLI_delaunay_2d.h
M   source/blender/blenlib/intern/delaunay_2d.cc
M   source/blender/blenlib/tests/BLI_delaunay_2d_test.cc

===

diff --git a/source/blender/blenlib/BLI_delaunay_2d.h 
b/source/blender/blenlib/BLI_delaunay_2d.h
index e91726991ca..d42bd6af637 100644
--- a/source/blender/blenlib/BLI_delaunay_2d.h
+++ b/source/blender/blenlib/BLI_delaunay_2d.h
@@ -178,6 +178,8 @@ typedef enum CDT_output_type {
   CDT_FULL,
   /** All triangles fully enclosed by constraint edges or faces. */
   CDT_INSIDE,
+  /** Like previous, but detect holes and omit those from output. */
+  CDT_INSIDE_WITH_HOLES,
   /** Only point, edge, and face constraints, and their intersections. */
   CDT_CONSTRAINTS,
   /**
@@ -186,7 +188,9 @@ typedef enum CDT_output_type {
* #BMesh faces in Blender: that is,
* no vertex appears more than once and no isolated holes in faces.
*/
-  CDT_CONSTRAINTS_VALID_BMESH
+  CDT_CONSTRAINTS_VALID_BMESH,
+  /** Like previous, but detect holes and omit those from output. */
+  CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES,
 } CDT_output_type;
 
 /**
diff --git a/source/blender/blenlib/intern/delaunay_2d.cc 
b/source/blender/blenlib/intern/delaunay_2d.cc
index 9444d1a29cb..eb3e64c49e6 100644
--- a/source/blender/blenlib/intern/delaunay_2d.cc
+++ b/source/blender/blenlib/intern/delaunay_2d.cc
@@ -226,6 +226,8 @@ template struct CDTFace {
   int visit_index{0};
   /** Marks this face no longer used. */
   bool deleted{false};
+  /** Marks this face as part of a hole. */
+  bool hole{false};
 
   CDTFace() = default;
 };
@@ -481,9 +483,9 @@ template void cdt_draw(const std::string 
&label, const CDTArrangemen
  * This is just for developer debugging anyway, and should never be called in 
production Blender.
  */
 #  ifdef _WIN32
-  const char *drawfile = "./debug_draw.html";
+  const char *drawfile = "./cdt_debug_draw.html";
 #  else
-  const char *drawfile = "/tmp/debug_draw.html";
+  const char *drawfile = "/tmp/cdt_debug_draw.html";
 #  endif
   constexpr int max_draw_width = 1800;
   constexpr int max_draw_height = 1600;
@@ -2364,9 +2366,6 @@ template void 
remove_non_constraint_edges_leave_valid_bmesh(CDT_stat
 
 template void remove_outer_edges_until_constraints(CDT_state 
*cdt_state)
 {
-  // LinkNode *fstack = NULL;
-  // SymEdge *se, *se_start;
-  // CDTFace *f, *fsym;
   int visit = ++cdt_state->visit_count;
 
   cdt_state->cdt.outer_face->visit_index = visit;
@@ -2415,6 +2414,137 @@ template void 
remove_outer_edges_until_constraints(CDT_state *cdt
   }
 }
 
+template void remove_faces_in_holes(CDT_state *cdt_state)
+{
+  CDTArrangement *cdt = &cdt_state->cdt;
+  for (int i : cdt->faces.index_range()) {
+CDTFace *f = cdt->faces[i];
+if (!f->deleted && f->hole) {
+  f->deleted = true;
+  SymEdge *se = f->symedge;
+  SymEdge *se_start = se;
+  SymEdge *se_next = nullptr;
+  do {
+BLI_assert(se != nullptr);
+se_next = se->next; /* In case we delete this edge. */
+if (se->edge && !is_constrained_edge(se->edge)) {
+  /* Invalidate one half of this edge. The other has will be or has 
been
+   * handled with the adjacent triangle is processed: it should be 
part of the same hole.
+   */
+  se->next = nullptr;
+}
+se = se_next;
+  } while (se != se_start);
+}
+  }
+}
+
+/**
+ * Set the hole member of each CDTFace to true for each face that is detected 
to be part of a
+ * hole. A hole face is define as one for which, when a ray is shot from a 
point inside the face
+ * to infinity, it crosses an even number of constraint edges. We'll choose a 
ray direction that
+ * is extremely unlikely to exactly superimpose some edge, so avoiding the 
need to be careful
+ * about such overlaps.
+ *
+ * To improve performance, we gather together faces that should have the same 
winding number, and
+ * only shoot rays once.
+ */
+template void detect_holes(CDT_state *cdt_state)
+{
+  CDTArrangement *cdt = &cdt_state->cdt;
+
+  /* Make 

[Bf-blender-cvs] [80083ac7736] master: Fix T89310: Industry Compatible keymap not working

2021-06-20 Thread Hans Goudey
Commit: 80083ac7736fb27b82c67f9c37cfc9bec43086bc
Author: Hans Goudey
Date:   Sun Jun 20 18:52:01 2021 -0500
Branches: master
https://developer.blender.org/rB80083ac7736fb27b82c67f9c37cfc9bec43086bc

Fix T89310: Industry Compatible keymap not working

Caused by improper testing on my part, assuming a helper function
existed in the industry compatible keymap file, and also assuming it
also used the N and T keys for the left and right side-regions.

===

M   
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py

===

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 237b7237c27..e56783fcc21 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -2144,23 +2144,6 @@ def km_clip_dopesheet_editor(_params):
 return keymap
 
 
-def km_spreadsheet_generic(_params):
-items = []
-keymap = (
-"Spreadsheet Generic",
-{"space_type": 'SPREADSHEET', "region_type": 'WINDOW'},
-{"items": items},
-)
-
-items.extend([
-*_template_space_region_type_toggle(
-sidebar_key={"type": 'N', "value": 'PRESS'},
-),
-])
-
-return keymap
-
-
 # 
--
 # Animation
 
@@ -4084,7 +4067,6 @@ def generate_keymaps_impl(params=None):
 km_image(params),
 km_node_generic(params),
 km_node_editor(params),
-km_spreadsheet_generic(params),
 km_info(params),
 km_file_browser(params),
 km_file_browser_main(params),

___
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] [0cd34967c0a] master: Curves: Multithread Curve to CurveEval conversion

2021-06-20 Thread Hans Goudey
Commit: 0cd34967c0a844c7cebe6f835a3c2303a5e53ef6
Author: Hans Goudey
Date:   Sun Jun 20 18:42:02 2021 -0500
Branches: master
https://developer.blender.org/rB0cd34967c0a844c7cebe6f835a3c2303a5e53ef6

Curves: Multithread Curve to CurveEval conversion

A different data structure / implementation is used for curves in the
node tree currently. Converting from the DNA `Curve` structure to this
wasn't slow, but it's nice to decrease overhead. In a test of 14000
splines with 128000 points, this halves the runtime from about 5ms
to about 2.5ms.

===

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

===

diff --git a/source/blender/blenkernel/intern/curve_eval.cc 
b/source/blender/blenkernel/intern/curve_eval.cc
index c9408cf4fcd..0a6e4458a35 100644
--- a/source/blender/blenkernel/intern/curve_eval.cc
+++ b/source/blender/blenkernel/intern/curve_eval.cc
@@ -15,10 +15,13 @@
  */
 
 #include "BLI_array.hh"
+#include "BLI_index_range.hh"
 #include "BLI_listbase.h"
 #include "BLI_map.hh"
 #include "BLI_span.hh"
 #include "BLI_string_ref.hh"
+#include "BLI_task.hh"
+#include "BLI_vector.hh"
 
 #include "DNA_curve_types.h"
 
@@ -28,9 +31,12 @@
 using blender::Array;
 using blender::float3;
 using blender::float4x4;
+using blender::IndexRange;
 using blender::Map;
+using blender::MutableSpan;
 using blender::Span;
 using blender::StringRefNull;
+using blender::Vector;
 
 blender::Span CurveEval::splines() const
 {
@@ -168,70 +174,118 @@ static NURBSpline::KnotsMode 
knots_mode_from_dna_nurb(const short flag)
   return NURBSpline::KnotsMode::Normal;
 }
 
+static SplinePtr spline_from_dna_bezier(const Nurb &nurb)
+{
+  std::unique_ptr spline = std::make_unique();
+  spline->set_resolution(nurb.resolu);
+  spline->set_cyclic(nurb.flagu & CU_NURB_CYCLIC);
+
+  Span src_points{nurb.bezt, nurb.pntsu};
+  spline->resize(src_points.size());
+  MutableSpan positions = spline->positions();
+  MutableSpan handle_positions_left = spline->handle_positions_left();
+  MutableSpan handle_positions_right = 
spline->handle_positions_right();
+  MutableSpan handle_types_left = 
spline->handle_types_left();
+  MutableSpan handle_types_right = 
spline->handle_types_right();
+  MutableSpan radii = spline->radii();
+  MutableSpan tilts = spline->tilts();
+
+  blender::threading::parallel_for(src_points.index_range(), 2048, 
[&](IndexRange range) {
+for (const int i : range) {
+  const BezTriple &bezt = src_points[i];
+  positions[i] = bezt.vec[1];
+  handle_positions_left[i] = bezt.vec[0];
+  handle_types_left[i] = 
handle_type_from_dna_bezt((eBezTriple_Handle)bezt.h1);
+  handle_positions_right[i] = bezt.vec[2];
+  handle_types_right[i] = 
handle_type_from_dna_bezt((eBezTriple_Handle)bezt.h2);
+  radii[i] = bezt.radius;
+  tilts[i] = bezt.tilt;
+}
+  });
+
+  return spline;
+}
+
+static SplinePtr spline_from_dna_nurbs(const Nurb &nurb)
+{
+  std::unique_ptr spline = std::make_unique();
+  spline->set_resolution(nurb.resolu);
+  spline->set_cyclic(nurb.flagu & CU_NURB_CYCLIC);
+  spline->set_order(nurb.orderu);
+  spline->knots_mode = knots_mode_from_dna_nurb(nurb.flagu);
+
+  Span src_points{nurb.bp, nurb.pntsu};
+  spline->resize(src_points.size());
+  MutableSpan positions = spline->positions();
+  MutableSpan weights = spline->weights();
+  MutableSpan radii = spline->radii();
+  MutableSpan tilts = spline->tilts();
+
+  blender::threading::parallel_for(src_points.index_range(), 2048, 
[&](IndexRange range) {
+for (const int i : range) {
+  const BPoint &bp = src_points[i];
+  positions[i] = bp.vec;
+  weights[i] = bp.vec[3];
+  radii[i] = bp.radius;
+  tilts[i] = bp.tilt;
+}
+  });
+
+  return spline;
+}
+
+static SplinePtr spline_from_dna_poly(const Nurb &nurb)
+{
+  std::unique_ptr spline = std::make_unique();
+  spline->set_cyclic(nurb.flagu & CU_NURB_CYCLIC);
+
+  Span src_points{nurb.bp, nurb.pntsu};
+  spline->resize(src_points.size());
+  MutableSpan positions = spline->positions();
+  MutableSpan radii = spline->radii();
+  MutableSpan tilts = spline->tilts();
+
+  blender::threading::parallel_for(src_points.index_range(), 2048, 
[&](IndexRange range) {
+for (const int i : range) {
+  const BPoint &bp = src_points[i];
+  positions[i] = bp.vec;
+  radii[i] = bp.radius;
+  tilts[i] = bp.tilt;
+}
+  });
+
+  return spline;
+}
+
 std::unique_ptr curve_eval_from_dna_curve(const Curve &dna_curve)
 {
+  Vector nurbs(*BKE_curve_nurbs_get(&const_cast(dna_curve)));
+
   std::unique_ptr curve = std::make_unique();
+  curve->resize(nurbs.size());
+  MutableSpan splines = curve->splines();
 
-  const ListBase *nurbs = BKE_curve_nurbs_get(&const_cast(dna_curve));
-
-  /* TODO: Optimize by reserving the correct points size. */
-  LISTBASE_FOREACH (const Nurb *, nurb, nurbs) {
-switch (nurb->type) {
-  case CU_BEZIER:

[Bf-blender-cvs] [ca4ac36c59e] temp_bmesh_multires: Merge branch 'master' into temp_bmesh_multires

2021-06-20 Thread Joseph Eagar
Commit: ca4ac36c59edf97e2bf25f56ba5646b51cf8c22f
Author: Joseph Eagar
Date:   Sun Jun 20 15:58:24 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rBca4ac36c59edf97e2bf25f56ba5646b51cf8c22f

Merge branch 'master' into temp_bmesh_multires

===



===

diff --cc source/blender/blenkernel/intern/mesh.c
index 5ab7b38ed69,08d3236f3a9..190596571b0
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@@ -1012,7 -1027,7 +1028,7 @@@ BMesh *BKE_mesh_to_bmesh_ex(const Objec
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me);
  
BMesh *bm = BM_mesh_create(&allocsize, create_params);
-   BM_mesh_bm_from_me((Object*)ob, bm, me, convert_params);
 -  BM_mesh_bm_from_me(bm, me, convert_params);
++  BM_mesh_bm_from_me((Object *)ob, bm, me, convert_params);
  
return bm;
  }
@@@ -1039,12 -1053,8 +1055,13 @@@ Mesh *BKE_mesh_from_bmesh_nomain(BMesh 
  {
BLI_assert(params->calc_object_remap == false);
Mesh *mesh = BKE_id_new_nomain(ID_ME, NULL);
 -  BM_mesh_bm_to_me(NULL, bm, mesh, params);
 -  BKE_mesh_copy_parameters_for_eval(mesh, me_settings);
++
 +  BM_mesh_bm_to_me(NULL, NULL, bm, mesh, params);
 +
 +  if (me_settings) {
- BKE_mesh_copy_settings(mesh, me_settings);
++BKE_mesh_copy_parameters_for_eval(mesh, me_settings);
 +  }
 +
return mesh;
  }
  
diff --cc source/blender/blenlib/BLI_mempool.h
index 6109a216d95,4d9381093c7..90d78a1d055
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@@ -88,24 -89,6 +89,19 @@@ enum 
  void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) 
ATTR_NONNULL();
  void *BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT 
ATTR_NONNULL();
  
- BLI_mempool_iter *BLI_mempool_iter_threadsafe_create(BLI_mempool *pool,
-  const size_t num_iter) 
ATTR_WARN_UNUSED_RESULT
- ATTR_NONNULL();
- void BLI_mempool_iter_threadsafe_free(BLI_mempool_iter *iter_arr) 
ATTR_NONNULL();
- 
 +/*
 +This preallocates a mempool suitable for threading.  totelem elements are 
preallocated
 +in chunks of size pchunk, and returned in r_chunks.
 +*/
 +
 +BLI_mempool *BLI_mempool_create_for_tasks(const unsigned int esize,
 +  unsigned int totelem,
 +  const unsigned int pchunk,
 +  void ***r_chunks,
 +  unsigned int *r_totchunk,
 +  unsigned int *r_esize,
 +  unsigned int flag);
 +
  #ifdef __cplusplus
  }
  #endif
diff --cc source/blender/editors/mesh/editmesh_tools.c
index bf0b6f4a7ca,d4491721689..4c3149f2529
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@@ -4206,7 -4391,7 +4391,8 @@@ static Base *mesh_separate_tagged
  
BM_mesh_normals_update(bm_new);
  
-   BM_mesh_bm_to_me(bmain, base_new->object, bm_new, base_new->object->data, 
(&(struct BMeshToMeshParams){0}));
 -  BM_mesh_bm_to_me(bmain, bm_new, base_new->object->data, (&(struct 
BMeshToMeshParams){0}));
++  BM_mesh_bm_to_me(
++  bmain, base_new->object, bm_new, base_new->object->data, (&(struct 
BMeshToMeshParams){0}));
  
BM_mesh_free(bm_new);
((Mesh *)base_new->object->data)->edit_mesh = NULL;
@@@ -4272,7 -4457,7 +4458,8 @@@ static Base *mesh_separate_arrays(Main 
  BM_vert_kill(bm_old, verts[i]);
}
  
-   BM_mesh_bm_to_me(bmain, base_new->object, bm_new, base_new->object->data, 
(&(struct BMeshToMeshParams){0}));
 -  BM_mesh_bm_to_me(bmain, bm_new, base_new->object->data, (&(struct 
BMeshToMeshParams){0}));
++  BM_mesh_bm_to_me(
++  bmain, base_new->object, bm_new, base_new->object->data, (&(struct 
BMeshToMeshParams){0}));
  
BM_mesh_free(bm_new);
((Mesh *)base_new->object->data)->edit_mesh = NULL;
@@@ -4454,7 -4639,7 +4641,8 @@@ static bool mesh_separate_loose
BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, 
BM_ELEM_SELECT, false);
  
if (clear_object_data) {
- BM_mesh_bm_to_me(NULL, base_old->object,
+ BM_mesh_bm_to_me(NULL,
++ base_old->object,
   bm_old,
   me_old,
   (&(struct BMeshToMeshParams){
@@@ -5706,112 -5933,6 +5937,116 @@@ static void edbm_dissolve_prop__use_bou
"Split off face corners instead of merging faces");
  }
  
 +static int edbm_mres_test_exec(bContext *C, wmOperator *op)
 +{
 +  const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split");
 +  const bool use_boundary_tear = RNA_boolean_get(op->ptr, 
"use_boundary_tear");
 +
 +  ViewLayer *view_layer = CTX_data_view_layer(C);
 +  uint objects_len = 0;
 +  Object **objec

[Bf-blender-cvs] [6afafc46f63] master: Fix: Spreadsheet selection filter crash on non-mesh components

2021-06-20 Thread Hans Goudey
Commit: 6afafc46f639c49a0d12a22c3ce298c6b6396ec9
Author: Hans Goudey
Date:   Sun Jun 20 17:39:18 2021 -0500
Branches: master
https://developer.blender.org/rB6afafc46f639c49a0d12a22c3ce298c6b6396ec9

Fix: Spreadsheet selection filter crash on non-mesh components

The spreadsheet filter tried to apply the mesh selection filter on non-
mesh geometry components. Add a check for the component type,
and also refactor the function to be more easily readable.

===

M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc

===

diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 77248254d7b..0c76c8b7a15 100644
--- 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -226,15 +226,23 @@ static void get_selected_indices_on_domain(const Mesh 
&mesh,
   }
 }
 
+/**
+ * Only data sets corresponding to mesh objects in edit mode currently support 
selection filtering.
+ */
 bool GeometryDataSource::has_selection_filter() const
 {
   Object *object_orig = DEG_get_original_object(object_eval_);
-  if (object_orig->type == OB_MESH) {
-if (object_orig->mode == OB_MODE_EDIT) {
-  return true;
-}
+  if (object_orig->type != OB_MESH) {
+return false;
   }
-  return false;
+  if (object_orig->mode != OB_MODE_EDIT) {
+return false;
+  }
+  if (component_->type() != GEO_COMPONENT_TYPE_MESH) {
+return false;
+  }
+
+  return true;
 }
 
 void GeometryDataSource::apply_selection_filter(MutableSpan 
rows_included) const

___
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] [50cbc830209] temp-angavrilov-constraints: Animation: allow specifying a custom frame range for actions.

2021-06-20 Thread Alexander Gavrilov
Commit: 50cbc830209cc45c92ef713ea3247692a623bb0d
Author: Alexander Gavrilov
Date:   Mon May 3 00:03:00 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB50cbc830209cc45c92ef713ea3247692a623bb0d

Animation: allow specifying a custom frame range for actions.

Some operations, e.g. adding a new action strip to NLA, require
knowing the active frame range of an action, but currently it can
only be deduced by scanning the keyframes of the curves within it.
This is not ideal if e.g. curves are staggered for overlap.

As suggested by Nathan Vegdahl, this patch adds Action properties
that allow manually specifying its active frame range, and whether
it is intended to be cyclic. The settings are exposed in a popover
in Action Editor. When enabled, the range is highlighted in the
background using a striped fill to distinguish it from the solid
filled regular playback range.

When set, the frame range is used by NLA. In addition, the Cycle-Aware
Keying option automatically sets up F-Curves newly added to a cyclic
action to use cyclic extrapolation with the correct period.

===

M   release/scripts/startup/bl_ui/space_dopesheet.py
M   source/blender/blenkernel/BKE_action.h
M   source/blender/blenkernel/intern/action.c
M   source/blender/blenkernel/intern/nla.c
M   source/blender/editors/animation/anim_draw.c
M   source/blender/editors/animation/keyframing.c
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/space_action/action_data.c
M   source/blender/editors/space_action/space_action.c
M   source/blender/editors/space_nla/nla_edit.c
M   source/blender/makesdna/DNA_action_types.h
M   source/blender/makesrna/intern/rna_action.c
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index ffb7b9e5c20..4ee37176a5d 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -251,6 +251,12 @@ class DOPESHEET_HT_editor_buttons:
 
 layout.template_ID(st, "action", new="action.new", 
unlink="action.unlink")
 
+layout.popover(
+panel="DOPESHEET_PT_action_range",
+text="",
+icon='PREVIEW_RANGE',
+)
+
 # Layer management
 if st.mode == 'GPENCIL':
 ob = context.active_object
@@ -707,6 +713,33 @@ class LayersDopeSheetPanel:
 return False
 
 
+class DOPESHEET_PT_action_range(Panel):
+bl_space_type = 'DOPESHEET_EDITOR'
+bl_region_type = 'HEADER'
+bl_label = "Custom Frame Range"
+bl_description = "Explicitly specify the intended playback frame range of 
the action"
+
+@classmethod
+def poll(cls, context):
+st = context.space_data
+return st and st.mode in {'ACTION', 'SHAPEKEY'} and st.action
+
+def draw(self, context):
+layout = self.layout
+action = context.space_data.action
+
+layout.prop(action, "use_frame_range", text="Use Custom Range")
+
+col = layout.column()
+col.active = action.use_frame_range
+
+row = col.row(align=True)
+row.prop(action, "frame_start", text="Start")
+row.prop(action, "frame_end", text="End")
+
+col.prop(action, "is_cyclic")
+
+
 class DOPESHEET_PT_gpencil_mode(LayersDopeSheetPanel, Panel):
 # bl_space_type = 'DOPESHEET_EDITOR'
 # bl_region_type = 'UI'
@@ -778,6 +811,7 @@ classes = (
 DOPESHEET_MT_channel_context_menu,
 DOPESHEET_MT_snap_pie,
 DOPESHEET_PT_filters,
+DOPESHEET_PT_action_range,
 DOPESHEET_PT_gpencil_mode,
 DOPESHEET_PT_gpencil_layer_masks,
 DOPESHEET_PT_gpencil_layer_transform,
diff --git a/source/blender/blenkernel/BKE_action.h 
b/source/blender/blenkernel/BKE_action.h
index 3d81fcba37d..5c87e8f70a4 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -91,9 +91,15 @@ short action_get_item_transforms(struct bAction *act,
 /* Some kind of bounding box operation on the action */
 void calc_action_range(const struct bAction *act, float *start, float *end, 
short incl_modifiers);
 
+/* Retrieve the frame range, using the custom range if set. */
+void BKE_action_get_frame_range(const struct bAction *act, float *start, float 
*end);
+
 /* Does action have any motion data at all? */
 bool action_has_motion(const struct bAction *act);
 
+/* Is the action configured as cyclic. */
+bool BKE_action_is_cyclic(const struct bAction *act);
+
 /* Action Groups API - */
 
 /* Get the active action-group for an Action */
diff --git a/source/blender/blenkernel/intern/action.c 
b/source/blender/blenkernel/intern/action.c
index 2fdb4963c87..ef5d2f8bcb8 100644
--- a/source/blender/blen

[Bf-blender-cvs] [5af26dfc00a] temp-angavrilov-constraints: Animation: support filtering for curves with a cycle period mismatch.

2021-06-20 Thread Alexander Gavrilov
Commit: 5af26dfc00a19deee63e794a7eda6007f3171bfd
Author: Alexander Gavrilov
Date:   Mon May 3 17:27:53 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB5af26dfc00a19deee63e794a7eda6007f3171bfd

Animation: support filtering for curves with a cycle period mismatch.

Since the looping behavior is defined per curve rather than at
action level, it is possible for curve loop periods to get out of
sync with each other. This commit adds an option to compare curves
against the frame range specified in the action, and treat those
with a mismatch as errors for the purpose of F-Curve filtering.

When enabled, the check verifies that curves within the action
have valid cyclic extrapolation, and the action period evenly
divides by the curve period (since a curve looping at e.g. half
of the action period length still repeats in sync with the action).

===

M   release/scripts/startup/bl_ui/space_dopesheet.py
M   source/blender/editors/animation/anim_filter.c
M   source/blender/makesdna/DNA_action_types.h
M   source/blender/makesrna/intern/rna_action.c

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index 4ee37176a5d..1bc2b7895e3 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -737,7 +737,11 @@ class DOPESHEET_PT_action_range(Panel):
 row.prop(action, "frame_start", text="Start")
 row.prop(action, "frame_end", text="End")
 
-col.prop(action, "is_cyclic")
+row = col.row()
+row.prop(action, "is_cyclic")
+row = row.row()
+row.active = action.is_cyclic
+row.prop(action, "use_cyclic_errors", icon="ERROR", text="", 
toggle=True)
 
 
 class DOPESHEET_PT_gpencil_mode(LayersDopeSheetPanel, Panel):
diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index a03f19d0111..e81161366cc 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -40,6 +40,7 @@
  * -- Joshua Leung, Dec 2008 (Last revision July 2009)
  */
 
+#include 
 #include 
 
 #include "DNA_anim_types.h"
@@ -1217,7 +1218,7 @@ static bool skip_fcurve_with_name(
  *
  * \return true if F-Curve has errors/is disabled
  */
-static bool fcurve_has_errors(FCurve *fcu)
+static bool fcurve_has_errors(FCurve *fcu, bAction *act)
 {
   /* F-Curve disabled - path eval error */
   if (fcu->flag & FCURVE_DISABLED) {
@@ -1249,6 +1250,37 @@ static bool fcurve_has_errors(FCurve *fcu)
 }
   }
 
+  /* Check cycle errors. */
+  const int cyclic_error_mask = ACT_FRAME_RANGE | ACT_CYCLIC | 
ACT_CYCLIC_ERRORS;
+
+  if (act && (act->flag & cyclic_error_mask) == cyclic_error_mask) {
+/* Check if the curve has enough points. */
+if (fcu->totvert < 2 || !fcu->bezt) {
+  return true;
+}
+
+/* Check if it is cyclic. */
+FModifier *fmod = fcu->modifiers.first;
+if (!fmod || fmod->type != FMODIFIER_TYPE_CYCLES) {
+  return true;
+}
+
+/* Check that it has a nonzero period length. */
+float curve_period = fcu->bezt[fcu->totvert - 1].vec[1][0] - 
fcu->bezt[0].vec[1][0];
+
+if (curve_period < 0.01f) {
+  return true;
+}
+
+/* Check that the action period is divisible by the curve period. */
+float action_period = act->frame_end - act->frame_start;
+float gap = action_period - roundf(action_period / curve_period) * 
curve_period;
+
+if (fabsf(gap) > 0.01f) {
+  return true;
+}
+  }
+
   /* no errors found */
   return false;
 }
@@ -1258,6 +1290,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
   FCurve *first,
   eAnim_ChannelType channel_type,
   int filter_mode,
+  bAction *act,
   void *owner,
   ID *owner_id)
 {
@@ -1309,7 +1342,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
 /* error-based filtering... */
 if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
   /* skip if no errors... */
-  if (fcurve_has_errors(fcu) == false) {
+  if (fcurve_has_errors(fcu, act) == false) {
 continue;
   }
 }
@@ -1331,6 +1364,7 @@ static size_t animfilter_fcurves(ListBase *anim_data,
  FCurve *first,
  eAnim_ChannelType fcurve_type,
  int filter_mode,
+ bAction *act,
  void *owner,
  ID *owner_id,
  

[Bf-blender-cvs] [eaf8ab08faf] temp-angavrilov-constraints: Bone Overlay: support bone wireframe opacity settings.

2021-06-20 Thread Alexander Gavrilov
Commit: eaf8ab08faf2397949d3a4684c45e51e3af2d1ff
Author: Alexander Gavrilov
Date:   Sun Jan 3 23:40:44 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rBeaf8ab08faf2397949d3a4684c45e51e3af2d1ff

Bone Overlay: support bone wireframe opacity settings.

When weight painting the bone overlay is extremely intrusive,
effectively requiring either extensive use of hiding individual
bones, or disabling the whole bone overlay between selections.

This addresses the issue by adding two bone opacity sliders that
are used for the 'wireframe' armature drawing mode. One directly
controls the opacity in a uniform way. The other one allows fade
based on the depth between the near and far clip planes in order
to provide an automatic visual cue about which bones are closest.

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_armature.c
M   source/blender/draw/engines/overlay/overlay_private.h
M   source/blender/draw/engines/overlay/overlay_shader.c
A   source/blender/draw/engines/overlay/shaders/armature_alpha_lib.glsl
M   source/blender/draw/engines/overlay/shaders/armature_dof_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/armature_envelope_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/armature_shape_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/armature_sphere_solid_frag.glsl
M   source/blender/draw/engines/overlay/shaders/armature_stick_frag.glsl
M   source/blender/draw/engines/overlay/shaders/armature_wire_frag.glsl
M   source/blender/makesdna/DNA_view3d_defaults.h
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 266ca408157..9b67b176557 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6503,17 +6503,18 @@ class VIEW3D_PT_overlay_sculpt(Panel):
 row.prop(overlay, "sculpt_mode_face_sets_opacity", text="Face Sets")
 
 
-class VIEW3D_PT_overlay_pose(Panel):
+class VIEW3D_PT_overlay_bones(Panel):
 bl_space_type = 'VIEW_3D'
 bl_region_type = 'HEADER'
 bl_parent_id = 'VIEW3D_PT_overlay'
-bl_label = "Pose Mode"
+bl_label = "Bones"
 
 @classmethod
 def poll(cls, context):
 mode = context.mode
 return (
 (mode == 'POSE') or
+(mode == 'EDIT_ARMATURE') or
 (mode == 'PAINT_WEIGHT' and context.pose_object)
 )
 
@@ -6533,10 +6534,14 @@ class VIEW3D_PT_overlay_pose(Panel):
 sub = row.row()
 sub.active = display_all and overlay.show_xray_bone
 sub.prop(overlay, "xray_alpha_bone", text="Fade Geometry")
-else:
+elif mode == 'PAINT_WEIGHT':
 row = col.row()
 row.prop(overlay, "show_xray_bone")
 
+row = col.row()
+row.prop(overlay, "bone_wire_alpha")
+row.prop(overlay, "bone_wire_fade")
+
 
 class VIEW3D_PT_overlay_texture_paint(Panel):
 bl_space_type = 'VIEW_3D'
@@ -7704,7 +7709,7 @@ classes = (
 VIEW3D_PT_overlay_texture_paint,
 VIEW3D_PT_overlay_vertex_paint,
 VIEW3D_PT_overlay_weight_paint,
-VIEW3D_PT_overlay_pose,
+VIEW3D_PT_overlay_bones,
 VIEW3D_PT_overlay_sculpt,
 VIEW3D_PT_snapping,
 VIEW3D_PT_proportional_edit,
diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 0fe1267b871..42353ad709d 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -31,6 +31,8 @@
 #include "DNA_genfile.h"
 #include "DNA_listBase.h"
 #include "DNA_modifier_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
 #include "DNA_text_types.h"
 
 #include "BKE_animsys.h"
@@ -390,6 +392,20 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 
   BKE_animdata_main_cb(bmain, do_version_bbone_len_scale_animdata_cb, 
NULL);
 }
+
+/* Initialize the bone wireframe opacity setting. */
+if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", 
"bone_wire_alpha")) {
+  for (bScreen *screen = bmain->screens.first; screen; screen = 
screen->id.next) {
+LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+if (sl->spacetype == SPACE_VIEW3D) {
+  View3D *v3d = (View3D *)sl;
+  v3d->overlay.bone_wire_alpha = 1.0f;
+}
+  }
+}
+  }
+}
   }
 
   /**
diff --gi

[Bf-blender-cvs] [850cc79bf1f] temp-angavrilov-constraints: Copy Transforms: implement Remove Target Shear and more Mix options.

2021-06-20 Thread Alexander Gavrilov
Commit: 850cc79bf1fbe5c66948154f2b0252ae7b48d99f
Author: Alexander Gavrilov
Date:   Wed Nov 4 19:29:27 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB850cc79bf1fbe5c66948154f2b0252ae7b48d99f

Copy Transforms: implement Remove Target Shear and more Mix options.

This constraint can be naturally viewed as a prototype for a future
4x4 matrix math node (or subset thereof), since its basic semantics
already is matrix assignment. Thus it makes sense to add math options
to this constraint to increase flexibility in the meantime.

This patch adds support for several operations that would be useful:

- An option to remove shear in the incoming target matrix.

  Shear is known to cause issues for various mathematical operations,
  so an option to remove it at key points is useful.

  Constraints based on Euler like Copy Rotation and Limit Rotation
  already have always enabled shear removal built in, because their
  math doesn't work correctly with shear.

  In the future node system shear removal would be a separate node
  (and currently Limit Rotation can be used as a Remove Shear constraint).
  However removing shear from the result of the target space conversion
  before mixing (similar to Copy Rotation) has to be built into
  Copy Transforms itself as an option.

- More ways to combine the target and owner matrices.

  Similar to multiple Inherit Scale modes for parenting, there are
  multiple ways one may want to combine matrices based on context.
  This implements 3 variants for each of the Before/After modes
  (one of them already existing).

  - Full implements regular matrix multiplication as the most basic
option. The downside is the risk of creating shear.
  - Aligned emulates the 'anti-shear' Aligned Inherit Scale mode,
and basically uses Full for location, and Split for rotation/scale.
(This choice already existed.)
  - Split Channels combines location, rotation and scale separately.

  Looking at D7547 there is demand for Split Channels in some cases,
  so I think it makes sense to include it in Copy Transforms too, so that
  the Mix menu items can be identical for it and the Action constraint.

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

===

M   release/scripts/startup/bl_ui/properties_constraint.py
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/blenlib/BLI_math_matrix.h
M   source/blender/blenlib/intern/math_matrix.c
M   source/blender/editors/transform/transform_convert.c
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesrna/intern/rna_constraint.c

===

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py 
b/release/scripts/startup/bl_ui/properties_constraint.py
index a88def34767..2a0cf56534c 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -505,6 +505,7 @@ class ConstraintButtonsPanel:
 
 self.target_template(layout, con)
 
+layout.prop(con, "remove_target_shear")
 layout.prop(con, "mix_mode", text="Mix")
 
 self.space_template(layout, con)
diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index 5d7ef12dbc2..0ba331c85bf 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2256,17 +2256,47 @@ static void translike_evaluate(bConstraint *con, 
bConstraintOb *cob, ListBase *t
   bConstraintTarget *ct = targets->first;
 
   if (VALID_CONS_TARGET(ct)) {
+float target_mat[4][4];
+
+copy_m4_m4(target_mat, ct->matrix);
+
+/* Remove the shear of the target matrix if enabled.
+ * Use Y as the axis since it's the natural default for bones. */
+if (data->flag & TRANSLIKE_REMOVE_TARGET_SHEAR) {
+  orthogonalize_m4_stable(target_mat, 1, false);
+}
+
+/* Finally, combine the matrices. */
 switch (data->mix_mode) {
   case TRANSLIKE_MIX_REPLACE:
-copy_m4_m4(cob->matrix, ct->matrix);
+copy_m4_m4(cob->matrix, target_mat);
+break;
+
+  /* Simple matrix multiplication. */
+  case TRANSLIKE_MIX_BEFORE_FULL:
+mul_m4_m4m4(cob->matrix, target_mat, cob->matrix);
+break;
+
+  case TRANSLIKE_MIX_AFTER_FULL:
+mul_m4_m4m4(cob->matrix, cob->matrix, target_mat);
 break;
 
+  /* Aligned Inherit Scale emulation. */
   case TRANSLIKE_MIX_BEFORE:
-mul_m4_m4m4_aligned_scale(cob->matrix, ct->matrix, cob->matrix);
+mul_m4_m4m4_aligned_scale(cob->matrix, target_mat, cob->matrix);
 break;
 
   case TRANSLIKE_MIX_AFTER:
-mul_m4_m4m4_aligned_scale(cob->matrix, cob->matrix, ct->matrix);
+mul_m4_m4m4_aligned_scale(cob->matrix, cob->matrix, target_mat);
+break;
+
+  

[Bf-blender-cvs] [24ae08308b1] temp-angavrilov-constraints: Armature: apply Y scale to B-Bone segments.

2021-06-20 Thread Alexander Gavrilov
Commit: 24ae08308b185fad0a209ba1e341a66e28064372
Author: Alexander Gavrilov
Date:   Tue Jun 15 13:52:23 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB24ae08308b185fad0a209ba1e341a66e28064372

Armature: apply Y scale to B-Bone segments.

This fixes a strange behavior where the segments were not actually
scaled in the Y direction to match their actual length, thus
producing gaps or overlap depending on the shape of the curve. For
transformation the change should be very small if enough segments
are used, but this will affect the results of the Copy Transforms
and Armature constraints, so a backwards compatibility option is
provided. Newly created bones default to the new behavior.

===

M   release/scripts/startup/bl_ui/properties_data_bone.py
M   source/blender/blenkernel/BKE_armature.h
M   source/blender/blenkernel/intern/armature.c
M   source/blender/draw/engines/overlay/overlay_armature.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/makesdna/DNA_armature_types.h
M   source/blender/makesrna/intern/rna_armature.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py 
b/release/scripts/startup/bl_ui/properties_data_bone.py
index daf64642f68..d141501d6bc 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -178,6 +178,8 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
 col.prop(bbone, "bbone_easeout", text="Out")
 col.prop(bone, "use_scale_easing")
 
+topcol.prop(bone, "use_unscaled_segments")
+
 col = topcol.column(align=True)
 col.prop(bone, "bbone_handle_type_start", text="Start Handle")
 
diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index 112b8bf3ad4..a603a54810c 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -288,7 +288,7 @@ typedef struct BBoneSplineParameters {
   float length;
 
   /* Non-uniform scale correction. */
-  bool do_scale;
+  bool do_scale, do_scale_segments;
   float scale[3];
 
   /* Handle control bone data. */
diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index d308b2da6a3..e2e33821d59 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -967,6 +967,8 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel 
*pchan,
   param->segments = bone->segments;
   param->length = bone->length;
 
+  param->do_scale_segments = (bone->bbone_flag & BBONE_SCALE_SEGMENTS) != 0;
+
   if (!rest) {
 float scale[3];
 
@@ -1335,6 +1337,7 @@ static void 
make_bbone_spline_matrix(BBoneSplineParameters *param,
  const float axis[3],
  float roll,
  float scalex,
+ float scaley,
  float scalez,
  float result[4][4])
 {
@@ -1352,6 +1355,7 @@ static void 
make_bbone_spline_matrix(BBoneSplineParameters *param,
 
   /* BBone scale... */
   mul_v3_fl(result[0], scalex);
+  mul_v3_fl(result[1], scaley);
   mul_v3_fl(result[2], scalez);
 }
 
@@ -1418,6 +1422,8 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters 
*param,
   equalize_cubic_bezier(
   bezt_controls, MAX_BBONE_SUBDIV, param->segments, segment_scales, 
bezt_points);
 
+  const float scale_fac = param->segments / length;
+
   /* Deformation uses N+1 matrices computed at points between the segments. */
   if (for_deform) {
 /* Bezier derivatives. */
@@ -1430,6 +1436,32 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters 
*param,
   sub_v3_v3v3(bezt_deriv2[i], bezt_deriv1[i + 1], bezt_deriv1[i]);
 }
 
+/* Inner segment points. */
+float points[MAX_BBONE_SUBDIV][3], tangents[MAX_BBONE_SUBDIV][3];
+
+copy_v3_v3(points[0], bezt_controls[0]);
+
+for (int a = 1; a < param->segments; a++) {
+  evaluate_cubic_bezier(bezt_controls, bezt_points[a], points[a], 
tangents[a]);
+}
+
+/* Segment lengths. */
+float seg_length[MAX_BBONE_SUBDIV + 1];
+
+if (param->do_scale_segments) {
+  for (int a = 1; a < param->segments; a++) {
+seg_length[a] = len_v3v3(points[a - 1], points[a]) * scale_fac;
+  }
+
+  seg_length[param->segments] = len_v3v3(points[param->segments - 1], 
bezt_controls[3]) *
+scale_fac;
+}
+else {
+  for (int a = 1; a <= param->segments; a++) {
+seg_length[a] = 1;
+  }
+}
+
 /* End points require special handling to fix zero length handles. */
 ease_handle_axis(bezt_deriv1[0], bezt_deriv2[0], axis);
 make_bb

[Bf-blender-cvs] [3abe1efe85a] temp-angavrilov-constraints: Constraints: support a new Local Space (Owner Orientation) for targets.

2021-06-20 Thread Alexander Gavrilov
Commit: 3abe1efe85ad0c785bdaba050e5a9cccf378df6b
Author: Alexander Gavrilov
Date:   Fri Dec 11 11:53:25 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB3abe1efe85ad0c785bdaba050e5a9cccf378df6b

Constraints: support a new Local Space (Owner Orientation) for targets.

Add a new transformation space choice for bone constraints, which
represent the local transformation of the target bone in the constraint
owner's local space.

The use case for this is transferring the local (i.e. excluding the
effect of parents) motion of one bone to another one, while ignoring
the difference between their rest pose orientations.

Owner Local Space replaces the following setup:

* A `child` bone of the `target`, rotated the same as `owner` in rest pose.
* A `sibling` bone of the `target`, positioned same as `child` in rest
  pose and using Copy Transforms in World Space from `child`.
* The `owner` bone constraint uses Local Space of `sibling`.

(This analogy applies provided both bones use Local Location)

Since the space list is getting long, also add a couple of separators.

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

===

M   source/blender/blenkernel/intern/constraint.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

===

diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index 9df071be754..5d7ef12dbc2 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -299,7 +299,10 @@ void BKE_constraint_mat_convertspace(Object *ob,
   mul_m4_m4m4(mat, imat, mat);
 
   /* Use pose-space as stepping stone for other spaces. */
-  if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
+  if (ELEM(to,
+   CONSTRAINT_SPACE_LOCAL,
+   CONSTRAINT_SPACE_PARLOCAL,
+   CONSTRAINT_SPACE_OWNLOCAL)) {
 /* Call self with slightly different values. */
 BKE_constraint_mat_convertspace(
 ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
@@ -315,6 +318,17 @@ void BKE_constraint_mat_convertspace(Object *ob,
 BKE_armature_mat_pose_to_bone(pchan, mat, mat);
   }
 }
+/* pose to owner local */
+else if (to == CONSTRAINT_SPACE_OWNLOCAL) {
+  /* pose to local */
+  if (pchan->bone) {
+BKE_armature_mat_pose_to_bone(pchan, mat, mat);
+  }
+
+  /* local to owner local (recursive) */
+  BKE_constraint_mat_convertspace(
+  ob, pchan, cob, mat, CONSTRAINT_SPACE_LOCAL, to, keep_scale);
+}
 /* pose to local with parent */
 else if (to == CONSTRAINT_SPACE_PARLOCAL) {
   if (pchan->bone) {
@@ -336,17 +350,59 @@ void BKE_constraint_mat_convertspace(Object *ob,
   }
   case CONSTRAINT_SPACE_LOCAL: /*  FROM LOCALSPACE - */
   {
+/* local to owner local */
+if (to == CONSTRAINT_SPACE_OWNLOCAL) {
+  if (pchan->bone) {
+copy_m4_m4(diff_mat, pchan->bone->arm_mat);
+
+if (cob && cob->pchan && cob->pchan->bone) {
+  invert_m4_m4(imat, cob->pchan->bone->arm_mat);
+  mul_m4_m4m4(diff_mat, imat, diff_mat);
+}
+
+zero_v3(diff_mat[3]);
+invert_m4_m4(imat, diff_mat);
+mul_m4_series(mat, diff_mat, mat, imat);
+  }
+}
 /* local to pose - do inverse procedure that was done for pose to 
local */
+else {
+  if (pchan->bone) {
+/* we need the posespace_matrix = local_matrix + 
(parent_posespace_matrix + restpos) */
+BKE_armature_mat_bone_to_pose(pchan, mat, mat);
+  }
+
+  /* use pose-space as stepping stone for other spaces */
+  if (ELEM(to,
+   CONSTRAINT_SPACE_WORLD,
+   CONSTRAINT_SPACE_PARLOCAL,
+   CONSTRAINT_SPACE_CUSTOM)) {
+/* call self with slightly different values */
+BKE_constraint_mat_convertspace(
+ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
+  }
+}
+break;
+  }
+  case CONSTRAINT_SPACE_OWNLOCAL: { /* -- FROM OWNER LOCAL 
-- */
+/* owner local to local */
 if (pchan->bone) {
-  /* we need the posespace_matrix = local_matrix + 
(parent_posespace_matrix + restpos) */
-  BKE_armature_mat_bone_to_pose(pchan, mat, mat);
+  copy_m4_m4(diff_mat, pchan->bone->arm_mat);
+
+  if (cob && cob->pchan && cob->

[Bf-blender-cvs] [1a1f3e4dbab] temp-angavrilov-constraints: Constraints: refactor the D7437 patch adding Custom Space for constraints.

2021-06-20 Thread Alexander Gavrilov
Commit: 1a1f3e4dbabe8976fe988043be8ac09f253fcc5d
Author: Alexander Gavrilov
Date:   Mon Nov 23 23:42:05 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB1a1f3e4dbabe8976fe988043be8ac09f253fcc5d

Constraints: refactor the D7437 patch adding Custom Space for constraints.

As mentioned in the comments to that patch, I had an idea for
a different way to do some technical aspects, but it was too
complicated to force changes in the original patch. Thus I submit
this follow up patch.

First, instead of modifying all the get_constraint_targets and
flush_constraint_targets callbacks, introduce wrapper functions
for accessing constraint targets, convert all code to use them,
and handle the new reference there uniformly for all constraints.

This incidentally revealed a place in the Collada exporter that
didn't clean up after retrieving the targets.

Also, tag the special target with a flag so other code can
handle it appropriately where necessary. This for instance
allows dependency graph to know that the Use B-Bone Shape
option doesn't affect this specific target.

Finally, rename and simplify the function for initializing the
custom space, and make sure it is called everywhere necessary.

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

===

M   source/blender/blenkernel/BKE_constraint.h
M   source/blender/blenkernel/intern/action.c
M   source/blender/blenkernel/intern/armature.c
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/blenkernel/intern/object.c
M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/editors/armature/armature_naming.c
M   source/blender/editors/armature/armature_relations.c
M   source/blender/editors/armature/pose_select.c
M   source/blender/editors/object/object_constraint.c
M   source/blender/editors/transform/transform_mode.c
M   source/blender/io/collada/BCAnimationSampler.cpp
M   source/blender/io/collada/SceneExporter.cpp
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesrna/intern/rna_constraint.c

===

diff --git a/source/blender/blenkernel/BKE_constraint.h 
b/source/blender/blenkernel/BKE_constraint.h
index afad1e26159..c4f6f855a5a 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -214,6 +214,8 @@ void BKE_constraint_mat_convertspace(struct Object *ob,
  short to,
  const bool keep_scale);
 
+int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *list);
+void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase 
*list, bool no_copy);
 void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph,
   struct Scene *scene,
   struct bConstraint *con,
@@ -227,7 +229,7 @@ void BKE_constraint_targets_for_solving_get(struct 
Depsgraph *depsgraph,
 struct bConstraintOb *ob,
 struct ListBase *targets,
 float ctime);
-void BKE_constraint_custom_object_space_get(float r_mat[4][4], struct 
bConstraint *con);
+void BKE_constraint_custom_object_space_init(struct bConstraintOb *cob, struct 
bConstraint *con);
 void BKE_constraints_solve(struct Depsgraph *depsgraph,
struct ListBase *conlist,
struct bConstraintOb *cob,
diff --git a/source/blender/blenkernel/intern/action.c 
b/source/blender/blenkernel/intern/action.c
index 5db2eceb0d1..2fdb4963c87 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1009,13 +1009,10 @@ void BKE_pose_channels_remove(Object *ob,
   else {
 /* Maybe something the bone references is being removed instead? */
 for (con = pchan->constraints.first; con; con = con->next) {
-  const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
   ListBase targets = {NULL, NULL};
   bConstraintTarget *ct;
 
-  if (cti && cti->get_constraint_targets) {
-cti->get_constraint_targets(con, &targets);
-
+  if (BKE_constraint_targets_get(con, &targets)) {
 for (ct = targets.first; ct; ct = ct->next) {
   if (ct->tar == ob) {
 if (ct->subtarget[0]) {
@@ -1027,9 +1024,7 @@ void BKE_pose_channels_remove(Object *ob,
   }
 }
 
-if (cti->flush_constraint_targets) {
-  cti->flush_constraint_targets(con, &targets, 0);
-}
+ 

[Bf-blender-cvs] [600d267184f] temp-angavrilov-constraints: Depsgraph: connect up drivers on various physics properties.

2021-06-20 Thread Alexander Gavrilov
Commit: 600d267184f85bc31cb6de5cd0dc66d0c698f8e2
Author: Alexander Gavrilov
Date:   Sat Jan 9 21:19:37 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB600d267184f85bc31cb6de5cd0dc66d0c698f8e2

Depsgraph: connect up drivers on various physics properties.

It seems drivers for physics properties weren't being linked to
evaluation nodes. This connects settings used by modifiers
to Geometry; particle settings and rigid body data to Transform
which seems to contain rigid body evaluation; and force fields
to object Transform, since fields can exist on empties.

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

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   source/blender/depsgraph/intern/builder/deg_builder_rna.cc
M   source/blender/makesrna/RNA_access.h

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 8a02228146a..8c7df472049 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1863,6 +1863,27 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene 
*scene)
 }
 FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
   }
+  /* Constraints. */
+  if (rbw->constraints != nullptr) {
+build_collection(nullptr, nullptr, rbw->constraints);
+FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, object) {
+  if (object->rigidbody_constraint == nullptr) {
+continue;
+  }
+  if (object->rigidbody_object != nullptr) {
+/* Avoid duplicate relations for constraints attached to objects. */
+continue;
+  }
+
+  /* Simulation uses object transformation after parenting and solving 
constraints. */
+  OperationKey object_transform_simulation_init_key(
+  &object->id, NodeType::TRANSFORM, 
OperationCode::TRANSFORM_SIMULATION_INIT);
+  add_relation(object_transform_simulation_init_key,
+   rb_simulate_key,
+   "Object Transform -> Rigidbody Sim Eval");
+}
+FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+  }
 }
 
 void DepsgraphRelationBuilder::build_particle_systems(Object *object)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 54c51adec66..a3ff7f155f1 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -278,7 +278,16 @@ RNANodeIdentifier 
RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
RNA_struct_is_a(ptr->type, &RNA_LatticePoint) ||
RNA_struct_is_a(ptr->type, &RNA_MeshUVLoop) ||
RNA_struct_is_a(ptr->type, &RNA_MeshLoopColor) ||
-   RNA_struct_is_a(ptr->type, &RNA_VertexGroupElement)) {
+   RNA_struct_is_a(ptr->type, &RNA_VertexGroupElement) ||
+   ELEM(ptr->type,
+&RNA_CollisionSettings,
+&RNA_SoftBodySettings,
+&RNA_ClothSettings,
+&RNA_ClothCollisionSettings,
+&RNA_DynamicPaintSurface,
+&RNA_DynamicPaintCanvasSettings,
+&RNA_DynamicPaintBrushSettings) ||
+   (ELEM(ptr->type, &RNA_EffectorWeights) && 
GS(node_identifier.id->name) == ID_OB)) {
 /* When modifier is used as FROM operation this is likely referencing to
  * the property (for example, modifier's influence).
  * But when it's used as TO operation, this is geometry component. */
@@ -379,6 +388,20 @@ RNANodeIdentifier 
RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
 node_identifier.type = NodeType::GEOMETRY;
 return node_identifier;
   }
+  else if (GS(node_identifier.id->name) == ID_PA &&
+   ELEM(ptr->type, &RNA_EffectorWeights, &RNA_FieldSettings, 
&RNA_ParticleSettings)) {
+node_identifier.type = NodeType::PARTICLE_SETTINGS;
+return node_identifier;
+  }
+  else if (ELEM(ptr->type,
+&RNA_EffectorWeights,
+&RNA_RigidBodyWorld,
+&RNA_FieldSettings,
+&RNA_RigidBodyObject,
+&RNA_RigidBodyConstraint)) {
+node_identifier.type = NodeType::TRANSFORM;
+return node_identifier;
+  }
   if (prop != nullptr) {
 /* All unknown data effectively falls under "parameter evaluation". */
 node_identifier.type = NodeType::PARAMETERS;
diff --git a/source/blender/makesrna/RNA_access.h 
b/source/blender/makesrna/RNA_access.h
index c691eb3b534..b19615aad24 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -512,7 +512,7 @@ extern StructRNA RNA_RenderLayer;
 extern StructRNA RNA_RenderPass;
 extern StructRNA RNA_Rende

[Bf-blender-cvs] [2d75b39b641] master: Fix T89302: Broken normals after mesh to curve node

2021-06-20 Thread Hans Goudey
Commit: 2d75b39b6412612f1a5c04b08656d7390ede0ba5
Author: Hans Goudey
Date:   Sun Jun 20 13:07:49 2021 -0500
Branches: master
https://developer.blender.org/rB2d75b39b6412612f1a5c04b08656d7390ede0ba5

Fix T89302: Broken normals after mesh to curve node

The normals were broken because the normal calculation mode wasn't set.
This patch adds a default normal mode so all code creating a spline does
not necessarily have to set it manually. In the future there should be a
way to change this value in the node tree.

===

M   source/blender/blenkernel/BKE_spline.hh

===

diff --git a/source/blender/blenkernel/BKE_spline.hh 
b/source/blender/blenkernel/BKE_spline.hh
index 5e88dd02bdd..f4a27c91e67 100644
--- a/source/blender/blenkernel/BKE_spline.hh
+++ b/source/blender/blenkernel/BKE_spline.hh
@@ -72,8 +72,7 @@ class Spline {
 Minimum,
 Tangent,
   };
-  /* Only #Zup is supported at the moment. */
-  NormalCalculationMode normal_mode;
+  NormalCalculationMode normal_mode = Minimum;
 
   blender::bke::CustomDataAttributes attributes;

___
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] [0208c836e33] soc-2021-curves: Cleanup: Addressed several build warnings and style guide issues

2021-06-20 Thread dilithjay
Commit: 0208c836e335d8da227e0d0698cc41429367d71e
Author: dilithjay
Date:   Sat Jun 19 19:25:53 2021 +0530
Branches: soc-2021-curves
https://developer.blender.org/rB0208c836e335d8da227e0d0698cc41429367d71e

Cleanup: Addressed several build warnings and style guide issues

===

M   source/blender/editors/curve/editcurve_pen.c

===

diff --git a/source/blender/editors/curve/editcurve_pen.c 
b/source/blender/editors/curve/editcurve_pen.c
index bc8a213a423..fb0fb5550af 100644
--- a/source/blender/editors/curve/editcurve_pen.c
+++ b/source/blender/editors/curve/editcurve_pen.c
@@ -458,28 +458,19 @@ static int ed_editcurve_addvert(bContext *C, const float 
location_init[3])
   return changed;
 }
 
-static void curve_edit_exit(wmOperator *op)
-{
-}
-
-static void curve_edit_cancel(bContext *UNUSED(C), wmOperator *op)
-{
-  curve_edit_exit(op);
-}
-
-static void mouse_location_to_worldspace(int *mouse_loc,
- float *depth,
- ViewContext vc,
+static void mouse_location_to_worldspace(const int *mouse_loc,
+ const float *depth,
+ const ViewContext *vc,
  float r_location[3])
 {
-  mul_v3_m4v3(r_location, vc.obedit->obmat, depth);
-  ED_view3d_win_to_3d_int(vc.v3d, vc.region, r_location, mouse_loc, 
r_location);
+  mul_v3_m4v3(r_location, vc->obedit->obmat, depth);
+  ED_view3d_win_to_3d_int(vc->v3d, vc->region, r_location, mouse_loc, 
r_location);
 }
 
 static void move_bezt_handles_to_mouse(BezTriple *bezt,
-   bool is_end_point,
+   const bool is_end_point,
const wmEvent *event,
-   ViewContext vc)
+   const ViewContext *vc)
 {
   if (bezt->h1 == HD_VECT && bezt->h2 == HD_VECT) {
 bezt->h1 = HD_ALIGN;
@@ -514,7 +505,7 @@ static void move_bezt_handles_to_mouse(BezTriple *bezt,
   }
 }
 
-static void move_bezt_to_location(BezTriple *bezt, float location[3])
+static void move_bezt_to_location(BezTriple *bezt, const float location[3])
 {
   float change[3];
   sub_v3_v3v3(change, location, bezt->vec[1]);
@@ -547,8 +538,6 @@ static void free_up_selected_handles_for_movement(BezTriple 
*bezt)
 
 static void delete_bezt_from_nurb(BezTriple *bezt, Nurb *nu)
 {
-  if (!bezt || !nu)
-return;
   int index = BKE_curve_nurb_vert_index_get(nu, bezt);
   nu->pntsu -= 1;
   BezTriple *bezt1 = (BezTriple *)MEM_mallocN(nu->pntsu * sizeof(BezTriple), 
"NewBeztCurve");
@@ -561,8 +550,6 @@ static void delete_bezt_from_nurb(BezTriple *bezt, Nurb *nu)
 
 static void delete_bp_from_nurb(BPoint *bp, Nurb *nu)
 {
-  if (!bp || !nu)
-return;
   int index = BKE_curve_nurb_vert_index_get(nu, bp);
   nu->pntsu -= 1;
   BPoint *bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), 
"NewBpCurve");
@@ -573,7 +560,7 @@ static void delete_bp_from_nurb(BPoint *bp, Nurb *nu)
   nu->bp = bp1;
 }
 
-static float get_view_zoom(const float *depth, ViewContext vc)
+static float get_view_zoom(const float *depth, const ViewContext *vc)
 {
   int p1[2] = {0, 0};
   int p2[2] = {100, 0};
@@ -583,16 +570,19 @@ static float get_view_zoom(const float *depth, 
ViewContext vc)
   return 10 / len_v2v2(p1_3d, p2_3d);
 }
 
-static bool *get_closest_point_on_edge(
-float *point, const float pos[2], const float pos1[3], const float 
pos2[3], ViewContext vc)
+static bool get_closest_point_on_edge(float *point,
+  const float pos[2],
+  const float pos1[3],
+  const float pos2[3],
+  const ViewContext *vc)
 {
   float pos1_2d[2], pos2_2d[2], vec1[2], vec2[2], vec3[2];
 
   /* Get screen space coordinates of points. */
   ED_view3d_project_float_object(
-  vc.region, pos1, pos1_2d, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN);
+  vc->region, pos1, pos1_2d, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN);
   ED_view3d_project_float_object(
-  vc.region, pos2, pos2_2d, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN);
+  vc->region, pos2, pos2_2d, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN);
 
   /* Obtain the vectors of each side. */
   sub_v2_v2v2(vec1, pos, pos1_2d);
@@ -601,17 +591,15 @@ static bool *get_closest_point_on_edge(
 
   float dot1 = dot_v2v2(vec1, vec3);
   float dot2 = dot_v2v2(vec2, vec3);
-  float len_vec2_sq = len_squared_v2(vec2);
 
   /* Compare the dot products to identify if both angles are optuse/acute or
   opposite to each other. If they're the same, that indicates that there is a
   perpendicular line from the mouse to the line.*/
   if ((dot1 > 0) == (dot2 > 0)) {
-

[Bf-blender-cvs] [efc9cb67b7e] soc-2021-curves: Changed data initialization to fix warning

2021-06-20 Thread dilithjay
Commit: efc9cb67b7e78d7b01f04327b3662be4a9cb3055
Author: dilithjay
Date:   Sun Jun 20 21:20:05 2021 +0530
Branches: soc-2021-curves
https://developer.blender.org/rBefc9cb67b7e78d7b01f04327b3662be4a9cb3055

Changed data initialization to fix warning

===

M   source/blender/editors/curve/editcurve_pen.c

===

diff --git a/source/blender/editors/curve/editcurve_pen.c 
b/source/blender/editors/curve/editcurve_pen.c
index fb0fb5550af..8eae7818c0b 100644
--- a/source/blender/editors/curve/editcurve_pen.c
+++ b/source/blender/editors/curve/editcurve_pen.c
@@ -865,7 +865,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, 
const wmEvent *event)
 float prev_loc[3], cut_loc[3], next_loc[3];
 /* Mouse location as floats. */
 float mval[2];
-  } data = {NULL};
+  } data = {.bezt_index = 0, .min_dist = 1, .has_prev = false, 
.has_next = false};
 
   data.mval[0] = event->mval[0];
   data.mval[1] = event->mval[1];

___
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] [a959da98178] cycles-x: Merge branch 'master' into cycles-x

2021-06-20 Thread Brecht Van Lommel
Commit: a959da9817851467db23244bb09a0d1da942e3cd
Author: Brecht Van Lommel
Date:   Sun Jun 20 13:17:00 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBa959da9817851467db23244bb09a0d1da942e3cd

Merge branch 'master' into cycles-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] [4b03995ce51] soc-2021-vse-strip-thumbnails: Thumbnail Cache fix : thumbs get loaded and not cleared when preview on

2021-06-20 Thread Aditya Y Jeppu
Commit: 4b03995ce51bcb6b7f81ccfb929dd997d30934ab
Author: Aditya Y Jeppu
Date:   Sun Jun 20 20:00:20 2021 +0530
Branches: soc-2021-vse-strip-thumbnails
https://developer.blender.org/rB4b03995ce51bcb6b7f81ccfb929dd997d30934ab

Thumbnail Cache fix : thumbs get loaded and not cleared when preview on

===

M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/sequencer/intern/image_cache.c
M   source/blender/sequencer/intern/render.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index 61c42e228d1..09e40e92777 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1145,7 +1145,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
 
   int frame_factor = 0;
   float cut_off = 0;
-  float upper_thumb_bound = strip_x2 - handsize_clamped;
+  float upper_thumb_bound = strip_x2;
 
   while (x1 < upper_thumb_bound - 1) {
 x2 = x1 + thumb_w;
@@ -1172,6 +1172,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
 }
 
 /* clip if full thumbnail cannot be displayed */
+
 if (x2 >= (upper_thumb_bound - 1)) {
   x2 = (upper_thumb_bound - 1);
   if (x2 - x1 < 1)
@@ -1179,7 +1180,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
 }
 
 /* Get the image */
-ibuf = SEQ_render_give_ibuf_direct(&context, x1 + cut_off, seq);
+ibuf = SEQ_render_give_ibuf_direct(&context, x1 + (int)(cut_off), seq);
 
 if (ibuf) {
   ED_draw_imbuf_ctx_clipping(C, ibuf, x1, y1, true, x1 + cut_off, y1, x2, 
y2, zoom_x, zoom_y);
diff --git a/source/blender/sequencer/intern/image_cache.c 
b/source/blender/sequencer/intern/image_cache.c
index ef6bec474e7..3393b034dc0 100644
--- a/source/blender/sequencer/intern/image_cache.c
+++ b/source/blender/sequencer/intern/image_cache.c
@@ -1207,7 +1207,7 @@ void seq_cache_free_temp_cache(Scene *scene, short id, 
int timeline_frame)
 SeqCacheKey *key = BLI_ghashIterator_getKey(&gh_iter);
 BLI_ghashIterator_step(&gh_iter);
 
-if (key->is_temp_cache && key->task_id == id) {
+if (key->is_temp_cache && key->task_id == id && !key->context.is_thumb) {
   /* Use frame_index here to avoid freeing raw images if they are used for 
multiple frames. */
   float frame_index = seq_cache_timeline_frame_to_frame_index(
   key->seq, timeline_frame, key->type);
@@ -1304,7 +1304,7 @@ void seq_cache_cleanup_sequence(Scene *scene,
   int invalidate_composite = invalidate_types & SEQ_CACHE_STORE_FINAL_OUT;
   int invalidate_source = invalidate_types &
   (SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED |
-   SEQ_CACHE_STORE_COMPOSITE);  // TODO(AYJ) : add 
thumbnail
+   SEQ_CACHE_STORE_THUMBNAIL | 
SEQ_CACHE_STORE_COMPOSITE);
 
   GHashIterator gh_iter;
   BLI_ghashIterator_init(&gh_iter, cache->hash);
diff --git a/source/blender/sequencer/intern/render.c 
b/source/blender/sequencer/intern/render.c
index 4d4fcc8677e..3ae9a7a5c5b 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -541,7 +541,6 @@ static void sequencer_preprocess_transform_crop(
  context->preview_render_size);
   const bool do_scale_to_render_size = seq_need_scale_to_render_size(seq, 
is_proxy_image);
   float image_scale_factor = do_scale_to_render_size ? 1.0f : 
preview_scale_factor;
-  // TODO(AYJ) : check is setting image_scale_factor as const is imp
   if (context->is_thumb)
 image_scale_factor = 0.25f;

___
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] [df579a3b6da] soc-2021-vse-strip-thumbnails: Merge branch 'master' into soc-2021-vse-strip-thumbnails

2021-06-20 Thread Aditya Y Jeppu
Commit: df579a3b6da712c6e0eb467181a65b038d86822d
Author: Aditya Y Jeppu
Date:   Sun Jun 20 20:01:29 2021 +0530
Branches: soc-2021-vse-strip-thumbnails
https://developer.blender.org/rBdf579a3b6da712c6e0eb467181a65b038d86822d

Merge branch 'master' into soc-2021-vse-strip-thumbnails

===



===



___
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] [eee3529eaf4] master: Docs: improve poly_to_tri_count doc-string

2021-06-20 Thread Campbell Barton
Commit: eee3529eaf444cc0db0ad46182dccab46907c361
Author: Campbell Barton
Date:   Mon Jun 21 00:02:09 2021 +1000
Branches: master
https://developer.blender.org/rBeee3529eaf444cc0db0ad46182dccab46907c361

Docs: improve poly_to_tri_count doc-string

It wasn't obvious this can be used for calculating the triangle index
from the polygon and loop index.

===

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

===

diff --git a/source/blender/blenlib/intern/math_geom_inline.c 
b/source/blender/blenlib/intern/math_geom_inline.c
index 23c351026f2..655d3fcc4c0 100644
--- a/source/blender/blenlib/intern/math_geom_inline.c
+++ b/source/blender/blenlib/intern/math_geom_inline.c
@@ -244,10 +244,13 @@ MINLINE int min_axis_v3(const float vec[3])
 }
 
 /**
- * Simple method to find how many tri's we need when we already know the 
corner+poly count.
+ * Simple function to either:
+ * - Calculate how many triangles needed from the total number of polygons + 
loops.
+ * - Calculate the first triangle index from the polygon index & that polygons 
loop-start.
  *
- * \param poly_count: The number of ngon's/tris (1-2 sided faces will give 
incorrect results)
- * \param corner_count: also known as loops in BMesh/DNA
+ * \param poly_count: The number of polygons or polygon-index
+ * (3+ sided faces, 1-2 sided give incorrect results).
+ * \param corner_count: The number of corners (also called loop-index).
  */
 MINLINE int poly_to_tri_count(const int poly_count, const int corner_count)
 {

___
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] [bce482f476f] master: Cleanup: use eSpace_Type enum type

2021-06-20 Thread Campbell Barton
Commit: bce482f476fad526d34c889de200eb58e8c0c861
Author: Campbell Barton
Date:   Sun Jun 20 21:05:35 2021 +1000
Branches: master
https://developer.blender.org/rBbce482f476fad526d34c889de200eb58e8c0c861

Cleanup: use eSpace_Type enum type

===

M   source/blender/editors/gpencil/annotate_draw.c
M   source/blender/editors/screen/screen_edit.c

===

diff --git a/source/blender/editors/gpencil/annotate_draw.c 
b/source/blender/editors/gpencil/annotate_draw.c
index fe1c5efc747..3131ec70fb0 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -760,15 +760,15 @@ static void annotation_draw_data_all(Scene *scene,
  int winy,
  int cfra,
  int dflag,
- const char spacetype)
+ const eSpace_Type space_type)
 {
   bGPdata *gpd_source = NULL;
 
   if (scene) {
-if (spacetype == SPACE_VIEW3D) {
+if (space_type == SPACE_VIEW3D) {
   gpd_source = (scene->gpd ? scene->gpd : NULL);
 }
-else if (spacetype == SPACE_CLIP && scene->clip) {
+else if (space_type == SPACE_CLIP && scene->clip) {
   /* currently drawing only gpencil data from either clip or track,
* but not both - XXX fix logic behind */
   gpd_source = (scene->clip->gpd ? scene->clip->gpd : NULL);
diff --git a/source/blender/editors/screen/screen_edit.c 
b/source/blender/editors/screen/screen_edit.c
index bcfe30a829e..21800536503 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -68,7 +68,7 @@ static ScrArea *screen_addarea_ex(ScrAreaMap *area_map,
   ScrVert *top_left,
   ScrVert *top_right,
   ScrVert *bottom_right,
-  short spacetype)
+  const eSpace_Type space_type)
 {
   ScrArea *area = MEM_callocN(sizeof(ScrArea), "addscrarea");
 
@@ -76,7 +76,7 @@ static ScrArea *screen_addarea_ex(ScrAreaMap *area_map,
   area->v2 = top_left;
   area->v3 = top_right;
   area->v4 = bottom_right;
-  area->spacetype = spacetype;
+  area->spacetype = space_type;
 
   BLI_addtail(&area_map->areabase, area);
 
@@ -87,10 +87,10 @@ static ScrArea *screen_addarea(bScreen *screen,
ScrVert *left_top,
ScrVert *right_top,
ScrVert *right_bottom,
-   short spacetype)
+   const eSpace_Type space_type)
 {
   return screen_addarea_ex(
-  AREAMAP_FROM_SCREEN(screen), left_bottom, left_top, right_top, 
right_bottom, spacetype);
+  AREAMAP_FROM_SCREEN(screen), left_bottom, left_top, right_top, 
right_bottom, space_type);
 }
 
 static void screen_delarea(bContext *C, bScreen *screen, ScrArea *area)
@@ -972,7 +972,7 @@ int ED_screen_area_active(const bContext *C)
  */
 static ScrArea *screen_area_create_with_geometry(ScrAreaMap *area_map,
  const rcti *rect,
- short spacetype)
+ eSpace_Type space_type)
 {
   ScrVert *bottom_left = screen_geom_vertex_add_ex(area_map, rect->xmin, 
rect->ymin);
   ScrVert *top_left = screen_geom_vertex_add_ex(area_map, rect->xmin, 
rect->ymax);
@@ -984,7 +984,7 @@ static ScrArea *screen_area_create_with_geometry(ScrAreaMap 
*area_map,
   screen_geom_edge_add_ex(area_map, top_right, bottom_right);
   screen_geom_edge_add_ex(area_map, bottom_right, bottom_left);
 
-  return screen_addarea_ex(area_map, bottom_left, top_left, top_right, 
bottom_right, spacetype);
+  return screen_addarea_ex(area_map, bottom_left, top_left, top_right, 
bottom_right, space_type);
 }
 
 static void screen_area_set_geometry_rect(ScrArea *area, const rcti *rect)
@@ -1001,7 +1001,7 @@ static void screen_area_set_geometry_rect(ScrArea *area, 
const rcti *rect)
 
 static void screen_global_area_refresh(wmWindow *win,
bScreen *screen,
-   eSpace_Type space_type,
+   const eSpace_Type space_type,
GlobalAreaAlign align,
const rcti *rect,
const short height_cur,

___
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] [859b3ff3467] master: Cleanup: remove contents of endif() in cmake

2021-06-20 Thread Campbell Barton
Commit: 859b3ff34675d51b2e8548217f8d011c2846ee70
Author: Campbell Barton
Date:   Sun Jun 20 21:13:19 2021 +1000
Branches: master
https://developer.blender.org/rB859b3ff34675d51b2e8548217f8d011c2846ee70

Cleanup: remove contents of endif() in cmake

This convention is no longer used for Blender's CMake files.

===

M   build_files/cmake/Modules/FindGflags.cmake
M   build_files/cmake/Modules/FindNanoVDB.cmake
M   build_files/cmake/Modules/Findsse2neon.cmake

===

diff --git a/build_files/cmake/Modules/FindGflags.cmake 
b/build_files/cmake/Modules/FindGflags.cmake
index 71a05b423ed..e6da056925f 100644
--- a/build_files/cmake/Modules/FindGflags.cmake
+++ b/build_files/cmake/Modules/FindGflags.cmake
@@ -472,8 +472,7 @@ if(NOT GFLAGS_FOUND)
 gflags_report_not_found(
   "Could not find gflags include directory, set GFLAGS_INCLUDE_DIR "
   "to directory containing gflags/gflags.h")
-  endif(NOT GFLAGS_INCLUDE_DIR OR
-NOT EXISTS ${GFLAGS_INCLUDE_DIR})
+  endif()
 
   find_library(GFLAGS_LIBRARY NAMES gflags
 PATHS ${GFLAGS_LIBRARY_DIR_HINTS}
@@ -484,8 +483,7 @@ if(NOT GFLAGS_FOUND)
 gflags_report_not_found(
   "Could not find gflags library, set GFLAGS_LIBRARY "
   "to full path to libgflags.")
-  endif(NOT GFLAGS_LIBRARY OR
-NOT EXISTS ${GFLAGS_LIBRARY})
+  endif()
 
   # gflags typically requires a threading library (which is OS dependent), note
   # that this defines the CMAKE_THREAD_LIBS_INIT variable.  If we are able to
@@ -560,8 +558,7 @@ if(NOT GFLAGS_FOUND)
 gflags_report_not_found(
   "Caller defined GFLAGS_INCLUDE_DIR:"
   " ${GFLAGS_INCLUDE_DIR} does not contain gflags/gflags.h header.")
-  endif(GFLAGS_INCLUDE_DIR AND
-NOT EXISTS ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h)
+  endif()
   # TODO: This regex for gflags library is pretty primitive, we use lowercase
   #   for comparison to handle Windows using CamelCase library names, could
   #   this check be better?
@@ -571,8 +568,7 @@ if(NOT GFLAGS_FOUND)
 gflags_report_not_found(
   "Caller defined GFLAGS_LIBRARY: "
   "${GFLAGS_LIBRARY} does not match gflags.")
-  endif(GFLAGS_LIBRARY AND
-NOT "${LOWERCASE_GFLAGS_LIBRARY}" MATCHES ".*gflags[^/]*")
+  endif()
 
   gflags_reset_find_library_prefix()
 
diff --git a/build_files/cmake/Modules/FindNanoVDB.cmake 
b/build_files/cmake/Modules/FindNanoVDB.cmake
index 95d76fb39af..e830f770c03 100644
--- a/build_files/cmake/Modules/FindNanoVDB.cmake
+++ b/build_files/cmake/Modules/FindNanoVDB.cmake
@@ -40,7 +40,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(NanoVDB DEFAULT_MSG
 
 IF(NANOVDB_FOUND)
   SET(NANOVDB_INCLUDE_DIRS ${NANOVDB_INCLUDE_DIR})
-ENDIF(NANOVDB_FOUND)
+ENDIF()
 
 MARK_AS_ADVANCED(
   NANOVDB_INCLUDE_DIR
diff --git a/build_files/cmake/Modules/Findsse2neon.cmake 
b/build_files/cmake/Modules/Findsse2neon.cmake
index 2159dfac114..5c163326251 100644
--- a/build_files/cmake/Modules/Findsse2neon.cmake
+++ b/build_files/cmake/Modules/Findsse2neon.cmake
@@ -40,7 +40,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(sse2neon DEFAULT_MSG
 
 IF(SSE2NEON_FOUND)
   SET(SSE2NEON_INCLUDE_DIRS ${SSE2NEON_INCLUDE_DIR})
-ENDIF(SSE2NEON_FOUND)
+ENDIF()
 
 MARK_AS_ADVANCED(
   SSE2NEON_INCLUDE_DIR

___
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] [3462b4c7aee] master: Docs: add additional notes on tessellation, update comments

2021-06-20 Thread Campbell Barton
Commit: 3462b4c7aeeab656cc0e97e5d20061a31e0d17c4
Author: Campbell Barton
Date:   Sun Jun 20 17:01:09 2021 +1000
Branches: master
https://developer.blender.org/rB3462b4c7aeeab656cc0e97e5d20061a31e0d17c4

Docs: add additional notes on tessellation, update comments

===

M   source/blender/blenkernel/intern/mesh_tessellate.c
M   source/blender/draw/intern/draw_cache_extract_mesh_render_data.c

===

diff --git a/source/blender/blenkernel/intern/mesh_tessellate.c 
b/source/blender/blenkernel/intern/mesh_tessellate.c
index 0cd1b211e4d..797db4df97f 100644
--- a/source/blender/blenkernel/intern/mesh_tessellate.c
+++ b/source/blender/blenkernel/intern/mesh_tessellate.c
@@ -49,6 +49,8 @@
 
 /*  */
 /** \name MFace Tessellation
+ *
+ * #MFace is a legacy data-structure that should be avoided, use #MLoopTri 
instead.
  * \{ */
 
 /**
@@ -67,11 +69,10 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata,
 uint (*loopindices)[4],
 const int num_faces)
 {
-  /* Note: performances are sub-optimal when we get a NULL mface,
-   *   we could be ~25% quicker with dedicated code...
-   *   Issue is, unless having two different functions with nearly the 
same code,
-   *   there's not much ways to solve this. Better imho to live with it 
for now. :/ --mont29
-   */
+  /* NOTE(mont29): performances are sub-optimal when we get a NULL #MFace,
+   * we could be ~25% quicker with dedicated code.
+   * The issue is, unless having two different functions with nearly the same 
code,
+   * there's not much ways to solve this. Better IMHO to live with it for now 
(sigh). */
   const int numUV = CustomData_number_of_layers(ldata, CD_MLOOPUV);
   const int numCol = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
   const bool hasPCol = CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL);
@@ -139,7 +140,7 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata,
   }
 
   if (hasLoopTangent) {
-/* need to do for all uv maps at some point */
+/* Need to do for all UV maps at some point. */
 float(*ftangents)[4] = CustomData_get_layer(fdata, CD_TANGENT);
 float(*ltangents)[4] = CustomData_get_layer(ldata, CD_TANGENT);
 
@@ -154,12 +155,15 @@ void BKE_mesh_loops_to_tessdata(CustomData *fdata,
 }
 
 /**
- * Recreate tessellation.
+ * Recreate #MFace Tessellation.
  *
  * \param do_face_nor_copy: Controls whether the normals from the poly
  * are copied to the tessellated faces.
  *
  * \return number of tessellation faces.
+ *
+ * \note This doesn't use multi-threading like #BKE_mesh_recalc_looptri since
+ * it's not used in many places and #MFace should be phased out.
  */
 int BKE_mesh_tessface_calc_ex(CustomData *fdata,
   CustomData *ldata,
@@ -170,13 +174,10 @@ int BKE_mesh_tessface_calc_ex(CustomData *fdata,
   int totpoly,
   const bool do_face_nor_copy)
 {
-  /* use this to avoid locking pthread for _every_ polygon
-   * and calling the fill function */
-
 #define USE_TESSFACE_SPEEDUP
-#define USE_TESSFACE_QUADS /* NEEDS FURTHER TESTING */
+#define USE_TESSFACE_QUADS
 
-/* We abuse MFace->edcode to tag quad faces. See below for details. */
+/* We abuse #MFace.edcode to tag quad faces. See below for details. */
 #define TESSFACE_IS_QUAD 1
 
   const int looptri_num = poly_to_tri_count(totpoly, totloop);
@@ -193,9 +194,9 @@ int BKE_mesh_tessface_calc_ex(CustomData *fdata,
   mpoly = CustomData_get_layer(pdata, CD_MPOLY);
   mloop = CustomData_get_layer(ldata, CD_MLOOP);
 
-  /* allocate the length of totfaces, avoid many small reallocs,
-   * if all faces are tri's it will be correct, quads == 2x allocs */
-  /* take care. we are _not_ calloc'ing so be sure to initialize each field */
+  /* Allocate the length of `totfaces`, avoid many small reallocation's,
+   * if all faces are triangles it will be correct, `quads == 2x` allocations. 
*/
+  /* Take care since memory is _not_ zeroed so be sure to initialize each 
field. */
   mface_to_poly_map = MEM_malloc_arrayN((size_t)looptri_num, 
sizeof(*mface_to_poly_map), __func__);
   mface = MEM_malloc_arrayN((size_t)looptri_num, sizeof(*mface), __func__);
   lindices = MEM_malloc_arrayN((size_t)looptri_num, sizeof(*lindices), 
__func__);
@@ -208,7 +209,7 @@ int BKE_mesh_tessface_calc_ex(CustomData *fdata,
 uint l1, l2, l3, l4;
 uint *lidx;
 if (mp_totloop < 3) {
-  /* do nothing */
+  /* Do nothing. */
 }
 
 #ifdef USE_TESSFACE_SPEEDUP
@@ -217,7 +218,7 @@ int BKE_mesh_tessface_calc_ex(CustomData *fdata,
 mface_to_poly_map[mface_index] = poly_index; \
 mf = &mface[mface_index]; \
 lidx = lindices[mface_index]; \
-/* set loop indices, transformed to vert indices later */ \
+/* Set loop 

[Bf-blender-cvs] [d9b1592c886] master: Cleanup: make BKE_mesh_loops_to_tessdata a static function

2021-06-20 Thread Campbell Barton
Commit: d9b1592c886783fbb1c39a016a91b403db8e8660
Author: Campbell Barton
Date:   Sun Jun 20 17:21:50 2021 +1000
Branches: master
https://developer.blender.org/rBd9b1592c886783fbb1c39a016a91b403db8e8660

Cleanup: make BKE_mesh_loops_to_tessdata a static function

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/intern/customdata.c
M   source/blender/blenkernel/intern/mesh_tessellate.c

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 87964307105..8ddfb0c8eb2 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -274,13 +274,6 @@ void BKE_mesh_vert_normals_apply(struct Mesh *mesh, const 
short (*vert_normals)[
 
 /* *** mesh_tessellate.c *** */
 
-void BKE_mesh_loops_to_tessdata(struct CustomData *fdata,
-struct CustomData *ldata,
-struct MFace *mface,
-const int *polyindices,
-unsigned int (*loopindices)[4],
-const int num_faces);
-
 int BKE_mesh_tessface_calc_ex(struct CustomData *fdata,
   struct CustomData *ldata,
   struct CustomData *pdata,
diff --git a/source/blender/blenkernel/intern/customdata.c 
b/source/blender/blenkernel/intern/customdata.c
index ccf002b4c6f..b1bb8b9715e 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1970,7 +1970,7 @@ const CustomData_MeshMasks CD_MASK_BMESH = {
   CD_MASK_SCULPT_FACE_SETS),
 };
 /**
- * cover values copied by #BKE_mesh_loops_to_tessdata
+ * cover values copied by #mesh_loops_to_tessdata
  */
 const CustomData_MeshMasks CD_MASK_FACECORNERS = {
 .vmask = 0,
diff --git a/source/blender/blenkernel/intern/mesh_tessellate.c 
b/source/blender/blenkernel/intern/mesh_tessellate.c
index 797db4df97f..213f2929d63 100644
--- a/source/blender/blenkernel/intern/mesh_tessellate.c
+++ b/source/blender/blenkernel/intern/mesh_tessellate.c
@@ -62,12 +62,12 @@
  * \note when mface is not NULL, mface[face_index].v4
  * is used to test quads, else, loopindices[face_index][3] is used.
  */
-void BKE_mesh_loops_to_tessdata(CustomData *fdata,
-CustomData *ldata,
-MFace *mface,
-const int *polyindices,
-uint (*loopindices)[4],
-const int num_faces)
+static void mesh_loops_to_tessdata(CustomData *fdata,
+   CustomData *ldata,
+   MFace *mface,
+   const int *polyindices,
+   uint (*loopindices)[4],
+   const int num_faces)
 {
   /* NOTE(mont29): performances are sub-optimal when we get a NULL #MFace,
* we could be ~25% quicker with dedicated code.
@@ -391,9 +391,9 @@ int BKE_mesh_tessface_calc_ex(CustomData *fdata,
* Currently, our tfaces' fourth vertex index might be 0 even for a quad.
* However, we know our fourth loop index is never 0 for quads
* (because they are sorted for polygons, and our quads are still mere 
copies of their polygons).
-   * So we pass NULL as MFace pointer, and #BKE_mesh_loops_to_tessdata
+   * So we pass NULL as MFace pointer, and #mesh_loops_to_tessdata
* will use the fourth loop index as quad test. */
-  BKE_mesh_loops_to_tessdata(fdata, ldata, NULL, mface_to_poly_map, lindices, 
totface);
+  mesh_loops_to_tessdata(fdata, ldata, NULL, mface_to_poly_map, lindices, 
totface);
 
   /* NOTE: quad detection issue - fourth vertidx vs fourth loopidx:
* ...However, most TFace code uses 'MFace->v4 == 0' test to check whether 
it is a tri or quad.

___
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