[Bf-blender-cvs] [344c001eae6] master: Fix T81669: Vertex size in UV Editor changes using Face Dot Size in themes

2020-10-13 Thread Philipp Oeser
Commit: 344c001eae644dba41c0eaf62d741903813d6dd2
Author: Philipp Oeser
Date:   Tue Oct 13 10:21:53 2020 +0200
Branches: master
https://developer.blender.org/rB344c001eae644dba41c0eaf62d741903813d6dd2

Fix T81669: Vertex size in UV Editor changes using Face Dot Size in themes

Probably copy-paste error in rBd6525e8d133b.

Maniphest Tasks: T81669

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

===

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

===

diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c 
b/source/blender/draw/engines/overlay/overlay_edit_uv.c
index af20e85a89b..18400799d3c 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_uv.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c
@@ -174,7 +174,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
   GPUShader *sh = OVERLAY_shader_edit_uv_verts_get();
   pd->edit_uv_verts_grp = DRW_shgroup_create(sh, psl->edit_uv_verts_ps);
 
-  const float point_size = UI_GetThemeValuef(TH_FACEDOT_SIZE);
+  const float point_size = UI_GetThemeValuef(TH_VERTEX_SIZE);
 
   DRW_shgroup_uniform_block(pd->edit_uv_verts_grp, "globalsBlock", 
G_draw.block_ubo);
   DRW_shgroup_uniform_float_copy(

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


[Bf-blender-cvs] [6b21b827048] master: Fix (unreported) broken 'make override' of objects in master collection.

2020-10-13 Thread Bastien Montagne
Commit: 6b21b827048fa6e7eb5e6da007e66f2fcf248f3e
Author: Bastien Montagne
Date:   Tue Oct 13 12:26:44 2020 +0200
Branches: master
https://developer.blender.org/rB6b21b827048fa6e7eb5e6da007e66f2fcf248f3e

Fix (unreported) broken 'make override' of objects in master collection.

Master collections are not in Main list of collections, so we also need
to check the scenes.

===

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

===

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 6f9a2ee9067..780ce487550 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2306,6 +2306,11 @@ static bool 
make_override_library_object_overridable_check(Main *bmain, Object *
   return true;
 }
   }
+  LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+if (!ID_IS_LINKED(scene) && 
BKE_collection_has_object(scene->master_collection, object)) {
+  return true;
+}
+  }
   return false;
 }

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


[Bf-blender-cvs] [7d5d567dba0] master: Cleanup: Fix typo in function name.

2020-10-13 Thread Bastien Montagne
Commit: 7d5d567dba0c787f3446c5aaa1f3ffd4552a01f7
Author: Bastien Montagne
Date:   Tue Oct 13 12:17:50 2020 +0200
Branches: master
https://developer.blender.org/rB7d5d567dba0c787f3446c5aaa1f3ffd4552a01f7

Cleanup: Fix typo in function name.

===

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

===

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 80b521b2af3..6f9a2ee9067 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2297,7 +2297,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
 /** \name Make Library Override Operator
  * \{ */
 
-static bool make_override_library_ovject_overridable_check(Main *bmain, Object 
*object)
+static bool make_override_library_object_overridable_check(Main *bmain, Object 
*object)
 {
   /* An object is actually overrideable only if it is in at least one local 
collections.
* Unfortunately 'direct link' flag is not enough here. */
@@ -2323,7 +2323,7 @@ static int make_override_library_invoke(bContext *C, 
wmOperator *op, const wmEve
 
   if ((!ID_IS_LINKED(obact) && obact->instance_collection != NULL &&
ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) ||
-  make_override_library_ovject_overridable_check(bmain, obact)) {
+  make_override_library_object_overridable_check(bmain, obact)) {
 uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION);
 uiLayout *layout = UI_popup_menu_layout(pup);
 
@@ -2374,7 +2374,7 @@ static int make_override_library_exec(bContext *C, 
wmOperator *op)
 id_root = &obact->instance_collection->id;
 is_override_instancing_object = true;
   }
-  else if (!make_override_library_ovject_overridable_check(bmain, obact)) {
+  else if (!make_override_library_object_overridable_check(bmain, obact)) {
 const int i = RNA_property_enum_get(op->ptr, op->type->prop);
 const uint collection_session_uuid = *((uint *)&i);
 if (collection_session_uuid == MAIN_ID_SESSION_UUID_UNSET) {

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


[Bf-blender-cvs] [666485f38ca] master: CMake/macOS: find ZLib before setting CMAKE_PREFIX_PATH

2020-10-13 Thread Ankit Meel
Commit: 666485f38ca5abe89db042635572bd2a06fb7896
Author: Ankit Meel
Date:   Tue Oct 13 16:34:14 2020 +0530
Branches: master
https://developer.blender.org/rB666485f38ca5abe89db042635572bd2a06fb7896

CMake/macOS: find ZLib before setting CMAKE_PREFIX_PATH

https://devtalk.blender.org/t/building-blender-on-macos-fails/15756/

In some cases, CMake finds the Zlib supplied with OpenCollada
pre-compiled libraries, and not the system one.

===

M   build_files/cmake/platform/platform_apple.cmake

===

diff --git a/build_files/cmake/platform/platform_apple.cmake 
b/build_files/cmake/platform/platform_apple.cmake
index fa64016392c..020f8defdc0 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -44,6 +44,15 @@ function(print_found_status
   endif()
 endfunction()
 
+# 
+# Find system provided libraries.
+
+# Find system ZLIB, not the pre-compiled one supplied with OpenCollada.
+set(ZLIB_ROOT /usr)
+find_package(ZLIB REQUIRED)
+find_package(BZip2 REQUIRED)
+list(APPEND ZLIB_LIBRARIES ${BZIP2_LIBRARIES})
+
 if(NOT DEFINED LIBDIR)
   set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
   # Prefer lib directory paths
@@ -56,16 +65,6 @@ if(NOT EXISTS "${LIBDIR}/")
   message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'")
 endif()
 
-
-# 
-# Find system provided libraries.
-
-# Find system ZLIB, not the pre-compiled one supplied with OpenCollada.
-set(ZLIB_ROOT /usr)
-find_package(ZLIB REQUIRED)
-find_package(BZip2 REQUIRED)
-list(APPEND ZLIB_LIBRARIES ${BZIP2_LIBRARIES})
-
 # -
 # Find precompiled libraries, and avoid system or user-installed ones.

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


[Bf-blender-cvs] [3f78569c3e6] master: Fix (unreported) liboverride of an object hiding its dependencies.

2020-10-13 Thread Bastien Montagne
Commit: 3f78569c3e62ea3a184c7e0854e6e699c814cc72
Author: Bastien Montagne
Date:   Tue Oct 13 13:05:19 2020 +0200
Branches: master
https://developer.blender.org/rB3f78569c3e62ea3a184c7e0854e6e699c814cc72

Fix (unreported) liboverride of an object hiding its dependencies.

When we override a whole collection, we want to add non-instantiated
objects to a hidden sub-collection at the end of the process.

However, this makes no sense when instantiating an object, if other
dependencies objects get also overridden on the process, we should just
add them to the same collection owning the root object.

===

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

===

diff --git a/source/blender/blenkernel/intern/lib_override.c 
b/source/blender/blenkernel/intern/lib_override.c
index a989a865994..e008058ae39 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -597,32 +597,30 @@ static void lib_override_library_create_post_process(
 case ID_GR: {
   default_instantiating_collection = BKE_collection_add(
   bmain, (Collection *)id_root, "OVERRIDE_HIDDEN");
+  /* Hide the collection from viewport and render. */
+  default_instantiating_collection->flag |= 
COLLECTION_RESTRICT_VIEWPORT |
+
COLLECTION_RESTRICT_RENDER;
   break;
 }
 case ID_OB: {
-  /* Add the new container collection to one of the collections 
instantiating the
+  /* Add the other objects to one of the collections instantiating 
the
* root object, or scene's master collection if none found. */
   Object *ob_root = (Object *)id_root;
   LISTBASE_FOREACH (Collection *, collection, &bmain->collections) 
{
 if (BKE_collection_has_object(collection, ob_root) &&
 BKE_view_layer_has_collection(view_layer, collection) &&
 !ID_IS_LINKED(collection) && 
!ID_IS_OVERRIDE_LIBRARY(collection)) {
-  default_instantiating_collection = BKE_collection_add(
-  bmain, collection, "OVERRIDE_HIDDEN");
+  default_instantiating_collection = collection;
 }
   }
   if (default_instantiating_collection == NULL) {
-default_instantiating_collection = BKE_collection_add(
-bmain, scene->master_collection, "OVERRIDE_HIDDEN");
+default_instantiating_collection = scene->master_collection;
   }
   break;
 }
 default:
   BLI_assert(0);
   }
-  /* Hide the collection from viewport and render. */
-  default_instantiating_collection->flag |= 
COLLECTION_RESTRICT_VIEWPORT |
-COLLECTION_RESTRICT_RENDER;
 }
 
 BKE_collection_object_add(bmain, default_instantiating_collection, 
ob_new);

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


[Bf-blender-cvs] [415910a7e08] arcpatch-D9019: Make the operators that change keyframe data update the motion paths

2020-10-13 Thread Octave C
Commit: 415910a7e08cc77a869bee6002c80a9ff1064388
Author: Octave C
Date:   Tue Oct 13 13:11:30 2020 +0200
Branches: arcpatch-D9019
https://developer.blender.org/rB415910a7e08cc77a869bee6002c80a9ff1064388

Make the operators that change keyframe data update the motion paths

**Problem **

Right now, when auto-keying is on and and one transforms an object in the 3d 
view, its motion paths get updated. This makes it easy to iterate over an 
animation and make sure the object's trajectory looks right.

However, when the animation data is updated in any other way (e.g. through the 
graph editor, timeline, or action editor), the motion paths don't get updated 
right away, requiring an extra manual refresh on each incremental change.

**Proposed solution **

This patch makes sure that motion paths get updated whenever keyframe data 
changes, allowing for easier incremental changes. For now, the active object's 
motion paths are recomputed on every edit that triggers an "ND_KEYFRAME_PROP" 
notifier.

**Before**

{F8944697}

**After**

{F8944698}

Performance is fine now, there is no noticeable slow down with the Rain scene. 
Earlier it was slow because I was updating every point on the motion path as 
the mouse was moving, but now (as of diff 29494) only a single point is moved 
interactively and the whole path gets updated once the transform is confirmed, 
which matches what happens with viewport updates.

Here is a stress test, with a dozen motion paths having each 100 frames. I'm 
not an animator, so please excuse the wonkiness of it :)

{F8965509}

I've also tried moving around the keyframes in the timeline and dope sheet, and 
there isn't a noticeable slow down there either, which makes sense because the 
code that runs is almost the same each time (tiny bit of setup + a call to 
ED_objects_and_pose_recalculate_paths). For very large updates, say, selecting 
every single keyframe of every single bone and changing their handle type at 
once, there is a lag of about half a second (on a Ryzen 3600 with a debug 
build), which in my opinion i [...]

Reviewed By: looch

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

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/space_action/action_edit.c
M   source/blender/editors/space_graph/graph_edit.c
M   source/blender/editors/transform/transform_convert_action.c
M   source/blender/editors/transform/transform_convert_graph.c
M   source/blender/editors/transform/transform_convert_nla.c
M   source/blender/editors/transform/transform_convert_object.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index 6fdd65fdcc9..c4b465ec023 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -25,6 +25,7 @@
 
 #include "BLI_compiler_attrs.h"
 #include "DNA_object_enums.h"
+#include "ED_anim_api.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -62,10 +63,11 @@ struct Object *ED_object_context(const struct bContext *C);
 struct Object *ED_object_active_context(const struct bContext *C);
 void ED_collection_hide_menu_draw(const struct bContext *C, struct uiLayout 
*layout);
 
-Object **ED_object_array_in_mode_or_selected(struct bContext *C,
- bool (*filter_fn)(struct Object 
*ob, void *user_data),
- void *filter_user_data,
- uint *r_objects_len);
+struct Object **ED_object_array_in_mode_or_selected(struct bContext *C,
+bool (*filter_fn)(struct 
Object *ob,
+  void 
*user_data),
+void *filter_user_data,
+uint *r_objects_len);
 
 /* object_utils.c */
 bool ED_object_calc_active_center_for_editmode(struct Object *obedit,
@@ -229,18 +231,22 @@ void ED_object_vpaintmode_exit(struct bContext *C);
 void ED_object_wpaintmode_exit_ex(struct Object *ob);
 void ED_object_wpaintmode_exit(struct bContext *C);
 
-void ED_object_texture_paint_mode_enter_ex(struct Main *bmain, struct Scene 
*scene, Object *ob);
+void ED_object_texture_paint_mode_enter_ex(struct Main *bmain,
+   struct Scene *scene,
+   struct Object *ob);
 void ED_object_texture_paint_mode_enter(struct bContext *C);
 
-void ED_object_texture_paint_mode_exit_ex(struct Main *bmain, struct Scene 
*scene, Object *ob);
+void ED_object_texture_paint_mode_exit_ex(struct Main *bmain,
+  struct Scene *scene,
+   

[Bf-blender-cvs] [9db111b5fd3] arcpatch-D9019: Cleanup: Animation, rename function to match operator

2020-10-13 Thread Sybren A. Stüvel
Commit: 9db111b5fd3fb50e8d59becd65d529fb4bd46322
Author: Sybren A. Stüvel
Date:   Tue Oct 13 12:45:08 2020 +0200
Branches: arcpatch-D9019
https://developer.blender.org/rB9db111b5fd3fb50e8d59becd65d529fb4bd46322

Cleanup: Animation, rename function to match operator

Rename `animchannels_deselectall_exec` → `animchannels_selectall_exec` so
that it matches the operator `ANIM_OT_channels_select_all`.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 92b37628263..8a13872ca61 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2526,7 +2526,7 @@ static void ANIM_OT_channels_find(wmOperatorType *ot)
 
 /* ** Select All Operator *** */
 
-static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
+static int animchannels_selectall_exec(bContext *C, wmOperator *op)
 {
   bAnimContext ac;
 
@@ -2569,7 +2569,7 @@ static void ANIM_OT_channels_select_all(wmOperatorType 
*ot)
   ot->description = "Toggle selection of all animation channels";
 
   /* api callbacks */
-  ot->exec = animchannels_deselectall_exec;
+  ot->exec = animchannels_selectall_exec;
   ot->poll = animedit_poll_channels_nla_tweakmode_off;
 
   /* flags */

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


[Bf-blender-cvs] [c11ae5cd212] master: Fix sculpting/painting with viewport clipping and radial symmetry

2020-10-13 Thread Philipp Oeser
Commit: c11ae5cd21259a991b3cb1febdd4184fa62d789a
Author: Philipp Oeser
Date:   Tue Oct 6 12:50:11 2020 +0200
Branches: master
https://developer.blender.org/rBc11ae5cd21259a991b3cb1febdd4184fa62d789a

Fix sculpting/painting with viewport clipping and radial symmetry

This was reported for sculpting, the same is true for weightpaint or
vertexpaint though.

When viewport clipping and radial symmetry are enabled, the
'sculpt_brush_test_clipping()' function was not considering radial
symmetry at all, so if the coordinate was outside the clipping planes,
no action would take place. Now the coordinte is brought back to where
the stroke actually happens and that is checked against clipping.

Since other mirroring options while painting/sculpting (as well as
editmode operations with mirroring) usually still take place even if the
mirrored coord is outside the clipping planes, this should also be the
case for radial symmetry.

This grows the 'SculptBrushTest' struct a bit, but should be acceptable?

Fixes T81466

Maniphest Tasks: T81466

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

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 1a2848f1b38..806a9e4b0fb 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1591,10 +1591,14 @@ void SCULPT_brush_test_init(SculptSession *ss, 
SculptBrushTest *test)
   if (ss->cache) {
 copy_v3_v3(test->location, ss->cache->location);
 test->mirror_symmetry_pass = ss->cache->mirror_symmetry_pass;
+test->radial_symmetry_pass = ss->cache->radial_symmetry_pass;
+copy_m4_m4(test->symm_rot_mat_inv, ss->cache->symm_rot_mat_inv);
   }
   else {
 copy_v3_v3(test->location, ss->cursor_location);
 test->mirror_symmetry_pass = 0;
+test->radial_symmetry_pass = 0;
+unit_m4(test->symm_rot_mat_inv);
   }
 
   /* Just for initialize. */
@@ -1622,6 +1626,9 @@ BLI_INLINE bool sculpt_brush_test_clipping(const 
SculptBrushTest *test, const fl
   }
   float symm_co[3];
   flip_v3_v3(symm_co, co, test->mirror_symmetry_pass);
+  if (test->radial_symmetry_pass) {
+mul_m4_v3(test->symm_rot_mat_inv, symm_co);
+  }
   return ED_view3d_clipping_test(rv3d, symm_co, true);
 }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index e6710e27115..84a47ab86ba 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -735,6 +735,9 @@ typedef struct SculptBrushTest {
   float dist;
   int mirror_symmetry_pass;
 
+  int radial_symmetry_pass;
+  float symm_rot_mat_inv[4][4];
+
   /* For circle (not sphere) projection. */
   float plane_view[4];

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


[Bf-blender-cvs] [79875e37fe2] master: Cleanup: remove redundant assignment in SCULPT_brush_test_init

2020-10-13 Thread Philipp Oeser
Commit: 79875e37fe281c1988a1160978ab904bd42a336a
Author: Philipp Oeser
Date:   Tue Oct 13 13:11:24 2020 +0200
Branches: master
https://developer.blender.org/rB79875e37fe281c1988a1160978ab904bd42a336a

Cleanup: remove redundant assignment in SCULPT_brush_test_init

As discussed in D9120, this was an oversight in rBe0c792135adf, the same
assignment already happens a couple of lines above.

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 806a9e4b0fb..39b675de3c0 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1608,8 +1608,6 @@ void SCULPT_brush_test_init(SculptSession *ss, 
SculptBrushTest *test)
   zero_v4(test->plane_view);
   zero_v4(test->plane_tool);
 
-  test->mirror_symmetry_pass = ss->cache ? ss->cache->mirror_symmetry_pass : 0;
-
   if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) {
 test->clip_rv3d = rv3d;
   }

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


[Bf-blender-cvs] [16289274ed6] master: Fix T81656: Crash relocating a linked library into the current .blend

2020-10-13 Thread Philipp Oeser
Commit: 16289274ed6fdae83a3fbe400698d5d40c7a5d6c
Author: Philipp Oeser
Date:   Tue Oct 13 11:43:32 2020 +0200
Branches: master
https://developer.blender.org/rB16289274ed6fdae83a3fbe400698d5d40c7a5d6c

Fix T81656: Crash relocating a linked library into the current .blend

A .blend file cannot use itself as a library.
This is prevented when linking manually, but was still possible when
relocating, which is now prevented.

Maniphest Tasks: T81656

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

===

M   source/blender/windowmanager/intern/wm_files_link.c

===

diff --git a/source/blender/windowmanager/intern/wm_files_link.c 
b/source/blender/windowmanager/intern/wm_files_link.c
index 860c1d40dd9..e97f4ed0fa6 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -1057,6 +1057,15 @@ static int wm_lib_relocate_exec_do(bContext *C, 
wmOperator *op, bool do_reload)
   return OPERATOR_CANCELLED;
 }
 
+if (BLI_path_cmp(BKE_main_blendfile_path(bmain), path) == 0) {
+  BKE_reportf(op->reports,
+  RPT_ERROR_INVALID_INPUT,
+  "Cannot relocate library '%s' to current blend file '%s'",
+  lib->id.name,
+  path);
+  return OPERATOR_CANCELLED;
+}
+
 if (BLI_path_cmp(lib->filepath_abs, path) == 0) {
 #ifdef PRINT_DEBUG
   printf("We are supposed to reload '%s' lib (%d)...\n", lib->filepath, 
lib->id.us);

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


[Bf-blender-cvs] [b44173754f0] xr-actions-D9124: Fix condition for processing xr actions.

2020-10-13 Thread Peter Kim
Commit: b44173754f0a504132dd1e35cd8f5a94ad285be4
Author: Peter Kim
Date:   Thu Oct 8 16:26:06 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBb44173754f0a504132dd1e35cd8f5a94ad285be4

Fix condition for processing xr actions.

===

M   source/blender/windowmanager/xr/intern/wm_xr.c

===

diff --git a/source/blender/windowmanager/xr/intern/wm_xr.c 
b/source/blender/windowmanager/xr/intern/wm_xr.c
index 9b34232daf3..501b39fd281 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr.c
@@ -133,7 +133,7 @@ bool wm_xr_events_handle(wmWindowManager *wm)
 GHOST_XrEventsHandle(wm->xr.runtime->context);
 
 /* Process OpenXR action events and dispatch to XR surface / window 
queues. */
-if (WM_xr_session_exists) {
+if (WM_xr_session_is_ready(&wm->xr)) {
   wm_xr_session_actions_update(&wm->xr);
 }

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


[Bf-blender-cvs] [cfc5c1b46d6] xr-actions-D9124: Improve error logging and controller data management.

2020-10-13 Thread Peter Kim
Commit: cfc5c1b46d6d4191e08f8fc172e9ae5ec1dafa0c
Author: Peter Kim
Date:   Sun Oct 11 16:24:56 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBcfc5c1b46d6d4191e08f8fc172e9ae5ec1dafa0c

Improve error logging and controller data management.

===

M   intern/ghost/intern/GHOST_XrSession.cpp
M   source/blender/makesrna/intern/rna_xr.c
M   source/blender/windowmanager/xr/intern/wm_xr_actions.c
M   source/blender/windowmanager/xr/intern/wm_xr_intern.h
M   source/blender/windowmanager/xr/intern/wm_xr_operators.c
M   source/blender/windowmanager/xr/intern/wm_xr_session.c

===

diff --git a/intern/ghost/intern/GHOST_XrSession.cpp 
b/intern/ghost/intern/GHOST_XrSession.cpp
index a2f4af94aca..22b20d4cd23 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -609,7 +609,10 @@ bool GHOST_XrSession::createActionSet(const 
GHOST_XrActionSetInfo *info)
 
   OpenXRActionSet action_set;
   CHECK_XR_ND_BUF(xrCreateActionSet(m_context->getInstance(), 
&action_set_info, &action_set.set),
-  (std::string("Failed to create action set \"") + info->name 
+ "\".").c_str(),
+  (std::string("Failed to create action set \"") + info->name 
+ "\".\n" +
+   "Name must not contain upper case letters or special 
characters other than "
+   "'-', '_', or '.'.")
+  .c_str(),
   g_error_msg_buf);
 
   std::map &action_sets = m_oxr->action_sets;
@@ -708,7 +711,11 @@ bool GHOST_XrSession::createActions(const char 
*action_set_name,
 
 OpenXRAction action;
 CHECK_XR_ND_BUF(xrCreateAction(action_set->set, &action_info, 
&action.action),
-(std::string("Failed to create action \"") + info.name + 
"\".").c_str(),
+(std::string("Failed to create action \"") + info.name + 
"\".\n" +
+ "Action name and/or paths are invalid.\n" +
+ "Name must not contain upper case letters or special 
characters other than "
+ "'-', '_', or '.'.")
+.c_str(),
 g_error_msg_buf);
 
 if (actions.find(info.name) == actions.end()) {
@@ -917,7 +924,8 @@ bool GHOST_XrSession::createActionBindings(const char 
*action_set_name,
 
 CHECK_XR_ND_BUF(xrSuggestInteractionProfileBindings(instance, 
&bindings_info),
 (std::string("Failed to create bindings for profile \"") +
- interaction_profile_path + "\".")
+ interaction_profile_path + "\".\n" +
+ "Are the profile and action paths correct?")
 .c_str(),
 g_error_msg_buf);
 
@@ -1026,7 +1034,7 @@ void GHOST_XrSession::destroyActionBindings(const char 
*action_set_name,
 
 CHECK_XR_BUF(xrSuggestInteractionProfileBindings(instance, &bindings_info),
  (std::string("Failed to destroy bindings for profile \"") +
-  interaction_profile_path + "\".")
+  interaction_profile_path + "\".\n" + "Are the profile and 
action paths correct?")
  .c_str(),
  g_error_msg_buf);
 
@@ -1078,7 +1086,7 @@ bool GHOST_XrSession::attachActionSets()
   attach_info.actionSets = action_sets.data();
 
   CHECK_XR_ND(xrAttachSessionActionSets(m_oxr->session, &attach_info),
-  "Failed to attach action sets.");
+  "Failed to attach XR action sets.");
 
   return true;
 }
@@ -1097,7 +1105,7 @@ bool GHOST_XrSession::syncActions(const char 
*action_set_name)
   std::vector 
active_action_sets(sync_info.countActiveActionSets);
   if (action_set_name != nullptr) {
 OpenXRActionSet *action_set = find_action_set(m_oxr.get(), 
action_set_name);
-if (action_set == nullptr) {
+if (action_set == nullptr || action_set->actions.size() < 1) {
   return false;
 }
 
@@ -1108,15 +1116,25 @@ bool GHOST_XrSession::syncActions(const char 
*action_set_name)
   else {
 uint32_t i = 0;
 for (auto &action_set : action_sets) {
+  if (action_set.second.actions.size() < 1) {
+active_action_sets.pop_back();
+--sync_info.countActiveActionSets;
+continue;
+  }
+
   XrActiveActionSet &active_action_set = active_action_sets[i];
   active_action_set.actionSet = action_set.second.set;
   active_action_set.subactionPath = XR_NULL_PATH;
   ++i;
 }
+
+if (sync_info.countActiveActionSets < 1) {
+  return false;
+}
   }
   sync_info.activeActionSets = active_action_sets.data();
 
-  CHECK_XR(xrSyncActions(m_oxr->session, &sync_info), "Failed to sync 
actions.");
+  CHECK_XR(xrSyncActions(m_oxr->session, &sync_info), "Failed to synchronize 
XR actions.");
 
   return true;
 }
diff --git a/source/blender/makesrna/

[Bf-blender-cvs] [d7083de46d8] xr-actions-D9124: Update controller data when setting controller pose action.

2020-10-13 Thread Peter Kim
Commit: d7083de46d8b3bf64bf11eb3cf86fe296ec46b67
Author: Peter Kim
Date:   Thu Oct 8 23:49:29 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBd7083de46d8b3bf64bf11eb3cf86fe296ec46b67

Update controller data when setting controller pose action.

===

M   source/blender/windowmanager/xr/intern/wm_xr_actions.c
M   source/blender/windowmanager/xr/intern/wm_xr_session.c

===

diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actions.c 
b/source/blender/windowmanager/xr/intern/wm_xr_actions.c
index d6c440f73bf..ecb3e61efb3 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_actions.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_actions.c
@@ -263,6 +263,10 @@ void WM_xr_actions_destroy(wmXrData *xr,
 
   if (!action_find(action_set, controller_pose_name)) {
 action_set->controller_pose_action = NULL;
+
+/* Update controller data. */
+wmXrSessionState *session_state = &xr->runtime->session_state;
+memset(session_state->controllers, 0, sizeof(session_state->controllers));
   }
 }
 
@@ -329,6 +333,15 @@ bool WM_xr_controller_pose_action_set(wmXrData *xr,
   }
 
   action_set->controller_pose_action = action;
+
+  /* Update controller data. */
+  wmXrSessionState *session_state = &xr->runtime->session_state;
+  memset(session_state->controllers, 0, sizeof(session_state->controllers));
+  const unsigned int count = min((unsigned 
int)ARRAY_SIZE(session_state->controllers), action->count_subaction_paths);
+  for (unsigned int i = 0; i < count; ++i) {
+strcpy(session_state->controllers[i].subaction_path, 
action->subaction_paths[i]);
+  }
+
   return true;
 }
 
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c 
b/source/blender/windowmanager/xr/intern/wm_xr_session.c
index 22c49089d6f..bbef1e47790 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_session.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c
@@ -487,7 +487,7 @@ static void wm_xr_session_controller_mats_update(const 
XrSessionSettings *settin
 static const GHOST_XrPose *wm_xr_session_controller_pose_find(const 
wmXrSessionState *state,
   const char 
*subaction_path)
 {
-  for (unsigned int i = 0; i < 2; ++i) {
+  for (unsigned int i = 0; i < (unsigned int)ARRAY_SIZE(state->controllers); 
++i) {
 if (STREQ(state->controllers[i].subaction_path, subaction_path)) {
   return &state->controllers[i].pose;
 }

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


[Bf-blender-cvs] [3b3955d9e2c] xr-actions-D9124: Update comment.

2020-10-13 Thread Peter Kim
Commit: 3b3955d9e2c1d688d7acaf84d7765bc5b4192c0c
Author: Peter Kim
Date:   Sun Oct 11 17:50:11 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB3b3955d9e2c1d688d7acaf84d7765bc5b4192c0c

Update comment.

===

M   source/blender/makesdna/DNA_object_types.h
M   source/blender/windowmanager/xr/intern/wm_xr_intern.h
M   source/blender/windowmanager/xr/intern/wm_xr_session.c

===

diff --git a/source/blender/makesdna/DNA_object_types.h 
b/source/blender/makesdna/DNA_object_types.h
index 87abbdbbb6c..25bda62de7a 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -136,7 +136,7 @@ typedef struct Object_Runtime {
*/
   char is_data_eval_owned;
 
-  /** Identifies whether the object is an XR object (used for rendering). */
+  /** Identifies whether the object is an XR object (used for drawing). */
   char is_xr;
 
   /** Axis aligned boundbox (in localspace). */
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h 
b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
index 0fc8f8c3ead..728c4345969 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h
+++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
@@ -34,7 +34,7 @@ typedef struct wmXrControllerData {
   GHOST_XrPose pose;
   /** The last known controller matrix, calculated from above's controller 
pose. */
   float mat[4][4];
-  /** Mesh object, used to render the controller. */
+  /** Mesh object, used to draw the controller. */
   Object *ob;
 } wmXrControllerData;
 
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c 
b/source/blender/windowmanager/xr/intern/wm_xr_session.c
index d8b7afd3932..216ea23c082 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_session.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c
@@ -734,6 +734,7 @@ void wm_xr_session_controller_data_populate(const 
wmXrAction *controller_pose_ac
 strcpy(c->subaction_path, controller_pose_action->subaction_paths[i]);
 memset(&c->pose, 0, sizeof(c->pose));
 memset(c->mat, 0, sizeof(c->mat));
+#if 1
 if (!c->ob) {
   /* Just use zeroed-out pose.position for loc and rot. */
   c->ob = ED_object_add_type(
@@ -742,6 +743,7 @@ void wm_xr_session_controller_data_populate(const 
wmXrAction *controller_pose_ac
 c->ob->runtime.is_xr = true;
   }
 }
+#endif
   }
 }

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


[Bf-blender-cvs] [45194962c1a] xr-actions-D9124: Add wm_xr_operators.c.

2020-10-13 Thread Peter Kim
Commit: 45194962c1a566c3db2b967367b2a421485e3a56
Author: Peter Kim
Date:   Sat Oct 10 20:25:57 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB45194962c1a566c3db2b967367b2a421485e3a56

Add wm_xr_operators.c.

===

M   source/blender/windowmanager/CMakeLists.txt
M   source/blender/windowmanager/intern/wm_operators.c
A   source/blender/windowmanager/xr/intern/wm_xr_operators.c
M   source/blender/windowmanager/xr/wm_xr.h

===

diff --git a/source/blender/windowmanager/CMakeLists.txt 
b/source/blender/windowmanager/CMakeLists.txt
index 657a82d1349..dea181aa0fb 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -200,6 +200,7 @@ if(WITH_XR_OPENXR)
 xr/intern/wm_xr_draw.c
 xr/intern/wm_xr_session.c
 xr/intern/wm_xr_actions.c
+xr/intern/wm_xr_operators.c
 
 xr/wm_xr.h
 xr/intern/wm_xr_intern.h
diff --git a/source/blender/windowmanager/intern/wm_operators.c 
b/source/blender/windowmanager/intern/wm_operators.c
index a4c0cbd227c..dbba6b60a59 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3660,87 +3660,6 @@ static void WM_OT_stereo3d_set(wmOperatorType *ot)
 
 /** \} */
 
-#ifdef WITH_XR_OPENXR
-
-static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data)
-{
-  const bool session_exists = WM_xr_session_exists(xr_data);
-
-  for (bScreen *screen = bmain->screens.first; screen; screen = 
screen->id.next) {
-LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
-  LISTBASE_FOREACH (SpaceLink *, slink, &area->spacedata) {
-if (slink->spacetype == SPACE_VIEW3D) {
-  View3D *v3d = (View3D *)slink;
-
-  if (v3d->flag & V3D_XR_SESSION_MIRROR) {
-ED_view3d_xr_mirror_update(area, v3d, session_exists);
-  }
-
-  if (session_exists) {
-wmWindowManager *wm = bmain->wm.first;
-const Scene *scene = WM_windows_scene_get_from_screen(wm, screen);
-
-ED_view3d_xr_shading_update(wm, v3d, scene);
-  }
-  /* Ensure no 3D View is tagged as session root. */
-  else {
-v3d->runtime.flag &= ~V3D_RUNTIME_XR_SESSION_ROOT;
-  }
-}
-  }
-}
-  }
-
-  WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL);
-}
-
-static void wm_xr_session_update_screen_on_exit_cb(const wmXrData *xr_data)
-{
-  /* Just use G_MAIN here, storing main isn't reliable enough on file read or 
exit. */
-  wm_xr_session_update_screen(G_MAIN, xr_data);
-}
-
-static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op))
-{
-  Main *bmain = CTX_data_main(C);
-  wmWindowManager *wm = CTX_wm_manager(C);
-  wmWindow *win = CTX_wm_window(C);
-  View3D *v3d = CTX_wm_view3d(C);
-
-  /* Lazy-create xr context - tries to dynlink to the runtime, reading 
active_runtime.json. */
-  if (wm_xr_init(wm) == false) {
-return OPERATOR_CANCELLED;
-  }
-
-  v3d->runtime.flag |= V3D_RUNTIME_XR_SESSION_ROOT;
-  wm_xr_session_toggle(C, wm, win, wm_xr_session_update_screen_on_exit_cb);
-  wm_xr_session_update_screen(bmain, &wm->xr);
-
-  WM_event_add_notifier(C, NC_WM | ND_XR_DATA_CHANGED, NULL);
-
-  return OPERATOR_FINISHED;
-}
-
-static void WM_OT_xr_session_toggle(wmOperatorType *ot)
-{
-  /* identifiers */
-  ot->name = "Toggle VR Session";
-  ot->idname = "WM_OT_xr_session_toggle";
-  ot->description =
-  "Open a view for use with virtual reality headsets, or close it if 
already "
-  "opened";
-
-  /* callbacks */
-  ot->exec = wm_xr_session_toggle_exec;
-  ot->poll = ED_operator_view3d_active;
-
-  /* XXX INTERNAL just to hide it from the search menu by default, an Add-on 
will expose it in the
-   * UI instead. Not meant as a permanent solution. */
-  ot->flag = OPTYPE_INTERNAL;
-}
-
-#endif /* WITH_XR_OPENXR */
-
 /*  */
 /** \name Operator Registration & Keymaps
  * \{ */
@@ -3782,9 +3701,6 @@ void wm_operatortypes_register(void)
   WM_operatortype_append(WM_OT_call_panel);
   WM_operatortype_append(WM_OT_radial_control);
   WM_operatortype_append(WM_OT_stereo3d_set);
-#ifdef WITH_XR_OPENXR
-  WM_operatortype_append(WM_OT_xr_session_toggle);
-#endif
 #if defined(WIN32)
   WM_operatortype_append(WM_OT_console_toggle);
 #endif
@@ -3795,6 +3711,10 @@ void wm_operatortypes_register(void)
   /* gizmos */
   WM_operatortype_append(GIZMOGROUP_OT_gizmo_select);
   WM_operatortype_append(GIZMOGROUP_OT_gizmo_tweak);
+
+#ifdef WITH_XR_OPENXR
+  wm_xr_operatortypes_register();
+#endif
 }
 
 /* circleselect-like modal operators */
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_operators.c 
b/source/blender/windowmanager/xr/intern/wm_xr_operators.c
new file mode 100644
index 000..b6d57854125
--- /de

[Bf-blender-cvs] [921510f34f0] xr-actions-D9124: Add xr overlay and controller object.

2020-10-13 Thread Peter Kim
Commit: 921510f34f0a4359e321980f477b74aaf47e93c8
Author: Peter Kim
Date:   Sat Oct 10 19:36:49 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB921510f34f0a4359e321980f477b74aaf47e93c8

Add xr overlay and controller object.

===

M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_engine.c
M   source/blender/draw/engines/overlay/overlay_private.h
A   source/blender/draw/engines/overlay/overlay_xr.c
M   source/blender/draw/intern/draw_manager.c
M   source/blender/makesdna/DNA_object_types.h
M   source/blender/windowmanager/xr/intern/wm_xr_actions.c
M   source/blender/windowmanager/xr/intern/wm_xr_intern.h
M   source/blender/windowmanager/xr/intern/wm_xr_session.c

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 4e72e89ae99..f45788a2c6c 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -148,6 +148,7 @@ set(SRC
   engines/overlay/overlay_shader.c
   engines/overlay/overlay_volume.c
   engines/overlay/overlay_wireframe.c
+  engines/overlay/overlay_xr.c
 
   DRW_engine.h
   DRW_engine_types.h
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c 
b/source/blender/draw/engines/overlay/overlay_engine.c
index 30b39e5d5e1..c2b39f1b2b0 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -209,6 +209,7 @@ static void OVERLAY_cache_init(void *vedata)
   OVERLAY_particle_cache_init(vedata);
   OVERLAY_wireframe_cache_init(vedata);
   OVERLAY_volume_cache_init(vedata);
+  OVERLAY_xr_cache_init(vedata);
 }
 
 BLI_INLINE OVERLAY_DupliData *OVERLAY_duplidata_get(Object *ob, void *vedata, 
bool *do_init)
@@ -421,6 +422,10 @@ static void OVERLAY_cache_populate(void *vedata, Object 
*ob)
 OVERLAY_motion_path_cache_populate(vedata, ob);
   }
 
+  if (ob->runtime.is_xr) {
+OVERLAY_xr_cache_populate(vedata, ob);
+  }
+
   if (!pd->hide_overlays) {
 switch (ob->type) {
   case OB_ARMATURE:
@@ -641,6 +646,8 @@ static void OVERLAY_draw_scene(void *vedata)
   break;
   }
 
+  OVERLAY_xr_draw(vedata);
+
   OVERLAY_antialiasing_end(vedata);
 }
 
diff --git a/source/blender/draw/engines/overlay/overlay_private.h 
b/source/blender/draw/engines/overlay/overlay_private.h
index ef7a2db476c..d10b5328dc7 100644
--- a/source/blender/draw/engines/overlay/overlay_private.h
+++ b/source/blender/draw/engines/overlay/overlay_private.h
@@ -122,6 +122,7 @@ typedef struct OVERLAY_PassList {
   DRWPass *volume_ps;
   DRWPass *wireframe_ps;
   DRWPass *wireframe_xray_ps;
+  DRWPass *xr_controllers_ps;
   DRWPass *xray_fade_ps;
 } OVERLAY_PassList;
 
@@ -291,6 +292,7 @@ typedef struct OVERLAY_PrivateData {
   DRWShadingGroup *wires_all_grp[2][2];  /* With and without coloring. */
   DRWShadingGroup *wires_hair_grp[2][2]; /* With and without coloring. */
   DRWShadingGroup *wires_sculpt_grp[2];
+  DRWShadingGroup *xr_controllers_grp;
 
   DRWView *view_default;
   DRWView *view_wires;
@@ -636,6 +638,10 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata,
 void OVERLAY_wireframe_draw(OVERLAY_Data *vedata);
 void OVERLAY_wireframe_in_front_draw(OVERLAY_Data *vedata);
 
+void OVERLAY_xr_cache_init(OVERLAY_Data *vedata);
+void OVERLAY_xr_cache_populate(OVERLAY_Data *vedata, Object *ob);
+void OVERLAY_xr_draw(OVERLAY_Data *vedata);
+
 void OVERLAY_shader_library_ensure(void);
 GPUShader *OVERLAY_shader_antialiasing(void);
 GPUShader *OVERLAY_shader_armature_degrees_of_freedom_wire(void);
diff --git a/source/blender/draw/engines/overlay/overlay_xr.c 
b/source/blender/draw/engines/overlay/overlay_xr.c
new file mode 100644
index 000..01c9fe4c0b5
--- /dev/null
+++ b/source/blender/draw/engines/overlay/overlay_xr.c
@@ -0,0 +1,77 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2019, Blender Foundation.
+ */
+
+/** \file
+ * \ingroup draw_engine
+ */
+
+#include "DRW_render.h"
+
+#include "GPU_batch.h"
+
+#include "overlay_private.h"
+
+void OVERLAY_xr_cache_init(OVERLAY_Data *vedata)
+{
+  OVERLAY_PassList *psl = vedata->psl;
+  OVERLAY_Privat

[Bf-blender-cvs] [e0eafd27579] xr-actions-D9124: XR: Add selection outline offscreen draw flag

2020-10-13 Thread Peter Kim
Commit: e0eafd2757904db57e8dad982624bc76e67e45f9
Author: Peter Kim
Date:   Tue Oct 13 18:35:44 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBe0eafd2757904db57e8dad982624bc76e67e45f9

XR: Add selection outline offscreen draw flag

===

M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/makesdna/DNA_view3d_enums.h
M   source/blender/makesrna/intern/rna_xr.c

===

diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index d7b0e3ea3bd..bc587e5a4b4 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1788,23 +1788,26 @@ void ED_view3d_draw_offscreen_simple(Depsgraph 
*depsgraph,
 v3d.shading.flag = V3D_SHADING_SCENE_WORLD | V3D_SHADING_SCENE_LIGHTS;
   }
 
-  if ((draw_flags & (V3D_OFSDRAW_SHOW_ANNOTATION | 
V3D_OFSDRAW_XR_SHOW_CONTROLLERS |
- V3D_OFSDRAW_SHOW_GRIDFLOOR)) == 0) {
+  if ((draw_flags & (V3D_OFSDRAW_SHOW_ANNOTATION | V3D_OFSDRAW_SHOW_GRIDFLOOR |
+ V3D_OFSDRAW_SHOW_SELECTION | 
V3D_OFSDRAW_XR_SHOW_CONTROLLERS)) == 0) {
 v3d.flag2 = V3D_HIDE_OVERLAYS;
   }
   else {
 if (draw_flags & V3D_OFSDRAW_SHOW_ANNOTATION) {
   v3d.flag2 |= V3D_SHOW_ANNOTATION;
 }
-if (draw_flags & V3D_OFSDRAW_XR_SHOW_CONTROLLERS) {
-  v3d.flag2 |= V3D_XR_SHOW_CONTROLLERS;
-}
 if (draw_flags & V3D_OFSDRAW_SHOW_GRIDFLOOR) {
   v3d.gridflag |= V3D_SHOW_FLOOR | V3D_SHOW_X | V3D_SHOW_Y;
   v3d.grid = 1.0f;
   v3d.gridlines = 16;
   v3d.gridsubdiv = 10;
 }
+if (draw_flags & V3D_OFSDRAW_SHOW_SELECTION) {
+  v3d.flag |= V3D_SELECT_OUTLINE;
+}
+if (draw_flags & V3D_OFSDRAW_XR_SHOW_CONTROLLERS) {
+  v3d.flag2 |= V3D_XR_SHOW_CONTROLLERS;
+}
 /* Disable other overlays (set all available _HIDE_ flags). */
 v3d.overlay.flag |= V3D_OVERLAY_HIDE_CURSOR | V3D_OVERLAY_HIDE_TEXT |
 V3D_OVERLAY_HIDE_MOTION_PATHS | V3D_OVERLAY_HIDE_BONES 
|
diff --git a/source/blender/makesdna/DNA_view3d_enums.h 
b/source/blender/makesdna/DNA_view3d_enums.h
index 5a066f05754..7f79be1df8e 100644
--- a/source/blender/makesdna/DNA_view3d_enums.h
+++ b/source/blender/makesdna/DNA_view3d_enums.h
@@ -26,7 +26,8 @@ typedef enum eV3DOffscreenDrawFlag {
   V3D_OFSDRAW_SHOW_ANNOTATION = (1 << 0),
   V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS = (1 << 1),
   V3D_OFSDRAW_SHOW_GRIDFLOOR = (1 << 2),
-  V3D_OFSDRAW_XR_SHOW_CONTROLLERS = (1 << 3),
+  V3D_OFSDRAW_SHOW_SELECTION = (1 << 3),
+  V3D_OFSDRAW_XR_SHOW_CONTROLLERS = (1 << 4),
 } eV3DOffscreenDrawFlag;
 
 /** #View3DShading.light */
diff --git a/source/blender/makesrna/intern/rna_xr.c 
b/source/blender/makesrna/intern/rna_xr.c
index 91024fa0087..6bff5104e7a 100644
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -510,6 +510,11 @@ static void rna_def_xr_session_settings(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Show Annotation", "Show annotations for this 
view");
   RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
 
+  prop = RNA_def_property(srna, "show_selection", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", 
V3D_OFSDRAW_SHOW_SELECTION);
+  RNA_def_property_ui_text(prop, "Show Selection", "Show selection outlines");
+  RNA_def_property_update(prop, NC_WM | ND_XR_DATA_CHANGED, NULL);
+
   prop = RNA_def_property(srna, "show_controllers", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", 
V3D_OFSDRAW_XR_SHOW_CONTROLLERS);
   RNA_def_property_ui_text(

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


[Bf-blender-cvs] [e0da7250750] xr-actions-D9124: Add basic controller visualization.

2020-10-13 Thread Peter Kim
Commit: e0da72507509510ce3fadfc6dd6a2e46ae7164fc
Author: Peter Kim
Date:   Tue Oct 6 21:37:06 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBe0da72507509510ce3fadfc6dd6a2e46ae7164fc

Add basic controller visualization.

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

===

M   intern/ghost/GHOST_C-api.h
M   intern/ghost/GHOST_IXrContext.h
M   intern/ghost/GHOST_Types.h
M   intern/ghost/intern/GHOST_C-api.cpp
M   intern/ghost/intern/GHOST_XrContext.cpp
M   intern/ghost/intern/GHOST_XrContext.h
M   intern/ghost/intern/GHOST_XrException.h
M   intern/ghost/intern/GHOST_XrSession.cpp
M   intern/ghost/intern/GHOST_XrSession.h
M   intern/ghost/intern/GHOST_Xr_intern.h
M   source/blender/blenkernel/BKE_callbacks.h
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/makesdna/DNA_view3d_enums.h
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/makesrna/intern/rna_wm.c
M   source/blender/makesrna/intern/rna_xr.c
M   source/blender/python/intern/bpy_app_handlers.c
M   source/blender/windowmanager/CMakeLists.txt
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_event_query.c
M   source/blender/windowmanager/intern/wm_event_system.c
M   source/blender/windowmanager/intern/wm_operators.c
M   source/blender/windowmanager/wm_event_system.h
M   source/blender/windowmanager/wm_event_types.h
M   source/blender/windowmanager/wm_surface.h
M   source/blender/windowmanager/xr/intern/wm_xr.c
A   source/blender/windowmanager/xr/intern/wm_xr_actions.c
M   source/blender/windowmanager/xr/intern/wm_xr_draw.c
M   source/blender/windowmanager/xr/intern/wm_xr_intern.h
M   source/blender/windowmanager/xr/intern/wm_xr_session.c
M   source/blender/windowmanager/xr/wm_xr.h

===

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 2046b55c97f..09734506020 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -1067,6 +1067,115 @@ int GHOST_XrSessionNeedsUpsideDownDrawing(const 
GHOST_XrContextHandle xr_context
  * \returns GHOST_kSuccess if any event was handled, otherwise GHOST_kFailure.
  */
 GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_context);
+
+/* actions */
+/**
+ * Create an OpenXR action set for input / output.
+ */
+int GHOST_XrCreateActionSet(GHOST_XrContextHandle xr_context, const 
GHOST_XrActionSetInfo *info);
+
+/**
+ * Destroy a previously created OpenXR action set.
+ */
+void GHOST_XrDestroyActionSet(GHOST_XrContextHandle xr_context, const char 
*action_set_name);
+
+/**
+ * Create OpenXR input / output actions.
+ */
+int GHOST_XrCreateActions(GHOST_XrContextHandle xr_context,
+  const char *action_set_name,
+  GHOST_TUns32 count,
+  const GHOST_XrActionInfo *infos);
+
+/**
+ * Destroy previously created OpenXR actions.
+ */
+void GHOST_XrDestroyActions(GHOST_XrContextHandle xr_context,
+const char *action_set_name,
+GHOST_TUns32 count,
+const char *const *action_names);
+
+/**
+ * Create spaces for pose-based OpenXR actions.
+ */
+int GHOST_XrCreateActionSpaces(GHOST_XrContextHandle xr_context,
+   const char *action_set_name,
+   GHOST_TUns32 count,
+   const GHOST_XrActionSpaceInfo *infos);
+
+/**
+ * Destroy previously created spaces for OpenXR actions.
+ */
+void GHOST_XrDestroyActionSpaces(GHOST_XrContextHandle xr_context,
+ const char *action_set_name,
+ GHOST_TUns32 count,
+ const GHOST_XrActionSpaceInfo *infos);
+
+/**
+ * Create input / output path bindings for OpenXR actions.
+ *
+ * \param replace_existing: Whether to replace all existing bindings for the 
profiles
+ * specified in infos.
+ */
+int GHOST_XrCreateActionBindings(GHOST_XrContextHandle xr_context,
+ const char *action_set_name,
+ GHOST_TUns32 count,
+ const GHOST_XrActionBindingsInfo *infos,
+ int replace_existing);
+
+/**
+ * Destroy previously created bindings for OpenXR actions.
+ */
+void GHOST_XrDestroyActionBindings(GHOST_XrContextHandle xr_context,
+   const char *action_set_name,
+   GHOST_TUns32 count,
+   const GHOST_XrActionBindingsInfo *infos);
+
+/**
+ * Attach all created action set

[Bf-blender-cvs] [9c9081bf834] xr-actions-D9124: Fix annotations not being shown in XR view.

2020-10-13 Thread Peter Kim
Commit: 9c9081bf834f36b2864717a9650c02604f6d6c68
Author: Peter Kim
Date:   Sun Oct 11 17:20:43 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB9c9081bf834f36b2864717a9650c02604f6d6c68

Fix annotations not being shown in XR view.

===

M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/include/ED_view3d_offscreen.h
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/windowmanager/xr/intern/wm_xr_draw.c

===

diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index 3ade3611a6a..2545564e6fe 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1446,7 +1446,7 @@ void DRW_draw_callbacks_post_scene(void)
 
 GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
   }
-  else if ((v3d->flag2 & V3D_XR_SHOW_CONTROLLERS) != 0) {
+  else if ((v3d->flag & V3D_XR_SESSION_SURFACE) != 0) {
 DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
 
 DRW_state_reset();
@@ -1460,12 +1460,13 @@ void DRW_draw_callbacks_post_scene(void)
 if (do_annotations) {
   GPU_depth_test(GPU_DEPTH_NONE);
   ED_annotation_draw_view3d(DEG_get_input_scene(depsgraph), depsgraph, 
v3d, region, true);
-  GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
 }
 
 /* Controllers. */
-GPU_depth_test(GPU_DEPTH_ALWAYS);
-WM_xr_draw_controllers();
+if ((v3d->flag2 & V3D_XR_SHOW_CONTROLLERS) != 0) {
+  GPU_depth_test(GPU_DEPTH_ALWAYS);
+  WM_xr_draw_controllers();
+}
 
 GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
   }
diff --git a/source/blender/editors/include/ED_view3d_offscreen.h 
b/source/blender/editors/include/ED_view3d_offscreen.h
index 2833d205e77..393976aa91f 100644
--- a/source/blender/editors/include/ED_view3d_offscreen.h
+++ b/source/blender/editors/include/ED_view3d_offscreen.h
@@ -60,7 +60,7 @@ void ED_view3d_draw_offscreen(struct Depsgraph *depsgraph,
 void ED_view3d_draw_offscreen_simple(struct Depsgraph *depsgraph,
  struct Scene *scene,
  struct View3DShading *shading_override,
- int drawtype,
+ eDrawType drawtype,
  int winx,
  int winy,
  unsigned int draw_flags,
@@ -68,6 +68,7 @@ void ED_view3d_draw_offscreen_simple(struct Depsgraph 
*depsgraph,
  const float winmat[4][4],
  float clip_start,
  float clip_end,
+ bool is_xr_surface,
  bool is_image_render,
  bool do_sky,
  bool is_persp,
diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index e80de3a3f79..364c79a9578 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1749,7 +1749,7 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
 void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
  Scene *scene,
  View3DShading *shading_override,
- int drawtype,
+ eDrawType drawtype,
  int winx,
  int winy,
  uint draw_flags,
@@ -1757,6 +1757,7 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
  const float winmat[4][4],
  float clip_start,
  float clip_end,
+ bool is_xr_surface,
  bool is_image_render,
  bool do_sky,
  bool is_persp,
@@ -1803,13 +1804,16 @@ void ED_view3d_draw_offscreen_simple(Depsgraph 
*depsgraph,
   v3d.grid = 1.0f;
   v3d.gridlines = 16;
   v3d.gridsubdiv = 10;
-
-  /* Show grid, disable other overlays (set all available _HIDE_ flags). */
-  v3d.overlay.flag |= V3D_OVERLAY_HIDE_CURSOR | V3D_OVERLAY_HIDE_TEXT |
-  V3D_OVERLAY_HIDE_MOTION_PATHS | 
V3D_OVERLAY_HIDE_BONES |
-  V3D_OVERLAY_HIDE_OBJECT_XTRAS | 
V3D_OVERLAY_HIDE_OBJECT_ORIGINS;
-  v3d.flag |= V3D_HIDE_HELPLINES;
 }
+/* Disable other overlays (set all available _HIDE_ flags). */
+v3d.overlay.f

[Bf-blender-cvs] [090c1b7ddac] xr-actions-D9124: Disable XR object saving and (for now) creation

2020-10-13 Thread Peter Kim
Commit: 090c1b7ddacdb2498e1838662db0441faa409649
Author: Peter Kim
Date:   Mon Oct 12 22:44:39 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB090c1b7ddacdb2498e1838662db0441faa409649

Disable XR object saving and (for now) creation

===

M   source/blender/blenloader/intern/writefile.c
M   source/blender/makesdna/DNA_object_types.h
M   source/blender/windowmanager/xr/intern/wm_xr_session.c

===

diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index a37ec2d9f0a..199628467ab 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1312,6 +1312,13 @@ static void write_shaderfxs(BlendWriter *writer, 
ListBase *fxbase)
 
 static void write_object(BlendWriter *writer, Object *ob, const void 
*id_address)
 {
+#if 1
+  /* Don't write XR objects. */
+  if (ob->runtime.is_xr) {
+return;
+  }
+#endif
+
   const bool is_undo = BLO_write_is_undo(writer);
   if (ob->id.us > 0 || is_undo) {
 /* Clean up, important in undo case to reduce false detection of changed 
data-blocks. */
diff --git a/source/blender/makesdna/DNA_object_types.h 
b/source/blender/makesdna/DNA_object_types.h
index 25bda62de7a..128d5b98d40 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -136,7 +136,10 @@ typedef struct Object_Runtime {
*/
   char is_data_eval_owned;
 
-  /** Identifies whether the object is an XR object (used for drawing). */
+  /**
+   * Denotes whether the object is tied to the lifetime of an XR session. This 
is used for
+   * drawing and also to prevent temporary XR objects from being saved in 
files.
+   */
   char is_xr;
 
   /** Axis aligned boundbox (in localspace). */
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c 
b/source/blender/windowmanager/xr/intern/wm_xr_session.c
index dfdb832a1f2..08e60e8baae 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_session.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c
@@ -746,7 +746,7 @@ void wm_xr_session_controller_data_populate(const 
wmXrAction *controller_pose_ac
 strcpy(c->subaction_path, controller_pose_action->subaction_paths[i]);
 memset(&c->pose, 0, sizeof(c->pose));
 memset(c->mat, 0, sizeof(c->mat));
-#if 1
+#if 0
 if (!c->ob) {
   /* Just use zeroed-out pose.position for loc and rot. */
   c->ob = ED_object_add_type(

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


[Bf-blender-cvs] [5e8d3f6d281] xr-actions-D9124: Operators: Add invoke_3d() and implement for VIEW3D_OT_select

2020-10-13 Thread Peter Kim
Commit: 5e8d3f6d281267a7866060dee0a78b10bb65429b
Author: Peter Kim
Date:   Tue Oct 13 18:11:22 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB5e8d3f6d281267a7866060dee0a78b10bb65429b

Operators: Add invoke_3d() and implement for VIEW3D_OT_select

===

M   source/blender/editors/space_view3d/view3d_select.c
M   source/blender/makesrna/intern/rna_wm.c
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_event_query.c
M   source/blender/windowmanager/intern/wm_event_system.c
M   source/blender/windowmanager/wm_event_system.h
M   source/blender/windowmanager/xr/intern/wm_xr_draw.c
M   source/blender/windowmanager/xr/intern/wm_xr_intern.h
M   source/blender/windowmanager/xr/intern/wm_xr_session.c

===

diff --git a/source/blender/editors/space_view3d/view3d_select.c 
b/source/blender/editors/space_view3d/view3d_select.c
index 3f758c0fda3..e03609dab52 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2507,6 +2507,60 @@ static int view3d_select_invoke(bContext *C, wmOperator 
*op, const wmEvent *even
   return view3d_select_exec(C, op);
 }
 
+static void controller_loc_to_mval(const float loc[3],
+   const float viewmat[4][4],
+   const float winmat[4][4],
+   short winx,
+   short winy,
+   int r_mval[2])
+{
+  float persmat[4][4];
+  float tmp[3];
+
+  mul_m4_m4m4(persmat, winmat, viewmat);
+  copy_v3_v3(tmp, loc);
+  mul_project_m4_v3(persmat, tmp);
+  r_mval[0] = (int)(((float)winx / 2.0f) * (1.0f + tmp[0]));
+  r_mval[1] = (int)(((float)winy / 2.0f) * (1.0f + tmp[1]));
+}
+
+static int view3d_select_invoke_3d(bContext *C, wmOperator *op, const wmEvent 
*event)
+{
+  BLI_assert(event->type == EVT_XR_ACTION);
+  BLI_assert(event->custom == EVT_DATA_XR);
+  BLI_assert(event->customdata);
+
+  ARegion *ar = CTX_wm_region(C);
+  RegionView3D *rv3d = ar->regiondata;
+  wmXrActionData *customdata = event->customdata;
+  float viewmat_prev[4][4];
+  float winmat_prev[4][4];
+  int mval[2];
+
+  /* Since this function is called in a window context, we need to replace the
+   * window viewmat and winmat with the XR surface counterparts to get a 
correct
+   * result for GPU select. */
+  copy_m4_m4(viewmat_prev, rv3d->viewmat);
+  copy_m4_m4(winmat_prev, rv3d->winmat);
+  copy_m4_m4(rv3d->viewmat, customdata->viewmat);
+  copy_m4_m4(rv3d->winmat, customdata->winmat);
+
+  controller_loc_to_mval(customdata->controller_loc,
+ customdata->viewmat,
+ customdata->winmat,
+ ar->winx,
+ ar->winy,
+ mval);
+
+  RNA_int_set_array(op->ptr, "location", mval);
+
+  int retval = view3d_select_exec(C, op);
+  copy_m4_m4(rv3d->viewmat, viewmat_prev);
+  copy_m4_m4(rv3d->winmat, winmat_prev);
+
+  return retval;
+}
+
 void VIEW3D_OT_select(wmOperatorType *ot)
 {
   PropertyRNA *prop;
@@ -2518,6 +2572,7 @@ void VIEW3D_OT_select(wmOperatorType *ot)
 
   /* api callbacks */
   ot->invoke = view3d_select_invoke;
+  ot->invoke_3d = view3d_select_invoke_3d;
   ot->exec = view3d_select_exec;
   ot->poll = ED_operator_view3d_active;
 
diff --git a/source/blender/makesrna/intern/rna_wm.c 
b/source/blender/makesrna/intern/rna_wm.c
index 9b23cfcec67..949f25fac2d 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -686,7 +686,7 @@ static void rna_Event_xr_action_get(PointerRNA *ptr, char 
*value)
 {
   const wmEvent *event = ptr->data;
   if (WM_event_is_xr(event)) {
-WM_event_xr_data(event, &value, NULL, NULL, NULL, NULL);
+WM_event_xr_data(event, &value, NULL, NULL, NULL, NULL, NULL, NULL);
   }
   else {
 value[0] = '\0';
@@ -710,7 +710,7 @@ static int rna_Event_xr_type_get(PointerRNA *ptr)
   const wmEvent *event = ptr->data;
   if (WM_event_is_xr(event)) {
 GHOST_XrActionType type;
-WM_event_xr_data(event, NULL, (char *)&type, NULL, NULL, NULL);
+WM_event_xr_data(event, NULL, (char *)&type, NULL, NULL, NULL, NULL, NULL);
 return type;
   }
   else {
@@ -722,7 +722,7 @@ static void rna_Event_xr_state_get(PointerRNA *ptr, float 
*value)
 {
   const wmEvent *event = ptr->data;
   if (WM_event_is_xr(event)) {
-WM_event_xr_data(event, NULL, NULL, value, NULL, NULL);
+WM_event_xr_data(event, NULL, NULL, value, NULL, NULL, NULL, NULL);
   }
   else {
 memset(value, 0, sizeof(float[2]));
@@ -733,7 +733,7 @@ static void rna_Event_xr_controller_location_get(PointerRNA 
*ptr, float *value)
 {
   const wmEvent *event = ptr->data;
   if (WM_event_is_xr(

[Bf-blender-cvs] [f126ce2d5b7] xr-actions-D9124: Add safety checks when accessing XR window and controller objects.

2020-10-13 Thread Peter Kim
Commit: f126ce2d5b765f11acec8c12035c3ecfda738a8e
Author: Peter Kim
Date:   Sun Oct 11 20:13:28 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBf126ce2d5b765f11acec8c12035c3ecfda738a8e

Add safety checks when accessing XR window and controller objects.

===

M   source/blender/draw/engines/overlay/overlay_xr.c
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/windowmanager/intern/wm_event_system.c
M   source/blender/windowmanager/xr/intern/wm_xr_intern.h
M   source/blender/windowmanager/xr/intern/wm_xr_session.c

===

diff --git a/source/blender/draw/engines/overlay/overlay_xr.c 
b/source/blender/draw/engines/overlay/overlay_xr.c
index 01c9fe4c0b5..ba9c8c16646 100644
--- a/source/blender/draw/engines/overlay/overlay_xr.c
+++ b/source/blender/draw/engines/overlay/overlay_xr.c
@@ -31,9 +31,10 @@ void OVERLAY_xr_cache_init(OVERLAY_Data *vedata)
   OVERLAY_PassList *psl = vedata->psl;
   OVERLAY_PrivateData *pd = vedata->stl->pd;
   DRWShadingGroup *grp;
-  const float color[4] = { 0.211f, 0.219f, 0.223f, 0.4f };
+  const float color[4] = {0.211f, 0.219f, 0.223f, 0.4f};
 
-  DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | 
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA;
+  DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | 
DRW_STATE_DEPTH_LESS_EQUAL |
+   DRW_STATE_BLEND_ALPHA;
   DRW_PASS_CREATE(psl->xr_controllers_ps, state | pd->clipping_state);
 
   GPUShader *sh = OVERLAY_shader_uniform_color();
@@ -46,12 +47,13 @@ void OVERLAY_xr_cache_populate(OVERLAY_Data *vedata, Object 
*ob)
   OVERLAY_PrivateData *pd = vedata->stl->pd;
   GPUBatch *xr_controllers = DRW_cache_mesh_all_verts_get(ob);
 
-  if (xr_controllers && xr_controllers->verts[0] && 
(GPU_vertbuf_get_vertex_len(xr_controllers->verts[0]) > 0)) {
+  if (xr_controllers && xr_controllers->verts[0] &&
+  (GPU_vertbuf_get_vertex_len(xr_controllers->verts[0]) > 0)) {
 DRW_shgroup_call_obmat(pd->xr_controllers_grp, xr_controllers, ob->obmat);
   }
   else {
 /* Fallback to primitive sphere. */
-const float scale[3] = { 0.05f, 0.05f, 0.05f };
+const float scale[3] = {0.05f, 0.05f, 0.05f};
 float obmat[4][4];
 copy_m4_m4(obmat, ob->obmat);
 rescale_m4(obmat, scale);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index 364c79a9578..d7b0e3ea3bd 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1807,8 +1807,8 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
 }
 /* Disable other overlays (set all available _HIDE_ flags). */
 v3d.overlay.flag |= V3D_OVERLAY_HIDE_CURSOR | V3D_OVERLAY_HIDE_TEXT |
-  V3D_OVERLAY_HIDE_MOTION_PATHS | V3D_OVERLAY_HIDE_BONES |
-  V3D_OVERLAY_HIDE_OBJECT_XTRAS | V3D_OVERLAY_HIDE_OBJECT_ORIGINS;
+V3D_OVERLAY_HIDE_MOTION_PATHS | V3D_OVERLAY_HIDE_BONES 
|
+V3D_OVERLAY_HIDE_OBJECT_XTRAS | 
V3D_OVERLAY_HIDE_OBJECT_ORIGINS;
 v3d.flag |= V3D_HIDE_HELPLINES;
   }
 
diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index 81baf956509..fdf4d71c6a5 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -3188,6 +3188,9 @@ static void wm_event_surface_free_all(wmXrSurfaceData 
*surface_data)
 
 static void wm_event_do_surface_handlers(bContext *C, wmSurface *surface)
 {
+  /* TODO_XR: Currently assumes that the XR surface is the
+   * same as the one for the XR runtime. In the future this
+   * might not always be the case. */
   wmWindowManager *wm = CTX_wm_manager(C);
   wmXrData *xr = &wm->xr;
   if (!xr->runtime || !surface->is_xr) {
@@ -3199,13 +3202,9 @@ static void wm_event_do_surface_handlers(bContext *C, 
wmSurface *surface)
 return;
   }
 
-  /* TODO_XR: Currently assumes that the XR surface is the
-   * same as the one for the runtime. In the future this
-   * might not always be the case. */
-  wmWindow *win = xr->runtime->session_root_win;
+  wmWindow *win = wm_xr_session_root_window_or_fallback_get(wm, xr->runtime);
   bScreen *screen = WM_window_get_active_screen(win);
 
-  /* some safety checks - these should always be set! */
   BLI_assert(WM_window_get_active_scene(win));
   BLI_assert(WM_window_get_active_screen(win));
   BLI_assert(WM_window_get_active_workspace(win));
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h 
b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
index 728c4345969..cbc78eb800e 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h
+++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
@@ -139,6 +139,8 @@ typedef struct wmXrAc

[Bf-blender-cvs] [ae609346ee9] master: Fix T81672: Array modifier default merge distance is 0.1m (typo)

2020-10-13 Thread Philipp Oeser
Commit: ae609346ee98e53d9038878b8d83205cc9b555ff
Author: Philipp Oeser
Date:   Tue Oct 13 13:40:05 2020 +0200
Branches: master
https://developer.blender.org/rBae609346ee98e53d9038878b8d83205cc9b555ff

Fix T81672: Array modifier default merge distance is 0.1m (typo)

Seems to be an oversight/typo in rB83980506957c.
Now set back to 0.01m (as it was before).

Maniphest Tasks: T81672

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

===

M   source/blender/makesdna/DNA_modifier_defaults.h

===

diff --git a/source/blender/makesdna/DNA_modifier_defaults.h 
b/source/blender/makesdna/DNA_modifier_defaults.h
index 41db7c914aa..3aca558cdbe 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -41,7 +41,7 @@
 .offset = {1.0f, 0.0f, 0.0f}, \
 .scale = {1.0f, 0.0f, 0.0f}, \
 .length = 0.0f, \
-.merge_dist = 0.1f, \
+.merge_dist = 0.01f, \
 .fit_type = MOD_ARR_FIXEDCOUNT, \
 .offset_type = MOD_ARR_OFF_RELATIVE, \
 .flags = 0, \

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


[Bf-blender-cvs] [3bb3b26c8fd] master: Cycles: Add CUDA 11 build support

2020-10-13 Thread Patrick Mours
Commit: 3bb3b26c8fdf44bf317a1dd16653f77ebe7757d8
Author: Patrick Mours
Date:   Tue Oct 13 12:33:34 2020 +0200
Branches: master
https://developer.blender.org/rB3bb3b26c8fdf44bf317a1dd16653f77ebe7757d8

Cycles: Add CUDA 11 build support

With this patch the build system checks whether the "CUDA10_NVCC_EXECUTABLE" 
CMake
variable is set and if so will use that to build sm_30 kernels. Similarily for 
sm_8x kernels it
checks "CUDA11_NVCC_EXECUTABLE". All other kernels are built using the default 
CUDA
toolkit. This makes it possible to use either the CUDA 10 or CUDA 11 toolkit by 
default and
only selectively use the other for the kernels where its a hard requirement.

Reviewed By: brecht

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

===

M   CMakeLists.txt
M   build_files/buildbot/worker_compile.py
M   build_files/cmake/config/blender_release.cmake
M   intern/cycles/CMakeLists.txt
M   intern/cycles/kernel/CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bcb9ab80097..9fe108c2ba2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -377,7 +377,7 @@ option(WITH_CYCLES_CUDA_BINARIES"Build Cycles CUDA 
binaries" OFF)
 option(WITH_CYCLES_CUBIN_COMPILER   "Build cubins with nvrtc based compiler 
instead of nvcc" OFF)
 option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful 
on machines with limited RAM)" OFF)
 mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
-set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 
sm_75 compute_75 CACHE STRING "CUDA architectures to build binaries for")
+set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 
sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for")
 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
 unset(PLATFORM_DEFAULT)
 option(WITH_CYCLES_LOGGING  "Build Cycles with logging support" ON)
diff --git a/build_files/buildbot/worker_compile.py 
b/build_files/buildbot/worker_compile.py
index e569a1cf568..266f9e65313 100644
--- a/build_files/buildbot/worker_compile.py
+++ b/build_files/buildbot/worker_compile.py
@@ -45,6 +45,18 @@ def get_cmake_options(builder):
 optix_sdk_dir = os.path.join(builder.blender_dir, '..', '..', 
'NVIDIA-Optix-SDK')
 options.append('-DOPTIX_ROOT_DIR:PATH=' + optix_sdk_dir)
 
+# Workaround to build sm_30 kernels with CUDA 10, since CUDA 11 no longer 
supports that architecture
+if builder.platform == 'win':
+options.append('-DCUDA10_TOOLKIT_ROOT_DIR:PATH=C:/Program Files/NVIDIA 
GPU Computing Toolkit/CUDA/v10.1')
+options.append('-DCUDA10_NVCC_EXECUTABLE:FILEPATH=C:/Program 
Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin/nvcc.exe')
+options.append('-DCUDA11_TOOLKIT_ROOT_DIR:PATH=C:/Program Files/NVIDIA 
GPU Computing Toolkit/CUDA/v11.1')
+options.append('-DCUDA11_NVCC_EXECUTABLE:FILEPATH=C:/Program 
Files/NVIDIA GPU Computing Toolkit/CUDA/v11.1/bin/nvcc.exe')
+elif builder.platform == 'linux':
+options.append('-DCUDA10_TOOLKIT_ROOT_DIR:PATH=/usr/local/cuda-10.1')
+
options.append('-DCUDA10_NVCC_EXECUTABLE:FILEPATH=/usr/local/cuda-10.1/bin/nvcc')
+options.append('-DCUDA11_TOOLKIT_ROOT_DIR:PATH=/usr/local/cuda-11.1')
+
options.append('-DCUDA11_NVCC_EXECUTABLE:FILEPATH=/usr/local/cuda-11.1/bin/nvcc')
+
 options.append("-C" + os.path.join(builder.blender_dir, config_file))
 options.append("-DCMAKE_INSTALL_PREFIX=%s" % (builder.install_dir))
 
diff --git a/build_files/cmake/config/blender_release.cmake 
b/build_files/cmake/config/blender_release.cmake
index e7e64678b40..f8f7b730efe 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -55,7 +55,7 @@ set(WITH_USD ON  CACHE BOOL "" FORCE)
 set(WITH_MEM_JEMALLOC  ON  CACHE BOOL "" FORCE)
 set(WITH_CYCLES_CUDA_BINARIES  ON  CACHE BOOL "" FORCE)
 set(WITH_CYCLES_CUBIN_COMPILER OFF CACHE BOOL "" FORCE)
-set(CYCLES_CUDA_BINARIES_ARCH 
sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61;sm_70;sm_75;compute_75 CACHE STRING 
"" FORCE)
+set(CYCLES_CUDA_BINARIES_ARCH 
sm_30;sm_35;sm_37;sm_50;sm_52;sm_60;sm_61;sm_70;sm_75;sm_86;compute_75 CACHE 
STRING "" FORCE)
 set(WITH_CYCLES_DEVICE_OPTIX   ON CACHE BOOL "" FORCE)
 
 # platform dependent options
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index c77018cc686..9d5b5a2d1a6 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -352,7 +352,7 @@ if(WITH_CYCLES_CUDA_BINARIES AND (NOT 
WITH_CYCLES_CUBIN_COMPILER))
   set(MAX_MSVC 1910)
 elseif(${CUDA_VERSION} EQUAL "9.1")
   set(MAX_MSVC 1911)
-elseif(${CUDA_VERSION} LESS "11.0")
+elseif(${CUDA_VERSION} VERSION_GREATER_EQUAL 10.0)
   set(MAX_MSVC 1999)
 endif()
 if(NOT MSVC_VERSION LESS ${MAX_MSVC

[Bf-blender-cvs] [c82d167d814] master: Cycles: fix missing ShaderNode ownership in render_graph_finalize_test

2020-10-13 Thread Kévin Dietrich
Commit: c82d167d814fee9dbf462c891282e1e35916e8c8
Author: Kévin Dietrich
Date:   Tue Oct 13 15:36:52 2020 +0200
Branches: master
https://developer.blender.org/rBc82d167d814fee9dbf462c891282e1e35916e8c8

Cycles: fix missing ShaderNode ownership in render_graph_finalize_test

===

M   intern/cycles/test/render_graph_finalize_test.cpp

===

diff --git a/intern/cycles/test/render_graph_finalize_test.cpp 
b/intern/cycles/test/render_graph_finalize_test.cpp
index f0d5804aee9..4639fc6d0dd 100644
--- a/intern/cycles/test/render_graph_finalize_test.cpp
+++ b/intern/cycles/test/render_graph_finalize_test.cpp
@@ -40,9 +40,9 @@ namespace {
 
 template class ShaderNodeBuilder {
  public:
-  ShaderNodeBuilder(const string &name) : name_(name)
+  ShaderNodeBuilder(ShaderGraph &graph, const string &name) : name_(name)
   {
-node_ = new T();
+node_ = graph.create_node();
 node_->name = name;
   }
 
@@ -121,8 +121,8 @@ class ShaderGraphBuilder {
   /* Common input/output boilerplate. */
   ShaderGraphBuilder &add_attribute(const string &name)
   {
-return (*this).add_node(
-ShaderNodeBuilder(name).set(&AttributeNode::attribute, 
ustring(name)));
+return (*this).add_node(ShaderNodeBuilder(*graph_, name)
+.set(&AttributeNode::attribute, 
ustring(name)));
   }
 
   ShaderGraphBuilder &output_closure(const string &from)
@@ -133,7 +133,7 @@ class ShaderGraphBuilder {
   ShaderGraphBuilder &output_color(const string &from)
   {
 return (*this)
-.add_node(ShaderNodeBuilder("EmissionNode"))
+.add_node(ShaderNodeBuilder(*graph_, "EmissionNode"))
 .add_connection(from, "EmissionNode::Color")
 .output_closure("EmissionNode::Emission");
   }
@@ -141,11 +141,16 @@ class ShaderGraphBuilder {
   ShaderGraphBuilder &output_value(const string &from)
   {
 return (*this)
-.add_node(ShaderNodeBuilder("EmissionNode"))
+.add_node(ShaderNodeBuilder(*graph_, "EmissionNode"))
 .add_connection(from, "EmissionNode::Strength")
 .output_closure("EmissionNode::Emission");
   }
 
+  ShaderGraph &graph()
+  {
+return *graph_;
+  }
+
  protected:
   ShaderGraph *graph_;
   map node_map_;
@@ -203,14 +208,15 @@ TEST_F(RenderGraph, deduplicate_deep)
   CORRECT_INFO_MESSAGE(log, "Folding Value2::Value to constant (0.8).");
   CORRECT_INFO_MESSAGE(log, "Deduplicated 2 nodes.");
 
-  builder.add_node(ShaderNodeBuilder("Geometry1"))
-  .add_node(ShaderNodeBuilder("Geometry2"))
-  .add_node(ShaderNodeBuilder("Value1").set(&ValueNode::value, 
0.8f))
-  .add_node(ShaderNodeBuilder("Value2").set(&ValueNode::value, 
0.8f))
-  .add_node(ShaderNodeBuilder("Noise1"))
-  .add_node(ShaderNodeBuilder("Noise2"))
-  .add_node(
-  ShaderNodeBuilder("Mix").set(&MixNode::type, 
NODE_MIX_BLEND).set("Fac", 0.5f))
+  builder.add_node(ShaderNodeBuilder(graph, "Geometry1"))
+  .add_node(ShaderNodeBuilder(graph, "Geometry2"))
+  .add_node(ShaderNodeBuilder(graph, 
"Value1").set(&ValueNode::value, 0.8f))
+  .add_node(ShaderNodeBuilder(graph, 
"Value2").set(&ValueNode::value, 0.8f))
+  .add_node(ShaderNodeBuilder(graph, "Noise1"))
+  .add_node(ShaderNodeBuilder(graph, "Noise2"))
+  .add_node(ShaderNodeBuilder(graph, "Mix")
+.set(&MixNode::type, NODE_MIX_BLEND)
+.set("Fac", 0.5f))
   .add_connection("Geometry1::Parametric", "Noise1::Vector")
   .add_connection("Value1::Value", "Noise1::Scale")
   .add_connection("Noise1::Color", "Mix::Color1")
@@ -235,7 +241,7 @@ TEST_F(RenderGraph, constant_fold_rgb_to_bw)
"Folding convert_float_to_color::value_color to 
constant (0.8, 0.8, 0.8).");
 
   builder
-  .add_node(ShaderNodeBuilder("RGBToBWNodeNode")
+  .add_node(ShaderNodeBuilder(graph, "RGBToBWNodeNode")
 .set("Color", make_float3(0.8f, 0.8f, 0.8f)))
   .output_color("RGBToBWNodeNode::Val");
 
@@ -252,8 +258,8 @@ TEST_F(RenderGraph, constant_fold_emission1)
   CORRECT_INFO_MESSAGE(log, "Discarding closure Emission.");
 
   builder
-  .add_node(
-  ShaderNodeBuilder("Emission").set("Color", 
make_float3(0.0f, 0.0f, 0.0f)))
+  .add_node(ShaderNodeBuilder(graph, "Emission")
+.set("Color", make_float3(0.0f, 0.0f, 0.0f)))
   .output_closure("Emission::Emission");
 
   graph.finalize(scene);
@@ -264,7 +270,7 @@ TEST_F(RenderGraph, constant_fold_emission2)
   EXPECT_ANY_MESSAGE(log);
   CORRECT_INFO_MESSAGE(log, "Discarding closure Emission.");
 
-  builder.add_node(ShaderNodeBuilder("Emission").set("Strength", 
0.0f))
+  builder.add_node(ShaderNodeBuilder(graph, 
"Emission").set("Strength", 0.0f))
   .output_closure("Emission::Emission");
 
   graph.finalize(scene);
@@ -280,7 +286,7 @@ TEST_F(RenderGraph, constant_fold_background

[Bf-blender-cvs] [48b52e06b0b] master: Cleanup: Remove unused properties from node Viewer Region operator

2020-10-13 Thread Julian Eisel
Commit: 48b52e06b0bd75c0f143fb53d87e29ece81ec2d1
Author: Julian Eisel
Date:   Tue Oct 13 15:43:21 2020 +0200
Branches: master
https://developer.blender.org/rB48b52e06b0bd75c0f143fb53d87e29ece81ec2d1

Cleanup: Remove unused properties from node Viewer Region operator

The operator would define the `deselect` and `extend` properties,
without actually using them. It's confusing to have them in the keymap
item UI.

===

M   source/blender/editors/space_node/node_edit.c

===

diff --git a/source/blender/editors/space_node/node_edit.c 
b/source/blender/editors/space_node/node_edit.c
index 894da811ed4..b1659bcd023 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2724,7 +2724,7 @@ void NODE_OT_viewer_border(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
   /* properties */
-  WM_operator_properties_gesture_box_select(ot);
+  WM_operator_properties_gesture_box(ot);
 }
 
 static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))

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


[Bf-blender-cvs] [dd3b047f8b4] master: Windows/CMake:Support BLENDER_USER_SCRIPTS in IDE

2020-10-13 Thread Eric Cosky
Commit: dd3b047f8b4d7aa2155fb9b3570f536240dbd06f
Author: Eric Cosky
Date:   Tue Oct 13 08:45:22 2020 -0600
Branches: master
https://developer.blender.org/rBdd3b047f8b4d7aa2155fb9b3570f536240dbd06f

Windows/CMake:Support BLENDER_USER_SCRIPTS in IDE

This diff adds support for respecting the `BLENDER_USER_SCRIPTS`
environment variable when setting up the IDE environment.

Previously the scripts from the users profile folder were always
used even when this variable was set, leading to the possibility
of the wrong scripts being visible in the IDE.

Differential Revision: https://developer.blender.org/D9189
Reviewed By: Ray Molenkamp

===

M   build_files/cmake/platform/platform_win32.cmake

===

diff --git a/build_files/cmake/platform/platform_win32.cmake 
b/build_files/cmake/platform/platform_win32.cmake
index 2dd8d5f4600..e7474b0035d 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -720,14 +720,24 @@ if(WINDOWS_PYTHON_DEBUG)
 string(REPLACE "/" "\\" _group_path "${_source_path}")
 source_group("${_group_path}" FILES "${_source}")
   endforeach()
-  # Include the user scripts from the profile folder in the 
blender_python_user_scripts project.
-  set(USER_SCRIPTS_ROOT "$ENV{appdata}/blender 
foundation/blender/${BLENDER_VERSION}")
+  
+  # If the user scripts env var is set, include scripts from there otherwise
+  # include user scripts in the profile folder.
+  if(DEFINED ENV{BLENDER_USER_SCRIPTS})
+message(STATUS "Including user scripts from environment 
BLENDER_USER_SCRIPTS=$ENV{BLENDER_USER_SCRIPTS}")
+set(USER_SCRIPTS_ROOT "$ENV{BLENDER_USER_SCRIPTS}")
+  else()
+message(STATUS "Including user scripts from the profile folder")
+# Include the user scripts from the profile folder in the 
blender_python_user_scripts project.
+set(USER_SCRIPTS_ROOT "$ENV{appdata}/blender 
foundation/blender/${BLENDER_VERSION}/scripts")
+  endif()
+  
   file(TO_CMAKE_PATH ${USER_SCRIPTS_ROOT} USER_SCRIPTS_ROOT)
-  FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/scripts/*.*" )
+  FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" )
   ADD_CUSTOM_TARGET(blender_python_user_scripts SOURCES ${inFiles})
   foreach(_source IN ITEMS ${inFiles})
 get_filename_component(_source_path "${_source}" PATH)
-string(REPLACE "${USER_SCRIPTS_ROOT}/scripts" "" _source_path 
"${_source_path}")
+string(REPLACE "${USER_SCRIPTS_ROOT}" "" _source_path "${_source_path}")
 string(REPLACE "/" "\\" _group_path "${_source_path}")
 source_group("${_group_path}" FILES "${_source}")
   endforeach()

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


[Bf-blender-cvs] [b7afcdff7b0] master: EEVEE: Motion Blur: Add shutter position option

2020-10-13 Thread Clément Foucault
Commit: b7afcdff7b068f668a3bfb032cf659693c8879f0
Author: Clément Foucault
Date:   Tue Oct 13 16:55:19 2020 +0200
Branches: master
https://developer.blender.org/rBb7afcdff7b068f668a3bfb032cf659693c8879f0

EEVEE: Motion Blur: Add shutter position option

This makes it easier to generate motion trail effect with EEVEE.

This just mimics the cycles option as described here:
https://docs.blender.org/manual/en/latest/render/cycles/render_settings/motion_blur.html

This fix T80070

===

M   release/scripts/startup/bl_ui/properties_render.py
M   source/blender/draw/engines/eevee/eevee_engine.c
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/release/scripts/startup/bl_ui/properties_render.py 
b/release/scripts/startup/bl_ui/properties_render.py
index 1c52001f32e..ae2a7a8ccb9 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -173,7 +173,9 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, 
Panel):
 
 layout.active = props.use_motion_blur
 col = layout.column()
+col.prop(props, "motion_blur_position", text="Position")
 col.prop(props, "motion_blur_shutter")
+col.separator()
 col.prop(props, "motion_blur_depth_scale")
 col.prop(props, "motion_blur_max")
 col.prop(props, "motion_blur_steps", text="Steps")
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c 
b/source/blender/draw/engines/eevee/eevee_engine.c
index 872cc3247d4..355d156a083 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -460,13 +460,27 @@ static void eevee_render_to_image(void *vedata,
 
   int initial_frame = CFRA;
   float initial_subframe = SUBFRA;
-  int steps = max_ii(1, scene->eevee.motion_blur_steps);
-  int time_steps_tot = (do_motion_blur) ? steps : 1;
+  float shuttertime = (do_motion_blur) ? scene->eevee.motion_blur_shutter : 
0.0f;
+  int time_steps_tot = (do_motion_blur) ? max_ii(1, 
scene->eevee.motion_blur_steps) : 1;
   g_data->render_tot_samples = divide_ceil_u(scene->eevee.taa_render_samples, 
time_steps_tot);
-  /* Centered on frame for now. */
-  float time = initial_frame + initial_subframe - 
scene->eevee.motion_blur_shutter / 2.0f;
+  /* Compute start time. The motion blur will cover `[time ...time + 
shuttertime]`. */
+  float time = initial_frame + initial_subframe;
+  switch (scene->eevee.motion_blur_position) {
+case SCE_EEVEE_MB_START:
+  /* No offset. */
+  break;
+case SCE_EEVEE_MB_CENTER:
+  time -= shuttertime * 0.5f;
+  break;
+case SCE_EEVEE_MB_END:
+  time -= shuttertime;
+  break;
+default:
+  BLI_assert(!"Invalid motion blur position enum!");
+  break;
+  }
 
-  float time_step = scene->eevee.motion_blur_shutter / time_steps_tot;
+  float time_step = shuttertime / time_steps_tot;
   for (int i = 0; i < time_steps_tot && !RE_engine_test_break(engine); i++) {
 float time_prev = time;
 float time_curr = time + time_step * 0.5f;
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index b4356ddebb7..0b63a085ee6 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1635,8 +1635,10 @@ typedef struct SceneEEVEE {
   int motion_blur_samples DNA_DEPRECATED;
   int motion_blur_max;
   int motion_blur_steps;
+  int motion_blur_position;
   float motion_blur_shutter;
   float motion_blur_depth_scale;
+  char _pad0[4];
 
   int shadow_method DNA_DEPRECATED;
   int shadow_cube_size;
@@ -2405,6 +2407,13 @@ enum {
   /* SHADOW_METHOD_MAX = 3, */ /* UNUSED */
 };
 
+/* SceneEEVEE->motion_blur_position */
+enum {
+  SCE_EEVEE_MB_CENTER = 0,
+  SCE_EEVEE_MB_START = 1,
+  SCE_EEVEE_MB_END = 2,
+};
+
 /* SceneDisplay->render_aa, SceneDisplay->viewport_aa */
 enum {
   SCE_DISPLAY_AA_OFF = 0,
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index b909885b006..24cff501b59 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -6851,6 +6851,17 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
   {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem eevee_motion_blur_position_items[] = {
+  {SCE_EEVEE_MB_START, "START", 0, "Start on Frame", "The shutter opens at 
the current frame"},
+  {SCE_EEVEE_MB_CENTER,
+   "CENTER",
+   0,
+   "Center on Frame",
+   "The shutter is open during the current frame"},
+  {SCE_EEVEE_MB_END, "END", 0, "End on Frame", "The shutter closes at the 
current frame"},
+  {0, NULL, 0, NULL, NULL},
+  };
+
   srna = RNA_def_struct(brna, "SceneEEVEE", NULL);
   RNA_def_struct_path_func

[Bf-blender-cvs] [ed96c59c20f] master: Fix T80086 EEVEE: Motion Blur: Subframe not taken into account

2020-10-13 Thread Clément Foucault
Commit: ed96c59c20fb5f69edc9671b4efbcd4bf7f61ffb
Author: Clément Foucault
Date:   Tue Oct 13 16:25:38 2020 +0200
Branches: master
https://developer.blender.org/rBed96c59c20fb5f69edc9671b4efbcd4bf7f61ffb

Fix T80086 EEVEE: Motion Blur: Subframe not taken into account

This is a simple fix that just make it work like cycles. The initial time
was missing the subframe offset.

===

M   source/blender/draw/engines/eevee/eevee_engine.c

===

diff --git a/source/blender/draw/engines/eevee/eevee_engine.c 
b/source/blender/draw/engines/eevee/eevee_engine.c
index 5d5bd7ea9ba..872cc3247d4 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -459,11 +459,13 @@ static void eevee_render_to_image(void *vedata,
   EEVEE_render_modules_init(vedata, engine, depsgraph);
 
   int initial_frame = CFRA;
+  float initial_subframe = SUBFRA;
   int steps = max_ii(1, scene->eevee.motion_blur_steps);
   int time_steps_tot = (do_motion_blur) ? steps : 1;
   g_data->render_tot_samples = divide_ceil_u(scene->eevee.taa_render_samples, 
time_steps_tot);
   /* Centered on frame for now. */
-  float time = CFRA - scene->eevee.motion_blur_shutter / 2.0f;
+  float time = initial_frame + initial_subframe - 
scene->eevee.motion_blur_shutter / 2.0f;
+
   float time_step = scene->eevee.motion_blur_shutter / time_steps_tot;
   for (int i = 0; i < time_steps_tot && !RE_engine_test_break(engine); i++) {
 float time_prev = time;
@@ -562,9 +564,9 @@ static void eevee_render_to_image(void *vedata,
   /* Restore original viewport size. */
   DRW_render_viewport_size_set((int[2]){g_data->size_orig[0], 
g_data->size_orig[1]});
 
-  if (CFRA != initial_frame) {
+  if (CFRA != initial_frame || SUBFRA != initial_subframe) {
 /* Restore original frame number. This is because the render pipeline 
expects it. */
-RE_engine_frame_set(engine, initial_frame, 0.0f);
+RE_engine_frame_set(engine, initial_frame, initial_subframe);
   }
 }

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


[Bf-blender-cvs] [9fe58175885] master: UI: Monochrome Alert Icons not changing color until theme refresh

2020-10-13 Thread Harley Acheson
Commit: 9fe581758851c98a8e43f0e8a02d70551352682d
Author: Harley Acheson
Date:   Tue Oct 13 09:35:46 2020 -0700
Branches: master
https://developer.blender.org/rB9fe581758851c98a8e43f0e8a02d70551352682d

UI: Monochrome Alert Icons not changing color until theme refresh

Changing the color of monochrome alert icons would not change until the theme 
was reloaded.

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

Reviewed by Harley Acheson

===

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

===

diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 83e47ce9f07..94b93c11f6c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -4706,9 +4706,8 @@ uiBut *uiDefButImage(
 uiBut *uiDefButAlert(uiBlock *block, int icon, int x, int y, short width, 
short height)
 {
   struct ImBuf *ibuf = UI_icon_alert_imbuf_get(icon);
-  uchar icon_color[4];
-  UI_GetThemeColor4ubv(TH_TEXT, icon_color);
-  return uiDefButImage(block, ibuf, x, y, width, height, icon_color);
+  bTheme *btheme = UI_GetTheme();
+  return uiDefButImage(block, ibuf, x, y, width, height, 
btheme->tui.wcol_menu_back.text);
 }
 
 /**

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


[Bf-blender-cvs] [96dd299055a] master: UI: Add highlight arguments to tab buttons

2020-10-13 Thread Hans Goudey
Commit: 96dd299055a1ce35819480f3c4b938f8e6f91537
Author: Hans Goudey
Date:   Tue Oct 13 12:43:28 2020 -0500
Branches: master
https://developer.blender.org/rB96dd299055a1ce35819480f3c4b938f8e6f91537

UI: Add highlight arguments to tab buttons

This adds arguments to `uiLayout.prop_tabs_enum` and the C equivalent
(`uiItemTabsEnumR_prop`) to gray out tabs based on a boolean array.

For property search in multiple tabs, we need a way to show which tabs
have a search result, but we still need to show which tab is active.

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

===

M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/interface/interface_layout.c
M   source/blender/makesrna/intern/rna_ui_api.c

===

diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index bdec5ef3858..94095d04271 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2429,6 +2429,8 @@ void uiItemTabsEnumR_prop(uiLayout *layout,
   struct bContext *C,
   struct PointerRNA *ptr,
   PropertyRNA *prop,
+  struct PointerRNA *ptr_highlight,
+  PropertyRNA *prop_highlight,
   bool icon_only);
 
 /* Only for testing, inspecting layouts. */
diff --git a/source/blender/editors/interface/interface_layout.c 
b/source/blender/editors/interface/interface_layout.c
index b13dd24ea4b..98b1c020d95 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -886,6 +886,8 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
  uiBlock *block,
  PointerRNA *ptr,
  PropertyRNA *prop,
+ PointerRNA *ptr_highlight,
+ PropertyRNA *prop_highlight,
  const char *uiname,
  const int h,
  const bool icon_only)
@@ -894,9 +896,24 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
 
   ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, 
icon_only);
   BLI_assert(last != block->buttons.last);
+
   for (uiBut *tab = last ? last->next : block->buttons.first; tab; tab = 
tab->next) {
 UI_but_drawflag_enable(tab, 
ui_but_align_opposite_to_area_align_get(CTX_wm_region(C)));
   }
+
+  const bool use_custom_highlight = (prop_highlight != NULL);
+
+  if (use_custom_highlight) {
+const int highlight_array_len = RNA_property_array_length(ptr_highlight, 
prop_highlight);
+bool *highlight_array = alloca(sizeof(bool) * highlight_array_len);
+RNA_property_boolean_get_array(ptr_highlight, prop_highlight, 
highlight_array);
+int i = 0;
+for (uiBut *tab_but = last ? last->next : block->buttons.first;
+ (tab_but != NULL) && (i < highlight_array_len);
+ tab_but = tab_but->next, i++) {
+  SET_FLAG_FROM_TEST(tab_but->flag, !highlight_array[i], UI_BUT_INACTIVE);
+}
+  }
 }
 
 /* callback for keymap item change button */
@@ -3474,13 +3491,19 @@ void uiItemMenuEnumR(
   uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
 }
 
-void uiItemTabsEnumR_prop(
-uiLayout *layout, bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool 
icon_only)
+void uiItemTabsEnumR_prop(uiLayout *layout,
+  bContext *C,
+  PointerRNA *ptr,
+  PropertyRNA *prop,
+  PointerRNA *ptr_highlight,
+  PropertyRNA *prop_highlight,
+  bool icon_only)
 {
   uiBlock *block = layout->root->block;
 
   UI_block_layout_set_current(block, layout);
-  ui_item_enum_expand_tabs(layout, C, block, ptr, prop, NULL, UI_UNIT_Y, 
icon_only);
+  ui_item_enum_expand_tabs(
+  layout, C, block, ptr, prop, ptr_highlight, prop_highlight, NULL, 
UI_UNIT_Y, icon_only);
 }
 
 /** \} */
diff --git a/source/blender/makesrna/intern/rna_ui_api.c 
b/source/blender/makesrna/intern/rna_ui_api.c
index 47d9e3e146a..447f5b4210b 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -216,8 +216,13 @@ static void rna_uiItemMenuEnumR(uiLayout *layout,
   uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
 }
 
-static void rna_uiItemTabsEnumR(
-uiLayout *layout, bContext *C, struct PointerRNA *ptr, const char 
*propname, bool icon_only)
+static void rna_uiItemTabsEnumR(uiLayout *layout,
+bContext *C,
+struct PointerRNA *ptr,
+   

[Bf-blender-cvs] [7c633686e99] master: Property Search: Find results in all tabs

2020-10-13 Thread Hans Goudey
Commit: 7c633686e99512d33391f30e4602213ed3890802
Author: Hans Goudey
Date:   Tue Oct 13 13:10:41 2020 -0500
Branches: master
https://developer.blender.org/rB7c633686e99512d33391f30e4602213ed3890802

Property Search: Find results in all tabs

This patch enables property search for all tabs in the property editor.
To make interaction faster, if the editor's current tab doesn't have a
result, the current tab changes to the next tab that has a match.

This patch implements basic code that only searches panels.
While we could run the existing "single tab" property search for every
tab, that would also do everything else related to the layout pass,
which would be less efficient, and maybe more complicated to maintain.

The search match status for every current tab of the property editor is
stored in a runtime bitfield and them displayed later by dimming icons
in the tab selector panel to the left. Using `BLI_bitmap` properly in
the runtime struct required moving it to `buttons_intern.h` and
adding a small API to access the search filter instead.

To make sure the editor isn't influenced by anything that happens while
building the layout for other tabs, most of the context is duplicated
and the new search is run in the duplicated editor.

Note that the tool settings tab works slightly different than the other
tabs, so I've disabled searching it for this commit. That would be a
relatively simple improvement, but would just require a bit of
refactoring of existing code.

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

===

M   release/scripts/startup/bl_ui/space_properties.py
M   source/blender/editors/include/ED_buttons.h
M   source/blender/editors/include/ED_screen.h
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/interface/interface_layout.c
M   source/blender/editors/screen/area.c
M   source/blender/editors/space_buttons/buttons_intern.h
M   source/blender/editors/space_buttons/space_buttons.c
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_properties.py 
b/release/scripts/startup/bl_ui/space_properties.py
index ff25b8cd2fa..fe5057bed5d 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -53,7 +53,11 @@ class PROPERTIES_PT_navigation_bar(Panel):
 
 layout.scale_x = 1.4
 layout.scale_y = 1.4
-layout.prop_tabs_enum(view, "context", icon_only=True)
+if view.search_filter:
+layout.prop_tabs_enum(view, "context", data_highlight=view,
+property_highlight="tab_search_results", icon_only=True)
+else:
+layout.prop_tabs_enum(view, "context", icon_only=True)
 
 
 classes = (
diff --git a/source/blender/editors/include/ED_buttons.h 
b/source/blender/editors/include/ED_buttons.h
index a4cd2525af3..5d153757900 100644
--- a/source/blender/editors/include/ED_buttons.h
+++ b/source/blender/editors/include/ED_buttons.h
@@ -29,6 +29,11 @@ extern "C" {
 struct SpaceProperties;
 
 int ED_buttons_tabs_list(struct SpaceProperties *sbuts, short 
*context_tabs_array);
+bool ED_buttons_tab_has_search_result(struct SpaceProperties *sbuts, const int 
index);
+
+void ED_buttons_search_string_set(struct SpaceProperties *sbuts, const char 
*value);
+int ED_buttons_search_string_length(struct SpaceProperties *sbuts);
+const char *ED_buttons_search_string_get(struct SpaceProperties *sbuts);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/editors/include/ED_screen.h 
b/source/blender/editors/include/ED_screen.h
index 53554e3f34c..b8500ba0c37 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -92,6 +92,11 @@ void ED_region_panels_layout_ex(const struct bContext *C,
 struct ListBase *paneltypes,
 const char *contexts[],
 const char *category_override);
+bool ED_region_property_search(const struct bContext *C,
+   struct ARegion *region,
+   struct ListBase *paneltypes,
+   const char *contexts[],
+   const char *category_override);
 
 void ED_region_panels_layout(const struct bContext *C, struct ARegion *region);
 void ED_region_panels_draw(const struct bContext *C, struct ARegion *region);
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 94095d04271..2c8518de700 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1874,6 +1874,7 @@ uiLayout *UI_block_layout(uiBlock *block,
   const 

[Bf-blender-cvs] [be3841b1bf5] master: Cleanup: Use doxygen sections in space_buttons.c

2020-10-13 Thread Hans Goudey
Commit: be3841b1bf5f10acd1163189b689de1f1dd6d86c
Author: Hans Goudey
Date:   Tue Oct 13 13:23:57 2020 -0500
Branches: master
https://developer.blender.org/rBbe3841b1bf5f10acd1163189b689de1f1dd6d86c

Cleanup: Use doxygen sections in space_buttons.c

===

M   source/blender/editors/space_buttons/space_buttons.c

===

diff --git a/source/blender/editors/space_buttons/space_buttons.c 
b/source/blender/editors/space_buttons/space_buttons.c
index e7f057683ab..14817a8ce23 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -54,7 +54,9 @@
 
 #include "buttons_intern.h" /* own include */
 
-/*  default callbacks for buttons space * 
*/
+/*  */
+/** \name Default Callbacks for Properties Space
+ * \{ */
 
 static SpaceLink *buttons_create(const ScrArea *UNUSED(area), const Scene 
*UNUSED(scene))
 {
@@ -158,6 +160,12 @@ static void buttons_main_region_init(wmWindowManager *wm, 
ARegion *region)
   WM_event_add_keymap_handler(®ion->handlers, keymap);
 }
 
+/** \} */
+
+/*  */
+/** \name Property Editor Layout
+ * \{ */
+
 /**
  * Fills an array with the tab context values for the properties editor. -1 
signals a separator.
  *
@@ -305,6 +313,12 @@ static void buttons_main_region_layout_properties(const 
bContext *C,
   ED_region_panels_layout_ex(C, region, ®ion->type->paneltypes, contexts, 
NULL);
 }
 
+/** \} */
+
+/*  */
+/** \name Property Search Access API
+ * \{ */
+
 const char *ED_buttons_search_string_get(SpaceProperties *sbuts)
 {
   return sbuts->runtime->search_string;
@@ -325,6 +339,12 @@ bool ED_buttons_tab_has_search_result(SpaceProperties 
*sbuts, const int index)
   return BLI_BITMAP_TEST(sbuts->runtime->tab_search_results, index);
 }
 
+/** \} */
+
+/*  */
+/** \name "Off Screen" Layout Generation for Property Search
+ * \{ */
+
 static bool property_search_for_context(const bContext *C, ARegion *region, 
SpaceProperties *sbuts)
 {
   const char *contexts[2] = {buttons_main_region_context_string(sbuts->mainb), 
NULL};
@@ -462,6 +482,12 @@ static void buttons_main_region_property_search(const 
bContext *C,
   }
 }
 
+/** \} */
+
+/*  */
+/** \name Main Region Layout and Listener
+ * \{ */
+
 static void buttons_main_region_layout(const bContext *C, ARegion *region)
 {
   /* draw entirely, view changes should be handled here */
@@ -512,6 +538,12 @@ static void buttons_keymap(struct wmKeyConfig *keyconf)
   WM_keymap_ensure(keyconf, "Property Editor", SPACE_PROPERTIES, 0);
 }
 
+/** \} */
+
+/*  */
+/** \name Header Region Callbacks
+ * \{ */
+
 /* add handlers, stuff you only do once or on area/region changes */
 static void buttons_header_region_init(wmWindowManager *UNUSED(wm), ARegion 
*region)
 {
@@ -556,6 +588,12 @@ static void buttons_header_region_message_subscribe(const 
bContext *UNUSED(C),
   }
 }
 
+/** \} */
+
+/*  */
+/** \name Navigation Region Callbacks
+ * \{ */
+
 static void buttons_navigation_bar_region_init(wmWindowManager *wm, ARegion 
*region)
 {
   region->flag |= RGN_FLAG_PREFSIZE_OR_HIDDEN;
@@ -605,6 +643,12 @@ static void buttons_area_redraw(ScrArea *area, short 
buttons)
   }
 }
 
+/** \} */
+
+/*  */
+/** \name Area-Level Code
+ * \{ */
+
 /* reused! */
 static void buttons_area_listener(wmWindow *UNUSED(win),
   ScrArea *area,
@@ -860,6 +904,12 @@ static void buttons_id_remap(ScrArea *UNUSED(area), 
SpaceLink *slink, ID *old_id
   }
 }
 
+/** \} */
+
+/*  */
+/** \name Space Type Initialization
+ * \{ */
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_buttons(void)
 {
@@ -938,3 +988,5 @@ void ED_spacetype_buttons(void)
 
   BKE_spacetype_register(st);
 }
+
+/** \} */

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


[Bf-blender-cvs] [a36f02f9ba9] master: Fix (unreported) LibOverride: possible uninitialized return variable.

2020-10-13 Thread Bastien Montagne
Commit: a36f02f9ba9877a12dc5b453a348d01cd89f46c0
Author: Bastien Montagne
Date:   Tue Oct 13 20:36:38 2020 +0200
Branches: master
https://developer.blender.org/rBa36f02f9ba9877a12dc5b453a348d01cd89f46c0

Fix (unreported) LibOverride: possible uninitialized return variable.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c 
b/source/blender/makesrna/intern/rna_access_compare_override.c
index 098854513a4..202864a7d82 100644
--- a/source/blender/makesrna/intern/rna_access_compare_override.c
+++ b/source/blender/makesrna/intern/rna_access_compare_override.c
@@ -1160,6 +1160,10 @@ IDOverrideLibraryProperty 
*RNA_property_override_property_get(Main *bmain,
   ID *id;
   char *rna_path;
 
+  if (r_created != NULL) {
+*r_created = false;
+  }
+
   if ((rna_path = rna_property_override_property_real_id_owner(bmain, ptr, 
prop, &id)) != NULL) {
 IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get(
 id->override_library, rna_path, r_created);
@@ -1198,6 +1202,10 @@ IDOverrideLibraryPropertyOperation 
*RNA_property_override_property_operation_get
 bool *r_strict,
 bool *r_created)
 {
+  if (r_created != NULL) {
+*r_created = false;
+  }
+
   IDOverrideLibraryProperty *op = RNA_property_override_property_get(bmain, 
ptr, prop, NULL);
 
   if (!op) {

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


[Bf-blender-cvs] [72cfeb2c4ee] master: Fix T81674: LibOverride: 'Define Override' UI operation can crash.

2020-10-13 Thread Bastien Montagne
Commit: 72cfeb2c4ee38eb53b805ac775b5809b1df65660
Author: Bastien Montagne
Date:   Tue Oct 13 20:34:18 2020 +0200
Branches: master
https://developer.blender.org/rB72cfeb2c4ee38eb53b805ac775b5809b1df65660

Fix T81674: LibOverride: 'Define Override' UI operation can crash.

Case where RNA is not able to generate a proper path for a property was
not taken into account properly.

===

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

===

diff --git a/source/blender/editors/interface/interface_ops.c 
b/source/blender/editors/interface/interface_ops.c
index c9f21c7fc2e..4cb8a47690e 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -558,6 +558,13 @@ static int override_type_set_button_exec(bContext *C, 
wmOperator *op)
 
   IDOverrideLibraryPropertyOperation *opop = 
RNA_property_override_property_operation_get(
   CTX_data_main(C), &ptr, prop, operation, index, true, NULL, &created);
+
+  if (opop == NULL) {
+/* Sometimes e.g. RNA cannot generate a path to the given property. */
+BKE_reportf(op->reports, RPT_WARNING, "Failed to create the override 
operation");
+return OPERATOR_CANCELLED;
+  }
+
   if (!created) {
 opop->operation = operation;
   }

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


[Bf-blender-cvs] [9722e369cd4] master: UI: Motion Tracking: Make Lens a subpanel of Camera

2020-10-13 Thread Aaron Carlisle
Commit: 9722e369cd42532bc41c6ad884c71d88a8f547a9
Author: Aaron Carlisle
Date:   Tue Oct 13 14:38:34 2020 -0400
Branches: master
https://developer.blender.org/rB9722e369cd42532bc41c6ad884c71d88a8f547a9

UI: Motion Tracking: Make Lens a subpanel of Camera

The camera presets control lens settings too so these setting should be 
part of the camera panel.

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_clip.py 
b/release/scripts/startup/bl_ui/space_clip.py
index 93bc0c7b535..a23dfae55b7 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -879,6 +879,7 @@ class CLIP_PT_tracking_lens(Panel):
 bl_region_type = 'UI'
 bl_category = "Track"
 bl_label = "Lens"
+bl_parent_id = 'CLIP_PT_tracking_camera'
 bl_options = {'DEFAULT_CLOSED'}
 
 @classmethod

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


[Bf-blender-cvs] [ec9edd36ca1] master: Sculpt: Use plasticity for softbody influence

2020-10-13 Thread Pablo Dobarro
Commit: ec9edd36ca1f8f73373435a7941abff77df53719
Author: Pablo Dobarro
Date:   Mon Oct 12 23:24:45 2020 +0200
Branches: master
https://developer.blender.org/rBec9edd36ca1f8f73373435a7941abff77df53719

Sculpt: Use plasticity for softbody influence

Previously the softbody strength property was controlling the strength
of the constraints that pin all vertices to the original location. This
was causing problems when the forces were trying to deform the vertices
too much, like when using gravity or grab brushes.

Now softbody is implemented with plasticity, which creates constraints to
a separate coordinates array. These coordinates are deformed with the
simulation, and the plasticity parameter controls how much the
simulation moves the coordinates (plasticity 0), or the coordinates move
the simulation back to its previous position (plasticity 1).

This creates much better and predictable results and adding softbody
plasticity to the brushes can increase its control and the stability of
the simulation.

Reviewed By: sergey, zeddb

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

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_cloth.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/makesrna/intern/rna_brush.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index a7a837406ac..64910e5f1a9 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -272,8 +272,11 @@ typedef enum eSculptClothConstraintType {
   /* Constraint that references the position of a vertex and a position in 
deformation_pos which
  can be deformed by the tools. */
   SCULPT_CLOTH_CONSTRAINT_DEFORMATION = 1,
-  /* Constarint that references the vertex position and its initial position. 
*/
+  /* Constarint that references the vertex position and a editable softbody 
position for
+ plasticity. */
   SCULPT_CLOTH_CONSTRAINT_SOFTBODY = 2,
+  /* Constarint that references the vertex position and its initial position. 
*/
+  SCULPT_CLOTH_CONSTRAINT_PIN = 3,
 } eSculptClothConstraintType;
 
 typedef struct SculptClothLengthConstraint {
@@ -314,10 +317,12 @@ typedef struct SculptClothSimulation {
 
   float mass;
   float damping;
+  float softbody_strength;
 
   float (*acceleration)[3];
   float (*pos)[3];
   float (*init_pos)[3];
+  float (*softbody_pos)[3];
   float (*prev_pos)[3];
   float (*last_iteration_pos)[3];
 
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 39b675de3c0..c4c9db69dcd 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5747,7 +5747,8 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush 
*brush, UnifiedPaintSe
 
 if (brush->deform_target == BRUSH_DEFORM_TARGET_CLOTH_SIM) {
   if (!ss->cache->cloth_sim) {
-ss->cache->cloth_sim = SCULPT_cloth_brush_simulation_create(ss, 1.0f, 
0.0f, false, true);
+ss->cache->cloth_sim = SCULPT_cloth_brush_simulation_create(
+ss, 1.0f, 0.0f, 0.0f, false, true);
 SCULPT_cloth_brush_simulation_init(ss, ss->cache->cloth_sim);
   }
   SCULPT_cloth_brush_store_simulation_state(ss, ss->cache->cloth_sim);
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c 
b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 2bca5e2e1f0..84d156122f3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -229,7 +229,7 @@ static void 
cloth_brush_add_softbody_constraint(SculptClothSimulation *cloth_sim
   length_constraint->node = node_index;
 
   length_constraint->elem_position_a = cloth_sim->pos[v];
-  length_constraint->elem_position_b = cloth_sim->init_pos[v];
+  length_constraint->elem_position_b = cloth_sim->softbody_pos[v];
 
   length_constraint->type = SCULPT_CLOTH_CONSTRAINT_SOFTBODY;
 
@@ -242,6 +242,33 @@ static void 
cloth_brush_add_softbody_constraint(SculptClothSimulation *cloth_sim
   cloth_brush_reallocate_constraints(cloth_sim);
 }
 
+static void cloth_brush_add_pin_constraint(SculptClothSimulation *cloth_sim,
+   const int node_index,
+   const int v,
+   const float strength)
+{
+  SculptClothLengthConstraint *length_constraint =
+  &cloth_sim->length_constraints[cloth_sim->tot_length_constraints];
+
+  length_constraint->elem_index_a = v;
+  length_constraint->elem_index_b = v;
+
+  length_constraint->node = node_index;
+
+  length_constraint->elem_position_a = cloth_sim->pos[v];
+  length_constraint->elem_position_b = cloth_sim->init_po

[Bf-blender-cvs] [5f49f818d62] master: Fixes T81670: Sculpt paint vertex colors brush does not switch to secondary color using CTRL

2020-10-13 Thread Philipp Oeser
Commit: 5f49f818d6282a2f421f454bb32b2a6b2c9a0a0d
Author: Philipp Oeser
Date:   Tue Oct 13 15:33:03 2020 +0200
Branches: master
https://developer.blender.org/rB5f49f818d6282a2f421f454bb32b2a6b2c9a0a0d

Fixes T81670: Sculpt paint vertex colors brush does not switch to secondary 
color using CTRL

This was just not implemented. Now make this consistent with
vertexpainting / texturepainting.

Maniphest Tasks: T81670

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

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c 
b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
index 000b7afdf55..f0047448a8d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
@@ -133,7 +133,9 @@ static void do_paint_brush_task_cb_ex(void *__restrict 
userdata,
   const int thread_id = BLI_task_parallel_thread_id(tls);
 
   float brush_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
-  copy_v3_v3(brush_color, BKE_brush_color_get(ss->scene, brush));
+  copy_v3_v3(brush_color,
+ ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, 
brush) :
+ BKE_brush_color_get(ss->scene, brush));
   IMB_colormanagement_srgb_to_scene_linear_v3(brush_color);
 
   BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)

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


[Bf-blender-cvs] [2cc7be3e490] master: Fluid: Removed fluid levelset argument from pressure solve

2020-10-13 Thread Sebastián Barschkis
Commit: 2cc7be3e4907a0f9ed508b278cae987b35b2f503
Author: Sebastián Barschkis
Date:   Wed Oct 14 00:25:32 2020 +0200
Branches: master
https://developer.blender.org/rB2cc7be3e4907a0f9ed508b278cae987b35b2f503

Fluid: Removed fluid levelset argument from pressure solve

It seems that this was causing the instabilities at slanted obstacles (with 
secondary boundary (fractional) collisions enabled) ...

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index 71f55a1d336..6e78fce1d61 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -304,7 +304,7 @@ def liquid_step_$ID$():\n\
 PD_fluid_guiding(vel=vel_s$ID$, velT=velT_s$ID$, flags=flags_s$ID$, 
phi=phi_s$ID$, curv=curvature_s$ID$, surfTens=surfaceTension_s$ID$, 
fractions=fractions_s$ID$, weight=weightGuide_s$ID$, blurRadius=beta_sg$ID$, 
pressure=pressure_s$ID$, tau=tau_sg$ID$, sigma=sigma_sg$ID$, 
theta=theta_sg$ID$, zeroPressureFixing=domainClosed_s$ID$)\n\
 else:\n\
 mantaMsg('Pressure')\n\
-solvePressure(flags=flags_s$ID$, vel=vel_s$ID$, 
pressure=pressure_s$ID$, phi=phi_s$ID$, curv=curvature_s$ID$, 
surfTens=surfaceTension_s$ID$, fractions=fractions_s$ID$, obvel=obvel_s$ID$ if 
using_fractions_s$ID$ else None, zeroPressureFixing=domainClosed_s$ID$)\n\
+solvePressure(flags=flags_s$ID$, vel=vel_s$ID$, 
pressure=pressure_s$ID$, curv=curvature_s$ID$, surfTens=surfaceTension_s$ID$, 
fractions=fractions_s$ID$, obvel=obvel_s$ID$ if using_fractions_s$ID$ else 
None, zeroPressureFixing=domainClosed_s$ID$)\n\
 \n\
 extrapolateMACSimple(flags=flags_s$ID$, vel=vel_s$ID$, distance=4, 
intoObs=True if using_fractions_s$ID$ else False)\n\
 setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=None if 
using_fractions_s$ID$ else obvel_s$ID$, phiObs=phiObs_s$ID$, 
fractions=fractions_s$ID$)\n\

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


[Bf-blender-cvs] [2ec07dfa182] master: Fluid: Update Mantaflow source files

2020-10-13 Thread Sebastián Barschkis
Commit: 2ec07dfa182d4503ccf3930406e8c7b239751e18
Author: Sebastián Barschkis
Date:   Tue Oct 13 21:36:14 2020 +0200
Branches: master
https://developer.blender.org/rB2ec07dfa182d4503ccf3930406e8c7b239751e18

Fluid: Update Mantaflow source files

Updated files includes:
- Fix for smoke / fire emission from particles
- Custom precision for liquid particles when saving in OpenVDB format

===

M   extern/mantaflow/preprocessed/fileio/iovdb.cpp
M   extern/mantaflow/preprocessed/fileio/mantaio.cpp
M   extern/mantaflow/preprocessed/fileio/mantaio.h
M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/plugin/initplugins.cpp
M   extern/mantaflow/preprocessed/python/defines.py.reg.cpp

===

diff --git a/extern/mantaflow/preprocessed/fileio/iovdb.cpp 
b/extern/mantaflow/preprocessed/fileio/iovdb.cpp
index b990274e1c4..287c78f0608 100644
--- a/extern/mantaflow/preprocessed/fileio/iovdb.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iovdb.cpp
@@ -60,7 +60,7 @@ template void importVDB(typename 
GridType::Ptr from, Gr
 template
 void importVDB(VDBType vdbValue, ParticleDataImpl *to, int index, float 
voxelSize)
 {
-  (void)voxelSize;  // Unused
+  unusedParameter(voxelSize);  // Unused for now
   T toMantaValue;
   convertFrom(vdbValue, &toMantaValue);
   to->set(index, toMantaValue);
@@ -165,12 +165,12 @@ static void setGridOptions(typename GridType::Ptr grid,
string name,
openvdb::GridClass cls,
float voxelSize,
-   bool precisionHalf)
+   int precision)
 {
   
grid->setTransform(openvdb::math::Transform::createLinearTransform(voxelSize));
   grid->setGridClass(cls);
   grid->setName(name);
-  grid->setSaveFloatAsHalf(precisionHalf);
+  grid->setSaveFloatAsHalf(precision == PRECISION_MINI || precision == 
PRECISION_HALF);
 }
 
 template typename GridType::Ptr exportVDB(Grid 
*from)
@@ -194,7 +194,8 @@ template
 void exportVDB(ParticleDataImpl *from,
openvdb::points::PointDataGrid::Ptr to,
openvdb::tools::PointIndexGrid::Ptr pIndex,
-   bool skipDeletedParts)
+   bool skipDeletedParts,
+   int precision)
 {
   std::vector vdbValues;
   std::string name = from->getName();
@@ -212,8 +213,21 @@ void exportVDB(ParticleDataImpl *from,
 vdbValues.push_back(vdbValue);
   }
 
-  openvdb::NamePair attribute =
-  openvdb::points::TypedAttributeArray::attributeType();
+  // Use custom codec for precision of the attribute
+  openvdb::NamePair attribute;
+  if (precision == PRECISION_FULL) {
+attribute =
+openvdb::points::TypedAttributeArray::attributeType();
+  }
+  else if (precision == PRECISION_HALF ||
+   precision == PRECISION_MINI) {  // Mini uses same precision as half 
for now
+attribute =
+openvdb::points::TypedAttributeArray::attributeType();
+  }
+  else {
+errMsg("exportVDB: invalid precision level");
+  }
   openvdb::points::appendAttribute(to->tree(), name, attribute);
 
   // Create a wrapper around the vdb values vector.
@@ -229,7 +243,8 @@ void exportVDB(ParticleDataImpl *from,
 openvdb::points::PointDataGrid::Ptr exportVDB(BasicParticleSystem *from,
   std::vector 
&fromPData,
   bool skipDeletedParts,
-  float voxelSize)
+  float voxelSize,
+  int precision)
 {
   std::vector positions;
   std::vector flags;
@@ -257,16 +272,34 @@ openvdb::points::PointDataGrid::Ptr 
exportVDB(BasicParticleSystem *from,
   
openvdb::tools::createPointIndexGrid(positionsWrapper,

*transform);
 
-  // TODO (sebbas): Use custom codec for attributes?
-  // using Codec = openvdb::points::FixedPointCodec;
-  openvdb::points::PointDataGrid::Ptr to =
-  openvdb::points::createPointDataGrid(
-  *pointIndexGrid, positionsWrapper, *transform);
+  openvdb::points::PointDataGrid::Ptr to;
+  openvdb::NamePair flagAttribute;
+
+  using CodecNull = openvdb::points::NullCodec;
+  using CodecTrunc = openvdb::points::TruncateCodec;
+  using CodecFixPoint = openvdb::points::FixedPointCodec;
+
+  // Use custom codec for precision of the particle position and the flag 
attribute
+  if (precision == PRECISION_FULL) {
+to = openvdb::points::createPointDataGrid(
+*pointIndexGrid, positionsWrapper, *transform);
+flagAttribute = openvdb::points::TypedAttributeArray::attributeType();
+  }
+  else if (precision == PRECISION_HALF) {
+to = openvdb::points::createPointDataGrid(
+*pointIndexGrid, positionsWrapper, *t

[Bf-blender-cvs] [3d1b5e35bdd] master: Fluid: Enabled OpenVDB precision argument

2020-10-13 Thread Sebastián Barschkis
Commit: 3d1b5e35bddb9e54257021b2f2d610fbf5f0814b
Author: Sebastián Barschkis
Date:   Tue Oct 13 21:46:52 2020 +0200
Branches: master
https://developer.blender.org/rB3d1b5e35bddb9e54257021b2f2d610fbf5f0814b

Fluid: Enabled OpenVDB precision argument

This way particles can be saved with the custom OpenVDB precision options that 
were introduced in the latest Mantaflow update.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   source/blender/makesdna/DNA_fluid_types.h
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index cc702b82151..ef7cd4721b0 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -740,11 +740,13 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd)
   else if (fds->openvdb_compression == VDB_COMPRESSION_BLOSC)
 vdbCompressionMethod = "Compression_Blosc";
 
-  string vdbPrecisionHalf = "True";
-  if (fds->openvdb_data_depth == VDB_PRECISION_HALF_FLOAT)
-vdbPrecisionHalf = "True";
-  else if (fds->openvdb_data_depth == VDB_PRECISION_FULL_FLOAT)
-vdbPrecisionHalf = "False";
+  string vdbPrecisionHalf = "Precision_Half";
+  if (fds->openvdb_data_depth == VDB_PRECISION_FULL_FLOAT)
+vdbPrecisionHalf = "Precision_Full";
+  else if (fds->openvdb_data_depth == VDB_PRECISION_HALF_FLOAT)
+vdbPrecisionHalf = "Precision_Half";
+  else if (fds->openvdb_data_depth == VDB_PRECISION_MINI_FLOAT)
+vdbPrecisionHalf = "Precision_Mini";
 
   mRNAMap["USING_SMOKE"] = getBooleanString(fds->type == 
FLUID_DOMAIN_TYPE_GAS);
   mRNAMap["USING_LIQUID"] = getBooleanString(fds->type == 
FLUID_DOMAIN_TYPE_LIQUID);
diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index 65773221042..9e723f69c70 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -165,7 +165,7 @@ gravity_s$ID$ *= scaleAcceleration_s$ID$ # scale from world 
acceleration to cell
 \n\
 # OpenVDB options\n\
 vdbCompression_s$ID$ = $COMPRESSION_OPENVDB$\n\
-vdbPrecisionHalf_s$ID$ = $PRECISION_OPENVDB$\n\
+vdbPrecision_s$ID$ = $PRECISION_OPENVDB$\n\
 \n\
 # Cache file names\n\
 file_data_s$ID$ = '$NAME_DATA$'\n\
@@ -718,7 +718,7 @@ def fluid_file_export_s$ID$(framenr, file_format, path, 
dict, file_name=None, mo
 file = os.path.join(path, file_name + '_' + framenr + 
file_format)\n\
 if not os.path.isfile(file) or mode_override:\n\
 if file_format == '.vdb':\n\
-saveCombined = save(name=file, 
objects=list(dict.values()), worldSize=domainSize_s$ID$, skipDeletedParts=True, 
compression=vdbCompression_s$ID$, precisionHalf=vdbPrecisionHalf_s$ID$)\n\
+saveCombined = save(name=file, 
objects=list(dict.values()), worldSize=domainSize_s$ID$, skipDeletedParts=True, 
compression=vdbCompression_s$ID$, precision=vdbPrecision_s$ID$)\n\
 elif file_format == '.bobj.gz' or file_format == '.obj':\n\
 for name, object in dict.items():\n\
 if not os.path.isfile(file) or mode_override:\n\
diff --git a/source/blender/makesdna/DNA_fluid_types.h 
b/source/blender/makesdna/DNA_fluid_types.h
index 8f67cd060e9..afb2a294605 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -463,6 +463,7 @@ enum {
 enum {
   VDB_PRECISION_HALF_FLOAT = 0,
   VDB_PRECISION_FULL_FLOAT = 1,
+  VDB_PRECISION_MINI_FLOAT = 2,
 };
 
 /* Deprecated values (i.e. all defines and enums below this line up until 
typedefs). */
diff --git a/source/blender/makesrna/intern/rna_fluid.c 
b/source/blender/makesrna/intern/rna_fluid.c
index 1630468db7c..916ebf422da 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1264,8 +1264,13 @@ static void rna_def_fluid_domain_settings(BlenderRNA 
*brna)
   {0, NULL, 0, NULL, NULL}};
 
   static const EnumPropertyItem fluid_data_depth_items[] = {
-  {VDB_PRECISION_HALF_FLOAT, "16", 0, "Half", "Half float (16 bit data)"},
-  {VDB_PRECISION_FULL_FLOAT, "32", 0, "Full", "Full float (32 bit data)"},
+  {VDB_PRECISION_MINI_FLOAT,
+   "8",
+   0,
+   "Mini",
+   "Mini float (Use 8 bit where possible, otherwise 16 bit)"},
+  {VDB_PRECISION_HALF_FLOAT, "16", 0, "Half", "Half float (Use 16 bit for 
all data)"},
+  {VDB_PRECISION_FULL_FLOAT, "32", 0, "Full", "Full float (Use 32 bit for 
all data)"},
   {0, NULL, 0, NULL, NULL},
   };
 
@@ -2628,10 +2633,10 @@ static void rna_def_fluid_domain_settings(BlenderRNA 
*brna)
   prop = RNA_def_property(srna, "openvdb_data_depth", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_

[Bf-blender-cvs] [ae1d8f4c35a] xr-actions-D9124: Fix: Use correct add-on branch for 'make update'

2020-10-13 Thread Peter Kim
Commit: ae1d8f4c35a70844ffd11932a108fa7eaa4ea396
Author: Peter Kim
Date:   Wed Oct 14 08:47:14 2020 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBae1d8f4c35a70844ffd11932a108fa7eaa4ea396

Fix: Use correct add-on branch for 'make update'

Credit to Julian Eisel for the fix.

===

M   build_files/utils/make_update.py

===

diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py
index 53f6b3d447f..5e97b6a9886 100755
--- a/build_files/utils/make_update.py
+++ b/build_files/utils/make_update.py
@@ -169,7 +169,7 @@ def submodules_update(args, release_version, branch):
 branch = "master"
 
 submodules = [
-("release/scripts/addons", branch),
+("release/scripts/addons", "xr-actions-D9124"),
 ("release/scripts/addons_contrib", branch),
 ("release/datafiles/locale", branch),
 ("source/tools", branch),

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


[Bf-blender-cvs] [94673c6c643] temp-trimesh-sculpt: * Add support for 16-bit textures to python gpu api

2020-10-13 Thread Joseph Eagar
Commit: 94673c6c6437e08609132d3f5cad76058ba26020
Author: Joseph Eagar
Date:   Wed Jun 26 12:25:23 2019 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB94673c6c6437e08609132d3f5cad76058ba26020

* Add support for 16-bit textures to python gpu
  api

===

M   source/blender/python/gpu/gpu_py_offscreen.c

===

diff --git a/source/blender/python/gpu/gpu_py_offscreen.c 
b/source/blender/python/gpu/gpu_py_offscreen.c
index 0efafe4e022..c8f022b95b9 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -84,16 +84,16 @@ static PyObject *bpygpu_offscreen_new(PyTypeObject 
*UNUSED(self), PyObject *args
   BPYGPU_IS_INIT_OR_ERROR_OBJ;
 
   GPUOffScreen *ofs;
-  int width, height, samples = 0;
+  int width, height, high_bitdepth=0, samples = 0;
   char err_out[256];
 
-  static const char *_keywords[] = {"width", "height", "samples", NULL};
-  static _PyArg_Parser _parser = {"ii|i:GPUOffScreen.__new__", _keywords, 0};
-  if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &width, &height, 
&samples)) {
+  static const char *_keywords[] = {"width", "height", "samples", 
"high_bitdepth", NULL};
+  static _PyArg_Parser _parser = {"ii|ii:GPUOffScreen.__new__", _keywords, 0};
+  if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &width, &height, 
&samples, &high_bitdepth)) {
 return NULL;
   }
 
-  ofs = GPU_offscreen_create(width, height, samples, true, false, err_out);
+  ofs = GPU_offscreen_create(width, height, samples, true, high_bitdepth, 
err_out);
 
   if (ofs == NULL) {
 PyErr_Format(PyExc_RuntimeError,

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


[Bf-blender-cvs] [a74189736ff] temp-trimesh-sculpt: merge

2020-10-13 Thread Joseph Eagar
Commit: a74189736ff4aef89c171dac8908ef75f629280a
Author: Joseph Eagar
Date:   Sun Feb 16 23:53:10 2020 -0800
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBa74189736ff4aef89c171dac8908ef75f629280a

merge

===

M   intern/cycles/blender/addon/ui.py
M   intern/cycles/kernel/kernel_path.h
M   intern/cycles/kernel/kernel_path_surface.h

===

diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index 61a4c33836b..fe1deb40327 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -178,10 +178,9 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
 layout.use_property_split = True
 layout.use_property_decorate = False
 
-if not use_optix(context):
-layout.prop(cscene, "progressive")
-
-if not use_branched_path(context):
+layout.prop(cscene, "progressive")
+
+if cscene.progressive == 'PATH' or use_branched_path(context) is False:
 col = layout.column(align=True)
 col.prop(cscene, "samples", text="Render")
 col.prop(cscene, "preview_samples", text="Viewport")
diff --git a/intern/cycles/kernel/kernel_path.h 
b/intern/cycles/kernel/kernel_path.h
index 1a0b67275a7..97df04d887d 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -621,6 +621,9 @@ ccl_device_forceinline void 
kernel_path_integrate(KernelGlobals *kg,
 /* direct lighting */
 kernel_path_surface_connect_light(kg, &sd, emission_sd, throughput, 
state, L);
 #  endif /* __EMISSION__ */
+if (kernel_data.integrator.use_light_bounce) {
+  kernel_path_surface_connect_light_indirect(kg, &sd, emission_sd, 
throughput, state, L);
+}
 
 #  ifdef __VOLUME__
   }
diff --git a/intern/cycles/kernel/kernel_path_surface.h 
b/intern/cycles/kernel/kernel_path_surface.h
index 47679549f6f..eb1c1b5cd23 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -472,6 +472,212 @@ ccl_device_inline void 
kernel_path_surface_connect_light_indirect(KernelGlobals*
 #endif
 }
 
+constexpr size_t HCLEN = 1024*16;
+
+typedef struct _hitcache {
+  Ray rays[HCLEN];
+  int cur, used;
+} _hitcache;
+
+static _hitcache hitcache[2] = { 0, };
+
+static void hitcache_add(Ray ray, int thread) {
+  hitcache[thread].rays[hitcache[thread].cur] = ray;
+  hitcache[thread].cur = (hitcache[thread].cur + 1) % HCLEN;
+
+  if (hitcache[thread].used < HCLEN) {
+hitcache[thread].used++;
+  }
+}
+
+static int hitcache_get(KernelGlobals *kg, PathState* state, int thread) {
+  if (hitcache[thread].used == 0)
+return -1;
+
+  //is path_state_rng_1D only giving numbers from 0.5-1.0?
+  float r = path_state_rng_1D(kg, state, PRNG_LIGHT_U);
+  r = r > 0.5 ? (r - 0.5) * 2.0 : r;
+
+  int idx = (int)(r * ((float)hitcache[thread].used) * 0.);
+
+  return idx;
+}
+
+//bastardized one-bounce bidirection tracing
+ccl_device_inline void 
kernel_path_surface_connect_light_indirect(KernelGlobals* kg,
+  ShaderData* sd,
+  ShaderData* emission_sd,
+  float3 throughput,
+  ccl_addr_space PathState* state,
+  PathRadiance* L)
+{
+  PROFILING_INIT(kg, PROFILING_CONNECT_LIGHT);
+
+#ifdef __EMISSION__
+  if (!(kernel_data.integrator.use_direct_light && (sd->flag & 
SD_BSDF_HAS_EVAL)))
+return;
+
+  /* sample illumination from lights to find path contribution */
+  float light_u, light_v;
+  path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
+
+  Ray light_ray;
+  BsdfEval L_light;
+  PathRadiance L2 = { 0, };
+  bool is_lamp;
+
+#  ifdef __OBJECT_MOTION__
+  light_ray.time = sd->time;
+#  endif
+
+  LightSample ls;
+  if (light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) 
{
+float terminate = path_state_rng_light_termination(kg, state);
+
+if (1) { //direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, 
&L_light, &is_lamp, terminate) || true) {
+  Ray ray;
+  float3 omega;
+  float3 Ng;
+  float pdf = 0.0;
+
+  /*trace a ray*/
+  if (ls.type == LIGHT_DISTANT) {
+const ccl_global KernelLight* klight = &kernel_tex_fetch(__lights, 
ls.lamp);
+
+ray.P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+Ng = ls.P;
+  } else if (ls.type == LIGHT_POINT) {
+Ng = -ls.D;
+ray.P = ls.P + Ng * 0.00015f;
+  } else {
+Ng = ls.Ng;
+ray.P = ls.P + Ng * 0.00015f;
+  }
+
+  ray.t = ls.t;
+
+  sample_cos_hemisphere(Ng, light_u, light_v, &omega, &pdf);
+
+  omega = normalize(omega);
+  ray.D = omega;
+
+  float prob = path_state_rng_1D(kg, state, PRNG_LIGHT_U);
+  bool has_cache = prob > 0.75;
+
+  if (has_cache) {
+int i = hitcache_get(kg, state, 0);
+
+if (i >= 0) {
+  r

[Bf-blender-cvs] [8bc596f0372] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: 8bc596f0372097ed9d16eea3c8106b0464eb8c4d
Author: Joseph Eagar
Date:   Fri Mar 27 04:53:03 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB8bc596f0372097ed9d16eea3c8106b0464eb8c4d

Merge branch 'master' of git://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [0f4a0b7b3e8] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: 0f4a0b7b3e838f31ac330208119086eb7905d5ec
Author: Joseph Eagar
Date:   Sat Feb 22 00:49:04 2020 -0800
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB0f4a0b7b3e838f31ac330208119086eb7905d5ec

Merge branch 'master' of git://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [aba8be7c3e6] temp-trimesh-sculpt: merge

2020-10-13 Thread Joseph Eagar
Commit: aba8be7c3e6e5cd9c5ae915ca8a01c8076458c33
Author: Joseph Eagar
Date:   Sun Feb 16 23:51:32 2020 -0800
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBaba8be7c3e6e5cd9c5ae915ca8a01c8076458c33

merge

===

M   intern/cycles/blender/addon/properties.py
M   intern/cycles/blender/addon/ui.py
M   intern/cycles/blender/blender_sync.cpp
M   intern/cycles/kernel/kernel_path_surface.h
M   intern/cycles/kernel/kernel_types.h
M   intern/cycles/render/integrator.cpp
M   intern/cycles/render/integrator.h

===

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index eafe37618b3..2f7a664fed4 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -264,6 +264,16 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
 min=0, max=(1 << 24),
 default=32,
 )
+preview_pause: BoolProperty(
+name="Pause Preview",
+description="Pause all viewport preview renders",
+default=False,
+)
+use_light_bounce: BoolProperty(
+name="Cache Light Bounce",
+description="Cache first light bounce",
+default=False,
+)
 aa_samples: IntProperty(
 name="AA Samples",
 description="Number of antialiasing samples to render for each pixel",
diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index f23d141e3da..61a4c33836b 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -242,13 +242,13 @@ class 
CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
 
 scene = context.scene
 cscene = scene.cycles
-
+
 row = layout.row(align=True)
 row.prop(cscene, "seed")
 row.prop(cscene, "use_animated_seed", text="", icon='TIME')
 
+layout.prop(cscene, "use_light_bounce")
 layout.prop(cscene, "sampling_pattern", text="Pattern")
-
 layout.prop(cscene, "use_square_samples")
 
 layout.separator()
diff --git a/intern/cycles/blender/blender_sync.cpp 
b/intern/cycles/blender/blender_sync.cpp
index 0412654d3bd..1df5b83c567 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -245,6 +245,8 @@ void BlenderSync::sync_integrator()
   Integrator *integrator = scene->integrator;
   Integrator previntegrator = *integrator;
 
+  integrator->use_light_bounce = get_boolean(cscene, "use_light_bounce");
+
   integrator->min_bounce = get_int(cscene, "min_light_bounces");
   integrator->max_bounce = get_int(cscene, "max_bounces");
 
diff --git a/intern/cycles/kernel/kernel_path_surface.h 
b/intern/cycles/kernel/kernel_path_surface.h
index ba48c0bdfc4..47679549f6f 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -266,6 +266,212 @@ ccl_device_inline void 
kernel_path_surface_connect_light(KernelGlobals *kg,
 #endif
 }
 
+constexpr size_t HCLEN = 1024*16;
+
+typedef struct _hitcache {
+  Ray rays[HCLEN];
+  int cur, used;
+} _hitcache;
+
+static _hitcache hitcache[2] = { 0, };
+
+static void hitcache_add(Ray ray, int thread) {
+  hitcache[thread].rays[hitcache[thread].cur] = ray;
+  hitcache[thread].cur = (hitcache[thread].cur + 1) % HCLEN;
+
+  if (hitcache[thread].used < HCLEN) {
+hitcache[thread].used++;
+  }
+}
+
+static int hitcache_get(KernelGlobals *kg, PathState* state, int thread) {
+  if (hitcache[thread].used == 0)
+return -1;
+
+  //is path_state_rng_1D only giving numbers from 0.5-1.0?
+  float r = path_state_rng_1D(kg, state, PRNG_LIGHT_U);
+  r = r > 0.5 ? (r - 0.5) * 2.0 : r;
+
+  int idx = (int)(r * ((float)hitcache[thread].used) * 0.);
+
+  return idx;
+}
+
+//bastardized one-bounce bidirection tracing
+ccl_device_inline void 
kernel_path_surface_connect_light_indirect(KernelGlobals* kg,
+  ShaderData* sd,
+  ShaderData* emission_sd,
+  float3 throughput,
+  ccl_addr_space PathState* state,
+  PathRadiance* L)
+{
+  PROFILING_INIT(kg, PROFILING_CONNECT_LIGHT);
+
+#ifdef __EMISSION__
+  if (!(kernel_data.integrator.use_direct_light && (sd->flag & 
SD_BSDF_HAS_EVAL)))
+return;
+
+  /* sample illumination from lights to find path contribution */
+  float light_u, light_v;
+  path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
+
+  Ray light_ray;
+  BsdfEval L_light;
+  PathRadiance L2 = { 0, };
+  bool is_lamp;
+
+#  ifdef __OBJECT_MOTION__
+  light_ray.time = sd->time;
+#  endif
+
+  LightSample ls;
+  if (light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) 
{
+float terminate = path_state_rng_light_termination(kg, state);
+
+if (1) { //direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, 
&L_light, &is_lamp, terminate) || true) {
+  Ray ray;
+  float3 omega;
+  fl

[Bf-blender-cvs] [7055f022483] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: 7055f0224831ea23fab6b5f436fa1dd38946f6d4
Author: Joseph Eagar
Date:   Mon Mar 30 20:34:10 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB7055f0224831ea23fab6b5f436fa1dd38946f6d4

Merge branch 'master' of git://git.blender.org/blender

===



===

diff --cc release/datafiles/locale
index 0cbba701783,ad82c4ce43e..e213bf9c7b7
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 0cbba70178397662c87c1f5015af6dadd8ecdfc3
 -Subproject commit ad82c4ce43ef2801ef51e75af1f9702992478b02
++Subproject commit e213bf9c7b730ed5f17279ac74f49f9202bbdb9d
diff --cc release/scripts/addons
index 670da1eea44,8e6f485cf5b..a32b859fecb
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 670da1eea44d27200c9bd1fb6aacac4cf5daa52f
 -Subproject commit 8e6f485cf5b160c425d7da7c743879b20f3d6a96
++Subproject commit a32b859fecb1a1d269408d0b9730eb5c7fc52c0f
diff --cc release/scripts/addons_contrib
index 70b649775ee,7077ff07384..9468c406fb5
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 70b649775bedb02c1c7b7aa996a7f6294177
 -Subproject commit 7077ff07384491d1f7630484995557f1c7302dae
++Subproject commit 9468c406fb554e32ff47b62bfef356b3908ec651
diff --cc source/tools
index d230f2161f3,2afbb8ec472..4a6f1706258
--- a/source/tools
+++ b/source/tools
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit d230f2161f36f8b21f3ce8eeb19b34c0629506c2
 -Subproject commit 2afbb8ec472cac5102eb239f57b006f8c9387685
++Subproject commit 4a6f1706258439db3ee5a50ec6938fef79c7cb97

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


[Bf-blender-cvs] [bf4d5f8ea94] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: bf4d5f8ea948d6d7f35b0f614b7eb43afbf48c47
Author: Joseph Eagar
Date:   Mon Mar 9 19:12:45 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBbf4d5f8ea948d6d7f35b0f614b7eb43afbf48c47

Merge branch 'master' of git://git.blender.org/blender

===



===

diff --cc intern/cycles/blender/addon/properties.py
index 623bebc71bb,1a93a603e23..dbbe8e4900f
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@@ -264,16 -261,6 +261,11 @@@ class CyclesRenderSettings(bpy.types.Pr
  min=0, max=(1 << 24),
  default=32,
  )
 +preview_pause: BoolProperty(
 +name="Pause Preview",
 +description="Pause all viewport preview renders",
 +default=False,
 +)
- use_light_bounce: BoolProperty(
- name="Cache Light Bounce",
- description="Cache first light bounce",
- default=False,
- )
  aa_samples: IntProperty(
  name="AA Samples",
  description="Number of antialiasing samples to render for each pixel",
diff --cc intern/cycles/render/integrator.cpp
index 8f97ae2b788,ee1aa5988bf..27c6ed9c907
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@@ -176,7 -182,22 +182,23 @@@ void Integrator::device_update(Device *
  
kintegrator->sampling_pattern = sampling_pattern;
kintegrator->aa_samples = aa_samples;
-   kintegrator->use_light_bounce = use_light_bounce;
++
+   if (aa_samples > 0 && adaptive_min_samples == 0) {
+ kintegrator->adaptive_min_samples = max(4, (int)sqrtf(aa_samples));
+ VLOG(1) << "Cycles adaptive sampling: automatic min samples = "
+ << kintegrator->adaptive_min_samples;
+   }
+   else {
+ kintegrator->adaptive_min_samples = max(4, adaptive_min_samples);
+   }
+   if (aa_samples > 0 && adaptive_threshold == 0.0f) {
+ kintegrator->adaptive_threshold = max(0.001f, 1.0f / (float)aa_samples);
+ VLOG(1) << "Cycles adaptive sampling: automatic threshold = "
+ << kintegrator->adaptive_threshold;
+   }
+   else {
+ kintegrator->adaptive_threshold = adaptive_threshold;
+   }
  
if (light_sampling_threshold > 0.0f) {
  kintegrator->light_inv_rr_threshold = 1.0f / light_sampling_threshold;
diff --cc release/datafiles/locale
index 34d98762cef,2a25e004396..0cbba701783
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 34d98762cef85b9c065f21a051d1dbe3bf2979b7
 -Subproject commit 2a25e004396d3f135a98da132b496923275a3dcc
++Subproject commit 0cbba70178397662c87c1f5015af6dadd8ecdfc3
diff --cc release/scripts/addons
index 47a32a5370d,7f50343d1c5..670da1eea44
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 47a32a5370d36942674621e5a03e57e8dd4986d8
 -Subproject commit 7f50343d1c53ca9a5ca747f47e3b1e5bbcbe8471
++Subproject commit 670da1eea44d27200c9bd1fb6aacac4cf5daa52f
diff --cc source/tools
index 603f076606f,4a6f1706258..d230f2161f3
--- a/source/tools
+++ b/source/tools
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 603f076606f052adc97d937633bfeb9b268ec202
 -Subproject commit 4a6f1706258439db3ee5a50ec6938fef79c7cb97
++Subproject commit d230f2161f36f8b21f3ce8eeb19b34c0629506c2

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


[Bf-blender-cvs] [dc02d5439bd] temp-trimesh-sculpt: add trimesh and thread safe mempool code

2020-10-13 Thread Joseph Eagar
Commit: dc02d5439bdb32fffce519030f34816938320252
Author: Joseph Eagar
Date:   Thu Sep 24 22:06:43 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBdc02d5439bdb32fffce519030f34816938320252

add trimesh and thread safe mempool code

===

A   source/blender/blenlib/BLI_threadsafe_mempool.h
A   source/blender/blenlib/BLI_trimesh.h
M   source/blender/blenlib/CMakeLists.txt
A   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
A   source/blender/blenlib/intern/BLI_trimesh.c

===

diff --git a/source/blender/blenlib/BLI_threadsafe_mempool.h 
b/source/blender/blenlib/BLI_threadsafe_mempool.h
new file mode 100644
index 000..e900651856b
--- /dev/null
+++ b/source/blender/blenlib/BLI_threadsafe_mempool.h
@@ -0,0 +1,47 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ */
+#ifndef _BLI_THREADSAFE_MEMPOOL_H
+#define _BLI_THREADSAFE_MEMPOOL_H
+
+struct BLI_ThreadSafePool;
+typedef struct BLI_ThreadSafePool BLI_ThreadSafePool;
+
+struct BLI_ThreadSafePool* BLI_safepool_create(int elemsize, int chunksize, 
int maxthread);
+void* BLI_safepool_alloc(struct BLI_ThreadSafePool *pool, int threadnr);
+
+void BLI_safepool_free(struct BLI_ThreadSafePool*pool, void *elem);
+bool BLI_safepool_is_dead(struct BLI_ThreadSafePool *pool, void *elem);
+
+void BLI_safepool_threaded_free(struct BLI_ThreadSafePool*pool, void *elem, 
int threadnr);
+int BLI_safepool_length(struct BLI_ThreadSafePool*pool);
+void BLI_safepool_destroy(struct BLI_ThreadSafePool* pool);
+
+typedef struct ThreadSafePoolIter {
+  struct BLI_ThreadSafePool* pool;
+  int thread;
+  void *chunk;
+  int i;
+} ThreadSafePoolIter;
+
+void BLI_safepool_iternew(struct BLI_ThreadSafePool* pool, ThreadSafePoolIter* 
iter);
+void BLI_safepool_iterfree(ThreadSafePoolIter* iter);
+void* BLI_safepool_iterstep(ThreadSafePoolIter* iter);
+void BLI_safepool_threaded_free(struct BLI_ThreadSafePool* pool, void* elem, 
int thread);
+
+#endif /* _BLI_THREADSAFE_MEMPOOL_H */
diff --git a/source/blender/blenlib/BLI_trimesh.h 
b/source/blender/blenlib/BLI_trimesh.h
new file mode 100644
index 000..9c84155e8a7
--- /dev/null
+++ b/source/blender/blenlib/BLI_trimesh.h
@@ -0,0 +1,107 @@
+//optimized thread-safe triangle mesh library with topological info
+
+#include "BLI_threads.h"
+#include "BLI_threadsafe_mempool.h"
+
+
+struct OptTriVert;
+struct OptTriEdge;
+struct OptTri;
+
+#define OPTELEM_HEAD(type) struct type *next, *prev; int threadtag;
+
+typedef struct OptElem {
+  OPTELEM_HEAD(OptElem)
+} OptElem;
+
+typedef struct optmesh_simplelist {
+  void **items;
+  int _size, length;
+  bool is_pool_allocd;
+} optmesh_simplelist;
+
+typedef struct OptTriVert {
+  OPTELEM_HEAD(OptTriVert)
+  float co[3];
+  float no[3];
+
+  optmesh_simplelist edges;
+} OptTriVert;
+
+typedef struct OptTriEdge {
+  OPTELEM_HEAD(OptTriEdge)
+  OptTriVert *v1, *v2;
+  optmesh_simplelist tris;
+} OptTriEdge;
+
+typedef struct OptTri {
+  OPTELEM_HEAD(OptTri)
+
+  OptTriVert *v1, *v2, *v3;
+  OptTriEdge *e1, *e2, *e3;
+
+  float no[3];
+} OptTri;
+
+typedef struct OptTriIsland {
+  OptTri **tris;
+  int tottri;
+  OptTriVert **verts;
+  int totvert;
+  int tag;
+} OptTriIsland;
+
+struct BLI_ThreadSafePool;
+
+#define MAX_TRIMESH_POOLS 5
+
+typedef struct OptTriMesh {
+ struct BLI_ThreadSafePool* pools[MAX_TRIMESH_POOLS];
+
+  int totvert, tottri, totedge;
+  int maxthread;
+  SpinLock global_lock;
+} OptTriMesh;
+
+typedef struct OptTriMeshIter {
+  int pool;
+  ThreadSafePoolIter iter;
+} OptTriMeshIter;
+
+#define TRIMESH_NEED_TAG -1
+#define TRIMESH_BOUNDARY -2
+#define TRIMESH_BOUNDARY_TEMP -3
+#define TRIMESH_TAG_CLEAR -4
+
+#define TRIMESH_VERT 1
+#define TRIMESH_EDGE 2
+#define TRIMESH_TRI  4
+
+OptTriMesh* BLI_trimesh_new(int maxthread);
+void BLI_trimesh_free(OptTriMesh *tm);
+void BLI_trimesh_vert_iternew(OptTriMesh *tm, OptTriMeshIter* iter);
+void BLI_trimesh_edge_iternew(OptTriMesh *tm, OptTriMeshIter* iter);
+void BLI_trimesh_tri_iternew(OptTriMesh *tm, OptTriMeshIter* iter);
+void BLI_trimesh_iterstep(OptTriMeshIter* iter);
+void BLI_trimes

[Bf-blender-cvs] [d88f0b1052a] temp-trimesh-sculpt: More trimesh stuff

2020-10-13 Thread Joseph Eagar
Commit: d88f0b1052a707eab3d0cb077d9ca9c11c0c3663
Author: Joseph Eagar
Date:   Tue Sep 29 19:34:12 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBd88f0b1052a707eab3d0cb077d9ca9c11c0c3663

More trimesh stuff

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/paint.c
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_trimesh.h
M   source/blender/blenlib/intern/BLI_trimesh.c
M   source/blender/editors/sculpt_paint/sculpt.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 881f3356a86..7fc94ba9b26 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -298,6 +298,9 @@ typedef struct SculptSession {
   /* Mesh Face Sets */
   int *face_sets;
 
+  struct BLI_TriMesh *tm;
+  struct TriMeshLog *tm_log;
+
   /* BMesh for dynamic topology sculpting */
   struct BMesh *bm;
   int cd_vert_node_offset;
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index a9ff2a3b46a..2f238dd45a3 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -118,6 +118,13 @@ void BKE_pbvh_build_bmesh(PBVH *bvh,
   struct BMLog *log,
   const int cd_vert_node_offset,
   const int cd_face_node_offset);
+void BKE_pbvh_build_trimesh(PBVH *bvh,
+  struct BLI_TriMesh *bm,
+  bool smooth_shading,
+  struct TriMeshLog *log,
+  const int cd_vert_node_offset,
+  const int cd_face_node_offset);
+
 void BKE_pbvh_free(PBVH *bvh);
 void BKE_pbvh_free_layer_disp(PBVH *bvh);
 
@@ -162,6 +169,11 @@ bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
 struct IsectRayPrecalc *isect_precalc,
 float *depth,
 float *r_edge_length);
+bool BKE_pbvh_trimesh_node_raycast_detail(PBVHNode *node,
+  const float ray_start[3],
+  struct IsectRayPrecalc *isect_precalc,
+  float *depth,
+  float *r_edge_length);
 
 /* for orthographic cameras, project the far away ray segment points to the 
root node so
  * we can have better precision. */
@@ -228,7 +240,8 @@ int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh);
 
 /* Only valid for type == PBVH_BMESH */
 struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
-void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size);
+struct BLI_TriMesh *BKE_pbvh_get_trimesh(PBVH *pbvh);
+void BKE_pbvh_topology_detail_size_set(PBVH *pbvh, float detail_size);
 
 typedef enum {
   PBVH_Subdivide = 1,
@@ -242,6 +255,13 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh,
 const bool use_frontface,
 const bool use_projected);
 
+bool BKE_pbvh_trimesh_update_topology(PBVH *bvh,
+  PBVHTopologyUpdateMode mode,
+  const float center[3],
+  const float view_normal[3],
+  float radius,
+  const bool use_frontface,
+  const bool use_projected);
 /* Node Access */
 
 void BKE_pbvh_node_mark_update(PBVHNode *node);
@@ -286,6 +306,12 @@ struct GSet *BKE_pbvh_bmesh_node_faces(PBVHNode *node);
 void BKE_pbvh_bmesh_node_save_orig(struct BMesh *bm, PBVHNode *node);
 void BKE_pbvh_bmesh_after_stroke(PBVH *bvh);
 
+struct GSet *BKE_pbvh_trimesh_node_unique_verts(PBVHNode *node);
+struct GSet *BKE_pbvh_trimesh_node_other_verts(PBVHNode *node);
+struct GSet *BKE_pbvh_trimesh_node_faces(PBVHNode *node);
+void BKE_pbvh_trimesh_node_save_orig(struct BLI_TriMesh *tm, PBVHNode *node);
+void BKE_pbvh_trimesh_after_stroke(PBVH *bvh);
+
 /* Update Bounding Box/Redraw and clear flags */
 
 void BKE_pbvh_update_bounds(PBVH *bvh, int flags);
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 719336f7351..d44dc9bd7f5 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -74,6 +74,7 @@
 #include "RNA_enum_types.h"
 
 #include "bmesh.h"
+#include "BLI_trimesh.h"
 
 static void palette_init_data(ID *id)
 {
@@ -1158,6 +1159,17 @@ bool paint_is_bmesh_face_hidden(BMFace *f)
   return false;
 }
 
+
+/* Return true if all vertices in the face are visible, false otherwise */
+bool paint_is_trimesh_face_hidden(TMFace *f)
+{
+  bool ret = f->v1->flag & TRIMESH_HIDE;
+  ret = ret || (f->v2->flag & TRIMESH_HIDE);
+  ret = ret || (f->v3->flag & TRIMESH_HIDE);
+
+  return ret;
+}
+
 float paint_grid_paint_mask(const GridPaintMask *gpm, uint level, uint x, uint 
y)
 {
   int factor = BKE_ccg_factor(level, gpm->level);
@@ -1257,6 +1269,34 @@ void BKE_sculptsessio

[Bf-blender-cvs] [e79c6515e7f] temp-trimesh-sculpt: * more trimesh work

2020-10-13 Thread Joseph Eagar
Commit: e79c6515e7f5f71a3beb8f6f821c6e7d2d92f064
Author: Joseph Eagar
Date:   Fri Sep 25 02:01:29 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBe79c6515e7f5f71a3beb8f6f821c6e7d2d92f064

* more trimesh work

===

M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/pbvh_intern.h
A   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_threadsafe_mempool.h
M   source/blender/blenlib/BLI_trimesh.h
M   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
M   source/blender/blenlib/intern/BLI_trimesh.c

===

diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 16a7e4d38d0..a9ff2a3b46a 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -203,6 +203,7 @@ typedef enum {
   PBVH_FACES,
   PBVH_GRIDS,
   PBVH_BMESH,
+  PBVH_TRIMESH
 } PBVHType;
 
 PBVHType BKE_pbvh_type(const PBVH *bvh);
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 1e230e5af3a..6233de63d22 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -194,6 +194,7 @@ set(SRC
   intern/particle_distribute.c
   intern/particle_system.c
   intern/pbvh.c
+  intern/pbvh_trimesh.c
   intern/pbvh_bmesh.c
   intern/pbvh_parallel.cc
   intern/pointcache.c
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h 
b/source/blender/blenkernel/intern/pbvh_intern.h
index af92f11e219..fa054efbecb 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -105,6 +105,14 @@ struct PBVHNode {
   float (*bm_orco)[3];
   int (*bm_ortri)[3];
   int bm_tot_ortri;
+
+  /* trimesh */
+  GSet *tm_faces;
+  GSet *tm_unique_verts;
+  GSet *tm_other_verts;
+  float (*tm_orco)[3];
+  int (*tm_ortri)[3];
+  int tm_tot_ortri;
 };
 
 typedef enum {
@@ -168,6 +176,11 @@ struct PBVH {
   int cd_face_node_offset;
 
   struct BMLog *bm_log;
+
+  /* trimesh data */
+  struct TriMesh *tm;
+  float tm_max_edge_len;
+  float tm_min_edge_len;
 };
 
 /* pbvh.c */
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
new file mode 100644
index 000..71054592e18
--- /dev/null
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -0,0 +1,2242 @@
+/*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+/** \file
+* \ingroup bli
+*/
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_buffer.h"
+#include "BLI_ghash.h"
+#include "BLI_heap_simple.h"
+#include "BLI_math.h"
+#include "BLI_memarena.h"
+#include "BLI_utildefines.h"
+
+#include "BLI_threadsafe_mempool.h"
+#include "BLI_trimesh.h"
+
+#include "BKE_DerivedMesh.h"
+#include "BKE_ccg.h"
+#include "BKE_pbvh.h"
+
+#include "GPU_buffers.h"
+
+#include "bmesh.h"
+#include "pbvh_intern.h"
+
+#include 
+
+/* Avoid skinny faces */
+#define USE_EDGEQUEUE_EVEN_SUBDIV
+#ifdef USE_EDGEQUEUE_EVEN_SUBDIV
+#  include "BKE_global.h"
+#endif
+
+/* Support for only operating on front-faces */
+#define USE_EDGEQUEUE_FRONTFACE
+
+/* don't add edges into the queue multiple times */
+#define USE_EDGEQUEUE_TAG
+/**
+* Ensure we don't have dirty tags for the edge queue, and that they are left 
cleared.
+* (slow, even for debug mode, so leave disabled for now).
+*/
+#if defined(USE_EDGEQUEUE_TAG) && 0
+#  if !defined(NDEBUG)
+#define USE_EDGEQUEUE_TAG_VERIFY
+#  endif
+#endif
+
+// #define USE_VERIFY
+
+#ifdef USE_VERIFY
+static void pbvh_trimesh_verify(PBVH *bvh);
+#endif
+
+/** \} */
+
+/** Building **/
+
+#define _TRITEST(a, b, c) tri->v1 == a && tri->v2 == b && tri->v3 == c
+
+OptTri *trimesh_tri_exists(OptTriEdge *e, OptTriVert *opposite) {
+  for (int i=0; itris.length; i++) {
+OptTri *tri = e->tris.items[i];
+
+if (_TRITEST(e->v1, e->v2, opposite))
+  return tri;
+if (_TRITEST(e->v1, opposite, e->v2))
+  return tri;
+if (_TRITEST(e->v2, e->v1, opposite))
+  return tri;
+if (_TRITEST(e->v2, opposite, e->v1))
+  return

[Bf-blender-cvs] [6ce85c0e88a] temp-trimesh-sculpt: prepare to move trimesh out of BLI

2020-10-13 Thread Joseph Eagar
Commit: 6ce85c0e88a0c0ca3284486ac5e947580fff9d43
Author: Joseph Eagar
Date:   Tue Sep 29 19:44:37 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB6ce85c0e88a0c0ca3284486ac5e947580fff9d43

prepare to move trimesh out of BLI

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/paint.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_trimesh.h
M   source/blender/blenlib/intern/BLI_trimesh.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 7fc94ba9b26..d840b6e5734 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -298,7 +298,7 @@ typedef struct SculptSession {
   /* Mesh Face Sets */
   int *face_sets;
 
-  struct BLI_TriMesh *tm;
+  struct TM_TriMesh *tm;
   struct TriMeshLog *tm_log;
 
   /* BMesh for dynamic topology sculpting */
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 2f238dd45a3..cabacabf0ad 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -119,7 +119,7 @@ void BKE_pbvh_build_bmesh(PBVH *bvh,
   const int cd_vert_node_offset,
   const int cd_face_node_offset);
 void BKE_pbvh_build_trimesh(PBVH *bvh,
-  struct BLI_TriMesh *bm,
+  struct TM_TriMesh *bm,
   bool smooth_shading,
   struct TriMeshLog *log,
   const int cd_vert_node_offset,
@@ -240,7 +240,7 @@ int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh);
 
 /* Only valid for type == PBVH_BMESH */
 struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
-struct BLI_TriMesh *BKE_pbvh_get_trimesh(PBVH *pbvh);
+struct TM_TriMesh *BKE_pbvh_get_trimesh(PBVH *pbvh);
 void BKE_pbvh_topology_detail_size_set(PBVH *pbvh, float detail_size);
 
 typedef enum {
@@ -309,7 +309,7 @@ void BKE_pbvh_bmesh_after_stroke(PBVH *bvh);
 struct GSet *BKE_pbvh_trimesh_node_unique_verts(PBVHNode *node);
 struct GSet *BKE_pbvh_trimesh_node_other_verts(PBVHNode *node);
 struct GSet *BKE_pbvh_trimesh_node_faces(PBVHNode *node);
-void BKE_pbvh_trimesh_node_save_orig(struct BLI_TriMesh *tm, PBVHNode *node);
+void BKE_pbvh_trimesh_node_save_orig(struct TM_TriMesh *tm, PBVHNode *node);
 void BKE_pbvh_trimesh_after_stroke(PBVH *bvh);
 
 /* Update Bounding Box/Redraw and clear flags */
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index d44dc9bd7f5..cfd7d758d91 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1276,18 +1276,18 @@ static void 
sculptsession_tm_to_me_update_data_only(Object *ob, bool reorder)
 
   if (ss->bm) {
 if (ob->data) {
-  BLI_TriMeshIter iter;
+  TM_TriMeshIter iter;
   TMFace *f;
 
-  BLI_trimesh_tri_iternew(ss->tm, &iter);
-  f = BLI_trimesh_iterstep(&iter);
-  for (; f; f = BLI_trimesh_iterstep(&iter)) {
+  TM_tri_iternew(ss->tm, &iter);
+  f = TM_iterstep(&iter);
+  for (; f; f = TM_iterstep(&iter)) {
 TRIMESH_elem_flag_set(f, TRIMESH_SMOOTH, ss->bm_smooth_shading);
   }
   //if (reorder) {
   //  BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
   //}
-  BLI_trimesh_mesh_bm_to_me(NULL,
+  TM_mesh_bm_to_me(NULL,
 ss->tm,
 ob->data,
 (&(struct TMeshToMeshParams){
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h 
b/source/blender/blenkernel/intern/pbvh_intern.h
index 493e0905f0d..7bc4ef44014 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -178,7 +178,7 @@ struct PBVH {
   struct BMLog *bm_log;
 
   /* trimesh data */
-  struct BLI_TriMesh *tm;
+  struct TM_TriMesh *tm;
   float tm_max_edge_len;
   float tm_min_edge_len;
 
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index ba9d3bcdc31..c0869088d87 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -120,10 +120,10 @@ static TMVert *tm_vert_hash_lookup_chain(GHash 
*deleted_verts, TMVert *v)
 }
 
 
-static void tm_edges_from_tri(BLI_TriMesh *tm, TMVert *vs[3], TMEdge *es[3], 
int threadnr, bool skipcd) {
-  es[0] = BLI_trimesh_get_edge(tm, vs[0], vs[1], threadnr, skipcd);
-  es[1] = BLI_trimesh_get_edge(tm, vs[1], vs[2], threadnr, skipcd);
-  es[2] = BLI_trimesh_get_edge(tm, vs[2], vs[0], threadnr, skipcd);
+static void tm_edges_from_tri(TM_TriMesh *tm, TMVert *vs[3], TMEdge *es[3], 
int threadnr, bool skipcd) {
+  es[0] = TM_get_edge(tm, vs[0], vs[1], threadnr, skipcd);
+  es[1] = TM_get_edge(tm, vs[1], vs[2], threadnr, skipcd);
+  es[2]

[Bf-blender-cvs] [cef79fecde1] temp-trimesh-sculpt: commit current code

2020-10-13 Thread Joseph Eagar
Commit: cef79fecde11add7b1c3ff3969c1f92b5887809e
Author: Joseph Eagar
Date:   Thu Sep 24 22:04:41 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBcef79fecde11add7b1c3ff3969c1f92b5887809e

commit current code

===

M   intern/cycles/blender/addon/properties.py
M   intern/cycles/blender/addon/ui.py
M   intern/cycles/blender/blender_sync.cpp
M   intern/cycles/kernel/kernel_path_surface.h
M   intern/cycles/kernel/kernel_random.h
M   intern/cycles/kernel/kernel_textures.h
M   intern/cycles/kernel/kernel_types.h
M   intern/cycles/render/integrator.cpp
M   intern/cycles/render/integrator.h
M   intern/cycles/render/scene.cpp
M   intern/cycles/render/scene.h
M   intern/cycles/util/CMakeLists.txt
M   intern/ghost/intern/GHOST_WindowWin32.cpp
M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   release/scripts/startup/bl_ui/properties_render.py
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/bmesh/tools/bmesh_decimate_collapse.c
M   source/blender/draw/intern/draw_cache_impl_particles.c
M   source/blender/draw/intern/draw_hair.c
M   source/blender/draw/intern/draw_hair_private.h
M   source/blender/draw/intern/shaders/common_hair_lib.glsl
M   source/blender/makesdna/DNA_scene_defaults.h
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/rna_context.c
M   source/blender/makesrna/intern/rna_scene.c
M   source/tools

===

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index 0befeb164cc..3d648ca1587 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -249,6 +249,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
 default=False,
 )
 
+use_bluenoise_seeds: BoolProperty(
+name="Blue Noise Seeds",
+description="Use blue noise seeds to add coherency",
+default=False,
+)
+
 samples: IntProperty(
 name="Samples",
 description="Number of samples to render for each pixel",
@@ -329,6 +335,19 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
 default='SOBOL',
 )
 
+coherency_shift: IntProperty(
+name="Coherency Shift",
+description="Higher values force pixels to be more similar to each 
other",
+min=0, max=31,
+default=16,
+)
+
+coherency_only_blue : BoolProperty(
+name="Bluenoise Only",
+description="Use coherency parameter for bluenoise seeds only",
+default=True
+)
+
 use_layer_samples: EnumProperty(
 name="Layer Samples",
 description="How to use per view layer sample settings",
diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index 1614d787010..a9d2d3481c5 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -277,6 +277,12 @@ class 
CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
 col.prop(cscene, "sampling_pattern", text="Pattern")
 
 layout.prop(cscene, "use_square_samples")
+
+layout.prop(cscene, "use_bluenoise_seeds", text="Blue Noise Seeds")
+
+row = layout.row()
+row.prop(cscene, "coherency_shift", text="Coherency")
+row.prop(cscene, "coherency_only_blue", text="Bluenoise Only")
 
 layout.separator()
 
diff --git a/intern/cycles/blender/blender_sync.cpp 
b/intern/cycles/blender/blender_sync.cpp
index 28a737c3341..85b210ffe37 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -284,6 +284,10 @@ void BlenderSync::sync_integrator()
   integrator->sampling_pattern = (SamplingPattern)get_enum(
   cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, 
SAMPLING_PATTERN_SOBOL);
 
+  integrator->coherency_only_blue = get_boolean(cscene, "coherency_only_blue");
+  integrator->coherency_shift = get_int(cscene, "coherency_shift");
+  integrator->use_bluenoise_seeds = get_boolean(cscene, "use_bluenoise_seeds");
+
   integrator->sample_clamp_direct = get_float(cscene, "sample_clamp_direct");
   integrator->sample_clamp_indirect = get_float(cscene, 
"sample_clamp_indirect");
   if (!preview) {
diff --git a/intern/cycles/kernel/kernel_path_surface.h 
b/intern/cycles/kernel/kernel_path_surface.h
index eb1c1b5cd23..ba48c0bdfc4 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -266,418 +266,6 @@ ccl_device_inline void 
kernel_path_surface_connect_light(KernelGlobals *kg,
 #endif
 }
 
-constexpr size_t HCLEN = 1024*16;
-
-typedef struct _hitcache {
-  Ray rays[HCLEN];
-  int cur, used;
-} _hitcache;
-
-static _hitcache hitcache[2] = { 0, 

[Bf-blender-cvs] [2e64b16879c] temp-trimesh-sculpt: * More roughing out of code

2020-10-13 Thread Joseph Eagar
Commit: 2e64b16879c2d7986f94e7de4242ebdb7b4464ca
Author: Joseph Eagar
Date:   Tue Sep 29 18:39:27 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB2e64b16879c2d7986f94e7de4242ebdb7b4464ca

* More roughing out of code

===

M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_trimesh.h
M   source/blender/blenlib/intern/BLI_trimesh.c

===

diff --git a/source/blender/blenkernel/intern/pbvh_intern.h 
b/source/blender/blenkernel/intern/pbvh_intern.h
index fa054efbecb..cabe96dc158 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -178,9 +178,11 @@ struct PBVH {
   struct BMLog *bm_log;
 
   /* trimesh data */
-  struct TriMesh *tm;
+  struct BLI_TriMesh *tm;
   float tm_max_edge_len;
   float tm_min_edge_len;
+
+  struct TriMeshLog *tm_log;
 };
 
 /* pbvh.c */
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index 71054592e18..35accad9133 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -74,9 +74,9 @@ static void pbvh_trimesh_verify(PBVH *bvh);
 
 #define _TRITEST(a, b, c) tri->v1 == a && tri->v2 == b && tri->v3 == c
 
-OptTri *trimesh_tri_exists(OptTriEdge *e, OptTriVert *opposite) {
+TMFace *trimesh_tri_exists(TMEdge *e, TMVert *opposite) {
   for (int i=0; itris.length; i++) {
-OptTri *tri = e->tris.items[i];
+TMFace *tri = e->tris.items[i];
 
 if (_TRITEST(e->v1, e->v2, opposite))
   return tri;
@@ -94,6 +94,38 @@ OptTri *trimesh_tri_exists(OptTriEdge *e, OptTriVert 
*opposite) {
 }
 #undef _TRITEST
 
+
+/**
+* Uses a map of vertices to lookup the final target.
+* References can't point to previous items (would cause infinite loop).
+*/
+static TMVert *tm_vert_hash_lookup_chain(GHash *deleted_verts, TMVert *v)
+{
+  while (true) {
+TMVert **v_next_p = (TMVert **)BLI_ghash_lookup_p(deleted_verts, v);
+
+if (v_next_p == NULL) {
+  /* not remapped*/
+  return v;
+}
+else if (*v_next_p == NULL) {
+  /* removed and not remapped */
+  return NULL;
+}
+else {
+  /* remapped */
+  v = *v_next_p;
+}
+  }
+}
+
+
+static void tm_edges_from_tri(BLI_TriMesh *tm, TMVert *vs[3], TMEdge *es[3], 
int threadnr, bool skipcd) {
+  es[0] = BLI_trimesh_get_edge(tm, vs[0], vs[1], threadnr, skipcd);
+  es[1] = BLI_trimesh_get_edge(tm, vs[1], vs[2], threadnr, skipcd);
+  es[2] = BLI_trimesh_get_edge(tm, vs[2], vs[0], threadnr, skipcd);
+}
+
 /* Update node data after splitting */
 static void pbvh_trimesh_node_finalize(PBVH *bvh,
   const int node_index,
@@ -111,16 +143,16 @@ static void pbvh_trimesh_node_finalize(PBVH *bvh,
   BB_reset(&n->vb);
 
   GSET_ITER (gs_iter, n->tm_faces) {
-OptTri *f = BLI_gsetIterator_getKey(&gs_iter);
+TMFace *f = BLI_gsetIterator_getKey(&gs_iter);
 
 /* Update ownership of faces */
 TRIMESH_ELEM_CD_SET_INT(f, cd_face_node_offset, node_index);
 
 /* Update vertices */
 for (int i=0; i<3; i++) {
-  OptTriVert *v = TRIMESH_GET_TRI_VERT(f, i);
-  OptTriEdge *e = TRIMESH_GET_TRI_EDGE(f, i);
-  OptTriLoop *l = TRIMESH_GET_TRI_LOOP(f, i);
+  TMVert *v = TRIMESH_GET_TRI_VERT(f, i);
+  TMEdge *e = TRIMESH_GET_TRI_EDGE(f, i);
+  TMLoopData *l = TRIMESH_GET_TRI_LOOP(f, i);
 
   if (TRIMESH_ELEM_CD_GET_INT(v, cd_vert_node_offset) != 
DYNTOPO_NODE_NONE) {
 BLI_gset_add(n->tm_other_verts, v);
@@ -163,7 +195,7 @@ static void pbvh_trimesh_node_split(PBVH *bvh, const BBC 
*bbc_array, int node_in
   BB_reset(&cb);
   GSetIterator gs_iter;
   GSET_ITER (gs_iter, n->tm_faces) {
-const OptTri *f = BLI_gsetIterator_getKey(&gs_iter);
+const TMFace *f = BLI_gsetIterator_getKey(&gs_iter);
 const BBC *bbc = &bbc_array[f->index];
 
 BB_expand(&cb, bbc->bcentroid);
@@ -190,7 +222,7 @@ static void pbvh_trimesh_node_split(PBVH *bvh, const BBC 
*bbc_array, int node_in
 
   /* Partition the parent node's faces between the two children */
   GSET_ITER (gs_iter, n->tm_faces) {
-OptTri *f = BLI_gsetIterator_getKey(&gs_iter);
+TMFace *f = BLI_gsetIterator_getKey(&gs_iter);
 const BBC *bbc = &bbc_array[f->index];
 
 if (bbc->bcentroid[axis] < mid) {
@@ -225,7 +257,7 @@ static void pbvh_trimesh_node_split(PBVH *bvh, const BBC 
*bbc_array, int node_in
   /* Mark this node's unique verts as unclaimed */
   if (n->tm_unique_verts) {
 GSET_ITER (gs_iter, n->tm_unique_verts) {
-  OptTriVert *v = BLI_gsetIterator_getKey(&gs_iter);
+  TMVert *v = BLI_gsetIterator_getKey(&gs_iter);
   TRIMESH_ELEM_CD_SET_INT(v, cd_vert_node_offset, DYNTOPO_NODE_NONE);
 }
 BLI_gset_free(n->tm_unique_verts, NULL);
@@ -233,7 +265,7 @@ static void

[Bf-blender-cvs] [d26b8c0e2a4] temp-trimesh-sculpt: moved trimesh into its own folder, source/blender/trimesh

2020-10-13 Thread Joseph Eagar
Commit: d26b8c0e2a46adecdb4d1eed782307c0f0bd6ed0
Author: Joseph Eagar
Date:   Tue Sep 29 20:06:32 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBd26b8c0e2a46adecdb4d1eed782307c0f0bd6ed0

moved trimesh into its own folder, source/blender/trimesh

===

M   source/blender/CMakeLists.txt
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/paint.c
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/CMakeLists.txt
R073source/blender/blenlib/intern/BLI_trimesh.c 
source/blender/trimesh/intern/trimesh.c
R098source/blender/blenlib/BLI_trimesh.hsource/blender/trimesh/trimesh.h

===

diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 203b6da272f..46f7b24f618 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -98,6 +98,7 @@ add_subdirectory(editors)
 add_subdirectory(windowmanager)
 add_subdirectory(blenkernel)
 add_subdirectory(blenlib)
+add_subdirectory(trimesh)
 add_subdirectory(bmesh)
 add_subdirectory(draw)
 add_subdirectory(render)
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 6233de63d22..2aed99caa37 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -25,6 +25,7 @@ set(INC
   ../blenloader
   ../blentranslation
   ../bmesh
+  ../trimesh
   ../depsgraph
   ../draw
   ../gpencil_modifiers
@@ -403,6 +404,7 @@ set(LIB
   bf_blenloader
   bf_blentranslation
   bf_bmesh
+  bf_trimesh
   bf_depsgraph
   bf_draw
   bf_gpencil_modifiers
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index cfd7d758d91..dbdaea5f5aa 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -74,7 +74,7 @@
 #include "RNA_enum_types.h"
 
 #include "bmesh.h"
-#include "BLI_trimesh.h"
+#include "trimesh.h"
 
 static void palette_init_data(ID *id)
 {
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index c0869088d87..dfd670faaab 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -28,7 +28,7 @@
 #include "BLI_utildefines.h"
 
 #include "BLI_threadsafe_mempool.h"
-#include "BLI_trimesh.h"
+#include "trimesh.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_ccg.h"
diff --git a/source/blender/blenlib/CMakeLists.txt 
b/source/blender/blenlib/CMakeLists.txt
index 61cfd78f966..db1bee1a4fa 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -40,7 +40,6 @@ set(SRC
   intern/BLI_dial_2d.c
   intern/BLI_dynstr.c
   intern/BLI_filelist.c
-  intern/BLI_trimesh.c
   intern/BLI_ghash.c
   intern/BLI_ghash_utils.c
   intern/BLI_heap.c
diff --git a/source/blender/blenlib/intern/BLI_trimesh.c 
b/source/blender/trimesh/intern/trimesh.c
similarity index 73%
rename from source/blender/blenlib/intern/BLI_trimesh.c
rename to source/blender/trimesh/intern/trimesh.c
index 0e88272ae68..d201dfaea92 100644
--- a/source/blender/blenlib/intern/BLI_trimesh.c
+++ b/source/blender/trimesh/intern/trimesh.c
@@ -18,7 +18,7 @@
  */
 
  /** \file
-  * \ingroup bli
+  * \ingroup trimesh
   *
   * optimized thread-safe triangle mesh library with topological info
   *
@@ -30,7 +30,7 @@
 #include "BLI_listbase.h"
 
 #include "BLI_math.h"
-#include "BLI_trimesh.h"
+#include "trimesh.h"
 #include "BLI_threadsafe_mempool.h"
 #include "BLI_array.h"
 
@@ -57,33 +57,8 @@
 #  include "valgrind/memcheck.h"
 #endif
 
+#include "trimesh_private.h"
 
-#define TRIVERT(tri, n) ((&(tri)->v1)[n])
-#define TRIEDGE(tri, n) ((&(tri)->e1)[n])
-
-#define TRILOOP(tri, n) ((&(tri)->l1)[n])
-
-enum {
-  TM_VERTEX = 1,
-  TM_EDGE = 2,
-  TM_LOOP = 4,
-  TM_TRI = 8
-};
-
-enum {
-POOL_VERTEX = 0,
-POOL_EDGE = 1,
-//POOL_LOOP = 2,
-POOL_TRI = 2,
-POOL_ELIST = 3, //pool for lists of edges around vertices
-POOL_TLIST = 4, //pool for lists of triangles around edges
-#ifdef WITH_TRIMESH_CUSTOMDATA
-POOL_LOOP = 5
-#endif
-};
-
-#define V_ELIST_ESIZE 5
-#define E_TLIST_ESIZE 2
 
 //keep up to sync with MAX_TRIMESH_POOLS in BLI_trimesh.h
 static int poolsizes[] = {
@@ -92,39 +67,23 @@ static int poolsizes[] = {
   sizeof(TMFace),
   sizeof(void*)*V_ELIST_ESIZE,
   sizeof(void*)*E_TLIST_ESIZE,
-#ifdef WITH_TRIMESH_CUSTOMDATA
   sizeof(TMLoopData)
-#endif
 };
 
-#ifdef WITH_TRIMESH_CUSTOMDATA
 void trimesh_element_init(void *elem, CustomData *customdata) {
-#else
-void trimesh_element_init(void *elem) {
-#endif
 
-#ifdef WITH_TRIMESH_CUSTOMDATA
   TMElement *e = elem;
 
   CustomData_bmesh_set_default(customdata, &e->customdata);
-#endif
 }
 
-#ifdef WITH_TRIMESH_CUSTOMDATA
 void trimesh_element_destroy(void *elem, int threadnr, CustomData *c

[Bf-blender-cvs] [ed66631de47] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: ed66631de47278b1b9a40520a41ab8c040e750d4
Author: Joseph Eagar
Date:   Thu Oct 1 21:34:51 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBed66631de47278b1b9a40520a41ab8c040e750d4

Merge branch 'master' of git://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [db35853b19b] temp-trimesh-sculpt: more trimesh stuff

2020-10-13 Thread Joseph Eagar
Commit: db35853b19b60ad6111a8412eb400e89ec8ec301
Author: Joseph Eagar
Date:   Wed Sep 30 04:35:52 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBdb35853b19b60ad6111a8412eb400e89ec8ec301

more trimesh stuff

===

M   source/blender/blenkernel/BKE_customdata.h
M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/DerivedMesh.c
M   source/blender/blenkernel/intern/customdata.c
M   source/blender/blenkernel/intern/paint.c
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_threadsafe_mempool.h
M   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
M   source/blender/bmesh/intern/bmesh_interp.c
M   source/blender/bmesh/intern/bmesh_mesh.c
M   source/blender/bmesh/intern/bmesh_mesh_conv.c
M   source/blender/editors/object/object_remesh.c
M   source/blender/editors/sculpt_paint/CMakeLists.txt
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/space_info/CMakeLists.txt
M   source/blender/editors/space_info/info_stats.c
M   source/blender/makesdna/DNA_customdata_types.h
M   source/blender/trimesh/intern/trimesh.c
M   source/blender/trimesh/trimesh.h

===

diff --git a/source/blender/blenkernel/BKE_customdata.h 
b/source/blender/blenkernel/BKE_customdata.h
index a4a36343ca3..f23b0ae07da 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -310,6 +310,15 @@ void CustomData_bmesh_interp(struct CustomData *data,
  int count,
  void *dst_block);
 
+struct TM_TriMesh;
+void CustomData_trimesh_init_pool(struct TM_TriMesh *tm, struct CustomData 
*data, int totelem, const char htype);
+bool CustomData_trimesh_merge(const struct CustomData *source,
+  struct CustomData *dest,
+  CustomDataMask mask,
+  eCDAllocType alloctype,
+  struct TM_TriMesh *bm,
+  const char htype);
+
 /* swaps the data in the element corners, to new corners with indices as
  * specified in corner_indices. for edges this is an array of length 2, for
  * faces an array of length 4 */
diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index d840b6e5734..27363484673 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -394,7 +394,6 @@ typedef struct SculptSession {
* Set #Main.is_memfile_undo_flush_needed when enabling.
*/
   char needs_flush_to_id;
-
 } SculptSession;
 
 void BKE_sculptsession_free(struct Object *ob);
@@ -403,6 +402,9 @@ void BKE_sculptsession_free_vwpaint_data(struct 
SculptSession *ss);
 void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
 void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
 
+void BKE_sculptsession_tm_to_me(struct Object *ob, bool reorder);
+void BKE_sculptsession_tm_to_me_for_render(struct Object *object);
+
 void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph,
struct Object *ob_orig,
bool need_pmap,
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index cabacabf0ad..8d26704446d 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -352,6 +352,8 @@ bool BKE_pbvh_is_deformed(struct PBVH *pbvh);
 #define PBVH_ITER_ALL 0
 #define PBVH_ITER_UNIQUE 1
 
+struct TMVert;
+
 typedef struct PBVHVertexIter {
   /* iteration */
   int g;
@@ -381,12 +383,18 @@ typedef struct PBVHVertexIter {
   struct GSetIterator bm_unique_verts;
   struct GSetIterator bm_other_verts;
   struct CustomData *bm_vdata;
+
+  struct GSetIterator tm_unique_verts;
+  struct GSetIterator tm_other_verts;
+  struct CustomData *tm_vdata;
+
   int cd_vert_mask_offset;
 
   /* result: these are all computed in the macro, but we assume
* that compiler optimization's will skip the ones we don't use */
   struct MVert *mvert;
   struct BMVert *bm_vert;
+  struct TMVert *tm_vert;
   float *co;
   short *no;
   float *fno;
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c 
b/source/blender/blenkernel/intern/DerivedMesh.c
index baef2b2290e..20673938bfa 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -904,7 +904,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
   const bool has_multires = (mmd && BKE_multires_sculpt_level_get(mmd) != 0);
   bool multires_applied = false;
   const bool sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt && 
!use_render;
-  const bool sculpt_dyntopo = (sculpt_mode && ob-

[Bf-blender-cvs] [a62dd1e7413] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: a62dd1e74130dfc5e7bd87bda49c7dc2a72de129
Author: Joseph Eagar
Date:   Wed Sep 30 04:39:02 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBa62dd1e74130dfc5e7bd87bda49c7dc2a72de129

Merge branch 'master' of git://git.blender.org/blender

===



===

diff --cc release/scripts/addons
index a32b859fecb,feca8c52897..3d2076556a7
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit a32b859fecb1a1d269408d0b9730eb5c7fc52c0f
 -Subproject commit feca8c5289794a70bdd375be76fc4bc59d83c96b
++Subproject commit 3d2076556a73af15779fc06630a3254fd584af02
diff --cc source/tools
index 4a6f1706258,2afbb8ec472..6dddb863ddc
--- a/source/tools
+++ b/source/tools
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 4a6f1706258439db3ee5a50ec6938fef79c7cb97
 -Subproject commit 2afbb8ec472cac5102eb239f57b006f8c9387685
++Subproject commit 6dddb863ddcced0e7f103f5b76ef7aeea48396ea

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


[Bf-blender-cvs] [cf9ec5bf1de] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: cf9ec5bf1de86793670c2a935482cd82e587164c
Author: Joseph Eagar
Date:   Fri Oct 2 13:38:09 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBcf9ec5bf1de86793670c2a935482cd82e587164c

Merge branch 'master' of git://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [4c3b444c85e] temp-trimesh-sculpt: it compiles

2020-10-13 Thread Joseph Eagar
Commit: 4c3b444c85e3c5686ffc32c915b6c1cf1c9545ea
Author: Joseph Eagar
Date:   Thu Oct 1 05:00:31 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB4c3b444c85e3c5686ffc32c915b6c1cf1c9545ea

it compiles

===

M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/paint.c
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
M   source/blender/editors/sculpt_paint/paint_hide.c
M   source/blender/editors/sculpt_paint/paint_mask.c
M   source/blender/editors/sculpt_paint/paint_vertex.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_boundary.c
M   source/blender/editors/sculpt_paint/sculpt_cloth.c
M   source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M   source/blender/editors/sculpt_paint/sculpt_face_set.c
M   source/blender/editors/sculpt_paint/sculpt_filter_color.c
M   source/blender/editors/sculpt_paint/sculpt_filter_mask.c
M   source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M   source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
M   source/blender/editors/sculpt_paint/sculpt_paint_color.c
M   source/blender/editors/sculpt_paint/sculpt_pose.c
M   source/blender/editors/sculpt_paint/sculpt_smooth.c
M   source/blender/editors/sculpt_paint/sculpt_transform.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c
M   source/blender/gpu/CMakeLists.txt
M   source/blender/gpu/GPU_buffers.h
M   source/blender/gpu/intern/gpu_buffers.c
M   source/blender/trimesh/intern/trimesh_conv.c
M   source/blender/trimesh/intern/trimesh_log.c
M   source/blender/trimesh/intern/trimesh_private.h
M   source/blender/trimesh/trimesh.h

===

diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index fb56c13d0c8..dbed842ea9e 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -255,6 +255,7 @@ int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh);
 struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
 struct TM_TriMesh *BKE_pbvh_get_trimesh(PBVH *pbvh);
 void BKE_pbvh_topology_detail_size_set(PBVH *pbvh, float detail_size);
+void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size);
 
 typedef enum {
   PBVH_Subdivide = 1,
@@ -472,6 +473,24 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, 
PBVHVertexIter *vi, int m
 vi.col = vi.vcol[vi.index].color; \
   } \
 } \
+else if (vi.tm_vdata) { \
+  if (!BLI_gsetIterator_done(&vi.tm_unique_verts)) { \
+vi.tm_vert = BLI_gsetIterator_getKey(&vi.tm_unique_verts); \
+BLI_gsetIterator_step(&vi.tm_unique_verts); \
+  } \
+  else { \
+vi.tm_vert = BLI_gsetIterator_getKey(&vi.tm_other_verts); \
+BLI_gsetIterator_step(&vi.tm_other_verts); \
+  } \
+  vi.visible = !TM_elem_flag_test_bool(vi.tm_vert, TM_ELEM_HIDDEN); \
+  if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
+continue; \
+  } \
+  vi.co = vi.tm_vert->co; \
+  vi.fno = vi.tm_vert->no; \
+  vi.index = vi.tm_vert->index; \
+  vi.mask = TM_ELEM_CD_GET_VOID_P(vi.tm_vert, vi.cd_vert_mask_offset); 
\
+}\
 else { \
   if (!BLI_gsetIterator_done(&vi.bm_unique_verts)) { \
 vi.bm_vert = BLI_gsetIterator_getKey(&vi.bm_unique_verts); \
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 2ac2364fc93..ff0b8023c73 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1098,7 +1098,9 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint 
**r_paint)
 paint = &ts->imapaint.paint;
   }
 
-  paint->flags |= PAINT_SHOW_BRUSH;
+  if (paint) {
+paint->flags |= PAINT_SHOW_BRUSH;
+  }
 
   *r_paint = paint;
 
@@ -1218,9 +1220,9 @@ bool paint_is_bmesh_face_hidden(BMFace *f)
 /* Return true if all vertices in the face are visible, false otherwise */
 bool paint_is_trimesh_face_hidden(TMFace *f)
 {
-  bool ret = f->v1->flag & TRIMESH_HIDE;
-  ret = ret || (f->v2->flag & TRIMESH_HIDE);
-  ret = ret || (f->v3->flag & TRIMESH_HIDE);
+  bool ret = f->v1->flag & TM_ELEM_HIDDEN;
+  ret = ret || (f->v2->flag & TM_ELEM_HIDDEN);
+  ret = ret || (f->v3->flag & TM_ELEM_HIDDEN);
 
   return ret;
 }
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 288e64b6020..b502711578d 100644
--- a/sourc

[Bf-blender-cvs] [3559b8a651f] temp-trimesh-sculpt: Merge branch 'master' into joeedh-trimesh-sculpt

2020-10-13 Thread Joseph Eagar
Commit: 3559b8a651f8c714496f6e66d774b81fefcbab30
Author: Joseph Eagar
Date:   Wed Sep 30 05:13:47 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB3559b8a651f8c714496f6e66d774b81fefcbab30

Merge branch 'master' into joeedh-trimesh-sculpt

===



===

diff --cc intern/cycles/kernel/kernel_types.h
index 10e7268ae9d,77e134da4b0..951dcbe0eb0
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@@ -1347,11 -1373,10 +1374,13 @@@ typedef struct KernelIntegrator 
  
/* sampler */
int sampling_pattern;
 +  int coherency_shift;
 +  int coherency_only_blue;
 +  int use_bluenoise_seeds;
int aa_samples;
int adaptive_min_samples;
+   int adaptive_step;
+   int adaptive_stop_per_sample;
float adaptive_threshold;
  
/* volume render */
@@@ -1363,6 -1388,8 +1392,7 @@@
int start_sample;
  
int max_closures;
 -
 -  int pad1, pad2;
++  int pad1;
  } KernelIntegrator;
  static_assert_align(KernelIntegrator, 16);
  
diff --cc intern/ghost/intern/GHOST_WindowWin32.cpp
index 43020fbe489,55525157753..ec5062dc621
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@@ -1034,79 -1029,78 +1029,97 @@@ GHOST_TSuccess GHOST_WindowWin32::getPo
  return GHOST_kFailure;
}
  
-   pointerInfo->hasButtonMask = GHOST_kSuccess;
-   switch (pointerApiInfo.ButtonChangeType) {
- case POINTER_CHANGE_FIRSTBUTTON_DOWN:
- case POINTER_CHANGE_FIRSTBUTTON_UP:
-   pointerInfo->buttonMask = GHOST_kButtonMaskLeft;
-   break;
- case POINTER_CHANGE_SECONDBUTTON_DOWN:
- case POINTER_CHANGE_SECONDBUTTON_UP:
-   pointerInfo->buttonMask = GHOST_kButtonMaskRight;
-   break;
- case POINTER_CHANGE_THIRDBUTTON_DOWN:
- case POINTER_CHANGE_THIRDBUTTON_UP:
-   pointerInfo->buttonMask = GHOST_kButtonMaskMiddle;
-   break;
- case POINTER_CHANGE_FOURTHBUTTON_DOWN:
- case POINTER_CHANGE_FOURTHBUTTON_UP:
-   pointerInfo->buttonMask = GHOST_kButtonMaskButton4;
-   break;
- case POINTER_CHANGE_FIFTHBUTTON_DOWN:
- case POINTER_CHANGE_FIFTHBUTTON_UP:
-   pointerInfo->buttonMask = GHOST_kButtonMaskButton5;
-   break;
- default:
-   pointerInfo->hasButtonMask = GHOST_kFailure;
-   break;
-   }
- 
-   pointerInfo->pixelLocation = pointerApiInfo.ptPixelLocation;
-   pointerInfo->tabletData.Active = GHOST_kTabletModeNone;
-   pointerInfo->tabletData.Pressure = 1.0f;
-   pointerInfo->tabletData.Xtilt = 0.0f;
-   pointerInfo->tabletData.Ytilt = 0.0f;
- 
-   if (pointerApiInfo.pointerType == PT_PEN) {
-   POINTER_PEN_INFO pointerPenInfo;
-   if (m_fpGetPointerPenInfo && 
m_fpGetPointerPenInfo(pointerInfo->pointerId, &pointerPenInfo)) {
-   pointerInfo->tabletData.Active = GHOST_kTabletModeStylus;
- 
-   if (pointerPenInfo.penMask & PEN_MASK_PRESSURE) {
-   pointerInfo->tabletData.Pressure = pointerPenInfo.pressure / 
1024.0f;
-   }
+   GHOST_TInt32 pointerId = GET_POINTERID_WPARAM(wParam);
+   GHOST_TInt32 isPrimary = IS_POINTER_PRIMARY_WPARAM(wParam);
+   GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)GHOST_System::getSystem();
+   GHOST_TUns32 outCount;
  
-   if (pointerPenInfo.penFlags & PEN_FLAG_ERASER) {
-   pointerInfo->tabletData.Active = GHOST_kTabletModeEraser;
-   }
+   if (!(m_fpGetPointerInfoHistory && m_fpGetPointerInfoHistory(pointerId, 
&outCount, NULL))) {
+ return GHOST_kFailure;
+   }
  
-   if (pointerPenInfo.penFlags & PEN_MASK_TILT_X) {
-   pointerInfo->tabletData.Xtilt = fmin(fabs(pointerPenInfo.tiltX 
/ 90), 1.0f);
-   }
+   auto pointerPenInfo = std::vector(outCount);
+   outPointerInfo.resize(outCount);
  
-   if (pointerPenInfo.penFlags & PEN_MASK_TILT_Y) {
-   pointerInfo->tabletData.Ytilt = fmin(fabs(pointerPenInfo.tiltY 
/ 90), 1.0f);
-   }
-   }
-   } else if (pointerApiInfo.pointerType == PT_TOUCH) {
++#if 0
++  if (pointerApiInfo.pointerType == PT_TOUCH) {
 +  POINTER_TOUCH_INFO pointerTouchInfo;
 +
 +  if (m_fpGetPointerTouchInfo && 
m_fpGetPointerTouchInfo(pointerInfo->pointerId, &pointerTouchInfo)) {
 +  pointerInfo->tabletData.Active = GHOST_kTabletModeStylus;
 +
 +  if (pointerTouchInfo.touchMask & TOUCH_MASK_PRESSURE) {
 +  pointerInfo->tabletData.Pressure = 
((float)pointerTouchInfo.pressure) / 1024.0f;
 +  }
 +  
 +  if (pointerTouchInfo.touchMask & TOUCH_MASK_ORIENTATION) {
 +  pointerInfo->tabletData.Xtilt = 
fmin(fabs((float)pointerTouchInfo.orientation / 359.0f), 1.0f);
 +  }
 +  } else {
 +  pointerInfo->tabletData.Active = GHOST_kTabletModeNone;
 +  }
-   } else {
-   return GHOST_kFailure;
++  }
++#endif
++
+   if (!(m_fpGetPointerPenInfoHistory &&
+  

[Bf-blender-cvs] [27e47dd77ab] temp-trimesh-sculpt: a few bug fixes

2020-10-13 Thread Joseph Eagar
Commit: 27e47dd77abbcd90547ea9f432e2b09abc1d4267
Author: Joseph Eagar
Date:   Thu Oct 1 05:48:01 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB27e47dd77abbcd90547ea9f432e2b09abc1d4267

a few bug fixes

===

M   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
M   source/blender/trimesh/intern/trimesh.c
M   source/blender/trimesh/intern/trimesh_private.h
M   source/blender/trimesh/trimesh.h

===

diff --git a/source/blender/blenlib/intern/BLI_threadsafe_mempool.c 
b/source/blender/blenlib/intern/BLI_threadsafe_mempool.c
index c2bf45137f9..80e8eaf433a 100644
--- a/source/blender/blenlib/intern/BLI_threadsafe_mempool.c
+++ b/source/blender/blenlib/intern/BLI_threadsafe_mempool.c
@@ -65,7 +65,9 @@ void BLI_safepool_threadnr_set(int threadnr) {
 }
 
 static size_t get_chunk_size(BLI_ThreadSafePool* pool) {
-  return getalign(sizeof(pool_thread_data) + pool->esize*pool->csize);
+  return getalign(sizeof(pool_thread_data)) + pool->esize*pool->csize;
+
+  //return getalign(sizeof(pool_thread_data) + pool->esize*pool->csize);
 }
 
 #define getelem(elem) ((poolelem*) ((char*) (elem) - sizeof(void*)))
@@ -91,18 +93,19 @@ static poolchunk *new_chunk(BLI_ThreadSafePool *pool, 
pool_thread_data* thread_d
 
   chunk->magic = POOL_CHUNK_MAGIC;
   chunk->threadnr = thread_data - pool->threadchunks;
-
+  
   BLI_addtail(&thread_data->chunks, chunk);
   poolelem *first = NULL;
 
   for (size_t i = 0; i < pool->csize-1; i++) {
 poolelem *de = (poolelem*)(((char*)chunk) + sizeof(poolchunk) + esize*i);
+poolelem *next = (poolelem*)(((char*)chunk) + sizeof(poolchunk) + 
esize*(i+1));
 
 if (i ==  0) {
   first = de;
 }
 
-de->next = de + 1;
+de->next = next;
 de->dead_magic = DEAD_MAGIC;
   }
 
@@ -118,11 +121,18 @@ static poolchunk *new_chunk(BLI_ThreadSafePool *pool, 
pool_thread_data* thread_d
 BLI_ThreadSafePool* BLI_safepool_create(int elemsize, int chunksize, int 
maxthread) {
   BLI_ThreadSafePool* pool = MEM_callocN(sizeof(*pool), "BLI_ThreadSafePool");
 
-  elemsize = MAX2(elemsize, sizeof(void*)*2);
+  //align to pointer size
+  if (elemsize & 7) {
+elemsize += 8 - (elemsize & 7);
+  }
+
+  //add header pointer to owning chunk
+  elemsize = MAX2(elemsize + sizeof(void*), sizeof(void*)*2);
+  maxthread = MAX2(maxthread, 1);
 
   pool->maxthread = maxthread;
   pool->threadchunks = MEM_callocN(sizeof(pool_thread_data) * maxthread, 
"pool->threadchunks");
-  pool->esize = elemsize + sizeof(void*); //add header pointer to owning chunk
+  pool->esize = elemsize; 
   pool->csize = chunksize;
 
 #ifdef BLI_SAFEPOOL_HAVE_LENGTH
@@ -132,6 +142,7 @@ BLI_ThreadSafePool* BLI_safepool_create(int elemsize, int 
chunksize, int maxthre
   for (int i = 0; i < maxthread; i++) {
 BLI_rw_mutex_init(&pool->threadchunks[i].lock);
 pool->threadchunks[i].threadnr = i;
+memset(pool->threadchunks + i, 0, sizeof(pool_thread_data));
 new_chunk(pool, pool->threadchunks + i);
   }
 
@@ -292,7 +303,7 @@ void* BLI_safepool_iterstep(ThreadSafePoolIter* iter) {
 iter->i = -1; //flag end of iteration
   }
 
-  poolelem *de = getelem(ptr);
+  poolelem *de = (poolelem*) ptr;
 
   if (!ptr || de->dead_magic == DEAD_MAGIC) {
 return BLI_safepool_iterstep(iter);
diff --git a/source/blender/trimesh/intern/trimesh.c 
b/source/blender/trimesh/intern/trimesh.c
index f60d2bf8fe8..782a1b26502 100644
--- a/source/blender/trimesh/intern/trimesh.c
+++ b/source/blender/trimesh/intern/trimesh.c
@@ -72,7 +72,9 @@ static int poolsizes[] = {
 void trimesh_element_init(void *elem, CustomData *customdata) {
 
   TMElement *e = elem;
-
+  e->customdata = NULL;
+  e->flag = e->index = e->threadtag = 0;
+  
   CustomData_bmesh_set_default(customdata, &e->customdata);
 }
 
@@ -84,6 +86,7 @@ void trimesh_element_destroy(void *elem, int threadnr, 
CustomData *customdata) {
 
 static TMLoopData *trimesh_make_loop(TM_TriMesh *tm, int threadnr, bool 
skipcd) {
   TMLoopData *loop = BLI_safepool_alloc(tm->pools[POOL_LOOP]);
+
   trimesh_element_init(loop, &tm->ldata);
 
   return loop;
@@ -132,8 +135,11 @@ TM_TriMesh* TMesh_new(int maxthread) {
   TM_TriMesh* tm = MEM_callocN(sizeof(*tm), "OptTriMesh");
   int i;
 
+  maxthread = MAX2(maxthread, 1);
+  tm->maxthread = maxthread;
+
   for (i = 0; i < MAX_TRIMESH_POOLS; i++) {
-tm->pools[i] = BLI_safepool_create(poolsizes[i], 0, maxthread);
+tm->pools[i] = BLI_safepool_create(poolsizes[i], 512, maxthread);
   }
 
   return tm;
@@ -156,9 +162,12 @@ static TMEdge *ensure_edge(TM_TriMesh* tm, TMVert* v1, 
TMVert* v2, int threadnr,
   e->v1 = v1;
   e->v2 = v2;
 
+  trilist_simplelist_init(tm, &e->tris, E_TLIST_ESIZE, POOL_TLIST);
+
   trilist_simplelist_append(tm, &e->v1->edges, e, POOL_ELIST, threadnr);
   trilist_simplelist_append(tm, &e->v2->edges, e, POOL_ELIST, threadnr);
 
+  memset(&e->tris,

[Bf-blender-cvs] [cd24c4b30aa] temp-trimesh-sculpt: prepare for merge

2020-10-13 Thread Joseph Eagar
Commit: cd24c4b30aa6af4d3f00cbbe52c57060b6b6825d
Author: Joseph Eagar
Date:   Thu Oct 1 03:20:15 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBcd24c4b30aa6af4d3f00cbbe52c57060b6b6825d

prepare for merge

===

M   intern/cycles/kernel/kernel_types.h
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/editors/sculpt_paint/sculpt.c

===

diff --git a/intern/cycles/kernel/kernel_types.h 
b/intern/cycles/kernel/kernel_types.h
index 951dcbe0eb0..efd283fce0a 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1392,7 +1392,7 @@ typedef struct KernelIntegrator {
   int start_sample;
 
   int max_closures;
-  int pad1;
+  int pad1, pad2, pad3;
 } KernelIntegrator;
 static_assert_align(KernelIntegrator, 16);
 
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h 
b/source/blender/blenkernel/intern/pbvh_intern.h
index 5ba3c746f82..3c14310ad6f 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -1,3 +1,6 @@
+#ifndef _PBVH_INTERN_H
+#define _PBVH_INTERN_H
+
 /*
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -270,4 +273,4 @@ bool pbvh_trimesh_node_nearest_to_ray(PBVHNode *node,
 
 void pbvh_trimesh_normals_update(PBVHNode **nodes, int totnode);
 
-#endif
+#endif /* _PBVH_INTERN_H */
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 454b4296ce9..9c3a411d47a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -7414,6 +7414,7 @@ float SCULPT_raycast_init(ViewContext *vc,
   Object *ob = vc->obact;
   RegionView3D *rv3d = vc->region->regiondata;
   View3D *v3d = vc->v3d;
+  SculptSession *ss = ob->sculpt;
 
   /* TODO: what if the segment is totally clipped? (return == 0). */
   ED_view3d_win_to_segment_clipped(
@@ -7432,7 +7433,7 @@ float SCULPT_raycast_init(ViewContext *vc,
 
   if ((rv3d->is_persp == false) &&
   /* If the ray is clipped, don't adjust its start/end. */
-  RV3D_CLIPPING_ENABLED(v3d, rv3d)) {
+  RV3D_CLIPPING_ENABLED(v3d, cdrv3d)) {
 BKE_pbvh_raycast_project_ray_root(ob->sculpt->pbvh, original, ray_start, 
ray_end, ray_normal);
 
 /* rRecalculate the normal. */

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


[Bf-blender-cvs] [5111efd42df] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: 5111efd42df53aae64360edf6a8a32434d5a46aa
Author: Joseph Eagar
Date:   Thu Oct 1 03:20:35 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB5111efd42df53aae64360edf6a8a32434d5a46aa

Merge branch 'master' of git://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [5075082b590] temp-trimesh-sculpt: add these files

2020-10-13 Thread Joseph Eagar
Commit: 5075082b5909ff0528bb06d1e6a7300a8e7e54d1
Author: Joseph Eagar
Date:   Wed Sep 30 04:36:45 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB5075082b5909ff0528bb06d1e6a7300a8e7e54d1

add these files

===

A   source/blender/trimesh/CMakeLists.txt
A   source/blender/trimesh/intern/trimesh_conv.c
A   source/blender/trimesh/intern/trimesh_log.c
A   source/blender/trimesh/intern/trimesh_private.h
A   source/blender/trimesh/intern/trimesh_thread.c

===

diff --git a/source/blender/trimesh/CMakeLists.txt 
b/source/blender/trimesh/CMakeLists.txt
new file mode 100644
index 000..6588bbad260
--- /dev/null
+++ b/source/blender/trimesh/CMakeLists.txt
@@ -0,0 +1,74 @@
+# * BEGIN GPL LICENSE BLOCK *
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2006, Blender Foundation
+# All rights reserved.
+# * END GPL LICENSE BLOCK *
+
+set(INC
+  .
+  ./intern
+  ../blenkernel
+  ../blenlib
+  ../bmesh
+  ../blentranslation
+  ../makesdna
+  ../../../intern/atomic
+  ../../../intern/eigen
+  ../../../intern/guardedalloc
+  ../../../extern/rangetree
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+  intern/trimesh.c
+  intern/trimesh_log.c
+  intern/trimesh_thread.c
+  intern/trimesh_conv.c
+  intern/trimesh_private.h
+  trimesh.h
+)
+
+set(LIB
+  bf_blenkernel
+  bf_blenlib
+  extern_rangetree
+)
+
+if(WITH_BULLET)
+  list(APPEND INC_SYS
+${BULLET_INCLUDE_DIRS}
+  )
+  list(APPEND LIB
+extern_bullet
+
+${BULLET_LIBRARIES}
+  )
+  add_definitions(-DWITH_BULLET)
+endif()
+
+if(WITH_INTERNATIONAL)
+  add_definitions(-DWITH_INTERNATIONAL)
+endif()
+
+if(WITH_FREESTYLE)
+  add_definitions(-DWITH_FREESTYLE)
+endif()
+
+blender_add_lib(bf_trimesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/trimesh/intern/trimesh_conv.c 
b/source/blender/trimesh/intern/trimesh_conv.c
new file mode 100644
index 000..0e628157739
--- /dev/null
+++ b/source/blender/trimesh/intern/trimesh_conv.c
@@ -0,0 +1,460 @@
+/*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* The Original Code is Copyright (C) 2008 by Blender Foundation.
+* All rights reserved.
+*/
+
+/** \file
+* \ingroup trimesh
+*
+* optimized thread-safe triangle mesh library with topological info
+*
+*/
+
+#include 
+#include 
+
+#include "BLI_listbase.h"
+
+#include "BLI_math.h"
+#include "BLI_threadsafe_mempool.h"
+#include "BLI_array.h"
+#include "BLI_alloca.h"
+
+#include "DNA_key_types.h"
+#include "DNA_customdata_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+
+#include "atomic_ops.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+
+#include "BKE_customdata.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
+#include "BKE_multires.h"
+
+#include "BKE_key.h"
+#include "BKE_main.h"
+
+#include "MEM_guardedalloc.h"
+#ifdef WITH_MEM_VALGRIND
+#  include "valgrind/memcheck.h"
+#endif
+
+#include "trimesh_private.h"
+#include "trimesh.h"
+#include "bmesh.h"
+
+/* ME -> BM */
+char TM_vert_flag_from_mflag(const char meflag)
+{
+  return (((meflag & SELECT) ? SELECT : 0) | ((meflag & ME_HIDE) ? 
TRIMESH_HIDE : 0));
+}
+char TM_edge_flag_from_mflag(const short meflag)
+{
+  return (((meflag & SELECT) ? SELECT : 0) | ((meflag & ME_SEAM) ? 
TRIMESH_SEAM : 0) |
+((meflag & ME_EDGEDRAW) ? TRIMESH_EDGEDRAW : 0) |
+((meflag & ME_SHARP) == 0 ? TRIMESH_SHARP : 0) | /* invert */
+((meflag & ME_HIDE) ? TRI

[Bf-blender-cvs] [52de938667f] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: 52de938667f757a882cedc739f36f80fa0236e60
Author: Joseph Eagar
Date:   Sun Oct 4 17:11:26 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB52de938667f757a882cedc739f36f80fa0236e60

Merge branch 'master' of git://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [f084d3958b8] temp-trimesh-sculpt: Merge branch 'master' into joeedh-trimesh-sculpt

2020-10-13 Thread Joseph Eagar
Commit: f084d3958b8c21a44428bea516f305babf4f60aa
Author: Joseph Eagar
Date:   Sun Oct 4 17:12:46 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBf084d3958b8c21a44428bea516f305babf4f60aa

Merge branch 'master' into joeedh-trimesh-sculpt

===



===

diff --cc intern/cycles/render/integrator.cpp
index 75a50541275,4d1e95a0db7..6bea1d14b5f
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@@ -23,8 -23,8 +23,9 @@@
  #include "render/scene.h"
  #include "render/shader.h"
  #include "render/sobol.h"
- #include "kernel/kernel_bluenoise_mask.h"
+ #include "render/stats.h"
  
++#include "kernel/kernel_bluenoise_mask.h"
  #include "kernel/kernel_types.h"
  
  #include "util/util_foreach.h"

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


[Bf-blender-cvs] [ceeb5af1b3a] temp-trimesh-sculpt: Merge branch 'master' of git://git.blender.org/blender

2020-10-13 Thread Joseph Eagar
Commit: ceeb5af1b3a2d3eab786bd5e01cbb4e17484297f
Author: Joseph Eagar
Date:   Sun Oct 4 04:12:09 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBceeb5af1b3a2d3eab786bd5e01cbb4e17484297f

Merge branch 'master' of git://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [919bdeb9279] temp-trimesh-sculpt: stupid submodules, the helpful "here's how to revert accidental git add" from git did not work.

2020-10-13 Thread Joseph Eagar
Commit: 919bdeb92798ff929d6115c22551ed377f87e43f
Author: Joseph Eagar
Date:   Sun Oct 4 17:48:46 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB919bdeb92798ff929d6115c22551ed377f87e43f

stupid submodules, the helpful "here's how to revert accidental git add"
from git did not work.

stupid.

===

D   extern/parallel-hashmap

===

diff --git a/extern/parallel-hashmap b/extern/parallel-hashmap
deleted file mode 16
index 72beffb1407..000
--- a/extern/parallel-hashmap
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 72beffb14075ca9d9dd6560bdbe924e57cb0d3df

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


[Bf-blender-cvs] [6a3abe3d816] temp-trimesh-sculpt: More trimesh stuff.

2020-10-13 Thread Joseph Eagar
Commit: 6a3abe3d81677df9345e7e7eb6dec5f9b3f2091c
Author: Joseph Eagar
Date:   Thu Oct 1 21:34:10 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB6a3abe3d81677df9345e7e7eb6dec5f9b3f2091c

More trimesh stuff.

Yeesh, the pbvh leaf limit in both trimesh and the original bmesh
code seems to be a bit low.  eek

===

M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_ghash.h
M   source/blender/blenlib/intern/BLI_ghash.c
M   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
M   source/blender/bmesh/operators/bmo_fill_grid.c
M   source/blender/bmesh/operators/bmo_hull.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c
M   source/blender/trimesh/intern/trimesh.c
M   source/blender/trimesh/intern/trimesh_conv.c
M   source/blender/trimesh/intern/trimesh_log.c
M   source/blender/trimesh/intern/trimesh_private.h
M   source/blender/trimesh/intern/trimesh_thread.c
M   source/blender/trimesh/trimesh.h

===

diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index 35b2386acb4..47023dfccf8 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -97,6 +97,8 @@ TMFace *trimesh_tri_exists(TMEdge *e, TMVert *opposite) {
 if (_TRITEST(opposite, e->v2, e->v1))
   return tri;
   }
+
+  return NULL;
 }
 #undef _TRITEST
 
@@ -272,7 +274,9 @@ static void pbvh_trimesh_node_split(PBVH *bvh, const BBC 
*bbc_array, int node_in
   /* Unclaim faces */
   GSET_ITER (gs_iter, n->tm_faces) {
 TMFace *f = BLI_gsetIterator_getKey(&gs_iter);
-TM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
+if (f) {
+//  TM_ELEM_CD_SET_INT(f, cd_face_node_offset, DYNTOPO_NODE_NONE);
+}
   }
   BLI_gset_free(n->tm_faces, NULL);
 
@@ -339,7 +343,7 @@ static bool pbvh_trimesh_node_limit_ensure(PBVH *bvh, int 
node_index)
 f->index = i; /* set_dirty! */
   }
   /* Likely this is already dirty. */
-  bvh->tm->elem_index_dirty |= BM_FACE;
+  bvh->tm->elem_index_dirty |= TM_VERTEX;
 
   pbvh_trimesh_node_split(bvh, bbc_array, node_index);
 
@@ -409,7 +413,13 @@ BLI_INLINE PBVHNode *pbvh_trimesh_node_from_vert(PBVH 
*bvh, const TMVert *key)
 
 BLI_INLINE PBVHNode *pbvh_trimesh_node_from_face(PBVH *bvh, const TMFace *key)
 {
-  return &bvh->nodes[pbvh_trimesh_node_index_from_face(bvh, key)];
+  int ni = pbvh_trimesh_node_index_from_face(bvh, key);
+
+  if (ni <= 0) {
+return NULL;
+  }
+
+  return &bvh->nodes[ni];
 }
 
 static TMVert *pbvh_trimesh_vert_create(
@@ -584,7 +594,7 @@ static void pbvh_trimesh_face_remove(PBVH *bvh, TMFace *f)
   /* Check if any of this face's vertices need to be removed
   * from the node */
 
-  for (int i=0; i<3; i++) {
+  for (int i=0; f_node && i<3; i++) {
 TMVert *v = TM_GET_TRI_VERT(f, i);
 
 if (pbvh_trimesh_node_vert_use_count_is_equal(bvh, f_node, v, 1)) {
@@ -607,14 +617,18 @@ static void pbvh_trimesh_face_remove(PBVH *bvh, TMFace *f)
   }
 
   /* Remove face from node and top level */
-  BLI_gset_remove(f_node->tm_faces, f, NULL);
-  TM_ELEM_CD_SET_INT(f, bvh->cd_face_node_offset, DYNTOPO_NODE_NONE);
+  if (TM_ELEM_CD_GET_INT(f, bvh->cd_face_node_offset) != DYNTOPO_NODE_NONE) {
+BLI_gset_remove(f_node->tm_faces, f, NULL);
+TM_ELEM_CD_SET_INT(f, bvh->cd_face_node_offset, DYNTOPO_NODE_NONE);
+  }
 
   /* Log removed face */
   BLI_trimesh_log_tri_kill(bvh->tm_log, f, false, false);
 
   /* mark node for update */
-  f_node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
+  if (f_node) {
+f_node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
+  }
 }
 
 
@@ -823,7 +837,7 @@ static void long_edge_queue_edge_add_recursive(
 if (len_sq_other > max_ff(len_sq_cmp, limit_len_sq)) {
   //  edge_queue_insert(eq_ctx, l_adjacent[i]->e, 
-len_sq_other);
   long_edge_queue_edge_add_recursive(
-eq_ctx, l_adjacent[i], l_adjacent[i], 
TM_nextTriInEdge(l_adjacent[i], tri), tri, len_sq_other, limit_len);
+eq_ctx, l_adjacent[j], l_adjacent[j], 
TM_nextTriInEdge(l_adjacent[j], tri), tri, len_sq_other, limit_len);
 }
   }
 }
@@ -1036,86 +1050,58 @@ static void pbvh_trimesh_split_edge(EdgeQueueContext 
*eq_ctx,
   TMEdge *e)
 {
 
-  //remove existing faces from bvh
-  for (int i=0; itris.length; i++) {
-TMFace *tri = e->tris.items[i];
-
-pbvh_trimesh_face_remove(bvh, tri);
-  }
-
-  //split edge and triangles
-  //XXX threadnr argument!
-  TMVert *v_new = TM_split_edge(bvh->tm, e, 0, 0.5, true); //skipcd true, or 
false?
-
-  for (int i=0; iedges.length; i++) {
-TMEdge *e2 = v_new->edges.items[i];
-for (int j=0; jtris.length; j++) {
-  TMFace *f_adj = e2->tris.

[Bf-blender-cvs] [9d02e2eb1d7] temp-trimesh-sculpt: * Trimesh sculpt now exposes actual pointers for vert "indices."

2020-10-13 Thread Joseph Eagar
Commit: 9d02e2eb1d7bc3287e62b0a3148e012adb098cf6
Author: Joseph Eagar
Date:   Tue Oct 13 16:14:33 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB9d02e2eb1d7bc3287e62b0a3148e012adb098cf6

* Trimesh sculpt now exposes actual pointers for vert "indices."

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/editors/sculpt_paint/paint_cursor.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_automasking.c
M   source/blender/editors/sculpt_paint/sculpt_boundary.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M   source/blender/editors/sculpt_paint/sculpt_pose.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index cd6127512bc..248b53d3015 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -287,10 +287,10 @@ typedef struct SculptClothLengthConstraint {
* point, position for a previous state). In that case, elem_index_a and 
elem_index_b should be
* the same to avoid affecting two different vertices when solving the 
constraints.
* *elem_position points to the position which is owned by the element. */
-  int elem_index_a;
+  SculptIdx elem_index_a;
   float *elem_position_a;
 
-  int elem_index_b;
+  SculptIdx elem_index_b;
   float *elem_position_b;
 
   float length;
@@ -341,7 +341,7 @@ typedef struct SculptPersistentBase {
 
 typedef struct SculptVertexInfo {
   /* Idexed by vertex, stores and ID of its topologycally connected component. 
*/
-  int *connected_component;
+  SculptIdx *connected_component;
 
   /* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
   BLI_bitmap *boundary;
@@ -349,7 +349,7 @@ typedef struct SculptVertexInfo {
 
 typedef struct SculptBoundaryEditInfo {
   /* Vertex index from where the topology propagation reached this vertex. */
-  int original_vertex;
+  SculptIdx original_vertex;
 
   /* How many steps were needed to reach this vertex from the boundary. */
   int num_propagation_steps;
@@ -360,13 +360,13 @@ typedef struct SculptBoundaryEditInfo {
 
 /* Edge for drawing the boundary preview in the cursor. */
 typedef struct SculptBoundaryPreviewEdge {
-  int v1;
-  int v2;
+  SculptIdx v1;
+  SculptIdx v2;
 } SculptBoundaryPreviewEdge;
 
 typedef struct SculptBoundary {
   /* Vertex indices of the active boundary. */
-  int *vertices;
+  SculptIdx *vertices;
   int vertices_capacity;
   int num_vertices;
 
@@ -384,12 +384,12 @@ typedef struct SculptBoundary {
   bool forms_loop;
 
   /* Initial vertex in the boundary which is closest to the current sculpt 
active vertex. */
-  int initial_vertex;
+  SculptIdx initial_vertex;
 
   /* Vertex that at max_propagation_steps from the boundary and closest to the 
original active
* vertex that was used to initialize the boundary. This is used as a 
reference to check how much
* the deformation will go into the mesh and to calculate the strength of 
the brushes. */
-  int pivot_vertex;
+  SculptIdx pivot_vertex;
 
   /* Stores the initial positions of the pivot and boundary initial vertex as 
they may be deformed
* during the brush action. This allows to use them as a reference positions 
and vectors for some
@@ -429,7 +429,7 @@ typedef struct SculptFakeNeighbors {
   float current_max_distance;
 
   /* Idexed by vertex, stores the vertex index of its fake neighbor if 
available. */
-  int *fake_neighbor_index;
+  SculptIdx *fake_neighbor_index;
 
 } SculptFakeNeighbors;
 
@@ -519,7 +519,7 @@ typedef struct SculptSession {
   struct Scene *scene;
 
   /* Dynamic mesh preview */
-  int *preview_vert_index_list;
+  SculptIdx *preview_vert_index_list;
   int preview_vert_index_count;
 
   /* Pose Brush Preview */
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index fb5f14eb8a6..2fd0e34e0e1 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -26,7 +26,7 @@
 
 #include "stdint.h"
 
-typedef uintptr_t SculptIdx;
+typedef intptr_t SculptIdx;
 
 /* For embedding CCGKey in iterator. */
 #include "BKE_ccg.h"
@@ -491,7 +491,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, 
PBVHVertexIter *vi, int m
   } \
   vi.co = vi.tm_vert->co; \
   vi.fno = vi.tm_vert->no; \
-  vi.index = vi.tm_vert->index; \
+  vi.index = (SculptIdx)vi.tm_vert; \
   vi.mask = TM_ELEM_CD_GET_VOID_P(vi.tm_vert, vi.cd_vert_mask_offset); 
\
 }\
 else { \
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
ind

[Bf-blender-cvs] [3f59180b03d] temp-trimesh-sculpt: uncommit

2020-10-13 Thread Joseph Eagar
Commit: 3f59180b03dd881265ce03769c85edcd1962979f
Author: Joseph Eagar
Date:   Sun Oct 4 04:11:34 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB3f59180b03dd881265ce03769c85edcd1962979f

uncommit

===

M   intern/cycles/kernel/kernel_path_surface.h
M   source/blender/blenkernel/intern/customdata.c
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenlib/BLI_smallhash.h
M   source/blender/blenlib/intern/math_geom_inline.c
M   source/blender/blenlib/intern/smallhash.c
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/bmesh/intern/bmesh_polygon.c
M   source/blender/bmesh/intern/bmesh_polygon.h
M   source/blender/draw/engines/overlay/overlay_paint.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c
M   source/blender/makesdna/DNA_customdata_types.h

===

diff --git a/intern/cycles/kernel/kernel_path_surface.h 
b/intern/cycles/kernel/kernel_path_surface.h
index ba48c0bdfc4..eb1c1b5cd23 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -266,6 +266,418 @@ ccl_device_inline void 
kernel_path_surface_connect_light(KernelGlobals *kg,
 #endif
 }
 
+constexpr size_t HCLEN = 1024*16;
+
+typedef struct _hitcache {
+  Ray rays[HCLEN];
+  int cur, used;
+} _hitcache;
+
+static _hitcache hitcache[2] = { 0, };
+
+static void hitcache_add(Ray ray, int thread) {
+  hitcache[thread].rays[hitcache[thread].cur] = ray;
+  hitcache[thread].cur = (hitcache[thread].cur + 1) % HCLEN;
+
+  if (hitcache[thread].used < HCLEN) {
+hitcache[thread].used++;
+  }
+}
+
+static int hitcache_get(KernelGlobals *kg, PathState* state, int thread) {
+  if (hitcache[thread].used == 0)
+return -1;
+
+  //is path_state_rng_1D only giving numbers from 0.5-1.0?
+  float r = path_state_rng_1D(kg, state, PRNG_LIGHT_U);
+  r = r > 0.5 ? (r - 0.5) * 2.0 : r;
+
+  int idx = (int)(r * ((float)hitcache[thread].used) * 0.);
+
+  return idx;
+}
+
+//bastardized one-bounce bidirection tracing
+ccl_device_inline void 
kernel_path_surface_connect_light_indirect(KernelGlobals* kg,
+  ShaderData* sd,
+  ShaderData* emission_sd,
+  float3 throughput,
+  ccl_addr_space PathState* state,
+  PathRadiance* L)
+{
+  PROFILING_INIT(kg, PROFILING_CONNECT_LIGHT);
+
+#ifdef __EMISSION__
+  if (!(kernel_data.integrator.use_direct_light && (sd->flag & 
SD_BSDF_HAS_EVAL)))
+return;
+
+  /* sample illumination from lights to find path contribution */
+  float light_u, light_v;
+  path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
+
+  Ray light_ray;
+  BsdfEval L_light;
+  PathRadiance L2 = { 0, };
+  bool is_lamp;
+
+#  ifdef __OBJECT_MOTION__
+  light_ray.time = sd->time;
+#  endif
+
+  LightSample ls;
+  if (light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) 
{
+float terminate = path_state_rng_light_termination(kg, state);
+
+if (1) { //direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, 
&L_light, &is_lamp, terminate) || true) {
+  Ray ray;
+  float3 omega;
+  float3 Ng;
+  float pdf = 0.0;
+
+  /*trace a ray*/
+  if (ls.type == LIGHT_DISTANT) {
+const ccl_global KernelLight* klight = &kernel_tex_fetch(__lights, 
ls.lamp);
+
+ray.P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+Ng = ls.P;
+  } else if (ls.type == LIGHT_POINT) {
+Ng = -ls.D;
+ray.P = ls.P + Ng * 0.00015f;
+  } else {
+Ng = ls.Ng;
+ray.P = ls.P + Ng * 0.00015f;
+  }
+
+  ray.t = ls.t;
+
+  sample_cos_hemisphere(Ng, light_u, light_v, &omega, &pdf);
+
+  omega = normalize(omega);
+  ray.D = omega;
+
+  float prob = path_state_rng_1D(kg, state, PRNG_LIGHT_U);
+  bool has_cache = prob > 0.75;
+
+  if (has_cache) {
+int i = hitcache_get(kg, state, 0);
+
+if (i >= 0) {
+  ray = hitcache[0].rays[i];
+}
+  }
+
+  /* trace shadow ray */
+  float3 shadow = make_float3(1.0f, 1.0f, 1.0f);
+
+  if (1) { //!shadow_blocked(kg, sd, emission_sd, state, &ray, &shadow)) {
+Intersection isect, isect2;
+PathState _state2 = *state, *state2 = &_state2;
+ShaderData sd2;
+float3 P, Ng;
+BsdfEval bsdf_eval;
+Ray ray2;
+
+//bool hit = scene_intersect(kg, *ray, visibility, isect);
+//bool hit = kernel_path_scene_intersect(kg, state2, &ray, &isect, 
&L2);
+bool hit = scene_intersect(kg, ray, PATH_RAY_ALL_VISIBILITY, &isect);
+if (!hit) {
+  return;
+}
+
+P = ray.P + ray.D * isect.t;
+Ng = normalize(isect.Ng);
+
+float d1 = dot(Ng, -ray.D);
+d1 = d1 < 0.0 ? 0.0 : d1;
+
+ray2.P = sd->P + sd->Ng * 0.00015;
+
+floa

[Bf-blender-cvs] [40a786d2a10] temp-trimesh-sculpt: add parallel hashmap library

2020-10-13 Thread Joseph Eagar
Commit: 40a786d2a100b47ee412d61062693b8250e8dff8
Author: Joseph Eagar
Date:   Sun Oct 4 17:40:44 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB40a786d2a100b47ee412d61062693b8250e8dff8

add parallel hashmap library

===

A   extern/parallel-hashmap

===

diff --git a/extern/parallel-hashmap b/extern/parallel-hashmap
new file mode 16
index 000..72beffb1407
--- /dev/null
+++ b/extern/parallel-hashmap
@@ -0,0 +1 @@
+Subproject commit 72beffb14075ca9d9dd6560bdbe924e57cb0d3df

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


[Bf-blender-cvs] [31acfc360ca] temp-trimesh-sculpt: for some reason the cycles patch reversion missed this

2020-10-13 Thread Joseph Eagar
Commit: 31acfc360ca8e2bb5a4b855eae8dbf1c55b376c2
Author: Joseph Eagar
Date:   Tue Oct 6 10:19:35 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB31acfc360ca8e2bb5a4b855eae8dbf1c55b376c2

for some reason the cycles patch reversion missed this

===

M   intern/cycles/util/CMakeLists.txt

===

diff --git a/intern/cycles/util/CMakeLists.txt 
b/intern/cycles/util/CMakeLists.txt
index 9cce5977f67..18e14913884 100644
--- a/intern/cycles/util/CMakeLists.txt
+++ b/intern/cycles/util/CMakeLists.txt
@@ -23,7 +23,6 @@ set(INC_SYS
 
 set(SRC
   util_aligned_malloc.cpp
-  util_bluenoise_mask.cpp
   util_debug.cpp
   util_ies.cpp
   util_logging.cpp

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


[Bf-blender-cvs] [893c36a7c95] temp-trimesh-sculpt: prepare for merge

2020-10-13 Thread Joseph Eagar
Commit: 893c36a7c95d926b15c1db603d3b3291cc00158e
Author: Joseph Eagar
Date:   Sun Oct 4 17:09:55 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB893c36a7c95d926b15c1db603d3b3291cc00158e

prepare for merge

===

M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/CMakeLists.txt
M   source/blender/editors/interface/interface_template_search_menu.c
M   source/blender/editors/mesh/editmesh_select_similar.c
M   source/blender/editors/screen/area.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/trimesh/intern/trimesh_log.c
M   source/blender/trimesh/trimesh.h

===

diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index 47023dfccf8..f398714d1ef 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -1944,6 +1944,9 @@ bool BKE_pbvh_trimesh_update_topology(PBVH *bvh,
   pbvh_trimesh_verify(bvh);
 #endif
 
+  TM_mesh_elem_table_ensure(bvh->tm, TM_VERTEX|TM_TRI);
+  TM_mesh_elem_index_ensure(bvh->tm, TM_VERTEX|TM_TRI);
+
   return modified;
 }
 
diff --git a/source/blender/blenlib/CMakeLists.txt 
b/source/blender/blenlib/CMakeLists.txt
index 5f3826d257a..a514f06dac4 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -27,6 +27,7 @@ set(INC
   ../../../intern/guardedalloc
   ../../../intern/numaapi/include
   ../../../extern/wcwidth
+  ../../../extern/parallel-hashmap
 )
 
 set(INC_SYS
diff --git a/source/blender/editors/interface/interface_template_search_menu.c 
b/source/blender/editors/interface/interface_template_search_menu.c
index 5bde51846a8..0dac2b5cd41 100644
--- a/source/blender/editors/interface/interface_template_search_menu.c
+++ b/source/blender/editors/interface/interface_template_search_menu.c
@@ -33,6 +33,7 @@
 #include "DNA_shader_fx_types.h"
 #include "DNA_texture_types.h"
 
+#include "BLI_ghash.h"
 #include "BLI_alloca.h"
 #include "BLI_dynstr.h"
 #include "BLI_ghash.h"
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c 
b/source/blender/editors/mesh/editmesh_select_similar.c
index b3fb9747070..5a1895d784c 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -27,6 +27,7 @@
 #include "BLI_kdtree.h"
 #include "BLI_listbase.h"
 #include "BLI_math.h"
+#include "BLI_ghash.h"
 
 #include "BKE_context.h"
 #include "BKE_editmesh.h"
diff --git a/source/blender/editors/screen/area.c 
b/source/blender/editors/screen/area.c
index 7b41b1df0ab..671078e8118 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -620,6 +620,7 @@ void ED_region_do_draw(bContext *C, ARegion *region)
   SpaceLink *sl = area->spacedata.first;
 
   PointerRNA ptr;
+
   RNA_pointer_create(&screen->id, &RNA_Space, sl, &ptr);
 
   wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 58815d85281..51758997aa2 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1348,7 +1348,9 @@ void SCULPT_orig_vert_data_init(SculptOrigVertData *data, 
Object *ob, PBVHNode *
 void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, 
PBVHVertexIter *iter)
 {
   if (orig_data->unode->type == SCULPT_UNDO_COORDS) {
-if (orig_data->bm_log) {
+if (orig_data->tm_log) {
+  TM_log_original_vert_data(orig_data->tm_log, iter->tm_vert,  
&orig_data->co, &orig_data->no);
+} else if (orig_data->bm_log) {
   BM_log_original_vert_data(orig_data->bm_log, iter->bm_vert, 
&orig_data->co, &orig_data->no);
 }
 else {
@@ -1574,7 +1576,7 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
   };
 
   TaskParallelSettings settings;
-  BKE_pbvh_parallel_range_settings(&settings, true && !ss->bm, totnode);
+  BKE_pbvh_parallel_range_settings(&settings, true && !ss->tm, totnode);
   BLI_task_parallel_range(0, totnode, &data, paint_mesh_restore_co_task_cb, 
&settings);
 
   BKE_pbvh_node_color_buffer_free(ss->pbvh);
@@ -1707,6 +1709,9 @@ bool SCULPT_brush_test_sphere(SculptBrushTest *test, 
const float co[3])
 
 bool SCULPT_brush_test_sphere_sq(SculptBrushTest *test, const float co[3])
 {
+  if (!co) {
+return false;
+  }
   float distsq = len_squared_v3v3(co, test->location);
 
   if (distsq <= test->radius_squared) {
@@ -5676,7 +5681,7 @@ static void sculpt_topology_update(Sculpt *sd,
   Brush *brush,
   UnifiedPaintSettings *UNUSED(ups))
 {
-  return;
+  //return;
   SculptSession *ss = ob->sculpt;
 
   int n, totnode;
diff --git a/source/blender/trimesh/intern/trimesh_log.c 
b/source/blender/trimesh/intern/trimesh_lo

[Bf-blender-cvs] [48e1058e9df] temp-trimesh-sculpt: edge collapse mostly works. need to track down more memory corruption bugs.

2020-10-13 Thread Joseph Eagar
Commit: 48e1058e9df1a6a153aab22e3ccf78d1e7d0e1a7
Author: Joseph Eagar
Date:   Tue Oct 13 18:59:21 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB48e1058e9df1a6a153aab22e3ccf78d1e7d0e1a7

edge collapse mostly works.  need to track down more memory corruption
bugs.

===

M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_threadsafe_mempool.h
M   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
M   source/blender/trimesh/intern/trimesh_private.h
M   source/blender/trimesh/trimesh.h

===

diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index 486b04fa7d8..4129cddac9f 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -435,7 +435,7 @@ static TMVert *pbvh_trimesh_vert_create(
   TMVert *v = TM_make_vert(bvh->tm, co, no, 0, false);
 
   if (node_index < 0 || node_index >= bvh->totnode) {
-printf("eek!");
+printf("eek!\n");
 return v;
   }
 
@@ -932,7 +932,7 @@ static void long_edge_queue_face_add(EdgeQueueContext 
*eq_ctx, TMFace *f)
 
   if (len_sq > eq_ctx->q->limit_len_squared) {
 if (e->v1->edges.length > 24 || e->v2->edges.length > 24) {
-  printf("eek! %.4f", len_sq);
+  //printf("eek! %.4f %d %d\n", len_sq, e->v1->edges.length, 
e->v2->edges.length);
   continue;
 }
 
@@ -1307,13 +1307,19 @@ static void pbvh_trimesh_collapse_edge(PBVH *bvh,
   pbvh_trimesh_vert_remove(bvh, v_del);
 
   /* Remove all faces adjacent to the edge */
-  for (int i=0; itris.length; i++) {
+  while (e->tris.length) {
+int lastlen = e->tris.length;
 TMFace *f_adj = e->tris.items[0];
 
 pbvh_trimesh_face_remove(bvh, f_adj);
 
 //XXX check threadnr argument!
 TM_kill_tri(bvh->tm, f_adj, 0, false, false);
+
+if (lastlen == e->tris.length) { //paranoia check
+  printf("eek! %s %d\n", __FILE__, __LINE__);
+  break;
+}
   }
 
   /* Kill the edge */
@@ -1329,13 +1335,43 @@ static void pbvh_trimesh_collapse_edge(PBVH *bvh,
   * really buy anything. */
   BLI_buffer_clear(deleted_faces);
 
+  TM_ITER_VERT_TRIEDGES(v_del, tri, e) {
+tri->flag &= ~TRIMESH_TEMP_TAG;
+
+TMEdge *e2 = TM_nextEdgeInTri(tri, e);
+for (int i=0; itris.length; i++) {
+  TMFace *tri2 = e2->tris.items[i];
+
+  tri2->flag &= ~TRIMESH_TEMP_TAG;
+
+  for (int j=0; j<3; j++) {
+TMEdge *e3 = TM_GET_TRI_EDGE(tri2, j);
+for (int k=0; ktris.length; k++) {
+  TMFace *tri3 = e3->tris.items[k];
+
+  tri3->flag &= ~TRIMESH_TEMP_TAG;
+}
+  }
+}
+  } TM_ITER_VERT_TRIEDGES_END
+
   TM_ITER_VERT_TRIEDGES(v_del, tri, e) {
 TMEdge *e2 = TM_nextEdgeInTri(tri, e);
 TMFace *existing_face = NULL;
+TMVert *v2 = TM_nextVertInTri(tri, v_del);
+
+if (v2 == TM_other_vert(e, v_del)) {
+  v2 = TM_prevVertInTri(tri, v_del);
+}
 
-if (UNLIKELY(existing_face = TM_tri_exists(v_conn, e2->v1, e->v2))) {
-  BLI_buffer_append(deleted_faces, TMFace *, existing_face);
-} else {
+if (UNLIKELY(existing_face = TM_tri_exists(v_conn, v2, v_del))) {
+  if (!(existing_face->flag & TRIMESH_TEMP_TAG)) {
+BLI_buffer_append(deleted_faces, TMFace *, existing_face);
+existing_face->flag |= TRIMESH_TEMP_TAG;
+  } else {
+printf("eek! %s %d\n", __FILE__, __LINE__);
+  }
+} else if (1) {
   TMVert *v_tri[3] = {v_conn, TM_nextVertInTri(tri, v_del), 
TM_prevVertInTri(tri, v_del)};
 
   //BLI_assert(!BM_face_exists(v_tri, 3));
@@ -1351,6 +1387,11 @@ static void pbvh_trimesh_collapse_edge(PBVH *bvh,
 BLI_gset_add(n->tm_other_verts, v_conn);
   }
 }
+
+if (!(tri->flag & TRIMESH_TEMP_TAG)) {
+  tri->flag |= TRIMESH_TEMP_TAG;
+  BLI_buffer_append(deleted_faces, TMFace *, tri);
+}
   } TM_ITER_VERT_TRIEDGES_END
 
   /* Delete the tagged faces */
@@ -1363,14 +1404,16 @@ static void pbvh_trimesh_collapse_edge(PBVH *bvh,
 TMEdge *e_tri[3];
 
 v_tri[0] = f_del->v1;
-e_tri[0] = f_del->e1;
 v_tri[1] = f_del->v2;
-e_tri[1] = f_del->e2;
 v_tri[2] = f_del->v3;
+
+e_tri[0] = f_del->e1;
+e_tri[1] = f_del->e2;
 e_tri[2] = f_del->e3;
 
 /* Remove the face */
 pbvh_trimesh_face_remove(bvh, f_del);
+
 TM_kill_tri(bvh->tm, f_del, 0, false, false);
 
 /* Check if any of the face's edges are now unused by any
@@ -1423,6 +1466,10 @@ static void pbvh_trimesh_collapse_edge(PBVH *bvh,
 
   /* Delete v_del */
   BLI_assert(!TM_vert_face_check(v_del));
+  if (TM_vert_face_check(v_del)) {
+printf("eek! %s %d\n", __FILE__, __LINE__);
+  }
+
   BLI_trimesh_log_vert_kill(bvh->tm_log, v_del);
 
   /* v_conn == NULL is OK */
@@ -1434,7 +1481,6 @@ static bool 
pbvh_trimesh_collapse_short_edge

[Bf-blender-cvs] [30fdd868f14] temp-trimesh-sculpt: stupid msvc doesn't want to inline c++ methods

2020-10-13 Thread Joseph Eagar
Commit: 30fdd868f146289ec2703015d9276c355662dbd6
Author: Joseph Eagar
Date:   Tue Oct 6 12:58:12 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB30fdd868f146289ec2703015d9276c355662dbd6

stupid msvc doesn't want to inline c++ methods

===

M   extern/parallel-hashmap/phmap.h
M   extern/parallel-hashmap/phmap_base.h
M   source/blender/blenlib/BLI_hashmap.h
M   source/blender/blenlib/CMakeLists.txt
M   source/blender/blenlib/intern/hashmap.cc
M   source/blender/blenlib/intern/hashmap_gen.h
M   source/blender/blenlib/intern/testHashMap.c
M   source/blender/trimesh/intern/trimesh.c
M   source/blender/trimesh/intern/trimesh_log.c
M   source/blender/trimesh/trimesh.h

===

diff --git a/extern/parallel-hashmap/phmap.h b/extern/parallel-hashmap/phmap.h
index 8f3c1869a72..f8ad2b5912c 100644
--- a/extern/parallel-hashmap/phmap.h
+++ b/extern/parallel-hashmap/phmap.h
@@ -1,6 +1,10 @@
 #if !defined(phmap_h_guard_)
 #define phmap_h_guard_
 
+#ifdef _MSC_VER
+#define FORCEINLINE __forceinline
+#endif
+
 // ---
 // Copyright (c) 2019, Gregory Popovitch - greg7...@gmail.com
 //
@@ -39,12 +43,12 @@
 
 #pragma warning(disable : 4127) // conditional expression is constant
 #pragma warning(disable : 4324) // structure was padded due to alignment 
specifier
-#pragma warning(disable : 4514) // unreferenced inline function has been 
removed
+#pragma warning(disable : 4514) // unreferenced FORCEINLINE function has 
been removed
 #pragma warning(disable : 4623) // default constructor was implicitly 
defined as deleted
 #pragma warning(disable : 4625) // copy constructor was implicitly defined 
as deleted
 #pragma warning(disable : 4626) // assignment operator was implicitly 
defined as deleted
 #pragma warning(disable : 4710) // function not inlined
-#pragma warning(disable : 4711) // selected for automatic inline expansion
+#pragma warning(disable : 4711) // selected for automatic FORCEINLINE 
expansion
 #pragma warning(disable : 4820) // '6' bytes padding added after data 
member
 #pragma warning(disable : 4868) // compiler may not enforce left-to-right 
evaluation order in braced initializer list
 #pragma warning(disable : 5027) // move assignment operator was implicitly 
defined as deleted
@@ -254,7 +258,7 @@ static_assert(kDeleted == -2,
 // A single block of empty control bytes for tables without any slots 
allocated.
 // This enables removing a branch in the hot path of find().
 // --
-inline ctrl_t* EmptyGroup() {
+FORCEINLINE ctrl_t* EmptyGroup() {
   alignas(16) static constexpr ctrl_t empty_group[] = {
   kSentinel, kEmpty, kEmpty, kEmpty, kEmpty, kEmpty, kEmpty, kEmpty,
   kEmpty,kEmpty, kEmpty, kEmpty, kEmpty, kEmpty, kEmpty, kEmpty};
@@ -262,7 +266,7 @@ inline ctrl_t* EmptyGroup() {
 }
 
 // --
-inline size_t HashSeed(const ctrl_t* ctrl) {
+FORCEINLINE size_t HashSeed(const ctrl_t* ctrl) {
   // The low bits of the pointer have little or no entropy because of
   // alignment. We shift the pointer to try to use higher entropy bits. A
   // good number seems to be 12 bits, because that aligns with page size.
@@ -271,7 +275,7 @@ inline size_t HashSeed(const ctrl_t* ctrl) {
 
 #ifdef PHMAP_NON_DETERMINISTIC
 
-inline size_t H1(size_t hash, const ctrl_t* ctrl) {
+FORCEINLINE size_t H1(size_t hash, const ctrl_t* ctrl) {
 // use ctrl_ pointer to add entropy to ensure
 // non-deterministic iteration order.
 return (hash >> 7) ^ HashSeed(ctrl);
@@ -279,7 +283,7 @@ inline size_t H1(size_t hash, const ctrl_t* ctrl) {
 
 #else
 
-inline size_t H1(size_t hash, const ctrl_t* ) {
+FORCEINLINE size_t H1(size_t hash, const ctrl_t* ) {
 return (hash >> 7);
 }
 
@@ -579,25 +583,25 @@ struct HashtablezInfo
 
 inline void RecordRehashSlow(HashtablezInfo*, size_t ) {}
 
-static inline void RecordInsertSlow(HashtablezInfo* , size_t, size_t ) {}
+static FORCEINLINE void RecordInsertSlow(HashtablezInfo* , size_t, size_t ) {}
 
-static inline void RecordEraseSlow(HashtablezInfo*) {}
+static FORCEINLINE void RecordEraseSlow(HashtablezInfo*) {}
 
-static inline HashtablezInfo* SampleSlow(int64_t*) { return nullptr; }
-static inline void UnsampleSlow(HashtablezInfo* ) {}
+static FORCEINLINE HashtablezInfo* SampleSlow(int64_t*) { return nullptr; }
+static FORCEINLINE void UnsampleSlow(HashtablezInfo* ) {}
 
 class HashtablezInfoHandle 
 {
 public:
-inline void RecordStorageChanged(size_t , size_t ) {}
-inline void RecordRehash(size_t ) {}
-inline void RecordInsert(size_t , size_t ) {}
-inline void RecordErase() {}
-friend inline void swap(Hashtabl

[Bf-blender-cvs] [e4e1467fa4b] temp-trimesh-sculpt: * code is in somewhat more working state * Began refactoring pbvh vertex indices to be uint64_t's, to eliminate usage of element tables in trimesh.

2020-10-13 Thread Joseph Eagar
Commit: e4e1467fa4bdd1cd7991fd2156dd967431a29091
Author: Joseph Eagar
Date:   Tue Oct 13 15:24:43 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBe4e1467fa4bdd1cd7991fd2156dd967431a29091

* code is in somewhat more working state
* Began refactoring pbvh vertex indices to be uint64_t's,
  to eliminate usage of element tables in trimesh.

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/anim_data.c
M   source/blender/blenkernel/intern/collection.c
M   source/blender/blenkernel/intern/lib_id.c
M   source/blender/blenkernel/intern/object.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/blenlib/BLI_smallhash.h
M   source/blender/blenlib/BLI_threadsafe_mempool.h
M   source/blender/blenlib/CMakeLists.txt
M   source/blender/blenlib/intern/BLI_threadsafe_mempool.c
M   source/blender/blenlib/intern/hashmap.cc
M   source/blender/blenlib/intern/task_pool.cc
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_automasking.c
M   source/blender/editors/sculpt_paint/sculpt_boundary.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M   source/blender/editors/sculpt_paint/sculpt_pose.c
M   source/blender/editors/sculpt_paint/sculpt_smooth.c
M   source/blender/trimesh/intern/trimesh.c
M   source/blender/trimesh/intern/trimesh_log.c
M   source/blender/trimesh/trimesh.h

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index a6cca2910df..cd6127512bc 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -23,6 +23,8 @@
  * \ingroup bke
  */
 
+#include "BKE_pbvh.h"
+
 #include "BLI_bitmap.h"
 #include "BLI_utildefines.h"
 #include "DNA_object_enums.h"
@@ -500,7 +502,7 @@ typedef struct SculptSession {
   struct FilterCache *filter_cache;
 
   /* Cursor data and active vertex for tools */
-  int active_vertex_index;
+  SculptIdx active_vertex_index;
 
   int active_face_index;
   int active_grid_index;
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index de2e571af22..0461e1e48b2 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -24,6 +24,10 @@
 #include "BLI_bitmap.h"
 #include "BLI_ghash.h"
 
+#include "stdint.h"
+
+typedef uintptr_t SculptIdx;
+
 /* For embedding CCGKey in iterator. */
 #include "BKE_ccg.h"
 
@@ -169,8 +173,8 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
const float ray_normal[3],
struct IsectRayPrecalc *isect_precalc,
float *depth,
-   int *active_vertex_index,
-   int *active_face_grid_index,
+   SculptIdx *active_vertex_index,
+   SculptIdx *active_face_grid_index,
float *face_normal);
 
 bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
@@ -274,7 +278,7 @@ bool BKE_pbvh_trimesh_update_topology(PBVH *bvh,
   const float view_normal[3],
   float radius,
   const bool use_frontface,
-  const bool use_projected);
+  const bool use_projected, int sym_axis);
 /* Node Access */
 
 void BKE_pbvh_node_mark_update(PBVHNode *node);
@@ -373,7 +377,7 @@ typedef struct PBVHVertexIter {
   int gx;
   int gy;
   int i;
-  int index;
+  SculptIdx index;
   bool respect_hide;
 
   /* grid */
diff --git a/source/blender/blenkernel/intern/anim_data.c 
b/source/blender/blenkernel/intern/anim_data.c
index c26fc6578f1..6f2e0c7257d 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -452,7 +452,7 @@ void BKE_animdata_copy_id_action(Main *bmain, ID *id)
 
 void BKE_animdata_duplicate_id_action(struct Main *bmain,
   struct ID *id,
-  const eDupli_ID_Flags duplicate_flags)
+  const uint duplicate_flags)
 {
   if (duplicate_flags & USER_DUP_ACT) {
 animdata_copy_id_action(bmain, id, true, (duplicate_flags & 
USER_DUP_LINKED_ID) != 0);
diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index de2ec273567..de37f4d0b15 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -471,8 +471,8 @@ static Collection *collection_duplicate_recursive(Main 
*bmain,
 Collection *BKE_collection_duplicate(Main *bmain,
  Collection *parent,
  

[Bf-blender-cvs] [b82b3ade8d3] temp-trimesh-sculpt: commit patch

2020-10-13 Thread Joseph Eagar
Commit: b82b3ade8d312a9e00a9e45f1356660b70020b67
Author: Joseph Eagar
Date:   Sun Oct 4 04:11:09 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBb82b3ade8d312a9e00a9e45f1356660b70020b67

commit patch

===

M   intern/cycles/kernel/kernel_path_surface.h
M   source/blender/blenkernel/intern/customdata.c
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenlib/BLI_smallhash.h
M   source/blender/blenlib/intern/math_geom_inline.c
M   source/blender/blenlib/intern/smallhash.c
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/bmesh/intern/bmesh_polygon.c
M   source/blender/bmesh/intern/bmesh_polygon.h
M   source/blender/draw/engines/overlay/overlay_paint.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c
M   source/blender/makesdna/DNA_customdata_types.h

===

diff --git a/intern/cycles/kernel/kernel_path_surface.h 
b/intern/cycles/kernel/kernel_path_surface.h
index eb1c1b5cd23..ba48c0bdfc4 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -266,418 +266,6 @@ ccl_device_inline void 
kernel_path_surface_connect_light(KernelGlobals *kg,
 #endif
 }
 
-constexpr size_t HCLEN = 1024*16;
-
-typedef struct _hitcache {
-  Ray rays[HCLEN];
-  int cur, used;
-} _hitcache;
-
-static _hitcache hitcache[2] = { 0, };
-
-static void hitcache_add(Ray ray, int thread) {
-  hitcache[thread].rays[hitcache[thread].cur] = ray;
-  hitcache[thread].cur = (hitcache[thread].cur + 1) % HCLEN;
-
-  if (hitcache[thread].used < HCLEN) {
-hitcache[thread].used++;
-  }
-}
-
-static int hitcache_get(KernelGlobals *kg, PathState* state, int thread) {
-  if (hitcache[thread].used == 0)
-return -1;
-
-  //is path_state_rng_1D only giving numbers from 0.5-1.0?
-  float r = path_state_rng_1D(kg, state, PRNG_LIGHT_U);
-  r = r > 0.5 ? (r - 0.5) * 2.0 : r;
-
-  int idx = (int)(r * ((float)hitcache[thread].used) * 0.);
-
-  return idx;
-}
-
-//bastardized one-bounce bidirection tracing
-ccl_device_inline void 
kernel_path_surface_connect_light_indirect(KernelGlobals* kg,
-  ShaderData* sd,
-  ShaderData* emission_sd,
-  float3 throughput,
-  ccl_addr_space PathState* state,
-  PathRadiance* L)
-{
-  PROFILING_INIT(kg, PROFILING_CONNECT_LIGHT);
-
-#ifdef __EMISSION__
-  if (!(kernel_data.integrator.use_direct_light && (sd->flag & 
SD_BSDF_HAS_EVAL)))
-return;
-
-  /* sample illumination from lights to find path contribution */
-  float light_u, light_v;
-  path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v);
-
-  Ray light_ray;
-  BsdfEval L_light;
-  PathRadiance L2 = { 0, };
-  bool is_lamp;
-
-#  ifdef __OBJECT_MOTION__
-  light_ray.time = sd->time;
-#  endif
-
-  LightSample ls;
-  if (light_sample(kg, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) 
{
-float terminate = path_state_rng_light_termination(kg, state);
-
-if (1) { //direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, 
&L_light, &is_lamp, terminate) || true) {
-  Ray ray;
-  float3 omega;
-  float3 Ng;
-  float pdf = 0.0;
-
-  /*trace a ray*/
-  if (ls.type == LIGHT_DISTANT) {
-const ccl_global KernelLight* klight = &kernel_tex_fetch(__lights, 
ls.lamp);
-
-ray.P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
-Ng = ls.P;
-  } else if (ls.type == LIGHT_POINT) {
-Ng = -ls.D;
-ray.P = ls.P + Ng * 0.00015f;
-  } else {
-Ng = ls.Ng;
-ray.P = ls.P + Ng * 0.00015f;
-  }
-
-  ray.t = ls.t;
-
-  sample_cos_hemisphere(Ng, light_u, light_v, &omega, &pdf);
-
-  omega = normalize(omega);
-  ray.D = omega;
-
-  float prob = path_state_rng_1D(kg, state, PRNG_LIGHT_U);
-  bool has_cache = prob > 0.75;
-
-  if (has_cache) {
-int i = hitcache_get(kg, state, 0);
-
-if (i >= 0) {
-  ray = hitcache[0].rays[i];
-}
-  }
-
-  /* trace shadow ray */
-  float3 shadow = make_float3(1.0f, 1.0f, 1.0f);
-
-  if (1) { //!shadow_blocked(kg, sd, emission_sd, state, &ray, &shadow)) {
-Intersection isect, isect2;
-PathState _state2 = *state, *state2 = &_state2;
-ShaderData sd2;
-float3 P, Ng;
-BsdfEval bsdf_eval;
-Ray ray2;
-
-//bool hit = scene_intersect(kg, *ray, visibility, isect);
-//bool hit = kernel_path_scene_intersect(kg, state2, &ray, &isect, 
&L2);
-bool hit = scene_intersect(kg, ray, PATH_RAY_ALL_VISIBILITY, &isect);
-if (!hit) {
-  return;
-}
-
-P = ray.P + ray.D * isect.t;
-Ng = normalize(isect.Ng);
-
-float d1 = dot(Ng, -ray.D);
-d1 = d1 < 0.0 ? 0.0 : d1;
-
-ray2.P = sd->P + sd->Ng * 0.00015;
-
-

[Bf-blender-cvs] [a4ce6ed948a] temp-trimesh-sculpt: attempt to reverse old cycles patch in joeedh-trimesh-sculpt branch

2020-10-13 Thread Joseph Eagar
Commit: a4ce6ed948a4e141d3d2c5bcfff8e5d2fcf99ef4
Author: Joseph Eagar
Date:   Tue Oct 6 10:13:43 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBa4ce6ed948a4e141d3d2c5bcfff8e5d2fcf99ef4

attempt to reverse old cycles patch in joeedh-trimesh-sculpt branch

===

M   intern/cycles/blender/addon/properties.py
M   intern/cycles/blender/addon/ui.py
D   intern/cycles/kernel/kernel_bluenoise_mask.h
M   intern/cycles/render/integrator.cpp
D   intern/cycles/util/util_bluenoise_mask.cpp

===

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index f93602e673e..0a2bb56e9ce 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -313,11 +313,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
 min=0, max=(1 << 24),
 default=32,
 )
-preview_pause: BoolProperty(
-name="Pause Preview",
-description="Pause all viewport preview renders",
-default=False,
-)
 aa_samples: IntProperty(
 name="AA Samples",
 description="Number of antialiasing samples to render for each pixel",
diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index 4acfd15b286..1ccd4851d9c 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -174,9 +174,10 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
 layout.use_property_split = True
 layout.use_property_decorate = False
 
-layout.prop(cscene, "progressive")
-
-if cscene.progressive == 'PATH' or use_branched_path(context) is False:
+if not use_optix(context):
+layout.prop(cscene, "progressive")
+
+if not use_branched_path(context):
 col = layout.column(align=True)
 col.prop(cscene, "samples", text="Render")
 col.prop(cscene, "preview_samples", text="Viewport")
@@ -296,7 +297,7 @@ class 
CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
 
 scene = context.scene
 cscene = scene.cycles
-
+
 row = layout.row(align=True)
 row.prop(cscene, "seed")
 row.prop(cscene, "use_animated_seed", text="", icon='TIME')
diff --git a/intern/cycles/kernel/kernel_bluenoise_mask.h 
b/intern/cycles/kernel/kernel_bluenoise_mask.h
deleted file mode 100755
index b3c6a04b6a8..000
--- a/intern/cycles/kernel/kernel_bluenoise_mask.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2011-2013 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-CCL_NAMESPACE_BEGIN
-
-#define BLUE_MASK_DIMEN 128
-#define BLUE_MASK_BYTES_PER_PIXEL 2
-#define BLUE_MASK_MASK 127
-
-extern unsigned short bluenoise_mask[16384];
-
-CCL_NAMESPACE_END
diff --git a/intern/cycles/render/integrator.cpp 
b/intern/cycles/render/integrator.cpp
index 6bea1d14b5f..d6ee57bafdf 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -199,7 +199,6 @@ void Integrator::device_update(Device *device, DeviceScene 
*dscene, Scene *scene
 
   kintegrator->sampling_pattern = sampling_pattern;
   kintegrator->aa_samples = aa_samples;
-
   if (aa_samples > 0 && adaptive_min_samples == 0) {
 kintegrator->adaptive_min_samples = max(4, (int)sqrtf(aa_samples));
 VLOG(1) << "Cycles adaptive sampling: automatic min samples = "
diff --git a/intern/cycles/util/util_bluenoise_mask.cpp 
b/intern/cycles/util/util_bluenoise_mask.cpp
deleted file mode 100755
index 2a82681db7d..000
--- a/intern/cycles/util/util_bluenoise_mask.cpp
+++ /dev/null
@@ -1,1470 +0,0 @@
-//see kernel/kernel_bluenoise_mask.h
-
-CCL_NAMESPACE_BEGIN
-
-unsigned short bluenoise_mask[16384] = {
-0xa44d,0x4afd,0xf046,0x77d6,0xbbde,0xf832,0x1202,0xb83f,0x6957,0x92ad,0xc9ef,
-0x24ba,0xe5b9,0x2bba,0xd8bc,0x9d3,0x44dc,0xbc39,0x28fe,0x9818,0xd7b,0xa3f3,0xc2d7,
-0xf012,0x5f84,0xc657,0xf2f9,0xa658,0x6040,0xfc04,0x8793,0x2875,0xe0b4,0x418b,
-0x7d74,0x280e,0xe80f,0x7a3b,0xc2d3,0x41ab,0x9d41,0xfa3d,0xbab8,0x1383,0xb25d,
-0x3065,0xebb2,0xbd30,0x2ce1,0x905b,0xf968,0x689b,0x1315,0x4b20,0x72f4,0xe74a,
-0x43a6,0xced1,0x78e9,0x96ed,0x1fcc,0xfc1c,0x3f75,0xdfd4,0x553a,0x81dd,0xf935,
-0x64f7,0xd206,0x1ada,0x9f38,0x6218,0xf633,0x3c5f,0xa24e,0xe321,0x4068,0xc998,
-0x211a,

[Bf-blender-cvs] [34c3d73da15] temp-trimesh-sculpt: okay that's better

2020-10-13 Thread Joseph Eagar
Commit: 34c3d73da159f7f0eab906ce5b4293feb95bcab9
Author: Joseph Eagar
Date:   Sun Oct 4 17:49:50 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB34c3d73da159f7f0eab906ce5b4293feb95bcab9

okay that's better

===

A   extern/parallel-hashmap/btree.h
A   extern/parallel-hashmap/conanfile.py
A   extern/parallel-hashmap/meminfo.h
A   extern/parallel-hashmap/phmap.h
A   extern/parallel-hashmap/phmap_base.h
A   extern/parallel-hashmap/phmap_bits.h
A   extern/parallel-hashmap/phmap_config.h
A   extern/parallel-hashmap/phmap_dump.h
A   extern/parallel-hashmap/phmap_fwd_decl.h
A   extern/parallel-hashmap/phmap_utils.h

===

diff --git a/extern/parallel-hashmap/btree.h b/extern/parallel-hashmap/btree.h
new file mode 100644
index 000..7c73162d1c5
--- /dev/null
+++ b/extern/parallel-hashmap/btree.h
@@ -0,0 +1,4050 @@
+// ---
+// Copyright (c) 2019, Gregory Popovitch - greg7...@gmail.com
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Includes work from abseil-cpp (https://github.com/abseil/abseil-cpp)
+// with modifications.
+//
+// Copyright 2018 The Abseil Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ---
+
+#ifndef PHMAP_BTREE_BTREE_CONTAINER_H_
+#define PHMAP_BTREE_BTREE_CONTAINER_H_
+
+#ifdef _MSC_VER
+#pragma warning(push)  
+
+#pragma warning(disable : 4127) // conditional expression is constant
+#pragma warning(disable : 4324) // structure was padded due to alignment 
specifier
+#pragma warning(disable : 4355) // 'this': used in base member initializer 
list
+#pragma warning(disable : 4365) // conversion from 'int' to 'const 
unsigned __int64', signed/unsigned mismatch
+#pragma warning(disable : 4514) // unreferenced inline function has been 
removed
+#pragma warning(disable : 4623) // default constructor was implicitly 
defined as deleted
+#pragma warning(disable : 4625) // copy constructor was implicitly defined 
as deleted
+#pragma warning(disable : 4626) // assignment operator was implicitly 
defined as deleted
+#pragma warning(disable : 4710) // function not inlined
+#pragma warning(disable : 4711) //  selected for automatic inline expansion
+#pragma warning(disable : 4820) // '6' bytes padding added after data 
member
+#pragma warning(disable : 4868) // compiler may not enforce left-to-right 
evaluation order in braced initializer list
+#pragma warning(disable : 5026) // move constructor was implicitly defined 
as deleted
+#pragma warning(disable : 5027) // move assignment operator was implicitly 
defined as deleted
+#pragma warning(disable : 5045) // Compiler will insert Spectre mitigation 
for memory load if /Qspectre switch specified
+#endif
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "phmap_fwd_decl.h"
+#include "phmap_base.h"
+
+#if PHMAP_HAVE_STD_STRING_VIEW
+#include 
+#endif
+
+// MSVC constructibility traits do not detect destructor properties and so our
+// implementations should not use them as a source-of-truth.
+#if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__)
+#define PHMAP_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 
1
+#endif
+
+namespace phmap {
+
+// Defined and documented later on in this file.
+template 
+struct is_trivially_destructible;
+
+// Defined and documented later on in this file.
+template 
+struct is_trivially_move_assignable;
+
+namespace type_traits_internal {
+
+// Silence MSVC warnings about the destructor being defined as deleted.
+#if defined(_MSC_VER) && !defined(__GNUC__)
+#pragma warning(push)
+#pragma 

[Bf-blender-cvs] [ba19079902c] temp-trimesh-sculpt: commit before getting collapse to work

2020-10-13 Thread Joseph Eagar
Commit: ba19079902c7c46e76d3c913ca325451407cc52d
Author: Joseph Eagar
Date:   Tue Oct 13 16:47:37 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBba19079902c7c46e76d3c913ca325451407cc52d

commit before getting collapse to work

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index 89c2601a305..486b04fa7d8 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -929,7 +929,13 @@ static void long_edge_queue_face_add(EdgeQueueContext 
*eq_ctx, TMFace *f)
   TMEdge *e = TM_GET_TRI_EDGE(f, i);
 
   const float len_sq = TM_edge_calc_length_squared(e);
+
   if (len_sq > eq_ctx->q->limit_len_squared) {
+if (e->v1->edges.length > 24 || e->v2->edges.length > 24) {
+  printf("eek! %.4f", len_sq);
+  continue;
+}
+
 long_edge_queue_edge_add_recursive(
   eq_ctx, e, e, TM_nextTriInEdge(e, f), f, len_sq, 
eq_ctx->q->limit_len);
   }
@@ -1204,9 +1210,18 @@ static void pbvh_trimesh_split_edge(EdgeQueueContext 
*eq_ctx,
 }
 
 if (v_opp->edges.length > 8) {
-  for (int i=0; iedges.length; i++) {
+  //prevent degenerate cases that make lots of geometry
+  int len = MIN2(v_opp->edges.length, 32);
+
+  for (int i=0; iedges.items[i];
-long_edge_queue_edge_add(eq_ctx, e2);
+
+if (e2 != e) {
+  long_edge_queue_edge_add(eq_ctx, e2);
+} else {
+  printf("eek! %s %d\n", __FILE__, __LINE__);
+  continue;
+}
   }
 }
   }

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


[Bf-blender-cvs] [f330d1f127b] temp-trimesh-sculpt: Commit working copy

2020-10-13 Thread Joseph Eagar
Commit: f330d1f127b6746341a2a6d656e69b67b97181f4
Author: Joseph Eagar
Date:   Tue Oct 6 12:57:16 2020 -0400
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBf330d1f127b6746341a2a6d656e69b67b97181f4

Commit working copy

===

M   extern/parallel-hashmap/phmap.h
M   extern/parallel-hashmap/phmap_base.h
A   intern/cycles/kernel/kernel_bluenoise_mask.h
M   intern/cycles/render/integrator.h
A   intern/cycles/util/util_bluenoise_mask.cpp
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/pbvh_trimesh.c
A   source/blender/blenlib/BLI_hashmap.h
M   source/blender/blenlib/CMakeLists.txt
A   source/blender/blenlib/intern/hashmap.cc
A   source/blender/blenlib/intern/hashmap_gen.h
A   source/blender/blenlib/intern/testHashMap.c
M   source/blender/gpu/GPU_vertex_buffer.h
M   source/blender/python/gpu/gpu_py_offscreen.c
M   source/blender/trimesh/intern/trimesh_log.c
M   source/blender/trimesh/intern/trimesh_private.h
M   source/blender/trimesh/trimesh.h

===

diff --git a/extern/parallel-hashmap/phmap.h b/extern/parallel-hashmap/phmap.h
index 2b093c36ded..8f3c1869a72 100644
--- a/extern/parallel-hashmap/phmap.h
+++ b/extern/parallel-hashmap/phmap.h
@@ -867,14 +867,14 @@ public:
 pointer operator->() const { return &operator*(); }
 
 // PRECONDITION: not an end() iterator.
-iterator& operator++() {
+inline iterator& operator++() {
 ++ctrl_;
 ++slot_;
 skip_empty_or_deleted();
 return *this;
 }
 // PRECONDITION: not an end() iterator.
-iterator operator++(int) {
+inline iterator operator++(int) {
 auto tmp = *this;
 ++*this;
 return tmp;
@@ -899,10 +899,10 @@ public:
 }
 #endif
 
-friend bool operator==(const iterator& a, const iterator& b) {
+inline friend bool operator==(const iterator& a, const iterator& b) {
 return a.ctrl_ == b.ctrl_;
 }
-friend bool operator!=(const iterator& a, const iterator& b) {
+inline friend bool operator!=(const iterator& a, const iterator& b) {
 return !(a == b);
 }
 
@@ -948,21 +948,21 @@ public:
 reference operator*() const { return *inner_; }
 pointer operator->() const { return inner_.operator->(); }
 
-const_iterator& operator++() {
+inline const_iterator& operator++() {
 ++inner_;
 return *this;
 }
-const_iterator operator++(int) { return inner_++; }
+inline const_iterator operator++(int) { return inner_++; }
 
-friend bool operator==(const const_iterator& a, const const_iterator& 
b) {
+inline friend bool operator==(const const_iterator& a, const 
const_iterator& b) {
 return a.inner_ == b.inner_;
 }
-friend bool operator!=(const const_iterator& a, const const_iterator& 
b) {
+inline friend bool operator!=(const const_iterator& a, const 
const_iterator& b) {
 return !(a == b);
 }
 
 private:
-const_iterator(const ctrl_t* ctrl, const slot_type* slot)
+inline const_iterator(const ctrl_t* ctrl, const slot_type* slot)
 : inner_(const_cast(ctrl), const_cast(slot)) 
{}
 
 iterator inner_;
@@ -1077,11 +1077,11 @@ public:
  const allocator_type& alloc)
 : raw_hash_set(init, 0, hasher(), key_equal(), alloc) {}
 
-raw_hash_set(const raw_hash_set& that)
+inline raw_hash_set(const raw_hash_set& that)
 : raw_hash_set(that, 
AllocTraits::select_on_container_copy_construction(
that.alloc_ref())) {}
 
-raw_hash_set(const raw_hash_set& that, const allocator_type& a)
+inline raw_hash_set(const raw_hash_set& that, const allocator_type& a)
 : raw_hash_set(0, that.hash_ref(), that.eq_ref(), a) {
 reserve(that.size());
 // Because the table is guaranteed to be empty, we can do something 
faster
@@ -1097,7 +1097,7 @@ public:
 growth_left() -= that.size();
 }
 
-raw_hash_set(raw_hash_set&& that) noexcept(
+inline raw_hash_set(raw_hash_set&& that) noexcept(
 std::is_nothrow_copy_constructible::value&&
 std::is_nothrow_copy_constructible::value&&
 std::is_nothrow_copy_constructible::value)
@@ -1135,7 +1135,7 @@ public:
 }
 }
 
-raw_hash_set& operator=(const raw_hash_set& that) {
+inline raw_hash_set& operator=(const raw_hash_set& that) {
 raw_hash_set tmp(that,
  
AllocTraits::propagate_on_container_copy_assignment::value
  ? that.alloc_ref()
@@ -1144,7 +1144,7 @@ public:
 return *this;
 }
 
-raw_hash_set& operator=(raw_hash_set&& tha

[Bf-blender-cvs] [d6ac6595504] temp-trimesh-sculpt: more int->SculptIdx refactoring

2020-10-13 Thread Joseph Eagar
Commit: d6ac6595504254ed2f06a6fd4e89c71f2052fe44
Author: Joseph Eagar
Date:   Tue Oct 13 15:30:46 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBd6ac6595504254ed2f06a6fd4e89c71f2052fe44

more int->SculptIdx refactoring

===

M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 0461e1e48b2..fb5f14eb8a6 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -174,7 +174,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
struct IsectRayPrecalc *isect_precalc,
float *depth,
SculptIdx *active_vertex_index,
-   SculptIdx *active_face_grid_index,
+   int *active_face_grid_index,
float *face_normal);
 
 bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node,
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index b502711578d..04cf1767792 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2202,7 +2202,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
 const float ray_normal[3],
 struct IsectRayPrecalc *isect_precalc,
 float *depth,
-int *r_active_vertex_index,
+SculptIdx *r_active_vertex_index,
 int *r_active_face_index,
 float *r_face_normal)
 {
@@ -2270,7 +2270,7 @@ static bool pbvh_grids_node_raycast(PBVH *pbvh,
 const float ray_normal[3],
 struct IsectRayPrecalc *isect_precalc,
 float *depth,
-int *r_active_vertex_index,
+SculptIdx *r_active_vertex_index,
 int *r_active_grid_index,
 float *r_face_normal)
 {
@@ -2365,7 +2365,7 @@ bool BKE_pbvh_node_raycast(PBVH *pbvh,
const float ray_normal[3],
struct IsectRayPrecalc *isect_precalc,
float *depth,
-   int *active_vertex_index,
+   SculptIdx *active_vertex_index,
int *active_face_grid_index,
float *face_normal)
 {
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c 
b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 9b68b1d35e9..990ecfaaa21 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1518,7 +1518,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
  struct IsectRayPrecalc *isect_precalc,
  float *depth,
  bool use_original,
- int *r_active_vertex_index,
+ SculptIdx *r_active_vertex_index,
  float *r_face_normal)
 {
   bool hit = false;
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index 40cc079d75e..e26267dc004 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -1477,7 +1477,7 @@ bool pbvh_trimesh_node_raycast(PBVHNode *node,
   struct IsectRayPrecalc *isect_precalc,
   float *depth,
   bool use_original,
-  int *r_active_vertex_index,
+  SculptIdx *r_active_vertex_index,
   float *r_face_normal)
 {
   bool hit = false;
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index f13072360bf..428256e427e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -119,7 +119,7 @@ float 
*SCULPT_brush_deform_target_vertex_co_get(SculptSession *ss,
 #define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256
 typedef struct SculptVertexNeighborIter {
   /* Storage */
-  int *neighbors;
+  SculptIdx *neighbors;
   int size;
   int capacity;
   SculptIdx neighbors_fixed[SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY];

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

[Bf-blender-cvs] [3369b0b0ee9] temp-trimesh-sculpt: inline SmallHash

2020-10-13 Thread Joseph Eagar
Commit: 3369b0b0ee936459a7df089e423ddbff61874a3f
Author: Joseph Eagar
Date:   Sat Oct 10 01:15:57 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rB3369b0b0ee936459a7df089e423ddbff61874a3f

inline SmallHash

===

M   source/blender/blenlib/BLI_smallhash.h
M   source/blender/blenlib/intern/smallhash.c

===

diff --git a/source/blender/blenlib/BLI_smallhash.h 
b/source/blender/blenlib/BLI_smallhash.h
index daea2fcd914..c9875caf7b3 100644
--- a/source/blender/blenlib/BLI_smallhash.h
+++ b/source/blender/blenlib/BLI_smallhash.h
@@ -23,7 +23,14 @@
  * \ingroup bli
  */
 
+#define USE_SMALLHASH_REMOVE
+
+#include "BLI_utildefines.h"
+
 #include "BLI_compiler_attrs.h"
+#include "BLI_compiler_compat.h"
+#include "BLI_compiler_typecheck.h"
+#include "BLI_assert.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -48,29 +55,281 @@ typedef struct SmallHash {
 
 typedef struct {
   const SmallHash *sh;
-  unsigned int i;
+  uintptr_t key;
+  void *val;
+  unsigned int i, done;
 } SmallHashIter;
 
+
+#define SMHASH_KEY_UNUSED ((uintptr_t)(UINTPTR_MAX - 0))
+#define SMHASH_CELL_FREE ((void *)(UINTPTR_MAX - 1))
+#define SMHASH_CELL_UNUSED ((void *)(UINTPTR_MAX - 2))
+
+/* typically this re-assigns 'h' */
+#define SMHASH_NEXT(h, hoff) \
+  (CHECK_TYPE_INLINE(&(h), uintptr_t *), \
+   CHECK_TYPE_INLINE(&(hoff), uintptr_t *), \
+   ((h) + (((hoff) = ((hoff)*2) + 1), (hoff
+
+BLI_INLINE int smallhash_val_is_used(const void *val)
+{
+#ifdef USE_SMALLHASH_REMOVE
+  return !ELEM(val, SMHASH_CELL_FREE, SMHASH_CELL_UNUSED);
+#else
+  return (val != SMHASH_CELL_FREE);
+#endif
+}
+
+BLI_INLINE uintptr_t smallhash_key(const uintptr_t key)
+{
+  return key;
+}
+
+BLI_INLINE SmallHashEntry *smallhash_lookup(const SmallHash *sh, const 
uintptr_t key)
+{
+  SmallHashEntry *e;
+  uintptr_t h = smallhash_key(key);
+  uintptr_t hoff = 1;
+
+  BLI_assert(key != SMHASH_KEY_UNUSED);
+
+  /* note: there are always more buckets than entries,
+  * so we know there will always be a free bucket if the key isn't found. */
+  for (e = &sh->buckets[h % sh->nbuckets]; e->val != SMHASH_CELL_FREE;)
+  {
+if (e->key == key) {
+  /* should never happen because unused keys are zero'd */
+  BLI_assert(e->val != SMHASH_CELL_UNUSED);
+
+  return e;
+}
+
+h = SMHASH_NEXT(h, hoff);
+e = &sh->buckets[h % sh->nbuckets];
+  }
+
+  return NULL;
+}
+
+BLI_INLINE void *BLI_smallhash_lookup(const SmallHash *sh, uintptr_t key)
+{
+  SmallHashEntry *e = smallhash_lookup(sh, key);
+
+  return e ? e->val : NULL;
+}
+
+BLI_INLINE void **BLI_smallhash_lookup_p(const SmallHash *sh, uintptr_t key)
+{
+  SmallHashEntry *e = smallhash_lookup(sh, key);
+
+  return e ? &e->val : NULL;
+}
+
+BLI_INLINE bool BLI_smallhash_haskey(const SmallHash *sh, uintptr_t key)
+{
+  SmallHashEntry *e = smallhash_lookup(sh, key);
+
+  return (e != NULL);
+}
+
+BLI_INLINE int BLI_smallhash_len(const SmallHash *sh)
+{
+  return (int)sh->nentries;
+}
+
+BLI_INLINE SmallHashEntry *smallhash_iternext(SmallHashIter *iter, uintptr_t 
*key)
+{
+  while (iter->i < iter->sh->nbuckets) {
+if (smallhash_val_is_used(iter->sh->buckets[iter->i].val)) {
+  SmallHashEntry *e = iter->sh->buckets + iter->i;
+
+  iter->key = e->key;
+  iter->val = e->val;
+
+  if (key) {
+*key = iter->key;
+  }
+
+  iter->i++;
+  return e;
+}
+
+iter->i++;
+  }
+
+  iter->done = 1;
+  return NULL;
+}
+
+BLI_INLINE void *BLI_smallhash_iternext(SmallHashIter *iter, uintptr_t *key)
+{
+  SmallHashEntry *e = smallhash_iternext(iter, key);
+
+  return e ? e->val : NULL;
+}
+
+BLI_INLINE void **BLI_smallhash_iternext_p(SmallHashIter *iter, uintptr_t *key)
+{
+  SmallHashEntry *e = smallhash_iternext(iter, key);
+
+  return e ? &e->val : NULL;
+}
+
+BLI_INLINE void *BLI_smallhash_iternew(const SmallHash *sh, SmallHashIter 
*iter, uintptr_t *key)
+{
+  iter->sh = sh;
+  iter->i = 0;
+  iter->key = 0;
+  iter->val = NULL;
+  iter->done = 0;
+
+  return BLI_smallhash_iternext(iter, key);
+}
+void BLI_smallhash_clear(SmallHash *sh);
+
+BLI_INLINE void smallhash_resize_buckets(SmallHash *sh, const uint nbuckets);
+extern const uint BLI_ghash_hash_sizes[];
+
+/**
+* Check if the number of items in the smallhash is large enough to require 
more buckets.
+*/
+BLI_INLINE bool smallhash_test_expand_buckets(const uint nentries, const uint 
nbuckets)
+{
+  /* (approx * 1.5) */
+  return (nentries + (nentries >> 1)) > nbuckets;
+}
+
+BLI_INLINE SmallHashEntry *smallhash_lookup_first_free(SmallHash *sh, const 
uintptr_t key)
+{
+  SmallHashEntry *e;
+  uintptr_t h = smallhash_key(key);
+  uintptr_t hoff = 1;
+
+  for (e = &sh->buckets[h % sh->nbuckets]; smallhash_val_is_used(e->val);
+h = SMHASH_NEXT(h, hoff), e = &sh->buckets[h % sh->nbuckets]) {
+/* pass */
+  }
+
+  return e;
+}
+
+BLI_INLINE void smallhash_init_empt

[Bf-blender-cvs] [862b5b18421] master: Fix T81511: Loop-cut overlay doesn't follow deformed cage

2020-10-13 Thread Campbell Barton
Commit: 862b5b18421a986b3d2cf8b0951f1a58797aaa52
Author: Campbell Barton
Date:   Wed Oct 14 14:49:22 2020 +1100
Branches: master
https://developer.blender.org/rB862b5b18421a986b3d2cf8b0951f1a58797aaa52

Fix T81511: Loop-cut overlay doesn't follow deformed cage

With constructive + deform modifiers, loop-cut visualization
wasn't following the displayed mesh.

This now gets the coordinates from the cage when available.

===

M   source/blender/blenkernel/BKE_editmesh.h
M   source/blender/blenkernel/intern/editmesh.c
M   source/blender/editors/mesh/editmesh_loopcut.c
M   source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c

===

diff --git a/source/blender/blenkernel/BKE_editmesh.h 
b/source/blender/blenkernel/BKE_editmesh.h
index 819e91b438e..6febbb4e136 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -99,6 +99,13 @@ float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph 
*depsgraph,
struct Object *ob,
int *r_vert_len))[3];
 float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int 
*r_vert_len))[3];
+const float (*BKE_editmesh_vert_coords_when_deformed(struct Depsgraph 
*depsgraph,
+ struct BMEditMesh *em,
+ struct Scene *scene,
+ struct Object *obedit,
+ int *r_vert_len,
+ bool *r_is_alloc))[3];
+
 void BKE_editmesh_lnorspace_update(BMEditMesh *em, struct Mesh *me);
 void BKE_editmesh_ensure_autosmooth(BMEditMesh *em, struct Mesh *me);
 struct BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em);
diff --git a/source/blender/blenkernel/intern/editmesh.c 
b/source/blender/blenkernel/intern/editmesh.c
index 1a5b7685c0e..c5a4b48aed8 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -36,6 +36,7 @@
 #include "BKE_lib_id.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_iterators.h"
+// #include "BKE_jesh_runtime.h"
 #include "BKE_mesh_wrapper.h"
 #include "BKE_object.h"
 
@@ -228,6 +229,34 @@ float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph 
*depsgraph,
   return cos_cage;
 }
 
+const float (*BKE_editmesh_vert_coords_when_deformed(struct Depsgraph 
*depsgraph,
+ BMEditMesh *em,
+ struct Scene *scene,
+ Object *ob,
+ int *r_vert_len,
+ bool *r_is_alloc))[3]
+{
+  const float(*coords)[3] = NULL;
+  *r_is_alloc = false;
+
+  Mesh *me = ob->data;
+
+  if ((me->runtime.edit_data != NULL) && (me->runtime.edit_data->vertexCos != 
NULL)) {
+/* Deformed, and we have deformed coords already. */
+coords = me->runtime.edit_data->vertexCos;
+  }
+  else if ((em->mesh_eval_final != NULL) &&
+   (em->mesh_eval_final->runtime.wrapper_type == 
ME_WRAPPER_TYPE_BMESH)) {
+/* If this is an edit-mesh type, leave NULL as we can use the vertex 
coords. . */
+  }
+  else {
+/* Constructive modifiers have been used, we need to allocate coordinates. 
*/
+*r_is_alloc = true;
+coords = BKE_editmesh_vert_coords_alloc(depsgraph, em, scene, ob, 
r_vert_len);
+  }
+  return coords;
+}
+
 float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int 
*r_vert_len))[3]
 {
   return BM_mesh_vert_coords_alloc(em->bm, r_vert_len);
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c 
b/source/blender/editors/mesh/editmesh_loopcut.c
index d19e7799fbe..69d27cd5ffa 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -64,6 +64,11 @@
 
 /* ringsel operator */
 
+struct MeshCoordsCache {
+  bool is_init, is_alloc;
+  const float (*coords)[3];
+};
+
 /* struct for properties used while drawing */
 typedef struct RingSelOpData {
   ARegion *region;   /* region that ringsel was activated in */
@@ -78,6 +83,8 @@ typedef struct RingSelOpData {
   Base **bases;
   uint bases_len;
 
+  struct MeshCoordsCache *geom_cache;
+
   /* These values switch objects based on the object under the cursor. */
   uint base_index;
   Object *ob;
@@ -138,15 +145,18 @@ static void edgering_select(RingSelOpData *lcd)
 static void ringsel_find_edge(RingSelOpData *lcd, const int previewlines)
 {
   if (lcd->eed) {
-const float(*coords)[3] = NULL;
-{
-  Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(lcd->depsgraph, 
lcd->ob->data);
-  if (me_eval->runtime.edit_data) {
-coords = me_eval->r

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

2020-10-13 Thread Campbell Barton
Commit: deca7c795411975e3bfb11cd6934ace768be772b
Author: Campbell Barton
Date:   Wed Oct 14 14:43:54 2020 +1100
Branches: master
https://developer.blender.org/rBdeca7c795411975e3bfb11cd6934ace768be772b

Cleanup: spelling

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/shrinkwrap.c
M   source/blender/bmesh/intern/bmesh_construct.c
M   source/blender/editors/screen/area.c
M   source/blender/io/collada/MeshImporter.cpp
M   source/blender/modifiers/intern/MOD_volume_displace.cc
M   source/blender/simulation/intern/implicit_blender.c
M   source/blender/simulation/intern/implicit_eigen.cpp

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 64910e5f1a9..614badb59f9 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -270,12 +270,12 @@ typedef enum eSculptClothConstraintType {
   /* Constraint that creates the structure of the cloth. */
   SCULPT_CLOTH_CONSTRAINT_STRUCTURAL = 0,
   /* Constraint that references the position of a vertex and a position in 
deformation_pos which
- can be deformed by the tools. */
+   * can be deformed by the tools. */
   SCULPT_CLOTH_CONSTRAINT_DEFORMATION = 1,
-  /* Constarint that references the vertex position and a editable softbody 
position for
- plasticity. */
+  /* Constraint that references the vertex position and a editable soft-body 
position for
+   * plasticity. */
   SCULPT_CLOTH_CONSTRAINT_SOFTBODY = 2,
-  /* Constarint that references the vertex position and its initial position. 
*/
+  /* Constraint that references the vertex position and its initial position. 
*/
   SCULPT_CLOTH_CONSTRAINT_PIN = 3,
 } eSculptClothConstraintType;
 
@@ -295,7 +295,7 @@ typedef struct SculptClothLengthConstraint {
   float length;
   float strength;
 
-  /* Index in SculptClothSimulation.node_state of the node from where this 
constraint was created.
+  /* Index in #SculptClothSimulation.node_state of the node from where this 
constraint was created.
* This constraints will only be used by the solver if the state is active. 
*/
   int node;
 
@@ -329,7 +329,7 @@ typedef struct SculptClothSimulation {
   struct ListBase *collider_list;
 
   int totnode;
-  /* PBVHNode pointer as a key, index in SculptClothSimulation.node_state as 
value. */
+  /** #PBVHNode pointer as a key, index in #SculptClothSimulation.node_state 
as value. */
   struct GHash *node_state_index;
   eSculptClothNodeSimState *node_state;
 } SculptClothSimulation;
@@ -341,7 +341,7 @@ typedef struct SculptPersistentBase {
 } SculptPersistentBase;
 
 typedef struct SculptVertexInfo {
-  /* Idexed by vertex, stores and ID of its topologycally connected component. 
*/
+  /* Indexed by vertex, stores and ID of its topologically connected 
component. */
   int *connected_component;
 
   /* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
@@ -429,7 +429,7 @@ typedef struct SculptFakeNeighbors {
   /* Max distance used to calculate neighborhood information. */
   float current_max_distance;
 
-  /* Idexed by vertex, stores the vertex index of its fake neighbor if 
available. */
+  /* Indexed by vertex, stores the vertex index of its fake neighbor if 
available. */
   int *fake_neighbor_index;
 
 } SculptFakeNeighbors;
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c 
b/source/blender/blenkernel/intern/shrinkwrap.c
index e9cf6421a02..96f2b8c1095 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -345,10 +345,10 @@ void BKE_shrinkwrap_compute_boundary_data(struct Mesh 
*mesh)
   mesh->runtime.shrinkwrap_data = shrinkwrap_build_boundary_data(mesh);
 }
 
-/*
- * Shrinkwrap to the nearest vertex
+/**
+ * Shrink-wrap to the nearest vertex
  *
- * it builds a kdtree of vertexs we can attach to and then
+ * it builds a #BVHTree of vertices we can attach to and then
  * for each vertex performs a nearest vertex search on the tree
  */
 static void shrinkwrap_calc_nearest_vertex_cb_ex(void *__restrict userdata,
diff --git a/source/blender/bmesh/intern/bmesh_construct.c 
b/source/blender/bmesh/intern/bmesh_construct.c
index 757ab735134..4c70be65bef 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -612,8 +612,8 @@ void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh 
*bm_src, const BMAllocTem
  *
  * \param bm_dst: BMesh whose custom-data layers will be added.
  * \param bm_src: BMesh whose custom-data layers will be copied.
- * \param htype: Specifies which custom-datas will be initiated.
- * \param allocsize: Estimated number of elements to init the mempool.
+ * \param htype: Specifies which custom-data layers will be initiated.
+ * \param allocsize: Initialize the the mem

[Bf-blender-cvs] [c7cd74fac3c] master: Cleanup: multi-line comment blocks

2020-10-13 Thread Campbell Barton
Commit: c7cd74fac3c47ce0c449ba5f2d130c6309242431
Author: Campbell Barton
Date:   Wed Oct 14 15:24:42 2020 +1100
Branches: master
https://developer.blender.org/rBc7cd74fac3c47ce0c449ba5f2d130c6309242431

Cleanup: multi-line comment blocks

===

M   source/blender/blenlib/BLI_vector.hh
M   source/blender/blenlib/intern/math_boolean.cc
M   source/blender/compositor/intern/COM_NodeOperation.h
M   source/blender/draw/engines/eevee/eevee_renderpasses.c
M   source/blender/editors/animation/keyframes_general.c
M   source/blender/editors/gpencil/annotate_paint.c
M   source/blender/editors/gpencil/gpencil_paint.c
M   source/blender/editors/sculpt_paint/paint_stroke.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/space_node/node_group.c
M   source/blender/editors/space_outliner/outliner_tools.c
M   source/blender/editors/space_view3d/view3d_view.c
M   source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
M   source/blender/io/collada/BlenderContext.cpp
M   source/blender/makesdna/DNA_cloth_types.h
M   source/blender/makesdna/DNA_layer_types.h
M   source/blender/makesdna/DNA_sound_types.h
M   source/blender/makesrna/intern/rna_attribute.c
M   source/blender/python/generic/py_capi_utils.c
M   source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c

===

diff --git a/source/blender/blenlib/BLI_vector.hh 
b/source/blender/blenlib/BLI_vector.hh
index 3c90e1ab755..053dcb6faea 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -186,7 +186,7 @@ class Vector {
 
   template> * = 
nullptr>
   Vector(InputIt first, InputIt last, Allocator allocator = {})
   : Vector(NoExceptConstructor(), allocator)
diff --git a/source/blender/blenlib/intern/math_boolean.cc 
b/source/blender/blenlib/intern/math_boolean.cc
index f7454a713a1..f8bf8676f50 100644
--- a/source/blender/blenlib/intern/math_boolean.cc
+++ b/source/blender/blenlib/intern/math_boolean.cc
@@ -123,7 +123,7 @@ namespace robust_pred {
  * Since this is C++, an instantiated singleton class is used to make
  * sure that #exactinit() is called once.
  * (Because it's undefined when this is called in initialization of all 
modules,
- other modules shouldn't use these functions in initialization.)
+ * other modules shouldn't use these functions in initialization.)
  */
 
 void exactinit();
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h 
b/source/blender/compositor/intern/COM_NodeOperation.h
index d9324729560..0ce7c1389bd 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -51,20 +51,20 @@ class NodeOperationOutput;
  */
 typedef enum InputResizeMode {
   /** \brief Center the input image to the center of the working area of the 
node, no resizing
- occurs */
+   * occurs */
   COM_SC_CENTER = NS_CR_CENTER,
   /** \brief The bottom left of the input image is the bottom left of the 
working area of the node,
- no resizing occurs */
+   * no resizing occurs */
   COM_SC_NO_RESIZE = NS_CR_NONE,
   /** \brief Fit the width of the input image to the width of the working area 
of the node */
   COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
   /** \brief Fit the height of the input image to the height of the working 
area of the node */
   COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
   /** \brief Fit the width or the height of the input image to the width or 
height of the working
- area of the node, image will be larger than the working area */
+   * area of the node, image will be larger than the working area */
   COM_SC_FIT = NS_CR_FIT,
   /** \brief Fit the width and the height of the input image to the width and 
height of the working
- area of the node, image will be equally larger than the working area */
+   * area of the node, image will be equally larger than the working area */
   COM_SC_STRETCH = NS_CR_STRETCH,
 } InputResizeMode;
 
diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.c 
b/source/blender/draw/engines/eevee/eevee_renderpasses.c
index 8ec823879ad..be73225b348 100644
--- a/source/blender/draw/engines/eevee/eevee_renderpasses.c
+++ b/source/blender/draw/engines/eevee/eevee_renderpasses.c
@@ -367,8 +367,8 @@ void EEVEE_renderpasses_draw(EEVEE_ViewLayerData *sldata, 
EEVEE_Data *vedata)
   EEVEE_EffectsInfo *effects = stl->effects;
   DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
 
-  /* We can only draw a single renderpass. Lightpasses also select their color 
pass (a second
-  pass). We mask the light pass when a light pass is selected. */
+  /* We can only draw a single renderpass. Lightpasses also select their color 
pass
+   * (a second pass). We mask the light pass when a light pass is selected. */
   const eViewLa

[Bf-blender-cvs] [863b38d7081] master: Cleanup: commented includes

2020-10-13 Thread Campbell Barton
Commit: 863b38d7081673c41f343d28aa64c65f6cc41f96
Author: Campbell Barton
Date:   Wed Oct 14 15:12:40 2020 +1100
Branches: master
https://developer.blender.org/rB863b38d7081673c41f343d28aa64c65f6cc41f96

Cleanup: commented includes

===

M   source/blender/blenkernel/intern/editmesh.c
M   source/blender/draw/engines/eevee/eevee_shadows.c
M   source/blender/editors/sculpt_paint/paint_ops.c

===

diff --git a/source/blender/blenkernel/intern/editmesh.c 
b/source/blender/blenkernel/intern/editmesh.c
index c5a4b48aed8..0fa3bb29ccd 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -36,7 +36,6 @@
 #include "BKE_lib_id.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_iterators.h"
-// #include "BKE_jesh_runtime.h"
 #include "BKE_mesh_wrapper.h"
 #include "BKE_object.h"
 
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c 
b/source/blender/draw/engines/eevee/eevee_shadows.c
index 618096fc992..2f8eb482882 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows.c
@@ -23,9 +23,6 @@
 #include "BLI_string_utils.h"
 #include "BLI_sys_types.h" /* bool */
 
-// #include "BLI_dynstr.h"
-// #include "BLI_rand.h"
-
 #include "BKE_object.h"
 
 #include "DEG_depsgraph_query.h"
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c 
b/source/blender/editors/sculpt_paint/paint_ops.c
index d5745caa66a..f4586fa130d 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -56,9 +56,8 @@
 #include "paint_intern.h"
 #include "sculpt_intern.h"
 
-#include 
-// #include 
 #include 
+#include 
 
 /* Brush operators */
 static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))

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


[Bf-blender-cvs] [cb40edf63ae] master: Fix T81686: Confusing add menu in pose mode

2020-10-13 Thread Hans Goudey
Commit: cb40edf63ae40d5010304c7770afd0d78ef709e7
Author: Hans Goudey
Date:   Wed Oct 14 15:39:01 2020 +1100
Branches: master
https://developer.blender.org/rBcb40edf63ae40d5010304c7770afd0d78ef709e7

Fix T81686: Confusing add menu in pose mode

===

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 8f42c74092a..0622e9568d1 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -3892,7 +3892,6 @@ def km_pose(params):
 
 items.extend([
 ("object.parent_set", {"type": 'P', "value": 'PRESS', "ctrl": True}, 
None),
-op_menu("VIEW3D_MT_add", {"type": 'A', "value": 'PRESS', "shift": 
True}),
 ("pose.hide", {"type": 'H', "value": 'PRESS'},
  {"properties": [("unselected", False)]}),
 ("pose.hide", {"type": 'H', "value": 'PRESS', "shift": True},

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


[Bf-blender-cvs] [0133bcaf38f] master: Fix crash starting Blender with Python 3.9

2020-10-13 Thread Campbell Barton
Commit: 0133bcaf38f6ecb5d6937c9b762026cc452720de
Author: Campbell Barton
Date:   Wed Oct 14 16:15:44 2020 +1100
Branches: master
https://developer.blender.org/rB0133bcaf38f6ecb5d6937c9b762026cc452720de

Fix crash starting Blender with Python 3.9

In 3.8 and older the class held a reference to methods,
this is no longer the case in 3.9.

===

M   source/blender/python/intern/bpy_rna.c

===

diff --git a/source/blender/python/intern/bpy_rna.c 
b/source/blender/python/intern/bpy_rna.c
index 7796d0a01a1..ce66cd6ee27 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -8131,9 +8131,8 @@ static int bpy_class_validate_recursive(PointerRNA 
*dummyptr,
   PyErr_Clear();
 }
 else {
-  /* No need to keep a ref, the class owns it
-   * (technically we should keep a reference, but...). */
-  Py_DECREF(item);
+  /* Store original so we can decrement it's reference before returning. */
+  PyObject *item_orig = item;
 
   if (is_staticmethod) {
 if (PyMethod_Check(item) == 0) {
@@ -8144,6 +8143,7 @@ static int bpy_class_validate_recursive(PointerRNA 
*dummyptr,
py_class_name,
RNA_function_identifier(func),
Py_TYPE(item)->tp_name);
+  Py_DECREF(item_orig);
   return -1;
 }
 item = ((PyMethodObject *)item)->im_func;
@@ -8157,6 +8157,7 @@ static int bpy_class_validate_recursive(PointerRNA 
*dummyptr,
py_class_name,
RNA_function_identifier(func),
Py_TYPE(item)->tp_name);
+  Py_DECREF(item_orig);
   return -1;
 }
   }
@@ -8197,9 +8198,11 @@ static int bpy_class_validate_recursive(PointerRNA 
*dummyptr,
 func_arg_count,
 arg_count);
   }
+  Py_DECREF(item_orig);
   return -1;
 }
   }
+  Py_DECREF(item_orig);
 }
   }

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


[Bf-blender-cvs] [2d4f1afece1] master: Cleanup: reduce indentation level in bpy_class_validate_recursive

2020-10-13 Thread Campbell Barton
Commit: 2d4f1afece18e46bfab3d6b383a099d89975eefb
Author: Campbell Barton
Date:   Wed Oct 14 16:21:13 2020 +1100
Branches: master
https://developer.blender.org/rB2d4f1afece18e46bfab3d6b383a099d89975eefb

Cleanup: reduce indentation level in bpy_class_validate_recursive

===

M   source/blender/python/intern/bpy_rna.c

===

diff --git a/source/blender/python/intern/bpy_rna.c 
b/source/blender/python/intern/bpy_rna.c
index ce66cd6ee27..71471474ec0 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -8103,18 +8103,11 @@ static int bpy_class_validate_recursive(PointerRNA 
*dummyptr,
   for (link = lb->first; link; link = link->next) {
 FunctionRNA *func = (FunctionRNA *)link;
 const int flag = RNA_function_flag(func);
-/* TODO(campbell): this is used for classmethod's too,
- * even though class methods should have 'FUNC_USE_SELF_TYPE' set, see 
Operator.poll for eg.
- * Keep this as-is since it's working, but we should be using
- * 'FUNC_USE_SELF_TYPE' for many functions. */
-const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & 
FUNC_USE_SELF_TYPE);
-
 if (!(flag & FUNC_REGISTER)) {
   continue;
 }
 
 item = PyObject_GetAttrString(py_class, RNA_function_identifier(func));
-
 have_function[i] = (item != NULL);
 i++;
 
@@ -8127,83 +8120,89 @@ static int bpy_class_validate_recursive(PointerRNA 
*dummyptr,
  RNA_function_identifier(func));
 return -1;
   }
-
   PyErr_Clear();
+
+  continue;
 }
-else {
-  /* Store original so we can decrement it's reference before returning. */
-  PyObject *item_orig = item;
 
-  if (is_staticmethod) {
-if (PyMethod_Check(item) == 0) {
-  PyErr_Format(PyExc_TypeError,
-   "expected %.200s, %.200s class \"%.200s\" "
-   "attribute to be a static/class method, not a %.200s",
-   class_type,
-   py_class_name,
-   RNA_function_identifier(func),
-   Py_TYPE(item)->tp_name);
-  Py_DECREF(item_orig);
-  return -1;
-}
-item = ((PyMethodObject *)item)->im_func;
+/* TODO(campbell): this is used for classmethod's too,
+ * even though class methods should have 'FUNC_USE_SELF_TYPE' set, see 
Operator.poll for eg.
+ * Keep this as-is since it's working, but we should be using
+ * 'FUNC_USE_SELF_TYPE' for many functions. */
+const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & 
FUNC_USE_SELF_TYPE);
+
+/* Store original so we can decrement it's reference before returning. */
+PyObject *item_orig = item;
+
+if (is_staticmethod) {
+  if (PyMethod_Check(item) == 0) {
+PyErr_Format(PyExc_TypeError,
+ "expected %.200s, %.200s class \"%.200s\" "
+ "attribute to be a static/class method, not a %.200s",
+ class_type,
+ py_class_name,
+ RNA_function_identifier(func),
+ Py_TYPE(item)->tp_name);
+Py_DECREF(item_orig);
+return -1;
   }
-  else {
-if (PyFunction_Check(item) == 0) {
-  PyErr_Format(PyExc_TypeError,
-   "expected %.200s, %.200s class \"%.200s\" "
-   "attribute to be a function, not a %.200s",
-   class_type,
-   py_class_name,
-   RNA_function_identifier(func),
-   Py_TYPE(item)->tp_name);
-  Py_DECREF(item_orig);
-  return -1;
-}
+  item = ((PyMethodObject *)item)->im_func;
+}
+else {
+  if (PyFunction_Check(item) == 0) {
+PyErr_Format(PyExc_TypeError,
+ "expected %.200s, %.200s class \"%.200s\" "
+ "attribute to be a function, not a %.200s",
+ class_type,
+ py_class_name,
+ RNA_function_identifier(func),
+ Py_TYPE(item)->tp_name);
+Py_DECREF(item_orig);
+return -1;
   }
+}
 
-  func_arg_count = rna_function_arg_count(func, &func_arg_min_count);
+func_arg_count = rna_function_arg_count(func, &func_arg_min_count);
 
-  if (func_arg_count >= 0) { /* -1 if we don't care. */
-arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
+if (func_arg_count >= 0) { /* -1 if we don't care. */
+  arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
 
-/* note, the number of args we check for and the number of args we 
give to
- * '@staticmethods' are different (quirk of Python),
- * this is why rna_function_arg_count() doesn't return the value -1*/