[Bf-blender-cvs] [645298be296] master: Fix build error after last commit

2021-01-08 Thread Hans Goudey
Commit: 645298be29601b0e772a15fe04c570a31df4a25d
Author: Hans Goudey
Date:   Fri Jan 8 23:10:58 2021 -0600
Branches: master
https://developer.blender.org/rB645298be29601b0e772a15fe04c570a31df4a25d

Fix build error after last commit

===

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

===

diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index 5b07c11b254..3b0972a93ee 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -746,7 +746,6 @@ static bool modifier_apply_obdata(
   }
 
   if (ob->type == OB_MESH) {
-Mesh *mesh_applied;
 Mesh *me = ob->data;
 MultiresModifierData *mmd = find_multires_modifier_before(scene, md_eval);
 
@@ -767,7 +766,7 @@ static bool modifier_apply_obdata(
   }
 }
 else {
-  mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, ob, 
md_eval, true);
+  Mesh *mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, 
ob, md_eval, true);
   if (!mesh_applied) {
 BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping 
apply");
 return false;
@@ -911,7 +910,8 @@ bool ED_object_modifier_copy(
 ReportList *UNUSED(reports), Main *bmain, Scene *scene, Object *ob, 
ModifierData *md)
 {
   if (md->type == eModifierType_ParticleSystem) {
-nmd = object_copy_particle_system(bmain, scene, ob, 
((ParticleSystemModifierData *)md)->psys);
+ModifierData *nmd = object_copy_particle_system(
+bmain, scene, ob, ((ParticleSystemModifierData *)md)->psys);
 BLI_remlink(&ob->modifiers, nmd);
 BLI_insertlinkafter(&ob->modifiers, md, nmd);
 BKE_object_modifier_set_active(ob, nmd);

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


[Bf-blender-cvs] [1bb530745f8] master: Cleanup: Use bool instead of int

2021-01-08 Thread Hans Goudey
Commit: 1bb530745f84e0525ed50e65c56ba07060adb430
Author: Hans Goudey
Date:   Fri Jan 8 23:09:31 2021 -0600
Branches: master
https://developer.blender.org/rB1bb530745f84e0525ed50e65c56ba07060adb430

Cleanup: Use bool instead of int

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/object/object_modifier.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index f9358f62274..1fbc1339aa5 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -424,11 +424,11 @@ bool ED_object_modifier_apply(struct Main *bmain,
   struct ModifierData *md,
   int mode,
   bool keep_modifier);
-int ED_object_modifier_copy(struct ReportList *reports,
-struct Main *bmain,
-struct Scene *scene,
-struct Object *ob,
-struct ModifierData *md);
+bool ED_object_modifier_copy(struct ReportList *reports,
+ struct Main *bmain,
+ struct Scene *scene,
+ struct Object *ob,
+ struct ModifierData *md);
 void ED_object_modifier_link(struct bContext *C, struct Object *ob_dst, struct 
Object *ob_src);
 void ED_object_modifier_copy_to_object(struct bContext *C,
struct Object *ob_dst,
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index be3c2604eb2..5b07c11b254 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -346,7 +346,7 @@ static bool object_modifier_remove(
* get called twice on same modifier, so make
* sure it is in list. */
   if (BLI_findindex(&ob->modifiers, md) == -1) {
-return 0;
+return false;
   }
 
   /* special cases */
@@ -393,7 +393,7 @@ static bool object_modifier_remove(
   BKE_modifier_free(md);
   BKE_object_free_derived_caches(ob);
 
-  return 1;
+  return true;
 }
 
 bool ED_object_modifier_remove(
@@ -674,18 +674,18 @@ static Mesh 
*modifier_apply_create_mesh_for_modifier(Depsgraph *depsgraph,
   return mesh_applied;
 }
 
-static int modifier_apply_shape(Main *bmain,
-ReportList *reports,
-Depsgraph *depsgraph,
-Scene *scene,
-Object *ob,
-ModifierData *md_eval)
+static bool modifier_apply_shape(Main *bmain,
+ ReportList *reports,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob,
+ ModifierData *md_eval)
 {
   const ModifierTypeInfo *mti = BKE_modifier_get_info(md_eval->type);
 
   if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
 BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
-return 0;
+return false;
   }
 
   /* We could investigate using the #CD_ORIGINDEX layer
@@ -699,19 +699,18 @@ static int modifier_apply_shape(Main *bmain,
* we can look into supporting them. */
 
   if (ob->type == OB_MESH) {
-Mesh *mesh_applied;
 Mesh *me = ob->data;
 Key *key = me->key;
 
 if (!BKE_modifier_is_same_topology(md_eval) || mti->type == 
eModifierTypeType_NonGeometrical) {
   BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied 
to shapes");
-  return 0;
+  return false;
 }
 
-mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, ob, 
md_eval, false);
+Mesh *mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, 
ob, md_eval, false);
 if (!mesh_applied) {
   BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, 
skipping apply");
-  return 0;
+  return false;
 }
 
 if (key == NULL) {
@@ -731,19 +730,19 @@ static int modifier_apply_shape(Main *bmain,
   else {
 /* TODO: implement for hair, point-clouds and volumes. */
 BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object 
type");
-return 0;
+return false;
   }
-  return 1;
+  return true;
 }
 
-static int modifier_apply_obdata(
+static bool modifier_apply_obdata(
 ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, 
ModifierData *md_eval)
 {
   const ModifierTypeInfo *mti = BKE_modifier_get_info(md_eval->type);
 
   if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
 BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
-return 0;
+return false;
  

[Bf-blender-cvs] [9c074548165] master: Keymap: Enable repeat for "Make Edge/Face" operator

2021-01-08 Thread Hans Goudey
Commit: 9c074548165a029c318d0aff48c222b4694faeed
Author: Hans Goudey
Date:   Fri Jan 8 17:19:04 2021 -0600
Branches: master
https://developer.blender.org/rB9c074548165a029c318d0aff48c222b4694faeed

Keymap: Enable repeat for "Make Edge/Face" operator

The "repeat" property was turned off by default in rBf5080c82dd91, but
it's important to have repeat turned on for this operator since it can be
used to fill large areas. This commit is similar to rBaa77689f77b4.

Fixes T84531

===

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

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index d6a75c0209e..af361175cc2 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4566,7 +4566,7 @@ def km_mesh(params):
 op_menu("VIEW3D_MT_edit_mesh_merge", {"type": 'M', "value": 'PRESS'}),
 op_menu("VIEW3D_MT_edit_mesh_split", {"type": 'M', "value": 'PRESS', 
"alt": True}),
 ("transform.shrink_fatten", {"type": 'S', "value": 'PRESS', "alt": 
True}, None),
-("mesh.edge_face_add", {"type": 'F', "value": 'PRESS'}, None),
+("mesh.edge_face_add", {"type": 'F', "value": 'PRESS', "repeat": 
True}, None),
 ("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": 
True}, None),
 op_menu("VIEW3D_MT_mesh_add", {"type": 'A', "value": 'PRESS', "shift": 
True}),
 ("mesh.separate", {"type": 'P', "value": 'PRESS'}, None),

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


[Bf-blender-cvs] [69a22a70acf] master: Geometry Nodes: Don't start with empty group nodes selected

2021-01-08 Thread Hans Goudey
Commit: 69a22a70acff4d2f14d3c159a6319074de6af3bc
Author: Hans Goudey
Date:   Fri Jan 8 16:28:53 2021 -0600
Branches: master
https://developer.blender.org/rB69a22a70acff4d2f14d3c159a6319074de6af3bc

Geometry Nodes: Don't start with empty group nodes selected

The nodes were selected in new node groups because they are by default,
but there's no particular reason for them to be selected, and it can
be distracting.

===

M   release/scripts/startup/bl_operators/geometry_nodes.py
M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py 
b/release/scripts/startup/bl_operators/geometry_nodes.py
index d3f984269f8..9652f23aadb 100644
--- a/release/scripts/startup/bl_operators/geometry_nodes.py
+++ b/release/scripts/startup/bl_operators/geometry_nodes.py
@@ -27,6 +27,9 @@ def geometry_node_group_empty_new(context):
 output_node = group.nodes.new('NodeGroupOutput')
 output_node.is_active_output = True
 
+input_node.select = False
+output_node.select = False
+
 input_node.location.x = -200 - input_node.width
 output_node.location.x = 200
 
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index 133a19dde9e..edd7cb9cfd1 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -754,6 +754,9 @@ void MOD_nodes_init(Main *bmain, NodesModifierData *nmd)
   bNode *group_input_node = nodeAddStaticNode(nullptr, ntree, 
NODE_GROUP_INPUT);
   bNode *group_output_node = nodeAddStaticNode(nullptr, ntree, 
NODE_GROUP_OUTPUT);
 
+  nodeSetSelected(group_input_node, false);
+  nodeSetSelected(group_output_node, false);
+
   group_input_node->locx = -200 - group_input_node->width;
   group_output_node->locx = 200;
   group_output_node->flag |= NODE_DO_OUTPUT;

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


[Bf-blender-cvs] [69a4cd82b47] temp-angavrilov-constraints: Geometry Nodes: support object and collection settings in the modifier.

2021-01-08 Thread Alexander Gavrilov
Commit: 69a4cd82b4731148aa7cf67c60bd64ef372f7253
Author: Alexander Gavrilov
Date:   Sat Jan 9 00:59:14 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB69a4cd82b4731148aa7cf67c60bd64ef372f7253

Geometry Nodes: support object and collection settings in the modifier.

===

M   source/blender/makesrna/intern/rna_ID.c
M   source/blender/makesrna/intern/rna_access.c
M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/makesrna/intern/rna_ID.c 
b/source/blender/makesrna/intern/rna_ID.c
index 5e3c234708a..4bfd0e2dc35 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -1113,7 +1113,7 @@ static void rna_def_ID_properties(BlenderRNA *brna)
 
   /* IDP_ID */
   prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
-  RNA_def_property_flag(prop, PROP_IDPROPERTY | PROP_NEVER_UNLINK);
+  RNA_def_property_flag(prop, PROP_IDPROPERTY | PROP_NEVER_UNLINK | 
PROP_EDITABLE);
   RNA_def_property_struct_type(prop, "ID");
 
   /* ID property groups > level 0, since level 0 group is merged
diff --git a/source/blender/makesrna/intern/rna_access.c 
b/source/blender/makesrna/intern/rna_access.c
index 0479c5d1eed..b9bed8b0802 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -3678,8 +3678,8 @@ void RNA_property_pointer_set(PointerRNA *ptr,
   PointerRNA ptr_value,
   ReportList *reports)
 {
-  PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
   IDProperty *idprop = rna_idproperty_check(&prop, ptr);
+  PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
   BLI_assert(RNA_property_type(prop) == PROP_POINTER);
 
   /* Check types. */
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index 133a19dde9e..087ffb89c01 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -45,6 +45,7 @@
 #include "DNA_screen_types.h"
 
 #include "BKE_customdata.h"
+#include "BKE_global.h"
 #include "BKE_idprop.h"
 #include "BKE_lib_query.h"
 #include "BKE_mesh.h"
@@ -131,6 +132,19 @@ static void findUsedIds(const bNodeTree &tree, Set 
&ids)
   }
 }
 
+static void findUsedIds(const NodesModifierSettings &settings, Set &ids)
+{
+  IDP_foreach_property(
+  settings.properties,
+  IDP_TYPE_FILTER_ID,
+  [](IDProperty *id_prop, void *user_data) {
+Set *p_ids = (Set *)user_data;
+if (ID *ptr = (ID *)id_prop->data.pointer)
+  p_ids->add(ptr);
+  },
+  &ids);
+}
+
 static void updateDepsgraph(ModifierData *md, const 
ModifierUpdateDepsgraphContext *ctx)
 {
   NodesModifierData *nmd = reinterpret_cast(md);
@@ -138,6 +152,7 @@ static void updateDepsgraph(ModifierData *md, const 
ModifierUpdateDepsgraphConte
 DEG_add_node_tree_relation(ctx->node, nmd->node_group, "Nodes Modifier");
 
 Set used_ids;
+findUsedIds(nmd->settings, used_ids);
 findUsedIds(*nmd->node_group, used_ids);
 for (ID *id : used_ids) {
   if (GS(id->name) == ID_OB) {
@@ -464,7 +479,9 @@ struct SocketPropertyType {
   IDProperty *(*create_default_ui_prop)(const bNodeSocket &socket, const char 
*name);
   PropertyType (*rna_subtype_get)(const bNodeSocket &socket);
   bool (*is_correct_type)(const IDProperty &property);
-  void (*init_cpp_value)(const IDProperty &property, void *r_value);
+  void (*init_cpp_value)(const IDProperty &property,
+ const blender::bke::PersistentDataHandleMap 
&handle_map,
+ void *r_value);
 };
 
 static IDProperty *socket_add_property(IDProperty *settings_prop_group,
@@ -549,9 +566,9 @@ static const SocketPropertyType 
*get_socket_property_type(const bNodeSocket &bso
 return (PropertyType)((bNodeSocketValueFloat 
*)socket.default_value)->subtype;
   },
   [](const IDProperty &property) { return property.type == IDP_FLOAT; 
},
-  [](const IDProperty &property, void *r_value) {
-*(float *)r_value = IDP_Float(&property);
-  },
+  [](const IDProperty &property,
+ const blender::bke::PersistentDataHandleMap &,
+ void *r_value) { *(float *)r_value = IDP_Float(&property); },
   };
   return &float_type;
 }
@@ -585,7 +602,9 @@ static const SocketPropertyType 
*get_socket_property_type(const bNodeSocket &bso
 return (PropertyType)((bNodeSocketValueInt 
*)socket.default_value)->subtype;
   },
   [](const IDProperty &property) { return property.type == IDP_INT; },
-  [](const IDProperty &property, void *r_value) { *(int *)r_value = 
IDP_Int(&property); },
+  [](const IDProperty &property,
+ const blender::bke::PersistentDataHan

[Bf-blender-cvs] [7fd19c20e01] master: Geometry Nodes: Gray out "New" button when curve object is active

2021-01-08 Thread Hans Goudey
Commit: 7fd19c20e01ce4c4d5fe4c4c5f534724cde8bebc
Author: Hans Goudey
Date:   Fri Jan 8 15:04:38 2021 -0600
Branches: master
https://developer.blender.org/rB7fd19c20e01ce4c4d5fe4c4c5f534724cde8bebc

Geometry Nodes: Gray out "New" button when curve object is active

Currently curve objects aren't supported by the node modifier, so the
new node group and modifier operator shouldn't be available.

===

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

===

diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py 
b/release/scripts/startup/bl_operators/geometry_nodes.py
index 03cd14a3df7..d3f984269f8 100644
--- a/release/scripts/startup/bl_operators/geometry_nodes.py
+++ b/release/scripts/startup/bl_operators/geometry_nodes.py
@@ -38,8 +38,8 @@ def geometry_node_group_empty_new(context):
 def geometry_modifier_poll(context) -> bool:
 ob = context.object
 
-# Test object support for geometry node modifier (No volume or hair object 
support yet)
-if not ob or ob.type not in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT', 
'POINTCLOUD'}:
+# Test object support for geometry node modifier (No volume, curve, or 
hair object support yet)
+if not ob or ob.type not in {'MESH', 'POINTCLOUD'}:
 return False
 
 return True

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


[Bf-blender-cvs] [3c1fcec6522] master: Fix T84517: Two geometry node trees added with "New" button

2021-01-08 Thread Hans Goudey
Commit: 3c1fcec6522e25525cbf8747c70cd79db508f003
Author: Hans Goudey
Date:   Fri Jan 8 12:12:43 2021 -0600
Branches: master
https://developer.blender.org/rB3c1fcec6522e25525cbf8747c70cd79db508f003

Fix T84517: Two geometry node trees added with "New" button

Adding the modifier itself already adds a new node tree, which is
then displayed in the node editor because of the active object and
active modifier context. So there's no need to create the node tree
in the python code in this case.

===

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

===

diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py 
b/release/scripts/startup/bl_operators/geometry_nodes.py
index 12cb9473b64..03cd14a3df7 100644
--- a/release/scripts/startup/bl_operators/geometry_nodes.py
+++ b/release/scripts/startup/bl_operators/geometry_nodes.py
@@ -62,9 +62,6 @@ class NewGeometryNodesModifier(bpy.types.Operator):
 if not modifier:
 return {'CANCELLED'}
 
-group = geometry_node_group_empty_new(context)
-modifier.node_group = group
-
 return {'FINISHED'}

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


[Bf-blender-cvs] [bc788929aa2] master: Scenes: forbid deleting last local scene

2021-01-08 Thread Jacques Lucke
Commit: bc788929aa2bd259670a5562a1f403f25cad4625
Author: Jacques Lucke
Date:   Fri Jan 8 16:30:44 2021 +0100
Branches: master
https://developer.blender.org/rBbc788929aa2bd259670a5562a1f403f25cad4625

Scenes: forbid deleting last local scene

Previously, it was only forbidden to delete the last scene. This can
lead to the situation where a .blend file only contains linked scenes.
This is problematic, because linked data might not always be available
or can be removed from a .blend file without having an additional check
for remaining scenes.

Now there always has to be at least one local scene.

Reviewers: mont29

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

===

M   source/blender/blenkernel/BKE_scene.h
M   source/blender/blenkernel/intern/scene.c
M   source/blender/editors/scene/scene_edit.c
M   source/blender/makesrna/intern/rna_main_api.c

===

diff --git a/source/blender/blenkernel/BKE_scene.h 
b/source/blender/blenkernel/BKE_scene.h
index 7ac980e9d94..a3d40e093d9 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -110,6 +110,8 @@ void BKE_toolsettings_free(struct ToolSettings 
*toolsettings);
 struct Scene *BKE_scene_duplicate(struct Main *bmain, struct Scene *sce, 
eSceneCopyMethod type);
 void BKE_scene_groups_relink(struct Scene *sce);
 
+bool BKE_scene_can_be_removed(const struct Main *bmain, const struct Scene 
*scene);
+
 bool BKE_scene_has_view_layer(const struct Scene *scene, const struct 
ViewLayer *layer);
 struct Scene *BKE_scene_find_from_collection(const struct Main *bmain,
  const struct Collection 
*collection);
diff --git a/source/blender/blenkernel/intern/scene.c 
b/source/blender/blenkernel/intern/scene.c
index adc50c2247b..11cdf67cb82 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -2032,6 +2032,21 @@ void BKE_scene_groups_relink(Scene *sce)
   }
 }
 
+bool BKE_scene_can_be_removed(const Main *bmain, const Scene *scene)
+{
+  /* Linked scenes can always be removed. */
+  if (ID_IS_LINKED(scene)) {
+return true;
+  }
+  /* Local scenes can only be removed, when there is at least one local scene 
left. */
+  LISTBASE_FOREACH (Scene *, other_scene, &bmain->scenes) {
+if (other_scene != scene && !ID_IS_LINKED(other_scene)) {
+  return true;
+}
+  }
+  return false;
+}
+
 Scene *BKE_scene_add(Main *bmain, const char *name)
 {
   Scene *sce;
diff --git a/source/blender/editors/scene/scene_edit.c 
b/source/blender/editors/scene/scene_edit.c
index 47edb322701..2b2a0d10e29 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -240,8 +240,9 @@ static void SCENE_OT_new(wmOperatorType *ot)
 
 static bool scene_delete_poll(bContext *C)
 {
+  Main *bmain = CTX_data_main(C);
   Scene *scene = CTX_data_scene(C);
-  return (scene->id.prev || scene->id.next);
+  return BKE_scene_can_be_removed(bmain, scene);
 }
 
 static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
diff --git a/source/blender/makesrna/intern/rna_main_api.c 
b/source/blender/makesrna/intern/rna_main_api.c
index 5170d598ab5..d24be91f731 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -194,9 +194,9 @@ static void rna_Main_scenes_remove(
 {
   /* don't call BKE_id_free(...) directly */
   Scene *scene = scene_ptr->data;
-  Scene *scene_new;
 
-  if ((scene_new = scene->id.prev) || (scene_new = scene->id.next)) {
+  if (BKE_scene_can_be_removed(bmain, scene)) {
+Scene *scene_new = scene->id.prev ? scene->id.prev : scene->id.next;
 if (do_unlink) {
   wmWindow *win = CTX_wm_window(C);
 
@@ -216,8 +216,10 @@ static void rna_Main_scenes_remove(
 rna_Main_ID_remove(bmain, reports, scene_ptr, do_unlink, true, true);
   }
   else {
-BKE_reportf(
-reports, RPT_ERROR, "Scene '%s' is the last, cannot be removed", 
scene->id.name + 2);
+BKE_reportf(reports,
+RPT_ERROR,
+"Scene '%s' is the last local one, cannot be removed",
+scene->id.name + 2);
   }
 }

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


[Bf-blender-cvs] [cf3aa1e4b62] temp-gpencil-interpolate: Merge branch 'master' into temp-gpencil-interpolate

2021-01-08 Thread Antonio Vazquez
Commit: cf3aa1e4b62e17731d9ee2f9cccdbb65454bbc9e
Author: Antonio Vazquez
Date:   Fri Jan 8 16:11:23 2021 +0100
Branches: temp-gpencil-interpolate
https://developer.blender.org/rBcf3aa1e4b62e17731d9ee2f9cccdbb65454bbc9e

Merge branch 'master' into temp-gpencil-interpolate

===



===



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


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

2021-01-08 Thread Antonio Vazquez
Commit: 6740bbb39b4a31525875bf1c9041eae2821f585b
Author: Antonio Vazquez
Date:   Fri Jan 8 16:10:54 2021 +0100
Branches: greasepencil-object
https://developer.blender.org/rB6740bbb39b4a31525875bf1c9041eae2821f585b

Merge branch 'master' into greasepencil-object

===



===



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


[Bf-blender-cvs] [2d3f96cace6] master: Fix T84453: Crash bezier curves transfrom

2021-01-08 Thread Germano Cavalcante
Commit: 2d3f96cace6d63dbf15544dbe8a9a4fa912f6d6d
Author: Germano Cavalcante
Date:   Thu Jan 7 13:32:58 2021 -0300
Branches: master
https://developer.blender.org/rB2d3f96cace6d63dbf15544dbe8a9a4fa912f6d6d

Fix T84453: Crash bezier curves transfrom

The pointer allocated to the `TransData` was being incorrectly incremented,
causing misalignment and consequently `heap-buffer-overflow`.

Because of this, `TD_NOTCONNECTED` was being set in a strange way that did
not correspond to other types of `TransData`.

The solution is to not increment the `TransData` pointer and set
`TD_NOTCONNECTED` only for "unconnected" segments.

The code was also a bit deduplicated.

===

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

===

diff --git a/source/blender/editors/transform/transform_convert_curve.c 
b/source/blender/editors/transform/transform_convert_curve.c
index d2feb966657..445253d5446 100644
--- a/source/blender/editors/transform/transform_convert_curve.c
+++ b/source/blender/editors/transform/transform_convert_curve.c
@@ -197,9 +197,10 @@ void createTransCurveVerts(TransInfo *t)
 TransData *td = tc->data;
 ListBase *nurbs = BKE_curve_editNurbs_get(cu);
 LISTBASE_FOREACH (Nurb *, nu, nurbs) {
+  TransData *head, *tail;
+  head = tail = td;
+  bool has_any_selected = false;
   if (nu->type == CU_BEZIER) {
-TransData *head, *tail;
-head = tail = td;
 for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
   if (bezt->hide == 0) {
 TransDataCurveHandleFlags *hdata = NULL;
@@ -223,6 +224,7 @@ void createTransCurveVerts(TransInfo *t)
 
 /* Elements that will be transform (not always a match to 
selection). */
 const int bezt_tx = bezt_select_to_transform_triple_flag(bezt, 
hide_handles);
+has_any_selected |= bezt_tx != 0;
 
 if (is_prop_edit || bezt_tx & SEL_F1) {
   copy_v3_v3(td->iloc, bezt->vec[0]);
@@ -350,28 +352,9 @@ void createTransCurveVerts(TransInfo *t)
 
 (void)hdata; /* quiet warning */
   }
-  else if (is_prop_edit && head != tail) {
-tail->flag |= TD_NOTCONNECTED;
-td++;
-tail++;
-  }
-}
-if (is_prop_edit && head != tail) {
-  bool cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0;
-  calc_distanceCurveVerts(head, tail - 1, cyclic);
-}
-
-/* TODO - in the case of tilt and radius we can also avoid allocating 
the
- * initTransDataCurveHandles but for now just don't change handle 
types */
-if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT, TFM_DUMMY) == 0) {
-  /* sets the handles based on their selection,
-   * do this after the data is copied to the TransData */
-  BKE_nurb_handles_test(nu, !hide_handles, 
use_around_origins_for_handles_test);
 }
   }
   else {
-TransData *head, *tail;
-head = tail = td;
 for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
   if (bp->hide == 0) {
 if (is_prop_edit || (bp->f1 & SELECT)) {
@@ -400,6 +383,7 @@ void createTransCurveVerts(TransInfo *t)
   copy_v3_v3(td->center, td->loc);
   if (bp->f1 & SELECT) {
 td->flag = TD_SELECTED;
+has_any_selected |= true;
   }
   else {
 td->flag = 0;
@@ -427,16 +411,26 @@ void createTransCurveVerts(TransInfo *t)
   tail++;
 }
   }
-  else if (is_prop_edit && head != tail) {
-tail->flag |= TD_NOTCONNECTED;
-td++;
-tail++;
-  }
 }
-if (is_prop_edit && head != tail) {
-  bool cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0;
-  calc_distanceCurveVerts(head, tail - 1, cyclic);
+  }
+  if (is_prop_edit && head != tail) {
+tail -= 1;
+if (!has_any_selected) {
+  for (td = head; td <= tail; td++) {
+td->flag |= TD_NOTCONNECTED;
+  }
 }
+bool cyclic = (nu->flagu & CU_NURB_CYCLIC) != 0;
+calc_distanceCurveVerts(head, tail, cyclic);
+  }
+
+  /* TODO - in the case of tilt and radius we can also avoid allocating the
+   * initTransDataCurveHandles but for now just don't change handle types 
*/
+  if ((nu->type == CU_BEZIER) &&
+  ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT, TFM_DUMMY) == 0) {
+/* sets the handles based on their selection,
+ * do this after the data is copied to the TransData */
+BKE_nurb_handles_test(nu, !hide_handles, 
use_around_origins_for_handles_test);
   }
 }
   }

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

[Bf-blender-cvs] [c549d736cff] master: Icons: Update script to generate icons from SVGs for Inkscape 1.0

2021-01-08 Thread Julian Eisel
Commit: c549d736cff0d5013f05fb5240ef07671c5aa5ce
Author: Julian Eisel
Date:   Fri Jan 8 14:58:29 2021 +0100
Branches: master
https://developer.blender.org/rBc549d736cff0d5013f05fb5240ef07671c5aa5ce

Icons: Update script to generate icons from SVGs for Inkscape 1.0

The command line syntax for Inkscape changed quite a bit for the 1.0 release,
see https://wiki.inkscape.org/wiki/index.php/Release_notes/1.0#Command_Line.
Think it's reasonable to expect Inkscape 1.0 or later be installed if you want
to generate the icons with the script. It's easy to get via the website, if the
distribution doesn't provide new enough packages. Only few people would use the
script anyway.

I also had to change the path for command line access on macOS which apparently
changed (https://stackoverflow.com/a/60068607). Although I didn't find a
mention of this change in the Inkscape release notes.

===

M   release/datafiles/blender_icons_update.py
M   release/datafiles/prvicons_update.py

===

diff --git a/release/datafiles/blender_icons_update.py 
b/release/datafiles/blender_icons_update.py
index ed96afd7ea6..8167b8b25e6 100755
--- a/release/datafiles/blender_icons_update.py
+++ b/release/datafiles/blender_icons_update.py
@@ -17,7 +17,7 @@ inkscape_bin = os.environ.get("INKSCAPE_BIN", "inkscape")
 blender_bin = os.environ.get("BLENDER_BIN", "blender")
 
 if sys.platform == 'darwin':
-inkscape_app_path = '/Applications/Inkscape.app/Contents/Resources/script'
+inkscape_app_path = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
 if os.path.exists(inkscape_app_path):
 inkscape_bin = inkscape_app_path
 blender_app_path = '/Applications/Blender.app/Contents/MacOS/Blender'
@@ -29,8 +29,8 @@ cmd = (
 os.path.join(BASEDIR, "blender_icons.svg"),
 "--export-width=602",
 "--export-height=640",
-"--without-gui",
-"--export-png=" + os.path.join(BASEDIR, "blender_icons16.png"),
+"--export-type=png",
+"--export-filename=" + os.path.join(BASEDIR, "blender_icons16.png"),
 )
 run(cmd)
 
@@ -39,8 +39,8 @@ cmd = (
 os.path.join(BASEDIR, "blender_icons.svg"),
 "--export-width=1204",
 "--export-height=1280",
-"--without-gui",
-"--export-png=" + os.path.join(BASEDIR, "blender_icons32.png"),
+"--export-type=png",
+"--export-filename=" + os.path.join(BASEDIR, "blender_icons32.png"),
 )
 run(cmd)
 
diff --git a/release/datafiles/prvicons_update.py 
b/release/datafiles/prvicons_update.py
index 85e92e9e564..fa526f88e96 100755
--- a/release/datafiles/prvicons_update.py
+++ b/release/datafiles/prvicons_update.py
@@ -10,7 +10,7 @@ BASEDIR = os.path.abspath(os.path.dirname(__file__))
 inkscape_path = 'inkscape'
 
 if sys.platform == 'darwin':
-inkscape_app_path = '/Applications/Inkscape.app/Contents/Resources/script'
+inkscape_app_path = '/Applications/Inkscape.app/Contents/MacOS/inkscape'
 if os.path.exists(inkscape_app_path):
 inkscape_path = inkscape_app_path
 
@@ -19,7 +19,7 @@ cmd = (
 os.path.join(BASEDIR, "prvicons.svg"),
 "--export-width=1792",
 "--export-height=256",
-"--without-gui",
-"--export-png=" + os.path.join(BASEDIR, "prvicons.png"),
+"--export-type=png",
+"--export-filename=" + os.path.join(BASEDIR, "prvicons.png"),
 )
 subprocess.check_call(cmd)

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


[Bf-blender-cvs] [c66f00dc26b] master: Fix Cycles rendering with OptiX after instance limit increase when building with old SDK

2021-01-08 Thread Patrick Mours
Commit: c66f00dc26b08d5f7be6aef080c1a0ec2de19cd7
Author: Patrick Mours
Date:   Fri Jan 8 13:38:26 2021 +0100
Branches: master
https://developer.blender.org/rBc66f00dc26b08d5f7be6aef080c1a0ec2de19cd7

Fix Cycles rendering with OptiX after instance limit increase when building 
with old SDK

Commit d259e7dcfbbd37cec5a45fdfb554f24de10d0268 increased the instance limit, 
but only provided
a fall back for the host code for older OptiX SDKs, not for kernel code. This 
caused a mismatch when
an old SDK was used (as is currently the case on buildbot) and subsequent 
rendering artifacts. This
fixes that by moving the bit that is checked to a common location that works 
with both old an new
SDK versions.

===

M   intern/cycles/device/device_optix.cpp
M   intern/cycles/kernel/kernels/optix/kernel_optix.cu

===

diff --git a/intern/cycles/device/device_optix.cpp 
b/intern/cycles/device/device_optix.cpp
index de98e3f3594..f19289f966e 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -1514,16 +1514,19 @@ class OptiXDevice : public CUDADevice {
 }
 else {
   unsigned int num_instances = 0;
+  unsigned int max_num_instances = 0x;
 
   bvh_optix->as_data.free();
   bvh_optix->traversable_handle = 0;
   bvh_optix->motion_transform_data.free();
 
-#  if OPTIX_ABI_VERSION < 23
-  if (bvh->objects.size() > 0x7F) {
-#  else
-  if (bvh->objects.size() > 0x7FF) {
-#  endif
+  optixDeviceContextGetProperty(context,
+
OPTIX_DEVICE_PROPERTY_LIMIT_MAX_INSTANCE_ID,
+&max_num_instances,
+sizeof(max_num_instances));
+  // Do not count first bit, which is used to distinguish instanced and 
non-instanced objects
+  max_num_instances >>= 1;
+  if (bvh->objects.size() > max_num_instances) {
 progress.set_error(
 "Failed to build OptiX acceleration structure because there are 
too many instances");
 return;
@@ -1582,8 +1585,8 @@ class OptiXDevice : public CUDADevice {
 instance.transform[5] = 1.0f;
 instance.transform[10] = 1.0f;
 
-// Set user instance ID to object index
-instance.instanceId = ob->get_device_index();
+// Set user instance ID to object index (but leave low bit blank)
+instance.instanceId = ob->get_device_index() << 1;
 
 // Have to have at least one bit in the mask, or else instance would 
always be culled
 instance.visibilityMask = 1;
@@ -1689,13 +1692,9 @@ class OptiXDevice : public CUDADevice {
   else {
 // Disable instance transform if geometry already has it applied 
to vertex data
 instance.flags = OPTIX_INSTANCE_FLAG_DISABLE_TRANSFORM;
-// Non-instanced objects read ID from prim_object, so
-// distinguish them from instanced objects with high bit set
-#  if OPTIX_ABI_VERSION < 23
-instance.instanceId |= 0x80;
-#  else
-instance.instanceId |= 0x800;
-#  endif
+// Non-instanced objects read ID from 'prim_object', so distinguish
+// them from instanced objects with the low bit set
+instance.instanceId |= 1;
   }
 }
   }
diff --git a/intern/cycles/kernel/kernels/optix/kernel_optix.cu 
b/intern/cycles/kernel/kernels/optix/kernel_optix.cu
index 0c2c84fdbdf..7f609eab474 100644
--- a/intern/cycles/kernel/kernels/optix/kernel_optix.cu
+++ b/intern/cycles/kernel/kernels/optix/kernel_optix.cu
@@ -45,13 +45,12 @@ template ccl_device_forceinline uint 
get_object_id()
   uint object = optixGetInstanceId();
 #endif
   // Choose between always returning object ID or only for instances
-  if (always)
-// Can just remove the high bit since instance always contains object ID
-return object & 0x7FF;  // OPTIX_ABI_VERSION >= 23 ? 0x7FF : 
0x7F
-  // Set to OBJECT_NONE if this is not an instanced object
-  else if (object & 0x800)  // OPTIX_ABI_VERSION >= 23 ? 0x800 : 
0x80
-object = OBJECT_NONE;
-  return object;
+  if (always || (object & 1) == 0)
+// Can just remove the low bit since instance always contains object ID
+return object >> 1;
+  else
+// Set to OBJECT_NONE if this is not an instanced object
+return OBJECT_NONE;
 }
 
 extern "C" __global__ void __raygen__kernel_optix_path_trace()

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


[Bf-blender-cvs] [9973be83e94] temp-angavrilov-constraints: Surface Deform: fix binding vertex artifacts causing spikes.

2021-01-08 Thread Alexander Gavrilov
Commit: 9973be83e94497079f044ebe85b2cb3b32ff3d97
Author: Alexander Gavrilov
Date:   Thu Jan 7 20:40:29 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB9973be83e94497079f044ebe85b2cb3b32ff3d97

Surface Deform: fix binding vertex artifacts causing spikes.

There are two issues here. First, like in T81988 there are cases
where the modifier would deform some vertices immediately after
bind. This is caused by wrong assumptions in the code about the
possible relative angles between various vectors, which can cause
negative weights that don't blend correctly to appear.

Specifically, it seems originally the code assumes that the
centroid-point vector in the polygon plane lies somewhere
between the mid-edge vectors. This is however not necessarily
the case for distant vertices, because the polygon is not
guaranteed to be truly planar, so normal projection may be
a bit off. The code has to use signed angles and checks to
support all possible angular arrangements.

The second issue is very thin and long triangles, which tend
to be very spatially unstable in their thin dimension, resulting
in excess deformation. The code was weighting distance using
the distances between the centroid and the mid-edge points, which
in this case end up as nearly opposite vectors of sizable length
and don't correctly represent how thin the triangle actually is.
It is thus better to use centroid-to-line distances, and an
additional even stricter value for the midpoint that will use
only 3 vertices at evaluation time.

===

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

===

diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c 
b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 0fad78683eb..d0e04c3ac82 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -115,6 +115,7 @@ typedef struct SDefBindPoly {
   float weight_dist;
   float weight;
   float scales[2];
+  float scale_mid;
   /** Center of `coords` */
   float centroid[3];
   /** Center of `coords_v2` */
@@ -460,9 +461,13 @@ static void freeBindData(SDefBindWeightData *const bwdata)
   MEM_freeN(bwdata);
 }
 
-BLI_INLINE float computeAngularWeight(const float point_angle)
+BLI_INLINE float computeAngularWeight(const float point_angle, const float 
edgemid_angle)
 {
-  return sinf(point_angle * M_PI_2);
+  if (edgemid_angle <= FLT_EPSILON) {
+return point_angle > 0 ? 1 : 0;
+  }
+
+  return sinf(min_ff(point_angle / edgemid_angle, 1) * M_PI_2);
 }
 
 BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
@@ -603,33 +608,40 @@ BLI_INLINE SDefBindWeightData 
*computeBindWeights(SDefBindCalcData *const data,
 
 avg_point_dist += bpoly->weight_dist;
 
-/* Compute centroid to mid-edge vectors */
-mid_v2_v2v2(bpoly->cent_edgemid_vecs_v2[0],
-bpoly->coords_v2[bpoly->edge_vert_inds[0]],
-bpoly->coords_v2[bpoly->corner_ind]);
+/* Common vertex coordinates. */
+const float *const vert0_v2 = 
bpoly->coords_v2[bpoly->edge_vert_inds[0]];
+const float *const vert1_v2 = 
bpoly->coords_v2[bpoly->edge_vert_inds[1]];
+const float *const corner_v2 = bpoly->coords_v2[bpoly->corner_ind];
 
-mid_v2_v2v2(bpoly->cent_edgemid_vecs_v2[1],
-bpoly->coords_v2[bpoly->edge_vert_inds[1]],
-bpoly->coords_v2[bpoly->corner_ind]);
+/* Compute centroid to mid-edge vectors */
+mid_v2_v2v2(bpoly->cent_edgemid_vecs_v2[0], vert0_v2, corner_v2);
+mid_v2_v2v2(bpoly->cent_edgemid_vecs_v2[1], vert1_v2, corner_v2);
 
 sub_v2_v2(bpoly->cent_edgemid_vecs_v2[0], bpoly->centroid_v2);
 sub_v2_v2(bpoly->cent_edgemid_vecs_v2[1], bpoly->centroid_v2);
 
-/* Compute poly scales with respect to mid-edges, and normalize the 
vectors */
-bpoly->scales[0] = normalize_v2(bpoly->cent_edgemid_vecs_v2[0]);
-bpoly->scales[1] = normalize_v2(bpoly->cent_edgemid_vecs_v2[1]);
+normalize_v2(bpoly->cent_edgemid_vecs_v2[0]);
+normalize_v2(bpoly->cent_edgemid_vecs_v2[1]);
 
-/* Compute the required polygon angles */
+/* Compute poly scales with respect to the two edges. */
+bpoly->scales[0] = dist_to_line_v2(bpoly->centroid_v2, vert0_v2, 
corner_v2);
+bpoly->scales[1] = dist_to_line_v2(bpoly->centroid_v2, vert1_v2, 
corner_v2);
+
+/* Compute the angle between the edge mid vectors. */
 bpoly->edgemid_angle = 
angle_normalized_v2v2(bpoly->cent_edgemid_vecs_v2[0],
  
bpoly->cent_edgemid_vecs_v2[1]);
 
-sub_v2_v2v2(tmp_vec_v2, bpoly->coords_v2[bpoly->corner_ind], 
bpoly->centroid_v2);
+/* Compute the angles between the corner and the 

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

2021-01-08 Thread Alexander Gavrilov
Commit: 9cd9386d5745c64b1662321831bc54dfd7956bf4
Author: Alexander Gavrilov
Date:   Sun Jan 3 23:40:44 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB9cd9386d5745c64b1662321831bc54dfd7956bf4

Bone Overlay: support bone wireframe opacity settings.

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

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

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 55cb110177f..4748ec6a1ee 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6473,17 +6473,18 @@ class VIEW3D_PT_overlay_sculpt(Panel):
 row.prop(overlay, "sculpt_mode_face_sets_opacity", text="Face Sets")
 
 
-class VIEW3D_PT_overlay_pose(Panel):
+class VIEW3D_PT_overlay_bones(Panel):
 bl_space_type = 'VIEW_3D'
 bl_region_type = 'HEADER'
 bl_parent_id = 'VIEW3D_PT_overlay'
-bl_label = "Pose Mode"
+bl_label = "Bones"
 
 @classmethod
 def poll(cls, context):
 mode = context.mode
 return (
 (mode == 'POSE') or
+(mode == 'EDIT_ARMATURE') or
 (mode == 'PAINT_WEIGHT' and context.pose_object)
 )
 
@@ -6503,10 +6504,14 @@ class VIEW3D_PT_overlay_pose(Panel):
 sub = row.row()
 sub.active = display_all and overlay.show_xray_bone
 sub.prop(overlay, "xray_alpha_bone", text="Fade Geometry")
-else:
+elif mode == 'PAINT_WEIGHT':
 row = col.row()
 row.prop(overlay, "show_xray_bone")
 
+row = col.row()
+row.prop(overlay, "bone_wire_alpha")
+row.prop(overlay, "bone_wire_fade")
+
 
 class VIEW3D_PT_overlay_texture_paint(Panel):
 bl_space_type = 'VIEW_3D'
@@ -7675,7 +7680,7 @@ classes = (
 VIEW3D_PT_overlay_texture_paint,
 VIEW3D_PT_overlay_vertex_paint,
 VIEW3D_PT_overlay_weight_paint,
-VIEW3D_PT_overlay_pose,
+VIEW3D_PT_overlay_bones,
 VIEW3D_PT_overlay_sculpt,
 VIEW3D_PT_snapping,
 VIEW3D_PT_proportional_edit,
diff --git a/source/blender/blenloader/intern/versioning_290.c 
b/source/blender/blenloader/intern/versioning_290.c
index 055d7cc51b5..b15aadd913f 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1558,5 +1558,18 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 }
   }
 }
+
+if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", 
"bone_wire_alpha")) {
+  for (bScreen *screen = bmain->screens.first; screen; screen = 
screen->id.next) {
+LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+if (sl->spacetype == SPACE_VIEW3D) {
+  View3D *v3d = (View3D *)sl;
+  v3d->overlay.bone_wire_alpha = 1.0f;
+}
+  }
+}
+  }
+}
   }
 }
diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 9b716d3..382f0dae001 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -331,6 +331,7 @@ data_to_c_simple(engines/basic/shaders/depth_frag.glsl SRC)
 data_to_c_simple(engines/overlay/shaders/common_overlay_lib.glsl SRC)
 

[Bf-blender-cvs] [dadd4fdad6b] temp-angavrilov-constraints: Constraints: add support for a new Owner Local Space for targets.

2021-01-08 Thread Alexander Gavrilov
Commit: dadd4fdad6b06ebaedc74f38b985c69bb3ec77e7
Author: Alexander Gavrilov
Date:   Fri Dec 11 11:53:25 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rBdadd4fdad6b06ebaedc74f38b985c69bb3ec77e7

Constraints: add support for a new Owner Local Space for targets.

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

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

Owner Local Space replaces the following setup:

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

(This analogy applies provided both bones use Local Location)

Since the space list is getting long, this adds a couple of separators.

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

===

M   source/blender/blenkernel/intern/constraint.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesrna/intern/rna_constraint.c
M   source/blender/makesrna/intern/rna_object_api.c

===

diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index 87370b78810..9b3c6e3c955 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -299,7 +299,7 @@ void BKE_constraint_mat_convertspace(Object *ob,
   mul_m4_m4m4(mat, imat, mat);
 
   /* Use pose-space as stepping stone for other spaces. */
-  if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
+  if (to != CONSTRAINT_SPACE_POSE) {
 /* Call self with slightly different values. */
 BKE_constraint_mat_convertspace(
 ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
@@ -310,9 +310,22 @@ void BKE_constraint_mat_convertspace(Object *ob,
   case CONSTRAINT_SPACE_POSE: /* -- FROM POSESPACE -- */
   {
 /* pose to local */
-if (to == CONSTRAINT_SPACE_LOCAL) {
+if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_OWNLOCAL)) {
   if (pchan->bone) {
 BKE_armature_mat_pose_to_bone(pchan, mat, mat);
+
+if (to == CONSTRAINT_SPACE_OWNLOCAL) {
+  copy_m4_m4(diff_mat, pchan->bone->arm_mat);
+
+  if (cob && cob->pchan && cob->pchan->bone) {
+invert_m4_m4(imat, cob->pchan->bone->arm_mat);
+mul_m4_m4m4(diff_mat, imat, diff_mat);
+  }
+
+  zero_v3(diff_mat[3]);
+  invert_m4_m4(imat, diff_mat);
+  mul_m4_series(mat, diff_mat, mat, imat);
+}
   }
 }
 /* pose to local with parent */
@@ -335,15 +348,28 @@ void BKE_constraint_mat_convertspace(Object *ob,
 break;
   }
   case CONSTRAINT_SPACE_LOCAL: /*  FROM LOCALSPACE - */
-  {
+  case CONSTRAINT_SPACE_OWNLOCAL: {
 /* local to pose - do inverse procedure that was done for pose to 
local */
 if (pchan->bone) {
+  if (from == CONSTRAINT_SPACE_OWNLOCAL) {
+copy_m4_m4(diff_mat, pchan->bone->arm_mat);
+
+if (cob && cob->pchan && cob->pchan->bone) {
+  invert_m4_m4(imat, cob->pchan->bone->arm_mat);
+  mul_m4_m4m4(diff_mat, imat, diff_mat);
+}
+
+zero_v3(diff_mat[3]);
+invert_m4_m4(imat, diff_mat);
+mul_m4_series(mat, imat, mat, diff_mat);
+  }
+
   /* we need the posespace_matrix = local_matrix + 
(parent_posespace_matrix + restpos) */
   BKE_armature_mat_bone_to_pose(pchan, mat, mat);
 }
 
 /* use pose-space as stepping stone for other spaces */
-if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL, 
CONSTRAINT_SPACE_CUSTOM)) {
+if (to != CONSTRAINT_SPACE_POSE) {
   /* call self with slightly different values */
   BKE_constraint_mat_convertspace(
   ob, pchan, cob, mat, CONSTRAINT_SPACE_POSE, to, keep_scale);
@@ -358,7 +384,7 @@ void BKE_constraint_mat_convertspace(Object *ob,
 }
 
 /* use pose-space as stepping stone for other spaces */
-if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, 
CONSTRAINT_SPACE_CUSTOM)) {
+if (to != CONSTRAINT_SPACE_POSE) {
   /* call self with slightly different values */
   BKE_constraint_mat_convertspace(

[Bf-blender-cvs] [8da6446a522] temp-angavrilov-constraints: Copy Transforms: implement Invert, Fix Shear and more Mix options.

2021-01-08 Thread Alexander Gavrilov
Commit: 8da6446a5224a6f2afce9234498f559c9e2efc44
Author: Alexander Gavrilov
Date:   Wed Nov 4 19:29:27 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB8da6446a5224a6f2afce9234498f559c9e2efc44

Copy Transforms: implement Invert, Fix Shear and more Mix options.

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

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

- An option to fix shear in the incoming target matrix.
- An option to invert the target matrix.
- More ways to combine target and owner matrix.

Shear is known to cause issues for various mathematical operations,
so an option to remove it at key points is useful. In the future node
system this would be a separate operation, but due to the limits of
the constraint stack it has to be built in for now.

Inverting a matrix is also an operation that can be useful to have.
For some uses it may be useful to invert components separately, so
implement this by checking the Mix mode setting to avoid UI options.

Finally, add two more ways to combine the matrices (multiplied by
two due to the necessity for the Before/After choice). Now there
are three combine modes:

Full implements regular matrix multiplication as the most basic option.

Split Channels combines location, rotation and scale separately.
Looking at D7547 there is demand for such a mode in some cases,
and even with nodes it's cumbersome to rig manually every time.

Finally, Aligned emulates the 'anti-shear' Aligned Inherit Scale mode,
and basically uses Full for location, and Split for rotation/scale.

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

===

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

===

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py 
b/release/scripts/startup/bl_ui/properties_constraint.py
index a7ac96508f4..3d358b2db5d 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -505,6 +505,8 @@ class ConstraintButtonsPanel(Panel):
 
 self.target_template(layout, con)
 
+layout.prop(con, "fix_target_shear")
+layout.prop(con, "invert")
 layout.prop(con, "mix_mode", text="Mix")
 
 self.space_template(layout, con)
diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index 5bd8a2bc576..9da17282a4f 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2232,17 +2232,62 @@ static void translike_evaluate(bConstraint *con, 
bConstraintOb *cob, ListBase *t
   bConstraintTarget *ct = targets->first;
 
   if (VALID_CONS_TARGET(ct)) {
+float target_mat[4][4];
+
+copy_m4_m4(target_mat, ct->matrix);
+
+/* Fix the shear of the target matrix if enabled.
+ * Use Y as the axis since it's the natural default for bones. */
+if (data->flag & TRANSLIKE_FIX_TARGET_SHEAR) {
+  orthogonalize_m4_stable(target_mat, 1, false);
+}
+
+/* Invert the transformation. */
+if (data->flag & TRANSLIKE_INVERT) {
+  /* For modes that split channels, split during invert too. */
+  if (ELEM(data->mix_mode,
+   TRANSLIKE_MIX_BEFORE,
+   TRANSLIKE_MIX_AFTER,
+   TRANSLIKE_MIX_BEFORE_SPLIT,
+   TRANSLIKE_MIX_AFTER_SPLIT)) {
+invert_m4_m4_split_channels(target_mat, target_mat);
+  }
+  else {
+invert_m4(target_mat);
+  }
+}
+
+/* Finally, combine the matrices. */
 switch (data->mix_mode) {
   case TRANSLIKE_MIX_REPLACE:
-copy_m4_m4(cob->matrix, ct->matrix);
+copy_m4_m4(cob->matrix, target_mat);
 break;
 
+  /* Simple matrix multiplication. */
+  case TRANSLIKE_MIX_BEFORE_FULL:
+mul_m4_m4m4(cob->matrix, target_mat, cob->matrix);
+break;
+
+  case TRANSLIKE_MIX_AFTER_FULL:
+mul_m4_m4m4(cob->matrix, cob->matrix, target_mat);
+break;
+
+  /* Aligned Inherit Scale emulation. */
   case TRANSLIKE_MIX_BEFORE:
-mul_m4_m4m4_aligned_scale(cob->matrix, ct->matrix, cob->matrix);
+mul_m4_m4m4_aligned_scale(cob->matrix, target_mat, cob->matrix);
 break;
 
   case TRANSLIKE_MIX_AFTER:
-mul_m4_m4m4_aligned_scale(co

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

2021-01-08 Thread Alexander Gavrilov
Commit: 1c7dae9ee079164e6a5bc1442f34ef6b024b6181
Author: Alexander Gavrilov
Date:   Mon Nov 23 23:42:05 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB1c7dae9ee079164e6a5bc1442f34ef6b024b6181

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

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

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

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

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

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

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

===

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

===

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

[Bf-blender-cvs] [c44e9b4de03] temp-angavrilov-constraints: Armature: add B-Bone lengthwise scaling and custom handle scaling options.

2021-01-08 Thread Alexander Gavrilov
Commit: c44e9b4de030faad69e43429c7834090bfeac4d2
Author: Alexander Gavrilov
Date:   Fri Dec 11 19:17:39 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rBc44e9b4de030faad69e43429c7834090bfeac4d2

Armature: add B-Bone lengthwise scaling and custom handle scaling options.

In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.

First, there are only X and Y scale factors (actually X and Z,
but this is the legacy naming), while lengthwise all segments
have the same scaling. The ease option merely affects the shape
of the curve, and does not cause actual scaling.

Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.

This patch addresses these deficiencies by adding Length scale
inputs, and providing toggles to apply custom handle local scale
channels to the now four scale-related properties. The 'Length'
name is used to avoid confusion due to the X/Y vs X/Z naming.

The two Length scale inputs control the ratio between the lengths
of the start and end segments of the bone: although for convenience
two inputs are provided, the whole chain is still uniformly scaled
to fit the curve.

A Scale Easing option is provided to multiply the easing value
by the Length scale factors to synchronize them - this produces
a natural scaling effect where both the shape of the curve and
the scale is affected.

The second issue is addressed by providing toggles for each handle
that multiply each of the X, Z, Length and Ease values by the matching
Local Scale channel of the handle bone, thus replacing trivial drivers.
The Scale Easing option has no effect on this process since it's easy
to just enable both Length and Ease buttons.

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

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

===

M   release/scripts/startup/bl_ui/properties_data_bone.py
M   source/blender/blenkernel/BKE_armature.h
M   source/blender/blenkernel/intern/action.c
M   source/blender/blenkernel/intern/armature.c
M   source/blender/blenloader/intern/versioning_290.c
M   source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
M   source/blender/draw/engines/overlay/overlay_armature.c
M   source/blender/editors/armature/armature_add.c
M   source/blender/editors/armature/armature_intern.h
M   source/blender/editors/armature/armature_utils.c
M   source/blender/editors/armature/pose_transform.c
M   source/blender/editors/armature/pose_utils.c
M   source/blender/makesdna/DNA_action_types.h
M   source/blender/makesdna/DNA_armature_types.h
M   source/blender/makesrna/intern/rna_armature.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py 
b/release/scripts/startup/bl_ui/properties_data_bone.py
index 170d7910339..5911994bcb9 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -170,28 +170,57 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
 col = topcol.column(align=True)
 col.prop(bbone, "bbone_scaleinx", text="Scale In X")
 col.prop(bbone, "bbone_scaleiny", text="In Y")
+col.prop(bbone, "bbone_scalein_len", text="In Len")
 
 col = topcol.column(align=True)
 col.prop(bbone, "bbone_scaleoutx", text="Scale Out X")
 col.prop(bbone, "bbone_scaleouty", text="Out Y")
+col.prop(bbone, "bbone_scaleout_len", text="Out Len")
 
 col = topcol.column(align=True)
 col.prop(bbone, "bbone_easein", text="Ease In")
 col.prop(bbone, "bbone_easeout", text="Out")
+col.prop(bone, "use_scale_easing")
+
+topcol.prop(bone, "use_unscaled_segments")
 
 col = topcol.column(align=True)
 col.prop(bone, "bbone_handle_type_start", text="Start Handle")
 
-col = col.column(align=True)
-col.active = (bone.bbone_handle_type_start != 'AUTO')
-col.prop_search(bone, "bbone_custom_handle_start", arm, bone_list, 
text="Custom")
+col2 = col.column(align=True)
+col2.active = 

[Bf-blender-cvs] [4053af19c2e] temp-angavrilov-constraints: Armature: fix bad B-Bone deformation blending with Preserve Volume.

2021-01-08 Thread Alexander Gavrilov
Commit: 4053af19c2e785b1592f9c0ec9d0461949c2d2ec
Author: Alexander Gavrilov
Date:   Tue Dec 29 19:55:29 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB4053af19c2e785b1592f9c0ec9d0461949c2d2ec

Armature: fix bad B-Bone deformation blending with Preserve Volume.

The double quaternion blending method in addition to the deformation
matrix of each bone requires their rest matrices. For ordinary bones
this literally should use the bone rest matrix without any ambiguity.

However, it was also using the bone rest matrix for all of its
B-Bone segments, which is incorrect and causes strange deformation
in some cases involving extreme non-uniform scale, especially
at boundaries between different B-Bones.

This changes both the Armature modifier and the Armature constraint
to use the actual segment rest matrices. Unlike bones, these can have
scale even in rest pose, so normalization is required.

===

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

===

diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index 5d3375cdb5e..8cd58968e04 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1582,7 +1582,11 @@ void BKE_pchan_bbone_segments_cache_compute(bPoseChannel 
*pchan)
   tmat,
   b_bone_mats[0].mat);
 
-mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a + 
1].mat);
+/* Compute the orthonormal object space rest matrix of the segment. */
+mul_m4_m4m4(tmat, bone->arm_mat, b_bone_rest[a].mat);
+normalize_m4(tmat);
+
+mat4_to_dquat(&b_bone_dual_quats[a], tmat, b_bone_mats[a + 1].mat);
   }
 }
 
diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index 9da17282a4f..51ffbf7feb8 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2592,9 +2592,14 @@ static void armdef_accumulate_matrix(const float 
obmat[4][4],
 
   /* Accumulate the transformation. */
   if (r_sum_dq != NULL) {
+float basemat_world[4][4];
 DualQuat tmpdq;
 
-mat4_to_dquat(&tmpdq, basemat, mat);
+/* Compute the orthonormal rest matrix in world space. */
+mul_m4_m4m4(basemat_world, obmat, basemat);
+orthogonalize_m4_stable(basemat_world, 1, true);
+
+mat4_to_dquat(&tmpdq, basemat_world, mat);
 add_weighted_dq_dq(r_sum_dq, &tmpdq, weight);
   }
   else {
@@ -2611,7 +2616,7 @@ static void armdef_accumulate_bone(bConstraintTarget *ct,
float r_sum_mat[4][4],
DualQuat *r_sum_dq)
 {
-  float iobmat[4][4], basemat[4][4], co[3];
+  float iobmat[4][4], co[3];
   Bone *bone = pchan->bone;
   float weight = ct->weight;
 
@@ -2625,15 +2630,12 @@ static void armdef_accumulate_bone(bConstraintTarget 
*ct,
 co, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, 
bone->dist);
   }
 
-  /* Compute the quaternion base matrix. */
-  if (r_sum_dq != NULL) {
-mul_m4_series(basemat, ct->tar->obmat, bone->arm_mat, iobmat);
-  }
-
   /* Find the correct bone transform matrix in world space. */
   if (bone->segments > 1 && bone->segments == pchan->runtime.bbone_segments) {
 Mat4 *b_bone_mats = pchan->runtime.bbone_deform_mats;
+Mat4 *b_bone_rest_mats = pchan->runtime.bbone_rest_mats;
 float(*iamat)[4] = b_bone_mats[0].mat;
+float basemat[4][4];
 
 /* The target is a B-Bone:
  * FIRST: find the segment (see b_bone_deform in armature.c)
@@ -2645,6 +2647,11 @@ static void armdef_accumulate_bone(bConstraintTarget *ct,
 float blend;
 BKE_pchan_bbone_deform_segment_index(pchan, y / bone->length, &index, 
&blend);
 
+if (r_sum_dq != NULL) {
+  /* Compute the object space rest matrix of the segment. */
+  mul_m4_m4m4(basemat, bone->arm_mat, b_bone_rest_mats[index].mat);
+}
+
 armdef_accumulate_matrix(ct->tar->obmat,
  iobmat,
  basemat,
@@ -2652,6 +2659,12 @@ static void armdef_accumulate_bone(bConstraintTarget *ct,
  weight * (1.0f - blend),
  r_sum_mat,
  r_sum_dq);
+
+if (r_sum_dq != NULL) {
+  /* Compute the object space rest matrix of the segment. */
+  mul_m4_m4m4(basemat, bone->arm_mat, b_bone_rest_mats[index + 1].mat);
+}
+
 armdef_accumulate_matrix(ct->tar->obmat,
  iobmat,
  basemat,
@@ -2663,7 +2676,7 @@ static void armdef_accumulate_bone(bConstraintTarget *ct,
   else {
 /* Simple bone. This requires DEG_OPCODE_BONE_DONE dependency due to 
chan_mat. */
 armdef_accumulate_mat

[Bf-blender-cvs] [9b0b961f123] temp-angavrilov-constraints: Limit Rotation: add an Euler Order option and orthogonalize the matrix.

2021-01-08 Thread Alexander Gavrilov
Commit: 9b0b961f123545b20a466ee71692c5afb1c9895d
Author: Alexander Gavrilov
Date:   Sun Nov 22 14:17:21 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB9b0b961f123545b20a466ee71692c5afb1c9895d

Limit Rotation: add an Euler Order option and orthogonalize the matrix.

Since Limit Rotation is based on Euler decomposition, it should allow
specifying the order to use for the same reasons as Copy Rotation does,
namely, if the bone uses Quaternion rotation for its animation channels,
there is no way to choose the order for the constraint.

In addition, add a call to orthogonalize the matrix before processing
for the same reasons as D8915, and an early exit in case no limits are
enabled for a bit of extra efficiency.

Since the constraint goes through Euler decomposition, it would remove
shear even before the change, but the rotation won't make much sense.

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

===

M   release/scripts/startup/bl_ui/properties_constraint.py
M   source/blender/blenkernel/intern/constraint.c
M   source/blender/makesdna/DNA_constraint_types.h
M   source/blender/makesrna/intern/rna_constraint.c

===

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py 
b/release/scripts/startup/bl_ui/properties_constraint.py
index 71a7b056d07..a7ac96508f4 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -245,6 +245,7 @@ class ConstraintButtonsPanel(Panel):
 sub.prop(con, "max_z", text="Max")
 row.label(icon="BLANK1")
 
+layout.prop(con, "euler_order", text="Order")
 layout.prop(con, "use_transform_limit")
 self.space_template(layout, con, target=False, owner=True)
 
diff --git a/source/blender/blenkernel/intern/constraint.c 
b/source/blender/blenkernel/intern/constraint.c
index 9b3c6e3c955..5bd8a2bc576 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1647,10 +1647,28 @@ static void rotlimit_evaluate(bConstraint *con, 
bConstraintOb *cob, ListBase *UN
   float eul[3];
   float size[3];
 
+  /* This constraint is based on euler rotation math, which doesn't work well 
with shear.
+   * The Y axis is chosen as the main one because constraints are most 
commonly used on bones.
+   * This also allows using the constraint to simply remove shear. */
+  orthogonalize_m4_stable(cob->matrix, 1, false);
+
+  /* Only do the complex processing if some limits are actually enabled. */
+  if (!(data->flag & (LIMIT_XROT | LIMIT_YROT | LIMIT_ZROT))) {
+return;
+  }
+
+  /* Select the Euler rotation order, defaulting to the owner value. */
+  short rot_order = cob->rotOrder;
+
+  if (data->euler_order != CONSTRAINT_EULER_AUTO) {
+rot_order = data->euler_order;
+  }
+
+  /* Decompose the matrix using the specified order. */
   copy_v3_v3(loc, cob->matrix[3]);
   mat4_to_size(size, cob->matrix);
 
-  mat4_to_eulO(eul, cob->rotOrder, cob->matrix);
+  mat4_to_eulO(eul, rot_order, cob->matrix);
 
   /* constraint data uses radians internally */
 
@@ -1683,7 +1701,7 @@ static void rotlimit_evaluate(bConstraint *con, 
bConstraintOb *cob, ListBase *UN
 }
   }
 
-  loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
+  loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, rot_order);
 }
 
 static bConstraintTypeInfo CTI_ROTLIMIT = {
diff --git a/source/blender/makesdna/DNA_constraint_types.h 
b/source/blender/makesdna/DNA_constraint_types.h
index d3f0809204b..20b60a52077 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -536,6 +536,8 @@ typedef struct bRotLimitConstraint {
   float zmin, zmax;
   short flag;
   short flag2;
+  char euler_order;
+  char _pad[3];
 } bRotLimitConstraint;
 
 /* Limit Scale Constraint */
diff --git a/source/blender/makesrna/intern/rna_constraint.c 
b/source/blender/makesrna/intern/rna_constraint.c
index 343318726c7..eeed8d2f9b3 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -2602,6 +2602,12 @@ static void rna_def_constraint_rotation_limit(BlenderRNA 
*brna)
   RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow");
   RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, 
"rna_Constraint_update");
 
+  prop = RNA_def_property(srna, "euler_order", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_sdna(prop, NULL, "euler_order");
+  RNA_def_property_enum_items(prop, euler_order_items);
+  RNA_def_property_ui_text(prop, "Euler Order", "Explicitly specify the euler 
rotation order");
+  RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, 
"rna_Constraint_update");
+
   prop = RNA_def_property(srna, "use_transform_limit", PROP_BOOLEAN, 
PROP_NONE

[Bf-blender-cvs] [1f590fbf8cf] temp-angavrilov-constraints: Weight Paint: avoid creating very small values with locked weights.

2021-01-08 Thread Alexander Gavrilov
Commit: 1f590fbf8cf60f9d212b74f21d09a71831451d8b
Author: Alexander Gavrilov
Date:   Thu Dec 24 14:30:51 2020 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rB1f590fbf8cf60f9d212b74f21d09a71831451d8b

Weight Paint: avoid creating very small values with locked weights.

When painting using Auto-Normalize or Lock Relative with some
groups locked, the locked weights may not add up precisely to
1 because of precision limitations, which results in creating
nonzero weights close to FLT_EPSILON. With Lock Relative display
mode this is very obvious and annoying (random red points amid
black or blue), so add an epsilon check to consider less than
1e-6 unlocked weight to be the same as 0.

In addition, in cases when no weight can be painted due to locks,
don't create vertex group entries at all if they don't exist yet.
Also, don't run Auto Normalize when not painting a deform group.

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

===

M   source/blender/blenkernel/BKE_deform.h
M   source/blender/blenkernel/intern/deform.c
M   source/blender/editors/sculpt_paint/paint_vertex.c

===

diff --git a/source/blender/blenkernel/BKE_deform.h 
b/source/blender/blenkernel/BKE_deform.h
index 2f3ec69418f..5d581b695af 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -80,6 +80,9 @@ float BKE_defvert_multipaint_collective_weight(const struct 
MDeformVert *dv,
int defbase_tot_sel,
bool is_normalized);
 
+/* This much unlocked weight is considered equivalent to none. */
+#define VERTEX_WEIGHT_EPSILON 1e-6f
+
 float BKE_defvert_calc_lock_relative_weight(float weight,
 float locked_weight,
 float unlocked_weight);
diff --git a/source/blender/blenkernel/intern/deform.c 
b/source/blender/blenkernel/intern/deform.c
index f7cf4faf7cb..23a23013d3d 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -899,7 +899,7 @@ float BKE_defvert_calc_lock_relative_weight(float weight,
   }
 
   /* handle division by zero */
-  if (locked_weight >= 1.0f) {
+  if (locked_weight >= 1.0f - VERTEX_WEIGHT_EPSILON) {
 if (weight != 0.0f) {
   return 1.0f;
 }
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index 9e9e0f441f7..0cbc7600aa5 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -415,7 +415,12 @@ static float wpaint_undo_lock_relative(
   /* In auto-normalize mode, or when there is no unlocked weight,
* compute based on locked weight. */
   if (auto_normalize || free_weight <= 0.0f) {
-weight *= (1.0f - locked_weight);
+if (locked_weight < 1.0f - VERTEX_WEIGHT_EPSILON) {
+  weight *= (1.0f - locked_weight);
+}
+else {
+  weight = 0;
+}
   }
   else {
 /* When dealing with full unlocked weight, don't paint, as it is always 
displayed as 1. */
@@ -518,7 +523,7 @@ static bool 
do_weight_paint_normalize_all_locked(MDeformVert *dvert,
 return false;
   }
 
-  if (lock_weight >= 1.0f) {
+  if (lock_weight >= 1.0f - VERTEX_WEIGHT_EPSILON) {
 /* locked groups make it impossible to fully normalize,
  * zero out what we can and return false */
 for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) {
@@ -779,7 +784,25 @@ static void do_weight_paint_vertex_single(
 index_mirr = vgroup_mirr = -1;
   }
 
-  if (wp->flag & VP_FLAG_VGROUP_RESTRICT) {
+  /* Check if painting should create new deform weight entries. */
+  bool restrict_to_existing = (wp->flag & VP_FLAG_VGROUP_RESTRICT) != 0;
+
+  if (wpi->do_lock_relative || wpi->do_auto_normalize) {
+/* Without do_lock_relative only dw_rel_locked is reliable, while 
dw_rel_free may be fake 0. */
+dw_rel_free = BKE_defvert_total_selected_weight(dv, wpi->defbase_tot, 
wpi->vgroup_unlocked);
+dw_rel_locked = BKE_defvert_total_selected_weight(dv, wpi->defbase_tot, 
wpi->vgroup_locked);
+CLAMP(dw_rel_locked, 0.0f, 1.0f);
+
+/* Do not create entries if there is not enough free weight to paint.
+ * This logic is the same as in wpaint_undo_lock_relative and 
auto-normalize. */
+if (wpi->do_auto_normalize || dw_rel_free <= 0.0f) {
+  if (dw_rel_locked >= 1.0f - VERTEX_WEIGHT_EPSILON) {
+restrict_to_existing = true;
+  }
+}
+  }
+
+  if (restrict_to_existing) {
 dw = BKE_defvert_find_index(dv, wpi->active.index);
   }
   else {
@@ -827,10 +850,6 @@ static void do_weight_paint_vertex_single(
 
   /* Handle weight caught up in locked defgroups for Lock Relative. */
   if (wpi->do_lock_relative) {
-dw_r

[Bf-blender-cvs] [eb566b615f7] temp-angavrilov-constraints: Cloth: add a vertex group setting to exclude from object collision.

2021-01-08 Thread Alexander Gavrilov
Commit: eb566b615f72403cafcf059cc366ecc01da3316b
Author: Alexander Gavrilov
Date:   Fri Jan 8 13:02:40 2021 +0300
Branches: temp-angavrilov-constraints
https://developer.blender.org/rBeb566b615f72403cafcf059cc366ecc01da3316b

Cloth: add a vertex group setting to exclude from object collision.

This can be useful as a workaround on the boundary with the pinned
vertices in some situations among other things, and completely copies
the existing design of the self collision vertex group setting.

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

===

M   release/scripts/startup/bl_ui/properties_physics_cloth.py
M   source/blender/blenkernel/BKE_cloth.h
M   source/blender/blenkernel/intern/cloth.c
M   source/blender/blenkernel/intern/collision.c
M   source/blender/makesdna/DNA_cloth_types.h
M   source/blender/makesdna/DNA_modifier_defaults.h
M   source/blender/makesrna/intern/rna_cloth.c

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py 
b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 79089b7cb89..3a5ca1e04f5 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -345,6 +345,7 @@ class PHYSICS_PT_cloth_object_collision(PhysicButtonsPanel, 
Panel):
 
 cloth = context.cloth.collision_settings
 md = context.cloth
+ob = context.object
 
 layout.active = cloth.use_collision and cloth_panel_enabled(md)
 
@@ -356,6 +357,9 @@ class PHYSICS_PT_cloth_object_collision(PhysicButtonsPanel, 
Panel):
 col = flow.column()
 col.prop(cloth, "impulse_clamp")
 
+col = flow.column()
+col.prop_search(cloth, "vertex_group_object_collisions", ob, 
"vertex_groups", text="Vertex Group")
+
 col = flow.column()
 col.prop(cloth, "collection")
 
diff --git a/source/blender/blenkernel/BKE_cloth.h 
b/source/blender/blenkernel/BKE_cloth.h
index 20e2122a195..e9267955d70 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -50,6 +50,7 @@ struct Scene;
 typedef enum eClothVertexFlag {
   CLOTH_VERT_FLAG_PINNED = (1 << 0),
   CLOTH_VERT_FLAG_NOSELFCOLL = (1 << 1), /* vertex NOT used for self 
collisions */
+  CLOTH_VERT_FLAG_NOOBJCOLL = (1 << 2),  /* vertex NOT used for object 
collisions */
 } eClothVertexFlag;
 
 typedef struct ClothHairData {
diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index e9df562a15f..3a16cb5e5d2 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -644,8 +644,8 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, 
Mesh *mesh)
   verts->shrink_factor = 0.0f;
 
   /* Reset vertex flags */
-  verts->flags &= ~CLOTH_VERT_FLAG_PINNED;
-  verts->flags &= ~CLOTH_VERT_FLAG_NOSELFCOLL;
+  verts->flags &= ~(CLOTH_VERT_FLAG_PINNED | CLOTH_VERT_FLAG_NOSELFCOLL |
+CLOTH_VERT_FLAG_NOOBJCOLL);
 
   MDeformVert *dvert = CustomData_get(&mesh->vdata, i, CD_MDEFORMVERT);
   if (dvert) {
@@ -682,6 +682,12 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, 
Mesh *mesh)
 }
   }
 
+  if (dvert->dw[j].def_nr == (clmd->coll_parms->vgroup_objcol - 1)) {
+if (dvert->dw[j].weight > 0.0f) {
+  verts->flags |= CLOTH_VERT_FLAG_NOOBJCOLL;
+}
+  }
+
   if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink - 1)) {
 /* Used for linear interpolation between min and max
  * shrink factor based on weight. */
diff --git a/source/blender/blenkernel/intern/collision.c 
b/source/blender/blenkernel/intern/collision.c
index 068216e3159..b321a388385 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1012,7 +1012,7 @@ static bool cloth_bvh_collision_is_active(const 
ClothModifierData *UNUSED(clmd),
   const int flags_a = verts[tri_a->tri[0]].flags & verts[tri_a->tri[1]].flags &
   verts[tri_a->tri[2]].flags;
 
-  if (flags_a & CLOTH_VERT_FLAG_PINNED) {
+  if (flags_a & (CLOTH_VERT_FLAG_PINNED | CLOTH_VERT_FLAG_NOOBJCOLL)) {
 return false;
   }
 
diff --git a/source/blender/makesdna/DNA_cloth_types.h 
b/source/blender/makesdna/DNA_cloth_types.h
index 11993d95c2c..467174c4f32 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -240,9 +240,11 @@ typedef struct ClothCollSettings {
   char _pad[4];
   /** Only use colliders from this group of objects. */
   struct Collection *group;
-  /** Vgroup to paint which vertices are used for self collisions. */
+  /** Vgroup to paint which vertices are not used for self collisions. */
   short vgroup_selfcol;

[Bf-blender-cvs] [e3ae7d1f2f4] master: Fix T83942: improve error checking when trying to render high resolution volume

2021-01-08 Thread Jacques Lucke
Commit: e3ae7d1f2f4592a0cc9032e2056b2236a39795f8
Author: Jacques Lucke
Date:   Fri Jan 8 12:14:12 2021 +0100
Branches: master
https://developer.blender.org/rBe3ae7d1f2f4592a0cc9032e2056b2236a39795f8

Fix T83942: improve error checking when trying to render high resolution volume

Reviewers: fclem

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

===

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

===

diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c 
b/source/blender/draw/intern/draw_cache_impl_volume.c
index 1119e0458a5..7244dfd12c3 100644
--- a/source/blender/draw/intern/draw_cache_impl_volume.c
+++ b/source/blender/draw/intern/draw_cache_impl_volume.c
@@ -330,9 +330,17 @@ static DRWVolumeGrid *volume_grid_cache_get(Volume *volume,
 format,
 GPU_DATA_FLOAT,
 dense_grid.voxels);
-GPU_texture_swizzle_set(cache_grid->texture, (channels == 3) ? "rgb1" : 
"rrr1");
-GPU_texture_wrap_mode(cache_grid->texture, false, false);
-BKE_volume_dense_float_grid_clear(&dense_grid);
+/* The texture can be null if the resolution along one axis is larger than
+ * GL_MAX_3D_TEXTURE_SIZE. */
+if (cache_grid->texture != NULL) {
+  GPU_texture_swizzle_set(cache_grid->texture, (channels == 3) ? "rgb1" : 
"rrr1");
+  GPU_texture_wrap_mode(cache_grid->texture, false, false);
+  BKE_volume_dense_float_grid_clear(&dense_grid);
+}
+else {
+  MEM_freeN(dense_grid.voxels);
+  printf("Error: Could not allocate 3D texture for volume.\n");
+}
   }
 
   /* Free grid from memory if it wasn't previously loaded. */

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


[Bf-blender-cvs] [c889ec916cf] master: Cleanup: clang format

2021-01-08 Thread Philipp Oeser
Commit: c889ec916cf857b5e38f19e601f3d8d4f0e18a56
Author: Philipp Oeser
Date:   Fri Jan 8 11:54:53 2021 +0100
Branches: master
https://developer.blender.org/rBc889ec916cf857b5e38f19e601f3d8d4f0e18a56

Cleanup: clang format

===

M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/sequencer/intern/sequencer.c

===

diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 49448ad0d25..88953e8fddf 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5900,8 +5900,7 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna)
   prop = RNA_def_property(srna, "ngon_method", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "ngon_method");
   RNA_def_property_enum_items(prop, 
rna_enum_modifier_triangulate_ngon_method_items);
-  RNA_def_property_ui_text(
-  prop, "N-gon Method", "Method for splitting the n-gons into triangles");
+  RNA_def_property_ui_text(prop, "N-gon Method", "Method for splitting the 
n-gons into triangles");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
   prop = RNA_def_property(srna, "min_vertices", PROP_INT, PROP_UNSIGNED);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 1e72cfe533f..7c37482e3df 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -8433,8 +8433,7 @@ static void def_geo_triangulate(StructRNA *srna)
   RNA_def_property_enum_sdna(prop, NULL, "custom2");
   RNA_def_property_enum_items(prop, 
rna_node_geometry_triangulate_ngon_method_items);
   RNA_def_property_enum_default(prop, GEO_NODE_TRIANGULATE_NGON_BEAUTY);
-  RNA_def_property_ui_text(
-  prop, "N-gon Method", "Method for splitting the n-gons into triangles");
+  RNA_def_property_ui_text(prop, "N-gon Method", "Method for splitting the 
n-gons into triangles");
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
diff --git a/source/blender/sequencer/intern/sequencer.c 
b/source/blender/sequencer/intern/sequencer.c
index 4db3d930e83..4a0e4f1d9ad 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -246,7 +246,7 @@ Editing *SEQ_editing_ensure(Scene *scene)
 ed->seqbasep = &ed->seqbase;
 ed->cache = NULL;
 ed->cache_flag = SEQ_CACHE_STORE_FINAL_OUT;
-ed->cache_flag |= SEQ_CACHE_STORE_RAW ;
+ed->cache_flag |= SEQ_CACHE_STORE_RAW;
   }
 
   return scene->ed;

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


[Bf-blender-cvs] [c44a17ec4b2] master: Fix T84475: Outliner missing update when adding IDs to main via RNA

2021-01-08 Thread Philipp Oeser
Commit: c44a17ec4b247b0af5e4c58bbcfca6dece51baf1
Author: Philipp Oeser
Date:   Thu Jan 7 14:06:43 2021 +0100
Branches: master
https://developer.blender.org/rBc44a17ec4b247b0af5e4c58bbcfca6dece51baf1

Fix T84475: Outliner missing update when adding IDs to main via RNA

Was reported for meshes, but was true for any type.
Now add appropriate notifier to refresh the Outliner.

Maniphest Tasks: T84475

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

===

M   source/blender/editors/space_outliner/space_outliner.c
M   source/blender/makesrna/intern/rna_main_api.c

===

diff --git a/source/blender/editors/space_outliner/space_outliner.c 
b/source/blender/editors/space_outliner/space_outliner.c
index 57a063a01ca..f207b6193be 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -196,7 +196,7 @@ static void outliner_main_region_listener(wmWindow 
*UNUSED(win),
   }
   break;
 case NC_ID:
-  if (wmn->action == NA_RENAME) {
+  if (ELEM(wmn->action, NA_RENAME, NA_ADDED)) {
 ED_region_tag_redraw(region);
   }
   break;
diff --git a/source/blender/makesrna/intern/rna_main_api.c 
b/source/blender/makesrna/intern/rna_main_api.c
index 564acaec90a..5170d598ab5 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -172,6 +172,9 @@ static Camera *rna_Main_cameras_new(Main *bmain, const char 
*name)
 
   ID *id = BKE_camera_add(bmain, safe_name);
   id_us_min(id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return (Camera *)id;
 }
 
@@ -180,7 +183,11 @@ static Scene *rna_Main_scenes_new(Main *bmain, const char 
*name)
   char safe_name[MAX_ID_NAME - 2];
   rna_idname_validate(name, safe_name);
 
-  return BKE_scene_add(bmain, safe_name);
+  Scene *scene = BKE_scene_add(bmain, safe_name);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
+  return scene;
 }
 static void rna_Main_scenes_remove(
 Main *bmain, bContext *C, ReportList *reports, PointerRNA *scene_ptr, bool 
do_unlink)
@@ -249,6 +256,8 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList 
*reports, const char
   ob->data = data;
   BKE_object_materials_test(bmain, ob, ob->data);
 
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return ob;
 }
 
@@ -259,6 +268,9 @@ static Material *rna_Main_materials_new(Main *bmain, const 
char *name)
 
   ID *id = (ID *)BKE_material_add(bmain, safe_name);
   id_us_min(id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return (Material *)id;
 }
 
@@ -309,6 +321,9 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char 
*name)
 
   Mesh *me = BKE_mesh_add(bmain, safe_name);
   id_us_min(&me->id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return me;
 }
 
@@ -331,7 +346,12 @@ static Mesh *rna_Main_meshes_new_from_object(Main *bmain,
   return NULL;
   }
 
-  return BKE_mesh_new_from_object_to_bmain(bmain, depsgraph, object, 
preserve_all_data_layers);
+  Mesh *mesh = BKE_mesh_new_from_object_to_bmain(
+  bmain, depsgraph, object, preserve_all_data_layers);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
+  return mesh;
 }
 
 static Light *rna_Main_lights_new(Main *bmain, const char *name, int type)
@@ -342,6 +362,9 @@ static Light *rna_Main_lights_new(Main *bmain, const char 
*name, int type)
   Light *lamp = BKE_light_add(bmain, safe_name);
   lamp->type = type;
   id_us_min(&lamp->id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return lamp;
 }
 
@@ -371,6 +394,9 @@ static Image *rna_Main_images_new(Main *bmain,
  is_data,
  tiled);
   id_us_min(&image->id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return image;
 }
 static Image *rna_Main_images_load(Main *bmain,
@@ -397,6 +423,9 @@ static Image *rna_Main_images_load(Main *bmain,
   }
 
   id_us_min((ID *)ima);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return ima;
 }
 
@@ -407,6 +436,9 @@ static Lattice *rna_Main_lattices_new(Main *bmain, const 
char *name)
 
   Lattice *lt = BKE_lattice_add(bmain, safe_name);
   id_us_min(<->id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return lt;
 }
 
@@ -417,6 +449,9 @@ static Curve *rna_Main_curves_new(Main *bmain, const char 
*name, int type)
 
   Curve *cu = BKE_curve_add(bmain, safe_name, type);
   id_us_min(&cu->id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return cu;
 }
 
@@ -427,6 +462,9 @@ static MetaBall *rna_Main_metaballs_new(Main *bmain, const 
char *name)
 
   MetaBall *mb = BKE_mball_add(bmain, safe_name);
   id_us_min(&mb->id);
+
+  WM_main_add_notifier(NC_ID | NA_ADDED, NULL);
+
   return mb;
 }
 
@@ -452,6 +490,9 @@ static VFont *rna_Main_fonts_load(Main *bmain,
 filepath,
 

[Bf-blender-cvs] [1698678231d] master: GPU: Mark AMD Polaris 20.11+ drivers with limited support.

2021-01-08 Thread Jeroen Bakker
Commit: 1698678231d20b57ed463d89270913599548ffcb
Author: Jeroen Bakker
Date:   Fri Jan 8 11:43:32 2021 +0100
Branches: master
https://developer.blender.org/rB1698678231d20b57ed463d89270913599548ffcb

GPU: Mark AMD Polaris 20.11+ drivers with limited support.

The issue does not render wireframes correctly.

===

M   source/blender/gpu/opengl/gl_backend.cc

===

diff --git a/source/blender/gpu/opengl/gl_backend.cc 
b/source/blender/gpu/opengl/gl_backend.cc
index 140425b349a..5c43a8990d7 100644
--- a/source/blender/gpu/opengl/gl_backend.cc
+++ b/source/blender/gpu/opengl/gl_backend.cc
@@ -34,6 +34,28 @@
 
 namespace blender::gpu {
 
+/* See T82856: AMD drivers since 20.11 running on a polaris architecture 
doesn't support the
+ * `GL_INT_2_10_10_10_REV` data type correctly. This data type is used to pack 
normals and flags.
+ * The work around uses `GPU_RGBA16I` but that is only possible for loop 
normals.
+ *
+ * Vertex and Face normals would still render resulting in undefined behavior 
during selection and
+ * rendering. */
+static bool is_faulty_T82856_platform(const char *version, const char 
*renderer)
+{
+  /* On Linux the driver does not report its version. Test the OpenGL version 
in stead. */
+  if (strstr(version, "4.5.14756") || strstr(version, "4.5.14757")) {
+if (strstr(renderer, " RX 460 ") || strstr(renderer, " RX 470 ") ||
+strstr(renderer, " RX 480 ") || strstr(renderer, " RX 490 ") ||
+strstr(renderer, " RX 560 ") || strstr(renderer, " RX 560X ") ||
+strstr(renderer, " RX 570 ") || strstr(renderer, " RX 580 ") ||
+strstr(renderer, " RX 590 ") || strstr(renderer, " RX550/550 ") ||
+strstr(renderer, " (TM) 520  ") || strstr(renderer, " (TM) 530  ") ||
+strstr(renderer, " R5 ") || strstr(renderer, " R7 ") || 
strstr(renderer, " R9 ")) {
+  return true;
+}
+  }
+  return false;
+}
 /*  */
 /** \name Platform
  * \{ */
@@ -137,6 +159,11 @@ void GLBackend::platform_init()
 GPG.support_level = GPU_SUPPORT_LEVEL_LIMITED;
   }
 }
+if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) {
+  if (is_faulty_T82856_platform(version, renderer)) {
+GPG.support_level = GPU_SUPPORT_LEVEL_LIMITED;
+  }
+}
   }
   GPG.create_key(GPG.support_level, vendor, renderer, version);
   GPG.create_gpu_name(vendor, renderer, version);
@@ -272,20 +299,10 @@ static void detect_workarounds()
 GCaps.broken_amd_driver = true;
   }
   /* See T82856: AMD drivers since 20.11 running on a polaris architecture 
doesn't support the
-   * `GL_INT_2_10_10_10_REV` data type. This data type is used to pack 
normals. The work around
-   * uses `GPU_RGBA16I`.*/
+   * `GL_INT_2_10_10_10_REV` data type. */
   if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) {
-/* On Linux the driver does not report its version. Test the OpenGL 
version in stead. */
-if (strstr(version, "4.5.14756") || strstr(version, "4.5.14757")) {
-  if (strstr(renderer, " RX 460 ") || strstr(renderer, " RX 470 ") ||
-  strstr(renderer, " RX 480 ") || strstr(renderer, " RX 490 ") ||
-  strstr(renderer, " RX 560 ") || strstr(renderer, " RX 560X ") ||
-  strstr(renderer, " RX 570 ") || strstr(renderer, " RX 580 ") ||
-  strstr(renderer, " RX 590 ") || strstr(renderer, " RX550/550 ") ||
-  strstr(renderer, " (TM) 520  ") || strstr(renderer, " (TM) 530  ") ||
-  strstr(renderer, " R5 ") || strstr(renderer, " R7 ") || 
strstr(renderer, " R9 ")) {
-GCaps.use_hq_normals_workaround = true;
-  }
+if (is_faulty_T82856_platform(version, renderer)) {
+  GCaps.use_hq_normals_workaround = true;
 }
   }
   /* There is an issue with the #glBlitFramebuffer on MacOS with radeon pro 
graphics.
@@ -378,7 +395,7 @@ static void detect_workarounds()
   if (GLContext::debug_layer_support == false) {
 GLContext::debug_layer_workaround = true;
   }
-}
+}  // namespace blender::gpu
 
 /** Internal capabilities. */
 GLint GLContext::max_cubemap_size = 0;

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


[Bf-blender-cvs] [03f1d8acab5] master: Use the term "N-gon" instead of "Polygon" for triangulation method

2021-01-08 Thread Philipp Oeser
Commit: 03f1d8acab5b96321935b03f7a402455d2a91fc8
Author: Philipp Oeser
Date:   Wed Jan 6 16:19:22 2021 +0100
Branches: master
https://developer.blender.org/rB03f1d8acab5b96321935b03f7a402455d2a91fc8

Use the term "N-gon" instead of "Polygon" for triangulation method

This was reported for the Triangulate geometry node, but was also true
for the triangulate modifier and in exporters.

Note the modifier was introduced with "Ngon Method" in rBa7b44c82e5b9 but
was renamed to "Polygon Method" in rBf4762eb12ba5.

Since quads are also polygons (and quads have their own method), the
term "N-gon" is more appropriate here and is also described in the
glossary https://docs.blender.org/manual/en/2.92/glossary/
index.html#term-N-gon

Docs have been updated in rBM7539 (partially - the method would also
have to be renamed once this patch lands).

Note this also fixes the wrong enum used for the alembic exporter.

Fixes T83907

Maniphest Tasks: T83907

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

===

M   source/blender/editors/io/io_alembic.c
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/makesrna/intern/rna_scene_api.c

===

diff --git a/source/blender/editors/io/io_alembic.c 
b/source/blender/editors/io/io_alembic.c
index 4d8e3c72c74..636e6688971 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -439,10 +439,10 @@ void WM_OT_alembic_export(wmOperatorType *ot)
 
   RNA_def_enum(ot->srna,
"ngon_method",
-   rna_enum_modifier_triangulate_quad_method_items,
+   rna_enum_modifier_triangulate_ngon_method_items,
MOD_TRIANGULATE_NGON_BEAUTY,
-   "Polygon Method",
-   "Method for splitting the polygons into triangles");
+   "N-gon Method",
+   "Method for splitting the n-gons into triangles");
 
   RNA_def_boolean(ot->srna,
   "export_hair",
diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index 26efcf88082..84f4e35cb0c 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -5340,8 +5340,8 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot)
"ngon_method",
rna_enum_modifier_triangulate_ngon_method_items,
MOD_TRIANGULATE_NGON_BEAUTY,
-   "Polygon Method",
-   "Method for splitting the polygons into triangles");
+   "N-gon Method",
+   "Method for splitting the n-gons into triangles");
 }
 
 /** \} */
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index 38c222d9a3b..49448ad0d25 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5901,7 +5901,7 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna)
   RNA_def_property_enum_sdna(prop, NULL, "ngon_method");
   RNA_def_property_enum_items(prop, 
rna_enum_modifier_triangulate_ngon_method_items);
   RNA_def_property_ui_text(
-  prop, "Polygon Method", "Method for splitting the polygons into 
triangles");
+  prop, "N-gon Method", "Method for splitting the n-gons into triangles");
   RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
   prop = RNA_def_property(srna, "min_vertices", PROP_INT, PROP_UNSIGNED);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 8072d77059a..1e72cfe533f 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -8434,7 +8434,7 @@ static void def_geo_triangulate(StructRNA *srna)
   RNA_def_property_enum_items(prop, 
rna_node_geometry_triangulate_ngon_method_items);
   RNA_def_property_enum_default(prop, GEO_NODE_TRIANGULATE_NGON_BEAUTY);
   RNA_def_property_ui_text(
-  prop, "Polygon Method", "Method for splitting the polygons into 
triangles");
+  prop, "N-gon Method", "Method for splitting the n-gons into triangles");
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
diff --git a/source/blender/makesrna/intern/rna_scene_api.c 
b/source/blender/makesrna/intern/rna_scene_api.c
index 94b435b5735..c2089004da2 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -420,10 +420,10 @@ void RNA_api_scene(StructRNA *srna)
"Method for splitting the quads into triangles");
   RNA_def_enum(func,
"ngon_method",
-   rna_enum_modifier_triangulate_quad_method_items,
+   rna_enum_modifier_triangulate_ngon_m

[Bf-blender-cvs] [4a0b8c9427b] master: Cloth: completely exclude fully pinned triangles from collision.

2021-01-08 Thread Alexander Gavrilov
Commit: 4a0b8c9427b57422f47c125a494c4631a6c0bfd1
Author: Alexander Gavrilov
Date:   Wed Jan 6 14:48:42 2021 +0300
Branches: master
https://developer.blender.org/rB4a0b8c9427b57422f47c125a494c4631a6c0bfd1

Cloth: completely exclude fully pinned triangles from collision.

Currently such triangles are effectively already excluded, because
the calculated forces are not applied to pinned vertices. However
these forces are still being computed, which is inefficient.

This adds an early check for triangles where all vertices are
pinned during BVH overlap detection, which significantly speeds
up certain use cases with big fully pinned areas that happen to
overlap a collider. In case of self collision both triangles must
be fully pinned to exclude safely, because the computation is
symmetric and handles two triangles at the same time.

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

===

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

===

diff --git a/source/blender/blenkernel/intern/collision.c 
b/source/blender/blenkernel/intern/collision.c
index 72525272254..068216e3159 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1002,6 +1002,23 @@ static int 
cloth_selfcollision_response_static(ClothModifierData *clmd,
 #  pragma GCC diagnostic pop
 #endif
 
+static bool cloth_bvh_collision_is_active(const ClothModifierData 
*UNUSED(clmd),
+  const Cloth *cloth,
+  const MVertTri *tri_a)
+{
+  const ClothVertex *verts = cloth->verts;
+
+  /* Fully pinned triangles don't need collision processing. */
+  const int flags_a = verts[tri_a->tri[0]].flags & verts[tri_a->tri[1]].flags &
+  verts[tri_a->tri[2]].flags;
+
+  if (flags_a & CLOTH_VERT_FLAG_PINNED) {
+return false;
+  }
+
+  return true;
+}
+
 static void cloth_collision(void *__restrict userdata,
 const int index,
 const TaskParallelTLS *__restrict UNUSED(tls))
@@ -1059,13 +1076,31 @@ static void cloth_collision(void *__restrict userdata,
   }
 }
 
-static bool cloth_bvh_selfcollision_is_active(const Cloth *cloth,
+static bool cloth_bvh_selfcollision_is_active(const ClothModifierData *clmd,
+  const Cloth *cloth,
   const MVertTri *tri_a,
-  const MVertTri *tri_b,
-  bool sewing_active)
+  const MVertTri *tri_b)
 {
   const ClothVertex *verts = cloth->verts;
+
+  /* Skip when either triangle is excluded. */
+  const int flags_a = verts[tri_a->tri[0]].flags & verts[tri_a->tri[1]].flags &
+  verts[tri_a->tri[2]].flags;
+  const int flags_b = verts[tri_b->tri[0]].flags & verts[tri_b->tri[1]].flags &
+  verts[tri_b->tri[2]].flags;
+
+  if ((flags_a | flags_b) & CLOTH_VERT_FLAG_NOSELFCOLL) {
+return false;
+  }
+
+  /* Skip when both triangles are pinned. */
+  if ((flags_a & flags_b) & CLOTH_VERT_FLAG_PINNED) {
+return false;
+  }
+
   /* Ignore overlap of neighboring triangles and triangles connected by a 
sewing edge. */
+  bool sewing_active = (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW);
+
   for (uint i = 0; i < 3; i++) {
 for (uint j = 0; j < 3; j++) {
   if (tri_a->tri[i] == tri_b->tri[j]) {
@@ -1080,12 +1115,6 @@ static bool cloth_bvh_selfcollision_is_active(const 
Cloth *cloth,
 }
   }
 
-  if (((verts[tri_a->tri[0]].flags & verts[tri_a->tri[1]].flags & 
verts[tri_a->tri[2]].flags) |
-   (verts[tri_b->tri[0]].flags & verts[tri_b->tri[1]].flags & 
verts[tri_b->tri[2]].flags)) &
-  CLOTH_VERT_FLAG_NOSELFCOLL) {
-return false;
-  }
-
   return true;
 }
 
@@ -1106,10 +1135,7 @@ static void cloth_selfcollision(void *__restrict 
userdata,
   tri_a = &clmd->clothObject->tri[data->overlap[index].indexA];
   tri_b = &clmd->clothObject->tri[data->overlap[index].indexB];
 
-#ifdef DEBUG
-  bool sewing_active = (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW);
-  BLI_assert(cloth_bvh_selfcollision_is_active(clmd->clothObject, tri_a, 
tri_b, sewing_active));
-#endif
+  BLI_assert(cloth_bvh_selfcollision_is_active(clmd, clmd->clothObject, tri_a, 
tri_b));
 
   /* Compute distance and normal. */
   distance = compute_collision_point_tri_tri(verts1[tri_a->tri[0]].tx,
@@ -1508,6 +1534,18 @@ static int 
cloth_bvh_selfcollisions_resolve(ClothModifierData *clmd,
   return ret;
 }
 
+static bool cloth_bvh_obj_overlap_cb(void *userdata,
+ int index_a,
+ int UNUSED(index_b),
+ int UNUSED(thread))
+{
+  ClothModifier

[Bf-blender-cvs] [8877e294dfd] master: Surface Deform: the Strength setting is not bind-specific.

2021-01-08 Thread Alexander Gavrilov
Commit: 8877e294dfd680f0ad9c1598b6462dd726cc46f3
Author: Alexander Gavrilov
Date:   Fri Jan 8 12:22:11 2021 +0300
Branches: master
https://developer.blender.org/rB8877e294dfd680f0ad9c1598b6462dd726cc46f3

Surface Deform: the Strength setting is not bind-specific.

It is used during evaluation so it shouldn't be greyed out in the UI.

Ref D10040

===

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

===

diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c 
b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 5eed2964e70..0fad78683eb 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1459,9 +1459,9 @@ static void panel_draw(const bContext *UNUSED(C), Panel 
*panel)
   col = uiLayoutColumn(layout, false);
   uiLayoutSetActive(col, !is_bound);
   uiItemR(col, ptr, "target", 0, NULL, ICON_NONE);
-
   uiItemR(col, ptr, "falloff", 0, NULL, ICON_NONE);
-  uiItemR(col, ptr, "strength", 0, NULL, ICON_NONE);
+
+  uiItemR(layout, ptr, "strength", 0, NULL, ICON_NONE);
 
   modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", 
"invert_vertex_group", NULL);

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


[Bf-blender-cvs] [662b7c3edfc] master: Surface Deform: optimize memory allocation in the evaluation code.

2021-01-08 Thread Alexander Gavrilov
Commit: 662b7c3edfcd64ca59a6ba2999eac583fc14cbaa
Author: Alexander Gavrilov
Date:   Thu Jan 7 20:31:06 2021 +0300
Branches: master
https://developer.blender.org/rB662b7c3edfcd64ca59a6ba2999eac583fc14cbaa

Surface Deform: optimize memory allocation in the evaluation code.

Using malloc to allocate a temporary array for each vertex,
which most commonly contains just 4 elements, is not efficient.
Checking the mode with a switch is also better.

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

===

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

===

diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c 
b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 64fad1b370b..5eed2964e70 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -20,6 +20,7 @@
  * \ingroup modifiers
  */
 
+#include "BLI_alloca.h"
 #include "BLI_math.h"
 #include "BLI_math_geom.h"
 #include "BLI_task.h"
@@ -1218,7 +1219,16 @@ static void deformVert(void *__restrict userdata,
   for (int j = 0; j < num_binds; j++) {
 max_verts = MAX2(max_verts, sdbind[j].numverts);
   }
-  float(*coords_buffer)[3] = MEM_malloc_arrayN(max_verts, 
sizeof(*coords_buffer), __func__);
+
+  const bool big_buffer = max_verts > 256;
+  float(*coords_buffer)[3];
+
+  if (UNLIKELY(big_buffer)) {
+coords_buffer = MEM_malloc_arrayN(max_verts, sizeof(*coords_buffer), 
__func__);
+  }
+  else {
+coords_buffer = BLI_array_alloca(coords_buffer, max_verts);
+  }
 
   for (int j = 0; j < num_binds; j++, sdbind++) {
 for (int k = 0; k < sdbind->numverts; k++) {
@@ -1228,28 +1238,32 @@ static void deformVert(void *__restrict userdata,
 normal_poly_v3(norm, coords_buffer, sdbind->numverts);
 zero_v3(temp);
 
-/* -- looptri mode -- */
-if (sdbind->mode == MOD_SDEF_MODE_LOOPTRI) {
-  madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[0]], 
sdbind->vert_weights[0]);
-  madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[1]], 
sdbind->vert_weights[1]);
-  madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[2]], 
sdbind->vert_weights[2]);
-}
-else {
+switch (sdbind->mode) {
+  /* -- looptri mode -- */
+  case MOD_SDEF_MODE_LOOPTRI: {
+madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[0]], 
sdbind->vert_weights[0]);
+madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[1]], 
sdbind->vert_weights[1]);
+madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[2]], 
sdbind->vert_weights[2]);
+break;
+  }
+
   /* -- ngon mode -- */
-  if (sdbind->mode == MOD_SDEF_MODE_NGON) {
+  case MOD_SDEF_MODE_NGON: {
 for (int k = 0; k < sdbind->numverts; k++) {
   madd_v3_v3fl(temp, coords_buffer[k], sdbind->vert_weights[k]);
 }
+break;
   }
 
   /* -- centroid mode -- */
-  else if (sdbind->mode == MOD_SDEF_MODE_CENTROID) {
+  case MOD_SDEF_MODE_CENTROID: {
 float cent[3];
 mid_v3_v3_array(cent, coords_buffer, sdbind->numverts);
 
 madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[0]], 
sdbind->vert_weights[0]);
 madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[1]], 
sdbind->vert_weights[1]);
 madd_v3_v3fl(temp, cent, sdbind->vert_weights[2]);
+break;
   }
 }
 
@@ -1263,7 +1277,10 @@ static void deformVert(void *__restrict userdata,
 
   /* Add the offset to start coord multiplied by the strength and weight 
values. */
   madd_v3_v3fl(vertexCos, offset, data->strength * weight);
-  MEM_freeN(coords_buffer);
+
+  if (UNLIKELY(big_buffer)) {
+MEM_freeN(coords_buffer);
+  }
 }
 
 static void surfacedeformModifier_do(ModifierData *md,

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


[Bf-blender-cvs] [ceaed47bf9a] master: GPU: Enable HQ normal work around on Linux.

2021-01-08 Thread Jeroen Bakker
Commit: ceaed47bf9a31acdce8cd8bdd436c55c74605b27
Author: Jeroen Bakker
Date:   Fri Jan 8 10:23:20 2021 +0100
Branches: master
https://developer.blender.org/rBceaed47bf9a31acdce8cd8bdd436c55c74605b27

GPU: Enable HQ normal work around on Linux.

Linux does not report the driver version. It does report the OpenGL
version. This change will check the OpenGL version to enable the HQ
normal work around.

===

M   source/blender/gpu/opengl/gl_backend.cc

===

diff --git a/source/blender/gpu/opengl/gl_backend.cc 
b/source/blender/gpu/opengl/gl_backend.cc
index d9bc3a78dd8..140425b349a 100644
--- a/source/blender/gpu/opengl/gl_backend.cc
+++ b/source/blender/gpu/opengl/gl_backend.cc
@@ -275,8 +275,8 @@ static void detect_workarounds()
* `GL_INT_2_10_10_10_REV` data type. This data type is used to pack 
normals. The work around
* uses `GPU_RGBA16I`.*/
   if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) {
-if (strstr(version, " 20.11.2") || strstr(version, " 20.11.3 ") ||
-strstr(version, " 20.12.")) {
+/* On Linux the driver does not report its version. Test the OpenGL 
version in stead. */
+if (strstr(version, "4.5.14756") || strstr(version, "4.5.14757")) {
   if (strstr(renderer, " RX 460 ") || strstr(renderer, " RX 470 ") ||
   strstr(renderer, " RX 480 ") || strstr(renderer, " RX 490 ") ||
   strstr(renderer, " RX 560 ") || strstr(renderer, " RX 560X ") ||

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