[Bf-blender-cvs] [43770adf13a] lanpr-under-gp: LineArt: Use max weight among groups for selection.

2020-10-02 Thread YimingWu
Commit: 43770adf13aafaa38a0ef53976040797a8fdf253
Author: YimingWu
Date:   Sat Oct 3 13:33:44 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB43770adf13aafaa38a0ef53976040797a8fdf253

LineArt: Use max weight among groups for selection.

===

M   source/blender/editors/lineart/lineart_cpu.c

===

diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index 872c37e5d4e..34cd33f553b 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -4132,7 +4132,7 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
   MDeformWeight *mdw = 
BKE_defvert_ensure_index(&me->dvert[vindex], dindex);
   MDeformWeight *gdw = 
BKE_defvert_ensure_index(&gps->dvert[sindex], gpdg);
   if (preserve_weight) {
-gdw->weight = mdw->weight;
+gdw->weight = MAX2(mdw->weight, gdw->weight);
   }
   else {
 if (mdw->weight > 0.999f) {

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


[Bf-blender-cvs] [9eefbdfc510] lanpr-under-gp: LineArt: Smooth weight option.

2020-10-02 Thread YimingWu
Commit: 9eefbdfc510163022d5cac4e3f573cf96ef093ce
Author: YimingWu
Date:   Sat Oct 3 12:15:30 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB9eefbdfc510163022d5cac4e3f573cf96ef093ce

LineArt: Smooth weight option.

===

M   source/blender/editors/lineart/lineart_cpu.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index 90a8f946135..872c37e5d4e 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -4040,6 +4040,7 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
   int enabled_types = lineart_rb_line_types(rb);
   bool invert_input = modifier_flags & LRT_GPENCIL_INVERT_SOURCE_VGROUP;
   bool match_output = modifier_flags & LRT_GPENCIL_MATCH_OUTPUT_VGROUP;
+  bool preserve_weight = modifier_flags & LRT_GPENCIL_SOFT_SELECTION;
 
   LISTBASE_FOREACH (LineartRenderLineChain *, rlc, &rb->chains) {
 
@@ -4129,9 +4130,14 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
 break;
   }
   MDeformWeight *mdw = 
BKE_defvert_ensure_index(&me->dvert[vindex], dindex);
-  if (mdw->weight > 0.999f) {
-MDeformWeight *gdw = 
BKE_defvert_ensure_index(&gps->dvert[sindex], gpdg);
-gdw->weight = 1.0f;
+  MDeformWeight *gdw = 
BKE_defvert_ensure_index(&gps->dvert[sindex], gpdg);
+  if (preserve_weight) {
+gdw->weight = mdw->weight;
+  }
+  else {
+if (mdw->weight > 0.999f) {
+  gdw->weight = 1.0f;
+}
   }
   sindex++;
 }
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index a456607a19e..2238dde14b7 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -433,6 +433,8 @@ static void vgroup_panel_draw(const bContext *C, Panel 
*panel)
 
   uiLayoutSetPropSep(layout, true);
 
+  uiItemR(layout, ptr, "soft_selection", 0, NULL, ICON_NONE);
+
   row = uiLayoutRow(layout, true);
   uiItemR(row, ptr, "source_vertex_group", 0, "Source", ICON_GROUP_VERTEX);
   uiItemR(row, ptr, "invert_source_vertex_group", UI_ITEM_R_TOGGLE, "", 
ICON_ARROW_LEFTRIGHT);
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h 
b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 2345bd855be..fe1a4887782 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -806,6 +806,7 @@ typedef enum eLineartGpencilModifierSource {
 typedef enum eLineArtGPencilModifierFlags {
   LRT_GPENCIL_INVERT_SOURCE_VGROUP = (1 << 0),
   LRT_GPENCIL_MATCH_OUTPUT_VGROUP = (1 << 1),
+  LRT_GPENCIL_SOFT_SELECTION = (1 << 2),
 } eLineArtGPencilModifierFlags;
 
 typedef enum eLineartGpencilTransparencyFlags {
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c 
b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index e7049b420f7..5256c6e6ad2 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -314,9 +314,11 @@ RNA_GP_MOD_VGROUP_NAME_SET(Opacity, vgname);
 RNA_GP_MOD_VGROUP_NAME_SET(Lattice, vgname);
 RNA_GP_MOD_VGROUP_NAME_SET(Smooth, vgname);
 RNA_GP_MOD_VGROUP_NAME_SET(Hook, vgname);
+RNA_GP_MOD_VGROUP_NAME_SET(Tint, vgname);
 RNA_GP_MOD_VGROUP_NAME_SET(Offset, vgname);
 RNA_GP_MOD_VGROUP_NAME_SET(Armature, vgname);
 RNA_GP_MOD_VGROUP_NAME_SET(Texture, vgname);
+RNA_GP_MOD_VGROUP_NAME_SET(Lineart, vgname);
 
 #  undef RNA_GP_MOD_VGROUP_NAME_SET
 
@@ -1073,7 +1075,7 @@ static void rna_def_modifier_gpenciltint(BlenderRNA *brna)
   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
   RNA_def_property_string_sdna(prop, NULL, "vgname");
   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for 
modulating the deform");
-  RNA_def_property_string_funcs(prop, NULL, NULL, 
"rna_HookGpencilModifier_vgname_set");
+  RNA_def_property_string_funcs(prop, NULL, NULL, 
"rna_TintGpencilModifier_vgname_set");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
@@ -2406,6 +2408,7 @@ static void rna_def_modifier_gpencillineart(BlenderRNA 
*brna)
 
   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
   RNA_def_property_string_sdna(prop, NULL, "vgname");
+  RNA_def_property_string_

[Bf-blender-cvs] [c28f0e55c1f] lanpr-under-gp: LineArt: Option for matching input/output vertex group names.

2020-10-02 Thread YimingWu
Commit: c28f0e55c1f0892e1557589bd6c23625736815ac
Author: YimingWu
Date:   Sat Oct 3 11:34:35 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rBc28f0e55c1f0892e1557589bd6c23625736815ac

LineArt: Option for matching input/output vertex group names.

===

M   source/blender/editors/include/ED_lineart.h
M   source/blender/editors/lineart/lineart_cpu.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/editors/include/ED_lineart.h 
b/source/blender/editors/include/ED_lineart.h
index 43b571eb403..7d30b082f7d 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -620,7 +620,7 @@ void ED_lineart_gpencil_generate_from_chain(struct 
Depsgraph *depsgraph,
 float pre_sample_length,
 const char *source_vgname,
 const char *vgname,
-bool invert_source);
+int modifier_flags);
 void ED_lineart_gpencil_generate_strokes_direct(struct Depsgraph *depsgraph,
 struct Object *ob,
 struct bGPDlayer *gpl,
@@ -638,7 +638,7 @@ void ED_lineart_gpencil_generate_strokes_direct(struct 
Depsgraph *depsgraph,
 float pre_sample_length,
 const char *source_vgname,
 const char *vgname,
-bool invert_source);
+int modifier_flags);
 
 struct bContext;
 
diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index d02ba32c3b3..2fc5dc13546 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -3999,7 +3999,7 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
 float pre_sample_length,
 const char *source_vgname,
 const char *vgname,
-bool invert_source)
+int modifier_flags)
 {
   LineartRenderBuffer *rb = lineart_share.render_buffer_shared;
 
@@ -4038,6 +4038,8 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
   unit_m4(mat);
 
   int enabled_types = lineart_rb_line_types(rb);
+  bool invert_input = modifier_flags & LRT_GPENCIL_INVERT_SOURCE_VGROUP;
+  bool match_output = modifier_flags & LRT_GPENCIL_MATCH_OUTPUT_VGROUP;
 
   LISTBASE_FOREACH (LineartRenderLineChain *, rlc, &rb->chains) {
 
@@ -4100,32 +4102,39 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
 if (source_vgname && vgname) {
   Object *eval_ob = DEG_get_evaluated_object(depsgraph, rlc->object_ref);
   int gpdg = -1;
-  if ((gpdg = BKE_object_defgroup_name_index(gpencil_object, vgname)) >= 
0) {
-if (eval_ob->type == OB_MESH) {
-  int dindex = 0;
-  Mesh *me = (Mesh *)eval_ob->data;
-  if (!me->dvert) {
-continue;
-  }
-  LISTBASE_FOREACH (bDeformGroup *, db, &eval_ob->defbase) {
-if (strstr(db->name, source_vgname) == db->name) {
-  int sindex = 0, vindex;
-  LISTBASE_FOREACH (LineartRenderLineChainItem *, rlci, 
&rlc->chain) {
-vindex = rlci->index;
-/* XXX: Here doesn't have post-modifier dvert! */
-if (vindex >= me->totvert) {
-  break;
-}
-MDeformWeight *mdw = 
BKE_defvert_ensure_index(&me->dvert[vindex], dindex);
-if (mdw->weight > 0.999f) {
-  MDeformWeight *gdw = 
BKE_defvert_ensure_index(&gps->dvert[sindex], gpdg);
-  gdw->weight = 1.0f;
-}
-sindex++;
+  if ((!match_output) && (gpdg = 
BKE_object_defgroup_name_index(gpencil_object, vgname)) < 0) {
+continue;
+  }
+  if (eval_ob->type == OB_MESH) {
+int dindex = 0;
+Mesh *me = (Mesh *)eval_ob->data;
+if (!me->dvert) {
+  continue;
+}
+LISTBASE_FOREACH (bDeformGroup *, db, &eval_ob->defbase) {
+  if (strstr(db->name, source_vgname) == db->name) {
+if (match_output) {
+  gpdg = BKE_object_defgroup_name_index(gpencil_object, db->name);
+ 

[Bf-blender-cvs] [bb231515e59] lanpr-under-gp: LineArt: Fix uncaught memory leak in stroke generation.

2020-10-02 Thread YimingWu
Commit: bb231515e59c341bde5624cae1b7f4c74e1c2712
Author: YimingWu
Date:   Sat Oct 3 11:38:21 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rBbb231515e59c341bde5624cae1b7f4c74e1c2712

LineArt: Fix uncaught memory leak in stroke generation.

===

M   source/blender/editors/lineart/lineart_cpu.c

===

diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index 2fc5dc13546..90a8f946135 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -4099,6 +4099,8 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
 BKE_gpencil_dvert_ensure(gps);
 gps->mat_nr = material_nr;
 
+MEM_freeN(stroke_data);
+
 if (source_vgname && vgname) {
   Object *eval_ob = DEG_get_evaluated_object(depsgraph, rlc->object_ref);
   int gpdg = -1;
@@ -4146,7 +4148,6 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
   BKE_gpencil_stroke_set_random_color(gps);
 }
 BKE_gpencil_stroke_geometry_update(gps);
-MEM_freeN(stroke_data);
 stroke_count++;
   }

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


[Bf-blender-cvs] [6d53c218de7] lanpr-under-gp: Merge remote-tracking branch 'origin/master' into lanpr-under-gp

2020-10-02 Thread YimingWu
Commit: 6d53c218de766ec67f92cdaf2ff1af767a407d8b
Author: YimingWu
Date:   Sat Oct 3 10:57:52 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB6d53c218de766ec67f92cdaf2ff1af767a407d8b

Merge remote-tracking branch 'origin/master' into lanpr-under-gp

===



===

diff --cc source/blender/editors/space_buttons/buttons_context.c
index 4486e767db9,fabccecd533..b3a5b39ce7a
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@@ -842,15 -814,11 +844,15 @@@ int /*eContextResult*/ buttons_context(
}
if (CTX_data_equals(member, "world")) {
  set_pointer_type(path, result, &RNA_World);
- return 1;
+ return CTX_RESULT_OK;
}
 +  if (CTX_data_equals(member, "collection")) {
 +set_pointer_type(path, result, &RNA_Collection);
 +return 1;
 +  }
if (CTX_data_equals(member, "object")) {
  set_pointer_type(path, result, &RNA_Object);
- return 1;
+ return CTX_RESULT_OK;
}
if (CTX_data_equals(member, "mesh")) {
  set_pointer_type(path, result, &RNA_Mesh);

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


[Bf-blender-cvs] [29a85682a03] master: Fix stack use after scope error after recent cleanup

2020-10-02 Thread Hans Goudey
Commit: 29a85682a0395f599f0500216061d4302493e800
Author: Hans Goudey
Date:   Fri Oct 2 21:24:09 2020 -0500
Branches: master
https://developer.blender.org/rB29a85682a0395f599f0500216061d4302493e800

Fix stack use after scope error after recent cleanup

An error adding search to an existing button,
caused by my own error in rBa4aa94c41cb79e9.

===

M   source/blender/editors/interface/interface_layout.c

===

diff --git a/source/blender/editors/interface/interface_layout.c 
b/source/blender/editors/interface/interface_layout.c
index a4b6004687f..8854ab4235b 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2658,10 +2658,10 @@ uiBut *ui_but_add_search(
 uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, 
PropertyRNA *searchprop)
 {
   /* for ID's we do automatic lookup */
+  PointerRNA sptr;
   if (!searchprop) {
 if (RNA_property_type(prop) == PROP_POINTER) {
   StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
-  PointerRNA sptr;
   search_id_collection(ptype, &sptr, &searchprop);
   searchptr = &sptr;
 }

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


[Bf-blender-cvs] [607c7fc4170] cycles_procedural_api: fix for missing detection of required mesh tesselation

2020-10-02 Thread Kévin Dietrich
Commit: 607c7fc417050a56b2b351937977363ed060f224
Author: Kévin Dietrich
Date:   Sat Oct 3 00:11:45 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB607c7fc417050a56b2b351937977363ed060f224

fix for missing detection of required mesh tesselation

===

M   intern/cycles/render/geometry.cpp

===

diff --git a/intern/cycles/render/geometry.cpp 
b/intern/cycles/render/geometry.cpp
index 5c519da856e..de063cea733 100644
--- a/intern/cycles/render/geometry.cpp
+++ b/intern/cycles/render/geometry.cpp
@@ -1275,7 +1275,7 @@ void GeometryManager::device_update(Device *device,
 
 /* Test if we need tessellation. */
 if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && 
mesh->num_subd_verts == 0 &&
-mesh->subd_params) {
+mesh->get_subd_params()) {
   total_tess_needed++;
 }
 
@@ -1310,7 +1310,7 @@ void GeometryManager::device_update(Device *device,
 
   Mesh *mesh = static_cast(geom);
   if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && 
mesh->num_subd_verts == 0 &&
-  mesh->subd_params) {
+  mesh->get_subd_params()) {
 string msg = "Tessellating ";
 if (mesh->name == "")
   msg += string_printf("%u/%u", (uint)(i + 1), 
(uint)total_tess_needed);

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


[Bf-blender-cvs] [8d0e620bafe] cycles_procedural_api: quiet introduced warnings

2020-10-02 Thread Kévin Dietrich
Commit: 8d0e620bafef3f69b190aca8c67fc0cb3ef13fdf
Author: Kévin Dietrich
Date:   Fri Oct 2 05:10:35 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB8d0e620bafef3f69b190aca8c67fc0cb3ef13fdf

quiet introduced warnings

===

M   intern/cycles/device/device_optix.cpp
M   intern/cycles/render/geometry.cpp

===

diff --git a/intern/cycles/device/device_optix.cpp 
b/intern/cycles/device/device_optix.cpp
index a868b46144c..45d332b9501 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -1260,7 +1260,9 @@ class OptiXDevice : public CUDADevice {
 
   for (size_t j = 0, i = 0; j < hair->num_curves(); ++j) {
 const Hair::Curve curve = hair->get_curve(j);
+#  if OPTIX_ABI_VERSION >= 36
 const array &curve_radius = hair->get_curve_radius();
+#  endif
 
 for (int segment = 0; segment < curve.num_segments(); ++segment, 
++i) {
 #  if OPTIX_ABI_VERSION >= 36
diff --git a/intern/cycles/render/geometry.cpp 
b/intern/cycles/render/geometry.cpp
index 980ec607b2c..f7ccf858e09 100644
--- a/intern/cycles/render/geometry.cpp
+++ b/intern/cycles/render/geometry.cpp
@@ -58,7 +58,7 @@ NODE_ABSTRACT_DEFINE(Geometry)
 }
 
 Geometry::Geometry(const NodeType *node_type, const Type type)
-: Node(node_type), geometry_type(type), attributes(this, 
ATTR_PRIM_GEOMETRY)
+: Node(node_type), attributes(this, ATTR_PRIM_GEOMETRY), 
geometry_type(type)
 {
   need_update_rebuild = false;

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


[Bf-blender-cvs] [0d5a53946a2] cycles_procedural_api: Mesh, fix typo in socket declaration for subd_shader

2020-10-02 Thread Kévin Dietrich
Commit: 0d5a53946a200f6c0804850f645c99feb5e6b0e3
Author: Kévin Dietrich
Date:   Fri Oct 2 23:09:22 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB0d5a53946a200f6c0804850f645c99feb5e6b0e3

Mesh, fix typo in socket declaration for subd_shader

===

M   intern/cycles/render/mesh.cpp

===

diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index e13ff32c9a2..a6f3d3abcb5 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -146,7 +146,7 @@ NODE_DEFINE(Mesh)
   SOCKET_INT_ARRAY(subd_face_corners, "Subdivision Face Corners", 
array());
   SOCKET_INT_ARRAY(subd_start_corner, "Subdivision Face Start Corner", 
array());
   SOCKET_INT_ARRAY(subd_num_corners, "Subdivision Face Corner Count", 
array());
-  SOCKET_INT_ARRAY(subd_face_corners, "Subdivision Face Shader", array());
+  SOCKET_INT_ARRAY(subd_shader, "Subdivision Face Shader", array());
   SOCKET_BOOLEAN_ARRAY(subd_smooth, "Subdivision Face Smooth", array());
   SOCKET_INT_ARRAY(subd_ptex_offset, "Subdivision Face PTex Offset", 
array());
   SOCKET_INT(num_ngons, "NGons Number", 0);

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


[Bf-blender-cvs] [b2c708f7109] cycles_procedural_api: preserve number of subd faces when copying mesh data, needs a better way...

2020-10-02 Thread Kévin Dietrich
Commit: b2c708f71097ea9af195e018609d98bac5607edd
Author: Kévin Dietrich
Date:   Fri Oct 2 23:47:44 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBb2c708f71097ea9af195e018609d98bac5607edd

preserve number of subd faces when copying mesh data, needs a better
way...

===

M   intern/cycles/blender/blender_mesh.cpp
M   intern/cycles/render/mesh.h

===

diff --git a/intern/cycles/blender/blender_mesh.cpp 
b/intern/cycles/blender/blender_mesh.cpp
index 4be8d9a723f..4cf5d08080a 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1077,6 +1077,7 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph,
 mesh->subd_attributes.attributes.push_back(std::move(attr));
   }
 
+  mesh->set_num_subd_faces(new_mesh.get_num_subd_faces());
   mesh->set_time_stamp(b_depsgraph.scene().frame_current());
 
   /* tag update */
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index 52e04ac0941..989f96967f9 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -243,6 +243,11 @@ class Mesh : public Geometry {
 return num_subd_faces;
   }
 
+  void set_num_subd_faces(size_t num_subd_faces_)
+  {
+num_subd_faces = num_subd_faces_;
+  }
+
   size_t get_num_subd_verts()
   {
 return num_subd_verts;

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


[Bf-blender-cvs] [e3f27ea93f3] cycles_procedural_api: fix typo in mesh tesselation causing an infinite loop

2020-10-02 Thread Kévin Dietrich
Commit: e3f27ea93f3a13621620f655f587897398fc8d5e
Author: Kévin Dietrich
Date:   Sat Oct 3 03:25:59 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBe3f27ea93f3a13621620f655f587897398fc8d5e

fix typo in mesh tesselation causing an infinite loop

===

M   intern/cycles/render/mesh_subdivision.cpp

===

diff --git a/intern/cycles/render/mesh_subdivision.cpp 
b/intern/cycles/render/mesh_subdivision.cpp
index 7b93bbffbe1..2c2f3e3f6b9 100644
--- a/intern/cycles/render/mesh_subdivision.cpp
+++ b/intern/cycles/render/mesh_subdivision.cpp
@@ -50,7 +50,7 @@ bool 
TopologyRefinerFactory::resizeComponentTopology(TopologyRefiner
   setNumBaseFaces(refiner, mesh.get_num_subd_faces());
 
   for (int i = 0; i < mesh.get_num_subd_faces(); i++) {
-setNumBaseFaceVertices(refiner, i, mesh.get_subd_face_corners()[i]);
+setNumBaseFaceVertices(refiner, i, mesh.get_subd_num_corners()[i]);
   }
 
   return true;

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


[Bf-blender-cvs] [809a2d02647] cycles_procedural_api: cleanup, rename num_subd_faces get_num_subd_faces

2020-10-02 Thread Kévin Dietrich
Commit: 809a2d02647d7583231cdf818b182ac172724e7d
Author: Kévin Dietrich
Date:   Fri Oct 2 23:33:08 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB809a2d02647d7583231cdf818b182ac172724e7d

cleanup, rename num_subd_faces get_num_subd_faces

===

M   intern/cycles/blender/blender_mesh.cpp
M   intern/cycles/render/attribute.cpp
M   intern/cycles/render/geometry.cpp
M   intern/cycles/render/mesh.cpp
M   intern/cycles/render/mesh.h
M   intern/cycles/render/mesh_subdivision.cpp
M   intern/cycles/subd/subd_split.cpp

===

diff --git a/intern/cycles/blender/blender_mesh.cpp 
b/intern/cycles/blender/blender_mesh.cpp
index 7ba6d07002e..f4d814c68db 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -48,7 +48,7 @@ struct MikkUserData {
float *tangent_sign)
   : mesh(mesh), texface(NULL), orco(NULL), tangent(tangent), 
tangent_sign(tangent_sign)
   {
-const AttributeSet &attributes = (mesh->num_subd_faces()) ? 
mesh->subd_attributes :
+const AttributeSet &attributes = (mesh->get_num_subd_faces()) ? 
mesh->subd_attributes :
 
mesh->attributes;
 
 Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
@@ -85,8 +85,8 @@ struct MikkUserData {
 static int mikk_get_num_faces(const SMikkTSpaceContext *context)
 {
   const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
-  if (userdata->mesh->num_subd_faces()) {
-return userdata->mesh->num_subd_faces();
+  if (userdata->mesh->get_num_subd_faces()) {
+return userdata->mesh->get_num_subd_faces();
   }
   else {
 return userdata->mesh->num_triangles();
@@ -96,7 +96,7 @@ static int mikk_get_num_faces(const SMikkTSpaceContext 
*context)
 static int mikk_get_num_verts_of_face(const SMikkTSpaceContext *context, const 
int face_num)
 {
   const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
-  if (userdata->mesh->num_subd_faces()) {
+  if (userdata->mesh->get_num_subd_faces()) {
 const Mesh *mesh = userdata->mesh;
 return mesh->get_subd_num_corners()[face_num];
   }
@@ -107,7 +107,7 @@ static int mikk_get_num_verts_of_face(const 
SMikkTSpaceContext *context, const i
 
 static int mikk_vertex_index(const Mesh *mesh, const int face_num, const int 
vert_num)
 {
-  if (mesh->num_subd_faces()) {
+  if (mesh->get_num_subd_faces()) {
 const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
 return mesh->get_subd_face_corners()[face.start_corner + vert_num];
   }
@@ -118,7 +118,7 @@ static int mikk_vertex_index(const Mesh *mesh, const int 
face_num, const int ver
 
 static int mikk_corner_index(const Mesh *mesh, const int face_num, const int 
vert_num)
 {
-  if (mesh->num_subd_faces()) {
+  if (mesh->get_num_subd_faces()) {
 const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
 return face.start_corner + vert_num;
   }
@@ -178,7 +178,7 @@ static void mikk_get_normal(const SMikkTSpaceContext 
*context,
   const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
   const Mesh *mesh = userdata->mesh;
   float3 vN;
-  if (mesh->num_subd_faces()) {
+  if (mesh->get_num_subd_faces()) {
 const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
 if (face.smooth) {
   const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
@@ -222,7 +222,7 @@ static void mikk_compute_tangents(
 const BL::Mesh &b_mesh, const char *layer_name, Mesh *mesh, bool 
need_sign, bool active_render)
 {
   /* Create tangent attributes. */
-  AttributeSet &attributes = (mesh->num_subd_faces()) ? mesh->subd_attributes 
: mesh->attributes;
+  AttributeSet &attributes = (mesh->get_num_subd_faces()) ? 
mesh->subd_attributes : mesh->attributes;
   Attribute *attr;
   ustring name;
   if (layer_name != NULL) {
diff --git a/intern/cycles/render/attribute.cpp 
b/intern/cycles/render/attribute.cpp
index c723c29b3d6..37b98909d78 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -191,7 +191,7 @@ size_t Attribute::element_size(Geometry *geom, 
AttributePrimitive prim) const
   size = mesh->num_triangles();
 }
 else {
-  size = mesh->num_subd_faces() + mesh->get_num_ngons();
+  size = mesh->get_num_subd_faces() + mesh->get_num_ngons();
 }
   }
   break;
diff --git a/intern/cycles/render/geometry.cpp 
b/intern/cycles/render/geometry.cpp
index 6a4bf0e7d6b..5c519da856e 100644
--- a/intern/cycles/render/geometry.cpp
+++ b/intern/cycles/render/geometry.cpp
@@ -442,7 +442,7 @@ void GeometryManager::update_svm_attributes(Device *,
 
   if (geom->is_mesh()) {
 Mesh *mesh = static_cast(geom);
-if (mesh->num_subd_faces()) {
+if (mesh->get_num_subd_faces()) {
   

[Bf-blender-cvs] [2221c24067f] cycles_procedural_api: attempt to read normals

2020-10-02 Thread Kévin Dietrich
Commit: 2221c24067f0ecbaa0a8c0b49e77ac2751b5bb04
Author: Kévin Dietrich
Date:   Mon Sep 28 15:40:08 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB2221c24067f0ecbaa0a8c0b49e77ac2751b5bb04

attempt to read normals

===

M   intern/cycles/render/alembic.cpp

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index e6559583c87..fc9ab763ed4 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -108,6 +108,73 @@ static void read_default_uvs(const IV2fGeomParam &uvs,
   }
 }
 
+static void read_default_normals(const IN3fGeomParam &normals,
+ const ISampleSelector &iss,
+ AlembicObject::DataCache &data_cache)
+{
+  switch (normals.getScope()) {
+case kFacevaryingScope: {
+  IN3fGeomParam::Sample sample = normals.getExpandedValue(iss);
+
+  if (!sample.valid()) {
+return;
+  }
+
+  AlembicObject::AttributeData &attr = 
data_cache.attributes.emplace_back();
+  attr.std = ATTR_STD_VERTEX_NORMAL;
+  attr.name = normals.getName();
+  attr.data.resize(data_cache.vertices.size() * sizeof(float3));
+
+  float3 *data_float3 = reinterpret_cast(attr.data.data());
+
+  for (size_t i = 0; i < data_cache.vertices.size(); ++i) {
+data_float3[i] = make_float3(0.0f);
+  }
+
+  const Imath::V3f *values = sample.getVals()->get();
+
+  for (const int3 &tri : data_cache.triangles) {
+const Imath::V3f &v0 = values[tri.x];
+const Imath::V3f &v1 = values[tri.y];
+const Imath::V3f &v2 = values[tri.z];
+
+data_float3[tri.x] += make_float3_from_yup(v0);
+data_float3[tri.y] += make_float3_from_yup(v1);
+data_float3[tri.z] += make_float3_from_yup(v2);
+  }
+
+  break;
+}
+case kVaryingScope:
+case kVertexScope: {
+  IN3fGeomParam::Sample sample = normals.getExpandedValue(iss);
+
+  if (!sample.valid()) {
+return;
+  }
+
+  AlembicObject::AttributeData &attr = 
data_cache.attributes.emplace_back();
+  attr.std = ATTR_STD_VERTEX_NORMAL;
+  attr.name = normals.getName();
+  attr.data.resize(data_cache.vertices.size() * sizeof(float3));
+
+  float3 *data_float3 = reinterpret_cast(attr.data.data());
+
+  const Imath::V3f *values = sample.getVals()->get();
+
+  for (size_t i = 0; i < data_cache.vertices.size(); ++i) {
+data_float3[i] = make_float3_from_yup(values[i]);
+  }
+
+  break;
+}
+default: {
+  // not supported
+  break;
+}
+  }
+}
+
 NODE_DEFINE(AlembicObject)
 {
   NodeType *type = NodeType::add("alembic_object", create);
@@ -228,6 +295,12 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
   read_default_uvs(uvs, iss, data_cache);
 }
 
+//const IN3fGeomParam &normals = schema.getNormalsParam();
+
+//if (normals.valid()) {
+//  read_default_normals(normals, iss, data_cache);
+//}
+
 foreach (const AttributeRequest &attr, requested_attributes.requests) {
   read_attribute(schema.getArbGeomParams(), iss, attr.name, data_cache);
 }
@@ -551,9 +624,6 @@ void AlembicProcedural::read_mesh(Scene *scene,
 mesh->set_shader(shader);
   }
 
-  /* TODO: read normals from the archive if present */
-  mesh->add_face_normals();
-
   /* we don't yet support arbitrary attributes, for now add vertex
* coordinates as generated coordinates if requested */
   if (mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
@@ -575,6 +645,9 @@ void AlembicProcedural::read_mesh(Scene *scene,
 memcpy(attr->data(), attribute.data.data(), attribute.data.size());
   }
 
+  /* TODO: read normals from the archive if present */
+  mesh->add_face_normals();
+
   if (mesh->is_modified()) {
 // TODO : check for modification of subdivision data (is a separate object 
in Alembic)
 bool need_rebuild = mesh->triangles_is_modified();

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


[Bf-blender-cvs] [6bc78f071ce] cycles_procedural_api: Merge branch 'master' into cycles_procedural_api

2020-10-02 Thread Kévin Dietrich
Commit: 6bc78f071ced44734534b1356febbc85a1414606
Author: Kévin Dietrich
Date:   Fri Oct 2 05:02:40 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB6bc78f071ced44734534b1356febbc85a1414606

Merge branch 'master' into cycles_procedural_api

===



===

diff --cc intern/cycles/render/background.cpp
index 9769ec464ca,d2463454522..7bdcb1578c3
--- a/intern/cycles/render/background.cpp
+++ b/intern/cycles/render/background.cpp
@@@ -61,9 -64,15 +63,15 @@@ Background::~Background(
  
  void Background::device_update(Device *device, DeviceScene *dscene, Scene 
*scene)
  {
 -  if (!need_update)
 +  if (!is_modified())
  return;
  
+   scoped_callback_timer timer([scene](double time) {
+ if (scene->update_stats) {
+   scene->update_stats->background.times.add_entry({"device_update", 
time});
+ }
+   });
+ 
device_free(device, dscene);
  
Shader *bg_shader = get_shader(scene);
diff --cc intern/cycles/render/camera.cpp
index ebfa6ff02ca,ee68c9ede22..599685b4bc9
--- a/intern/cycles/render/camera.cpp
+++ b/intern/cycles/render/camera.cpp
@@@ -237,9 -230,15 +239,15 @@@ void Camera::update(Scene *scene
  need_device_update = true;
}
  
 -  if (!need_update)
 +  if (!is_modified())
  return;
  
+   scoped_callback_timer timer([scene](double time) {
+ if (scene->update_stats) {
+   scene->update_stats->camera.times.add_entry({"update", time});
+ }
+   });
+ 
/* Full viewport to camera border in the viewport. */
Transform fulltoborder = transform_from_viewplane(viewport_camera_border);
Transform bordertofull = transform_inverse(fulltoborder);
diff --cc intern/cycles/render/film.cpp
index c280a1ab8b5,e4c1e452bd5..53e7a341618
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@@ -424,9 -407,15 +426,15 @@@ void Film::add_default(Scene *scene
  
  void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
  {
 -  if (!need_update)
 +  if (!is_modified())
  return;
  
+   scoped_callback_timer timer([scene](double time) {
+ if (scene->update_stats) {
+   scene->update_stats->film.times.add_entry({"update", time});
+ }
+   });
+ 
device_free(device, dscene, scene);
  
KernelFilm *kfilm = &dscene->data.film;
diff --cc intern/cycles/render/geometry.cpp
index 5c43178ad73,d96dc15f400..6a4bf0e7d6b
--- a/intern/cycles/render/geometry.cpp
+++ b/intern/cycles/render/geometry.cpp
@@@ -1241,38 -1237,44 +1247,46 @@@ void GeometryManager::device_update(Dev
bool true_displacement_used = false;
size_t total_tess_needed = 0;
  
-   foreach (Geometry *geom, scene->geometry) {
- foreach (Node *node, geom->get_used_shaders()) {
-   Shader *shader = static_cast(node);
-   if (shader->need_update_geometry)
- geom->tag_modified();
- }
+   {
+ scoped_callback_timer timer([scene](double time) {
+   if (scene->update_stats) {
+ scene->update_stats->geometry.times.add_entry({"device_update 
(normals)", time});
+   }
+ });
  
- if (geom->is_modified() &&
- (geom->geometry_type == Geometry::MESH || geom->geometry_type == 
Geometry::VOLUME)) {
-   Mesh *mesh = static_cast(geom);
+ foreach (Geometry *geom, scene->geometry) {
 -  foreach (Shader *shader, geom->used_shaders) {
++  foreach (Node *node, geom->get_used_shaders()) {
++Shader *shader = static_cast(node);
+ if (shader->need_update_geometry)
 -  geom->need_update = true;
++  geom->tag_modified();
+   }
  
-   /* Update normals. */
-   mesh->add_face_normals();
-   mesh->add_vertex_normals();
 -  if (geom->need_update && (geom->type == Geometry::MESH || geom->type == 
Geometry::VOLUME)) {
++  if (geom->is_modified() &&
++  (geom->geometry_type == Geometry::MESH || geom->geometry_type == 
Geometry::VOLUME)) {
+ Mesh *mesh = static_cast(geom);
  
-   if (mesh->need_attribute(scene, ATTR_STD_POSITION_UNDISPLACED)) {
- mesh->add_undisplaced();
-   }
+ /* Update normals. */
+ mesh->add_face_normals();
+ mesh->add_vertex_normals();
  
-   /* Test if we need tessellation. */
-   if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && 
mesh->num_subd_verts == 0 &&
-   mesh->subd_params) {
- total_tess_needed++;
-   }
+ if (mesh->need_attribute(scene, ATTR_STD_POSITION_UNDISPLACED)) {
+   mesh->add_undisplaced();
+ }
  
-   /* Test if we need displacement. */
-   if (mesh->has_true_displacement()) {
- true_displacement_used = true;
-   }
+ /* Test if we need tessellation. */
+ if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE && 
mesh->num_subd_verts == 0 &&
+ mesh->subd_params) {
+   total_tess_needed++;
+ }
  
-   if (progres

[Bf-blender-cvs] [60a8c3970cc] cycles_procedural_api: fix for missing width and height on dicing camera

2020-10-02 Thread Kévin Dietrich
Commit: 60a8c3970ccc7a504eb94d52906e521a802bcafe
Author: Kévin Dietrich
Date:   Sat Oct 3 04:00:19 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB60a8c3970ccc7a504eb94d52906e521a802bcafe

fix for missing width and height on dicing camera

===

M   intern/cycles/render/geometry.cpp

===

diff --git a/intern/cycles/render/geometry.cpp 
b/intern/cycles/render/geometry.cpp
index de063cea733..980ec607b2c 100644
--- a/intern/cycles/render/geometry.cpp
+++ b/intern/cycles/render/geometry.cpp
@@ -1300,6 +1300,7 @@ void GeometryManager::device_update(Device *device,
 });
 
 Camera *dicing_camera = scene->dicing_camera;
+
dicing_camera->set_screen_size_and_resolution(dicing_camera->get_full_width(), 
dicing_camera->get_full_height(), 1);
 dicing_camera->update(scene);
 
 size_t i = 0;

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


[Bf-blender-cvs] [5fca35e4942] cycles_procedural_api: fix data type for vertex colors

2020-10-02 Thread Kévin Dietrich
Commit: 5fca35e49421844854647fb655a918d5123be483
Author: Kévin Dietrich
Date:   Mon Sep 28 14:56:56 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB5fca35e49421844854647fb655a918d5123be483

fix data type for vertex colors

===

M   intern/cycles/render/alembic.cpp

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 403b2fa62b3..1b60540ba27 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -293,7 +293,7 @@ void AlembicObject::read_attribute(const ICompoundProperty 
&arb_geom_params,
 
   if (param.getScope() == kVaryingScope) {
 attribute.element = ATTR_ELEMENT_CORNER_BYTE;
-attribute.type_desc = TypeDesc::TypeColor;
+attribute.type_desc = TypeRGBA;
 attribute.data.resize(data_cache.triangles.size() * 3 * 
sizeof(uchar4));
 
 uchar4 *data_uchar4 = reinterpret_cast(attribute.data.data());

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


[Bf-blender-cvs] [3c341523348] cycles_procedural_api: fix crash dereferencing nul pointer

2020-10-02 Thread Kévin Dietrich
Commit: 3c3415233481306072f154db1d33b89ec2d13bb2
Author: Kévin Dietrich
Date:   Fri Oct 2 23:38:10 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB3c3415233481306072f154db1d33b89ec2d13bb2

fix crash dereferencing nul pointer

===

M   intern/cycles/blender/blender_mesh.cpp
M   intern/cycles/render/mesh.cpp
M   intern/cycles/render/mesh.h

===

diff --git a/intern/cycles/blender/blender_mesh.cpp 
b/intern/cycles/blender/blender_mesh.cpp
index f4d814c68db..4be8d9a723f 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -762,8 +762,11 @@ static void create_mesh(Scene *scene,
   }
 
   /* allocate memory */
+  if (subdivision) {
+mesh->reserve_subd_faces(numfaces, numngons, numcorners);
+  }
+
   mesh->reserve_mesh(numverts, numtris);
-  mesh->reserve_subd_faces(numfaces, numngons, numcorners);
 
   /* create vertex coordinates and normals */
   BL::Mesh::vertices_iterator v;
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index a7f88be4bd7..5786aeff22b 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -186,6 +186,7 @@ Mesh::Mesh(const NodeType *node_type, Type geom_type_)
   corner_offset = 0;
 
   num_subd_verts = 0;
+  num_subd_faces = 0;
 
   num_ngons = 0;
 
@@ -245,6 +246,7 @@ void Mesh::resize_subd_faces(int numfaces, int num_ngons_, 
int numcorners)
   subd_ptex_offset.resize(numfaces);
   subd_face_corners.resize(numcorners);
   num_ngons = num_ngons_;
+  num_subd_faces = numfaces;
 
   subd_attributes.resize();
 }
@@ -258,6 +260,7 @@ void Mesh::reserve_subd_faces(int numfaces, int num_ngons_, 
int numcorners)
   subd_ptex_offset.reserve(numfaces);
   subd_face_corners.reserve(numcorners);
   num_ngons = num_ngons_;
+  num_subd_faces = numfaces;
 
   subd_attributes.resize(true);
 }
@@ -289,6 +292,7 @@ void Mesh::clear(bool preserve_voxel_data)
   subd_face_corners.clear();
 
   num_subd_verts = 0;
+  num_subd_faces = 0;
 
   subd_creases_edge.clear();
   subd_creases_weight.clear();
@@ -358,9 +362,9 @@ void Mesh::add_subd_face(int *corners, int num_corners, int 
shader_, bool smooth
   }
 
   int ptex_offset = 0;
-
-  if (get_num_subd_faces()) {
-SubdFace s = get_subd_face(get_num_subd_faces() - 1);
+  // cannot use get_num_subd_faces here as it holds the total number of 
subd_faces, but we do not have the total amount of data yet
+  if (subd_shader.size()) {
+SubdFace s = get_subd_face(subd_shader.size() - 1);
 ptex_offset = s.ptex_offset + s.num_ptex_faces();
   }
 
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index f00be5466f9..52e04ac0941 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -176,6 +176,7 @@ class Mesh : public Geometry {
   size_t corner_offset;
 
   size_t num_subd_verts;
+  size_t num_subd_faces;
 
   unordered_map vert_to_stitching_key_map; /* real vert index -> 
stitching index */
   unordered_multimap
@@ -239,7 +240,7 @@ class Mesh : public Geometry {
 
   size_t get_num_subd_faces() const
   {
-return subd_shader.size();
+return num_subd_faces;
   }
 
   size_t get_num_subd_verts()

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


[Bf-blender-cvs] [bbaa6a6728f] cycles_procedural_api: add support for RGBA attributes

2020-10-02 Thread Kévin Dietrich
Commit: bbaa6a6728fc7afa14114a106c2267ac6b3f9e3d
Author: Kévin Dietrich
Date:   Mon Sep 28 14:59:41 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBbbaa6a6728fc7afa14114a106c2267ac6b3f9e3d

add support for RGBA attributes

===

M   intern/cycles/render/alembic.cpp

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 1b60540ba27..e6559583c87 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -309,6 +309,40 @@ void AlembicObject::read_attribute(const ICompoundProperty 
&arb_geom_params,
   v = (*values)[tri.z];
   data_uchar4[offset + 2] = color_float_to_byte(make_float3(v.x, v.y, 
v.z));
 
+  offset += 3;
+}
+  }
+}
+else if (IC4fProperty::matches(prop.getMetaData())) {
+  const IC4fGeomParam ¶m = IC4fGeomParam(arb_geom_params, 
prop.getName());
+
+  IC4fGeomParam::Sample sample;
+  param.getIndexed(sample, iss);
+
+  C4fArraySamplePtr values = sample.getVals();
+
+  AttributeData &attribute = data_cache.attributes.emplace_back();
+  attribute.std = ATTR_STD_NONE;
+  attribute.name = attr_name;
+
+  if (param.getScope() == kVaryingScope) {
+attribute.element = ATTR_ELEMENT_CORNER_BYTE;
+attribute.type_desc = TypeRGBA;
+attribute.data.resize(data_cache.triangles.size() * 3 * 
sizeof(uchar4));
+
+uchar4 *data_uchar4 = reinterpret_cast(attribute.data.data());
+
+int offset = 0;
+for (const int3 &tri : data_cache.triangles) {
+  Imath::C4f v = (*values)[tri.x];
+  data_uchar4[offset + 0] = color_float4_to_uchar4(make_float4(v.r, 
v.g, v.b, v.a));
+
+  v = (*values)[tri.y];
+  data_uchar4[offset + 1] = color_float4_to_uchar4(make_float4(v.r, 
v.g, v.b, v.a));
+
+  v = (*values)[tri.z];
+  data_uchar4[offset + 2] = color_float4_to_uchar4(make_float4(v.r, 
v.g, v.b, v.a));
+
   offset += 3;
 }
   }

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


[Bf-blender-cvs] [40d1cbf354a] cycles_procedural_api: read UV attributes

2020-10-02 Thread Kévin Dietrich
Commit: 40d1cbf354a606bba8c424257fe1de9f6b1d5fa0
Author: Kévin Dietrich
Date:   Mon Sep 28 14:50:31 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB40d1cbf354a606bba8c424257fe1de9f6b1d5fa0

read UV attributes

===

M   intern/cycles/render/alembic.cpp
M   intern/cycles/render/alembic.h

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 1b5c7983363..1ad2d0bf4b8 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -66,52 +66,42 @@ static Transform make_transform(const Abc::M44d &a)
   return trans;
 }
 
-/* TODO: any attribute lookup should probably go through the AttributeRequests
- */
-static void read_uvs(const IV2fGeomParam &uvs,
- Geometry *node,
- const int *face_counts,
- const int num_faces)
+static void read_default_uvs(const IV2fGeomParam &uvs, const ISampleSelector 
&iss, AlembicObject::DataCache &data_cache)
 {
-  if (uvs.valid()) {
-switch (uvs.getScope()) {
-  case kVaryingScope:
-  case kVertexScope: {
-IV2fGeomParam::Sample uvsample = uvs.getExpandedValue();
-break;
-  }
-  case kFacevaryingScope: {
-IV2fGeomParam::Sample uvsample = uvs.getIndexedValue();
-
-ustring name = ustring("UVMap");
-Attribute *attr = node->attributes.add(ATTR_STD_UV, name);
-float2 *fdata = attr->data_float2();
-
-/* loop over the triangles */
-int index_offset = 0;
-const unsigned int *uvIndices = uvsample.getIndices()->get();
-const Imath::Vec2 *uvValues = uvsample.getVals()->get();
-
-for (size_t i = 0; i < num_faces; i++) {
-  for (int j = 0; j < face_counts[i] - 2; j++) {
-   unsigned int v0 = uvIndices[index_offset];
-   unsigned int v1 = uvIndices[index_offset + j + 1];
-   unsigned int v2 = uvIndices[index_offset + j + 2];
-
-fdata[0] = make_float2(uvValues[v0][0], uvValues[v0][1]);
-fdata[1] = make_float2(uvValues[v1][0], uvValues[v1][1]);
-fdata[2] = make_float2(uvValues[v2][0], uvValues[v2][1]);
-fdata += 3;
-  }
-
-  index_offset += face_counts[i];
-}
+  switch (uvs.getScope()) {
+case kFacevaryingScope: {
+  IV2fGeomParam::Sample uvsample = uvs.getIndexedValue(iss);
 
-break;
+  if (!uvsample.valid()) {
+return;
   }
-  default: {
-break;
+
+  AlembicObject::AttributeData &attr = 
data_cache.attributes.emplace_back();
+  attr.std = ATTR_STD_UV;
+  attr.name = uvs.getName();
+  attr.data.resize(data_cache.triangles.size() * 3 * sizeof(float2));
+
+  float2 *data_float2 = reinterpret_cast(attr.data.data());
+
+  const unsigned int *indices = uvsample.getIndices()->get();
+  const Imath::Vec2 *values = uvsample.getVals()->get();
+
+  for (const int3 &loop : data_cache.triangles_loops) {
+unsigned int v0 = indices[loop.x];
+unsigned int v1 = indices[loop.y];
+unsigned int v2 = indices[loop.z];
+
+data_float2[0] = make_float2(values[v0][0], values[v0][1]);
+data_float2[1] = make_float2(values[v1][0], values[v1][1]);
+data_float2[2] = make_float2(values[v2][0], values[v2][1]);
+data_float2 += 3;
   }
+
+  break;
+}
+default: {
+  // not supported
+  break;
 }
   }
 }
@@ -212,6 +202,7 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
   }
 
   data_cache.triangles.reserve(num_triangles);
+  data_cache.triangles_loops.reserve(num_triangles);
   int index_offset = 0;
 
   for (size_t i = 0; i < num_faces; i++) {
@@ -221,12 +212,19 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
   int v2 = face_indices_array[index_offset + j + 2];
 
   data_cache.triangles.push_back_reserved(make_int3(v0, v1, v2));
+  
data_cache.triangles_loops.push_back_reserved(make_int3(index_offset, 
index_offset + j + 1, index_offset + j + 2));
 }
 
 index_offset += face_counts_array[i];
   }
 }
 
+const IV2fGeomParam &uvs = schema.getUVsParam();
+
+if (uvs.valid()) {
+  read_default_uvs(uvs, iss, data_cache);
+}
+
 foreach (const AttributeRequest &attr, requested_attributes.requests) {
   read_attribute(schema.getArbGeomParams(), iss, attr.name, data_cache);
 }
@@ -245,20 +243,35 @@ void AlembicObject::read_attribute(const 
ICompoundProperty &arb_geom_params, con
 }
 
 if (IV2fProperty::matches(prop.getMetaData()) && 
Alembic::AbcGeom::isUV(prop)) {
-  // TODO : UV indices
-//  const IV2fGeomParam ¶m = IV2fGeomParam(arb_geom_params, 
prop.getName());
+  const IV2fGeomParam ¶m = IV2fGeomParam(

[Bf-blender-cvs] [ff1a9a2e71c] cycles_procedural_api: remove Scene::update_procedurals in favor of using directly the ProceduralManager

2020-10-02 Thread Kévin Dietrich
Commit: ff1a9a2e71cc31e1b259d535118d8b2e5c99082e
Author: Kévin Dietrich
Date:   Tue Sep 29 18:41:31 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBff1a9a2e71cc31e1b259d535118d8b2e5c99082e

remove Scene::update_procedurals in favor of using directly the
ProceduralManager

===

M   intern/cycles/render/scene.cpp
M   intern/cycles/render/scene.h

===

diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index 14d64986d2b..4e8d8241431 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -216,7 +216,10 @@ void Scene::device_update(Device *device_, Progress 
&progress)
* - Lookup tables are done a second time to handle film tables
*/
 
-  update_procedurals(progress);
+  procedural_manager->update(this, progress);
+
+  if (progress.get_cancel())
+return;
 
   progress.set_status("Updating Shaders");
   shader_manager->device_update(device, &dscene, this, progress);
@@ -330,11 +333,6 @@ void Scene::device_update(Device *device_, Progress 
&progress)
   }
 }
 
-void Scene::update_procedurals(Progress &progress)
-{
-  procedural_manager->update(this, progress);
-}
-
 Scene::MotionType Scene::need_motion()
 {
   if (integrator->get_motion_blur())
@@ -476,7 +474,7 @@ bool Scene::update(Progress &progress, bool 
&kernel_switch_needed)
   if (need_update()) {
 /* Need to update the procedurals before tagging for used shaders as 
procedurals may create
  * geometry which is not in the scene yet. */
-update_procedurals(progress);
+procedural_manager->update(this, progress);
 
 /* Updated used shader tag so we know which features are need for the 
kernel. */
 shader_manager->update_shaders_used(this);
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index 2f7c5da5f0f..6d0fafc1205 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -321,8 +321,6 @@ class Scene : public NodeOwner {
 (void)owner;
   }
 
-  void update_procedurals(Progress &progress);
-
  protected:
   /* Check if some heavy data worth logging was updated.
* Mainly used to suppress extra annoying logging.

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


[Bf-blender-cvs] [2500f65b0b3] cycles_procedural_api: cleanup, format

2020-10-02 Thread Kévin Dietrich
Commit: 2500f65b0b365a447971b8e140f4218e010b8d73
Author: Kévin Dietrich
Date:   Mon Sep 28 14:53:57 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB2500f65b0b365a447971b8e140f4218e010b8d73

cleanup, format

===

M   intern/cycles/render/alembic.cpp
M   intern/cycles/render/alembic.h

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 1ad2d0bf4b8..403b2fa62b3 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -66,7 +66,9 @@ static Transform make_transform(const Abc::M44d &a)
   return trans;
 }
 
-static void read_default_uvs(const IV2fGeomParam &uvs, const ISampleSelector 
&iss, AlembicObject::DataCache &data_cache)
+static void read_default_uvs(const IV2fGeomParam &uvs,
+ const ISampleSelector &iss,
+ AlembicObject::DataCache &data_cache)
 {
   switch (uvs.getScope()) {
 case kFacevaryingScope: {
@@ -212,7 +214,8 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
   int v2 = face_indices_array[index_offset + j + 2];
 
   data_cache.triangles.push_back_reserved(make_int3(v0, v1, v2));
-  
data_cache.triangles_loops.push_back_reserved(make_int3(index_offset, 
index_offset + j + 1, index_offset + j + 2));
+  data_cache.triangles_loops.push_back_reserved(
+  make_int3(index_offset, index_offset + j + 1, index_offset + j + 
2));
 }
 
 index_offset += face_counts_array[i];
@@ -233,7 +236,10 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
   data_loaded = true;
 }
 
-void AlembicObject::read_attribute(const ICompoundProperty &arb_geom_params, 
const ISampleSelector &iss, const ustring &attr_name, DataCache &data_cache)
+void AlembicObject::read_attribute(const ICompoundProperty &arb_geom_params,
+   const ISampleSelector &iss,
+   const ustring &attr_name,
+   DataCache &data_cache)
 {
   for (size_t i = 0; i < arb_geom_params.getNumProperties(); ++i) {
 const PropertyHeader &prop = arb_geom_params.getPropertyHeader(i);
diff --git a/intern/cycles/render/alembic.h b/intern/cycles/render/alembic.h
index 0a894ab07bf..123f40e4d41 100644
--- a/intern/cycles/render/alembic.h
+++ b/intern/cycles/render/alembic.h
@@ -56,11 +56,11 @@ class AlembicObject : public Node {
   // TODO : handle attributes as well
 
   struct AttributeData {
-  AttributeStandard std;
-  AttributeElement element;
-  TypeDesc type_desc;
-  ustring name;
-  array data;
+AttributeStandard std;
+AttributeElement element;
+TypeDesc type_desc;
+ustring name;
+array data;
   };
 
   struct DataCache {
@@ -86,7 +86,10 @@ class AlembicObject : public Node {
 
   vector frame_data;
 
-  void read_attribute(const ICompoundProperty &arb_geom_params, const 
ISampleSelector &iss, const ustring &attr_name, DataCache &data_cache);
+  void read_attribute(const ICompoundProperty &arb_geom_params,
+  const ISampleSelector &iss,
+  const ustring &attr_name,
+  DataCache &data_cache);
 };
 
 class AlembicProcedural : public Procedural {

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


[Bf-blender-cvs] [b9d246d640e] cycles_procedural_api: prefer using AttributeElement over AttributeStandard

2020-10-02 Thread Kévin Dietrich
Commit: b9d246d640e86eeed943b2cfa93bc0d7af656190
Author: Kévin Dietrich
Date:   Mon Sep 28 14:49:54 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBb9d246d640e86eeed943b2cfa93bc0d7af656190

prefer using AttributeElement over AttributeStandard

===

M   intern/cycles/render/alembic.cpp
M   intern/cycles/render/alembic.h

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 63ebd1adcc0..1b5c7983363 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -269,10 +269,12 @@ void AlembicObject::read_attribute(const 
ICompoundProperty &arb_geom_params, con
   C3fArraySamplePtr values = sample.getVals();
 
   AttributeData &attribute = data_cache.attributes.emplace_back();
+  attribute.std = ATTR_STD_NONE;
   attribute.name = attr_name;
 
   if (param.getScope() == kVaryingScope) {
-attribute.std = ATTR_STD_VERTEX_COLOR;
+attribute.element = ATTR_ELEMENT_CORNER_BYTE;
+attribute.type_desc = TypeDesc::TypeColor;
 attribute.data.resize(data_cache.triangles.size() * 3 * 
sizeof(uchar4));
 
 uchar4 *data_uchar4 = reinterpret_cast(attribute.data.data());
@@ -512,8 +514,16 @@ void AlembicProcedural::read_mesh(Scene *scene,
   }
 
   for (const AlembicObject::AttributeData &attribute : data.attributes) {
-   Attribute *attr = mesh->attributes.add(attribute.std, attribute.name);
-memcpy(attr->data_uchar4(), attribute.data.data(), attribute.data.size());
+Attribute *attr = nullptr;
+if (attribute.std != ATTR_STD_NONE) {
+  attr = mesh->attributes.add(attribute.std, attribute.name);
+}
+else {
+  attr = mesh->attributes.add(attribute.name, attribute.type_desc, 
attribute.element);
+}
+assert(attr);
+
+memcpy(attr->data(), attribute.data.data(), attribute.data.size());
   }
 
   if (mesh->is_modified()) {
diff --git a/intern/cycles/render/alembic.h b/intern/cycles/render/alembic.h
index 4bb5d5960ec..fe9d45b4f16 100644
--- a/intern/cycles/render/alembic.h
+++ b/intern/cycles/render/alembic.h
@@ -57,6 +57,8 @@ class AlembicObject : public Node {
 
   struct AttributeData {
   AttributeStandard std;
+  AttributeElement element;
+  TypeDesc type_desc;
   ustring name;
   array data;
   };

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


[Bf-blender-cvs] [b49f0f990b5] cycles_procedural_api: first pass at reading arbitrary attributes

2020-10-02 Thread Kévin Dietrich
Commit: b49f0f990b51aefbf752fa998e61cfebaf801ca9
Author: Kévin Dietrich
Date:   Sun Sep 27 20:52:19 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBb49f0f990b51aefbf752fa998e61cfebaf801ca9

first pass at reading arbitrary attributes

For now, we only read vertex colors.

===

M   intern/cycles/render/alembic.cpp
M   intern/cycles/render/alembic.h

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 70e0053cdd8..58fbad0cf31 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -166,11 +166,27 @@ void AlembicObject::load_all_data(IPolyMeshSchema &schema)
   frame_data.clear();
 
   // TODO : store other properties and have a better structure to store these 
arrays
+  auto geometry_ = object->get_geometry();
+
+  AttributeRequestSet requested_attributes;
+
+  foreach (Node *node, geometry_->get_used_shaders()) {
+Shader *shader = static_cast(node);
+
+foreach (const AttributeRequest &attr, shader->attributes.requests) {
+  if (attr.name != "") {
+requested_attributes.add(attr.name);
+  }
+}
+  }
+
   for (size_t i = 0; i < schema.getNumSamples(); ++i) {
 frame_data.emplace_back();
 AlembicObject::DataCache &data_cache = frame_data.back();
 
-auto sample = schema.getValue(ISampleSelector(static_cast(i)));
+ISampleSelector iss = ISampleSelector(static_cast(i));
+
+auto sample = schema.getValue(iss);
 
 auto positions = sample.getPositions();
 
@@ -211,11 +227,75 @@ void AlembicObject::load_all_data(IPolyMeshSchema &schema)
 index_offset += face_counts_array[i];
   }
 }
+
+foreach (const AttributeRequest &attr, requested_attributes.requests) {
+  read_attribute(schema.getArbGeomParams(), iss, attr.name, data_cache);
+}
   }
 
   data_loaded = true;
 }
 
+void AlembicObject::read_attribute(const ICompoundProperty &arb_geom_params, 
const ISampleSelector &iss, const ustring &attr_name, DataCache &data_cache)
+{
+  for (size_t i = 0; i < arb_geom_params.getNumProperties(); ++i) {
+const PropertyHeader &prop = arb_geom_params.getPropertyHeader(i);
+
+if (prop.getName() != attr_name) {
+  continue;
+}
+
+if (IV2fProperty::matches(prop.getMetaData()) && 
Alembic::AbcGeom::isUV(prop)) {
+  // TODO : UV indices
+//  const IV2fGeomParam ¶m = IV2fGeomParam(arb_geom_params, 
prop.getName());
+
+//  IV2fGeomParam::Sample sample;
+//  param.getIndexed(sample, iss);
+
+//  if (param.getScope() == kFacevaryingScope) {
+//V2fArraySamplePtr values = sample.getVals();
+//UInt32ArraySamplePtr indices = sample.getIndices();
+
+//AttributeData &attribute = data_cache.attributes.emplace_back();
+//attribute.name = attr_name;
+//attribute.std = ATTR_STD_UV;
+//  }
+}
+else if (IC3fProperty::matches(prop.getMetaData())) {
+  const IC3fGeomParam ¶m = IC3fGeomParam(arb_geom_params, 
prop.getName());
+
+  IC3fGeomParam::Sample sample;
+  param.getIndexed(sample, iss);
+
+  C3fArraySamplePtr values = sample.getVals();
+
+  AttributeData &attribute = data_cache.attributes.emplace_back();
+  attribute.name = attr_name;
+
+  if (param.getScope() == kVaryingScope) {
+attribute.std = ATTR_STD_VERTEX_COLOR;
+attribute.data.resize(data_cache.triangles.size() * 3 * 
sizeof(uchar4));
+
+uchar4 *data_uchar4 = reinterpret_cast(attribute.data.data());
+
+int offset = 0;
+for (const int3 &tri : data_cache.triangles) {
+  auto v = (*values)[tri.x];
+  data_uchar4[offset + 0] = color_float_to_byte(make_float3(v.x, v.y, 
v.z));
+
+  v = (*values)[tri.y];
+  data_uchar4[offset + 1] = color_float_to_byte(make_float3(v.x, v.y, 
v.z));
+
+  v = (*values)[tri.z];
+  data_uchar4[offset + 2] = color_float_to_byte(make_float3(v.x, v.y, 
v.z));
+
+  offset += 3;
+}
+  }
+}
+  }
+}
+
 NODE_DEFINE(AlembicProcedural)
 {
   NodeType *type = NodeType::add("alembic", create);
@@ -432,6 +512,11 @@ void AlembicProcedural::read_mesh(Scene *scene,
 attr->data_float3(), mesh->get_verts().data(), sizeof(float3) * 
mesh->get_verts().size());
   }
 
+  for (const AlembicObject::AttributeData &attribute : data.attributes) {
+auto attr = mesh->attributes.add(attribute.std, attribute.name);
+memcpy(attr->data_uchar4(), attribute.data.data(), attribute.data.size());
+  }
+
   if (mesh->is_modified()) {
 // TODO : check for modification of subdivision data (is a separate object 
in Alembic)
 bool need_rebuild = mesh->triangles_is_modified();
diff --git a/intern/cycles/render/alembic.h b/intern/cycles/render/alembic.h
index 52cd2dc59cf..14e98765b29 100644
--- a/intern/cycles/render/alembic.h
+++ b/intern/cycles/render/ale

[Bf-blender-cvs] [74aa582a30e] cycles_procedural_api: cleaunp

2020-10-02 Thread Kévin Dietrich
Commit: 74aa582a30e09b33099d928ad79fb916d5743826
Author: Kévin Dietrich
Date:   Mon Sep 28 14:48:44 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB74aa582a30e09b33099d928ad79fb916d5743826

cleaunp

===

M   intern/cycles/render/alembic.cpp

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 25fb5a6bcb1..63ebd1adcc0 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -182,12 +182,12 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
   }
 
   for (size_t i = 0; i < schema.getNumSamples(); ++i) {
-   AlembicObject::DataCache &data_cache = frame_data.emplace_back();
+AlembicObject::DataCache &data_cache = frame_data.emplace_back();
 
-   const ISampleSelector iss = ISampleSelector(static_cast(i));
-   const IPolyMeshSchema::Sample sample = schema.getValue(iss);
+const ISampleSelector iss = ISampleSelector(static_cast(i));
+const IPolyMeshSchema::Sample sample = schema.getValue(iss);
 
-   const P3fArraySamplePtr positions = sample.getPositions();
+const P3fArraySamplePtr positions = sample.getPositions();
 
 if (positions) {
   data_cache.vertices.reserve(positions->size());
@@ -198,16 +198,16 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
   }
 }
 
-   Int32ArraySamplePtr face_counts = sample.getFaceCounts();
-   Int32ArraySamplePtr face_indices = sample.getFaceIndices();
+Int32ArraySamplePtr face_counts = sample.getFaceCounts();
+Int32ArraySamplePtr face_indices = sample.getFaceIndices();
 
 if (face_counts && face_indices) {
- const size_t num_faces = face_counts->size();
+  const size_t num_faces = face_counts->size();
   const int *face_counts_array = face_counts->get();
   const int *face_indices_array = face_indices->get();
 
- size_t num_triangles = 0;
- for (size_t i = 0; i < face_counts->size(); i++) {
+  size_t num_triangles = 0;
+  for (size_t i = 0; i < face_counts->size(); i++) {
 num_triangles += face_counts_array[i] - 2;
   }
 
@@ -228,7 +228,7 @@ void AlembicObject::load_all_data(const IPolyMeshSchema 
&schema)
 }
 
 foreach (const AttributeRequest &attr, requested_attributes.requests) {
- read_attribute(schema.getArbGeomParams(), iss, attr.name, data_cache);
+  read_attribute(schema.getArbGeomParams(), iss, attr.name, data_cache);
 }
   }
 
@@ -279,7 +279,7 @@ void AlembicObject::read_attribute(const ICompoundProperty 
&arb_geom_params, con
 
 int offset = 0;
 for (const int3 &tri : data_cache.triangles) {
- Imath::C3f v = (*values)[tri.x];
+  Imath::C3f v = (*values)[tri.x];
   data_uchar4[offset + 0] = color_float_to_byte(make_float3(v.x, v.y, 
v.z));
 
   v = (*values)[tri.y];

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


[Bf-blender-cvs] [089f5f0bc2b] cycles_procedural_api: cleanup, const

2020-10-02 Thread Kévin Dietrich
Commit: 089f5f0bc2b65e8ee0fa4a66bf818094834e
Author: Kévin Dietrich
Date:   Mon Sep 28 14:47:22 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB089f5f0bc2b65e8ee0fa4a66bf818094834e

cleanup, const

===

M   intern/cycles/render/alembic.cpp
M   intern/cycles/render/alembic.h

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 4eac2ec5ac3..25fb5a6bcb1 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -38,12 +38,12 @@
 
 CCL_NAMESPACE_BEGIN
 
-static float3 make_float3_from_yup(Imath::Vec3 const &v)
+static float3 make_float3_from_yup(const Imath::Vec3 &v)
 {
   return make_float3(v.x, -v.z, v.y);
 }
 
-static M44d convert_yup_zup(M44d const &mtx)
+static M44d convert_yup_zup(const M44d &mtx)
 {
   Imath::Vec3 scale, shear, rot, trans;
   extractSHRT(mtx, scale, shear, rot, trans);
@@ -161,7 +161,7 @@ AlembicObject::DataCache &AlembicObject::get_frame_data(int 
index)
   return frame_data[index];
 }
 
-void AlembicObject::load_all_data(IPolyMeshSchema &schema)
+void AlembicObject::load_all_data(const IPolyMeshSchema &schema)
 {
   frame_data.clear();
 
diff --git a/intern/cycles/render/alembic.h b/intern/cycles/render/alembic.h
index 14e98765b29..4bb5d5960ec 100644
--- a/intern/cycles/render/alembic.h
+++ b/intern/cycles/render/alembic.h
@@ -48,7 +48,7 @@ class AlembicObject : public Node {
   void set_object(Object *object);
   Object *get_object();
 
-  void load_all_data(IPolyMeshSchema &schema);
+  void load_all_data(const IPolyMeshSchema &schema);
 
   bool has_data_loaded() const;

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


[Bf-blender-cvs] [db36bcd5a76] cycles_procedural_api: cleanup, avoid using "auto"

2020-10-02 Thread Kévin Dietrich
Commit: db36bcd5a76a4e223b3c0f72cefed621c2b53207
Author: Kévin Dietrich
Date:   Mon Sep 28 13:56:38 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBdb36bcd5a76a4e223b3c0f72cefed621c2b53207

cleanup, avoid using "auto"

===

M   intern/cycles/render/alembic.cpp

===

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 58fbad0cf31..4eac2ec5ac3 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -56,7 +56,7 @@ static M44d convert_yup_zup(M44d const &mtx)
 
 static Transform make_transform(const Abc::M44d &a)
 {
-  auto m = convert_yup_zup(a);
+  M44d m = convert_yup_zup(a);
   Transform trans;
   for (int j = 0; j < 3; j++) {
 for (int i = 0; i < 4; i++) {
@@ -94,9 +94,9 @@ static void read_uvs(const IV2fGeomParam &uvs,
 
 for (size_t i = 0; i < num_faces; i++) {
   for (int j = 0; j < face_counts[i] - 2; j++) {
-int v0 = uvIndices[index_offset];
-int v1 = uvIndices[index_offset + j + 1];
-int v2 = uvIndices[index_offset + j + 2];
+   unsigned int v0 = uvIndices[index_offset];
+   unsigned int v1 = uvIndices[index_offset + j + 1];
+   unsigned int v2 = uvIndices[index_offset + j + 2];
 
 fdata[0] = make_float2(uvValues[v0][0], uvValues[v0][1]);
 fdata[1] = make_float2(uvValues[v1][0], uvValues[v1][1]);
@@ -166,11 +166,12 @@ void AlembicObject::load_all_data(IPolyMeshSchema &schema)
   frame_data.clear();
 
   // TODO : store other properties and have a better structure to store these 
arrays
-  auto geometry_ = object->get_geometry();
+  Geometry *geometry = object->get_geometry();
+  assert(geometry);
 
   AttributeRequestSet requested_attributes;
 
-  foreach (Node *node, geometry_->get_used_shaders()) {
+  foreach (Node *node, geometry->get_used_shaders()) {
 Shader *shader = static_cast(node);
 
 foreach (const AttributeRequest &attr, shader->attributes.requests) {
@@ -181,14 +182,12 @@ void AlembicObject::load_all_data(IPolyMeshSchema &schema)
   }
 
   for (size_t i = 0; i < schema.getNumSamples(); ++i) {
-frame_data.emplace_back();
-AlembicObject::DataCache &data_cache = frame_data.back();
+   AlembicObject::DataCache &data_cache = frame_data.emplace_back();
 
-ISampleSelector iss = ISampleSelector(static_cast(i));
+   const ISampleSelector iss = ISampleSelector(static_cast(i));
+   const IPolyMeshSchema::Sample sample = schema.getValue(iss);
 
-auto sample = schema.getValue(iss);
-
-auto positions = sample.getPositions();
+   const P3fArraySamplePtr positions = sample.getPositions();
 
 if (positions) {
   data_cache.vertices.reserve(positions->size());
@@ -199,16 +198,16 @@ void AlembicObject::load_all_data(IPolyMeshSchema &schema)
   }
 }
 
-auto face_counts = sample.getFaceCounts();
-auto face_indices = sample.getFaceIndices();
+   Int32ArraySamplePtr face_counts = sample.getFaceCounts();
+   Int32ArraySamplePtr face_indices = sample.getFaceIndices();
 
 if (face_counts && face_indices) {
-  int num_faces = face_counts->size();
+ const size_t num_faces = face_counts->size();
   const int *face_counts_array = face_counts->get();
   const int *face_indices_array = face_indices->get();
 
-  int num_triangles = 0;
-  for (int i = 0; i < face_counts->size(); i++) {
+ size_t num_triangles = 0;
+ for (size_t i = 0; i < face_counts->size(); i++) {
 num_triangles += face_counts_array[i] - 2;
   }
 
@@ -229,7 +228,7 @@ void AlembicObject::load_all_data(IPolyMeshSchema &schema)
 }
 
 foreach (const AttributeRequest &attr, requested_attributes.requests) {
-  read_attribute(schema.getArbGeomParams(), iss, attr.name, data_cache);
+ read_attribute(schema.getArbGeomParams(), iss, attr.name, data_cache);
 }
   }
 
@@ -280,7 +279,7 @@ void AlembicObject::read_attribute(const ICompoundProperty 
&arb_geom_params, con
 
 int offset = 0;
 for (const int3 &tri : data_cache.triangles) {
-  auto v = (*values)[tri.x];
+ Imath::C3f v = (*values)[tri.x];
   data_uchar4[offset + 0] = color_float_to_byte(make_float3(v.x, v.y, 
v.z));
 
   v = (*values)[tri.y];
@@ -319,7 +318,7 @@ AlembicProcedural::AlembicProcedural() : 
Procedural(node_type)
 
 AlembicProcedural::~AlembicProcedural()
 {
-  for (auto i = 0; i < objects.size(); ++i) {
+  for (size_t i = 0; i < objects.size(); ++i) {
 delete objects[i];
   }
 }
@@ -348,7 +347,7 @@ void AlembicProcedural::generate(Scene *scene)
 objects_loaded = true;
   }
 
-  auto frame_time = (Abc::chrono_t)(frame / frame_rate);
+  Abc::chrono_t frame_time = (Abc::chrono_t)(frame / frame_rate);
 
   for (size_t 

[Bf-blender-cvs] [743eca0f316] master: UI: Create button group if none exists

2020-10-02 Thread Hans Goudey
Commit: 743eca0f316d1ec2ef16e6066d7cfc5233c92657
Author: Hans Goudey
Date:   Fri Oct 2 17:11:44 2020 -0500
Branches: master
https://developer.blender.org/rB743eca0f316d1ec2ef16e6066d7cfc5233c92657

UI: Create button group if none exists

This makes it unecessary to create a button group when the block
is created, giving more flexibility when creating the first group-- for
example, creating the first button group with special parameters.

===

M   source/blender/editors/interface/interface.c
M   source/blender/editors/interface/interface_button_group.c

===

diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index d06e3fd718d..98e76114956 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3476,7 +3476,6 @@ uiBlock *UI_block_begin(const bContext *C, ARegion 
*region, const char *name, ch
   block->evil_C = (void *)C; /* XXX */
 
   BLI_listbase_clear(&block->button_groups);
-  ui_block_new_button_group(block);
 
   if (scene) {
 /* store display device name, don't lookup for transformations yet
diff --git a/source/blender/editors/interface/interface_button_group.c 
b/source/blender/editors/interface/interface_button_group.c
index e890d0136cb..455a3c6a69c 100644
--- a/source/blender/editors/interface/interface_button_group.c
+++ b/source/blender/editors/interface/interface_button_group.c
@@ -41,10 +41,11 @@ void ui_block_new_button_group(uiBlock *block)
 
 void ui_button_group_add_but(uiBlock *block, uiBut *but)
 {
-  BLI_assert(block != NULL);
+  if (BLI_listbase_is_empty(&block->button_groups)) {
+ui_block_new_button_group(block);
+  }
 
   uiButtonGroup *current_button_group = block->button_groups.last;
-  BLI_assert(current_button_group != NULL);
 
   /* We can't use the button directly because adding it to
* this list would mess with its prev and next pointers. */

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


[Bf-blender-cvs] [3eab2248c34] master: UI: Move button groups from layout to block level

2020-10-02 Thread Hans Goudey
Commit: 3eab2248c346081b76c8379656aeff2a473a3da4
Author: Hans Goudey
Date:   Fri Oct 2 17:00:41 2020 -0500
Branches: master
https://developer.blender.org/rB3eab2248c346081b76c8379656aeff2a473a3da4

UI: Move button groups from layout to block level

For a future patch (D9006) we need these groups for longer than just the
the layout process, in order to differentiate buttons in panel headers.
It may also be helpful in the future to have a way to access related
buttons added in the same uiLayout.prop call. With this commit, the
groups are stored in and destructed with the uiBlock.

===

M   source/blender/editors/interface/CMakeLists.txt
M   source/blender/editors/interface/interface.c
A   source/blender/editors/interface/interface_button_group.c
M   source/blender/editors/interface/interface_intern.h
M   source/blender/editors/interface/interface_layout.c

===

diff --git a/source/blender/editors/interface/CMakeLists.txt 
b/source/blender/editors/interface/CMakeLists.txt
index 680cf3ea01a..e7b4402d1f1 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -38,6 +38,7 @@ set(SRC
   interface.c
   interface_align.c
   interface_anim.c
+  interface_button_group.c
   interface_context_menu.c
   interface_draw.c
   interface_eyedropper.c
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 85097a80b53..d06e3fd718d 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3392,6 +3392,8 @@ void UI_block_free(const bContext *C, uiBlock *block)
   BLI_freelistN(&block->saferct);
   BLI_freelistN(&block->color_pickers.list);
 
+  ui_block_free_button_groups(block);
+
   MEM_freeN(block);
 }
 
@@ -3473,6 +3475,9 @@ uiBlock *UI_block_begin(const bContext *C, ARegion 
*region, const char *name, ch
   block->emboss = emboss;
   block->evil_C = (void *)C; /* XXX */
 
+  BLI_listbase_clear(&block->button_groups);
+  ui_block_new_button_group(block);
+
   if (scene) {
 /* store display device name, don't lookup for transformations yet
  * block could be used for non-color displays where looking up for 
transformation
@@ -3944,7 +3949,7 @@ uiBut *ui_but_change_type(uiBut *but, eButType new_type)
   const bool found_layout = ui_layout_replace_but_ptr(but->layout, 
old_but_ptr, but);
   BLI_assert(found_layout);
   UNUSED_VARS_NDEBUG(found_layout);
-  ui_button_group_replace_but_ptr(but->layout, old_but_ptr, but);
+  ui_button_group_replace_but_ptr(uiLayoutGetBlock(but->layout), 
old_but_ptr, but);
 }
   }
 
diff --git a/source/blender/editors/interface/interface_button_group.c 
b/source/blender/editors/interface/interface_button_group.c
new file mode 100644
index 000..e890d0136cb
--- /dev/null
+++ b/source/blender/editors/interface/interface_button_group.c
@@ -0,0 +1,84 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup edinterface
+ */
+
+#include "BLI_listbase.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "interface_intern.h"
+
+/*  */
+/** \name Button Groups
+ * \{ */
+
+/**
+ * Every function that adds a set of buttons must create another group,
+ * then #ui_def_but adds buttons to the current group (the last).
+ */
+void ui_block_new_button_group(uiBlock *block)
+{
+  uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__);
+  BLI_listbase_clear(&new_group->buttons);
+  BLI_addtail(&block->button_groups, new_group);
+}
+
+void ui_button_group_add_but(uiBlock *block, uiBut *but)
+{
+  BLI_assert(block != NULL);
+
+  uiButtonGroup *current_button_group = block->button_groups.last;
+  BLI_assert(current_button_group != NULL);
+
+  /* We can't use the button directly because adding it to
+   * this list would mess with its prev and next pointers. */
+  LinkData *button_link = BLI_genericNodeN(but);
+  BLI_addtail(¤t_button_group->buttons, button_link);
+}
+
+static void button_group_free(uiButtonGroup *button_group)
+{
+  BLI_freelistN(&button_group->buttons);
+  MEM_freeN(butt

[Bf-blender-cvs] [a94f16dd0aa] usd-importer-T81257: Fixed assignment of wm_usd_import_invoke callback.

2020-10-02 Thread Michael A. Kowalski
Commit: a94f16dd0aa1e6a975d670004ab931fb2e5c32fe
Author: Michael A. Kowalski
Date:   Fri Oct 2 17:03:51 2020 -0400
Branches: usd-importer-T81257
https://developer.blender.org/rBa94f16dd0aa1e6a975d670004ab931fb2e5c32fe

Fixed assignment of wm_usd_import_invoke callback.

===

M   source/blender/editors/io/io_usd.c

===

diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index feb0c8aa6af..5c3e5d3e02b 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -311,7 +311,7 @@ void WM_OT_usd_import(wmOperatorType *ot)
   ot->idname = "WM_OT_usd_import";
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
-  ot->invoke = wm_usd_export_invoke;
+  ot->invoke = wm_usd_import_invoke;
   ot->exec = wm_usd_import_exec;
   ot->poll = WM_operator_winactive;
   ot->ui = wm_usd_import_draw;

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


[Bf-blender-cvs] [e255040c779] master: Cleanup: run UserDef versioning from readfile.c

2020-10-02 Thread Campbell Barton
Commit: e255040c7797a282cb0ea614e3f95c6a59cd0298
Author: Campbell Barton
Date:   Fri Oct 2 23:23:57 2020 +1000
Branches: master
https://developer.blender.org/rBe255040c7797a282cb0ea614e3f95c6a59cd0298

Cleanup: run UserDef versioning from readfile.c

Now versioning UserDef is run in readfile.c,
as is done for other Blender data.

Previously versioning was mixed with other run-time initialization,
so it needed to be called later by the window manager.

===

M   source/blender/blenloader/intern/readfile.c
M   source/blender/editors/interface/interface.c
M   source/blender/editors/interface/interface_intern.h
M   source/blender/editors/interface/resources.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index c9e279f7588..2ea4206bab3 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6883,15 +6883,15 @@ static void link_global(FileData *fd, BlendFileData 
*bfd)
 /** \name Versioning
  * \{ */
 
-/* initialize userdef with non-UI dependency stuff */
-/* other initializers (such as theme color defaults) go to resources.c */
-static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
+static void do_versions_userdef(FileData *UNUSED(fd), BlendFileData *bfd)
 {
   UserDef *user = bfd->user;
 
   if (user == NULL) {
 return;
   }
+
+  BLO_version_defaults_userpref_blend(user);
 }
 
 static void do_versions(FileData *fd, Library *lib, Main *main)
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index d93d80bb4ef..85097a80b53 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -7061,11 +7061,8 @@ void UI_init(void)
 /* after reading userdef file */
 void UI_init_userdef(void)
 {
-  /* fix saved themes */
-  init_userdef_do_versions();
+  /* Initialize UI variables from values set in the preferences. */
   uiStyleInit();
-
-  BLO_sanitize_experimental_features_userpref_blend(&U);
 }
 
 void UI_reinit_font(void)
diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index 7ac6ca4577e..194726b1347 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -993,7 +993,6 @@ void icon_draw_rect_input(
 float x, float y, int w, int h, float alpha, short event_type, short 
event_value);
 
 /* resources.c */
-void init_userdef_do_versions(void);
 void ui_resources_init(void);
 void ui_resources_free(void);
 
diff --git a/source/blender/editors/interface/resources.c 
b/source/blender/editors/interface/resources.c
index 1601d9914a3..ec6f99f167d 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1499,18 +1499,3 @@ void UI_make_axis_color(const uchar src_col[3], uchar 
dst_col[3], const char axi
   break;
   }
 }
-
-/* patching UserDef struct and Themes */
-void init_userdef_do_versions(void)
-{
-  BLO_version_defaults_userpref_blend(&U);
-
-  if (STREQ(U.tempdir, "/")) {
-BKE_tempdir_system_init(U.tempdir);
-  }
-
-  /* Not versioning, just avoid errors. */
-#ifndef WITH_CYCLES
-  BKE_addon_remove_safe(&U.addons, "cycles");
-#endif
-}
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 6e3a5ccb339..3f58ba9e5a0 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -69,6 +69,7 @@
 #include "DNA_windowmanager_types.h"
 #include "DNA_workspace_types.h"
 
+#include "BKE_addon.h"
 #include "BKE_appdir.h"
 #include "BKE_autoexec.h"
 #include "BKE_blender.h"
@@ -388,10 +389,18 @@ static void wm_window_match_do(bContext *C,
 /** \name Preferences Initialization & Versioning
  * \{ */
 
-/* in case UserDef was read, we re-initialize all, and do versioning */
+/**
+ * In case #UserDef was read, re-initialize values that depend on it.
+ */
 static void wm_init_userdef(Main *bmain)
 {
-  /* versioning is here */
+  /* Not versioning, just avoid errors. */
+#ifndef WITH_CYCLES
+  BKE_addon_remove_safe(&U.addons, "cycles");
+#else
+  UNUSED_VARS(BKE_addon_remove_safe);
+#endif
+
   UI_init_userdef();
 
   /* needed so loading a file from the command line respects user-pref T26156. 
*/
@@ -406,11 +415,16 @@ static void wm_init_userdef(Main *bmain)
   MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
   BKE_sound_init(bmain);
 
-  /* update tempdir from user preferences */
+  if (STREQ(U.tempdir, "/")) {
+BKE_tempdir_system_init(U.tempdir);
+  }
+  /* Update `U.tempdir` from user preferences. */
   BKE_tempdir_init(U.tempdir);
 
   /* Update tablet API 

[Bf-blender-cvs] [28a2c84948c] master: Cleanup: remove unused code in blend file loading

2020-10-02 Thread Campbell Barton
Commit: 28a2c84948cc2296dd86c5ddfc208035328a7b67
Author: Campbell Barton
Date:   Sat Oct 3 01:17:31 2020 +1000
Branches: master
https://developer.blender.org/rB28a2c84948cc2296dd86c5ddfc208035328a7b67

Cleanup: remove unused code in blend file loading

v2.4x could cancel loading files that warned of being a newer,
unsupported version.

Remove this logic since it's no longer in use.

===

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

===

diff --git a/source/blender/blenkernel/intern/blendfile.c 
b/source/blender/blenkernel/intern/blendfile.c
index fc1911d0394..9dabbb021b6 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -413,7 +413,7 @@ static void setup_app_blend_file_data(bContext *C,
   }
 }
 
-static bool handle_subversion_warning(Main *main, ReportList *reports)
+static void handle_subversion_warning(Main *main, ReportList *reports)
 {
   if (main->minversionfile > BLENDER_FILE_VERSION ||
   (main->minversionfile == BLENDER_FILE_VERSION &&
@@ -424,8 +424,6 @@ static bool handle_subversion_warning(Main *main, 
ReportList *reports)
 main->minversionfile,
 main->minsubversionfile);
   }
-
-  return true;
 }
 
 bool BKE_blendfile_read_ex(bContext *C,
@@ -436,37 +434,27 @@ bool BKE_blendfile_read_ex(bContext *C,
const bool startup_update_defaults,
const char *startup_app_template)
 {
-  BlendFileData *bfd;
-  bool success = false;
 
   /* Don't print startup file loading. */
   if (params->is_startup == false) {
 printf("Read blend: %s\n", filepath);
   }
 
-  bfd = BLO_read_from_file(filepath, params->skip_flags, reports);
+  BlendFileData *bfd = BLO_read_from_file(filepath, params->skip_flags, 
reports);
   if (bfd) {
-if (!handle_subversion_warning(bfd->main, reports)) {
-  BKE_main_free(bfd->main);
-  MEM_freeN(bfd);
-  bfd = NULL;
-}
-else {
-  if (startup_update_defaults) {
-if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) {
-  BLO_update_defaults_startup_blend(bfd->main, startup_app_template);
-}
+handle_subversion_warning(bfd->main, reports);
+if (startup_update_defaults) {
+  if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) {
+BLO_update_defaults_startup_blend(bfd->main, startup_app_template);
   }
-  setup_app_blend_file_data(C, bfd, filepath, params, reports);
-  BLO_blendfiledata_free(bfd);
-  success = true;
 }
+setup_app_blend_file_data(C, bfd, filepath, params, reports);
+BLO_blendfiledata_free(bfd);
   }
   else {
 BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
   }
-
-  return success;
+  return (bfd != NULL);
 }
 
 bool BKE_blendfile_read(bContext *C,
@@ -486,9 +474,7 @@ bool BKE_blendfile_read_from_memory_ex(bContext *C,
const bool startup_update_defaults,
const char *startup_app_template)
 {
-  BlendFileData *bfd;
-
-  bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports);
+  BlendFileData *bfd = BLO_read_from_memory(filebuf, filelength, 
params->skip_flags, reports);
   if (bfd) {
 if (startup_update_defaults) {
   if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) {
@@ -501,7 +487,6 @@ bool BKE_blendfile_read_from_memory_ex(bContext *C,
   else {
 BKE_reports_prepend(reports, "Loading failed: ");
   }
-
   return (bfd != NULL);
 }
 
@@ -521,9 +506,8 @@ bool BKE_blendfile_read_from_memfile(bContext *C,
  ReportList *reports)
 {
   Main *bmain = CTX_data_main(C);
-  BlendFileData *bfd;
-
-  bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, 
params, reports);
+  BlendFileData *bfd = BLO_read_from_memfile(
+  bmain, BKE_main_blendfile_path(bmain), memfile, params, reports);
   if (bfd) {
 /* Removing the unused workspaces, screens and wm is useless here, 
setup_app_data will switch
  * those lists with the ones from old bmain, which freeing is much more 
efficient than
@@ -539,7 +523,6 @@ bool BKE_blendfile_read_from_memfile(bContext *C,
   else {
 BKE_reports_prepend(reports, "Loading failed: ");
   }
-
   return (bfd != NULL);
 }

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


[Bf-blender-cvs] [15a9579a03f] master: Cleanup: centralize versioning

2020-10-02 Thread Campbell Barton
Commit: 15a9579a03f1ca65df477a1a39dbaef572ff3e9f
Author: Campbell Barton
Date:   Fri Oct 2 21:15:28 2020 +1000
Branches: master
https://developer.blender.org/rB15a9579a03f1ca65df477a1a39dbaef572ff3e9f

Cleanup: centralize versioning

readfile.c's versioning function was only used for 2 variables.
Move versioning into versioning_userdef.c so everything
is done in one function.

Note: DNA_struct_elem_find checks have been replaced with checks for
the next released version.
This is harmless, as only old preferences saved between releases can
have their values overwritten.

Note: userdef versioning should be called from `do_versions_userdef`,
this will be done separately.

===

M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/versioning_userdef.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 0b247d9a249..c9e279f7588 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6892,20 +6892,6 @@ static void do_versions_userdef(FileData *fd, 
BlendFileData *bfd)
   if (user == NULL) {
 return;
   }
-
-  if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "WalkNavigation", 
"walk_navigation")) {
-user->walk_navigation.mouse_speed = 1.0f;
-user->walk_navigation.walk_speed = 2.5f; /* m/s */
-user->walk_navigation.walk_speed_factor = 5.0f;
-user->walk_navigation.view_height = 1.6f;   /* m */
-user->walk_navigation.jump_height = 0.4f;   /* m */
-user->walk_navigation.teleport_time = 0.2f; /* s */
-  }
-
-  /* tablet pressure threshold */
-  if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "float", 
"pressure_threshold_max")) {
-user->pressure_threshold_max = 1.0f;
-  }
 }
 
 static void do_versions(FileData *fd, Library *lib, Main *main)
diff --git a/source/blender/blenloader/intern/versioning_userdef.c 
b/source/blender/blenloader/intern/versioning_userdef.c
index ded371aa2d8..da0dd486646 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -528,9 +528,14 @@ void BLO_version_defaults_userpref_blend(UserDef *userdef)
 }
   }
 
-  /* NOTE!! from now on use userdef->versionfile and userdef->subversionfile */
-#undef USER_VERSION_ATLEAST
-#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, 
subver)
+  if (!USER_VERSION_ATLEAST(269, 4)) {
+userdef->walk_navigation.mouse_speed = 1.0f;
+userdef->walk_navigation.walk_speed = 2.5f; /* m/s */
+userdef->walk_navigation.walk_speed_factor = 5.0f;
+userdef->walk_navigation.view_height = 1.6f;   /* m */
+userdef->walk_navigation.jump_height = 0.4f;   /* m */
+userdef->walk_navigation.teleport_time = 0.2f; /* s */
+  }
 
   if (!USER_VERSION_ATLEAST(271, 5)) {
 userdef->pie_menu_radius = 100;
@@ -599,6 +604,8 @@ void BLO_version_defaults_userpref_blend(UserDef *userdef)
   if (!USER_VERSION_ATLEAST(280, 33)) {
 /* Enable GLTF addon by default. */
 BKE_addon_ensure(&userdef->addons, "io_scene_gltf2");
+
+userdef->pressure_threshold_max = 1.0f;
   }
 
   if (!USER_VERSION_ATLEAST(280, 35)) {

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


[Bf-blender-cvs] [b13459f9e58] master: Cleanup: rename main preferences versioning function

2020-10-02 Thread Campbell Barton
Commit: b13459f9e585bcb0e4ba61e391e59a888f5042f2
Author: Campbell Barton
Date:   Fri Oct 2 23:36:05 2020 +1000
Branches: master
https://developer.blender.org/rBb13459f9e585bcb0e4ba61e391e59a888f5042f2

Cleanup: rename main preferences versioning function

BLO_version_defaults_userpref_blend -> blo_do_versions_userdef

The name was misleading as it was declared along with
BLO_update_defaults_startup_blend making it seem these functions were
related.

In fact preference defaults don't need to be updated as is done for
startup.blend since an in-memory blend file isn't used.

Rename the function to match other versioning functions
called from readfile.c. Also add/update comments on these differences.

===

M   source/blender/blenloader/BLO_readfile.h
M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/readfile.h
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/blenloader/intern/versioning_290.c
M   source/blender/blenloader/intern/versioning_defaults.c
M   source/blender/blenloader/intern/versioning_userdef.c
M   source/blender/makesdna/intern/dna_defaults.c

===

diff --git a/source/blender/blenloader/BLO_readfile.h 
b/source/blender/blenloader/BLO_readfile.h
index 88d89d9d6da..0ab9a5e9e14 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -223,13 +223,13 @@ typedef void (*BLOExpandDoitCallback)(void *fdhandle, 
struct Main *mainvar, void
 void BLO_main_expander(BLOExpandDoitCallback expand_doit_func);
 void BLO_expand_main(void *fdhandle, struct Main *mainvar);
 
-/* Update defaults in startup.blend & userprefs.blend, without having to save 
and embed it */
+/**
+ * Update defaults in startup.blend, without having to save and embed it.
+ * \note defaults for preferences are stored in `userdef_default.c` and can be 
updated there.
+ */
 void BLO_update_defaults_startup_blend(struct Main *bmain, const char 
*app_template);
 void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char 
*app_template);
 
-/* Version patch user preferences. */
-void BLO_version_defaults_userpref_blend(struct UserDef *userdef);
-
 /* Disable unwanted experimental feature settings on startup. */
 void BLO_sanitize_experimental_features_userpref_blend(struct UserDef 
*userdef);
 
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 2ea4206bab3..cf2181c8a27 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6891,7 +6891,7 @@ static void do_versions_userdef(FileData *UNUSED(fd), 
BlendFileData *bfd)
 return;
   }
 
-  BLO_version_defaults_userpref_blend(user);
+  blo_do_versions_userdef(user);
 }
 
 static void do_versions(FileData *fd, Library *lib, Main *main)
diff --git a/source/blender/blenloader/intern/readfile.h 
b/source/blender/blenloader/intern/readfile.h
index d3372a646a9..4fa41731454 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -42,6 +42,7 @@ struct Object;
 struct OldNewMap;
 struct PartEff;
 struct ReportList;
+struct UserDef;
 struct View3D;
 
 typedef struct IDNameLib_Map IDNameLib_Map;
@@ -189,6 +190,8 @@ void blo_do_version_old_trackto_to_constraints(struct 
Object *ob);
 void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase 
*regions);
 void blo_do_versions_key_uidgen(struct Key *key);
 
+void blo_do_versions_userdef(struct UserDef *userdef);
+
 void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct 
Main *bmain);
 void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main 
*bmain);
 void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main 
*bmain);
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index b7c48234590..ad6066647d6 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1747,7 +1747,7 @@ void do_versions_after_linking_280(Main *bmain, 
ReportList *UNUSED(reports))
*
* \note Be sure to check when bumping the version:
* - #blo_do_versions_280 in this file.
-   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
+   * - "versioning_userdef.c", #blo_do_versions_userdef
* - "versioning_userdef.c", #do_versions_theme
*
* \note Keep this message at the bottom of the function.
@@ -5092,7 +5092,7 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
*
* \note Be sure to check when bumping the version:
* - #do_versions_after_linking_280 in this file.
-   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
+   * - "versioning_userdef.c", #blo_do_versions_u

[Bf-blender-cvs] [8cd8b3e9bda] master: readfile: always run setup_app_data after updating defaults

2020-10-02 Thread Campbell Barton
Commit: 8cd8b3e9bda443ec8f560117d93a4f06fe91cb11
Author: Campbell Barton
Date:   Sat Oct 3 01:02:31 2020 +1000
Branches: master
https://developer.blender.org/rB8cd8b3e9bda443ec8f560117d93a4f06fe91cb11

readfile: always run setup_app_data after updating defaults

When blend files were loaded with app-templates,
setup_app_data was running before defaults were updated.

This is likely to cause problems with order of initialization
so always update the startup file beforehand.

===

M   source/blender/blenkernel/BKE_blendfile.h
M   source/blender/blenkernel/intern/blendfile.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenkernel/BKE_blendfile.h 
b/source/blender/blenkernel/BKE_blendfile.h
index 94d203eeb2c..f73c4a70809 100644
--- a/source/blender/blenkernel/BKE_blendfile.h
+++ b/source/blender/blenkernel/BKE_blendfile.h
@@ -31,16 +31,32 @@ struct ReportList;
 struct UserDef;
 struct bContext;
 
-int BKE_blendfile_read(struct bContext *C,
-   const char *filepath,
-   const struct BlendFileReadParams *params,
-   struct ReportList *reports);
+bool BKE_blendfile_read_ex(struct bContext *C,
+   const char *filepath,
+   const struct BlendFileReadParams *params,
+   struct ReportList *reports,
+   /* Extra args. */
+   const bool startup_update_defaults,
+   const char *startup_app_template);
+bool BKE_blendfile_read(struct bContext *C,
+const char *filepath,
+const struct BlendFileReadParams *params,
+struct ReportList *reports);
+
+bool BKE_blendfile_read_from_memory_ex(struct bContext *C,
+   const void *filebuf,
+   int filelength,
+   const struct BlendFileReadParams 
*params,
+   struct ReportList *reports,
+   /* Extra args. */
+   const bool startup_update_defaults,
+   const char *startup_app_template);
 bool BKE_blendfile_read_from_memory(struct bContext *C,
 const void *filebuf,
 int filelength,
-bool update_defaults,
 const struct BlendFileReadParams *params,
 struct ReportList *reports);
+
 bool BKE_blendfile_read_from_memfile(struct bContext *C,
  struct MemFile *memfile,
  const struct BlendFileReadParams *params,
diff --git a/source/blender/blenkernel/intern/blendfile.c 
b/source/blender/blenkernel/intern/blendfile.c
index 4ea8ae555e3..fc1911d0394 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -428,10 +428,13 @@ static bool handle_subversion_warning(Main *main, 
ReportList *reports)
   return true;
 }
 
-int BKE_blendfile_read(bContext *C,
-   const char *filepath,
-   const struct BlendFileReadParams *params,
-   ReportList *reports)
+bool BKE_blendfile_read_ex(bContext *C,
+   const char *filepath,
+   const struct BlendFileReadParams *params,
+   ReportList *reports,
+   /* Extra args. */
+   const bool startup_update_defaults,
+   const char *startup_app_template)
 {
   BlendFileData *bfd;
   bool success = false;
@@ -449,6 +452,11 @@ int BKE_blendfile_read(bContext *C,
   bfd = NULL;
 }
 else {
+  if (startup_update_defaults) {
+if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) {
+  BLO_update_defaults_startup_blend(bfd->main, startup_app_template);
+}
+  }
   setup_app_blend_file_data(C, bfd, filepath, params, reports);
   BLO_blendfiledata_free(bfd);
   success = true;
@@ -461,23 +469,32 @@ int BKE_blendfile_read(bContext *C,
   return success;
 }
 
-bool BKE_blendfile_read_from_memory(bContext *C,
-const void *filebuf,
-int filelength,
-bool update_defaults,
-const struct BlendFileReadParams *params,
-ReportList *reports)
+bool BKE_blendfile_read(bContext *C,
+const char *filepath,
+const struct BlendFi

[Bf-blender-cvs] [a03bd6460c1] master: Property Search: Don't use search color for subpanel titles

2020-10-02 Thread Hans Goudey
Commit: a03bd6460c130b06debfd583252c78d8b8ae73fb
Author: Hans Goudey
Date:   Fri Oct 2 13:14:33 2020 -0500
Branches: master
https://developer.blender.org/rBa03bd6460c130b06debfd583252c78d8b8ae73fb

Property Search: Don't use search color for subpanel titles

This replaces the blue theme color for subpanel titles with the the same
fade as for parent panels.

The search color doesn't work well for subpanel title colors. And actually,
because there are often buttons with checkboxes in the panel headers, we
don't have to treat this indicator any differently than regular buttons.

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

===

M   source/blender/editors/interface/interface_panel.c

===

diff --git a/source/blender/editors/interface/interface_panel.c 
b/source/blender/editors/interface/interface_panel.c
index 6304ce91688..ec4e2c03e85 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -132,7 +132,6 @@ static bool panel_type_context_poll(ARegion *region,
 
 static void panel_title_color_get(const Panel *panel,
   const bool show_background,
-  const bool use_search_color,
   const bool region_search_filter_active,
   uchar r_color[4])
 {
@@ -146,16 +145,11 @@ static void panel_title_color_get(const Panel *panel,
 
   const bool search_match = UI_panel_matches_search_filter(panel);
 
-  if (region_search_filter_active && use_search_color && search_match) {
-UI_GetThemeColor4ubv(TH_MATCH, r_color);
-  }
-  else {
-UI_GetThemeColor4ubv(TH_TITLE, r_color);
-if (region_search_filter_active && !search_match) {
-  r_color[0] *= 0.5;
-  r_color[1] *= 0.5;
-  r_color[2] *= 0.5;
-}
+  UI_GetThemeColor4ubv(TH_TITLE, r_color);
+  if (region_search_filter_active && !search_match) {
+r_color[0] *= 0.5;
+r_color[1] *= 0.5;
+r_color[2] *= 0.5;
   }
 }
 
@@ -965,8 +959,7 @@ static void ui_draw_aligned_panel_header(const uiStyle 
*style,
 
   /* Draw text labels. */
   uchar col_title[4];
-  panel_title_color_get(
-  panel, show_background, is_subpanel, region_search_filter_active, 
col_title);
+  panel_title_color_get(panel, show_background, region_search_filter_active, 
col_title);
   col_title[3] = 255;
 
   rcti hrect = *rect;
@@ -1084,7 +1077,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
   /* draw optional pin icon */
   if (show_pin && (block->panel->flag & PNL_PIN)) {
 uchar col_title[4];
-panel_title_color_get(panel, show_background, false, 
region_search_filter_active, col_title);
+panel_title_color_get(panel, show_background, region_search_filter_active, 
col_title);
 
 GPU_blend(GPU_BLEND_ALPHA);
 UI_icon_draw_ex(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect),
@@ -1199,7 +1192,7 @@ void ui_draw_aligned_panel(const uiStyle *style,
 BLI_rctf_scale(&itemrect, 0.25f);
 
 uchar col_title[4];
-panel_title_color_get(panel, show_background, false, 
region_search_filter_active, col_title);
+panel_title_color_get(panel, show_background, region_search_filter_active, 
col_title);
 float tria_color[4];
 rgb_uchar_to_float(tria_color, col_title);
 tria_color[3] = 1.0f;

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


[Bf-blender-cvs] [933bf62a611] master: Property Search: Differentiate search filtered and inactive buttons

2020-10-02 Thread Hans Goudey
Commit: 933bf62a611f61bd61e3e7745ce6dea58f571e72
Author: Hans Goudey
Date:   Fri Oct 2 13:10:21 2020 -0500
Branches: master
https://developer.blender.org/rB933bf62a611f61bd61e3e7745ce6dea58f571e72

Property Search: Differentiate search filtered and inactive buttons

Currently there's no way to know if a button is inactive when it doesn't
match the search results, because they use the same 50% gray level.

This isn't a huge problem, but it could lead to confusion. This commit
uses a subtle solution, a 25% opacity when the button is inactive and
 also filtered by search.

This requires flipping the meaning of the UI_SEARCH_FILTER_MATCHES
flag in the code, and also adding a widget_alpha_factor utility in
the widget code.

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

===

M   source/blender/editors/interface/interface_intern.h
M   source/blender/editors/interface/interface_layout.c
M   source/blender/editors/interface/interface_widgets.c

===

diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index 91a71b0ca28..7ac6ca4577e 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -81,11 +81,8 @@ enum {
   UI_HAS_ICON = (1 << 3),
   UI_HIDDEN = (1 << 4),
   UI_SELECT_DRAW = (1 << 5), /* Display selected, doesn't impact interaction. 
*/
-  /**
-   * The button matches the search filter. When property search is active, this
-   * is used to determine which items to keep enabled and which to disable.
-   */
-  UI_SEARCH_FILTER_MATCHES = (1 << 12),
+  /** Property search filter is active and the button does not match. */
+  UI_SEARCH_FILTER_NO_MATCH = (1 << 12),
   /* warn: rest of uiBut->flag in UI_interface.h */
 };
 
diff --git a/source/blender/editors/interface/interface_layout.c 
b/source/blender/editors/interface/interface_layout.c
index f8b9f4f0df1..ab641dc74fe 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -5239,26 +5239,19 @@ static bool block_search_filter_tag_buttons(uiBlock 
*block, const char *search_f
   LISTBASE_FOREACH (uiLayoutRoot *, root, &block->layouts) {
 LISTBASE_FOREACH (uiButtonGroup *, button_group, &root->button_groups) {
   if (button_group_has_search_match(button_group, search_filter)) {
+has_result = true;
+  }
+  else {
 LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
   uiBut *but = link->data;
-  but->flag |= UI_SEARCH_FILTER_MATCHES;
+  but->flag |= UI_SEARCH_FILTER_NO_MATCH;
 }
-has_result = true;
   }
 }
   }
   return has_result;
 }
 
-static void block_search_deactivate_buttons(uiBlock *block)
-{
-  LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
-if (!(but->flag & UI_SEARCH_FILTER_MATCHES)) {
-  but->flag |= UI_BUT_INACTIVE;
-}
-  }
-}
-
 /**
  * Apply property search behavior, setting panel flags and deactivating 
buttons that don't match.
  *
@@ -5284,10 +5277,6 @@ bool UI_block_apply_search_filter(uiBlock *block, const 
char *search_filter)
 }
   }
 
-  if (!panel_label_matches) {
-block_search_deactivate_buttons(block);
-  }
-
   return has_result;
 }
 
diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index 22e57cf8696..f2081199672 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1332,6 +1332,22 @@ static void widgetbase_draw(uiWidgetBase *wtb, const 
uiWidgetColors *wcol)
 
 #define PREVIEW_PAD 4
 
+static float widget_alpha_factor(const int state)
+{
+  if (state & (UI_BUT_INACTIVE | UI_BUT_DISABLED)) {
+if (state & UI_SEARCH_FILTER_NO_MATCH) {
+  return 0.25f;
+}
+return 0.5f;
+  }
+
+  if (state & UI_SEARCH_FILTER_NO_MATCH) {
+return 0.5f;
+  }
+
+  return 1.0f;
+}
+
 static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect)
 {
   int w, h, size;
@@ -1400,9 +1416,7 @@ static void widget_draw_icon(
 }
   }
   else if (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_DECORATOR)) {
-if (but->flag & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
-  alpha *= 0.5f;
-}
+alpha *= widget_alpha_factor(but->flag);
   }
 
   GPU_blend(GPU_BLEND_ALPHA);
@@ -2477,18 +2491,20 @@ static void widget_draw_text_icon(const uiFontStyle 
*fstyle,
  * \{ */
 
 /* put all widget colors on half alpha, use local storage */
-static void ui_widget_color_disabled(uiWidgetType *wt)
+static void ui_widget_color_disabled(uiWidgetType *wt, const int state)
 {
   static uiWidgetColors wcol_theme_s;
 
   wcol_theme_s = *wt->wcol_theme;
 
-  wcol_theme_s.outline[3] *= 0.5;
-  wcol_theme_s.inner[3] *= 0.5;
-  wcol_theme_s.inner_sel[3

[Bf-blender-cvs] [6f96dd85766] master: Fix T78503: Disabled layout portion passes mouse through

2020-10-02 Thread Hans Goudey
Commit: 6f96dd85766a8159d5ffb761cbb4dbd20b7cad00
Author: Hans Goudey
Date:   Fri Oct 2 13:06:58 2020 -0500
Branches: master
https://developer.blender.org/rB6f96dd85766a8159d5ffb761cbb4dbd20b7cad00

Fix T78503: Disabled layout portion passes mouse through

3D Viewport -> Sidebar -> View -> Local Camera is disabled. When you
click on it, box select starts. This behavior isn't intended, and fixing
it is quite simple. The only case where this would continuing would
still be desired is if a disabled button overlapped with a non-disabled
button, but this shouldn't be the case anywhere.

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

===

M   source/blender/editors/interface/interface_handlers.c

===

diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index efa5613e210..f2d9f90f354 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -7580,7 +7580,7 @@ static int ui_do_button(bContext *C, uiBlock *block, 
uiBut *but, const wmEvent *
   }
 
   if (but->flag & UI_BUT_DISABLED) {
-return WM_UI_HANDLER_CONTINUE;
+return WM_UI_HANDLER_BREAK;
   }
 
   switch (but->type) {

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


[Bf-blender-cvs] [a4aa94c41cb] master: Cleanup: Declare variables where initialized

2020-10-02 Thread Hans Goudey
Commit: a4aa94c41cb79e917a5bfe78907ab4a4bcbdad3b
Author: Hans Goudey
Date:   Fri Oct 2 13:02:30 2020 -0500
Branches: master
https://developer.blender.org/rBa4aa94c41cb79e917a5bfe78907ab4a4bcbdad3b

Cleanup: Declare variables where initialized

Also reduce the scope of some variable declarations.
This also allows making some variables constant.

===

M   source/blender/editors/interface/interface_layout.c

===

diff --git a/source/blender/editors/interface/interface_layout.c 
b/source/blender/editors/interface/interface_layout.c
index 7fa7984c7e7..f8b9f4f0df1 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -312,16 +312,13 @@ static bool ui_layout_variable_size(uiLayout *layout)
 /* estimated size of text + icon */
 static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, 
bool compact)
 {
-  bool variable;
   const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
 
   if (icon && !name[0]) {
 return unit_x; /* icon only */
   }
 
-  variable = ui_layout_variable_size(layout);
-
-  if (variable) {
+  if (ui_layout_variable_size(layout)) {
 if (!icon && !name[0]) {
   return unit_x; /* No icon or name. */
 }
@@ -510,7 +507,6 @@ int uiLayoutGetLocalDir(const uiLayout *layout)
 static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, 
bool align)
 {
   uiLayout *sub;
-
   if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL) {
 sub = uiLayoutRow(layout, align);
   }
@@ -569,17 +565,12 @@ static void ui_item_array(uiLayout *layout,
   bool show_text)
 {
   const uiStyle *style = layout->root->style;
-  uiBut *but;
-  PropertyType type;
-  PropertySubType subtype;
-  uiLayout *sub;
-  uint a, b;
 
   /* retrieve type and subtype */
-  type = RNA_property_type(prop);
-  subtype = RNA_property_subtype(prop);
+  const PropertyType type = RNA_property_type(prop);
+  const PropertySubType subtype = RNA_property_subtype(prop);
 
-  sub = ui_item_local_sublayout(layout, layout, 1);
+  uiLayout *sub = ui_item_local_sublayout(layout, layout, 1);
   UI_block_layout_set_current(block, sub);
 
   /* create label */
@@ -590,17 +581,15 @@ static void ui_item_array(uiLayout *layout,
   /* create buttons */
   if (type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) {
 /* special check for layer layout */
-int butw, buth, unit;
 const int cols = (len >= 20) ? 2 : 1;
-const uint colbuts = len / (2 * cols);
+const int colbuts = len / (2 * cols);
 uint layer_used = 0;
 uint layer_active = 0;
 
 UI_block_layout_set_current(block, uiLayoutAbsolute(layout, false));
 
-unit = UI_UNIT_X * 0.75;
-butw = unit;
-buth = unit;
+const int butw = UI_UNIT_X * 0.75;
+const int buth = UI_UNIT_X * 0.75;
 
 if (ptr->type == &RNA_Armature) {
   bArmature *arm = ptr->data;
@@ -619,10 +608,10 @@ static void ui_item_array(uiLayout *layout,
   }
 }
 
-for (b = 0; b < cols; b++) {
+for (int b = 0; b < cols; b++) {
   UI_block_align_begin(block);
 
-  for (a = 0; a < colbuts; a++) {
+  for (int a = 0; a < colbuts; a++) {
 const int layer_num = a + b * colbuts;
 const uint layer_flag = (1u << layer_num);
 
@@ -638,13 +627,13 @@ static void ui_item_array(uiLayout *layout,
   icon = ICON_BLANK1;
 }
 
-but = uiDefAutoButR(
+uiBut *but = uiDefAutoButR(
 block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, 
butw, buth);
 if (subtype == PROP_LAYER_MEMBER) {
   UI_but_func_set(but, ui_layer_but_cb, but, 
POINTER_FROM_INT(layer_num));
 }
   }
-  for (a = 0; a < colbuts; a++) {
+  for (int a = 0; a < colbuts; a++) {
 const int layer_num = a + len / 2 + b * colbuts;
 const uint layer_flag = (1u << layer_num);
 
@@ -660,7 +649,8 @@ static void ui_item_array(uiLayout *layout,
   icon = ICON_BLANK1;
 }
 
-but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * 
a, y, butw, buth);
+uiBut *but = uiDefAutoButR(
+block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, 
buth);
 if (subtype == PROP_LAYER_MEMBER) {
   UI_but_func_set(but, ui_layer_but_cb, but, 
POINTER_FROM_INT(layer_num));
 }
@@ -685,20 +675,20 @@ static void ui_item_array(uiLayout *layout,
 w /= dim_size[0];
 /* h /= dim_size[1]; */ /* UNUSED */
 
-for (a = 0; a < len; a++) {
+for (int a = 0; a < len; a++) {
   col = a % dim_size[0];
   row = a / dim_size[0];
 
-  but = uiDefAutoButR(block,
-  ptr,
-  prop,
-  a,
-  "",
-  ICON_NONE,
-  

[Bf-blender-cvs] [6b32de4d9fd] master: Cleanup: Fix build error on windows

2020-10-02 Thread Ray Molenkamp
Commit: 6b32de4d9fde0bb7d6d257f43a34ece2d56c8ad8
Author: Ray Molenkamp
Date:   Fri Oct 2 11:47:44 2020 -0600
Branches: master
https://developer.blender.org/rB6b32de4d9fde0bb7d6d257f43a34ece2d56c8ad8

Cleanup: Fix build error on windows

int and eContextResult are different types to MSVC
leading to a function signature mismatch.

===

M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 07a571ae464..74621b917c6 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -987,7 +987,7 @@ static eContextResult 
screen_ctx_active_editable_fcurve(const bContext *C,
 
 /* Registry of context callback functions. */
 
-typedef int (*context_callback)(const bContext *C, bContextDataResult *result);
+typedef eContextResult (*context_callback)(const bContext *C, 
bContextDataResult *result);
 static GHash *ed_screen_context_functions = NULL;
 
 static void free_context_function_ghash(void *UNUSED(user_data))

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


[Bf-blender-cvs] [38cdc7bcc1f] master: Fix non-thread safe code in view layer object hash

2020-10-02 Thread Brecht Van Lommel
Commit: 38cdc7bcc1f2ac7e89578be079e4be0b049a4036
Author: Brecht Van Lommel
Date:   Fri Oct 2 19:30:19 2020 +0200
Branches: master
https://developer.blender.org/rB38cdc7bcc1f2ac7e89578be079e4be0b049a4036

Fix non-thread safe code in view layer object hash

Found as part of D8324, multithreaded Cycles object sync, where it caused
a crash on concurrent access to object holdout state.

===

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

===

diff --git a/source/blender/blenkernel/intern/layer.c 
b/source/blender/blenkernel/intern/layer.c
index 1d47fb002e6..4ed8a796d5d 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -358,14 +358,16 @@ static void view_layer_bases_hash_create(ViewLayer 
*view_layer)
 BLI_mutex_lock(&hash_lock);
 
 if (view_layer->object_bases_hash == NULL) {
-  view_layer->object_bases_hash = BLI_ghash_new(
-  BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+  GHash *hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, 
__func__);
 
   LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
 if (base->object) {
-  BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
+  BLI_ghash_insert(hash, base->object, base);
 }
   }
+
+  /* Assign pointer only after hash is complete. */
+  view_layer->object_bases_hash = hash;
 }
 
 BLI_mutex_unlock(&hash_lock);

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


[Bf-blender-cvs] [cfa101c2287] master: Cycles: Add command line option for overriding the compute device

2020-10-02 Thread Lukas Stockner
Commit: cfa101c22871c3d115f854e23f8b656b1c58a304
Author: Lukas Stockner
Date:   Fri Oct 2 00:48:01 2020 +0200
Branches: master
https://developer.blender.org/rBcfa101c22871c3d115f854e23f8b656b1c58a304

Cycles: Add command line option for overriding the compute device

The current way of setting the compute device makes sense for local
use, but for headless rendering it it a massive pain to get Cycles
to use the correct device, usually involving entire Python scripts.

Therefore, this patch adds a simple command-line option to Blender
for specifying the type of device that should be used. If the option
is present, the settings in the user preferences and the scene are
ignored, and instead all devices matching the specified type are used.

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

===

M   intern/cycles/blender/addon/engine.py
M   intern/cycles/blender/blender_device.cpp
M   intern/cycles/blender/blender_python.cpp
M   intern/cycles/blender/blender_session.cpp
M   intern/cycles/blender/blender_session.h
M   intern/cycles/util/util_string.cpp
M   intern/cycles/util/util_string.h

===

diff --git a/intern/cycles/blender/addon/engine.py 
b/intern/cycles/blender/addon/engine.py
index 54221d3f1e0..807dcaf7f43 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -70,6 +70,11 @@ def _configure_argument_parser():
 parser.add_argument("--cycles-print-stats",
 help="Print rendering statistics to stderr",
 action='store_true')
+parser.add_argument("--cycles-device",
+help="Set the device to use for Cycles, overriding 
user preferences and the scene setting."
+ "Valid options are 'CPU', 'CUDA', 'OPTIX' or 
'OPENCL'."
+ "Additionally, you can append '+CPU' to any GPU 
type for hybrid rendering.",
+default=None)
 return parser
 
 
@@ -102,6 +107,10 @@ def _parse_command_line():
 import _cycles
 _cycles.enable_print_stats()
 
+if args.cycles_device:
+import _cycles
+_cycles.set_device_override(args.cycles_device)
+
 
 def init():
 import bpy
diff --git a/intern/cycles/blender/blender_device.cpp 
b/intern/cycles/blender/blender_device.cpp
index fb9ab9e8c97..0293223864d 100644
--- a/intern/cycles/blender/blender_device.cpp
+++ b/intern/cycles/blender/blender_device.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "blender/blender_device.h"
+#include "blender/blender_session.h"
 #include "blender/blender_util.h"
 
 #include "util/util_foreach.h"
@@ -42,6 +43,18 @@ int blender_device_threads(BL::Scene &b_scene)
 
 DeviceInfo blender_device_info(BL::Preferences &b_preferences, BL::Scene 
&b_scene, bool background)
 {
+  if (BlenderSession::device_override != DEVICE_MASK_ALL) {
+vector devices = 
Device::available_devices(BlenderSession::device_override);
+
+if (devices.empty()) {
+  printf("Found no Cycles device of the specified type, falling back to 
CPU...\n");
+  return Device::available_devices(DEVICE_MASK_CPU).front();
+}
+
+int threads = blender_device_threads(b_scene);
+return Device::get_multi_device(devices, threads, background);
+  }
+
   PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
 
   /* Default to CPU device. */
diff --git a/intern/cycles/blender/blender_python.cpp 
b/intern/cycles/blender/blender_python.cpp
index 25c77b74ce3..65337d1ba4f 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -968,6 +968,44 @@ static PyObject *get_device_types_func(PyObject * 
/*self*/, PyObject * /*args*/)
   return list;
 }
 
+static PyObject *set_device_override_func(PyObject * /*self*/, PyObject *arg)
+{
+  PyObject *override_string = PyObject_Str(arg);
+  string override = PyUnicode_AsUTF8(override_string);
+  Py_DECREF(override_string);
+
+  bool include_cpu = false;
+  const string cpu_suffix = "+CPU";
+  if (string_endswith(override, cpu_suffix)) {
+include_cpu = true;
+override = override.substr(0, override.length() - cpu_suffix.length());
+  }
+
+  if (override == "CPU") {
+BlenderSession::device_override = DEVICE_MASK_CPU;
+  }
+  else if (override == "OPENCL") {
+BlenderSession::device_override = DEVICE_MASK_OPENCL;
+  }
+  else if (override == "CUDA") {
+BlenderSession::device_override = DEVICE_MASK_CUDA;
+  }
+  else if (override == "OPTIX") {
+BlenderSession::device_override = DEVICE_MASK_OPTIX;
+  }
+  else {
+printf("\nError: %s is not a valid Cycles device.\n", override.c_str());
+Py_RETURN_FALSE;
+  }
+
+  if (include_cpu) {
+BlenderSession::device_override = 
(DeviceTypeMask)(BlenderSession::device_override |
+   DEVICE_MASK_CPU

[Bf-blender-cvs] [350ed861f14] master: Cleanup: clang-format

2020-10-02 Thread Lukas Stockner
Commit: 350ed861f149142784fc184086e92664b72a10ef
Author: Lukas Stockner
Date:   Fri Oct 2 19:31:55 2020 +0200
Branches: master
https://developer.blender.org/rB350ed861f149142784fc184086e92664b72a10ef

Cleanup: clang-format

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c 
b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 61455cc28bb..1e8c150a43b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -361,7 +361,7 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
 /* Cloth Snake Hook creates deformation constraint with fixed strength 
because the strength
  * is controlled per iteration using cloth_sim->deformation_strength. 
*/
 cloth_brush_add_deformation_constraint(
-data->cloth_sim,node_index, vd.index, 
CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH);
+data->cloth_sim, node_index, vd.index, 
CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH);
   }
 }
 else if (data->cloth_sim->deformation_pos) {

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


[Bf-blender-cvs] [90a27d5aa91] master: Cleanup: Use enum for return values in context callbacks

2020-10-02 Thread Sybren A. Stüvel
Commit: 90a27d5aa91a1b6a25ea14e11c889d47f77f4cf7
Author: Sybren A. Stüvel
Date:   Fri Oct 2 18:56:25 2020 +0200
Branches: master
https://developer.blender.org/rB90a27d5aa91a1b6a25ea14e11c889d47f77f4cf7

Cleanup: Use enum for return values in context callbacks

Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).

This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.

The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.

This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.

No functional changes.

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

===

M   source/blender/blenkernel/BKE_context.h
M   source/blender/blenkernel/BKE_screen.h
M   source/blender/blenkernel/intern/context.c
M   source/blender/editors/screen/screen_context.c
M   source/blender/editors/space_buttons/buttons_context.c
M   source/blender/editors/space_clip/space_clip.c
M   source/blender/editors/space_image/space_image.c
M   source/blender/editors/space_node/space_node.c
M   source/blender/editors/space_sequencer/space_sequencer.c
M   source/blender/editors/space_text/space_text.c
M   source/blender/makesdna/DNA_screen_types.h
M   source/blender/python/intern/bpy_rna.c

===

diff --git a/source/blender/blenkernel/BKE_context.h 
b/source/blender/blenkernel/BKE_context.h
index f3e4a18b9bd..5c534803781 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -74,9 +74,26 @@ typedef struct bContext bContext;
 struct bContextDataResult;
 typedef struct bContextDataResult bContextDataResult;
 
-typedef int (*bContextDataCallback)(const bContext *C,
-const char *member,
-bContextDataResult *result);
+/* Result of context lookups.
+ * The specific values are important, and used implicitly in ctx_data_get(). 
Some functions also
+ * still accept/return `int` instead, to ensure that the compiler uses the 
correct storage size
+ * when mixing C/C++ code. */
+typedef enum eContextResult {
+  /* The context member was found, and its data is available. */
+  CTX_RESULT_OK = 1,
+
+  /* The context member was not found. */
+  CTX_RESULT_MEMBER_NOT_FOUND = 0,
+
+  /* The context member was found, but its data is not available.
+   * For example, "active_bone" is a valid context member, but has not data in 
Object mode. */
+  CTX_RESULT_NO_DATA = -1,
+} eContextResult;
+
+/* Function mapping a context member name to its value. */
+typedef int /*eContextResult*/ (*bContextDataCallback)(const bContext *C,
+   const char *member,
+   bContextDataResult 
*result);
 
 typedef struct bContextStoreEntry {
   struct bContextStoreEntry *next, *prev;
@@ -213,7 +230,7 @@ ListBase CTX_data_dir_get_ex(const bContext *C,
  const bool use_rna,
  const bool use_all);
 ListBase CTX_data_dir_get(const bContext *C);
-int CTX_data_get(
+int /*eContextResult*/ CTX_data_get(
 const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, 
short *r_type);
 
 void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id);
diff --git a/source/blender/blenkernel/BKE_screen.h 
b/source/blender/blenkernel/BKE_screen.h
index bcc58ecf2c5..35a3d0415a8 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -26,6 +26,8 @@
 
 #include "RNA_types.h"
 
+#include "BKE_context.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -106,7 +108,7 @@ typedef struct SpaceType {
   void (*gizmos)(void);
 
   /* return context data */
-  int (*context)(const struct bContext *C, const char *member, struct 
bContextDataResult *result);
+  bContextDataCallback context;
 
   /* Used when we want to replace an ID by another (or NULL). */
   void (*id_remap)(struct ScrArea *area,
@@ -181,7 +183,7 @@ typedef struct ARegionType {
   void (*cursor)(struct wmWindow *win, struct ScrArea *area, struct ARegion 
*region);
 
   /* return context data */
-  int (*context)(const struct bContext *C, const char *member, struct 
bContextDataResult *result);
+  bContextDataCallback context;
 

[Bf-blender-cvs] [f3934523946] master: Fix T81345, part two: crash in depsgraph when freeing COW armature.

2020-10-02 Thread Bastien Montagne
Commit: f3934523946962b807b0dd7e0863a437cfc56e27
Author: Bastien Montagne
Date:   Fri Oct 2 16:12:27 2020 +0200
Branches: master
https://developer.blender.org/rBf3934523946962b807b0dd7e0863a437cfc56e27

Fix T81345, part two: crash in depsgraph when freeing COW armature.

Freeing of bones' IDproerties from Armature `free_data` callback would always
attempt to do user refcounting, which should never be done from that code.

This would generate crashes in depsgraph/COW context e.g.

===

M   source/blender/blenkernel/BKE_armature.h
M   source/blender/blenkernel/intern/armature.c
M   source/blender/editors/armature/armature_utils.c

===

diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index d7ed92b69b7..975190f0fb5 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -141,7 +141,7 @@ typedef struct PoseTree {
 struct bArmature *BKE_armature_add(struct Main *bmain, const char *name);
 struct bArmature *BKE_armature_from_object(struct Object *ob);
 int BKE_armature_bonelist_count(struct ListBase *lb);
-void BKE_armature_bonelist_free(struct ListBase *lb);
+void BKE_armature_bonelist_free(struct ListBase *lb, const bool do_id_user);
 struct bArmature *BKE_armature_copy(struct Main *bmain, const struct bArmature 
*arm);
 
 void BKE_armature_copy_bone_transforms(struct bArmature *armature_dst,
diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index af9ce7c34ac..3d91d22e139 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -139,7 +139,7 @@ static void armature_free_data(struct ID *id)
   bArmature *armature = (bArmature *)id;
 
   BKE_armature_bone_hash_free(armature);
-  BKE_armature_bonelist_free(&armature->bonebase);
+  BKE_armature_bonelist_free(&armature->bonebase, false);
 
   /* free editmode data */
   if (armature->edbo) {
@@ -357,15 +357,15 @@ int BKE_armature_bonelist_count(ListBase *lb)
   return i;
 }
 
-void BKE_armature_bonelist_free(ListBase *lb)
+void BKE_armature_bonelist_free(ListBase *lb, const bool do_id_user)
 {
   Bone *bone;
 
   for (bone = lb->first; bone; bone = bone->next) {
 if (bone->prop) {
-  IDP_FreeProperty(bone->prop);
+  IDP_FreeProperty_ex(bone->prop, do_id_user);
 }
-BKE_armature_bonelist_free(&bone->childbase);
+BKE_armature_bonelist_free(&bone->childbase, do_id_user);
   }
 
   BLI_freelistN(lb);
diff --git a/source/blender/editors/armature/armature_utils.c 
b/source/blender/editors/armature/armature_utils.c
index 1c8c5ba9d94..29df8b31819 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -695,7 +695,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
 
   /* armature bones */
   BKE_armature_bone_hash_free(arm);
-  BKE_armature_bonelist_free(&arm->bonebase);
+  BKE_armature_bonelist_free(&arm->bonebase, true);
   arm->act_bone = NULL;
 
   /* remove zero sized bones, this gives unstable restposes */

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


[Bf-blender-cvs] [619e52eb827] master: Fix T81345: Part one: Missing handling of ID pointers from EditBone IDProperties.

2020-10-02 Thread Bastien Montagne
Commit: 619e52eb82744c9dc2a403a0aa12fa9e9141fe3b
Author: Bastien Montagne
Date:   Fri Oct 2 15:38:02 2020 +0200
Branches: master
https://developer.blender.org/rB619e52eb82744c9dc2a403a0aa12fa9e9141fe3b

Fix T81345: Part one: Missing handling of ID pointers from EditBone 
IDProperties.

So far data management code would simply fully ignore potential ID
pointers in custom properties of edit bones (which are a copy of those
from regular `Bone`). This would lead to all kind of issues, among which
refcounting inconsistencies, missing clearing of data uppon deletion,
etc.

===

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

===

diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index 49ca25aca29..af9ce7c34ac 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -160,12 +160,24 @@ static void armature_foreach_id_bone(Bone *bone, 
LibraryForeachIDData *data)
   }
 }
 
+static void armature_foreach_id_editbone(EditBone *edit_bone, 
LibraryForeachIDData *data)
+{
+  IDP_foreach_property(
+  edit_bone->prop, IDP_TYPE_FILTER_ID, 
BKE_lib_query_idpropertiesForeachIDLink_callback, data);
+}
+
 static void armature_foreach_id(ID *id, LibraryForeachIDData *data)
 {
   bArmature *arm = (bArmature *)id;
   LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
 armature_foreach_id_bone(bone, data);
   }
+
+  if (arm->edbo != NULL) {
+LISTBASE_FOREACH (EditBone *, edit_bone, arm->edbo) {
+  armature_foreach_id_editbone(edit_bone, data);
+}
+  }
 }
 
 static void write_bone(BlendWriter *writer, Bone *bone)

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


[Bf-blender-cvs] [5fc992e76ae] master: Cleanup: Move `EditBone` structure definition from `ED` to `BKE` area.

2020-10-02 Thread Bastien Montagne
Commit: 5fc992e76aeeedf1955c9d7c561fb8b7c8a398a5
Author: Bastien Montagne
Date:   Fri Oct 2 15:36:42 2020 +0200
Branches: master
https://developer.blender.org/rB5fc992e76aeeedf1955c9d7c561fb8b7c8a398a5

Cleanup: Move `EditBone` structure definition from `ED` to `BKE` area.

Access to this structure will be needed in BKE's armature code.

===

M   source/blender/blenkernel/BKE_armature.h
M   source/blender/editors/armature/armature_add.c
M   source/blender/editors/armature/armature_intern.h
M   source/blender/editors/armature/armature_select.c
M   source/blender/editors/armature/editarmature_undo.c
M   source/blender/editors/include/ED_armature.h
M   source/blender/editors/interface/interface_layout.c
M   source/blender/editors/object/object_modifier.c
M   source/blender/editors/object/object_utils.c
M   source/blender/editors/space_buttons/buttons_context.c
M   source/blender/editors/space_info/info_stats.c
M   source/blender/editors/space_outliner/outliner_draw.c
M   source/blender/editors/space_outliner/outliner_edit.c
M   source/blender/editors/space_outliner/outliner_tools.c
M   source/blender/editors/space_outliner/outliner_tree.c
M   source/blender/editors/space_outliner/outliner_utils.c
M   source/blender/editors/space_view3d/view3d_buttons.c
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/editors/transform/transform_gizmo_3d.c
M   source/blender/editors/transform/transform_orientations.c
M   source/blender/editors/util/ed_transverts.c
M   source/blender/io/collada/collada_internal.cpp
M   source/blender/io/collada/collada_utils.cpp

===

diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index 8164d34f32b..d7ed92b69b7 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -30,6 +30,7 @@ extern "C" {
 struct BMEditMesh;
 struct Bone;
 struct Depsgraph;
+struct IDProperty;
 struct ListBase;
 struct Main;
 struct Mesh;
@@ -42,6 +43,77 @@ struct bGPDstroke;
 struct bPose;
 struct bPoseChannel;
 
+typedef struct EditBone {
+  struct EditBone *next, *prev;
+  /** User-Defined Properties on this Bone */
+  struct IDProperty *prop;
+  /** Editbones have a one-way link  (i.e. children refer
+   * to parents.  This is converted to a two-way link for
+   * normal bones when leaving editmode. */
+  struct EditBone *parent;
+  /** (64 == MAXBONENAME) */
+  char name[64];
+  /** Roll along axis.  We'll ultimately use the axis/angle method
+   * for determining the transformation matrix of the bone.  The axis
+   * is tail-head while roll provides the angle. Refer to Graphics
+   * Gems 1 p. 466 (section IX.6) if it's not already in here somewhere*/
+  float roll;
+
+  /** Orientation and length is implicit during editing */
+  float head[3];
+  float tail[3];
+  /** All joints are considered to have zero rotation with respect to
+   * their parents. Therefore any rotations specified during the
+   * animation are automatically relative to the bones' rest positions*/
+  int flag;
+  int layer;
+  char inherit_scale_mode;
+
+  /* Envelope distance & weight */
+  float dist, weight;
+  /** put them in order! transform uses this as scale */
+  float xwidth, length, zwidth;
+  float rad_head, rad_tail;
+
+  /* Bendy-Bone parameters */
+  short segments;
+  float roll1, roll2;
+  float curve_in_x, curve_in_y;
+  float curve_out_x, curve_out_y;
+  float ease1, ease2;
+  float scale_in_x, scale_in_y;
+  float scale_out_x, scale_out_y;
+
+  /** for envelope scaling */
+  float oldlength;
+
+  /** Type of next/prev bone handles */
+  char bbone_prev_type;
+  char bbone_next_type;
+  /** Next/prev bones to use as handle references when calculating bbones 
(optional) */
+  struct EditBone *bbone_prev;
+  struct EditBone *bbone_next;
+
+  /* Used for display */
+  /** in Armature space, rest pos matrix */
+  float disp_mat[4][4];
+  /** in Armature space, rest pos matrix */
+  float disp_tail_mat[4][4];
+  /** in Armature space, rest pos matrix (32 == MAX_BBONE_SUBDIV) */
+  float disp_bbone_mat[32][4][4];
+
+  /** connected child temporary during drawing */
+  struct EditBone *bbone_child;
+
+  /* Used to store temporary data */
+  union {
+struct EditBone *ebone;
+struct Bone *bone;
+void *p;
+int i;
+  } temp;
+} EditBone;
+
 typedef struct PoseTarget {
   struct PoseTarget *next, *prev;
 
diff --git a/source/blender/editors/armature/armature_add.c 
b/source/blender/editors/armature/armature_add.c
index 016a00bda56..5f01c4ed038 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -36,6 +36,7 @@
 #include "BLI_string_utils.h"
 
 #include "BKE_action.h"
+#include "BKE_armature.h"
 #include "BKE_constraint.h"
 #i

[Bf-blender-cvs] [4b36552967b] master: Fix T81345: part three, armature `free_data` was not handling editbones properly.

2020-10-02 Thread Bastien Montagne
Commit: 4b36552967bf55b1bf707acd3917280b42b12c52
Author: Bastien Montagne
Date:   Fri Oct 2 17:36:13 2020 +0200
Branches: master
https://developer.blender.org/rB4b36552967bf55b1bf707acd3917280b42b12c52

Fix T81345: part three, armature `free_data` was not handling editbones 
properly.

Armature freeing would not correctly free its editbone IDProperties.

Add a utils to free the whole list of edit bones, and properly handle
their potential IDProperties.

===

M   source/blender/blenkernel/BKE_armature.h
M   source/blender/blenkernel/intern/armature.c

===

diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index 975190f0fb5..092ca85a570 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -142,6 +142,7 @@ struct bArmature *BKE_armature_add(struct Main *bmain, 
const char *name);
 struct bArmature *BKE_armature_from_object(struct Object *ob);
 int BKE_armature_bonelist_count(struct ListBase *lb);
 void BKE_armature_bonelist_free(struct ListBase *lb, const bool do_id_user);
+void BKE_armature_editbonelist_free(struct ListBase *lb, const bool 
do_id_user);
 struct bArmature *BKE_armature_copy(struct Main *bmain, const struct bArmature 
*arm);
 
 void BKE_armature_copy_bone_transforms(struct bArmature *armature_dst,
diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index 3d91d22e139..0a731f0a7f0 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -143,8 +143,7 @@ static void armature_free_data(struct ID *id)
 
   /* free editmode data */
   if (armature->edbo) {
-BLI_freelistN(armature->edbo);
-
+BKE_armature_editbonelist_free(armature->edbo, false);
 MEM_freeN(armature->edbo);
 armature->edbo = NULL;
   }
@@ -371,6 +370,17 @@ void BKE_armature_bonelist_free(ListBase *lb, const bool 
do_id_user)
   BLI_freelistN(lb);
 }
 
+void BKE_armature_editbonelist_free(ListBase *lb, const bool do_id_user)
+{
+  LISTBASE_FOREACH_MUTABLE (EditBone *, edit_bone, lb) {
+if (edit_bone->prop) {
+  IDP_FreeProperty_ex(edit_bone->prop, do_id_user);
+}
+BLI_remlink_safe(lb, edit_bone);
+MEM_freeN(edit_bone);
+  }
+}
+
 static void copy_bonechildren(Bone *bone_dst,
   const Bone *bone_src,
   const Bone *bone_src_act,

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


[Bf-blender-cvs] [0db98b214d4] master: Fix T81345: part four, fix handling of IDProperties in edit armature undo.

2020-10-02 Thread Bastien Montagne
Commit: 0db98b214d468864630fc9bba72be4ff9b2548e5
Author: Bastien Montagne
Date:   Fri Oct 2 17:38:28 2020 +0200
Branches: master
https://developer.blender.org/rB0db98b214d468864630fc9bba72be4ff9b2548e5

Fix T81345: part four, fix handling of IDProperties in edit armature undo.

Specific armature editing undo code would duplicate and store a list of
editbones. However, those are not linked to main data storage and should
therefore never affect ID usercounting.

===

M   source/blender/editors/armature/armature_utils.c
M   source/blender/editors/armature/editarmature_undo.c
M   source/blender/editors/include/ED_armature.h

===

diff --git a/source/blender/editors/armature/armature_utils.c 
b/source/blender/editors/armature/armature_utils.c
index 29df8b31819..fba88e78162 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -35,6 +35,7 @@
 #include "BKE_deform.h"
 #include "BKE_global.h"
 #include "BKE_idprop.h"
+#include "BKE_lib_id.h"
 #include "BKE_main.h"
 
 #include "DEG_depsgraph.h"
@@ -847,7 +848,7 @@ void ED_armature_to_edit(bArmature *arm)
 
 /* free's bones and their properties */
 
-void ED_armature_ebone_listbase_free(ListBase *lb)
+void ED_armature_ebone_listbase_free(ListBase *lb, const bool do_id_user)
 {
   EditBone *ebone, *ebone_next;
 
@@ -855,7 +856,7 @@ void ED_armature_ebone_listbase_free(ListBase *lb)
 ebone_next = ebone->next;
 
 if (ebone->prop) {
-  IDP_FreeProperty(ebone->prop);
+  IDP_FreeProperty_ex(ebone->prop, do_id_user);
 }
 
 MEM_freeN(ebone);
@@ -864,7 +865,7 @@ void ED_armature_ebone_listbase_free(ListBase *lb)
   BLI_listbase_clear(lb);
 }
 
-void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src)
+void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src, const 
bool do_id_user)
 {
   EditBone *ebone_src;
   EditBone *ebone_dst;
@@ -874,7 +875,8 @@ void ED_armature_ebone_listbase_copy(ListBase *lb_dst, 
ListBase *lb_src)
   for (ebone_src = lb_src->first; ebone_src; ebone_src = ebone_src->next) {
 ebone_dst = MEM_dupallocN(ebone_src);
 if (ebone_dst->prop) {
-  ebone_dst->prop = IDP_CopyProperty(ebone_dst->prop);
+  ebone_dst->prop = IDP_CopyProperty_ex(ebone_dst->prop,
+do_id_user ? 0 : 
LIB_ID_CREATE_NO_USER_REFCOUNT);
 }
 ebone_src->temp.ebone = ebone_dst;
 BLI_addtail(lb_dst, ebone_dst);
diff --git a/source/blender/editors/armature/editarmature_undo.c 
b/source/blender/editors/armature/editarmature_undo.c
index bdb08abbf2c..c217b615db6 100644
--- a/source/blender/editors/armature/editarmature_undo.c
+++ b/source/blender/editors/armature/editarmature_undo.c
@@ -64,8 +64,8 @@ static void undoarm_to_editarm(UndoArmature *uarm, bArmature 
*arm)
 {
   EditBone *ebone;
 
-  ED_armature_ebone_listbase_free(arm->edbo);
-  ED_armature_ebone_listbase_copy(arm->edbo, &uarm->lb);
+  ED_armature_ebone_listbase_free(arm->edbo, true);
+  ED_armature_ebone_listbase_copy(arm->edbo, &uarm->lb, true);
 
   /* active bone */
   if (uarm->act_edbone) {
@@ -86,7 +86,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, 
bArmature *arm)
   /* TODO: include size of ID-properties. */
   uarm->undo_size = 0;
 
-  ED_armature_ebone_listbase_copy(&uarm->lb, arm->edbo);
+  ED_armature_ebone_listbase_copy(&uarm->lb, arm->edbo, false);
 
   /* active bone */
   if (arm->act_edbone) {
@@ -105,7 +105,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, 
bArmature *arm)
 
 static void undoarm_free_data(UndoArmature *uarm)
 {
-  ED_armature_ebone_listbase_free(&uarm->lb);
+  ED_armature_ebone_listbase_free(&uarm->lb, false);
 }
 
 static Object *editarm_object_from_context(bContext *C)
diff --git a/source/blender/editors/include/ED_armature.h 
b/source/blender/editors/include/ED_armature.h
index 1eeb81d4dc7..3501acd4fdf 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -171,8 +171,10 @@ void ED_armature_from_edit(struct Main *bmain, struct 
bArmature *arm);
 void ED_armature_to_edit(struct bArmature *arm);
 void ED_armature_edit_free(struct bArmature *arm);
 void ED_armature_ebone_listbase_temp_clear(struct ListBase *lb);
-void ED_armature_ebone_listbase_free(struct ListBase *lb);
-void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst, struct ListBase 
*lb_src);
+void ED_armature_ebone_listbase_free(struct ListBase *lb, const bool 
do_id_user);
+void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst,
+ struct ListBase *lb_src,
+ const bool do_id_user);
 
 /* low level selection functions which handle */
 int ED_armature_ebone_selectflag_get(const struct EditBone *ebone);

___
B

[Bf-blender-cvs] [e3b49bb8500] master: Fix T81200: Crash on certain armature select operators when OpenGL Depth Picking is disabled

2020-10-02 Thread Philipp Oeser
Commit: e3b49bb850018ae73088b8d4e7c195206f8b2f31
Author: Philipp Oeser
Date:   Thu Oct 1 18:11:51 2020 +0200
Branches: master
https://developer.blender.org/rBe3b49bb850018ae73088b8d4e7c195206f8b2f31

Fix T81200: Crash on certain armature select operators when OpenGL Depth
Picking is disabled

Affected were (at least)
- Select Linked pick
- Select Shortest Path

Was originally caused by rB8b347fc2cdc6 [which got improved in
rBfc8a7a44b200 - but only partially].

After removal of BONESEL_NOSEL we have to filter out -1 from the hits for
any bone picking it seems (since armature drawing uses this).
In rBfc8a7a44b200, this was done for 'ED_armature_edit_select_pick' (or
'get_nearest_editbonepoint' precisely), now do this for
'ed_armature_pick_bone_impl' as well.

Reviewers: campbellbarton

Maniphest Tasks: T81200

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

===

M   source/blender/editors/armature/armature_select.c

===

diff --git a/source/blender/editors/armature/armature_select.c 
b/source/blender/editors/armature/armature_select.c
index 4c5efb304c9..09d54410e55 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -335,8 +335,16 @@ static void *ed_armature_pick_bone_impl(
 
   BLI_rcti_init_pt_radius(&rect, xy, 0);
 
-  hits = view3d_opengl_select(
-  &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST, 
VIEW3D_SELECT_FILTER_NOP);
+  /* Don't use hits with this ID, (armature drawing uses this). */
+  const int select_id_ignore = -1;
+
+  hits = view3d_opengl_select_with_id_filter(&vc,
+ buffer,
+ MAXPICKBUF,
+ &rect,
+ VIEW3D_SELECT_PICK_NEAREST,
+ VIEW3D_SELECT_FILTER_NOP,
+ select_id_ignore);
 
   *r_base = NULL;

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


[Bf-blender-cvs] [81573058698] master: UI: Improve UV sticky select mode description

2020-10-02 Thread Hans Goudey
Commit: 81573058698dfc4a9a171dffa61c1c8d5d42377b
Author: Hans Goudey
Date:   Fri Oct 2 09:17:40 2020 -0500
Branches: master
https://developer.blender.org/rB81573058698dfc4a9a171dffa61c1c8d5d42377b

UI: Improve UV sticky select mode description

The sticky_select_mode property is an enum where each item has a
different behavior, but currently the description is for a single one
of the items. It should be more general, especially because one of the
items is "Disabled."

A couple more problems:
 - "Automatically" is not so helpful. Many things any program does are
   "automatic", it doesn't really help to say it.
 - "Also" is bad grammar.
 - Overly complex wording

This also adjusts the SHARED_VERTEX tooltip, because "irrespective"
should have "of" after, but it's also unecessarily complex.

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

===

M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index aa928b642f9..39938d6e470 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2836,7 +2836,7 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
"SHARED_VERTEX",
ICON_STICKY_UVS_VERT,
"Shared Vertex",
-   "Select UVs that share mesh vertex, irrespective if they are in the 
same location"},
+   "Select UVs that share a mesh vertex, whether or not they are at the 
same location"},
   {0, NULL, 0, NULL, NULL},
   };
 
@@ -2864,9 +2864,7 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
   RNA_def_property_enum_sdna(prop, NULL, "sticky");
   RNA_def_property_enum_items(prop, sticky_mode_items);
   RNA_def_property_ui_text(
-  prop,
-  "Sticky Selection Mode",
-  "Automatically select also UVs sharing the same vertex as the ones being 
selected");
+  prop, "Sticky Selection Mode", "Method for extending UV vertex 
selection");
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
 
   /* drawing */

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


[Bf-blender-cvs] [c65c4149c9b] master: Cleanup: Refactor `ed_screen_context()` to use hash lookups

2020-10-02 Thread Sybren A. Stüvel
Commit: c65c4149c9be8a1811eb389f657216fab071dfc5
Author: Sybren A. Stüvel
Date:   Fri Oct 2 12:57:11 2020 +0200
Branches: master
https://developer.blender.org/rBc65c4149c9be8a1811eb389f657216fab071dfc5

Cleanup: Refactor `ed_screen_context()` to use hash lookups

Refactor `ed_screen_context()` to use `GHash` lookups instead of a
sequence of string comparisons. This should provide a nice speedup,
given that the hash for `member` only has to be computed once instead of
matching it to each possible string.

Reviwed by: brecht

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

===

M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 84f16e8667d..e32d374d094 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -43,6 +43,7 @@
 
 #include "BKE_action.h"
 #include "BKE_armature.h"
+#include "BKE_blender.h"
 #include "BKE_context.h"
 #include "BKE_gpencil.h"
 #include "BKE_layer.h"
@@ -976,6 +977,81 @@ static int screen_ctx_active_editable_fcurve(const 
bContext *C, bContextDataResu
   return -1; /* found but not available */
 }
 
+/* Registry of context callback functions. */
+
+typedef int (*context_callback)(const bContext *C, bContextDataResult *result);
+static GHash *ed_screen_context_functions = NULL;
+
+static void free_context_function_ghash(void *UNUSED(user_data))
+{
+  BLI_ghash_free(ed_screen_context_functions, NULL, NULL);
+}
+static inline void register_context_function(const char *member, 
context_callback function)
+{
+  BLI_ghash_insert(ed_screen_context_functions, (void *)member, function);
+}
+
+static void ensure_ed_screen_context_functions(void)
+{
+  if (ed_screen_context_functions != NULL) {
+return;
+  }
+
+  /* Murmur hash is faster for smaller strings (according to BLI_hash_mm2). */
+  ed_screen_context_functions = BLI_ghash_new(
+  BLI_ghashutil_strhash_p_murmur, BLI_ghashutil_strcmp, __func__);
+
+  BKE_blender_atexit_register(free_context_function_ghash, NULL);
+
+  register_context_function("scene", screen_ctx_scene);
+  register_context_function("visible_objects", screen_ctx_visible_objects);
+  register_context_function("selectable_objects", 
screen_ctx_selectable_objects);
+  register_context_function("selected_objects", screen_ctx_selected_objects);
+  register_context_function("selected_editable_objects", 
screen_ctx_selected_editable_objects);
+  register_context_function("editable_objects", screen_ctx_editable_objects);
+  register_context_function("objects_in_mode", screen_ctx_objects_in_mode);
+  register_context_function("objects_in_mode_unique_data", 
screen_ctx_objects_in_mode_unique_data);
+  register_context_function("visible_bones", screen_ctx_visible_bones);
+  register_context_function("editable_bones", screen_ctx_editable_bones);
+  register_context_function("selected_bones", screen_ctx_selected_bones);
+  register_context_function("selected_editable_bones", 
screen_ctx_selected_editable_bones);
+  register_context_function("visible_pose_bones", 
screen_ctx_visible_pose_bones);
+  register_context_function("selected_pose_bones", 
screen_ctx_selected_pose_bones);
+  register_context_function("selected_pose_bones_from_active_object",
+screen_ctx_selected_pose_bones_from_active_object);
+  register_context_function("active_bone", screen_ctx_active_bone);
+  register_context_function("active_pose_bone", screen_ctx_active_pose_bone);
+  register_context_function("active_object", screen_ctx_active_object);
+  register_context_function("object", screen_ctx_object);
+  register_context_function("edit_object", screen_ctx_edit_object);
+  register_context_function("sculpt_object", screen_ctx_sculpt_object);
+  register_context_function("vertex_paint_object", 
screen_ctx_vertex_paint_object);
+  register_context_function("weight_paint_object", 
screen_ctx_weight_paint_object);
+  register_context_function("image_paint_object", 
screen_ctx_image_paint_object);
+  register_context_function("particle_edit_object", 
screen_ctx_particle_edit_object);
+  register_context_function("pose_object", screen_ctx_pose_object);
+  register_context_function("sequences", screen_ctx_sequences);
+  register_context_function("selected_sequences", 
screen_ctx_selected_sequences);
+  register_context_function("selected_editable_sequences", 
screen_ctx_selected_editable_sequences);
+  register_context_function("selected_nla_strips", 
screen_ctx_selected_nla_strips);
+  register_context_function("gpencil_data", screen_ctx_gpencil_data);
+  register_context_function("gpencil_data_owner", 
screen_ctx_gpencil_data_owner);
+  register_context_function("annotation_data", screen_ctx_annotation_data);
+  register_context_function("annotation_data_owner"

[Bf-blender-cvs] [ab72406dc34] master: Cleanup: split up `ed_screen_context()` into separate functions

2020-10-02 Thread Sybren A. Stüvel
Commit: ab72406dc347b428b5ef6981afd1ca45781f0ae6
Author: Sybren A. Stüvel
Date:   Fri Oct 2 11:56:06 2020 +0200
Branches: master
https://developer.blender.org/rBab72406dc347b428b5ef6981afd1ca45781f0ae6

Cleanup: split up `ed_screen_context()` into separate functions

Refactor `ed_screen_context()` to call separate functions, instead of
having the entire functionality in one function. Each function now only
retrieves the data it needs from the context. Furthermore, some string
comparisons are removed.

No functional changes.

Reviwed by: brecht

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

===

M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 89d6befbb25..84f16e8667d 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -37,6 +37,7 @@
 #include "DNA_space_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "BLI_ghash.h"
 #include "BLI_listbase.h"
 #include "BLI_utildefines.h"
 
@@ -110,669 +111,1016 @@ const char *screen_context_dir[] = {
 NULL,
 };
 
-int ed_screen_context(const bContext *C, const char *member, 
bContextDataResult *result)
+/* Each function `screen_ctx_XXX()` will be called when the screen context 
"XXX" is requested.
+ * ensure_ed_screen_context_functions() is responsible for creating the hash 
map from context
+ * member name to function.
+ *
+ * Each function returns:
+ *1 for "the member name was found and returned data is valid"
+ *0 for "the member name was not found"
+ *   -1 for "the member name was found but data is not available"
+ *
+ * */
+
+static int screen_ctx_scene(const bContext *C, bContextDataResult *result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  Scene *scene = WM_window_get_active_scene(win);
+  CTX_data_id_pointer_set(result, &scene->id);
+  return 1;
+}
+static int screen_ctx_visible_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_VISIBLE(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selectable_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_SELECTABLE(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selected_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_SELECTED(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selected_editable_objects(const bContext *C, 
bContextDataResult *result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_SELECTED_EDITABLE(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_editable_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  /* Visible + Editable, but not necessarily selected */
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_EDITABLE(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
+}
+  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_objects_in_mode(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+  Object 

[Bf-blender-cvs] [66cd82a8d23] master: Volumes: make Mesh to Volume modifier independent of object transforms

2020-10-02 Thread Jacques Lucke
Commit: 66cd82a8d23be2e78a3536706c1b66e3cbf8476f
Author: Jacques Lucke
Date:   Fri Oct 2 15:14:08 2020 +0200
Branches: master
https://developer.blender.org/rB66cd82a8d23be2e78a3536706c1b66e3cbf8476f

Volumes: make Mesh to Volume modifier independent of object transforms

===

M   source/blender/modifiers/intern/MOD_mesh_to_volume.cc

===

diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc 
b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
index 6fdc78c6ce9..2d6791cbe68 100644
--- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
+++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
@@ -120,7 +120,6 @@ static void initData(ModifierData *md)
 static void updateDepsgraph(ModifierData *md, const 
ModifierUpdateDepsgraphContext *ctx)
 {
   MeshToVolumeModifierData *mvmd = reinterpret_cast(md);
-  DEG_add_modifier_to_transform_relation(ctx->node, "Mesh to Volume Modifier");
   if (mvmd->object) {
 DEG_add_object_relation(
 ctx->node, mvmd->object, DEG_OB_COMP_GEOMETRY, "Mesh to Volume 
Modifier");
@@ -198,7 +197,9 @@ static float compute_voxel_size(const 
MeshToVolumeModifierData *mvmd,
   return voxel_size;
 }
 
-static Volume *modifyVolume(ModifierData *md, const ModifierEvalContext *ctx, 
Volume *input_volume)
+static Volume *modifyVolume(ModifierData *md,
+const ModifierEvalContext *UNUSED(ctx),
+Volume *input_volume)
 {
 #ifdef WITH_OPENVDB
   using namespace blender;
@@ -215,8 +216,7 @@ static Volume *modifyVolume(ModifierData *md, const 
ModifierEvalContext *ctx, Vo
   }
   BKE_mesh_wrapper_ensure_mdata(mesh);
 
-  const float4x4 mesh_to_own_object_space_transform = 
float4x4(ctx->object->imat) *
-  
float4x4(object_to_convert->obmat);
+  const float4x4 mesh_to_own_object_space_transform = object_to_convert->obmat;
   const float voxel_size = compute_voxel_size(mvmd, 
mesh_to_own_object_space_transform);
 
   float4x4 mesh_to_index_space_transform;
@@ -263,7 +263,7 @@ static Volume *modifyVolume(ModifierData *md, const 
ModifierEvalContext *ctx, Vo
   return volume;
 
 #else
-  UNUSED_VARS(md, ctx);
+  UNUSED_VARS(md);
   UNUSED_VARS(compute_voxel_size);
   BKE_modifier_set_error(md, "Compiled without OpenVDB");
   return input_volume;

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


[Bf-blender-cvs] [74ea3698303] master: Experimental Features: More robust way of sanitizing options

2020-10-02 Thread Dalai Felinto
Commit: 74ea36983038da1a2f00b35feed81032fcd666eb
Author: Dalai Felinto
Date:   Fri Oct 2 12:57:23 2020 +0200
Branches: master
https://developer.blender.org/rB74ea36983038da1a2f00b35feed81032fcd666eb

Experimental Features: More robust way of sanitizing options

===

M   source/blender/blenloader/intern/versioning_userdef.c
M   source/blender/makesdna/DNA_userdef_types.h

===

diff --git a/source/blender/blenloader/intern/versioning_userdef.c 
b/source/blender/blenloader/intern/versioning_userdef.c
index a9082d207ca..ded371aa2d8 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -824,11 +824,8 @@ void 
BLO_sanitize_experimental_features_userpref_blend(UserDef *userdef)
   if (BKE_blender_version_is_alpha()) {
 return;
   }
-  userdef->experimental.use_new_particle_system = false;
-  userdef->experimental.use_new_hair_type = false;
-  userdef->experimental.use_sculpt_vertex_colors = false;
-  userdef->experimental.use_tools_missing_icons = false;
-  userdef->experimental.use_switch_object_operator = false;
+
+  MEMSET_STRUCT_AFTER(&userdef->experimental, 0, SANITIZE_AFTER_HERE);
 }
 
 #undef USER_LMOUSESELECT
diff --git a/source/blender/makesdna/DNA_userdef_types.h 
b/source/blender/makesdna/DNA_userdef_types.h
index 47b8e5b83bd..f0a1378920e 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -626,13 +626,15 @@ typedef struct UserDef_Experimental {
   char use_undo_legacy;
   char use_cycles_debug;
   char use_image_editor_legacy_drawing;
-  /* Other options - remember to turn them off on
-   * BLO_sanitize_experimental_features_userpref_blend. */
+  char SANITIZE_AFTER_HERE;
+  /* The following options are automatically sanitized (set to 0)
+   * when the release cycle is not alpha. */
   char use_new_particle_system;
   char use_new_hair_type;
   char use_sculpt_vertex_colors;
   char use_tools_missing_icons;
   char use_switch_object_operator;
+  char _pad[7];
 } UserDef_Experimental;
 
 #define USER_EXPERIMENTAL_TEST(userdef, member) \

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


[Bf-blender-cvs] [cb363953f0b] master: Experimental Features: Sanitize missing (latest) options

2020-10-02 Thread Dalai Felinto
Commit: cb363953f0b2c33f72d956485aa12f32ba099ca1
Author: Dalai Felinto
Date:   Fri Oct 2 12:01:23 2020 +0200
Branches: master
https://developer.blender.org/rBcb363953f0b2c33f72d956485aa12f32ba099ca1

Experimental Features: Sanitize missing (latest) options

There was an oversight when adding new experimental user preferences.
I can try to overengineer this later to make it more fail-proof. But for now
it should be clear what to update when adding a new variable.

===

M   source/blender/blenloader/intern/versioning_userdef.c
M   source/blender/makesdna/DNA_userdef_types.h

===

diff --git a/source/blender/blenloader/intern/versioning_userdef.c 
b/source/blender/blenloader/intern/versioning_userdef.c
index 0265bd85f14..a9082d207ca 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -827,6 +827,8 @@ void 
BLO_sanitize_experimental_features_userpref_blend(UserDef *userdef)
   userdef->experimental.use_new_particle_system = false;
   userdef->experimental.use_new_hair_type = false;
   userdef->experimental.use_sculpt_vertex_colors = false;
+  userdef->experimental.use_tools_missing_icons = false;
+  userdef->experimental.use_switch_object_operator = false;
 }
 
 #undef USER_LMOUSESELECT
diff --git a/source/blender/makesdna/DNA_userdef_types.h 
b/source/blender/makesdna/DNA_userdef_types.h
index 1ed2fba208f..47b8e5b83bd 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -622,12 +622,15 @@ typedef struct UserDef_FileSpaceData {
 } UserDef_FileSpaceData;
 
 typedef struct UserDef_Experimental {
+  /* Debug options, always available. */
   char use_undo_legacy;
+  char use_cycles_debug;
+  char use_image_editor_legacy_drawing;
+  /* Other options - remember to turn them off on
+   * BLO_sanitize_experimental_features_userpref_blend. */
   char use_new_particle_system;
   char use_new_hair_type;
-  char use_cycles_debug;
   char use_sculpt_vertex_colors;
-  char use_image_editor_legacy_drawing;
   char use_tools_missing_icons;
   char use_switch_object_operator;
 } UserDef_Experimental;

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


[Bf-blender-cvs] [92a0ec87a24] master: Experimental Features: Rename Image editor option

2020-10-02 Thread Dalai Felinto
Commit: 92a0ec87a241fb279f8362e5f2d7cc2c4e57c6d1
Author: Dalai Felinto
Date:   Fri Oct 2 12:24:59 2020 +0200
Branches: master
https://developer.blender.org/rB92a0ec87a241fb279f8362e5f2d7cc2c4e57c6d1

Experimental Features: Rename Image editor option

This prevents having multiple UI strings starting exactly the same:
* Legacy A...
* Legacy B ...

===

M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/source/blender/makesrna/intern/rna_userdef.c 
b/source/blender/makesrna/intern/rna_userdef.c
index 9477f99e826..2e9838d689b 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6168,7 +6168,7 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
   prop = RNA_def_property(srna, "use_image_editor_legacy_drawing", 
PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "use_image_editor_legacy_drawing", 
1);
   RNA_def_property_ui_text(
-  prop, "Legacy Image Editor Drawing", "Use legacy UV/Image editor 
drawing");
+  prop, "Image Editor Legacy Drawing", "Use legacy UV/Image editor 
drawing");
 
   prop = RNA_def_property(srna, "use_tools_missing_icons", PROP_BOOLEAN, 
PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "use_tools_missing_icons", 1);

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


[Bf-blender-cvs] [5476017d070] master: CleanUp: Remove header only definition

2020-10-02 Thread Jeroen Bakker
Commit: 5476017d070b182d39672a40f404173cf1932994
Author: Jeroen Bakker
Date:   Fri Oct 2 11:47:49 2020 +0200
Branches: master
https://developer.blender.org/rB5476017d070b182d39672a40f404173cf1932994

CleanUp: Remove header only definition

node_draw_link_straight existed in header files without a body

===

M   source/blender/editors/space_node/drawnode.c
M   source/blender/editors/space_node/node_intern.h

===

diff --git a/source/blender/editors/space_node/drawnode.c 
b/source/blender/editors/space_node/drawnode.c
index 9db89ec1ba2..9373c434b9b 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -4128,7 +4128,6 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, 
bNodeLink *link)
   }
 
   node_draw_link_bezier(v2d, snode, link, th_col1, th_col2, th_col3);
-  //  node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, 
do_triple, th_col3);
 }
 
 void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, 
NodeBorder border, uint pos)
diff --git a/source/blender/editors/space_node/node_intern.h 
b/source/blender/editors/space_node/node_intern.h
index a1df40ebd1c..1a0b5dc9ee8 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -156,16 +156,6 @@ bool node_link_bezier_points(struct View2D *v2d,
  struct bNodeLink *link,
  float coord_array[][2],
  int resol);
-#if 0
-void node_draw_link_straight(View2D *v2d,
- SpaceNode *snode,
- bNodeLink *link,
- int th_col1,
- int do_shaded,
- int th_col2,
- int do_triple,
- int th_col3);
-#endif
 void draw_nodespace_back_pix(const struct bContext *C,
  struct ARegion *region,
  struct SpaceNode *snode,

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


[Bf-blender-cvs] [57c0287f8bb] asset-browser: Merge branch 'asset-metadata' into asset-browser

2020-10-02 Thread Julian Eisel
Commit: 57c0287f8bb7afe4d636182026df2e53b1311f2e
Author: Julian Eisel
Date:   Fri Oct 2 12:41:22 2020 +0200
Branches: asset-browser
https://developer.blender.org/rB57c0287f8bb7afe4d636182026df2e53b1311f2e

Merge branch 'asset-metadata' into asset-browser

===



===



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


[Bf-blender-cvs] [b5ad69832e9] master: Cleanup: reduce variable scopes

2020-10-02 Thread Jacques Lucke
Commit: b5ad69832e99f4f4d1bbdac2e57bccb303ba05f5
Author: Jacques Lucke
Date:   Fri Oct 2 13:03:39 2020 +0200
Branches: master
https://developer.blender.org/rBb5ad69832e99f4f4d1bbdac2e57bccb303ba05f5

Cleanup: reduce variable scopes

===

M   source/blender/makesdna/intern/makesdna.c

===

diff --git a/source/blender/makesdna/intern/makesdna.c 
b/source/blender/makesdna/intern/makesdna.c
index f5a35783dca..3782f265913 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -354,8 +354,6 @@ static bool is_name_legal(const char *name)
 
 static int add_type(const char *str, int size)
 {
-  char *cp;
-
   /* first do validity check */
   if (str[0] == 0) {
 return -1;
@@ -382,7 +380,7 @@ static int add_type(const char *str, int size)
 
   /* append new type */
   const int str_size = strlen(str) + 1;
-  cp = BLI_memarena_alloc(mem_arena, str_size);
+  char *cp = BLI_memarena_alloc(mem_arena, str_size);
   memcpy(cp, str, str_size);
   types[types_len] = cp;
   types_size_native[types_len] = size;
@@ -408,8 +406,6 @@ static int add_type(const char *str, int size)
  * */
 static int add_name(const char *str)
 {
-  int nr, i, j, k;
-  char *cp;
   char buf[255]; /* stupid limit, change it :) */
   const char *name;
 
@@ -428,7 +424,7 @@ static int add_name(const char *str)
 
 DEBUG_PRINTF(3, "\t\t\t\t*** Function pointer or multidim array pointer 
found\n");
 /* functionpointer: transform the type (sometimes) */
-i = 0;
+int i = 0;
 
 while (str[i] != ')') {
   buf[i] = str[i];
@@ -438,7 +434,7 @@ static int add_name(const char *str)
 /* Another number we need is the extra slen offset. This extra
  * offset is the overshoot after a space. If there is no
  * space, no overshoot should be calculated. */
-j = i; /* j at first closing brace */
+int j = i; /* j at first closing brace */
 
 DEBUG_PRINTF(3, "first brace after offset %d\n", i);
 
@@ -466,7 +462,7 @@ static int add_name(const char *str)
 else if (str[j] == 0) {
   DEBUG_PRINTF(3, "offsetting for space\n");
   /* get additional offset */
-  k = 0;
+  int k = 0;
   while (str[j] != ')') {
 j++;
 k++;
@@ -522,7 +518,7 @@ static int add_name(const char *str)
   }
 
   /* search name array */
-  for (nr = 0; nr < names_len; nr++) {
+  for (int nr = 0; nr < names_len; nr++) {
 if (STREQ(name, names[nr])) {
   return nr;
 }
@@ -535,7 +531,7 @@ static int add_name(const char *str)
 
   /* Append new name. */
   const int name_size = strlen(name) + 1;
-  cp = BLI_memarena_alloc(mem_arena, name_size);
+  char *cp = BLI_memarena_alloc(mem_arena, name_size);
   memcpy(cp, name, name_size);
   names[names_len] = cp;
 
@@ -550,19 +546,16 @@ static int add_name(const char *str)
 
 static short *add_struct(int namecode)
 {
-  int len;
-  short *sp;
-
   if (structs_len == 0) {
 structs[0] = structdata;
   }
   else {
-sp = structs[structs_len - 1];
-len = sp[1];
+short *sp = structs[structs_len - 1];
+const int len = sp[1];
 structs[structs_len] = sp + 2 * len + 2;
   }
 
-  sp = structs[structs_len];
+  short *sp = structs[structs_len];
   sp[0] = namecode;
 
   if (structs_len >= max_array_len) {
@@ -576,21 +569,18 @@ static short *add_struct(int namecode)
 
 static int preprocess_include(char *maindata, const int maindata_len)
 {
-  int a, newlen, comment = 0;
-  char *cp, *temp, *md;
-
   /* note: len + 1, last character is a dummy to prevent
* comparisons using uninitialized memory */
-  temp = MEM_mallocN(maindata_len + 1, "preprocess_include");
+  char *temp = MEM_mallocN(maindata_len + 1, "preprocess_include");
   temp[maindata_len] = ' ';
 
   memcpy(temp, maindata, maindata_len);
 
   /* remove all c++ comments */
   /* replace all enters/tabs/etc with spaces */
-  cp = temp;
-  a = maindata_len;
-  comment = 0;
+  char *cp = temp;
+  int a = maindata_len;
+  int comment = 0;
   while (a--) {
 if (cp[0] == '/' && cp[1] == '/') {
   comment = 1;
@@ -606,8 +596,8 @@ static int preprocess_include(char *maindata, const int 
maindata_len)
 
   /* data from temp copy to maindata, remove comments and double spaces */
   cp = temp;
-  md = maindata;
-  newlen = 0;
+  char *md = maindata;
+  int newlen = 0;
   comment = 0;
   a = maindata_len;
   while (a--) {
@@ -694,23 +684,21 @@ static int convert_include(const char *filename)
   /* read include file, skip structs with a '#' before it.
* store all data in temporal arrays.
*/
-  int maindata_len, count, slen, type, name, strct;
-  short *structpoin, *sp;
-  char *maindata, *mainend, *md, *md1;
-  bool skip_struct;
 
-  md = maindata = read_file_data(filename, &maindata_len);
+  int maindata_len;
+  char *maindata = read_file_data(filename, &maindata_len);
+  char *md = maindata;
   if (maindata

[Bf-blender-cvs] [dd95a2e1d5a] master: Cleanup: remove redundant theme versioning

2020-10-02 Thread Campbell Barton
Commit: dd95a2e1d5aefc710bc9cd49f6acd0d49c80ef18
Author: Campbell Barton
Date:   Fri Oct 2 20:58:43 2020 +1000
Branches: master
https://developer.blender.org/rBdd95a2e1d5aefc710bc9cd49f6acd0d49c80ef18

Cleanup: remove redundant theme versioning

All themes older than 2.8x are initialized from the defaults,
there is no need to version them.

===

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

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 7321d680537..0b247d9a249 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6887,22 +6887,12 @@ static void link_global(FileData *fd, BlendFileData 
*bfd)
 /* other initializers (such as theme color defaults) go to resources.c */
 static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
 {
-  Main *bmain = bfd->main;
   UserDef *user = bfd->user;
 
   if (user == NULL) {
 return;
   }
 
-  if (MAIN_VERSION_OLDER(bmain, 266, 4)) {
-/* Themes for Node and Sequence editor were not using grid color,
- * but back. we copy this over then. */
-LISTBASE_FOREACH (bTheme *, btheme, &user->themes) {
-  copy_v4_v4_uchar(btheme->space_node.grid, btheme->space_node.back);
-  copy_v4_v4_uchar(btheme->space_sequencer.grid, 
btheme->space_sequencer.back);
-}
-  }
-
   if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "WalkNavigation", 
"walk_navigation")) {
 user->walk_navigation.mouse_speed = 1.0f;
 user->walk_navigation.walk_speed = 2.5f; /* m/s */

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


[Bf-blender-cvs] [d8588594027] master: Cleanup: spelling

2020-10-02 Thread Campbell Barton
Commit: d858859402798898251bc3939ab0b6cf8c70dcd7
Author: Campbell Barton
Date:   Fri Oct 2 20:41:03 2020 +1000
Branches: master
https://developer.blender.org/rBd858859402798898251bc3939ab0b6cf8c70dcd7

Cleanup: spelling

Also correct own correction from 58b8724a4892
thanks @mont29 for raising this.

===

M   source/blender/blenloader/intern/readfile.c
M   source/blender/draw/engines/overlay/overlay_sculpt.c
M   source/blender/makesrna/intern/rna_access_compare_override.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 6072704100c..7321d680537 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5487,7 +5487,7 @@ static void direct_link_windowmanager(BlendDataReader 
*reader, wmWindowManager *
 if (win->workspace_hook != NULL) {
   /* We need to restore a pointer to this later when reading workspaces,
* so store in global oldnew-map.
-   * Note that this is only needed for versionning of older .blend files 
now.. */
+   * Note that this is only needed for versioning of older .blend files 
now.. */
   oldnewmap_insert(reader->fd->globmap, hook, win->workspace_hook, 0);
   /* Cleanup pointers to data outside of this data-block scope. */
   win->workspace_hook->act_layout = NULL;
diff --git a/source/blender/draw/engines/overlay/overlay_sculpt.c 
b/source/blender/draw/engines/overlay/overlay_sculpt.c
index a3860c9e25e..24c52ec427d 100644
--- a/source/blender/draw/engines/overlay/overlay_sculpt.c
+++ b/source/blender/draw/engines/overlay/overlay_sculpt.c
@@ -61,8 +61,8 @@ void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, 
Object *ob)
   }
 
   if (!pbvh_has_mask(pbvh) && !pbvh_has_face_sets(pbvh)) {
-/* The SculptSession and the PBVH can be created without a Mask datalayer 
or Face Set
- * datalayer. (masks datalayers are created after using a mask tool), so 
in these cases there
+/* The SculptSession and the PBVH can be created without a Mask data-layer 
or Face Set
+ * data-layer. (masks data-layers are created after using a mask tool), so 
in these cases there
  * is nothing to draw. */
 return;
   }
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c 
b/source/blender/makesrna/intern/rna_access_compare_override.c
index a630d227f17..098854513a4 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -916,7 +916,7 @@ static void rna_property_override_apply_ex(Main *bmain,
   /* This is rather fragile, but the fact that local override IDs may 
have a different name
* than their linked reference makes it necessary.
* Basically, here we are considering that if we cannot find the 
original linked ID in
-   * the local override we are (re-)applying the operations, then it 
may be because of
+   * the local override we are (re-)applying the operations, then it 
may be because some of
* those operations have already been applied, and we may already 
have the local ID
* pointer we want to set.
* This happens e.g. during re-sync of an override, since we have 
already remapped all ID

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


[Bf-blender-cvs] [d1f6c2e7bb5] master: Fix userpref.blend using version from startup.blend

2020-10-02 Thread Campbell Barton
Commit: d1f6c2e7bb59e12f381bffdbaf8274936f404b7e
Author: Campbell Barton
Date:   Fri Oct 2 20:11:51 2020 +1000
Branches: master
https://developer.blender.org/rBd1f6c2e7bb59e12f381bffdbaf8274936f404b7e

Fix userpref.blend using version from startup.blend

Version patching userpref.blend wasn't using the correct version,
causing settings not to be properly updated.

This seems the likely cause of T70196 and similar bugs.

===

M   source/blender/blenloader/BLO_readfile.h
M   source/blender/blenloader/intern/versioning_userdef.c
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/interface/interface.c
M   source/blender/editors/interface/interface_intern.h
M   source/blender/editors/interface/resources.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenloader/BLO_readfile.h 
b/source/blender/blenloader/BLO_readfile.h
index 4571e50dd36..88d89d9d6da 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -228,7 +228,7 @@ void BLO_update_defaults_startup_blend(struct Main *bmain, 
const char *app_templ
 void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char 
*app_template);
 
 /* Version patch user preferences. */
-void BLO_version_defaults_userpref_blend(struct Main *bmain, struct UserDef 
*userdef);
+void BLO_version_defaults_userpref_blend(struct UserDef *userdef);
 
 /* Disable unwanted experimental feature settings on startup. */
 void BLO_sanitize_experimental_features_userpref_blend(struct UserDef 
*userdef);
diff --git a/source/blender/blenloader/intern/versioning_userdef.c 
b/source/blender/blenloader/intern/versioning_userdef.c
index 691258a5a8c..0265bd85f14 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -303,10 +303,10 @@ static bool 
keymap_item_has_invalid_wm_context_data_path(wmKeyMapItem *kmi,
 }
 
 /* patching UserDef struct and Themes */
-void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
+void BLO_version_defaults_userpref_blend(UserDef *userdef)
 {
-
-#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(bmain, ver, 
subver)
+  /* #UserDef & #Main happen to have the same struct member. */
+#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, 
subver)
 
   /* the UserDef struct is not corrected with do_versions()  ugh! */
   if (userdef->wheellinescroll == 0) {
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 5fcde98f200..972c741f061 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1752,7 +1752,7 @@ void UI_popup_handlers_remove_all(struct bContext *C, 
struct ListBase *handlers)
  * be used to reinitialize some internal state if user preferences change. */
 
 void UI_init(void);
-void UI_init_userdef(struct Main *bmain);
+void UI_init_userdef(void);
 void UI_reinit_font(void);
 void UI_exit(void);
 
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 25354c30c62..d93d80bb4ef 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -7059,10 +7059,10 @@ void UI_init(void)
 }
 
 /* after reading userdef file */
-void UI_init_userdef(Main *bmain)
+void UI_init_userdef(void)
 {
   /* fix saved themes */
-  init_userdef_do_versions(bmain);
+  init_userdef_do_versions();
   uiStyleInit();
 
   BLO_sanitize_experimental_features_userpref_blend(&U);
diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index 60d60102736..91a71b0ca28 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -996,7 +996,7 @@ void icon_draw_rect_input(
 float x, float y, int w, int h, float alpha, short event_type, short 
event_value);
 
 /* resources.c */
-void init_userdef_do_versions(struct Main *bmain);
+void init_userdef_do_versions(void);
 void ui_resources_init(void);
 void ui_resources_free(void);
 
diff --git a/source/blender/editors/interface/resources.c 
b/source/blender/editors/interface/resources.c
index 76ad3981586..1601d9914a3 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1501,9 +1501,9 @@ void UI_make_axis_color(const uchar src_col[3], uchar 
dst_col[3], const char axi
 }
 
 /* patching UserDef struct and Themes */
-void init_userdef_do_versions(Main *bmain)
+void init_userdef_do_versions(void)
 {
-  BLO_version_defaults_userpref_blend(bmain, &U);
+  BLO_version_defaults_userpref_blend(&U);
 
   if (STREQ(U.tempdir, "/")) {
 BKE_tempdir_s

[Bf-blender-cvs] [34228d138b7] master: License: Rename GPL2 license to match the name specified in copyright.txt

2020-10-02 Thread Dalai Felinto
Commit: 34228d138b79e9ad6cdbded4bc5df1eefb1aad1c
Author: Dalai Felinto
Date:   Thu Oct 1 16:57:37 2020 +0200
Branches: master
https://developer.blender.org/rB34228d138b79e9ad6cdbded4bc5df1eefb1aad1c

License: Rename GPL2 license to match the name specified in copyright.txt

The license was renamed GPL-license.txt => license/GPL-2.0txt in 
0434efa09ddc451.

Although the renaming made all the license files consistent, we are better off
not updating the copyright file in Blender. Instead we can live with some mild
inconsistency in the license names.

===

R100release/license/GPL-2.0.txt release/license/GPL-license.txt

===

diff --git a/release/license/GPL-2.0.txt b/release/license/GPL-license.txt
similarity index 100%
rename from release/license/GPL-2.0.txt
rename to release/license/GPL-license.txt

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


[Bf-blender-cvs] [b81aad9064d] temp-cleanup-screen-context: Cleanup: refactor `ed_screen_context()` to use hash lookups

2020-10-02 Thread Sybren A. Stüvel
Commit: b81aad9064d626d1d75873672774594fd9bb70a5
Author: Sybren A. Stüvel
Date:   Fri Oct 2 11:56:06 2020 +0200
Branches: temp-cleanup-screen-context
https://developer.blender.org/rBb81aad9064d626d1d75873672774594fd9bb70a5

Cleanup: refactor `ed_screen_context()` to use hash lookups

Refactor `ed_screen_context()` to use `GHash` lookups instead of a sequence
of string comparisons, and move each context member into its own function.

===

M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 89d6befbb25..8ca10b7b493 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -37,6 +37,7 @@
 #include "DNA_space_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "BLI_ghash.h"
 #include "BLI_listbase.h"
 #include "BLI_utildefines.h"
 
@@ -110,197 +111,242 @@ const char *screen_context_dir[] = {
 NULL,
 };
 
-int ed_screen_context(const bContext *C, const char *member, 
bContextDataResult *result)
+/* Each function `screen_ctx_XXX()` will be called when the screen context 
"XXX" is requested.
+ * ensure_ed_screen_context_functions() is responsible for creating the hash 
map from context
+ * member name to function.
+ *
+ * Each function returns:
+ *1 for "the member name was found and returned data is valid"
+ *0 for "the member name was not found"
+ *   -1 for "the member name was found but data is not available"
+ *
+ * */
+
+static int screen_ctx_scene(const bContext *C, bContextDataResult *result)
 {
   wmWindow *win = CTX_wm_window(C);
-  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
-  bScreen *screen = CTX_wm_screen(C);
-  ScrArea *area = CTX_wm_area(C);
   Scene *scene = WM_window_get_active_scene(win);
+  CTX_data_id_pointer_set(result, &scene->id);
+  return 1;
+}
+static int screen_ctx_visible_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
   ViewLayer *view_layer = WM_window_get_active_view_layer(win);
-  Object *obact = view_layer->basact ? view_layer->basact->object : NULL;
-  Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
 
-  if (CTX_data_dir(member)) {
-CTX_data_dir_set(result, screen_context_dir);
-return 1;
-  }
-  if (CTX_data_equals(member, "scene")) {
-CTX_data_id_pointer_set(result, &scene->id);
-return 1;
-  }
-  if (CTX_data_equals(member, "visible_objects")) {
-LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
-  if (BASE_VISIBLE(v3d, base)) {
-CTX_data_id_list_add(result, &base->object->id);
-  }
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_VISIBLE(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
 }
-CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
-return 1;
   }
-  if (CTX_data_equals(member, "selectable_objects")) {
-LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
-  if (BASE_SELECTABLE(v3d, base)) {
-CTX_data_id_list_add(result, &base->object->id);
-  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selectable_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_SELECTABLE(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
 }
-CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
-return 1;
   }
-  if (CTX_data_equals(member, "selected_objects")) {
-LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
-  if (BASE_SELECTED(v3d, base)) {
-CTX_data_id_list_add(result, &base->object->id);
-  }
+  CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+  return 1;
+}
+static int screen_ctx_selected_objects(const bContext *C, bContextDataResult 
*result)
+{
+  wmWindow *win = CTX_wm_window(C);
+  View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */
+  ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+if (BASE_SELECTED(v3d, base)) {
+  CTX_data_id_list_add(result, &base->object->id);
 }
-CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
-return 1;
   }
-  if (CTX_data_equals(member, "selected_editable_objects")) {
-LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
-  if (BASE_SELECTED_EDITABLE(v3d, base)) {
-CTX_data_id_list_add(result, &base->object->id

[Bf-blender-cvs] [062dfab159d] master: Cleanup: readfile for workspaces: NULLify non-owned data pointers.

2020-10-02 Thread Bastien Montagne
Commit: 062dfab159d3c8e27635c0cd91b15d6736eb61b7
Author: Bastien Montagne
Date:   Fri Oct 2 11:38:08 2020 +0200
Branches: master
https://developer.blender.org/rB062dfab159d3c8e27635c0cd91b15d6736eb61b7

Cleanup: readfile for workspaces: NULLify non-owned data pointers.

`workspace_hook` of wmWindows store pointers for runtime data and to
data belonging to other IDs (workspace's layouts). That kind of pointers
should always be cleaned up on read, it allows for cleaner segfault
crash in case of mistakes in code updating/re-setting them, and avoids
potential security issue of accessing random memory address.

No behavioral change expected here.

===

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

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index aa2f103c693..6072704100c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5483,10 +5483,17 @@ static void direct_link_windowmanager(BlendDataReader 
*reader, wmWindowManager *
 WorkSpaceInstanceHook *hook = win->workspace_hook;
 BLO_read_data_address(reader, &win->workspace_hook);
 
-/* We need to restore a pointer to this later when reading workspaces,
- * so store in global oldnew-map.
- * Note that this is only needed for versionning of older .blend files 
now.. */
-oldnewmap_insert(reader->fd->globmap, hook, win->workspace_hook, 0);
+/* This will be NULL for any pre-2.80 blend file. */
+if (win->workspace_hook != NULL) {
+  /* We need to restore a pointer to this later when reading workspaces,
+   * so store in global oldnew-map.
+   * Note that this is only needed for versionning of older .blend files 
now.. */
+  oldnewmap_insert(reader->fd->globmap, hook, win->workspace_hook, 0);
+  /* Cleanup pointers to data outside of this data-block scope. */
+  win->workspace_hook->act_layout = NULL;
+  win->workspace_hook->temp_workspace_store = NULL;
+  win->workspace_hook->temp_layout_store = NULL;
+}
 
 direct_link_area_map(reader, &win->global_areas);

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


[Bf-blender-cvs] [6219d0d145d] master: Fix (unreported) design flow in how workspace's relation data are read from .blend file.

2020-10-02 Thread Bastien Montagne
Commit: 6219d0d145d3f2e6bd30be1c91e952e18db44e74
Author: Bastien Montagne
Date:   Wed Sep 30 14:49:42 2020 +0200
Branches: master
https://developer.blender.org/rB6219d0d145d3f2e6bd30be1c91e952e18db44e74

Fix (unreported) design flow in how workspace's relation data are read from 
.blend file.

Relying on pointer addresses across different data-blocks is extremely
not recommended (and should be strictly forbidden ideally), in
particular in direct_link step of blend file reading.
- It assumes a specific order in reading of data, which is not ensured
  in future, and is in any case a very bad, non explicit, hidden
  dependency on behaviors of other parts of the codebase.
- It is intrinsically unsafe (as in, it makes writing bad code and making
  mistakes easy, see e.g. fix in rB84b3f6e049b35f9).
- It makes advanced handling of data-blocks harder (thinking about
  partial undo code e.g., even though in this specific case it was not
  an issue as we do not re-read neither windowmanagers nor worspaces
  during undo).

New code uses windows' `winid` instead as 'anchor' to find again proper
workspace hook in windows at read time.

As a bonus, it will also cleanup the list of relations from any invalid
ones (afaict it was never done previously).

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

===

M   source/blender/blenkernel/BKE_workspace.h
M   source/blender/blenkernel/intern/workspace.c
M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/readfile.h
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/blenloader/intern/versioning_290.c
M   source/blender/editors/screen/workspace_edit.c
M   source/blender/makesdna/DNA_workspace_types.h
M   source/blender/windowmanager/intern/wm.c
M   source/blender/windowmanager/intern/wm_window.c

===

diff --git a/source/blender/blenkernel/BKE_workspace.h 
b/source/blender/blenkernel/BKE_workspace.h
index 5ff1ba2c6f5..82a4e5fe08e 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -36,7 +36,8 @@ struct bToolRef;
 struct WorkSpace *BKE_workspace_add(struct Main *bmain, const char *name);
 void BKE_workspace_remove(struct Main *bmain, struct WorkSpace *workspace);
 
-struct WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const struct 
Main *bmain);
+struct WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const struct 
Main *bmain,
+ const int 
winid);
 void BKE_workspace_instance_hook_free(const struct Main *bmain,
   struct WorkSpaceInstanceHook *hook);
 
@@ -83,11 +84,13 @@ void BKE_workspace_active_set(struct WorkSpaceInstanceHook 
*hook,
 struct WorkSpaceLayout *BKE_workspace_active_layout_get(const struct 
WorkSpaceInstanceHook *hook)
 GETTER_ATTRS;
 void BKE_workspace_active_layout_set(struct WorkSpaceInstanceHook *hook,
+ const int winid,
  struct WorkSpace *workspace,
  struct WorkSpaceLayout *layout) 
SETTER_ATTRS;
 struct bScreen *BKE_workspace_active_screen_get(const struct 
WorkSpaceInstanceHook *hook)
 GETTER_ATTRS;
 void BKE_workspace_active_screen_set(struct WorkSpaceInstanceHook *hook,
+ const int winid,
  struct WorkSpace *workspace,
  struct bScreen *screen) SETTER_ATTRS;
 
diff --git a/source/blender/blenkernel/intern/workspace.c 
b/source/blender/blenkernel/intern/workspace.c
index 324c8db0fe9..775d83278e9 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -125,10 +125,14 @@ static WorkSpaceLayout *workspace_layout_find_exec(const 
WorkSpace *workspace,
   return BLI_findptr(&workspace->layouts, screen, offsetof(WorkSpaceLayout, 
screen));
 }
 
-static void workspace_relation_add(ListBase *relation_list, void *parent, void 
*data)
+static void workspace_relation_add(ListBase *relation_list,
+   void *parent,
+   const int parentid,
+   void *data)
 {
   WorkSpaceDataRelation *relation = MEM_callocN(sizeof(*relation), __func__);
   relation->parent = parent;
+  relation->parentid = parentid;
   relation->value = data;
   /* add to head, if we switch back to it soon we find it faster. */
   BLI_addhead(relation_list, relation);
@@ -139,11 +143,15 @@ static void workspace_relation_remove(ListBase 
*relation_list, WorkSpaceDataRela
   MEM_freeN(relation);
 }
 
-static void workspace_relation_ensure_updated(ListBase *relation_list, void 
*parent, void *data)
+static void workspace_relation_en

[Bf-blender-cvs] [2b90dd1ac58] master: Fix (unreported) assert in texture code when loading some old 2.74 blend file.

2020-10-02 Thread Bastien Montagne
Commit: 2b90dd1ac581881c0cf0d784692a26bcfd4f494e
Author: Bastien Montagne
Date:   Fri Oct 2 11:42:36 2020 +0200
Branches: master
https://developer.blender.org/rB2b90dd1ac581881c0cf0d784692a26bcfd4f494e

Fix (unreported) assert in texture code when loading some old 2.74 blend file.

Trying to open the 2.74 Fishy Cat file would generate endless asserts in
customdata code. This commit refactors and cleans up the code of
`psys_get_dupli_texture` to avoid useless calls and data access, and
validate data before trying to further access it.

No behavioral changes expected here (besides getting rid of the assert).

===

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

===

diff --git a/source/blender/blenkernel/intern/particle.c 
b/source/blender/blenkernel/intern/particle.c
index 1ac46f4f17f..f265eade749 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -4804,7 +4804,6 @@ void psys_get_dupli_texture(ParticleSystem *psys,
 float orco[3])
 {
   MFace *mface;
-  MTFace *mtface;
   float loc[3];
   int num;
 
@@ -4816,21 +4815,25 @@ void psys_get_dupli_texture(ParticleSystem *psys,
* For now just include this workaround as an alternative to crashing,
* but longer term meta-balls should behave in a more manageable way, see: 
T46622. */
 
-  uv[0] = uv[1] = 0.f;
+  uv[0] = uv[1] = 0.0f;
 
   /* Grid distribution doesn't support UV or emit from vertex mode */
   bool is_grid = (part->distr == PART_DISTR_GRID && part->from != 
PART_FROM_VERT);
 
   if (cpa) {
 if ((part->childtype == PART_CHILD_FACES) && (psmd->mesh_final != NULL)) {
-  CustomData *mtf_data = &psmd->mesh_final->fdata;
-  const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
-  mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
-
-  if (mtface && !is_grid) {
-mface = CustomData_get(&psmd->mesh_final->fdata, cpa->num, CD_MFACE);
-mtface += cpa->num;
-psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
+  if (!is_grid) {
+CustomData *mtf_data = &psmd->mesh_final->fdata;
+const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
+
+if (uv_idx >= 0) {
+  MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
+  if (mtface != NULL) {
+mface = CustomData_get(&psmd->mesh_final->fdata, cpa->num, 
CD_MFACE);
+mtface += cpa->num;
+psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
+  }
+}
   }
 
   psys_particle_on_emitter(psmd,
@@ -4851,10 +4854,6 @@ void psys_get_dupli_texture(ParticleSystem *psys,
   }
 
   if ((part->from == PART_FROM_FACE) && (psmd->mesh_final != NULL) && 
!is_grid) {
-CustomData *mtf_data = &psmd->mesh_final->fdata;
-const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
-mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
-
 num = pa->num_dmcache;
 
 if (num == DMCACHE_NOTFOUND) {
@@ -4867,10 +4866,16 @@ void psys_get_dupli_texture(ParticleSystem *psys,
   num = DMCACHE_NOTFOUND;
 }
 
-if (mtface && !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
-  mface = CustomData_get(&psmd->mesh_final->fdata, num, CD_MFACE);
-  mtface += num;
-  psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
+if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
+  CustomData *mtf_data = &psmd->mesh_final->fdata;
+  const int uv_idx = CustomData_get_render_layer(mtf_data, CD_MTFACE);
+
+  if (uv_idx >= 0) {
+MTFace *mtface = CustomData_get_layer_n(mtf_data, CD_MTFACE, uv_idx);
+mface = CustomData_get(&psmd->mesh_final->fdata, num, CD_MFACE);
+mtface += num;
+psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
+  }
 }
   }

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


[Bf-blender-cvs] [d74d35e39ea] master: CleanUp: snode_group_offset -> space_node_group_offset

2020-10-02 Thread Jeroen Bakker
Commit: d74d35e39eaf97a63178c84a6c4e9ab4e0bc384c
Author: Jeroen Bakker
Date:   Fri Oct 2 11:46:01 2020 +0200
Branches: master
https://developer.blender.org/rBd74d35e39eaf97a63178c84a6c4e9ab4e0bc384c

CleanUp: snode_group_offset -> space_node_group_offset

===

M   source/blender/editors/space_node/node_group.c
M   source/blender/editors/space_node/node_intern.h
M   source/blender/editors/space_node/space_node.c

===

diff --git a/source/blender/editors/space_node/node_group.c 
b/source/blender/editors/space_node/node_group.c
index 7894fade517..e81d83102ac 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -578,7 +578,7 @@ static int node_group_separate_exec(bContext *C, wmOperator 
*op)
 return OPERATOR_CANCELLED;
   }
   /* get node tree offset */
-  snode_group_offset(snode, &offx, &offy);
+  space_node_group_offset(snode, &offx, &offy);
 
   switch (type) {
 case NODE_GS_COPY:
diff --git a/source/blender/editors/space_node/node_intern.h 
b/source/blender/editors/space_node/node_intern.h
index eeacff6be7a..a1df40ebd1c 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -56,7 +56,7 @@ typedef struct bNodeLinkDrag {
 /* space_node.c */
 
 /* transform between View2Ds in the tree path */
-void snode_group_offset(struct SpaceNode *snode, float *x, float *y);
+void space_node_group_offset(struct SpaceNode *snode, float *x, float *y);
 
 /* node_draw.c */
 int node_get_colorid(struct bNode *node);
diff --git a/source/blender/editors/space_node/space_node.c 
b/source/blender/editors/space_node/space_node.c
index 4b390a9121d..bc4bed502e0 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -227,7 +227,7 @@ void ED_node_set_active_viewer_key(SpaceNode *snode)
   }
 }
 
-void snode_group_offset(SpaceNode *snode, float *x, float *y)
+void space_node_group_offset(SpaceNode *snode, float *x, float *y)
 {
   bNodeTreePath *path = snode->treepath.last;

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


[Bf-blender-cvs] [01698caa665] master: CleanUp: Renamed drawnodespace -> node_draw_space

2020-10-02 Thread Jeroen Bakker
Commit: 01698caa6658196aeac6c34b34be1f9483013bd4
Author: Jeroen Bakker
Date:   Fri Oct 2 11:41:13 2020 +0200
Branches: master
https://developer.blender.org/rB01698caa6658196aeac6c34b34be1f9483013bd4

CleanUp: Renamed drawnodespace -> node_draw_space

===

M   source/blender/editors/space_node/node_draw.c
M   source/blender/editors/space_node/node_intern.h
M   source/blender/editors/space_node/space_node.c

===

diff --git a/source/blender/editors/space_node/node_draw.c 
b/source/blender/editors/space_node/node_draw.c
index 0c5ec1bf80e..ac2b8bac70d 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1713,7 +1713,7 @@ static void draw_group_overlay(const bContext *C, ARegion 
*region)
   UI_block_end(C, block);
 }
 
-void drawnodespace(const bContext *C, ARegion *region)
+void node_draw_space(const bContext *C, ARegion *region)
 {
   wmWindow *win = CTX_wm_window(C);
   SpaceNode *snode = CTX_wm_space_node(C);
diff --git a/source/blender/editors/space_node/node_intern.h 
b/source/blender/editors/space_node/node_intern.h
index 7e62170bce5..eeacff6be7a 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -88,7 +88,7 @@ void node_draw_nodetree(const struct bContext *C,
 struct SpaceNode *snode,
 struct bNodeTree *ntree,
 bNodeInstanceKey parent_key);
-void drawnodespace(const bContext *C, ARegion *region);
+void node_draw_space(const bContext *C, ARegion *region);
 
 void node_set_cursor(struct wmWindow *win, struct SpaceNode *snode, float 
cursor[2]);
 /* DPI scaled coords */
diff --git a/source/blender/editors/space_node/space_node.c 
b/source/blender/editors/space_node/space_node.c
index 6d570001347..4b390a9121d 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -627,7 +627,7 @@ static void node_main_region_init(wmWindowManager *wm, 
ARegion *region)
 
 static void node_main_region_draw(const bContext *C, ARegion *region)
 {
-  drawnodespace(C, region);
+  node_draw_space(C, region);
 }
 
 /* * dropboxes * */

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


[Bf-blender-cvs] [0c15f1ed3ec] lanpr-under-gp: LineArt: CD_MDEFORMVERT flag in viewport evaluation.

2020-10-02 Thread YimingWu
Commit: 0c15f1ed3ec14ef877dae190a75ec9b2b4039340
Author: YimingWu
Date:   Fri Oct 2 16:58:16 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB0c15f1ed3ec14ef877dae190a75ec9b2b4039340

LineArt: CD_MDEFORMVERT flag in viewport evaluation.

===

M   source/blender/blenkernel/intern/object_update.c
M   source/blender/editors/lineart/lineart_cpu.c

===

diff --git a/source/blender/blenkernel/intern/object_update.c 
b/source/blender/blenkernel/intern/object_update.c
index 1c4e0227876..56c29c9ee0e 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -180,6 +180,7 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, 
Scene *scene, Object *o
 #ifdef WITH_FREESTYLE
   cddata_masks.emask |= CD_MASK_FREESTYLE_EDGE;
   cddata_masks.pmask |= CD_MASK_FREESTYLE_FACE;
+  cddata_masks.vmask |= CD_MASK_MDEFORMVERT;
 #endif
   if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
 /* Always compute UVs, vertex colors as orcos for render. */
diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index 81c402a476d..d02ba32c3b3 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -4103,15 +4103,22 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph 
*depsgraph,
   if ((gpdg = BKE_object_defgroup_name_index(gpencil_object, vgname)) >= 
0) {
 if (eval_ob->type == OB_MESH) {
   int dindex = 0;
+  Mesh *me = (Mesh *)eval_ob->data;
+  if (!me->dvert) {
+continue;
+  }
   LISTBASE_FOREACH (bDeformGroup *, db, &eval_ob->defbase) {
 if (strstr(db->name, source_vgname) == db->name) {
-  Mesh *me = (Mesh *)eval_ob->data;
   int sindex = 0, vindex;
   LISTBASE_FOREACH (LineartRenderLineChainItem *, rlci, 
&rlc->chain) {
 vindex = rlci->index;
-MDeformWeight *mdw = 
BKE_defvert_find_index(&me->dvert[vindex], dindex);
+/* XXX: Here doesn't have post-modifier dvert! */
+if (vindex >= me->totvert) {
+  break;
+}
+MDeformWeight *mdw = 
BKE_defvert_ensure_index(&me->dvert[vindex], dindex);
 if (mdw->weight > 0.999f) {
-  MDeformWeight *gdw = 
BKE_defvert_find_index(&gps->dvert[sindex], gpdg);
+  MDeformWeight *gdw = 
BKE_defvert_ensure_index(&gps->dvert[sindex], gpdg);
   gdw->weight = 1.0f;
 }
 sindex++;

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


[Bf-blender-cvs] [63f525bae33] master: Fix text editor auto-complete refinement feature

2020-10-02 Thread Campbell Barton
Commit: 63f525bae3301c4d43bc62576772f42786173cd2
Author: Campbell Barton
Date:   Fri Oct 2 17:23:34 2020 +1000
Branches: master
https://developer.blender.org/rB63f525bae3301c4d43bc62576772f42786173cd2

Fix text editor auto-complete refinement feature

Left/right arrow keys can refine the completion,
this wasn't redrawing and there was an off-by-one error checking
the next character.

===

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

===

diff --git a/source/blender/editors/space_text/text_autocomplete.c 
b/source/blender/editors/space_text/text_autocomplete.c
index e754c143718..7d53f2a66cd 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -328,6 +328,7 @@ static int doc_scroll = 0;
 
 static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent 
*event)
 {
+  /* NOTE(campbell): this code could be refactored or rewritten. */
   SpaceText *st = CTX_wm_space_text(C);
   ScrArea *area = CTX_wm_area(C);
   ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
@@ -425,6 +426,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator 
*op, const wmEvent *e
   if (event->ctrl) {
 texttool_suggest_clear();
 retval = OPERATOR_CANCELLED;
+draw = 1;
   }
   else {
 /* Work out which char we are about to delete/pass */
@@ -433,15 +435,19 @@ static int text_autocomplete_modal(bContext *C, 
wmOperator *op, const wmEvent *e
   if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
 get_suggest_prefix(st->text, -1);
 text_pop_suggest_list();
+txt_move_left(st->text, false);
+draw = 1;
   }
   else {
 texttool_suggest_clear();
 retval = OPERATOR_CANCELLED;
+draw = 1;
   }
 }
 else {
   texttool_suggest_clear();
   retval = OPERATOR_CANCELLED;
+  draw = 1;
 }
   }
 }
@@ -457,23 +463,28 @@ static int text_autocomplete_modal(bContext *C, 
wmOperator *op, const wmEvent *e
   if (event->ctrl) {
 texttool_suggest_clear();
 retval = OPERATOR_CANCELLED;
+draw = 1;
   }
   else {
 /* Work out which char we are about to pass */
 if (st->text->curl && st->text->curc < st->text->curl->len) {
-  char ch = st->text->curl->line[st->text->curc + 1];
+  char ch = st->text->curl->line[st->text->curc];
   if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
 get_suggest_prefix(st->text, 1);
 text_pop_suggest_list();
+txt_move_right(st->text, false);
+draw = 1;
   }
   else {
 texttool_suggest_clear();
 retval = OPERATOR_CANCELLED;
+draw = 1;
   }
 }
 else {
   texttool_suggest_clear();
   retval = OPERATOR_CANCELLED;
+  draw = 1;
 }
   }
 }

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


[Bf-blender-cvs] [09082e15d00] master: Fix text editor auto-complete mouse interaction

2020-10-02 Thread Campbell Barton
Commit: 09082e15d00457bc22826c7d419a6dfb6c9905bd
Author: Campbell Barton
Date:   Fri Oct 2 17:07:35 2020 +1000
Branches: master
https://developer.blender.org/rB09082e15d00457bc22826c7d419a6dfb6c9905bd

Fix text editor auto-complete mouse interaction

- Remove MMB for activating an auto-complete item (use LMB instead).
- Update on cursor motion.

===

M   source/blender/editors/space_text/text_autocomplete.c
M   source/blender/editors/space_text/text_intern.h

===

diff --git a/source/blender/editors/space_text/text_autocomplete.c 
b/source/blender/editors/space_text/text_autocomplete.c
index 74cf3c866d3..e754c143718 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -49,13 +49,13 @@
 /** \name Public API
  * \{ */
 
-int text_do_suggest_select(SpaceText *st, ARegion *region)
+bool text_do_suggest_select(SpaceText *st, ARegion *region, const int mval[2])
 {
+  const int lheight = TXT_LINE_HEIGHT(st);
   SuggItem *item, *first, *last /* , *sel */ /* UNUSED */;
   TextLine *tmp;
   int l, x, y, w, h, i;
   int tgti, *top;
-  const int mval[2] = {0, 0};
 
   if (!st || !st->text) {
 return 0;
@@ -84,12 +84,10 @@ int text_do_suggest_select(SpaceText *st, ARegion *region)
   text_update_character_width(st);
 
   x = TXT_BODY_LEFT(st) + (st->runtime.cwidth_px * (st->text->curc - 
st->left));
-  y = region->winy - st->runtime.lheight_px * l - 2;
+  y = region->winy - lheight * l - 2;
 
   w = SUGG_LIST_WIDTH * st->runtime.cwidth_px + U.widget_unit;
-  h = SUGG_LIST_SIZE * st->runtime.lheight_px + 0.4f * U.widget_unit;
-
-  // XXX getmouseco_areawin(mval);
+  h = SUGG_LIST_SIZE * lheight + 0.4f * U.widget_unit;
 
   if (mval[0] < x || x + w < mval[0] || mval[1] < y - h || y < mval[1]) {
 return 0;
@@ -101,7 +99,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *region)
   }
 
   /* Work out the target item index in the visible list */
-  tgti = (y - mval[1] - 4) / st->runtime.lheight_px;
+  tgti = (y - mval[1] - 4) / lheight;
   if (tgti < 0 || tgti > SUGG_LIST_SIZE) {
 return 1;
   }
@@ -296,7 +294,6 @@ static void confirm_suggestion(Text *text)
 
 /*  */
 /** \name Auto Complete Operator
- *
  * \{ */
 
 static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
@@ -336,11 +333,8 @@ static int text_autocomplete_modal(bContext *C, wmOperator 
*op, const wmEvent *e
   ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
 
   int draw = 0, tools = 0, swallow = 0, scroll = 1;
-  Text *text = CTX_data_edit_text(C);
   int retval = OPERATOR_RUNNING_MODAL;
 
-  (void)text;
-
   if (st->doplugins && texttool_text_is_active(st->text)) {
 if (texttool_suggest_first()) {
   tools |= TOOL_SUGG_LIST;
@@ -351,33 +345,31 @@ static int text_autocomplete_modal(bContext *C, 
wmOperator *op, const wmEvent *e
   }
 
   switch (event->type) {
+case MOUSEMOVE: {
+  if (text_do_suggest_select(st, region, event->mval)) {
+draw = 1;
+  }
+  swallow = 1;
+  break;
+}
 case LEFTMOUSE:
   if (event->val == KM_PRESS) {
-if (text_do_suggest_select(st, region)) {
-  swallow = 1;
-}
-else {
+if (text_do_suggest_select(st, region, event->mval)) {
   if (tools & TOOL_SUGG_LIST) {
-texttool_suggest_clear();
+ED_text_undo_push_init(C);
+confirm_suggestion(st->text);
+text_update_line_edited(st->text->curl);
+ED_undo_push(C, op->type->name);
+swallow = 1;
+draw = 1;
   }
   if (tools & TOOL_DOCUMENT) {
 texttool_docs_clear();
 doc_scroll = 0;
+draw = 1;
   }
   retval = OPERATOR_FINISHED;
 }
-draw = 1;
-  }
-  break;
-case MIDDLEMOUSE:
-  if (event->val == KM_PRESS) {
-if (text_do_suggest_select(st, region)) {
-  ED_text_undo_push_init(C);
-  confirm_suggestion(st->text);
-  text_update_line_edited(st->text->curl);
-  ED_undo_push(C, op->type->name);
-  swallow = 1;
-}
 else {
   if (tools & TOOL_SUGG_LIST) {
 texttool_suggest_clear();
@@ -386,7 +378,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator 
*op, const wmEvent *e
 texttool_docs_clear();
 doc_scroll = 0;
   }
-  retval = OPERATOR_FINISHED;
+  retval = OPERATOR_CANCELLED;
 }
 draw = 1;
   }
diff --git a/source/blender/editors/space_text/text_intern.h 
b/source/blender/editors/space_text/text_intern.h
index e3c0e436ac4..a33af56e11a 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blende

[Bf-blender-cvs] [97656f68e16] lanpr-under-gp: LineArt: Fixed render vert linking in intersection stage.

2020-10-02 Thread YimingWu
Commit: 97656f68e164e2cb6062fca1f7e3b350c4719799
Author: YimingWu
Date:   Fri Oct 2 15:05:21 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB97656f68e164e2cb6062fca1f7e3b350c4719799

LineArt: Fixed render vert linking in intersection stage.

===

M   source/blender/editors/lineart/lineart_cpu.c

===

diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index c3127352567..81c402a476d 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -2153,7 +2153,8 @@ static LineartRenderVert 
*lineart_triangle_line_intersection_test(LineartRenderB
   double gloc[3];
   LineartRenderVert *l = rl->l, *r = rl->r;
 
-  LISTBASE_FOREACH (LineartRenderVert *, rv, &testing->intersecting_verts) {
+  LISTBASE_FOREACH (LinkData *, ld, &testing->intersecting_verts) {
+LineartRenderVert *rv = (LineartRenderVert *)ld->data;
 if (rv->intersecting_with == rt && rv->intersecting_line == rl) {
   return rv;
 }
@@ -2198,7 +2199,7 @@ static LineartRenderVert 
*lineart_triangle_line_intersection_test(LineartRenderB
 
   copy_v3_v3_db(result->gloc, gloc);
 
-  BLI_addtail(&testing->intersecting_verts, result);
+  lineart_list_append_pointer_static(&testing->intersecting_verts, 
&rb->render_data_pool, result);
 
   return result;
 }
@@ -2242,10 +2243,12 @@ static LineartRenderLine 
*lineart_triangle_generate_intersection_line_only(
   if (r == NULL) {
 return 0;
   }
-  BLI_addtail(&testing->intersecting_verts, new_share);
+  lineart_list_append_pointer_static(
+  &testing->intersecting_verts, &rb->render_data_pool, new_share);
 }
 else {
-  BLI_addtail(&rt->intersecting_verts, new_share);
+  lineart_list_append_pointer_static(
+  &rt->intersecting_verts, &rb->render_data_pool, new_share);
 }
   }
   else {

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