From 5fa58fb8a2bfbf132055d00dd3491f16f2f8379b Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Tue, 19 May 2020 00:53:59 -0400 Subject: [PATCH 01/12] Fix T76821: Generalize Use Flow Tooltip --- release/scripts/startup/bl_ui/properties_physics_fluid.py | 2 +- source/blender/makesrna/intern/rna_fluid.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 4b0791a63e6..2c8ed363738 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -237,7 +237,7 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel): col = grid.column() col.prop(flow, "flow_behavior", expand=False) if flow.flow_behavior in {'INFLOW', 'OUTFLOW'}: - col.prop(flow, "use_inflow", text="Use Flow") + col.prop(flow, "use_inflow") col.prop(flow, "subframes", text="Sampling Substeps") diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index 03b57a496ef..7ffba1caaa9 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -2516,7 +2516,7 @@ static void rna_def_fluid_flow_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_inflow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_FLOW_USE_INFLOW); - RNA_def_property_ui_text(prop, "Enabled", "Control when to apply inflow"); + RNA_def_property_ui_text(prop, "Use Flow", "Control when to apply fluid flow"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset"); prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE); From ac8b36535ead8b3f9ff680f70ad7fe773e17351e Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Tue, 19 May 2020 00:54:37 -0400 Subject: [PATCH 02/12] Cleanup: Creator Args Spelling Differential Revision: https://developer.blender.org/D7735 --- source/creator/creator_args.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index bd56d86784e..88c5cc9e53d 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -959,7 +959,7 @@ static const char arg_handle_debug_mode_generic_set_doc_jobs[] = "Enable time profiling for background jobs."; static const char arg_handle_debug_mode_generic_set_doc_gpu[] = "\n\t" - "Enable gpu debug context and information for OpenGL 4.3+."; + "Enable GPU debug context and information for OpenGL 4.3+."; static const char arg_handle_debug_mode_generic_set_doc_depsgraph[] = "\n\t" "Enable all debug messages from dependency graph."; @@ -995,7 +995,7 @@ static int arg_handle_debug_mode_generic_set(int UNUSED(argc), static const char arg_handle_debug_mode_io_doc[] = "\n\t" - "Enable debug messages for I/O (collada, ...)."; + "Enable debug messages for I/O (Collada, ...)."; static int arg_handle_debug_mode_io(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) @@ -1124,7 +1124,7 @@ static int arg_handle_factory_startup_set(int UNUSED(argc), static const char arg_handle_disable_override_library_doc[] = "\n\t" - "Enable Library Override features in the UI."; + "Disable Library Override features in the UI."; static int arg_handle_disable_override_library(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) @@ -1497,7 +1497,7 @@ static int arg_handle_threads_set(int argc, const char **argv, void *UNUSED(data static const char arg_handle_verbosity_set_doc[] = "\n" - "\tSet logging verbosity level for debug messages which supports it."; + "\tSet the logging verbosity level for debug messages that support it."; static int arg_handle_verbosity_set(int argc, const char **argv, void *UNUSED(data)) { const char *arg_id = "--verbose"; From fc06c248edd1ef29e4ca0daeb9f866eb8bd95621 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 18 May 2020 16:23:33 +0200 Subject: [PATCH 03/12] Fix T73169: Side by Side Stereo Rendering Glitches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Side by side and top down views were rendered using an unset matrix. This fix will reset the matrix just before copying the views to the screen. Reviewed By: Clément Foucault, Dalai Felinto Differential Revision: https://developer.blender.org/D7777 --- source/blender/windowmanager/intern/wm_draw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index a01ab1377c1..bf30d7a3328 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -848,6 +848,7 @@ static void wm_draw_window(bContext *C, wmWindow *win) glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture)); + wmWindowViewport(win); if (win->stereo3d_format->display_mode == S3D_DISPLAY_SIDEBYSIDE) { wm_stereo3d_draw_sidebyside(win, view); } From 888427cabbf4f218890cf908a135c1f527fe8a49 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 18 May 2020 15:06:03 +0200 Subject: [PATCH 04/12] Fix T76780: Freestyle pass for one scene not accessible in compositor in other scenes Current implementation would update the nodetree of the freestyle scene not the composite scene. Reviewed By: Dalai Felinto Differential Revision: https://developer.blender.org/D7770 --- source/blender/nodes/composite/nodes/node_composite_image.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 382459993b7..53ea02ff8a7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -311,8 +311,7 @@ static void cmp_node_rlayer_create_outputs(bNodeTree *ntree, if ((scene->r.mode & R_EDGE_FRS) && (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS)) { - ntreeCompositRegisterPass( - scene->nodetree, scene, view_layer, RE_PASSNAME_FREESTYLE, SOCK_RGBA); + ntreeCompositRegisterPass(ntree, scene, view_layer, RE_PASSNAME_FREESTYLE, SOCK_RGBA); } MEM_freeN(data); From 291136eecea31c13232054accc2663dcdf7b2a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 12 May 2020 18:22:14 +0200 Subject: [PATCH 05/12] Fix T76689: Armature layers not indicating the existence of bones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From what I can see, there are two issues at play in {T76689} and its merged-in report {T76590}: - In Blender ≤ 2.79 the bone layer dots were updated in the draw code. This ensured the info was up to date before drawing. This is no longer possible, as the drawing code uses evaluated objects, and those should not be written to. This has been addressed in rB709f126e8143 by calling the update function explicitly in various places in the code. The problem is that this wasn't added to all necessary spots. - When in edit mode, changes are made to the edit bones but not to the 'actual' bones (this is synced when exiting edit mode). This causes undo to mess up the layer indicators. I think both issues can be addressed by having the dependency graph update the used layer info as part of the armature evaluation. This will make the undo system work properly, and allows the removal of some `BKE_armature_refresh_layer_used()` from various places. There is still the issue that there are two functions (`BKE_armature_refresh_layer_used()` and `ED_armature_edit_refresh_layer_used()`) that are both responsible for updating `bArmature::layer_used`. This is a trickier thing to solve, though, as the definition of the `EditBone` struct resides in the armature editor module. This means that blenkernel can't iterate over edit bones, but on the other hand the dependency graph shouldn't call any editor functions either. This is why I left the `ED_armature_edit_refresh_layer_used()` calls untouched. The downside of recalculating `layer_used` from the dependency graph (at least in the way that I did it now) is that it is called every time a user moves a bone in pose mode. This frequency of updates is not necessary. Differential Revision: https://developer.blender.org/D7709 --- source/blender/blenkernel/BKE_armature.h | 2 +- source/blender/blenkernel/intern/armature.c | 18 +++++++++++++----- .../intern/builder/deg_builder_nodes.cc | 6 +++++- .../editors/armature/armature_relations.c | 3 --- source/blender/editors/armature/pose_edit.c | 2 -- source/blender/makesrna/intern/rna_armature.c | 3 +-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 6c383ae5011..54022a0a632 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -89,7 +89,7 @@ void BKE_armature_bone_hash_free(struct bArmature *arm); bool BKE_armature_bone_flag_test_recursive(const struct Bone *bone, int flag); -void BKE_armature_refresh_layer_used(struct bArmature *arm); +void BKE_armature_refresh_layer_used(struct Depsgraph *depsgraph, struct bArmature *arm); float distfactor_to_bone( const float vec[3], const float b1[3], const float b2[3], float r1, float r2, float rdist); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index af98992cc01..04051edd334 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -66,6 +66,7 @@ #include "BKE_scene.h" #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "BIK_api.h" @@ -480,14 +481,21 @@ static void armature_refresh_layer_used_recursive(bArmature *arm, ListBase *bone } } -/* Update the layers_used variable after bones are moved between layer - * NOTE: Used to be done in drawing code in 2.7, but that won't work with - * Copy-on-Write, as drawing uses evaluated copies. - */ -void BKE_armature_refresh_layer_used(bArmature *arm) +void BKE_armature_refresh_layer_used(struct Depsgraph *depsgraph, struct bArmature *arm) { + if (arm->edbo != NULL) { + /* Don't perform this update when the armature is in edit mode. In that case it should be + * handled by ED_armature_edit_refresh_layer_used(). */ + return; + } + arm->layer_used = 0; armature_refresh_layer_used_recursive(arm, &arm->bonebase); + + if (depsgraph == NULL || DEG_is_active(depsgraph)) { + bArmature *arm_orig = (bArmature *)DEG_get_original_id(&arm->id); + arm_orig->layer_used = arm->layer_used; + } } /* Finds the best possible extension to the name on a particular axis. (For renaming, check for diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index f6834feeeae..0e84494b2b7 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -1413,7 +1413,11 @@ void DepsgraphNodeBuilder::build_armature(bArmature *armature) build_animdata(&armature->id); build_parameters(&armature->id); /* Make sure pose is up-to-date with armature updates. */ - add_operation_node(&armature->id, NodeType::ARMATURE, OperationCode::ARMATURE_EVAL); + bArmature *armature_cow = (bArmature *)get_cow_id(&armature->id); + add_operation_node(&armature->id, + NodeType::ARMATURE, + OperationCode::ARMATURE_EVAL, + function_bind(BKE_armature_refresh_layer_used, _1, armature_cow)); build_armature_bones(&armature->bonebase); } diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index bc854747a68..d544aed5481 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -432,7 +432,6 @@ int join_armature_exec(bContext *C, wmOperator *op) ED_armature_from_edit(bmain, arm); ED_armature_edit_free(arm); - BKE_armature_refresh_layer_used(arm); DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); @@ -689,9 +688,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op) /* 5) restore original conditions */ ED_armature_to_edit(ob_old->data); - ED_armature_edit_refresh_layer_used(ob_old->data); - BKE_armature_refresh_layer_used(ob_new->data); /* parents tips remain selected when connected children are removed. */ ED_armature_edit_deselect_all(ob_old); diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index b86da6374be..c5b9f6adb28 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -901,8 +901,6 @@ static int pose_bone_layers_exec(bContext *C, wmOperator *op) RNA_boolean_set_array(&ptr, "layers", layers); if (prev_ob != ob) { - BKE_armature_refresh_layer_used(ob->data); - /* Note, notifier might evolve. */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); DEG_id_tag_update((ID *)ob->data, ID_RECALC_COPY_ON_WRITE); diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 3afbd0405fe..fe35af8c2e0 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -301,8 +301,7 @@ static void rna_Bone_layer_set(PointerRNA *ptr, const bool *values) Bone *bone = (Bone *)ptr->data; rna_bone_layer_set(&bone->layer, values); - - BKE_armature_refresh_layer_used(arm); + BKE_armature_refresh_layer_used(NULL, arm); } /* TODO: remove the deprecation stubs. */ From f89b89fa7fcce713fa560ff7be2bb5bbe274e29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 19 May 2020 09:39:03 +0200 Subject: [PATCH 06/12] CMake: Enable WITH_USD by default Having USD disabled by default was an oversight, and could have been corrected earlier. It's already enabled by default in the `blender_release.cmake` and `blender_full.cmake`. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fb0393dcda..71963bc0487 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,7 +278,7 @@ option(WITH_ALEMBIC "Enable Alembic Support" ON) option(WITH_ALEMBIC_HDF5 "Enable Legacy Alembic Support (not officially supported)" OFF) # Universal Scene Description support -option(WITH_USD "Enable Universal Scene Description (USD) Support" OFF) +option(WITH_USD "Enable Universal Scene Description (USD) Support" ON) # 3D format support # Disable opencollada when we don't have precompiled libs From b96ccb5126b29fa9ff014103e350cfa3c94d376a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 May 2020 17:53:26 +1000 Subject: [PATCH 07/12] Fix T76865: Vertex paint draws hidden but cannot be painted onto --- source/blender/blenkernel/BKE_pbvh.h | 15 +++++-- source/blender/blenkernel/intern/paint.c | 42 +++++++++++++------ source/blender/blenkernel/intern/pbvh.c | 27 +++++++++--- .../blender/blenkernel/intern/pbvh_intern.h | 1 + 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 1779385b97b..1eeb340d071 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -308,6 +308,8 @@ void BKE_pbvh_face_sets_set(PBVH *bvh, int *face_sets); void BKE_pbvh_face_sets_color_set(PBVH *bvh, int seed, int color_default); +void BKE_pbvh_respect_hide_set(PBVH *bvh, bool respect_hide); + /* vertex deformer */ float (*BKE_pbvh_vert_coords_alloc(struct PBVH *pbvh))[3]; void BKE_pbvh_vert_coords_apply(struct PBVH *pbvh, const float (*vertCos)[3], const int totvert); @@ -333,6 +335,7 @@ typedef struct PBVHVertexIter { int gy; int i; int index; + bool respect_hide; /* grid */ struct CCGKey key; @@ -401,9 +404,15 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo } \ else if (vi.mverts) { \ vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \ - vi.visible = !(vi.mvert->flag & ME_HIDE); \ - if (mode == PBVH_ITER_UNIQUE && !vi.visible) \ - continue; \ + if (vi.respect_hide) { \ + vi.visible = !(vi.mvert->flag & ME_HIDE); \ + if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \ + continue; \ + } \ + } \ + else { \ + BLI_assert(vi.visible); \ + } \ vi.co = vi.mvert->co; \ vi.no = vi.mvert->no; \ vi.index = vi.vert_indices[vi.i]; \ diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index a7f973dfdbb..0c9b1721f79 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1480,6 +1480,7 @@ static void sculpt_update_object( SculptSession *ss = ob->sculpt; Mesh *me = BKE_object_get_original_mesh(ob); MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); + const bool use_face_sets = (ob->mode & OB_MODE_SCULPT) != 0; ss->deform_modifiers_active = sculpt_modifiers_active(scene, sd, ob); ss->show_mask = (sd->flags & SCULPT_HIDE_MASK) == 0; @@ -1535,17 +1536,22 @@ static void sculpt_update_object( } /* Sculpt Face Sets. */ - if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { - ss->face_sets = CustomData_add_layer( - &me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly); - for (int i = 0; i < me->totpoly; i++) { - ss->face_sets[i] = 1; - } + if (use_face_sets) { + if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) { + ss->face_sets = CustomData_add_layer( + &me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly); + for (int i = 0; i < me->totpoly; i++) { + ss->face_sets[i] = 1; + } - /* Set the default face set color if the datalayer did not exist. */ - me->face_sets_color_default = 1; + /* Set the default face set color if the datalayer did not exist. */ + me->face_sets_color_default = 1; + } + ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); + } + else { + ss->face_sets = NULL; } - ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS); ss->subdiv_ccg = me_eval->runtime.subdiv_ccg; @@ -1805,11 +1811,12 @@ static PBVH *build_pbvh_for_dynamic_topology(Object *ob) return pbvh; } -static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform) +static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool respect_hide) { Mesh *me = BKE_object_get_original_mesh(ob); const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop); PBVH *pbvh = BKE_pbvh_new(); + BKE_pbvh_respect_hide_set(pbvh, respect_hide); MLoopTri *looptri = MEM_malloc_arrayN(looptris_num, sizeof(*looptri), __func__); @@ -1841,11 +1848,12 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform) return pbvh; } -static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg) +static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg, bool respect_hide) { CCGKey key; BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg); PBVH *pbvh = BKE_pbvh_new(); + BKE_pbvh_respect_hide_set(pbvh, respect_hide); BKE_pbvh_build_grids(pbvh, subdiv_ccg->grids, subdiv_ccg->num_grids, @@ -1863,6 +1871,14 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) if (ob == NULL || ob->sculpt == NULL) { return NULL; } + + bool respect_hide = true; + if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { + if (!(BKE_paint_select_vert_test(ob) || BKE_paint_select_face_test(ob))) { + respect_hide = false; + } + } + PBVH *pbvh = ob->sculpt->pbvh; if (pbvh != NULL) { /* NOTE: It is possible that grids were re-allocated due to modifier @@ -1886,11 +1902,11 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); Mesh *mesh_eval = object_eval->data; if (mesh_eval->runtime.subdiv_ccg != NULL) { - pbvh = build_pbvh_from_ccg(ob, mesh_eval->runtime.subdiv_ccg); + pbvh = build_pbvh_from_ccg(ob, mesh_eval->runtime.subdiv_ccg, respect_hide); } else if (ob->type == OB_MESH) { Mesh *me_eval_deform = object_eval->runtime.mesh_deform_eval; - pbvh = build_pbvh_from_regular_mesh(ob, me_eval_deform); + pbvh = build_pbvh_from_regular_mesh(ob, me_eval_deform, respect_hide); } } diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index d925a2b4db9..17edf94a53c 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -295,6 +295,10 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) node->face_vert_indices = (const int(*)[3])face_vert_indices; + if (bvh->respect_hide == false) { + has_visible = true; + } + for (int i = 0; i < totface; i++) { const MLoopTri *lt = &bvh->looptri[node->prim_indices[i]]; for (int j = 0; j < 3; j++) { @@ -302,8 +306,10 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) bvh, map, &node->face_verts, &node->uniq_verts, bvh->mloop[lt->tri[j]].v); } - if (!paint_is_face_hidden(lt, bvh->verts, bvh->mloop)) { - has_visible = true; + if (has_visible == false) { + if (!paint_is_face_hidden(lt, bvh->verts, bvh->mloop)) { + has_visible = true; + } } } @@ -666,7 +672,7 @@ void BKE_pbvh_build_grids(PBVH *bvh, PBVH *BKE_pbvh_new(void) { PBVH *bvh = MEM_callocN(sizeof(PBVH), "pbvh"); - + bvh->respect_hide = true; return bvh; } @@ -2117,7 +2123,7 @@ static bool pbvh_faces_node_raycast(PBVH *bvh, const MLoopTri *lt = &bvh->looptri[faces[i]]; const int *face_verts = node->face_vert_indices[i]; - if (paint_is_face_hidden(lt, vert, mloop)) { + if (bvh->respect_hide && paint_is_face_hidden(lt, vert, mloop)) { continue; } @@ -2426,7 +2432,7 @@ static bool pbvh_faces_node_nearest_to_ray(PBVH *bvh, const MLoopTri *lt = &bvh->looptri[faces[i]]; const int *face_verts = node->face_vert_indices[i]; - if (paint_is_face_hidden(lt, vert, mloop)) { + if (bvh->respect_hide && paint_is_face_hidden(lt, vert, mloop)) { continue; } @@ -2900,6 +2906,12 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo vi->fno = NULL; vi->mvert = NULL; + vi->respect_hide = bvh->respect_hide; + if (bvh->respect_hide == false) { + /* The same value for all vertices. */ + vi->visible = true; + } + BKE_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids); BKE_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); BKE_pbvh_node_get_verts(bvh, node, &vert_indices, &verts); @@ -3014,3 +3026,8 @@ void BKE_pbvh_face_sets_set(PBVH *bvh, int *face_sets) { bvh->face_sets = face_sets; } + +void BKE_pbvh_respect_hide_set(PBVH *bvh, bool respect_hide) +{ + bvh->respect_hide = respect_hide; +} diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index d3e42ac7705..7397f939894 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -160,6 +160,7 @@ struct PBVH { bool deformed; bool show_mask; bool show_face_sets; + bool respect_hide; /* Dynamic topology */ BMesh *bm; From cddfa7a449d22b3a680ea5e08381d6c621397e7a Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 18 May 2020 11:11:13 +0200 Subject: [PATCH 08/12] Fix T72729: Mask Modifier Loose Edges Not Shown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using the mask modifier loose edges could be added to the mesh. These edges weren't marked as loose edges and wasn't picked up by other areas of blender. This fix recalculates the loose edges so they have the correct flag `ME_LOOSE_EDGE`. Reviewed By: Sybren Stüvel Differential Revision: https://developer.blender.org/D7766 --- source/blender/modifiers/intern/MOD_mask.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index 3bdb5a3fd54..e5cba7fc601 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -366,6 +366,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes copy_masked_polys_to_new_mesh( *mesh, *result, vertex_map, edge_map, masked_poly_indices, new_loop_starts); + BKE_mesh_calc_edges_loose(result); /* Tag to recalculate normals later. */ result->runtime.cd_dirty_vert |= CD_MASK_NORMAL; From 24e5c64ea2e228ea7441c8175f30b00b18427631 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Thu, 23 Apr 2020 14:11:15 +0200 Subject: [PATCH 09/12] Made pose push/relax to breakdown behave smooth on rotations A follow up to T67212. I missed that the rotation interpolation had its own code path. The previous rotation push code was actually wrong (but smooth). Now all of the actions behave correctly and is smoothly interpolated. --- source/blender/editors/armature/pose_slide.c | 81 ++++++++------------ 1 file changed, 33 insertions(+), 48 deletions(-) diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 5d782f64a75..d9621dba730 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -544,71 +544,56 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) /* only if all channels exist, proceed */ if (fcu_w && fcu_x && fcu_y && fcu_z) { - float quat_prev[4], quat_prev_orig[4]; - float quat_next[4], quat_next_orig[4]; - float quat_curr[4], quat_curr_orig[4]; float quat_final[4]; - copy_qt_qt(quat_curr_orig, pchan->quat); - - /* get 2 quats */ - quat_prev_orig[0] = evaluate_fcurve(fcu_w, prevFrameF); - quat_prev_orig[1] = evaluate_fcurve(fcu_x, prevFrameF); - quat_prev_orig[2] = evaluate_fcurve(fcu_y, prevFrameF); - quat_prev_orig[3] = evaluate_fcurve(fcu_z, prevFrameF); - - quat_next_orig[0] = evaluate_fcurve(fcu_w, nextFrameF); - quat_next_orig[1] = evaluate_fcurve(fcu_x, nextFrameF); - quat_next_orig[2] = evaluate_fcurve(fcu_y, nextFrameF); - quat_next_orig[3] = evaluate_fcurve(fcu_z, nextFrameF); - - normalize_qt_qt(quat_prev, quat_prev_orig); - normalize_qt_qt(quat_next, quat_next_orig); - normalize_qt_qt(quat_curr, quat_curr_orig); - /* perform blending */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* Just perform the interpolation between quat_prev and * quat_next using pso->percentage as a guide. */ + float quat_prev[4]; + float quat_next[4]; + + quat_prev[0] = evaluate_fcurve(fcu_w, prevFrameF); + quat_prev[1] = evaluate_fcurve(fcu_x, prevFrameF); + quat_prev[2] = evaluate_fcurve(fcu_y, prevFrameF); + quat_prev[3] = evaluate_fcurve(fcu_z, prevFrameF); + + quat_next[0] = evaluate_fcurve(fcu_w, nextFrameF); + quat_next[1] = evaluate_fcurve(fcu_x, nextFrameF); + quat_next[2] = evaluate_fcurve(fcu_y, nextFrameF); + quat_next[3] = evaluate_fcurve(fcu_z, nextFrameF); + + normalize_qt(quat_prev); + normalize_qt(quat_next); + interp_qt_qtqt(quat_final, quat_prev, quat_next, pso->percentage); } - else if (pso->mode == POSESLIDE_PUSH) { - float quat_diff[4]; - - /* calculate the delta transform from the previous to the current */ - /* TODO: investigate ways to favor one transform more? */ - sub_qt_qtqt(quat_diff, quat_curr, quat_prev); - - /* increase the original by the delta transform, by an amount determined by percentage */ - add_qt_qtqt(quat_final, quat_curr, quat_diff, pso->percentage); - - normalize_qt(quat_final); - } else { - BLI_assert(pso->mode == POSESLIDE_RELAX); - float quat_interp[4], quat_final_prev[4]; - /* TODO: maybe a sensitivity ctrl on top of this is needed */ - int iters = (int)ceil(10.0f * pso->percentage); + /* POSESLIDE_PUSH and POSESLIDE_RELAX. */ + float quat_breakdown[4]; + float quat_curr[4]; - copy_qt_qt(quat_final, quat_curr); + copy_qt_qt(quat_curr, pchan->quat); - /* perform this blending several times until a satisfactory result is reached */ - while (iters-- > 0) { - /* calculate the interpolation between the endpoints */ - interp_qt_qtqt(quat_interp, - quat_prev, - quat_next, - (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame)); + quat_breakdown[0] = evaluate_fcurve(fcu_w, cframe); + quat_breakdown[1] = evaluate_fcurve(fcu_x, cframe); + quat_breakdown[2] = evaluate_fcurve(fcu_y, cframe); + quat_breakdown[3] = evaluate_fcurve(fcu_z, cframe); - normalize_qt_qt(quat_final_prev, quat_final); + normalize_qt(quat_breakdown); + normalize_qt(quat_curr); - /* tricky interpolations - blending between original and new */ - interp_qt_qtqt(quat_final, quat_final_prev, quat_interp, 1.0f / 6.0f); + if (pso->mode == POSESLIDE_PUSH) { + interp_qt_qtqt(quat_final, quat_breakdown, quat_curr, 1.0f + pso->percentage); + } + else { + BLI_assert(pso->mode == POSESLIDE_RELAX); + interp_qt_qtqt(quat_final, quat_curr, quat_breakdown, pso->percentage); } } /* Apply final to the pose bone, keeping compatible for similar keyframe positions. */ - quat_to_compatible_quat(pchan->quat, quat_final, quat_curr_orig); + quat_to_compatible_quat(pchan->quat, quat_final, pchan->quat); } /* free the path now */ From 10528a5cd4eacad7d67e0939f0e0941d8c499876 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Tue, 12 May 2020 13:19:20 +0200 Subject: [PATCH 10/12] Fix Frame Dropping not dropping the correct amount of frames Previously the playback mode "Frame Dropping" would not drop the correct number of frames which would lead to slow playback. For example, the playback target is 60fps. However we can only muster around 32 fps. The delta frames from the last step is in this case ~1.98 or so. With the previous code, we would floor this. That would lead us to step forward one frame each time, effectively playing back the animation at half the speed as we will try to render every frame. To fix this we simply save the remaining fraction from the previous frame and use it to compute the current frame step. Reviewed By: Sybren Differential Revision: http://developer.blender.org/D7694 --- .../blender/editors/include/ED_screen_types.h | 10 +++---- source/blender/editors/screen/screen_ops.c | 29 +++++++++++++++---- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index 06c2c3039f5..51f3eea74fa 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -34,11 +34,11 @@ extern "C" { typedef struct ScreenAnimData { ARegion *region; /* do not read from this, only for comparing if region exists */ short redraws; - short flag; /* flags for playback */ - int sfra; /* frame that playback was started from */ - int nextfra; /* next frame to go to (when ANIMPLAY_FLAG_USE_NEXT_FRAME is set) */ - double last_duration; /* used for frame dropping */ - bool from_anim_edit; /* playback was invoked from animation editor */ + short flag; /* flags for playback */ + int sfra; /* frame that playback was started from */ + int nextfra; /* next frame to go to (when ANIMPLAY_FLAG_USE_NEXT_FRAME is set) */ + double lagging_frame_count; /* used for frame dropping */ + bool from_anim_edit; /* playback was invoked from animation editor */ } ScreenAnimData; /* for animplayer */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 57367abca1a..90813c9351c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4443,10 +4443,29 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv } else { if (sync) { - /* note: this is very simplistic, - * its has problem that it may skip too many frames. - * however at least this gives a less jittery playback */ - const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS)); + /* Try to keep the playback in realtime by dropping frames. */ + + /* How much time (in frames) has passed since the last frame was drawn? */ + double delta_frames = wt->delta * FPS; + + /* Add the remaining fraction from the last time step. */ + delta_frames += sad->lagging_frame_count; + + if (delta_frames < 1.0) { + /* We can render faster than the scene frame rate. However skipping or delaying frames + * here seems to in practice lead to jittery playback so just step forward a minimum of + * one frame. (Even though this can lead to too fast playback, the jitteryness is more + * annoying) + */ + delta_frames = 1.0f; + sad->lagging_frame_count = 0; + } + else { + /* Extract the delta frame fractions that will be skipped when converting to int. */ + sad->lagging_frame_count = delta_frames - (int)delta_frames; + } + + const int step = delta_frames; /* skip frames */ if (sad->flag & ANIMPLAY_FLAG_REVERSE) { @@ -4467,8 +4486,6 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv } } - sad->last_duration = wt->duration; - /* reset 'jumped' flag before checking if we need to jump... */ sad->flag &= ~ANIMPLAY_FLAG_JUMPED; From 25dea3e65efd64566d0b6397094fa76ec4ef089d Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Wed, 13 May 2020 16:27:05 +0200 Subject: [PATCH 11/12] Fix T76717: Set Rotation Mode Incorrectly Recalculates Bone Rotation In Pose Mode The issue was that we didn't convert the current rotational values. We simply just switched mode without doing any data conversions. --- source/blender/editors/armature/pose_edit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index c5b9f6adb28..0cd3afc9cf9 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -665,6 +665,11 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op) /* set rotation mode of selected bones */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { + /* use API Method for conversions... */ + BKE_rotMode_change_values( + pchan->quat, pchan->eul, pchan->rotAxis, &pchan->rotAngle, pchan->rotmode, (short)mode); + + /* finally, set the new rotation type */ pchan->rotmode = mode; if (prev_ob != ob) { From 82bda82ec4494717f3796a8b458c81a98836838b Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Thu, 14 May 2020 13:43:09 +0200 Subject: [PATCH 12/12] Fix T76541: OpenGl Depth Picking not selecting frontmost object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue was that we used GL_ALWAYS for depth checking here which would lead to the depth information from objects being messed up. It would not represent which object was closest to the camera. Reviewed By: Clément Foucault, Jeroen Bakker, Campbell Barton Differential Revision: http://developer.blender.org/D7710 --- source/blender/gpu/intern/gpu_select_pick.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 674ca06d109..4b38cd333a1 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -314,17 +314,10 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); - - if (mode == GPU_SELECT_PICK_ALL) { - /* Note that other depth settings (such as #GL_LEQUAL) work too, - * since the depth is always cleared. - * Noting this for cases when depth picking is used where - * drawing calls change depth settings. */ - glDepthFunc(GL_ALWAYS); - } - else { - glDepthFunc(GL_LEQUAL); - } + /* Always use #GL_LEQUAL even though GPU_SELECT_PICK_ALL always clears the buffer. This is + * because individual objects themselves might have sections that overlap and we need these + * to have the correct distance information. */ + glDepthFunc(GL_LEQUAL); float viewport[4]; glGetFloatv(GL_VIEWPORT, viewport);