[Bf-blender-cvs] [010c551257d] master: DNA: mark OrigSpace structs as run-time

2020-01-07 Thread Campbell Barton
Commit: 010c551257d5e54eb4ca58116b745ca21a09c379
Author: Campbell Barton
Date:   Wed Jan 8 16:32:17 2020 +1100
Branches: master
https://developer.blender.org/rB010c551257d5e54eb4ca58116b745ca21a09c379

DNA: mark OrigSpace structs as run-time

===

M   source/blender/makesdna/DNA_meshdata_types.h

===

diff --git a/source/blender/makesdna/DNA_meshdata_types.h 
b/source/blender/makesdna/DNA_meshdata_types.h
index 57f8cb2b289..648389d610f 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -387,10 +387,14 @@ typedef struct GridPaintMask {
  * Unlike UV's these are not user editable and always start out using a fixed 
0-1 range.
  * Currently only used for particle placement.
  */
+#
+#
 typedef struct OrigSpaceFace {
   float uv[4][2];
 } OrigSpaceFace;
 
+#
+#
 typedef struct OrigSpaceLoop {
   float uv[2];
 } OrigSpaceLoop;

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


[Bf-blender-cvs] [b42b837b7ef] master: Cleanup: mesh data header

2020-01-07 Thread Campbell Barton
Commit: b42b837b7ef29f92dfc84c5ba2b5c762328cad25
Author: Campbell Barton
Date:   Wed Jan 8 16:16:02 2020 +1100
Branches: master
https://developer.blender.org/rBb42b837b7ef29f92dfc84c5ba2b5c762328cad25

Cleanup: mesh data header

This file had become disorganized, it wasn't clear which structs/flags
were deprecated.

- Add comments explaining what each struct is for.
- Use doxy sections.
- Remove outdated notes, unused flags.
- Group custom-data.
- Group deprecated structs in their own section.

T

===

M   source/blender/makesdna/DNA_meshdata_types.h

===

diff --git a/source/blender/makesdna/DNA_meshdata_types.h 
b/source/blender/makesdna/DNA_meshdata_types.h
index ebaaf72b3ae..57f8cb2b289 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -27,50 +27,67 @@
 #include "DNA_customdata_types.h"
 #include "DNA_listBase.h"
 
-/*tessellation face, see MLoop/MPoly for the real face data*/
-typedef struct MFace {
-  unsigned int v1, v2, v3, v4;
-  short mat_nr;
-  /** We keep edcode, for conversion to edges draw flags in old files. */
-  char edcode, flag;
-} MFace;
-
-typedef struct MEdge {
-  unsigned int v1, v2;
-  char crease, bweight;
-  short flag;
-} MEdge;
-
-typedef struct MDeformWeight {
-  int def_nr;
-  float weight;
-} MDeformWeight;
-
-typedef struct MDeformVert {
-  struct MDeformWeight *dw;
-  int totweight;
-  /** Flag only in use for weightpaint now. */
-  int flag;
-} MDeformVert;
+/*  */
+/** \name Geometry Elements
+ * \{ */
 
+/**
+ * Mesh Vertices.
+ *
+ * Typically accessed from #Mesh.mvert
+ */
 typedef struct MVert {
   float co[3];
+  /**
+   * Cache the normal, can always be recalculated from surrounding faces.
+   * See #CD_CUSTOMLOOPNORMAL for custom normals.
+   */
   short no[3];
   char flag, bweight;
 } MVert;
 
+/** #MVert.flag */
+enum {
+  /*  SELECT = (1 << 0), */
+  ME_VERT_TMP_TAG = (1 << 2),
+  ME_HIDE = (1 << 4),
+  ME_VERT_FACEDOT = (1 << 5),
+  /*  ME_VERT_MERGED = (1 << 6), */
+  ME_VERT_PBVH_UPDATE = (1 << 7),
+};
+
 /**
- * Tessellation vertex color data.
- * at the moment alpha is abused for vertex painting and not used for 
transparency,
- * note that red and blue are swapped.
+ * Mesh Edges.
+ *
+ * Typically accessed from #Mesh.medge
  */
-typedef struct MCol {
-  unsigned char a, r, g, b;
-} MCol;
+typedef struct MEdge {
+  /** Un-ordered vertex indices (cannot match). */
+  unsigned int v1, v2;
+  char crease, bweight;
+  short flag;
+} MEdge;
 
-/* new face structure, replaces MFace, which is now only used for storing 
tessellations.*/
+/** #MEdge.flag */
+enum {
+  /*  SELECT = (1 << 0), */
+  ME_EDGEDRAW = (1 << 1),
+  ME_SEAM = (1 << 2),
+  /*  ME_HIDE = (1 << 4), */
+  ME_EDGERENDER = (1 << 5),
+  ME_LOOSEEDGE = (1 << 7),
+  ME_EDGE_TMP_TAG = (1 << 8),
+  ME_SHARP = (1 << 9), /* only reason this flag remains a 'short' */
+};
+
+/**
+ * Mesh Faces
+ * This only stores the polygon size & flags, the vertex & edge indices are 
stored in the #MLoop.
+ *
+ * Typically accessed from #Mesh.mpoly.
+ */
 typedef struct MPoly {
-  /* offset into loop array and number of loops in the face */
+  /** Offset into loop array and number of loops in the face. */
   int loopstart;
   /** Keep signed since we need to subtract when getting the previous loop. */
   int totloop;
@@ -78,14 +95,62 @@ typedef struct MPoly {
   char flag, _pad;
 } MPoly;
 
-/* the e here is because we want to move away from relying on edge hashes.*/
+/** #MPoly.flag */
+enum {
+  ME_SMOOTH = (1 << 0),
+  ME_FACE_SEL = (1 << 1),
+  /* ME_HIDE = (1 << 4), */
+};
+
+/**
+ * Mesh Loops.
+ * Each loop represents the corner of a polygon (#MPoly).
+ *
+ * Typically accessed from #Mesh.mloop.
+ */
 typedef struct MLoop {
   /** Vertex index. */
   unsigned int v;
-  /** Edge index. */
+  /**
+   * Edge index.
+   *
+   * \note The e here is because we want to move away from relying on edge 
hashes.
+   */
   unsigned int e;
 } MLoop;
 
+/** \} */
+
+/*  */
+/** \name Ordered Selection Storage
+ * \{ */
+
+/**
+ * Optionally store the order of selected elements.
+ * This wont always be set since only some selection operations have an order.
+ *
+ * Typically accessed from #Mesh.mselect
+ */
+typedef struct MSelect {
+  /** Index in the vertex, edge or polygon array. */
+  int index;
+  /** #ME_VSEL, #ME_ESEL, #ME_FSEL. */
+  int type;
+} MSelect;
+
+/** #MSelect.type */
+enum {
+  ME_VSEL = 0,
+  ME_ESEL = 1,
+  ME_FSEL = 2,
+};
+
+/** \} */
+
+/*  */
+/** \name Loop Tesselation Runtime Data
+ * \{ */
+
 /**
  * #MLoopTri's are lightweight triangulation data,
  * for functionality that doesn't support ngons (#MPoly).

[Bf-blender-cvs] [a32ee63660f] master: Fix T72919: NDOF 'Free' orbit preference is ignored

2020-01-07 Thread Campbell Barton
Commit: a32ee63660ffd711ed2dab0d3e0b0c0efcd38044
Author: Campbell Barton
Date:   Wed Jan 8 14:20:23 2020 +1100
Branches: master
https://developer.blender.org/rBa32ee63660ffd711ed2dab0d3e0b0c0efcd38044

Fix T72919: NDOF 'Free' orbit preference is ignored

Regression from 6288dbffb6c1f.

===

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

===

diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index d40f79cea3f..45388ce3691 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1448,10 +1448,20 @@ static int ndof_orbit_zoom_invoke(bContext *C, 
wmOperator *op, const wmEvent *ev
 const bool is_orbit_around_pivot = (U.ndof_flag & NDOF_MODE_ORBIT) ||
ED_view3d_offset_lock_check(v3d, rv3d);
 const bool has_rotation = ndof_has_rotate(ndof, rv3d);
-const bool has_translate = !is_zero_v2(ndof->tvec) && 
ndof_has_translate(ndof, v3d, rv3d);
-const bool has_zoom = (ndof->tvec[2] != 0.0f);
+bool has_translate, has_zoom;
 
-/* Rotation first because dynamic offset resets offset otherwise (and 
disasbles panning). */
+if (is_orbit_around_pivot) {
+  /* Orbit preference or forced lock (Z zooms). */
+  has_translate = !is_zero_v2(ndof->tvec) && ndof_has_translate(ndof, v3d, 
rv3d);
+  has_zoom = (ndof->tvec[2] != 0.0f);
+}
+else {
+  /* Free preference (Z translates). */
+  has_translate = ndof_has_translate(ndof, v3d, rv3d);
+  has_zoom = false;
+}
+
+/* Rotation first because dynamic offset resets offset otherwise (and 
disables panning). */
 if (has_rotation) {
   const float dist_backup = rv3d->dist;
   if (!is_orbit_around_pivot) {

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


[Bf-blender-cvs] [0e37045f32f] master: Cleanup: use paint/sculpt prefix in BKE_paint.h

2020-01-07 Thread Campbell Barton
Commit: 0e37045f32f35ff2264838fbaadd48ca7f2a0117
Author: Campbell Barton
Date:   Wed Jan 8 12:59:48 2020 +1100
Branches: master
https://developer.blender.org/rB0e37045f32f35ff2264838fbaadd48ca7f2a0117

Cleanup: use paint/sculpt prefix in BKE_paint.h

PoseIKChain for example reads as if this is related to armature/pose
when it's a sculpting feature.

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/paint.c
M   source/blender/editors/sculpt_paint/paint_cursor.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 6089db5ed46..db35fbde2c8 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -85,14 +85,14 @@ typedef enum ePaintMode {
 #define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PAINT_MODE_SCULPT_UV)
 
 /* overlay invalidation */
-typedef enum eOverlayControlFlags {
+typedef enum ePaintOverlayControlFlags {
   PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY = 1,
   PAINT_OVERLAY_INVALID_TEXTURE_SECONDARY = (1 << 2),
   PAINT_OVERLAY_INVALID_CURVE = (1 << 3),
   PAINT_OVERLAY_OVERRIDE_CURSOR = (1 << 4),
   PAINT_OVERLAY_OVERRIDE_PRIMARY = (1 << 5),
   PAINT_OVERLAY_OVERRIDE_SECONDARY = (1 << 6),
-} eOverlayControlFlags;
+} ePaintOverlayControlFlags;
 
 #define PAINT_OVERRIDE_MASK \
   (PAINT_OVERLAY_OVERRIDE_SECONDARY | PAINT_OVERLAY_OVERRIDE_PRIMARY | \
@@ -102,12 +102,12 @@ typedef enum eOverlayControlFlags {
  * flip or mirror transform values depending on where the vertex is and where 
the transform
  * operation started to support XYZ symmetry on those operations in a 
predictable way. */
 
-#define AREA_SYMM_DEFAULT 0
+#define PAINT_SYMM_AREA_DEFAULT 0
 
 typedef enum ePaintSymmetryAreas {
-  AREA_SYMM_X = (1 << 0),
-  AREA_SYMM_Y = (1 << 1),
-  AREA_SYMM_Z = (1 << 2),
+  PAINT_SYMM_AREA_X = (1 << 0),
+  PAINT_SYMM_AREA_Y = (1 << 1),
+  PAINT_SYMM_AREA_Z = (1 << 2),
 } ePaintSymmetryAreas;
 
 #define PAINT_SYMM_AREAS 8
@@ -119,8 +119,8 @@ void BKE_paint_invalidate_cursor_overlay(struct Scene 
*scene,
  struct ViewLayer *view_layer,
  struct CurveMapping *curve);
 void BKE_paint_invalidate_overlay_all(void);
-eOverlayControlFlags BKE_paint_get_overlay_flags(void);
-void BKE_paint_reset_overlay_invalid(eOverlayControlFlags flag);
+ePaintOverlayControlFlags BKE_paint_get_overlay_flags(void);
+void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag);
 void BKE_paint_set_overlay_override(enum eOverlayFlags flag);
 
 /* palettes */
@@ -226,7 +226,7 @@ struct SculptVertexPaintGeomMap {
 };
 
 /* Pose Brush IK Chain */
-typedef struct PoseIKChainSegment {
+typedef struct SculptPoseIKChainSegment {
   float orig[3];
   float head[3];
 
@@ -241,12 +241,12 @@ typedef struct PoseIKChainSegment {
   float trans_mat[PAINT_SYMM_AREAS][4][4];
   float pivot_mat[PAINT_SYMM_AREAS][4][4];
   float pivot_mat_inv[PAINT_SYMM_AREAS][4][4];
-} PoseIKChainSegment;
+} SculptPoseIKChainSegment;
 
-typedef struct PoseIKChain {
-  PoseIKChainSegment *segments;
+typedef struct SculptPoseIKChain {
+  SculptPoseIKChainSegment *segments;
   int tot_segments;
-} PoseIKChain;
+} SculptPoseIKChain;
 
 /* Session data (mode-specific) */
 
@@ -313,7 +313,7 @@ typedef struct SculptSession {
 
   /* Pose Brush Preview */
   float pose_origin[3];
-  PoseIKChain *pose_ik_chain_preview;
+  SculptPoseIKChain *pose_ik_chain_preview;
 
   /* Transform operator */
   float pivot_pos[3];
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 0c03f1db729..a334a088e0f 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -79,7 +79,7 @@ const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
 const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
 const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
 
-static eOverlayControlFlags overlay_flags = 0;
+static ePaintOverlayControlFlags overlay_flags = 0;
 
 void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, 
const Tex *tex)
 {
@@ -120,7 +120,7 @@ void BKE_paint_invalidate_overlay_all(void)
 PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY | 
PAINT_OVERLAY_INVALID_CURVE);
 }
 
-eOverlayControlFlags BKE_paint_get_overlay_flags(void)
+ePaintOverlayControlFlags BKE_paint_get_overlay_flags(void)
 {
   return overlay_flags;
 }
@@ -143,7 +143,7 @@ void BKE_paint_set_overlay_override(eOverlayFlags flags)
   }
 }
 
-void BKE_paint_reset_overlay_invalid(eOverlayControlFlags flag)
+void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag)
 {
   overlay_flags &= ~(flag);
 }
diff --git 

[Bf-blender-cvs] [3b27d75f451] greasepencil-refactor: GPencil: Refactor: Add canvas grid

2020-01-07 Thread Clément Foucault
Commit: 3b27d75f45188a9fb6f70ac73d3ca6dc14311512
Author: Clément Foucault
Date:   Tue Jan 7 20:15:34 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB3b27d75f45188a9fb6f70ac73d3ca6dc14311512

GPencil: Refactor: Add canvas grid

===

M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_engine.c
M   source/blender/draw/engines/overlay/overlay_gpencil.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/edit_gpencil_canvas_vert.glsl

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 46211eefe87..23516f5067f 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -347,6 +347,7 @@ 
data_to_c_simple(engines/overlay/shaders/edit_curve_handle_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_curve_point_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_curve_wire_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_gpencil_vert.glsl SRC)
+data_to_c_simple(engines/overlay/shaders/edit_gpencil_canvas_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_lattice_point_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_lattice_wire_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_mesh_common_lib.glsl SRC)
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c 
b/source/blender/draw/engines/overlay/overlay_engine.c
index ac8af115500..1abd6ff459d 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -152,6 +152,7 @@ static void OVERLAY_cache_init(void *vedata)
   OVERLAY_armature_cache_init(vedata);
   OVERLAY_extra_cache_init(vedata);
   OVERLAY_facing_cache_init(vedata);
+  OVERLAY_gpencil_cache_init(vedata);
   OVERLAY_grid_cache_init(vedata);
   OVERLAY_image_cache_init(vedata);
   OVERLAY_metaball_cache_init(vedata);
@@ -394,6 +395,7 @@ static void OVERLAY_draw_scene(void *vedata)
   OVERLAY_armature_draw(vedata);
   OVERLAY_particle_draw(vedata);
   OVERLAY_metaball_draw(vedata);
+  OVERLAY_gpencil_draw(vedata);
   OVERLAY_extra_draw(vedata);
 
   if (DRW_state_is_fbo()) {
diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c 
b/source/blender/draw/engines/overlay/overlay_gpencil.c
index 83fce819151..f8d03f171b6 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -58,9 +58,10 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   View3D *v3d = draw_ctx->v3d;
   Object *ob = draw_ctx->obact;
   bGPdata *gpd = (bGPdata *)ob->data;
-  ToolSettings *ts = draw_ctx->scene->toolsettings;
+  Scene *scene = draw_ctx->scene;
+  ToolSettings *ts = scene->toolsettings;
 
-  if (gpd == NULL) {
+  if (ob->type != OB_GPENCIL || gpd == NULL) {
 return;
   }
 
@@ -101,11 +102,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
(GPENCIL_EDIT_MODE(gpd) &&
 (ts->gpencil_selectmode_edit != 
GP_SELECTMODE_STROKE));
 
-  if (GPENCIL_VERTEX_MODE(gpd) && !use_vertex_mask && !show_multi_edit_lines) {
-return;
-  }
-
-  {
+  if (!GPENCIL_VERTEX_MODE(gpd) || use_vertex_mask || show_multi_edit_lines) {
 DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS_EQUAL |
  DRW_STATE_BLEND_ALPHA;
 DRW_PASS_CREATE(psl->edit_gpencil_ps, state | pd->clipping_state);
@@ -133,6 +130,92 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   }
 }
 
+void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata)
+{
+  OVERLAY_PassList *psl = vedata->psl;
+  struct GPUShader *sh;
+  DRWShadingGroup *grp;
+
+  /* Default: Display nothing. */
+  psl->gpencil_canvas_ps = NULL;
+
+  /* REFACTOR(fclem) remove */
+  if (G.debug_value != 50) {
+return;
+  }
+
+  const DRWContextState *draw_ctx = DRW_context_state_get();
+  View3D *v3d = draw_ctx->v3d;
+  Object *ob = draw_ctx->obact;
+  bGPdata *gpd = (bGPdata *)ob->data;
+  Scene *scene = draw_ctx->scene;
+  ToolSettings *ts = scene->toolsettings;
+  const View3DCursor *cursor = >cursor;
+
+  if (ob->type != OB_GPENCIL || gpd == NULL) {
+return;
+  }
+
+  const bool show_overlays = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
+  const bool show_grid = (v3d->gp_flag & V3D_GP_SHOW_GRID) != 0;
+
+  if (show_grid && show_overlays) {
+const char *grid_unit = NULL;
+float mat[4][4];
+float col_grid[4];
+float size[2];
+
+/* set color */
+copy_v3_v3(col_grid, gpd->grid.color);
+col_grid[3] = max_ff(v3d->overlay.gpencil_grid_opacity, 0.01f);
+
+copy_m4_m4(mat, ob->obmat);
+
+float viewinv[4][4];
+/* 

[Bf-blender-cvs] [62f4eb5f1de] greasepencil-refactor: GPencil: Refactor: Fix weight paint not working

2020-01-07 Thread Clément Foucault
Commit: 62f4eb5f1de96388538f6975a097766b1637290e
Author: Clément Foucault
Date:   Tue Jan 7 20:11:46 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB62f4eb5f1de96388538f6975a097766b1637290e

GPencil: Refactor: Fix weight paint not working

===

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

===

diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c 
b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index ddd93ad8636..9d80f11e66b 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -555,7 +555,7 @@ static uint32_t gpencil_point_edit_flag(const bGPDspoint 
*pt, int v, int v_len)
 
 static float gpencil_point_edit_weight(const MDeformVert *dvert, int v, int 
vgindex)
 {
-  return (dvert && dvert->dw) ? defvert_find_weight([v], vgindex) : 
-1.0f;
+  return (dvert && dvert[v].dw) ? defvert_find_weight([v], vgindex) : 
-1.0f;
 }
 
 static void gpencil_edit_stroke_iter_cb(bGPDlayer *UNUSED(gpl),

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


[Bf-blender-cvs] [31700ba657b] greasepencil-refactor: Overlay: Allow alpha blend passes to write to the line buffer

2020-01-07 Thread Clément Foucault
Commit: 31700ba657b17fa8a722df1a260866d7a3962679
Author: Clément Foucault
Date:   Tue Jan 7 20:11:23 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB31700ba657b17fa8a722df1a260866d7a3962679

Overlay: Allow alpha blend passes to write to the line buffer

===

M   source/blender/draw/intern/shaders/common_view_lib.glsl

===

diff --git a/source/blender/draw/intern/shaders/common_view_lib.glsl 
b/source/blender/draw/intern/shaders/common_view_lib.glsl
index a94091b3c22..3faefd485bf 100644
--- a/source/blender/draw/intern/shaders/common_view_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_view_lib.glsl
@@ -60,11 +60,11 @@ vec4 pack_line_data(vec2 frag_co, vec2 edge_start, vec2 
edge_pos)
 vec2 perp = vec2(-edge.y, edge.x);
 float dist = dot(perp, frag_co - edge_start);
 /* Add 0.1 to diffenrentiate with cleared pixels. */
-return vec4(perp * 0.5 + 0.5, dist * 0.25 + 0.5 + 0.1, 0.0);
+return vec4(perp * 0.5 + 0.5, dist * 0.25 + 0.5 + 0.1, 1.0);
   }
   else {
 /* Default line if the origin is perfectly aligned with a pixel. */
-return vec4(1.0, 0.0, 0.5 + 0.1, 0.0);
+return vec4(1.0, 0.0, 0.5 + 0.1, 1.0);
   }
 }

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


[Bf-blender-cvs] [3cf0895bdee] greasepencil-refactor: GPencil: Refactor: Fix crash when using alt+b clipping

2020-01-07 Thread Clément Foucault
Commit: 3cf0895bdeedd30440c32158b0d20afbc667459b
Author: Clément Foucault
Date:   Tue Jan 7 20:12:58 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB3cf0895bdeedd30440c32158b0d20afbc667459b

GPencil: Refactor: Fix crash when using alt+b clipping

===

M   source/blender/draw/engines/overlay/shaders/outline_prepass_vert.glsl

===

diff --git 
a/source/blender/draw/engines/overlay/shaders/outline_prepass_vert.glsl 
b/source/blender/draw/engines/overlay/shaders/outline_prepass_vert.glsl
index 235a881b806..24f084fc9e7 100644
--- a/source/blender/draw/engines/overlay/shaders/outline_prepass_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/outline_prepass_vert.glsl
@@ -51,6 +51,10 @@ void main()
 {
 #ifdef USE_GPENCIL
   gpencil_vertex();
+#  ifdef USE_WORLD_CLIP_PLANES
+  vec3 world_pos = point_object_to_world(pos1.xyz);
+#  endif
+
 #else
   vec3 world_pos = point_object_to_world(pos);
   gl_Position = point_world_to_ndc(world_pos);

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


[Bf-blender-cvs] [eb6a46be2de] greasepencil-refactor: GPencil: Move Strokes Directions to Overlays

2020-01-07 Thread Antonio Vazquez
Commit: eb6a46be2de81c33faabf0832af6c4882d275f2e
Author: Antonio Vazquez
Date:   Tue Jan 7 19:53:13 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBeb6a46be2de81c33faabf0832af6c4882d275f2e

GPencil: Move Strokes Directions to Overlays

Before was part of the datablock.

Also some cleanup in annotations.

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/overlay/overlay_gpencil.c
M   source/blender/editors/gpencil/annotate_draw.c
M   source/blender/makesdna/DNA_gpencil_types.h
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/makesrna/intern/rna_gpencil.c
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 8859ecc5027..45dd7af9dd3 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6475,6 +6475,9 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
 sub.prop(overlay, "gpencil_paper_opacity", text="Fade Objects", 
slider=True)
 sub.prop(overlay, "use_gpencil_fade_objects", text="", 
icon='OUTLINER_OB_GREASEPENCIL')
 
+if context.object.mode == 'EDIT_GPENCIL':
+layout.prop(overlay, "use_gpencil_show_directions")
+
 if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 
'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}:
 layout.prop(overlay, "use_gpencil_edit_lines", text="Edit Lines")
 layout.prop(overlay, "use_gpencil_multiedit_line_only", text="Show 
Edit Lines only in multiframe")
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index d90f2b20980..ef79c381bb0 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -865,7 +865,7 @@ void gpencil_get_edit_geom(struct GpencilBatchCacheElem *be,
   gpencil_vbo_ensure_size(be, gps->totpoints);
 
   /* Draw start and end point differently if enabled stroke direction hint */
-  bool show_direction_hint = (dflag & GP_DATA_SHOW_DIRECTION) && 
(gps->totpoints > 1);
+  bool show_direction_hint = false;
 
   /* Draw all the stroke points (selected or not) */
   bGPDspoint *pt = gps->points;
diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c 
b/source/blender/draw/engines/overlay/overlay_gpencil.c
index 4e45d5f6cad..83fce819151 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -137,6 +137,8 @@ static void 
OVERLAY_edit_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob
 {
   OVERLAY_PrivateData *pd = vedata->stl->pd;
   bGPdata *gpd = (bGPdata *)ob->data;
+  const DRWContextState *draw_ctx = DRW_context_state_get();
+  View3D *v3d = draw_ctx->v3d;
 
   if (pd->edit_gpencil_wires_grp) {
 DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->edit_gpencil_wires_grp);
@@ -147,7 +149,7 @@ static void 
OVERLAY_edit_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob
   }
 
   if (pd->edit_gpencil_points_grp) {
-const bool show_direction = (gpd->flag & GP_DATA_SHOW_DIRECTION) != 0;
+const bool show_direction = (v3d->gp_flag & V3D_GP_SHOW_STROKE_DIRECTION) 
!= 0;
 
 DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->edit_gpencil_points_grp);
 DRW_shgroup_uniform_float_copy(grp, "doStrokeEndpoints", show_direction);
diff --git a/source/blender/editors/gpencil/annotate_draw.c 
b/source/blender/editors/gpencil/annotate_draw.c
index 856411e608d..42d725239a6 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -709,31 +709,12 @@ static void annotation_draw_strokes_edit(bGPdata *gpd,
 
 immBegin(GPU_PRIM_POINTS, gps->totpoints);
 
-/* Draw start and end point differently if enabled stroke direction hint */
-bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && 
(gps->totpoints > 1);
-
 /* Draw all the stroke points (selected or not) */
 bGPDspoint *pt = gps->points;
 for (int i = 0; i < gps->totpoints; i++, pt++) {
   /* size and color first */
-  if (show_direction_hint && i == 0) {
-/* start point in green bigger */
-immAttr3f(color, 0.0f, 1.0f, 0.0f);
-immAttr1f(size, vsize + 4);
-  }
-  else if (show_direction_hint && (i == gps->totpoints - 1)) {
-/* end point in red smaller */
-immAttr3f(color, 1.0f, 0.0f, 0.0f);
-immAttr1f(size, vsize + 1);
-  }
-  else if (pt->flag & GP_SPOINT_SELECT) {
-immAttr3fv(color, selectColor);
-immAttr1f(size, vsize);
-  }
-  else 

[Bf-blender-cvs] [6ac1f2eff25] greasepencil-refactor: GPencil: Refactor: Overlay: Add hide selection option back

2020-01-07 Thread Clément Foucault
Commit: 6ac1f2eff254d4ca81acdae24938ce5aa66d74a2
Author: Clément Foucault
Date:   Tue Jan 7 16:15:06 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB6ac1f2eff254d4ca81acdae24938ce5aa66d74a2

GPencil: Refactor: Overlay: Add hide selection option back

===

M   source/blender/draw/engines/overlay/overlay_gpencil.c
M   source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl

===

diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c 
b/source/blender/draw/engines/overlay/overlay_gpencil.c
index d7b17c6b9b8..ce2866ac7b3 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -64,8 +64,8 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
 return;
   }
 
-  // const bool use_sculpt_mask = (GPENCIL_SCULPT_MODE(gpd) &&
-  //   
GPENCIL_ANY_SCULPT_MASK(ts->gpencil_selectmode_sculpt));
+  const bool use_sculpt_mask = (GPENCIL_SCULPT_MODE(gpd) &&
+
GPENCIL_ANY_SCULPT_MASK(ts->gpencil_selectmode_sculpt));
   const bool show_sculpt_points = (GPENCIL_SCULPT_MODE(gpd) &&
(ts->gpencil_selectmode_sculpt &
 (GP_SCULPT_MASK_SELECTMODE_POINT |
@@ -87,8 +87,8 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   const bool is_vertex_paint = (gpd) && (gpd->flag & 
GP_DATA_STROKE_VERTEXMODE);
 
   /* If Sculpt/Vertex mode and the mask is disabled, the select must be 
hidden. */
-  // const bool hide_select = ((GPENCIL_SCULPT_MODE(gpd) && !use_sculpt_mask) 
||
-  //   (GPENCIL_VERTEX_MODE(gpd) && !use_vertex_mask));
+  const bool hide_select = ((GPENCIL_SCULPT_MODE(gpd) && !use_sculpt_mask) ||
+(GPENCIL_VERTEX_MODE(gpd) && !use_vertex_mask));
 
   /* Show Edit points if:
*  Edit mode: Not in Stroke selection mode
@@ -116,9 +116,10 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
   DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", 
show_multi_edit_lines);
   DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", 
v3d->vertex_opacity);
+  DRW_shgroup_uniform_bool_copy(grp, "hideSelect", hide_select);
 }
 
-if (show_points) {
+if (show_points && !hide_select) {
   sh = OVERLAY_shader_edit_gpencil_point();
   pd->edit_gpencil_points_grp = grp = DRW_shgroup_create(sh, 
psl->edit_gpencil_ps);
   DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
diff --git a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl 
b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
index 542db778e46..ef8febb59c4 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
@@ -2,6 +2,7 @@
 uniform float normalSize;
 uniform bool doMultiframe;
 uniform bool doStrokeEndpoints;
+uniform bool hideSelect;
 uniform float gpEditOpacity;
 uniform vec4 gpEditColor;
 
@@ -25,8 +26,10 @@ void discard_vert()
 
 #ifdef USE_POINTS
 #  define colorUnselect colorGpencilVertex
+#  define colorSelect colorGpencilVertexSelect
 #else
 #  define colorUnselect gpEditColor
+#  define colorSelect (hideSelect ? colorUnselect : colorGpencilVertexSelect)
 #endif
 
 void main()
@@ -39,7 +42,7 @@ void main()
   bool is_multiframe = (vflag & GP_EDIT_MULTIFRAME) != 0u;
   bool is_stroke_sel = (vflag & GP_EDIT_STROKE_SELECTED) != 0u;
   bool is_point_sel = (vflag & GP_EDIT_POINT_SELECTED) != 0u;
-  finalColor = (is_point_sel) ? colorGpencilVertexSelect : colorUnselect;
+  finalColor = (is_point_sel) ? colorSelect : colorUnselect;
   finalColor.a *= gpEditOpacity;
 
 #ifdef USE_POINTS

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


[Bf-blender-cvs] [1762cd34125] greasepencil-refactor: GPencil: Refactor: Add Weight Paint support

2020-01-07 Thread Clément Foucault
Commit: 1762cd341250e7ea8c1c45bfb957039c5138af38
Author: Clément Foucault
Date:   Tue Jan 7 17:41:07 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB1762cd341250e7ea8c1c45bfb957039c5138af38

GPencil: Refactor: Add Weight Paint support

===

M   source/blender/draw/engines/overlay/overlay_gpencil.c
M   source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
M   source/blender/draw/intern/draw_cache_impl_gpencil.c

===

diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c 
b/source/blender/draw/engines/overlay/overlay_gpencil.c
index ce2866ac7b3..4e45d5f6cad 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -115,8 +115,10 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   pd->edit_gpencil_wires_grp = grp = DRW_shgroup_create(sh, 
psl->edit_gpencil_ps);
   DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
   DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", 
show_multi_edit_lines);
-  DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", 
v3d->vertex_opacity);
+  DRW_shgroup_uniform_bool_copy(grp, "doWeightColor", is_weight_paint);
   DRW_shgroup_uniform_bool_copy(grp, "hideSelect", hide_select);
+  DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", 
v3d->vertex_opacity);
+  DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp);
 }
 
 if (show_points && !hide_select) {
@@ -124,7 +126,9 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   pd->edit_gpencil_points_grp = grp = DRW_shgroup_create(sh, 
psl->edit_gpencil_ps);
   DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
   DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", do_multiedit);
+  DRW_shgroup_uniform_bool_copy(grp, "doWeightColor", is_weight_paint);
   DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", 
v3d->vertex_opacity);
+  DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp);
 }
   }
 }
@@ -133,9 +137,6 @@ static void 
OVERLAY_edit_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob
 {
   OVERLAY_PrivateData *pd = vedata->stl->pd;
   bGPdata *gpd = (bGPdata *)ob->data;
-  if (gpd == NULL) {
-return;
-  }
 
   if (pd->edit_gpencil_wires_grp) {
 DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->edit_gpencil_wires_grp);
@@ -159,9 +160,6 @@ static void 
OVERLAY_edit_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob
 static void OVERLAY_gpencil_color_names(Object *ob)
 {
   bGPdata *gpd = (bGPdata *)ob->data;
-  if (gpd == NULL) {
-return;
-  }
 
   const DRWContextState *draw_ctx = DRW_context_state_get();
   ViewLayer *view_layer = draw_ctx->view_layer;
@@ -219,7 +217,12 @@ static void OVERLAY_gpencil_color_names(Object *ob)
 
 void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob)
 {
-  if (ob->mode == OB_MODE_EDIT_GPENCIL) {
+  bGPdata *gpd = (bGPdata *)ob->data;
+  if (gpd == NULL) {
+return;
+  }
+
+  if (GPENCIL_ANY_MODE(gpd)) {
 OVERLAY_edit_gpencil_cache_populate(vedata, ob);
   }
 
diff --git a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl 
b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
index ef8febb59c4..cb03ad44615 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
@@ -3,12 +3,15 @@ uniform float normalSize;
 uniform bool doMultiframe;
 uniform bool doStrokeEndpoints;
 uniform bool hideSelect;
+uniform bool doWeightColor;
 uniform float gpEditOpacity;
 uniform vec4 gpEditColor;
+uniform sampler1D weightTex;
 
 in vec3 pos;
 in float ma;
 in uint vflag;
+in float weight;
 
 out vec4 finalColor;
 
@@ -32,6 +35,21 @@ void discard_vert()
 #  define colorSelect (hideSelect ? colorUnselect : colorGpencilVertexSelect)
 #endif
 
+vec3 weight_to_rgb(float t)
+{
+  if (t < 0.0) {
+/* No weight */
+return colorUnselect.rgb;
+  }
+  else if (t > 1.0) {
+/* Error color */
+return vec3(1.0, 0.0, 1.0);
+  }
+  else {
+return texture(weightTex, t).rgb;
+  }
+}
+
 void main()
 {
   GPU_INTEL_VERTEX_SHADER_WORKAROUND
@@ -42,13 +60,20 @@ void main()
   bool is_multiframe = (vflag & GP_EDIT_MULTIFRAME) != 0u;
   bool is_stroke_sel = (vflag & GP_EDIT_STROKE_SELECTED) != 0u;
   bool is_point_sel = (vflag & GP_EDIT_POINT_SELECTED) != 0u;
-  finalColor = (is_point_sel) ? colorSelect : colorUnselect;
-  finalColor.a *= gpEditOpacity;
+
+  if (doWeightColor) {
+finalColor.rgb = weight_to_rgb(weight);
+finalColor.a = gpEditOpacity;
+  }
+  else {
+finalColor = (is_point_sel) ? colorSelect : colorUnselect;
+finalColor.a *= gpEditOpacity;
+  }
 
 #ifdef USE_POINTS
   gl_PointSize = sizeVertex * 2.0;
 
-  if 

[Bf-blender-cvs] [55daa0d4448] master: Fix T72251: Add rotate brush as constrained by radius for automasking

2020-01-07 Thread Pablo Dobarro
Commit: 55daa0d44483e165d5ce10d161489d136fa0c4e4
Author: Pablo Dobarro
Date:   Sat Dec 7 20:01:39 2019 +0100
Branches: master
https://developer.blender.org/rB55daa0d44483e165d5ce10d161489d136fa0c4e4

Fix T72251: Add rotate brush as constrained by radius for automasking

This brush should be added to the set of brushes where we know which
vertices are going to be affected by the brush when starting the stroke.
This way we can limit the automasking only to those vertices instead of
flood filling the whole mesh from the active vertex.

All brushes that are not in this set will automask by flood filling the
mesh when starting the stroke. To improve this and make it work as most
users expect, we need a fast way to calculate topological distances on
high poly meshes.

Reviewed By: jbakker

Maniphest Tasks: T72251

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

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 0ac43f18344..c350cb3b48a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1256,7 +1256,7 @@ static bool 
sculpt_automasking_is_constrained_by_radius(Brush *br)
 return false;
   }
 
-  if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) {
+  if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, 
SCULPT_TOOL_ROTATE)) {
 return true;
   }
   return false;

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


[Bf-blender-cvs] [4f70af34e05] master: Fix T72647: Check if the PBVH type makes sense for the sampling mode

2020-01-07 Thread Pablo Dobarro
Commit: 4f70af34e054ef42b0e9079d8d5fc8c6e2ac8c19
Author: Pablo Dobarro
Date:   Tue Dec 24 00:34:37 2019 +0100
Branches: master
https://developer.blender.org/rB4f70af34e054ef42b0e9079d8d5fc8c6e2ac8c19

Fix T72647: Check if the PBVH type makes sense for the sampling mode

Before this it was possible to use the operator with Dyntopo sample mode
with a PBVH type GRIDS or FACES, causing a crash. Now we check first if
the PBVH type is correct before calling the sampling function.

We also check if the PBVH exists, which may also cause a crash.

Reviewed By: jbakker

Maniphest Tasks: T72647

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

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index a96ca07cc9b..0ac43f18344 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -8845,14 +8845,14 @@ static void sample_detail_dyntopo(bContext *C, 
ViewContext *vc, ARegion *ar, int
   }
 }
 
-static void sample_detail(bContext *C, int mx, int my, int mode)
+static int sample_detail(bContext *C, int mx, int my, int mode)
 {
   /* Find 3D view to pick from. */
   bScreen *screen = CTX_wm_screen(C);
   ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_VIEW3D, mx, my);
   ARegion *ar = (sa) ? BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my) : 
NULL;
   if (ar == NULL) {
-return;
+return OPERATOR_CANCELLED;
   }
 
   /* Set context to 3D view. */
@@ -8865,12 +8865,29 @@ static void sample_detail(bContext *C, int mx, int my, 
int mode)
   ViewContext vc;
   ED_view3d_viewcontext_init(C, , depsgraph);
 
+  Object *ob = vc.obact;
+  SculptSession *ss = ob->sculpt;
+
+  if (!ss->pbvh) {
+return OPERATOR_CANCELLED;
+  }
+
   /* Pick sample detail. */
   switch (mode) {
 case SAMPLE_DETAIL_DYNTOPO:
+  if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) {
+CTX_wm_area_set(C, prev_sa);
+CTX_wm_region_set(C, prev_ar);
+return OPERATOR_CANCELLED;
+  }
   sample_detail_dyntopo(C, , ar, mx, my);
   break;
 case SAMPLE_DETAIL_VOXEL:
+  if (BKE_pbvh_type(ss->pbvh) != PBVH_FACES) {
+CTX_wm_area_set(C, prev_sa);
+CTX_wm_region_set(C, prev_ar);
+return OPERATOR_CANCELLED;
+  }
   sample_detail_voxel(C, , mx, my);
   break;
   }
@@ -8878,6 +8895,8 @@ static void sample_detail(bContext *C, int mx, int my, 
int mode)
   /* Restore context. */
   CTX_wm_area_set(C, prev_sa);
   CTX_wm_region_set(C, prev_ar);
+
+  return OPERATOR_FINISHED;
 }
 
 static int sculpt_sample_detail_size_exec(bContext *C, wmOperator *op)
@@ -8885,8 +8904,7 @@ static int sculpt_sample_detail_size_exec(bContext *C, 
wmOperator *op)
   int ss_co[2];
   RNA_int_get_array(op->ptr, "location", ss_co);
   int mode = RNA_enum_get(op->ptr, "mode");
-  sample_detail(C, ss_co[0], ss_co[1], mode);
-  return OPERATOR_FINISHED;
+  return sample_detail(C, ss_co[0], ss_co[1], mode);
 }
 
 static int sculpt_sample_detail_size_invoke(bContext *C, wmOperator *op, const 
wmEvent *UNUSED(e))

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


[Bf-blender-cvs] [97224681094] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

2020-01-07 Thread Antonio Vazquez
Commit: 9722468109484141e0cb0a1c6136e9d5301cb60d
Author: Antonio Vazquez
Date:   Tue Jan 7 17:00:42 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB9722468109484141e0cb0a1c6136e9d5301cb60d

Merge branch 'greasepencil-object' into greasepencil-refactor

===



===



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


[Bf-blender-cvs] [d8347833871] greasepencil-refactor: GPencil: Enable Annotations by default in 2D template

2020-01-07 Thread Antonio Vazquez
Commit: d834783387128d37ef82c89bdd3201681f0ea5f6
Author: Antonio Vazquez
Date:   Tue Jan 7 17:00:02 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBd834783387128d37ef82c89bdd3201681f0ea5f6

GPencil: Enable Annotations by default in 2D template

===

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

===

diff --git a/source/blender/blenloader/intern/versioning_defaults.c 
b/source/blender/blenloader/intern/versioning_defaults.c
index 3dcd1b57e7d..effc4c6fa30 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -234,6 +234,8 @@ static void blo_update_defaults_screen(bScreen *screen,
   View3D *v3d = sa->spacedata.first;
   /* Set Vertex Color by default. */
   v3d->shading.color_type = V3D_SHADING_VERTEX_COLOR;
+  /* Enable Annotations. */
+  v3d->flag2 |= V3D_SHOW_ANNOTATION;
 }
   }
 }

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


[Bf-blender-cvs] [bc9c8c35e17] master: Fix T72830: Check if the mesh has mask data before extractig or slicing

2020-01-07 Thread Pablo Dobarro
Commit: bc9c8c35e17428f3697664274bc54e9c294453c5
Author: Pablo Dobarro
Date:   Mon Jan 6 16:50:48 2020 +0100
Branches: master
https://developer.blender.org/rBbc9c8c35e17428f3697664274bc54e9c294453c5

Fix T72830: Check if the mesh has mask data before extractig or slicing

This was causing a crash when the mesh does not have the mask data
initialized. I also added the same check to mask extract as it works the
same way.

Reviewed By: jbakker

Maniphest Tasks: T72830

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

===

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

===

diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c 
b/source/blender/editors/mesh/editmesh_mask_extract.c
index 0d886360253..28962c8ec01 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -80,6 +80,8 @@ static int paint_mask_extract_exec(bContext *C, wmOperator 
*op)
   View3D *v3d = CTX_wm_view3d(C);
   Scene *scene = CTX_data_scene(C);
 
+  BKE_sculpt_mask_layers_ensure(ob, NULL);
+
   Mesh *mesh = ob->data;
   Mesh *new_mesh = BKE_mesh_copy(bmain, mesh);
 
@@ -104,9 +106,8 @@ static int paint_mask_extract_exec(bContext *C, wmOperator 
*op)
   BMIter face_iter;
 
   /* Delete all unmasked faces */
-  const int cd_vert_mask_offset = CustomData_get_offset(>vdata, 
CD_PAINT_MASK);
-  BLI_assert(cd_vert_mask_offset != -1);
   BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, 
false);
+  const int cd_vert_mask_offset = CustomData_get_offset(>vdata, 
CD_PAINT_MASK);
 
   float mask_threshold = RNA_float_get(op->ptr, "mask_threshold");
   BM_ITER_MESH (f, , bm, BM_FACES_OF_MESH) {
@@ -336,6 +337,8 @@ static int paint_mask_slice_exec(bContext *C, wmOperator 
*op)
   Object *ob = CTX_data_active_object(C);
   View3D *v3d = CTX_wm_view3d(C);
 
+  BKE_sculpt_mask_layers_ensure(ob, NULL);
+
   Mesh *mesh = ob->data;
   Mesh *new_mesh = BKE_mesh_copy(bmain, mesh);

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


[Bf-blender-cvs] [96c238dddb6] greasepencil-object: GPencil: Add Annotation tools to Vertex Paint mode

2020-01-07 Thread Antonio Vazquez
Commit: 96c238dddb66295df48752dc47fb11c61a1de0a8
Author: Antonio Vazquez
Date:   Tue Jan 7 16:55:12 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB96c238dddb66295df48752dc47fb11c61a1de0a8

GPencil: Add Annotation tools to Vertex Paint mode

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 6cf664591d6..cb4a0077e08 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2196,6 +2196,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, 
Panel):
 'VERTEX_GPENCIL': [
 _defs_gpencil_vertex.generate_from_brushes,
 None,
+*_tools_annotate,
+None,
 lambda context: (
 VIEW3D_PT_tools_active._tools_gpencil_select
 if _defs_gpencil_vertex.poll_select_mask(context)

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


[Bf-blender-cvs] [fdf89acc863] master: Sculpt: Pose Brush with Inverse Kinematics

2020-01-07 Thread Pablo Dobarro
Commit: fdf89acc8634ecba4dfe66e20ff595c0c24ffdee
Author: Pablo Dobarro
Date:   Tue Jan 7 16:46:56 2020 +0100
Branches: master
https://developer.blender.org/rBfdf89acc8634ecba4dfe66e20ff595c0c24ffdee

Sculpt: Pose Brush with Inverse Kinematics

This commits introduces the pose_ik_segments brush property in the Pose Brush. 
When increasing the IK segments count, the brush generates more segments and 
weights associations following the topology of the mesh. When moving the brush, 
these segments are transformed using an IK solver and they are used to deform 
the mesh.

When pressing Ctrl, the brush controls the segments' roll rotation instead of 
using the IK solver. The brush falloff controls how much rotation is propagated 
from the first to the last segment in the chain.

Reviewed By: jbakker

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

===

M   release/scripts/startup/bl_ui/properties_paint_common.py
M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/brush.c
M   source/blender/blenkernel/intern/paint.c
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/editors/sculpt_paint/paint_cursor.c
M   source/blender/editors/sculpt_paint/paint_intern.h
M   source/blender/editors/sculpt_paint/paint_utils.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/makesdna/DNA_brush_types.h
M   source/blender/makesrna/intern/rna_brush.c

===

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py 
b/release/scripts/startup/bl_ui/properties_paint_common.py
index 327df079d3b..b15a244eefd 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -616,9 +616,12 @@ def brush_settings(layout, context, brush, popover=False):
 layout.separator()
 
 if brush.sculpt_tool == 'POSE':
-row = layout.row()
-row.prop(brush, "pose_offset")
-
+layout.separator()
+layout.prop(brush, "pose_offset")
+layout.prop(brush, "pose_smooth_iterations")
+layout.prop(brush, "pose_ik_segments")
+layout.separator()
+
 if brush.sculpt_tool == 'SCRAPE':
 row = layout.row()
 row.prop(brush, "invert_to_scrape_fill", text="Invert to Fill")
diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index fdd3bd7cd86..6089db5ed46 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -98,6 +98,20 @@ typedef enum eOverlayControlFlags {
   (PAINT_OVERLAY_OVERRIDE_SECONDARY | PAINT_OVERLAY_OVERRIDE_PRIMARY | \
PAINT_OVERLAY_OVERRIDE_CURSOR)
 
+/* Defines 8 areas resulting of splitting the object space by the XYZ axis 
planes. This is used to
+ * flip or mirror transform values depending on where the vertex is and where 
the transform
+ * operation started to support XYZ symmetry on those operations in a 
predictable way. */
+
+#define AREA_SYMM_DEFAULT 0
+
+typedef enum ePaintSymmetryAreas {
+  AREA_SYMM_X = (1 << 0),
+  AREA_SYMM_Y = (1 << 1),
+  AREA_SYMM_Z = (1 << 2),
+} ePaintSymmetryAreas;
+
+#define PAINT_SYMM_AREAS 8
+
 void BKE_paint_invalidate_overlay_tex(struct Scene *scene,
   struct ViewLayer *view_layer,
   const struct Tex *tex);
@@ -211,6 +225,29 @@ struct SculptVertexPaintGeomMap {
   struct MeshElemMap *vert_to_poly;
 };
 
+/* Pose Brush IK Chain */
+typedef struct PoseIKChainSegment {
+  float orig[3];
+  float head[3];
+
+  float initial_orig[3];
+  float initial_head[3];
+  float len;
+  float rot[4];
+  float *weights;
+
+  /* Store a 4x4 transform matrix for each of the possible combinations of 
enabled XYZ symmetry
+   * axis. */
+  float trans_mat[PAINT_SYMM_AREAS][4][4];
+  float pivot_mat[PAINT_SYMM_AREAS][4][4];
+  float pivot_mat_inv[PAINT_SYMM_AREAS][4][4];
+} PoseIKChainSegment;
+
+typedef struct PoseIKChain {
+  PoseIKChainSegment *segments;
+  int tot_segments;
+} PoseIKChain;
+
 /* Session data (mode-specific) */
 
 typedef struct SculptSession {
@@ -273,7 +310,10 @@ typedef struct SculptSession {
   /* Dynamic mesh preview */
   int *preview_vert_index_list;
   int preview_vert_index_count;
+
+  /* Pose Brush Preview */
   float pose_origin[3];
+  PoseIKChain *pose_ik_chain_preview;
 
   /* Transform operator */
   float pivot_pos[3];
diff --git a/source/blender/blenkernel/intern/brush.c 
b/source/blender/blenkernel/intern/brush.c
index e9760f76cfc..8d49ab39bab 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -992,6 +992,7 @@ void BKE_brush_sculpt_reset(Brush *br)
   break;
 case 

[Bf-blender-cvs] [b9b577e3d1f] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

2020-01-07 Thread Antonio Vazquez
Commit: b9b577e3d1f23158bbb96649487ddcfed0fe5c2b
Author: Antonio Vazquez
Date:   Tue Jan 7 16:45:47 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBb9b577e3d1f23158bbb96649487ddcfed0fe5c2b

Merge branch 'greasepencil-object' into greasepencil-refactor

===



===



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


[Bf-blender-cvs] [7ac0d86582d] greasepencil-object: GPencil: Fix several issues with Vertex Paint

2020-01-07 Thread Antonio Vazquez
Commit: 7ac0d86582d88502e185b6ea62a3d593d9d80bc7
Author: Antonio Vazquez
Date:   Tue Jan 7 16:45:06 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB7ac0d86582d88502e185b6ea62a3d593d9d80bc7

GPencil: Fix several issues with Vertex Paint

Using big brush radius gets weird values.
Add missing some UI options

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/editors/gpencil/gpencil_vertex_paint.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 0de37f6729f..8859ecc5027 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -740,7 +740,14 @@ class VIEW3D_HT_header(Header):
 row.prop(tool_settings, "use_gpencil_select_mask_stroke", 
text="")
 row.prop(tool_settings, "use_gpencil_select_mask_segment", 
text="")
 
-if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode or 
gpd.is_stroke_weight_mode:
+# Select mode for Vertex Paint
+if gpd.is_stroke_vertex_mode:
+row = layout.row(align=True)
+row.prop(tool_settings, 
"use_gpencil_vertex_select_mask_point", text="")
+row.prop(tool_settings, 
"use_gpencil_vertex_select_mask_stroke", text="")
+row.prop(tool_settings, 
"use_gpencil_vertex_select_mask_segment", text="")
+
+if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode or 
gpd.is_stroke_weight_mode or gpd.is_stroke_vertex_mode:
 row = layout.row(align=True)
 row.prop(gpd, "use_multiedit", text="", 
icon='GP_MULTIFRAME_EDITING')
 
@@ -6468,12 +6475,16 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
 sub.prop(overlay, "gpencil_paper_opacity", text="Fade Objects", 
slider=True)
 sub.prop(overlay, "use_gpencil_fade_objects", text="", 
icon='OUTLINER_OB_GREASEPENCIL')
 
-if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 
'WEIGHT_GPENCIL'}:
+if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 
'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}:
 layout.prop(overlay, "use_gpencil_edit_lines", text="Edit Lines")
 layout.prop(overlay, "use_gpencil_multiedit_line_only", text="Show 
Edit Lines only in multiframe")
+
+if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 
'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}:
 layout.prop(overlay, "vertex_opacity", text="Vertex Opacity", 
slider=True)
 
-layout.prop(overlay, "gpencil_vertex_paint_opacity", slider=True)
+if context.object.mode in {'PAINT_GPENCIL', 'EDIT_GPENCIL', 
'SCULPT_GPENCIL', 'VERTEX_GPENCIL'}:
+layout.label(text="Vertex Paint")
+layout.prop(overlay, "gpencil_vertex_paint_opacity", 
text="Opacity", slider=True)
 
 
 class VIEW3D_PT_quad_view(Panel):
@@ -6792,11 +6803,23 @@ class VIEW3D_PT_gpencil_draw_context_menu(Panel):
 bl_label = "Draw Context Menu"
 
 def draw(self, context):
-brush = context.tool_settings.gpencil_paint.brush
+ts = context.tool_settings
+settings = ts.gpencil_paint
+brush = settings.brush
 gp_settings = brush.gpencil_settings
 
 layout = self.layout
 
+if brush.gpencil_tool not in {'ERASE', 'CUTTER', 'EYEDROPPER'} and 
settings.use_vertex_color:
+split = layout.split(factor=0.1)
+split.prop(brush, "color", text="")
+split.template_color_picker(brush, "color", value_slider=True)
+
+col = layout.column()
+col.separator()
+col.prop_menu_enum(gp_settings, "vertex_mode", text="Mode")
+col.separator()
+
 if brush.gpencil_tool not in {'FILL', 'CUTTER'}:
 layout.prop(brush, "size", slider=True)
 if brush.gpencil_tool not in {'ERASE', 'FILL', 'CUTTER'}:
diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c 
b/source/blender/editors/gpencil/gpencil_vertex_paint.c
index 9c9e2231865..028412799fb 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_paint.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c
@@ -429,6 +429,9 @@ static bool brush_tint_apply(tGP_BrushVertexpaintData *gso,
   100.0f;
   float inf_fill = (gso->pressure * brush->gpencil_settings->draw_strength) / 
1000.0f;
 
+  CLAMP(inf, 0.0f, 1.0f);
+  CLAMP(inf_fill, 0.0f, 1.0f);
+
   bGPDspoint *pt = >points[pt_index];
 
   float alpha = pt->mix_color[3];

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


[Bf-blender-cvs] [bd766f8f060] master: Fix T72935: Applying transform to parent mesh changes rotation of children using quaternions

2020-01-07 Thread mano-wii
Commit: bd766f8f0608d04c473544274b8dd9dcc00ec39a
Author: mano-wii
Date:   Tue Jan 7 12:42:37 2020 -0300
Branches: master
https://developer.blender.org/rBbd766f8f0608d04c473544274b8dd9dcc00ec39a

Fix T72935: Applying transform to parent mesh changes rotation of children 
using quaternions

`ob->quat` is `v4`.

===

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

===

diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index 10553e73d8d..1378e862034 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1323,7 +1323,7 @@ void BKE_object_transform_copy(Object *ob_tar, const 
Object *ob_src)
 {
   copy_v3_v3(ob_tar->loc, ob_src->loc);
   copy_v3_v3(ob_tar->rot, ob_src->rot);
-  copy_v3_v3(ob_tar->quat, ob_src->quat);
+  copy_v4_v4(ob_tar->quat, ob_src->quat);
   copy_v3_v3(ob_tar->rotAxis, ob_src->rotAxis);
   ob_tar->rotAngle = ob_src->rotAngle;
   ob_tar->rotmode = ob_src->rotmode;

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


[Bf-blender-cvs] [e665c2c8932] master: Fix T69314: Broken Rotation to Deltas for Quaternions

2020-01-07 Thread mano-wii
Commit: e665c2c89326f4b13270d0d5d5082b5368413371
Author: mano-wii
Date:   Tue Jan 7 11:52:44 2020 -0300
Branches: master
https://developer.blender.org/rBe665c2c89326f4b13270d0d5d5082b5368413371

Fix T69314: Broken Rotation to Deltas for Quaternions

===

M   release/scripts/startup/bl_operators/object.py

===

diff --git a/release/scripts/startup/bl_operators/object.py 
b/release/scripts/startup/bl_operators/object.py
index c42d5970ed9..12d7984b3b2 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -743,7 +743,9 @@ class TransformsToDeltas(Operator):
 def transfer_rotation(self, obj):
 # TODO: add transforms together...
 if obj.rotation_mode == 'QUATERNION':
-obj.delta_rotation_quaternion += obj.rotation_quaternion
+delta = obj.delta_rotation_quaternion.copy()
+obj.delta_rotation_quaternion = obj.rotation_quaternion
+obj.delta_rotation_quaternion.rotate(delta)
 
 if self.reset_values:
 obj.rotation_quaternion.identity()

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


[Bf-blender-cvs] [0bd598d388b] master: bmesh_intersect_edges: Remove unnecessary index setting

2020-01-07 Thread mano-wii
Commit: 0bd598d388b4d64e2d9ab4b8a84768beb30b8625
Author: mano-wii
Date:   Tue Jan 7 11:50:09 2020 -0300
Branches: master
https://developer.blender.org/rB0bd598d388b4d64e2d9ab4b8a84768beb30b8625

bmesh_intersect_edges: Remove unnecessary index setting

===

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

===

diff --git a/source/blender/bmesh/tools/bmesh_intersect_edges.c 
b/source/blender/bmesh/tools/bmesh_intersect_edges.c
index 6801501e95b..c3687c5d477 100644
--- a/source/blender/bmesh/tools/bmesh_intersect_edges.c
+++ b/source/blender/bmesh/tools/bmesh_intersect_edges.c
@@ -552,13 +552,11 @@ bool BM_mesh_intersect_edges(BMesh *bm, const char hflag, 
const float dist, GHas
   BM_ITER_MESH (v, , bm, BM_VERTS_OF_MESH) {
 if (BM_elem_flag_test(v, hflag)) {
   BM_elem_flag_enable(v, BM_ELEM_TAG);
-  v->head.index = -1;
   verts_act_len++;
 }
 else {
   BM_elem_flag_disable(v, BM_ELEM_TAG);
   if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
-v->head.index = -1;
 verts_remain_len++;
   }
 }
@@ -827,7 +825,6 @@ bool BM_mesh_intersect_edges(BMesh *bm, const char hflag, 
const float dist, GHas
   e = pair_elem->edge;
 
   BMVert *v_new = BM_edge_split(bm, e, e->v1, NULL, lambda);
-  v_new->head.index = -1;
   pair_elem->vert = v_new;
 }
   }

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


[Bf-blender-cvs] [6d479b4d2bb] greasepencil-refactor: GPencil: Refactor: Fix crash in vertex paint mode

2020-01-07 Thread Clément Foucault
Commit: 6d479b4d2bb12091aa8cefc06023167cbf678929
Author: Clément Foucault
Date:   Tue Jan 7 15:48:25 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB6d479b4d2bb12091aa8cefc06023167cbf678929

GPencil: Refactor: Fix crash in vertex paint mode

===

M   source/blender/draw/engines/overlay/overlay_gpencil.c

===

diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c 
b/source/blender/draw/engines/overlay/overlay_gpencil.c
index 2c56d3ba7dd..d7b17c6b9b8 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -47,6 +47,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   /* Default: Display nothing. */
   pd->edit_gpencil_points_grp = NULL;
   pd->edit_gpencil_wires_grp = NULL;
+  psl->edit_gpencil_ps = NULL;
 
   /* REFACTOR(fclem) remove */
   if (G.debug_value != 50) {
@@ -233,10 +234,7 @@ void OVERLAY_edit_gpencil_draw(OVERLAY_Data *vedata)
 {
   OVERLAY_PassList *psl = vedata->psl;
 
-  /* REFACTOR(fclem) remove */
-  if (G.debug_value != 50) {
-return;
+  if (psl->edit_gpencil_ps) {
+DRW_draw_pass(psl->edit_gpencil_ps);
   }
-
-  DRW_draw_pass(psl->edit_gpencil_ps);
 }

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


[Bf-blender-cvs] [7025910e88a] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

2020-01-07 Thread Antonio Vazquez
Commit: 7025910e88a0585659b651de969dc106ced7f247
Author: Antonio Vazquez
Date:   Tue Jan 7 15:46:50 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB7025910e88a0585659b651de969dc106ced7f247

Merge branch 'greasepencil-object' into greasepencil-refactor

===



===



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


[Bf-blender-cvs] [35c2d3fb5d0] greasepencil-refactor: GPencil: Fix damaged Overlay panel in Vertex Paint mode

2020-01-07 Thread Antonio Vazquez
Commit: 35c2d3fb5d016eec161af78af0d2edc8aa479321
Author: Antonio Vazquez
Date:   Tue Jan 7 15:45:34 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB35c2d3fb5d016eec161af78af0d2edc8aa479321

GPencil: Fix damaged Overlay panel in Vertex Paint mode

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index b4d7bc6632d..0de37f6729f 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6437,6 +6437,7 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
 'EDIT_GPENCIL': "Edit Grease Pencil",
 'SCULPT_GPENCIL': "Sculpt Grease Pencil",
 'WEIGHT_GPENCIL': "Weight Grease Pencil",
+'VERTEX_GPENCIL': "Vertex Grease Pencil",
 'OBJECT': "Grease Pencil",
 }[context.mode])
 
@@ -6472,6 +6473,8 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
 layout.prop(overlay, "use_gpencil_multiedit_line_only", text="Show 
Edit Lines only in multiframe")
 layout.prop(overlay, "vertex_opacity", text="Vertex Opacity", 
slider=True)
 
+layout.prop(overlay, "gpencil_vertex_paint_opacity", slider=True)
+
 
 class VIEW3D_PT_quad_view(Panel):
 bl_space_type = 'VIEW_3D'

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


[Bf-blender-cvs] [8c378e8517c] greasepencil-object: GPencil: Fix damaged Overlay panel in Vertex Paint mode

2020-01-07 Thread Antonio Vazquez
Commit: 8c378e8517c9beed021601acb15b7f0ce78a9606
Author: Antonio Vazquez
Date:   Tue Jan 7 15:45:34 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB8c378e8517c9beed021601acb15b7f0ce78a9606

GPencil: Fix damaged Overlay panel in Vertex Paint mode

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index b4d7bc6632d..0de37f6729f 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6437,6 +6437,7 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
 'EDIT_GPENCIL': "Edit Grease Pencil",
 'SCULPT_GPENCIL': "Sculpt Grease Pencil",
 'WEIGHT_GPENCIL': "Weight Grease Pencil",
+'VERTEX_GPENCIL': "Vertex Grease Pencil",
 'OBJECT': "Grease Pencil",
 }[context.mode])
 
@@ -6472,6 +6473,8 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
 layout.prop(overlay, "use_gpencil_multiedit_line_only", text="Show 
Edit Lines only in multiframe")
 layout.prop(overlay, "vertex_opacity", text="Vertex Opacity", 
slider=True)
 
+layout.prop(overlay, "gpencil_vertex_paint_opacity", slider=True)
+
 
 class VIEW3D_PT_quad_view(Panel):
 bl_space_type = 'VIEW_3D'

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


[Bf-blender-cvs] [41c45aef969] greasepencil-refactor: GPencil: Refactor: Fix multiedit having less predecence than onion skin

2020-01-07 Thread Clément Foucault
Commit: 41c45aef969c32169495f5190ac5895c9bb83775
Author: Clément Foucault
Date:   Tue Jan 7 12:49:33 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB41c45aef969c32169495f5190ac5895c9bb83775

GPencil: Refactor: Fix multiedit having less predecence than onion skin

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index 823f75de3f3..96c62802b50 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -3722,7 +3722,23 @@ void BKE_gpencil_visible_stroke_iter(
   continue;
 }
 
-if (is_onion && (gpl->onion_flag & GP_LAYER_ONIONSKIN)) {
+if (is_multiedit) {
+  sta_gpf = end_gpf = NULL;
+  /* Check the whole range and tag the editable frames. */
+  LISTBASE_FOREACH (bGPDframe *, gpf, >frames) {
+if (gpf == act_gpf || (gpf->flag & GP_FRAME_SELECT)) {
+  gpf->runtime.onion_id = 0;
+  if (sta_gpf == NULL) {
+sta_gpf = gpf;
+  }
+  end_gpf = gpf->next;
+}
+else {
+  gpf->runtime.onion_id = INT_MAX;
+}
+  }
+}
+else if (is_onion && (gpl->onion_flag & GP_LAYER_ONIONSKIN)) {
   if (act_gpf) {
 bGPDframe *last_gpf = gpl->frames.last;
 
@@ -3762,22 +3778,6 @@ void BKE_gpencil_visible_stroke_iter(
   sta_gpf = gpl->frames.first;
   end_gpf = NULL;
 }
-else if (is_multiedit) {
-  sta_gpf = end_gpf = NULL;
-  /* Check the whole range and tag the editable frames. */
-  LISTBASE_FOREACH (bGPDframe *, gpf, >frames) {
-if (gpf == act_gpf || (gpf->flag & GP_FRAME_SELECT)) {
-  gpf->runtime.onion_id = 0;
-  if (sta_gpf == NULL) {
-sta_gpf = gpf;
-  }
-  end_gpf = gpf->next;
-}
-else {
-  gpf->runtime.onion_id = INT_MAX;
-}
-  }
-}
 else {
   /* Bypass multiedit/onion skinning. */
   end_gpf = sta_gpf = NULL;

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


[Bf-blender-cvs] [55f38e453c9] greasepencil-refactor: GPencil: Refactor: Edit Mode: Add support for minor features

2020-01-07 Thread Clément Foucault
Commit: 55f38e453c93a6722f5c509150a07dbe4052271f
Author: Clément Foucault
Date:   Tue Jan 7 15:18:40 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB55f38e453c93a6722f5c509150a07dbe4052271f

GPencil: Refactor: Edit Mode: Add support for minor features

Add support for stroke color, vertex opacity and show stroke endpoints.

===

M   source/blender/draw/engines/overlay/overlay_gpencil.c
M   source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
M   source/blender/draw/intern/draw_cache_impl_gpencil.c

===

diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c 
b/source/blender/draw/engines/overlay/overlay_gpencil.c
index 27ab937dd7f..2c56d3ba7dd 100644
--- a/source/blender/draw/engines/overlay/overlay_gpencil.c
+++ b/source/blender/draw/engines/overlay/overlay_gpencil.c
@@ -79,6 +79,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   const bool show_multi_edit_lines = do_multiedit &&
  (v3d->gp_flag & 
V3D_GP_SHOW_MULTIEDIT_LINES) != 0;
 
+  const bool show_lines = (v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES);
   const bool hide_lines = GPENCIL_VERTEX_MODE(gpd) && use_vertex_mask && 
!show_multi_edit_lines;
 
   const bool is_weight_paint = (gpd) && (gpd->flag & 
GP_DATA_STROKE_WEIGHTMODE);
@@ -104,21 +105,24 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
   }
 
   {
-DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS_EQUAL;
+DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS_EQUAL |
+ DRW_STATE_BLEND_ALPHA;
 DRW_PASS_CREATE(psl->edit_gpencil_ps, state | pd->clipping_state);
 
+if (show_lines && !hide_lines) {
+  sh = OVERLAY_shader_edit_gpencil_wire();
+  pd->edit_gpencil_wires_grp = grp = DRW_shgroup_create(sh, 
psl->edit_gpencil_ps);
+  DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
+  DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", 
show_multi_edit_lines);
+  DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", 
v3d->vertex_opacity);
+}
+
 if (show_points) {
   sh = OVERLAY_shader_edit_gpencil_point();
   pd->edit_gpencil_points_grp = grp = DRW_shgroup_create(sh, 
psl->edit_gpencil_ps);
   DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
   DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", do_multiedit);
-}
-
-if (!hide_lines) {
-  sh = OVERLAY_shader_edit_gpencil_wire();
-  pd->edit_gpencil_wires_grp = grp = DRW_shgroup_create(sh, 
psl->edit_gpencil_ps);
-  DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
-  DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", 
show_multi_edit_lines);
+  DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", 
v3d->vertex_opacity);
 }
   }
 }
@@ -126,15 +130,27 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata)
 static void OVERLAY_edit_gpencil_cache_populate(OVERLAY_Data *vedata, Object 
*ob)
 {
   OVERLAY_PrivateData *pd = vedata->stl->pd;
+  bGPdata *gpd = (bGPdata *)ob->data;
+  if (gpd == NULL) {
+return;
+  }
 
   if (pd->edit_gpencil_wires_grp) {
+DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->edit_gpencil_wires_grp);
+DRW_shgroup_uniform_vec4_copy(grp, "gpEditColor", gpd->line_color);
+
 struct GPUBatch *geom = DRW_cache_gpencil_edit_lines_get(ob, pd->cfra);
 DRW_shgroup_call_no_cull(pd->edit_gpencil_wires_grp, geom, ob);
   }
 
   if (pd->edit_gpencil_points_grp) {
+const bool show_direction = (gpd->flag & GP_DATA_SHOW_DIRECTION) != 0;
+
+DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->edit_gpencil_points_grp);
+DRW_shgroup_uniform_float_copy(grp, "doStrokeEndpoints", show_direction);
+
 struct GPUBatch *geom = DRW_cache_gpencil_edit_points_get(ob, pd->cfra);
-DRW_shgroup_call_no_cull(pd->edit_gpencil_points_grp, geom, ob);
+DRW_shgroup_call_no_cull(grp, geom, ob);
   }
 }
 
diff --git a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl 
b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
index 9b690090fd0..542db778e46 100644
--- a/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl
@@ -1,6 +1,9 @@
 
 uniform float normalSize;
 uniform bool doMultiframe;
+uniform bool doStrokeEndpoints;
+uniform float gpEditOpacity;
+uniform vec4 gpEditColor;
 
 in vec3 pos;
 in float ma;
@@ -17,6 +20,14 @@ void discard_vert()
 #define GP_EDIT_POINT_SELECTED (1u << 0u)
 #define GP_EDIT_STROKE_SELECTED (1u << 1u)
 #define GP_EDIT_MULTIFRAME (1u << 2u)
+#define GP_EDIT_STROKE_START (1u << 3u)
+#define GP_EDIT_STROKE_END (1u << 4u)
+
+#ifdef USE_POINTS
+#  define colorUnselect colorGpencilVertex
+#else
+#  define 

[Bf-blender-cvs] [d333b0c6cb3] greasepencil-refactor: GPencil: Refactor: Disable GPencil Outline in edit mode

2020-01-07 Thread Clément Foucault
Commit: d333b0c6cb3f45f9fe75ab424b5de3eedfbf9214
Author: Clément Foucault
Date:   Tue Jan 7 12:48:24 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBd333b0c6cb3f45f9fe75ab424b5de3eedfbf9214

GPencil: Refactor: Disable GPencil Outline in edit mode

===

M   source/blender/draw/engines/overlay/overlay_outline.c

===

diff --git a/source/blender/draw/engines/overlay/overlay_outline.c 
b/source/blender/draw/engines/overlay/overlay_outline.c
index 63e366082c4..83385239ba7 100644
--- a/source/blender/draw/engines/overlay/overlay_outline.c
+++ b/source/blender/draw/engines/overlay/overlay_outline.c
@@ -186,6 +186,12 @@ static void OVERLAY_outline_gpencil(OVERLAY_PrivateData 
*pd, Object *ob)
   if (G.debug_value != 50) {
 return;
   }
+  /* No outlines in edit mode. */
+  bGPdata *gpd = (bGPdata *)ob->data;
+  if (gpd && GPENCIL_ANY_MODE(gpd)) {
+return;
+  }
+
   iterData iter = {
   .ob = ob,
   .stroke_grp = pd->outlines_gpencil_grp,

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


[Bf-blender-cvs] [fb514173709] greasepencil-refactor: GPencil: Refactor: Move vertex shader logic to gpencil_common_lib.glsl

2020-01-07 Thread Clément Foucault
Commit: fb514173709a57af02b44f7e0bcce240a7e2663c
Author: Clément Foucault
Date:   Mon Jan 6 18:31:17 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBfb514173709a57af02b44f7e0bcce240a7e2663c

GPencil: Refactor: Move vertex shader logic to gpencil_common_lib.glsl

This is to be able to reuse the code in other engines/shaders.

===

M   source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
M   source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl
M   source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl

===

diff --git 
a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index 089442ed666..dd6716284b0 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -133,4 +133,393 @@ void blend_mode_output(
   frag_revealage = vec4(0.0);
   break;
   }
-}
\ No newline at end of file
+}
+
+#ifdef GPU_VERTEX_SHADER
+#  define IN_OUT out
+#else
+#  define IN_OUT in
+#endif
+
+/* Shader interface. */
+IN_OUT vec4 finalColorMul;
+IN_OUT vec4 finalColorAdd;
+IN_OUT vec3 finalPos;
+IN_OUT vec2 finalUvs;
+noperspective IN_OUT float strokeThickness;
+flat IN_OUT vec2 strokePt1;
+flat IN_OUT vec2 strokePt2;
+flat IN_OUT int matFlag;
+flat IN_OUT float depth;
+
+#ifdef GPU_FRAGMENT_SHADER
+
+float stroke_round_cap_mask(vec2 p1, vec2 p2, float thickness)
+{
+  /* We create our own uv space to avoid issues with triangulation and linear
+   * interpolation artifacts. */
+  vec2 line = p2.xy - p1.xy;
+  vec2 pos = gl_FragCoord.xy - p1.xy;
+  float line_len = length(line);
+  float half_line_len = line_len * 0.5;
+  /* Normalize */
+  line = (line_len > 0.0) ? (line / line_len) : vec2(1.0, 0.0);
+  /* Create a uv space that englobe the whole segment into a capsule. */
+  vec2 uv_end;
+  uv_end.x = max(abs(dot(line, pos) - half_line_len) - half_line_len, 0.0);
+  uv_end.y = dot(vec2(-line.y, line.x), pos);
+  /* Divide by stroke radius. */
+  uv_end /= thickness;
+
+  return (dot(uv_end, uv_end) > 0.25) ? 0.0 : 1.0;
+}
+
+#endif
+
+#ifdef GPU_VERTEX_SHADER
+
+/* TODO UBO */
+uniform vec2 sizeViewport;
+uniform vec2 sizeViewportInv;
+
+/* Per Object */
+uniform bool strokeOrder3d;
+uniform float thicknessScale;
+uniform float thicknessWorldScale;
+#  define thicknessIsScreenSpace (thicknessWorldScale < 0.0)
+
+/* Per Layer */
+uniform float thicknessOffset;
+uniform float vertexColorOpacity;
+uniform vec4 layerTint;
+uniform float layerOpacity; /* Used for onion skin. */
+uniform float strokeIndexOffset = 0.0;
+
+in vec4 ma;
+in vec4 ma1;
+in vec4 ma2;
+in vec4 ma3;
+#  define strength1 ma1.y
+#  define strength2 ma2.y
+#  define stroke_id1 ma1.z
+#  define point_id1 ma1.w
+/* Position contains thickness in 4th component. */
+in vec4 pos;  /* Prev adj vert */
+in vec4 pos1; /* Current edge */
+in vec4 pos2; /* Current edge */
+in vec4 pos3; /* Next adj vert */
+#  define thickness1 pos1.w
+#  define thickness2 pos2.w
+/* xy is UV for fills, z is U of stroke, w is cosine of UV angle with sign of 
sine.  */
+in vec4 uv1;
+in vec4 uv2;
+
+in vec4 col1;
+in vec4 col2;
+
+void discard_vert()
+{
+  /* We set the vertex at the camera origin to generate 0 fragments. */
+  gl_Position = vec4(0.0, 0.0, -3e36, 0.0);
+}
+
+vec2 project_to_screenspace(vec4 v)
+{
+  return ((v.xy / v.w) * 0.5 + 0.5) * sizeViewport;
+}
+
+vec2 rotate_90deg(vec2 v)
+{
+  /* Counter Clock-Wise. */
+  return vec2(-v.y, v.x);
+}
+
+mat4 model_matrix_get()
+{
+  return ModelMatrix;
+}
+
+vec3 transform_point(mat4 m, vec3 v)
+{
+  return (m * vec4(v, 1.0)).xyz;
+}
+
+vec2 safe_normalize(vec2 v)
+{
+  float len_sqr = dot(v, v);
+  if (len_sqr > 0.0) {
+return v / sqrt(len_sqr);
+  }
+  else {
+return vec2(0.0);
+  }
+}
+
+vec2 safe_normalize_len(vec2 v, out float len)
+{
+  len = sqrt(dot(v, v));
+  if (len > 0.0) {
+return v / len;
+  }
+  else {
+return vec2(0.0);
+  }
+}
+
+float stroke_thickness_modulate(float thickness)
+{
+  /* Modify stroke thickness by object and layer factors.-*/
+  thickness *= thicknessScale;
+  thickness += thicknessOffset;
+  thickness = max(1.0, thickness);
+
+  if (thicknessIsScreenSpace) {
+/* Multiply offset by view Z so that offset is constant in screenspace.
+ * (e.i: does not change with the distance to camera) */
+thickness *= gl_Position.w;
+  }
+  else {
+/* World space point size. */
+thickness *= thicknessWorldScale * ProjectionMatrix[1][1] * sizeViewport.y;
+  }
+  return thickness;
+}
+
+#  ifdef GP_MATERIAL_BUFFER_LEN
+void color_output(vec4 stroke_col, vec4 vert_col, float vert_strength, float 
mix_tex)
+{
+  /* Mix stroke with other colors. */
+  vec4 mixed_col = stroke_col;
+  mixed_col.rgb = 

[Bf-blender-cvs] [b83692e11a3] greasepencil-refactor: GPencil: Refactor: Replace Stroke Miter break by rounded corners

2020-01-07 Thread Clément Foucault
Commit: b83692e11a3e960692af2662d7b50384b7bd7973
Author: Clément Foucault
Date:   Mon Jan 6 18:39:32 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBb83692e11a3e960692af2662d7b50384b7bd7973

GPencil: Refactor: Replace Stroke Miter break by rounded corners

Also fix stroke ends being twice too long.

===

M   source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl

===

diff --git 
a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
index dd6716284b0..08319ecd405 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
@@ -403,7 +403,8 @@ void stroke_vertex()
 float miter_dot = dot(miter_tan, line_adj);
 /* Break corners after a certain angle to avoid really thick corners. */
 const float miter_limit = 0.5; /* cos(60°) */
-miter_tan = (miter_dot < miter_limit) ? line : (miter_tan / miter_dot);
+bool miter_break = (miter_dot < miter_limit);
+miter_tan = (miter_break) ? line : (miter_tan / miter_dot);
 
 vec2 miter = rotate_90deg(miter_tan);
 
@@ -412,13 +413,13 @@ void stroke_vertex()
 strokeThickness = thickness / gl_Position.w;
 
 /* Reminder: we packed the cap flag into the sign of stength and thickness 
sign. */
-bool is_stroke_start = (ma.x == -1.0 && x == -1.0 && strength1 > 0.0);
-bool is_stroke_end = (ma3.x == -1.0 && x == 1.0 && thickness1 > 0.0);
+bool is_stroke_start = (ma.x == -1.0 && x == -1.0 && strength1 > 0.0) || 
miter_break;
+bool is_stroke_end = (ma3.x == -1.0 && x == 1.0 && thickness1 > 0.0) || 
miter_break;
 
 vec2 screen_ofs = miter * y;
 
 if (is_stroke_start || is_stroke_end) {
-  screen_ofs += line * x * 2.0;
+  screen_ofs += line * x;
 }
 
 gl_Position.xy += screen_ofs * sizeViewportInv.xy * thickness;

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


[Bf-blender-cvs] [75fc2bdf02e] greasepencil-refactor: GPencil: Refactor: Fix old implementation crashing on startup

2020-01-07 Thread Clément Foucault
Commit: 75fc2bdf02eed57328f83a5f59673cb5584f822e
Author: Clément Foucault
Date:   Mon Jan 6 19:06:15 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB75fc2bdf02eed57328f83a5f59673cb5584f822e

GPencil: Refactor: Fix old implementation crashing on startup

===

M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/overlay/overlay_outline.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 0114d6e059d..04de3d9634a 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -494,12 +494,6 @@ static void gpencil_batch_cache_clear(GpencilBatchCache 
*cache)
   MEM_SAFE_FREE(cache->grp_cache);
   cache->grp_size = 0;
   cache->grp_used = 0;
-
-  /* New code */
-  GPU_BATCH_DISCARD_SAFE(cache->fill_batch);
-  GPU_BATCH_DISCARD_SAFE(cache->stroke_batch);
-  GPU_VERTBUF_DISCARD_SAFE(cache->vbo);
-  GPU_INDEXBUF_DISCARD_SAFE(cache->ibo);
 }
 
 /* get cache */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 041003158e0..1e50d42faa1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -656,12 +656,6 @@ typedef struct GpencilBatchCache {
   int grp_size;
   /** Array of cache elements */
   struct GpencilBatchGroup *grp_cache;
-
-  /* Refactor */
-  GPUVertBuf *vbo;
-  GPUIndexBuf *ibo;
-  GPUBatch *stroke_batch;
-  GPUBatch *fill_batch;
 } GpencilBatchCache;
 
 /* general drawing functions */
diff --git a/source/blender/draw/engines/overlay/overlay_outline.c 
b/source/blender/draw/engines/overlay/overlay_outline.c
index 12ba0fbb4b9..63e366082c4 100644
--- a/source/blender/draw/engines/overlay/overlay_outline.c
+++ b/source/blender/draw/engines/overlay/overlay_outline.c
@@ -182,6 +182,10 @@ static void gp_stroke_cache_populate(bGPDlayer 
*UNUSED(gpl),
 
 static void OVERLAY_outline_gpencil(OVERLAY_PrivateData *pd, Object *ob)
 {
+  /* REFACTOR(fclem) remove */
+  if (G.debug_value != 50) {
+return;
+  }
   iterData iter = {
   .ob = ob,
   .stroke_grp = pd->outlines_gpencil_grp,

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


[Bf-blender-cvs] [a1285eb4d80] greasepencil-refactor: GPencil: Refactor: Edit Mode support.

2020-01-07 Thread Clément Foucault
Commit: a1285eb4d80429b08ef50a34c946b47c9146e64e
Author: Clément Foucault
Date:   Mon Jan 6 20:18:47 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBa1285eb4d80429b08ef50a34c946b47c9146e64e

GPencil: Refactor: Edit Mode support.

===

M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_engine.c
M   source/blender/draw/engines/overlay/overlay_extra.c
A   source/blender/draw/engines/overlay/overlay_gpencil.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/edit_gpencil_vert.glsl
M   source/blender/draw/intern/draw_cache.h
M   source/blender/draw/intern/draw_cache_impl_gpencil.c
M   source/blender/draw/intern/draw_common.c
M   source/blender/draw/intern/draw_common.h
M   source/blender/draw/intern/shaders/common_globals_lib.glsl

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 5c2cc1ce8a6..46211eefe87 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -131,6 +131,7 @@ set(SRC
   engines/overlay/overlay_engine.c
   engines/overlay/overlay_extra.c
   engines/overlay/overlay_facing.c
+  engines/overlay/overlay_gpencil.c
   engines/overlay/overlay_grid.c
   engines/overlay/overlay_image.c
   engines/overlay/overlay_lattice.c
@@ -345,6 +346,7 @@ 
data_to_c_simple(engines/overlay/shaders/edit_curve_handle_geom.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_curve_handle_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_curve_point_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_curve_wire_vert.glsl SRC)
+data_to_c_simple(engines/overlay/shaders/edit_gpencil_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_lattice_point_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_lattice_wire_vert.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/edit_mesh_common_lib.glsl SRC)
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c 
b/source/blender/draw/engines/overlay/overlay_engine.c
index dab307dc6ee..ac8af115500 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -135,12 +135,14 @@ static void OVERLAY_cache_init(void *vedata)
 case CTX_MODE_SCULPT:
   OVERLAY_sculpt_cache_init(vedata);
   break;
-case CTX_MODE_OBJECT:
-case CTX_MODE_PAINT_GPENCIL:
 case CTX_MODE_EDIT_GPENCIL:
+case CTX_MODE_PAINT_GPENCIL:
 case CTX_MODE_SCULPT_GPENCIL:
-case CTX_MODE_WEIGHT_GPENCIL:
 case CTX_MODE_VERTEX_GPENCIL:
+case CTX_MODE_WEIGHT_GPENCIL:
+  OVERLAY_edit_gpencil_cache_init(vedata);
+  break;
+case CTX_MODE_OBJECT:
   break;
 default:
   BLI_assert(!"Draw mode invalid");
@@ -448,6 +450,13 @@ static void OVERLAY_draw_scene(void *vedata)
 case CTX_MODE_SCULPT:
   OVERLAY_sculpt_draw(vedata);
   break;
+case CTX_MODE_EDIT_GPENCIL:
+case CTX_MODE_PAINT_GPENCIL:
+case CTX_MODE_SCULPT_GPENCIL:
+case CTX_MODE_VERTEX_GPENCIL:
+case CTX_MODE_WEIGHT_GPENCIL:
+  OVERLAY_edit_gpencil_draw(vedata);
+  break;
 default:
   break;
   }
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c 
b/source/blender/draw/engines/overlay/overlay_extra.c
index 90ddb9f7476..c821b301e4d 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -38,7 +38,7 @@
 
 #include "DNA_camera_types.h"
 #include "DNA_constraint_types.h"
-#include "DNA_gpencil_types.h"
+#include "DNA_curve_types.h"
 #include "DNA_lightprobe_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meta_types.h"
@@ -1318,87 +1318,6 @@ static void 
OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb,
 
 /** \} */
 
-/*  */
-/** \name GPencil.
- * \{ */
-
-static void OVERLAY_gpencil_color_names(Object *ob)
-{
-  if (ob->mode != OB_MODE_EDIT_GPENCIL) {
-return;
-  }
-
-  bGPdata *gpd = (bGPdata *)ob->data;
-  if (gpd == NULL) {
-return;
-  }
-
-  const DRWContextState *draw_ctx = DRW_context_state_get();
-  ViewLayer *view_layer = draw_ctx->view_layer;
-  int theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
-  uchar color[4];
-  UI_GetThemeColor4ubv(theme_id, color);
-  struct DRWTextStore *dt = DRW_text_cache_ensure();
-
-  for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
-if (gpl->flag & GP_LAYER_HIDE) {
-  continue;
-}
-bGPDframe *gpf = gpl->actframe;
-if (gpf == NULL) {
-  continue;
-}
-for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
-  Material *ma = 

[Bf-blender-cvs] [981c49ff4c2] greasepencil-refactor: GPencil: Refactor: Add outline overlay

2020-01-07 Thread Clément Foucault
Commit: 981c49ff4c250625ca688a1b5fff788b2143e0db
Author: Clément Foucault
Date:   Mon Jan 6 18:33:30 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB981c49ff4c250625ca688a1b5fff788b2143e0db

GPencil: Refactor: Add outline overlay

This does not work correctly on square & dot strokes.

Also another issue is the depth blending. We need to fix the depth of
the outline geometry to match the 2D projection we do in the gpencil engine.

===

M   source/blender/draw/engines/overlay/overlay_engine.c
M   source/blender/draw/engines/overlay/overlay_outline.c
M   source/blender/draw/engines/overlay/overlay_private.h
M   source/blender/draw/engines/overlay/overlay_shader.c
M   source/blender/draw/engines/overlay/shaders/outline_prepass_frag.glsl
M   source/blender/draw/engines/overlay/shaders/outline_prepass_vert.glsl

===

diff --git a/source/blender/draw/engines/overlay/overlay_engine.c 
b/source/blender/draw/engines/overlay/overlay_engine.c
index 38ab3d348ea..dab307dc6ee 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -25,6 +25,8 @@
 #include "DRW_engine.h"
 #include "DRW_render.h"
 
+#include "DEG_depsgraph_query.h"
+
 #include "ED_view3d.h"
 
 #include "BKE_object.h"
@@ -78,6 +80,7 @@ static void OVERLAY_engine_init(void *vedata)
   pd->xray_enabled = XRAY_ACTIVE(v3d);
   pd->xray_enabled_and_not_wire = pd->xray_enabled && v3d->shading.type > 
OB_WIRE;
   pd->clear_in_front = (v3d->shading.type != OB_SOLID);
+  pd->cfra = DEG_get_ctime(draw_ctx->depsgraph);
 
   OVERLAY_antialiasing_init(vedata);
 
@@ -184,6 +187,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
   OVERLAY_PrivateData *pd = data->stl->pd;
   const DRWContextState *draw_ctx = DRW_context_state_get();
   const bool is_select = DRW_state_is_select();
+  const bool is_gpencil = ob->type == OB_GPENCIL;
   const bool renderable = DRW_object_is_renderable(ob);
   const bool in_pose_mode = ob->type == OB_ARMATURE && 
OVERLAY_armature_is_pose_mode(ob, draw_ctx);
   const bool in_edit_mode = BKE_object_is_in_editmode(ob);
@@ -197,8 +201,8 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
   const bool draw_bones = (pd->overlay.flag & V3D_OVERLAY_HIDE_BONES) == 0;
   const bool draw_wires = draw_surface && has_surface &&
   (pd->wireframe_mode || !pd->hide_overlays);
-  const bool draw_outlines = !in_edit_mode && !in_paint_mode && renderable && 
has_surface &&
- (pd->v3d_flag & V3D_SELECT_OUTLINE) &&
+  const bool draw_outlines = !in_edit_mode && !in_paint_mode && renderable &&
+ (has_surface || is_gpencil) && (pd->v3d_flag & 
V3D_SELECT_OUTLINE) &&
  (ob->base_flag & BASE_SELECTED);
   const bool draw_bone_selection = (ob->type == OB_MESH) && 
pd->armature.do_pose_fade_geom &&
!is_select;
diff --git a/source/blender/draw/engines/overlay/overlay_outline.c 
b/source/blender/draw/engines/overlay/overlay_outline.c
index 63738b3c214..12ba0fbb4b9 100644
--- a/source/blender/draw/engines/overlay/overlay_outline.c
+++ b/source/blender/draw/engines/overlay/overlay_outline.c
@@ -23,8 +23,10 @@
 #include "DRW_render.h"
 
 #include "BKE_global.h"
+#include "BKE_gpencil.h"
 
-#include "DNA_lightprobe_types.h"
+// #include "DNA_lightprobe_types.h"
+#include "DNA_gpencil_types.h"
 
 #include "UI_resources.h"
 
@@ -79,6 +81,11 @@ void OVERLAY_outline_cache_init(OVERLAY_Data *vedata)
 
 pd->outlines_grp = grp = DRW_shgroup_create(sh_geom, 
psl->outlines_prepass_ps);
 DRW_shgroup_uniform_bool_copy(grp, "isTransform", (G.moving & 
G_TRANSFORM_OBJ) != 0);
+
+GPUShader *sh_gpencil = OVERLAY_shader_outline_prepass_gpencil();
+
+pd->outlines_gpencil_grp = grp = DRW_shgroup_create(sh_gpencil, 
psl->outlines_prepass_ps);
+DRW_shgroup_uniform_bool_copy(grp, "isTransform", (G.moving & 
G_TRANSFORM_OBJ) != 0);
   }
 
   /* outlines_prepass_ps is still needed for selection of probes. */
@@ -107,6 +114,85 @@ void OVERLAY_outline_cache_init(OVERLAY_Data *vedata)
   }
 }
 
+typedef struct iterData {
+  Object *ob;
+  DRWShadingGroup *stroke_grp;
+  DRWShadingGroup *fill_grp;
+  int cfra;
+} iterData;
+
+static void gp_layer_cache_populate(bGPDlayer *gpl,
+bGPDframe *UNUSED(gpf),
+bGPDstroke *UNUSED(gps),
+void *thunk)
+{
+  iterData *iter = (iterData *)thunk;
+  bGPdata *gpd = (bGPdata *)iter->ob->data;
+
+  const bool is_screenspace = (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS) != 0;
+
+  float object_scale = mat4_to_scale(iter->ob->obmat);
+  /* Negate thickness sign to tag that strokes are in screen space.
+   * Convert to world units 

[Bf-blender-cvs] [41cef139adc] greasepencil-refactor: GPencil: Refactor: Move batch cache functions to DRW module

2020-01-07 Thread Clément Foucault
Commit: 41cef139adc7ad61252930f355ada9f814d50a28
Author: Clément Foucault
Date:   Mon Jan 6 11:42:36 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB41cef139adc7ad61252930f355ada9f814d50a28

GPencil: Refactor: Move batch cache functions to DRW module

This is in preparation of drawing the overlays.

===

M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/intern/draw_cache.c
M   source/blender/draw/intern/draw_cache.h
A   source/blender/draw/intern/draw_cache_impl_gpencil.c

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 3434456c685..5c2cc1ce8a6 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -52,6 +52,7 @@ set(SRC
   intern/draw_cache_extract_mesh.c
   intern/draw_cache_impl_curve.c
   intern/draw_cache_impl_displist.c
+  intern/draw_cache_impl_gpencil.c
   intern/draw_cache_impl_lattice.c
   intern/draw_cache_impl_mesh.c
   intern/draw_cache_impl_metaball.c
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index b7c3f37df8c..0114d6e059d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -517,38 +517,4 @@ GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int 
cfra)
   else {
 return cache;
   }
-}
-
-/* set cache as dirty */
-void DRW_gpencil_batch_cache_dirty_tag(bGPdata *gpd)
-{
-  gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
-}
-
-/* free batch cache */
-void DRW_gpencil_batch_cache_free(bGPdata *UNUSED(gpd))
-{
-  return;
-}
-
-/* wrapper to clear cache */
-void DRW_gpencil_freecache(struct Object *ob)
-{
-  if ((ob) && (ob->type == OB_GPENCIL)) {
-gpencil_batch_cache_clear(ob->runtime.gpencil_cache);
-MEM_SAFE_FREE(ob->runtime.gpencil_cache);
-bGPdata *gpd = (bGPdata *)ob->data;
-if (gpd) {
-  gpd->flag |= GP_DATA_CACHE_IS_DIRTY;
-}
-  }
-
-  /* clear all frames evaluated data */
-  for (int i = 0; i < ob->runtime.gpencil_tot_layers; i++) {
-bGPDframe *gpf_eval = >runtime.gpencil_evaluated_frames[i];
-BKE_gpencil_free_frame_runtime_data(gpf_eval);
-  }
-
-  ob->runtime.gpencil_tot_layers = 0;
-  MEM_SAFE_FREE(ob->runtime.gpencil_evaluated_frames);
-}
+}
\ No newline at end of file
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index cb2ae1db374..d90f2b20980 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -43,314 +43,6 @@
 
 #include "gpencil_engine.h"
 
-/*  */
-/** \name Dummy vbos
- *
- * We need a dummy vbo containing the vertex count to draw instances ranges.
- *
- * \{ */
-
-static GPUVertBuf *gpencil_dummy_buffer_get(void)
-{
-  if (en_data.quad == NULL) {
-GPUVertFormat format = {0};
-GPU_vertformat_attr_add(, "dummy", GPU_COMP_U8, 1, GPU_FETCH_INT);
-en_data.quad = GPU_vertbuf_create_with_format();
-GPU_vertbuf_data_alloc(en_data.quad, 4);
-  }
-  return en_data.quad;
-}
-
-/** \} */
-
-/*  */
-/** \name Vertex Formats.
- * \{ */
-
-/* MUST match the format below. */
-typedef struct gpStrokeVert {
-  /** Mat is float because we need to pack other float attribs with it. */
-  float mat, strength, stroke_id, point_id;
-  /** Position and thickness packed in the same attribute. */
-  float pos[3], thickness;
-  float col[4];
-  float uv_fill[2], u_stroke, v_rot;
-} gpStrokeVert;
-
-static GPUVertFormat *gpencil_stroke_format(void)
-{
-  static GPUVertFormat format = {0};
-  if (format.attr_len == 0) {
-GPU_vertformat_attr_add(, "ma", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
-GPU_vertformat_attr_add(, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
-GPU_vertformat_attr_add(, "col", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
-GPU_vertformat_attr_add(, "uv", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
-/* IMPORTANT: This means having only 4 attributes to fit into opengl limit 
of 16 attrib. */
-GPU_vertformat_multiload_enable(, 4);
-  }
-  return 
-}
-
-/** \} */
-
-/*  */
-/** \name Vertex Buffers.
- * \{ */
-
-typedef struct gpIterData {
-  bGPdata *gpd;
-  gpStrokeVert *verts;
-  GPUIndexBufBuilder ibo;
-  int vert_len;
-  int tri_len;
-} gpIterData;
-
-static int 

[Bf-blender-cvs] [a0caa9e6b17] greasepencil-refactor: Cleanup: GPencil: Move GP_MATERIAL_BUFFER_LEN define to a common place

2020-01-07 Thread Clément Foucault
Commit: a0caa9e6b17f843449a3d9be14dfa3c663001a75
Author: Clément Foucault
Date:   Mon Jan 6 11:34:20 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBa0caa9e6b17f843449a3d9be14dfa3c663001a75

Cleanup: GPencil: Move GP_MATERIAL_BUFFER_LEN define to a common place

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_draw_data.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/gpencil/gpencil_shader.c
M   source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
M   source/blender/makesdna/DNA_gpencil_types.h

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 84ae3f02137..cb2ae1db374 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -129,7 +129,7 @@ static void gpencil_buffer_add_point(
   vert->v_rot = cosf(pt->uv_rot) * signf(pt->uv_rot);
   vert->thickness = max_ff(0.0f, gps->thickness * pt->pressure) * (round_cap1 
? 1.0 : -1.0);
   /* Tag endpoint material to -1 so they get discarded by vertex shader. */
-  vert->mat = (is_endpoint) ? -1 : (gps->mat_nr % GPENCIL_MATERIAL_BUFFER_LEN);
+  vert->mat = (is_endpoint) ? -1 : (gps->mat_nr % GP_MATERIAL_BUFFER_LEN);
 }
 
 static void gpencil_buffer_add_stroke(gpStrokeVert *verts, const bGPDstroke 
*gps)
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
index c22b43716f9..12941fab42a 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
@@ -115,7 +115,7 @@ GPENCIL_MaterialPool 
*gpencil_material_pool_create(GPENCIL_PrivateData *pd, Obje
 
   GPENCIL_MaterialPool *pool = matpool;
   for (int i = 0; i < ob->totcol; i++) {
-int mat_id = (i % GPENCIL_MATERIAL_BUFFER_LEN);
+int mat_id = (i % GP_MATERIAL_BUFFER_LEN);
 if ((i > 0) && (mat_id == 0)) {
   pool->next = gpencil_material_pool_add(pd);
   pool = pool->next;
@@ -216,11 +216,11 @@ void gpencil_material_resources_get(GPENCIL_MaterialPool 
*first_pool,
 GPUUniformBuffer **r_ubo_mat)
 {
   GPENCIL_MaterialPool *matpool = first_pool;
-  int pool_id = mat_id / GPENCIL_MATERIAL_BUFFER_LEN;
+  int pool_id = mat_id / GP_MATERIAL_BUFFER_LEN;
   for (int i = 0; i < pool_id; i++) {
 matpool = matpool->next;
   }
-  mat_id = mat_id % GPENCIL_MATERIAL_BUFFER_LEN;
+  mat_id = mat_id % GP_MATERIAL_BUFFER_LEN;
   *r_ubo_mat = matpool->ubo;
   if (r_tex_fill) {
 *r_tex_fill = matpool->tex_fill[mat_id];
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index e410ea6cc0f..8d4d835dfe8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -23,6 +23,8 @@
 #ifndef __GPENCIL_ENGINE_H__
 #define __GPENCIL_ENGINE_H__
 
+#include "DNA_gpencil_types.h"
+
 #include "GPU_batch.h"
 
 extern DrawEngineType draw_engine_gpencil_type;
@@ -56,10 +58,6 @@ struct GPUVertFormat;
 
 #define GP_IS_CAMERAVIEW ((rv3d != NULL) && (rv3d->persp == RV3D_CAMOB && 
v3d->camera))
 
-/* TODO(fclem) grow this number back when grouping different objects' material 
together
- * is implemented. */
-#define GPENCIL_MATERIAL_BUFFER_LEN 16
-
 /* UBO structure. Watch out for padding. Must match GLSL declaration. */
 typedef struct gpMaterial {
   float stroke_color[4];
@@ -169,12 +167,12 @@ typedef struct GPENCIL_MaterialPool {
   /* Linklist. */
   struct GPENCIL_MaterialPool *next;
   /* GPU representatin of materials. */
-  gpMaterial mat_data[GPENCIL_MATERIAL_BUFFER_LEN];
+  gpMaterial mat_data[GP_MATERIAL_BUFFER_LEN];
   /* Matching ubo. */
   struct GPUUniformBuffer *ubo;
   /* Texture per material. NULL means none. */
-  struct GPUTexture *tex_fill[GPENCIL_MATERIAL_BUFFER_LEN];
-  struct GPUTexture *tex_stroke[GPENCIL_MATERIAL_BUFFER_LEN];
+  struct GPUTexture *tex_fill[GP_MATERIAL_BUFFER_LEN];
+  struct GPUTexture *tex_stroke[GP_MATERIAL_BUFFER_LEN];
 } GPENCIL_MaterialPool;
 
 typedef struct GPENCIL_LightPool {
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c 
b/source/blender/draw/engines/gpencil/gpencil_shader.c
index 802498ebf26..7f11de84f5c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader.c
@@ -102,7 +102,7 @@ struct GPUShader 
*GPENCIL_shader_geometry_get(GPENCIL_e_data *e_data)
 },
 .defs =
 (const char *[]){
-"#define GPENCIL_MATERIAL_BUFFER_LEN " 

[Bf-blender-cvs] [93c9347e9c4] greasepencil-refactor: GPencil: Refactor: Use drawcall matrices instead of custom one

2020-01-07 Thread Clément Foucault
Commit: 93c9347e9c4aa23ff8f680307ce999cd2146e0d6
Author: Clément Foucault
Date:   Mon Jan 6 14:15:54 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB93c9347e9c4aa23ff8f680307ce999cd2146e0d6

GPencil: Refactor: Use drawcall matrices instead of custom one

===

M   source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_shader.c
M   source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
M   source/blender/draw/engines/overlay/overlay_motion_path.c
M   source/blender/draw/intern/DRW_render.h
M   source/blender/draw/intern/draw_manager.h
M   source/blender/draw/intern/draw_manager_data.c
M   source/blender/draw/intern/draw_manager_exec.c
M   source/blender/draw/intern/shaders/common_view_lib.glsl
M   source/blender/gpu/GPU_shader_interface.h
M   source/blender/gpu/intern/gpu_shader_interface.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index fe1ef42c120..b71dc1b43a7 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1789,7 +1789,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data 
*e_data,
 }
 
 if ((do_onion) || (elm->onion == false)) {
-  DRW_shgroup_call_range(shgrp, cache->b_stroke.batch, start_stroke, 
len);
+  DRW_shgroup_call_range(shgrp, NULL, cache->b_stroke.batch, 
start_stroke, len);
 }
 stl->storage->shgroup_id++;
 start_stroke = elm->vertex_idx;
@@ -1818,7 +1818,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data 
*e_data,
 DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | 
DRW_STATE_STENCIL_NEQUAL);
 
 if ((do_onion) || (elm->onion == false)) {
-  DRW_shgroup_call_range(shgrp, cache->b_point.batch, start_point, 
len);
+  DRW_shgroup_call_range(shgrp, NULL, cache->b_point.batch, 
start_point, len);
 }
 stl->storage->shgroup_id++;
 start_point = elm->vertex_idx;
@@ -1844,7 +1844,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data 
*e_data,
 DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | 
DRW_STATE_STENCIL_NEQUAL);
 
 if ((do_onion) || (elm->onion == false)) {
-  DRW_shgroup_call_range(shgrp, cache->b_fill.batch, start_fill, len);
+  DRW_shgroup_call_range(shgrp, NULL, cache->b_fill.batch, start_fill, 
len);
 }
 stl->storage->shgroup_id++;
 start_fill = elm->vertex_idx;
@@ -1858,7 +1858,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data 
*e_data,
   DRW_shgroup_uniform_mat4(shgrp, "gpModelMatrix", obmat);
   /* use always the same group */
   DRW_shgroup_call_range(
-  stl->g_data->shgrps_edit_point, cache->b_edit.batch, start_edit, 
len);
+  stl->g_data->shgrps_edit_point, NULL, cache->b_edit.batch, 
start_edit, len);
 
   start_edit = elm->vertex_idx;
 }
@@ -1872,7 +1872,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data 
*e_data,
   DRW_shgroup_uniform_mat4(shgrp, "gpModelMatrix", obmat);
   /* use always the same group */
   DRW_shgroup_call_range(
-  stl->g_data->shgrps_edit_line, cache->b_edlin.batch, 
start_edlin, len);
+  stl->g_data->shgrps_edit_line, NULL, cache->b_edlin.batch, 
start_edlin, len);
 
   start_edlin = elm->vertex_idx;
 }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 059878d1cd2..699a86111cc 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -1005,10 +1005,6 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
   DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", iter->tex_stroke);
   DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", 
iter->pd->scene_depth_tx);
   DRW_shgroup_uniform_bool_copy(iter->grp, "strokeOrder3d", 
is_stroke_order_3d);
-  DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[0]", 
iter->ob->obmat[0]);
-  DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[1]", 
iter->ob->obmat[1]);
-  DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[2]", 
iter->ob->obmat[2]);
-  DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[3]", 
iter->ob->obmat[3]);
   DRW_shgroup_uniform_vec3_copy(iter->grp, "gpNormal", 
iter->tgp_ob->plane_normal);
   DRW_shgroup_uniform_vec2_copy(iter->grp, "sizeViewportInv", 
DRW_viewport_invert_size_get());
   DRW_shgroup_uniform_vec2_copy(iter->grp, "sizeViewport", 
DRW_viewport_size_get());
@@ -1089,7 +1085,7 @@ static void 

[Bf-blender-cvs] [154fa8b8536] greasepencil-refactor: GPencil: Refactor: Move iterator to BKE

2020-01-07 Thread Clément Foucault
Commit: 154fa8b85367e39aaea2ce38a47f289a5e20b4b6
Author: Clément Foucault
Date:   Mon Jan 6 11:31:10 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB154fa8b85367e39aaea2ce38a47f289a5e20b4b6

GPencil: Refactor: Move iterator to BKE

===

M   source/blender/blenkernel/BKE_gpencil.h
M   source/blender/blenkernel/intern/gpencil.c
M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h

===

diff --git a/source/blender/blenkernel/BKE_gpencil.h 
b/source/blender/blenkernel/BKE_gpencil.h
index 30cafdcc4f5..dce44a514da 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -302,6 +302,20 @@ bool BKE_gpencil_from_image(struct SpaceImage *sima,
 const float size,
 const bool mask);
 
+/* Iterator */
+/* frame & stroke are NULL if it is a layer callback. */
+typedef void (*gpIterCb)(struct bGPDlayer *layer,
+ struct bGPDframe *frame,
+ struct bGPDstroke *stroke,
+ void *thunk);
+
+void BKE_gpencil_visible_stroke_iter(struct Object *ob,
+ gpIterCb layer_cb,
+ gpIterCb stroke_cb,
+ void *thunk,
+ bool do_onion,
+ int cfra);
+
 extern void (*BKE_gpencil_batch_cache_dirty_tag_cb)(struct bGPdata *gpd);
 extern void (*BKE_gpencil_batch_cache_free_cb)(struct bGPdata *gpd);
 
diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index ab37efc1f61..823f75de3f3 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -3688,3 +3688,135 @@ bool BKE_gpencil_from_image(SpaceImage *sima, bGPDframe 
*gpf, const float size,
 
   return done;
 }
+
+/*  */
+/** \name Iterators
+ *
+ * Iterate over all visible stroke of all visible layers inside a gpObject.
+ * Also take into account onion skining.
+ *
+ * \{ */
+
+void BKE_gpencil_visible_stroke_iter(
+Object *ob, gpIterCb layer_cb, gpIterCb stroke_cb, void *thunk, bool 
do_onion, int cfra)
+{
+  bGPdata *gpd = (bGPdata *)ob->data;
+  const bool is_multiedit = GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+  const bool is_onion = do_onion && ((gpd->flag & GP_DATA_STROKE_WEIGHTMODE) 
== 0);
+
+  /* Onion skinning. */
+  const bool onion_mode_abs = (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE);
+  const bool onion_mode_sel = (gpd->onion_mode == GP_ONION_MODE_SELECTED);
+  const bool onion_loop = (gpd->onion_flag & GP_ONION_LOOP) != 0;
+  const short onion_keytype = gpd->onion_keytype;
+
+  int idx_eval = 0;
+
+  LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) {
+bGPDframe *act_gpf = gpl->actframe;
+bGPDframe *sta_gpf = act_gpf;
+bGPDframe *end_gpf = act_gpf ? act_gpf->next : NULL;
+
+if (gpl->flag & GP_LAYER_HIDE) {
+  idx_eval++;
+  continue;
+}
+
+if (is_onion && (gpl->onion_flag & GP_LAYER_ONIONSKIN)) {
+  if (act_gpf) {
+bGPDframe *last_gpf = gpl->frames.last;
+
+int frame_len = 0;
+LISTBASE_FOREACH (bGPDframe *, gpf, >frames) {
+  gpf->runtime.frameid = frame_len++;
+}
+
+LISTBASE_FOREACH (bGPDframe *, gpf, >frames) {
+  bool is_wrong_keytype = (onion_keytype > -1) && (gpf->key_type != 
onion_keytype);
+  bool is_in_range;
+  int delta = (onion_mode_abs) ? (gpf->framenum - cfra) :
+ (gpf->runtime.frameid - 
act_gpf->runtime.frameid);
+
+  if (onion_mode_sel) {
+is_in_range = (gpf->flag & GP_FRAME_SELECT) != 0;
+  }
+  else {
+is_in_range = (-delta <= gpd->gstep) && (delta <= gpd->gstep_next);
+
+if (onion_loop && !is_in_range) {
+  /* We wrap the value using the last frame and 0 as reference. */
+  /* FIXME: This might not be good for animations not starting at 
0. */
+  int shift = (onion_mode_abs) ? last_gpf->framenum : 
last_gpf->runtime.frameid;
+  delta += (delta < 0) ? (shift + 1) : -(shift + 1);
+  /* Test again with wrapped value. */
+  is_in_range = (-delta <= gpd->gstep) && (delta <= 
gpd->gstep_next);
+}
+  }
+  /* Mask frames that have wrong keytype of are not in range. */
+  gpf->runtime.onion_id = (is_wrong_keytype || !is_in_range) ? INT_MAX 
: delta;
+}
+/* Active frame is always 

[Bf-blender-cvs] [94e18b10be0] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

2020-01-07 Thread Antonio Vazquez
Commit: 94e18b10be0b5838f1cc527c19cb00b712198c05
Author: Antonio Vazquez
Date:   Tue Jan 7 14:15:31 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB94e18b10be0b5838f1cc527c19cb00b712198c05

Merge branch 'greasepencil-object' into greasepencil-refactor

===



===



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


[Bf-blender-cvs] [94d19d5ff50] master: GPencil: Fix unreported memory leak

2020-01-07 Thread Antonio Vazquez
Commit: 94d19d5ff505af0b63085ec76b85f86dcd97b127
Author: Antonio Vazquez
Date:   Tue Jan 7 14:13:37 2020 +0100
Branches: master
https://developer.blender.org/rB94d19d5ff505af0b63085ec76b85f86dcd97b127

GPencil: Fix unreported memory leak

Thanks to @dfelinto for his help

===

M   source/blender/blenkernel/intern/gpencil_modifier.c
M   source/blender/draw/engines/gpencil/gpencil_cache_utils.c

===

diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c 
b/source/blender/blenkernel/intern/gpencil_modifier.c
index fe087256d25..bc0c54ed96e 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -862,6 +862,14 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, 
Scene *scene, Object *ob)
   const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
   int cfra_eval = (int)DEG_get_ctime(depsgraph);
 
+  /* Clear any previous evaluated data. */
+  if (ob->runtime.gpencil_tot_layers > 0) {
+for (int i = 0; i < ob->runtime.gpencil_tot_layers; i++) {
+  bGPDframe *gpf_eval = >runtime.gpencil_evaluated_frames[i];
+  BKE_gpencil_free_frame_runtime_data(gpf_eval);
+}
+  }
+
   /* Create array of evaluated frames equal to number of layers. */
   ob->runtime.gpencil_tot_layers = BLI_listbase_count(>layers);
   CLAMP_MIN(ob->runtime.gpencil_tot_layers, 1);
diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index f9df1342bf8..f21d96a304c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -349,7 +349,6 @@ void DRW_gpencil_freecache(struct Object *ob)
   for (int i = 0; i < ob->runtime.gpencil_tot_layers; i++) {
 bGPDframe *gpf_eval = >runtime.gpencil_evaluated_frames[i];
 BKE_gpencil_free_frame_runtime_data(gpf_eval);
-gpf_eval = NULL;
   }
 
   ob->runtime.gpencil_tot_layers = 0;

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


[Bf-blender-cvs] [fb838592789] greasepencil-object: Merge branch 'master' into greasepencil-object

2020-01-07 Thread Antonio Vazquez
Commit: fb838592789b3589fd369f7b0b2750d4107e2871
Author: Antonio Vazquez
Date:   Tue Jan 7 14:14:51 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rBfb838592789b3589fd369f7b0b2750d4107e2871

Merge branch 'master' into greasepencil-object

===



===

diff --cc source/blender/editors/gpencil/gpencil_paint.c
index 023cc32227d,6a91417e7f3..5362390daa6
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@@ -980,10 -1171,9 +980,10 @@@ static void gp_stroke_newfrombuffer(tGP
const int subdivide = brush->gpencil_settings->draw_subdivide;
  
gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, 
"gp_stroke_points");
 +  gps->dvert = NULL;
  
/* initialize triangle memory to dummy data */
-   gps->triangles = MEM_callocN(sizeof(bGPDtriangle), "GP Stroke 
triangulation");
+   gps->triangles = NULL;
gps->flag |= GP_STROKE_RECALC_GEOMETRY;
gps->tot_triangles = 0;
/* drawing batch cache is dirty now */

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


[Bf-blender-cvs] [a99f6e5df18] master: GPencil: Remove memory allocation for triangles

2020-01-07 Thread Antonio Vazquez
Commit: a99f6e5df18d4f8bf480bf69d439f86311794fc1
Author: Antonio Vazquez
Date:   Tue Jan 7 12:14:36 2020 +0100
Branches: master
https://developer.blender.org/rBa99f6e5df18d4f8bf480bf69d439f86311794fc1

GPencil: Remove memory allocation for triangles

This will be replaced later, so it's not logic allocate now.

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index 4744d2cf1c0..98c8f46970f 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -494,7 +494,7 @@ bGPDstroke *BKE_gpencil_add_stroke(bGPDframe *gpf, int 
mat_idx, int totpoints, s
   gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, 
"gp_stroke_points");
 
   /* initialize triangle memory to dummy data */
-  gps->triangles = MEM_callocN(sizeof(bGPDtriangle), "GP Stroke 
triangulation");
+  gps->triangles = NULL;
   gps->flag |= GP_STROKE_RECALC_GEOMETRY;
   gps->tot_triangles = 0;
 
diff --git a/source/blender/editors/gpencil/gpencil_paint.c 
b/source/blender/editors/gpencil/gpencil_paint.c
index 67830d0e501..6a91417e7f3 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1173,7 +1173,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
   gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, 
"gp_stroke_points");
 
   /* initialize triangle memory to dummy data */
-  gps->triangles = MEM_callocN(sizeof(bGPDtriangle), "GP Stroke 
triangulation");
+  gps->triangles = NULL;
   gps->flag |= GP_STROKE_RECALC_GEOMETRY;
   gps->tot_triangles = 0;
   /* drawing batch cache is dirty now */

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


[Bf-blender-cvs] [122a0afa963] master: Blenlib: Add C++ guard for Queue

2020-01-07 Thread Sergey Sharybin
Commit: 122a0afa96300c56619964e5b57052bc6b6e814b
Author: Sergey Sharybin
Date:   Tue Jan 7 12:53:39 2020 +0100
Branches: master
https://developer.blender.org/rB122a0afa96300c56619964e5b57052bc6b6e814b

Blenlib: Add C++ guard for Queue

===

M   source/blender/blenlib/BLI_gsqueue.h

===

diff --git a/source/blender/blenlib/BLI_gsqueue.h 
b/source/blender/blenlib/BLI_gsqueue.h
index b8a87e9d9fa..dffb2a165ee 100644
--- a/source/blender/blenlib/BLI_gsqueue.h
+++ b/source/blender/blenlib/BLI_gsqueue.h
@@ -24,6 +24,10 @@
  * \ingroup bli
  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct _GSQueue GSQueue;
 
 GSQueue *BLI_gsqueue_new(const size_t elem_size);
@@ -33,4 +37,8 @@ void BLI_gsqueue_pop(GSQueue *gq, void *r_item);
 void BLI_gsqueue_push(GSQueue *gq, const void *item);
 void BLI_gsqueue_free(GSQueue *gq);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __BLI_GSQUEUE_H__ */

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


[Bf-blender-cvs] [025cc51a5a3] greasepencil-refactor: GPencil: Fix wrong functions name after merge

2020-01-07 Thread Antonio Vazquez
Commit: 025cc51a5a32fe012a0f82fa966e4b2dee331dc5
Author: Antonio Vazquez
Date:   Tue Jan 7 12:55:42 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB025cc51a5a32fe012a0f82fa966e4b2dee331dc5

GPencil: Fix wrong functions name after merge

===

M   source/blender/editors/gpencil/gpencil_data.c
M   source/blender/editors/gpencil/gpencil_edit.c
M   source/blender/editors/gpencil/gpencil_utils.c
M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/gpencil/gpencil_data.c 
b/source/blender/editors/gpencil/gpencil_data.c
index 8111cd6f4d2..c7c121b2f39 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -292,7 +292,7 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
 
   bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) :
 ED_annotation_data_get_active(C);
-  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 
   /* sanity checks */
   if (ELEM(NULL, gpd, gpl)) {
@@ -342,7 +342,7 @@ void GPENCIL_OT_layer_remove(wmOperatorType *ot)
 static bool gp_active_layer_annotation_poll(bContext *C)
 {
   bGPdata *gpd = ED_annotation_data_get_active(C);
-  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 
   return (gpl != NULL);
 }
@@ -373,7 +373,7 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op)
 
   bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) :
 ED_annotation_data_get_active(C);
-  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 
   const int direction = RNA_enum_get(op->ptr, "type") * -1;
 
diff --git a/source/blender/editors/gpencil/gpencil_edit.c 
b/source/blender/editors/gpencil/gpencil_edit.c
index 0890d8f648c..f0caf3ddf9d 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1770,7 +1770,7 @@ static bool gp_actframe_delete_poll(bContext *C)
 static bool gp_annotation_actframe_delete_poll(bContext *C)
 {
   bGPdata *gpd = ED_annotation_data_get_active(C);
-  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 
   /* only if there's an active layer with an active frame */
   return (gpl && gpl->actframe);
@@ -1784,7 +1784,7 @@ static int gp_actframe_delete_exec(bContext *C, 
wmOperator *op)
   bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) :
 ED_annotation_data_get_active(C);
 
-  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 
   Scene *scene = CTX_data_scene(C);
 
diff --git a/source/blender/editors/gpencil/gpencil_utils.c 
b/source/blender/editors/gpencil/gpencil_utils.c
index 26364ad5e3a..8776fd64965 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -369,7 +369,7 @@ bool gp_active_layer_poll(bContext *C)
 return false;
   }
   bGPdata *gpd = (bGPdata *)ob->data;
-  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 
   return (gpl != NULL);
 }
diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 134a51751f9..1256c45cfa7 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -555,7 +555,7 @@ int ed_screen_context(const bContext *C, const char 
*member, bContextDataResult
 bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
 
 if (gpd) {
-  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
 
   if (gpl) {
 CTX_data_pointer_set(result, >id, _GPencilLayer, gpl);

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


[Bf-blender-cvs] [581a5ee0cc7] master: Edit Mesh: add comments to EDBM_op_finish

2020-01-07 Thread Campbell Barton
Commit: 581a5ee0cc7ea685cdb83f5260c3b1fbf3f977ab
Author: Campbell Barton
Date:   Tue Jan 7 22:27:16 2020 +1100
Branches: master
https://developer.blender.org/rB581a5ee0cc7ea685cdb83f5260c3b1fbf3f977ab

Edit Mesh: add comments to EDBM_op_finish

Was marked 'FIXME' however this only ever happens in exceptional cases.

Also comment why tagging is needed in this case.

===

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

===

diff --git a/source/blender/editors/mesh/editmesh_utils.c 
b/source/blender/editors/mesh/editmesh_utils.c
index 96fa31e17e9..f7092a8c6ab 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -161,14 +161,14 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, 
wmOperator *op, const bool
 em->emcopyusers = 0;
 em->emcopy = NULL;
 
-/* when copying, tessellation isn't to for faster copying,
- * but means we need to re-tessellate here */
-if (em->looptris == NULL) {
-  BKE_editmesh_looptri_calc(em);
-}
-
+/**
+ * Note, we could pass in the mesh, however this is an exceptional case, 
allow a slow lookup.
+ *
+ * This is needed because the COW mesh makes a full copy of the #BMEditMesh
+ * instead of sharing the pointer, tagging since this has been freed above,
+ * the #BMEditMesh.emcopy needs to be flushed to the COW edit-mesh, see 
T55457.
+ */
 {
-  /* FIXME: pass in mesh. */
   Main *bmain = G_MAIN;
   for (Mesh *mesh = bmain->meshes.first; mesh; mesh = mesh->id.next) {
 if (mesh->edit_mesh == em) {
@@ -178,6 +178,12 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, 
wmOperator *op, const bool
   }
 }
 
+/* when copying, tessellation isn't to for faster copying,
+ * but means we need to re-tessellate here */
+if (em->looptris == NULL) {
+  BKE_editmesh_looptri_calc(em);
+}
+
 return false;
   }
   else {

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


[Bf-blender-cvs] [bcfa1c30516] master: Depsgraph: Revert unwillingly staged change from previous commit

2020-01-07 Thread Sergey Sharybin
Commit: bcfa1c30516c0910169e0ebf9403aff14763defb
Author: Sergey Sharybin
Date:   Tue Jan 7 12:26:17 2020 +0100
Branches: master
https://developer.blender.org/rBbcfa1c30516c0910169e0ebf9403aff14763defb

Depsgraph: Revert unwillingly staged change from previous commit

One of those days, sorry for the spam.

===

M   source/blender/depsgraph/intern/eval/deg_eval.cc

===

diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc 
b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 4f3c090e142..aca20955ba4 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -56,7 +56,6 @@ namespace DEG {
 
 namespace {
 
-template
 void schedule_children(TaskPool *pool, Depsgraph *graph, OperationNode *node, 
const int thread_id);
 
 /* Denotes which part of dependency graph is being evaluated. */

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


[Bf-blender-cvs] [b6b5924e691] master: Depsgraph: Cleanup spelling

2020-01-07 Thread Sergey Sharybin
Commit: b6b5924e69155161294a947b1caaf332f2c5a7d6
Author: Sergey Sharybin
Date:   Tue Jan 7 12:25:16 2020 +0100
Branches: master
https://developer.blender.org/rBb6b5924e69155161294a947b1caaf332f2c5a7d6

Depsgraph: Cleanup spelling

For some reason got sneaked into previous commit.

===

M   source/blender/depsgraph/intern/eval/deg_eval.cc

===

diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc 
b/source/blender/depsgraph/intern/eval/deg_eval.cc
index c690dae4ad3..4f3c090e142 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -56,6 +56,7 @@ namespace DEG {
 
 namespace {
 
+template
 void schedule_children(TaskPool *pool, Depsgraph *graph, OperationNode *node, 
const int thread_id);
 
 /* Denotes which part of dependency graph is being evaluated. */
@@ -65,7 +66,7 @@ enum class EvaluationStage {
* involved. */
   COPY_ON_WRITE,
 
-  /* Threaded evaluation of all possible operationsd. */
+  /* Threaded evaluation of all possible operations. */
   THREADED_EVALUATION,
 };

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


[Bf-blender-cvs] [5be0b2bc4e0] master: Depsgraph: Refactor, make evaluation stages easier to extend

2020-01-07 Thread Sergey Sharybin
Commit: 5be0b2bc4e0de8aae6f04a9da00af4e22e9476ca
Author: Sergey Sharybin
Date:   Tue Jan 7 12:04:26 2020 +0100
Branches: master
https://developer.blender.org/rB5be0b2bc4e0de8aae6f04a9da00af4e22e9476ca

Depsgraph: Refactor, make evaluation stages easier to extend

Currently should be no functional changes, but allows to extend it
for experiments or for real fixes.

===

M   source/blender/depsgraph/intern/eval/deg_eval.cc

===

diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc 
b/source/blender/depsgraph/intern/eval/deg_eval.cc
index b2e6e765328..c690dae4ad3 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -58,10 +58,21 @@ namespace {
 
 void schedule_children(TaskPool *pool, Depsgraph *graph, OperationNode *node, 
const int thread_id);
 
+/* Denotes which part of dependency graph is being evaluated. */
+enum class EvaluationStage {
+  /* Stage 1: Only  Copy-on-Write operations are to be evaluated, prior to 
anything else.
+   * This allows other operations to access its dependencies when there is a 
dependency cycle
+   * involved. */
+  COPY_ON_WRITE,
+
+  /* Threaded evaluation of all possible operationsd. */
+  THREADED_EVALUATION,
+};
+
 struct DepsgraphEvalState {
   Depsgraph *graph;
   bool do_stats;
-  bool is_cow_stage;
+  EvaluationStage stage;
 };
 
 void deg_task_run_func(TaskPool *pool, void *taskdata, int thread_id)
@@ -148,6 +159,25 @@ void initialize_execution(DepsgraphEvalState *state, 
Depsgraph *graph)
   }
 }
 
+bool need_evaluate_operation_at_stage(const DepsgraphEvalState *state,
+  const OperationNode *operation_node)
+{
+  const ComponentNode *component_node = operation_node->owner;
+  switch (state->stage) {
+case EvaluationStage::COPY_ON_WRITE:
+  return (component_node->type == NodeType::COPY_ON_WRITE);
+
+case EvaluationStage::THREADED_EVALUATION:
+  /* Sanity check: copy-on-write node should be evaluated already. This 
will be indicated by
+   * scheduled flag (we assume that scheduled operations have been 
actually handled by previous
+   * stage). */
+  BLI_assert(operation_node->scheduled || component_node->type != 
NodeType::COPY_ON_WRITE);
+  return true;
+  }
+  BLI_assert(!"Unhandled evaluation stage, should never happen.");
+  return false;
+}
+
 /* Schedule a node if it needs evaluation.
  *   dec_parents: Decrement pending parents count, true when child nodes are
  *scheduled after a task has been completed.
@@ -176,14 +206,9 @@ void schedule_node(
 return;
   }
   /* During the COW stage only schedule COW nodes. */
-  DepsgraphEvalState *state = (DepsgraphEvalState 
*)BLI_task_pool_userdata(pool);
-  if (state->is_cow_stage) {
-if (node->owner->type != NodeType::COPY_ON_WRITE) {
-  return;
-}
-  }
-  else {
-BLI_assert(node->scheduled || node->owner->type != 
NodeType::COPY_ON_WRITE);
+  const DepsgraphEvalState *state = (DepsgraphEvalState 
*)BLI_task_pool_userdata(pool);
+  if (!need_evaluate_operation_at_stage(state, node)) {
+return;
   }
   /* Actually schedule the node. */
   bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t *)>scheduled, 
(uint8_t) true);
@@ -271,16 +296,21 @@ void deg_evaluate_on_refresh(Depsgraph *graph)
   TaskPool *task_pool = BLI_task_pool_create_suspended(task_scheduler, );
   /* Prepare all nodes for evaluation. */
   initialize_execution(, graph);
+
   /* Do actual evaluation now. */
+
   /* First, process all Copy-On-Write nodes. */
-  state.is_cow_stage = true;
+  state.stage = EvaluationStage::COPY_ON_WRITE;
   schedule_graph(task_pool, graph);
   BLI_task_pool_work_wait_and_reset(task_pool);
+
   /* After that, process all other nodes. */
-  state.is_cow_stage = false;
+  state.stage = EvaluationStage::THREADED_EVALUATION;
   schedule_graph(task_pool, graph);
   BLI_task_pool_work_and_wait(task_pool);
+
   BLI_task_pool_free(task_pool);
+
   /* Finalize statistics gathering. This is because we only gather single
* operation timing here, without aggregating anything to avoid any extra
* synchronization. */

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


[Bf-blender-cvs] [8534fb1b01d] master: Depsgraph: Cleanup, move private functions to anonymous namespace

2020-01-07 Thread Sergey Sharybin
Commit: 8534fb1b01d556e64846e26f8135201bc2d46c1a
Author: Sergey Sharybin
Date:   Tue Jan 7 11:56:55 2020 +0100
Branches: master
https://developer.blender.org/rB8534fb1b01d556e64846e26f8135201bc2d46c1a

Depsgraph: Cleanup, move private functions to anonymous namespace

Allows to have shorter definition lines.

===

M   source/blender/depsgraph/intern/eval/deg_eval.cc

===

diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc 
b/source/blender/depsgraph/intern/eval/deg_eval.cc
index d6b3c54a149..b2e6e765328 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -54,14 +54,9 @@
 
 namespace DEG {
 
-/* ** */
-/* Evaluation Entrypoints */
+namespace {
 
-/* Forward declarations. */
-static void schedule_children(TaskPool *pool,
-  Depsgraph *graph,
-  OperationNode *node,
-  const int thread_id);
+void schedule_children(TaskPool *pool, Depsgraph *graph, OperationNode *node, 
const int thread_id);
 
 struct DepsgraphEvalState {
   Depsgraph *graph;
@@ -69,7 +64,7 @@ struct DepsgraphEvalState {
   bool is_cow_stage;
 };
 
-static void deg_task_run_func(TaskPool *pool, void *taskdata, int thread_id)
+void deg_task_run_func(TaskPool *pool, void *taskdata, int thread_id)
 {
   void *userdata_v = BLI_task_pool_userdata(pool);
   DepsgraphEvalState *state = (DepsgraphEvalState *)userdata_v;
@@ -91,7 +86,7 @@ static void deg_task_run_func(TaskPool *pool, void *taskdata, 
int thread_id)
   BLI_task_pool_delayed_push_end(pool, thread_id);
 }
 
-static bool check_operation_node_visible(OperationNode *op_node)
+bool check_operation_node_visible(OperationNode *op_node)
 {
   const ComponentNode *comp_node = op_node->owner;
   /* Special exception, copy on write component is to be always evaluated,
@@ -102,7 +97,7 @@ static bool check_operation_node_visible(OperationNode 
*op_node)
   return comp_node->affects_directly_visible;
 }
 
-static void calculate_pending_parents_for_node(OperationNode *node)
+void calculate_pending_parents_for_node(OperationNode *node)
 {
   /* Update counters, applies for both visible and invisible IDs. */
   node->num_links_pending = 0;
@@ -134,14 +129,14 @@ static void 
calculate_pending_parents_for_node(OperationNode *node)
   }
 }
 
-static void calculate_pending_parents(Depsgraph *graph)
+void calculate_pending_parents(Depsgraph *graph)
 {
   for (OperationNode *node : graph->operations) {
 calculate_pending_parents_for_node(node);
   }
 }
 
-static void initialize_execution(DepsgraphEvalState *state, Depsgraph *graph)
+void initialize_execution(DepsgraphEvalState *state, Depsgraph *graph)
 {
   const bool do_stats = state->do_stats;
   calculate_pending_parents(graph);
@@ -157,7 +152,7 @@ static void initialize_execution(DepsgraphEvalState *state, 
Depsgraph *graph)
  *   dec_parents: Decrement pending parents count, true when child nodes are
  *scheduled after a task has been completed.
  */
-static void schedule_node(
+void schedule_node(
 TaskPool *pool, Depsgraph *graph, OperationNode *node, bool dec_parents, 
const int thread_id)
 {
   /* No need to schedule nodes of invisible ID. */
@@ -205,17 +200,14 @@ static void schedule_node(
   }
 }
 
-static void schedule_graph(TaskPool *pool, Depsgraph *graph)
+void schedule_graph(TaskPool *pool, Depsgraph *graph)
 {
   for (OperationNode *node : graph->operations) {
 schedule_node(pool, graph, node, false, -1);
   }
 }
 
-static void schedule_children(TaskPool *pool,
-  Depsgraph *graph,
-  OperationNode *node,
-  const int thread_id)
+void schedule_children(TaskPool *pool, Depsgraph *graph, OperationNode *node, 
const int thread_id)
 {
   for (Relation *rel : node->outlinks) {
 OperationNode *child = (OperationNode *)rel->to;
@@ -228,7 +220,7 @@ static void schedule_children(TaskPool *pool,
   }
 }
 
-static void depsgraph_ensure_view_layer(Depsgraph *graph)
+void depsgraph_ensure_view_layer(Depsgraph *graph)
 {
   /* We update copy-on-write scene in the following cases:
* - It was not expanded yet.
@@ -242,6 +234,8 @@ static void depsgraph_ensure_view_layer(Depsgraph *graph)
   }
 }
 
+}  // namespace
+
 /**
  * Evaluate all nodes tagged for updating,
  * \warning This is usually done as part of main loop, but may also be

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


[Bf-blender-cvs] [2c9ca87ceff] master: Cleanup: Remove unused task scheduler constants

2020-01-07 Thread Sergey Sharybin
Commit: 2c9ca87ceff05eb691b27e521b0bcf1772ae2e21
Author: Sergey Sharybin
Date:   Tue Jan 7 12:13:53 2020 +0100
Branches: master
https://developer.blender.org/rB2c9ca87ceff05eb691b27e521b0bcf1772ae2e21

Cleanup: Remove unused task scheduler constants

===

M   source/blender/blenlib/BLI_task.h

===

diff --git a/source/blender/blenlib/BLI_task.h 
b/source/blender/blenlib/BLI_task.h
index 24346454a3f..83bcdff214d 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -45,11 +45,6 @@ struct BLI_mempool;
 
 typedef struct TaskScheduler TaskScheduler;
 
-enum {
-  TASK_SCHEDULER_AUTO_THREADS = 0,
-  TASK_SCHEDULER_SINGLE_THREAD = 1,
-};
-
 TaskScheduler *BLI_task_scheduler_create(int num_threads);
 void BLI_task_scheduler_free(TaskScheduler *scheduler);

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


[Bf-blender-cvs] [c128b30bd13] master: Edit Mesh: pass in Mesh instead of BMEditMesh to EDBM_update_generic

2020-01-07 Thread Campbell Barton
Commit: c128b30bd13bbf48a701fe068fa27c1d21378515
Author: Campbell Barton
Date:   Tue Jan 7 22:11:19 2020 +1100
Branches: master
https://developer.blender.org/rBc128b30bd13bbf48a701fe068fa27c1d21378515

Edit Mesh: pass in Mesh instead of BMEditMesh to EDBM_update_generic

This avoids a list lookup in Main (recently added), passing in a mesh
instead of an edit-mesh, since the mesh links to the edit-mesh.

===

M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/mesh/editmesh_add.c
M   source/blender/editors/mesh/editmesh_add_gizmo.c
M   source/blender/editors/mesh/editmesh_automerge.c
M   source/blender/editors/mesh/editmesh_bevel.c
M   source/blender/editors/mesh/editmesh_bisect.c
M   source/blender/editors/mesh/editmesh_extrude.c
M   source/blender/editors/mesh/editmesh_extrude_screw.c
M   source/blender/editors/mesh/editmesh_extrude_spin.c
M   source/blender/editors/mesh/editmesh_inset.c
M   source/blender/editors/mesh/editmesh_intersect.c
M   source/blender/editors/mesh/editmesh_knife.c
M   source/blender/editors/mesh/editmesh_loopcut.c
M   source/blender/editors/mesh/editmesh_path.c
M   source/blender/editors/mesh/editmesh_polybuild.c
M   source/blender/editors/mesh/editmesh_rip.c
M   source/blender/editors/mesh/editmesh_rip_edge.c
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/mesh/editmesh_select_similar.c
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/editors/mesh/editmesh_utils.c
M   source/blender/editors/object/object_data_transform.c
M   source/blender/editors/uvedit/uvedit_ops.c
M   source/blender/python/bmesh/bmesh_py_api.c

===

diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index 1153944068e..95d6d5cab3b 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -104,9 +104,7 @@ bool EDBM_vert_color_check(struct BMEditMesh *em);
 bool EDBM_mesh_hide(struct BMEditMesh *em, bool swap);
 bool EDBM_mesh_reveal(struct BMEditMesh *em, bool select);
 
-void EDBM_update_generic(struct BMEditMesh *em,
- const bool do_tessellation,
- const bool is_destructive);
+void EDBM_update_generic(struct Mesh *me, const bool do_tessellation, const 
bool is_destructive);
 
 struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm,
   const struct Scene *scene,
diff --git a/source/blender/editors/mesh/editmesh_add.c 
b/source/blender/editors/mesh/editmesh_add.c
index a7d1e54ad59..7a0124e72bb 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -92,7 +92,7 @@ static void make_prim_finish(bContext *C,
   EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
 
   /* only recalc editmode tessface if we are staying in editmode */
-  EDBM_update_generic(em, !exit_editmode, true);
+  EDBM_update_generic(obedit->data, !exit_editmode, true);
 
   /* userdef */
   if (exit_editmode) {
diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c 
b/source/blender/editors/mesh/editmesh_add_gizmo.c
index 66832ceba7f..c748560ae1b 100644
--- a/source/blender/editors/mesh/editmesh_add_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_add_gizmo.c
@@ -357,7 +357,7 @@ static int add_primitive_cube_gizmo_exec(bContext *C, 
wmOperator *op)
   }
 
   EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
-  EDBM_update_generic(em, true, true);
+  EDBM_update_generic(obedit->data, true, true);
 
   return OPERATOR_FINISHED;
 }
diff --git a/source/blender/editors/mesh/editmesh_automerge.c 
b/source/blender/editors/mesh/editmesh_automerge.c
index 55b52e01fc3..ffde9f338b4 100644
--- a/source/blender/editors/mesh/editmesh_automerge.c
+++ b/source/blender/editors/mesh/editmesh_automerge.c
@@ -79,7 +79,7 @@ void EDBM_automerge(Object *obedit, bool update, const char 
hflag, const float d
   BMO_op_finish(bm, );
 
   if ((totvert_prev != bm->totvert) && update) {
-EDBM_update_generic(em, true, true);
+EDBM_update_generic(obedit->data, true, true);
   }
 }
 
@@ -189,7 +189,7 @@ void EDBM_automerge_and_split(Object *obedit,
 #endif
 
   if (LIKELY(ok) && update) {
-EDBM_update_generic(em, true, true);
+EDBM_update_generic(obedit->data, true, true);
   }
 }
 
diff --git a/source/blender/editors/mesh/editmesh_bevel.c 
b/source/blender/editors/mesh/editmesh_bevel.c
index 710fbf9f693..b2b1e1ff4f5 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -406,7 +406,7 @@ static bool edbm_bevel_calc(wmOperator *op)
 
 EDBM_mesh_normals_update(em);
 
-EDBM_update_generic(em, true, true);
+EDBM_update_generic(obedit->data, true, true);
 changed 

[Bf-blender-cvs] [cb1f48ab7f5] master: Fix T69246: Outliner - Objects Filter Selected, Hidden and Active not working properly

2020-01-07 Thread Philipp Oeser
Commit: cb1f48ab7f5024715a898b767576ce4258098516
Author: Philipp Oeser
Date:   Fri Jan 3 11:08:42 2020 +0100
Branches: master
https://developer.blender.org/rBcb1f48ab7f5024715a898b767576ce4258098516

Fix T69246: Outliner - Objects Filter Selected, Hidden and Active not
working properly

'outliner_extract_children_from_subtree()' (introduced in
rB40a1c671655c) was extracting the children of non-matching parents
regardless of their own matching state.

Now properly filter the subtree prior to extracting.

Maniphest Tasks: T69246

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

===

M   source/blender/editors/space_outliner/outliner_tree.c

===

diff --git a/source/blender/editors/space_outliner/outliner_tree.c 
b/source/blender/editors/space_outliner/outliner_tree.c
index 7f7cfff12ef..ed0d85477f1 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -2186,6 +2186,8 @@ static int outliner_filter_subtree(SpaceOutliner *soops,
 te_next = te->next;
 if ((outliner_element_visible_get(view_layer, te, exclude_filter) == 
false)) {
   /* Don't free the tree, but extract the children from the parent and add 
to this tree. */
+  /* This also needs filtering the subtree prior (see T69246). */
+  outliner_filter_subtree(soops, view_layer, >subtree, search_string, 
exclude_filter);
   te_next = outliner_extract_children_from_subtree(te, lb);
   continue;
 }

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


[Bf-blender-cvs] [b6bcfd2a6e7] master: GPencil: Remove is_annotation parameter

2020-01-07 Thread Antonio Vazquez
Commit: b6bcfd2a6e73f25f9d60df8ea41e30cb9c57a1a2
Author: Antonio Vazquez
Date:   Tue Jan 7 11:44:51 2020 +0100
Branches: master
https://developer.blender.org/rBb6bcfd2a6e73f25f9d60df8ea41e30cb9c57a1a2

GPencil: Remove is_annotation parameter

Now, the name of the operator is used.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_edit.c 
b/source/blender/editors/gpencil/gpencil_edit.c
index d47db0a3ce8..8d0fe73572f 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1662,7 +1662,7 @@ static bool gp_annotation_actframe_delete_poll(bContext 
*C)
 /* delete active frame - wrapper around API calls */
 static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
 {
-  const int is_annotation = RNA_boolean_get(op->ptr, "is_annotation");
+  const bool is_annotation = STREQ(op->idname, 
"GPENCIL_OT_annotation_active_frame_delete");
 
   bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) :
 ED_annotation_data_get_active(C);
@@ -1695,8 +1695,6 @@ static int gp_actframe_delete_exec(bContext *C, 
wmOperator *op)
 
 void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
 {
-  PropertyRNA *prop;
-
   /* identifiers */
   ot->name = "Delete Active Frame";
   ot->idname = "GPENCIL_OT_active_frame_delete";
@@ -1707,15 +1705,10 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
   /* callbacks */
   ot->exec = gp_actframe_delete_exec;
   ot->poll = gp_actframe_delete_poll;
-
-  prop = RNA_def_boolean(ot->srna, "is_annotation", false, "Annotation", "");
-  RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }
 
 void GPENCIL_OT_annotation_active_frame_delete(wmOperatorType *ot)
 {
-  PropertyRNA *prop;
-
   /* identifiers */
   ot->name = "Delete Active Frame";
   ot->idname = "GPENCIL_OT_annotation_active_frame_delete";
@@ -1726,9 +1719,6 @@ void 
GPENCIL_OT_annotation_active_frame_delete(wmOperatorType *ot)
   /* callbacks */
   ot->exec = gp_actframe_delete_exec;
   ot->poll = gp_annotation_actframe_delete_poll;
-
-  prop = RNA_def_boolean(ot->srna, "is_annotation", true, "Annotation", "");
-  RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }
 /*  Delete All Active Frames ** */

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


[Bf-blender-cvs] [8a28f6e08db] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

2020-01-07 Thread Antonio Vazquez
Commit: 8a28f6e08db6a73eba18200baf735d148c21712a
Author: Antonio Vazquez
Date:   Tue Jan 7 11:38:39 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB8a28f6e08db6a73eba18200baf735d148c21712a

Merge branch 'greasepencil-object' into greasepencil-refactor

 Conflicts:
source/blender/editors/gpencil/gpencil_data.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/gpencil/gpencil_utils.c

===



===

diff --cc source/blender/editors/screen/screen_context.c
index f3512d746f9,a840d199823..134a51751f9
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@@ -530,11 -552,22 +552,22 @@@ int ed_screen_context(const bContext *C
  }
}
else if (CTX_data_equals(member, "active_gpencil_layer")) {
- /* XXX: see comment for gpencil_data case... */
- bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, 
obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
+ 
+ if (gpd) {
+   bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
+ 
+   if (gpl) {
+ CTX_data_pointer_set(result, >id, _GPencilLayer, gpl);
+ return 1;
+   }
+ }
+   }
+   else if (CTX_data_equals(member, "active_annotation_layer")) {
+ bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, sa, scene);
  
  if (gpd) {
 -  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
 +  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
  
if (gpl) {
  CTX_data_pointer_set(result, >id, _GPencilLayer, gpl);
@@@ -543,11 -576,10 +576,10 @@@
  }
}
else if (CTX_data_equals(member, "active_gpencil_frame")) {
- /* XXX: see comment for gpencil_data case... */
- bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, 
obact);
+ bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
  
  if (gpd) {
 -  bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
 +  bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
  
if (gpl) {
  CTX_data_pointer_set(result, >id, _GPencilLayer, 
gpl->actframe);

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


[Bf-blender-cvs] [70264903a45] greasepencil-object: Merge branch 'master' into greasepencil-object

2020-01-07 Thread Antonio Vazquez
Commit: 70264903a4593bd690e2f1001cb018b94b91cf80
Author: Antonio Vazquez
Date:   Tue Jan 7 11:35:30 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB70264903a4593bd690e2f1001cb018b94b91cf80

Merge branch 'master' into greasepencil-object

 Conflicts:
release/scripts/startup/bl_ui/space_toolsystem_toolbar.py

===



===

diff --cc release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index d09f30affdc,170b635f7e1..6cf664591d6
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@@ -2172,7 -2132,7 +2174,9 @@@ class VIEW3D_PT_tools_active(ToolSelect
  _defs_gpencil_edit.tosphere,
  ),
  None,
 +_defs_gpencil_edit.transform_fill,
++None,
+ *_tools_annotate,
  ],
  'SCULPT_GPENCIL': [
  _defs_gpencil_sculpt.generate_from_brushes,
@@@ -2185,16 -2146,9 +2190,18 @@@
  ],
  'WEIGHT_GPENCIL': [
  _defs_gpencil_weight.generate_from_brushes,
+ None,
+ *_tools_annotate,
  ],
 +'VERTEX_GPENCIL': [
 +_defs_gpencil_vertex.generate_from_brushes,
 +None,
 +lambda context: (
 +VIEW3D_PT_tools_active._tools_gpencil_select
 +if _defs_gpencil_vertex.poll_select_mask(context)
 +else ()
 +),
 +],
  }

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


[Bf-blender-cvs] [fa3a0697b84] master: Annotations: Split annotation operators and pointer functions

2020-01-07 Thread Antonio Vazquez
Commit: fa3a0697b846bd0ed3766fcabd1bf6f260aa425a
Author: Antonio Vazquez
Date:   Tue Jan 7 11:29:42 2020 +0100
Branches: master
https://developer.blender.org/rBfa3a0697b846bd0ed3766fcabd1bf6f260aa425a

Annotations: Split annotation operators and pointer functions

This allows to have annotation panels and grease pencil object panel at the 
same time.

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

===

M   release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M   source/blender/editors/gpencil/annotate_draw.c
M   source/blender/editors/gpencil/annotate_paint.c
M   source/blender/editors/gpencil/gpencil_data.c
M   source/blender/editors/gpencil/gpencil_edit.c
M   source/blender/editors/gpencil/gpencil_intern.h
M   source/blender/editors/gpencil/gpencil_ops.c
M   source/blender/editors/gpencil/gpencil_utils.c
M   source/blender/editors/include/ED_gpencil.h
M   source/blender/editors/screen/screen_context.c

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 45cb10bb3bd..2001f46820f 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -581,9 +581,9 @@ class AnnotationDataPanel:
 def poll(cls, context):
 # Show this panel as long as someone that might own this exists
 # AND the owner isn't an object (e.g. GP Object)
-if context.gpencil_data_owner is None:
+if context.annotation_data_owner is None:
 return False
-elif type(context.gpencil_data_owner) is bpy.types.Object:
+elif type(context.annotation_data_owner) is bpy.types.Object:
 return False
 else:
 return True
@@ -597,14 +597,14 @@ class AnnotationDataPanel:
 layout.use_property_decorate = False
 
 # Grease Pencil owner.
-gpd_owner = context.gpencil_data_owner
-gpd = context.gpencil_data
+gpd_owner = context.annotation_data_owner
+gpd = context.annotation_data
 
 # Owner selector.
 if context.space_data.type == 'CLIP_EDITOR':
 layout.row().prop(context.space_data, "grease_pencil_source", 
expand=True)
 
-layout.template_ID(gpd_owner, "grease_pencil", new="gpencil.data_add", 
unlink="gpencil.data_unlink")
+layout.template_ID(gpd_owner, "grease_pencil", 
new="gpencil.annotation_add", unlink="gpencil.data_unlink")
 
 # List of layers/notes.
 if gpd and gpd.layers:
@@ -624,17 +624,17 @@ class AnnotationDataPanel:
 col = row.column()
 
 sub = col.column(align=True)
-sub.operator("gpencil.layer_add", icon='ADD', text="")
-sub.operator("gpencil.layer_remove", icon='REMOVE', text="")
+sub.operator("gpencil.layer_annotation_add", icon='ADD', text="")
+sub.operator("gpencil.layer_annotation_remove", icon='REMOVE', text="")
 
-gpl = context.active_gpencil_layer
+gpl = context.active_annotation_layer
 if gpl:
 if len(gpd.layers) > 1:
 col.separator()
 
 sub = col.column(align=True)
-sub.operator("gpencil.layer_move", icon='TRIA_UP', 
text="").type = 'UP'
-sub.operator("gpencil.layer_move", icon='TRIA_DOWN', 
text="").type = 'DOWN'
+sub.operator("gpencil.layer_annotation_move", icon='TRIA_UP', 
text="").type = 'UP'
+sub.operator("gpencil.layer_annotation_move", 
icon='TRIA_DOWN', text="").type = 'DOWN'
 
 tool_settings = context.tool_settings
 if gpd and gpl:
@@ -653,7 +653,7 @@ class AnnotationDataPanel:
 else:
 lock_label = iface_("Lock Frame")
 row.prop(gpl, "lock_frame", text=lock_label, icon='UNLOCKED')
-row.operator("gpencil.active_frame_delete", text="", icon='X')
+row.operator("gpencil.annotation_active_frame_delete", text="", 
icon='X')
 
 
 class AnnotationOnionSkin:
@@ -665,26 +665,26 @@ class AnnotationOnionSkin:
 def poll(cls, context):
 # Show this panel as long as someone that might own this exists
 # AND the owner isn't an object (e.g. GP Object)
-if context.gpencil_data_owner is None:
+if context.annotation_data_owner is None:
 return False
-elif type(context.gpencil_data_owner) is bpy.types.Object:
+elif type(context.annotation_data_owner) is bpy.types.Object:
 return False
 else:
-gpl = context.active_gpencil_layer
+gpl = context.active_annotation_layer
 if gpl is None:
 return False
 
 return 

[Bf-blender-cvs] [e237b78b91b] master: Fix T72499: UV Editor : Selection tools don't deselect when dragging on an empty space [face selection]

2020-01-07 Thread Philipp Oeser
Commit: e237b78b91b9e88da8e3c4a5fb360101238c39e4
Author: Philipp Oeser
Date:   Fri Dec 20 15:25:47 2019 +0100
Branches: master
https://developer.blender.org/rBe237b78b91b9e88da8e3c4a5fb360101238c39e4

Fix T72499: UV Editor : Selection tools don't deselect when dragging on an 
empty space [face selection]

If pre-deselecting takes place, then flushing was not happening
('changed' never became true because no new faces were being selected).

This rectifies the logic. (also removed redundant double initialization
to false)

Maniphest Tasks: T72499

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

===

M   source/blender/editors/uvedit/uvedit_ops.c

===

diff --git a/source/blender/editors/uvedit/uvedit_ops.c 
b/source/blender/editors/uvedit/uvedit_ops.c
index 33fcd67f6ed..18b43bcf460 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -3484,6 +3484,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
 
   const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
   const bool select = (sel_op != SEL_OP_SUB);
+  const bool use_pre_deselect = SEL_OP_USE_PRE_DESELECT(sel_op);
 
   pinned = RNA_boolean_get(op->ptr, "pinned");
 
@@ -3493,7 +3494,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
   Object **objects = 
BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
   view_layer, ((View3D *)NULL), _len);
 
-  if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+  if (use_pre_deselect) {
 uv_select_all_perform_multi(scene, ima, objects, objects_len, 
SEL_DESELECT);
   }
 
@@ -3511,8 +3512,6 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
   /* handle face selection mode */
   float cent[2];
 
-  changed = false;
-
   BM_ITER_MESH (efa, , em->bm, BM_FACES_OF_MESH) {
 /* assume not touched */
 BM_elem_flag_disable(efa, BM_ELEM_TAG);
@@ -3565,7 +3564,7 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
   }
 }
 
-if (changed) {
+if (changed || use_pre_deselect) {
   changed_multi = true;
 
   uv_select_sync_flush(ts, em, select);
@@ -3661,9 +3660,10 @@ static int uv_circle_select_exec(bContext *C, wmOperator 
*op)
   const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
   
WM_gesture_is_modal_first(op->customdata));
   const bool select = (sel_op != SEL_OP_SUB);
-  if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+  const bool use_pre_deselect = SEL_OP_USE_PRE_DESELECT(sel_op);
+
+  if (use_pre_deselect) {
 uv_select_all_perform_multi(scene, ima, objects, objects_len, 
SEL_DESELECT);
-changed_multi = true;
   }
 
   for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
@@ -3676,7 +3676,6 @@ static int uv_circle_select_exec(bContext *C, wmOperator 
*op)
 
 /* do selection */
 if (use_face_center) {
-  changed = false;
   BM_ITER_MESH (efa, , em->bm, BM_FACES_OF_MESH) {
 BM_elem_flag_disable(efa, BM_ELEM_TAG);
 /* assume not touched */
@@ -3714,7 +3713,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator 
*op)
   }
 }
 
-if (changed) {
+if (changed || use_pre_deselect) {
   changed_multi = true;
 
   uv_select_sync_flush(ts, em, select);
@@ -3770,6 +3769,7 @@ static bool do_lasso_select_mesh_uv(bContext *C,
 (ts->selectmode == SCE_SELECT_FACE) :
 (ts->uv_selectmode == UV_SELECT_FACE));
   const bool select = (sel_op != SEL_OP_SUB);
+  const bool use_pre_deselect = SEL_OP_USE_PRE_DESELECT(sel_op);
 
   BMIter iter, liter;
 
@@ -3785,7 +3785,7 @@ static bool do_lasso_select_mesh_uv(bContext *C,
   Object **objects = 
BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
   view_layer, ((View3D *)NULL), _len);
 
-  if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
+  if (use_pre_deselect) {
 uv_select_all_perform_multi(scene, ima, objects, objects_len, 
SEL_DESELECT);
   }
 
@@ -3850,7 +3850,7 @@ static bool do_lasso_select_mesh_uv(bContext *C,
   }
 }
 
-if (changed) {
+if (changed || use_pre_deselect) {
   changed_multi = true;
 
   uv_select_sync_flush(ts, em, select);

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


[Bf-blender-cvs] [70eef1a800e] greasepencil-object: Merge branch 'master' into greasepencil-object

2020-01-07 Thread Antonio Vazquez
Commit: 70eef1a800e72b750d7e6ce5e702f4720f1ca4a1
Author: Antonio Vazquez
Date:   Tue Jan 7 09:15:51 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB70eef1a800e72b750d7e6ce5e702f4720f1ca4a1

Merge branch 'master' into greasepencil-object

===



===



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


[Bf-blender-cvs] [0f09693f2a0] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor

2020-01-07 Thread Antonio Vazquez
Commit: 0f09693f2a0f31deaac5ad57b3cc336d04ff6e7f
Author: Antonio Vazquez
Date:   Tue Jan 7 09:16:28 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB0f09693f2a0f31deaac5ad57b3cc336d04ff6e7f

Merge branch 'greasepencil-object' into greasepencil-refactor

===



===



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


[Bf-blender-cvs] [b5cef9fc3f5] master: GPencil: Fix wrong keymap for Radius thickness (related to T72945)

2020-01-07 Thread Antonio Vazquez
Commit: b5cef9fc3f5d505dab700cf8cecffc56e9a1e778
Author: Antonio Vazquez
Date:   Tue Jan 7 09:15:26 2020 +0100
Branches: master
https://developer.blender.org/rBb5cef9fc3f5d505dab700cf8cecffc56e9a1e778

GPencil: Fix wrong keymap for Radius thickness (related to T72945)

===

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

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 488df3f6f72..c6355d61a2b 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5960,7 +5960,7 @@ def km_3d_view_tool_edit_gpencil_radius(params):
 {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
 {"items": [
 ("transform.transform", {"type": params.tool_tweak, "value": 
'ANY'},
- {"properties": [("mode", 'CURVE_SHRINKFATTEN'), 
("release_confirm", True)]}),
+ {"properties": [("mode", 'GPENCIL_SHRINKFATTEN'), 
("release_confirm", True)]}),
 ]},
 )

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


[Bf-blender-cvs] [f226d9007e3] greasepencil-object: Fix T72945: Can't Change the Thickness of a Stroke

2020-01-07 Thread Antonio Vazquez
Commit: f226d9007e34829b1f09c5fc8bb5ccb46d2399f4
Author: Antonio Vazquez
Date:   Tue Jan 7 09:10:41 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rBf226d9007e34829b1f09c5fc8bb5ccb46d2399f4

Fix T72945: Can't Change the Thickness of a Stroke

===

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

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 9e136b407a7..f2d4ebbcdc9 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -6320,7 +6320,7 @@ def km_3d_view_tool_edit_gpencil_radius(params):
 {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
 {"items": [
 ("transform.transform", {"type": params.tool_tweak, "value": 
'ANY'},
- {"properties": [("mode", 'CURVE_SHRINKFATTEN'), 
("release_confirm", True)]}),
+ {"properties": [("mode", 'GPENCIL_SHRINKFATTEN'), 
("release_confirm", True)]}),
 ]},
 )

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