[Bf-blender-cvs] [329eeacc66d] master: Cleanup: Cycles: Remove isotropic microfacet closure setup functions
Commit: 329eeacc66d13c9007e22f200304ebe902737abb Author: Lukas Stockner Date: Mon Feb 6 02:01:17 2023 +0100 Branches: master https://developer.blender.org/rB329eeacc66d13c9007e22f200304ebe902737abb Cleanup: Cycles: Remove isotropic microfacet closure setup functions Turns out these are 100% redundant, so get rid of them. === M intern/cycles/kernel/closure/bsdf_microfacet.h M intern/cycles/kernel/osl/closures_setup.h === diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index f16c753d9e2..d7c3d3651fc 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -519,14 +519,6 @@ ccl_device int bsdf_microfacet_ggx_setup(ccl_private MicrofacetBsdf *bsdf) return SD_BSDF | SD_BSDF_HAS_EVAL; } -/* Required to maintain OSL interface. */ -ccl_device int bsdf_microfacet_ggx_isotropic_setup(ccl_private MicrofacetBsdf *bsdf) -{ - bsdf->alpha_y = bsdf->alpha_x; - - return bsdf_microfacet_ggx_setup(bsdf); -} - ccl_device int bsdf_microfacet_ggx_fresnel_setup(ccl_private MicrofacetBsdf *bsdf, ccl_private const ShaderData *sd) { @@ -613,14 +605,6 @@ ccl_device int bsdf_microfacet_beckmann_setup(ccl_private MicrofacetBsdf *bsdf) return SD_BSDF | SD_BSDF_HAS_EVAL; } -/* Required to maintain OSL interface. */ -ccl_device int bsdf_microfacet_beckmann_isotropic_setup(ccl_private MicrofacetBsdf *bsdf) -{ - bsdf->alpha_y = bsdf->alpha_x; - - return bsdf_microfacet_beckmann_setup(bsdf); -} - ccl_device int bsdf_microfacet_beckmann_refraction_setup(ccl_private MicrofacetBsdf *bsdf) { bsdf->alpha_x = saturatef(bsdf->alpha_x); diff --git a/intern/cycles/kernel/osl/closures_setup.h b/intern/cycles/kernel/osl/closures_setup.h index aa44132da5e..5ea8f080410 100644 --- a/intern/cycles/kernel/osl/closures_setup.h +++ b/intern/cycles/kernel/osl/closures_setup.h @@ -209,14 +209,7 @@ ccl_device void osl_closure_microfacet_setup(KernelGlobals kg, if (closure->distribution == make_string("ggx", 11253504724482777663ull) || closure->distribution == make_string("default", 4430693559278735917ull)) { if (!closure->refract) { - if (closure->alpha_x == closure->alpha_y) { -/* Isotropic */ -sd->flag |= bsdf_microfacet_ggx_isotropic_setup(bsdf); - } - else { -/* Anisotropic */ -sd->flag |= bsdf_microfacet_ggx_setup(bsdf); - } + sd->flag |= bsdf_microfacet_ggx_setup(bsdf); } else { sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf); @@ -225,14 +218,7 @@ ccl_device void osl_closure_microfacet_setup(KernelGlobals kg, /* Beckmann */ else { if (!closure->refract) { - if (closure->alpha_x == closure->alpha_y) { -/* Isotropic */ -sd->flag |= bsdf_microfacet_beckmann_isotropic_setup(bsdf); - } - else { -/* Anisotropic */ -sd->flag |= bsdf_microfacet_beckmann_setup(bsdf); - } + sd->flag |= bsdf_microfacet_beckmann_setup(bsdf); } else { sd->flag |= bsdf_microfacet_beckmann_refraction_setup(bsdf); @@ -258,9 +244,9 @@ ccl_device void osl_closure_microfacet_ggx_setup( } bsdf->N = ensure_valid_reflection(sd->Ng, sd->wi, closure->N); - bsdf->alpha_x = closure->alpha_x; + bsdf->alpha_x = bsdf->alpha_y = closure->alpha_x; - sd->flag |= bsdf_microfacet_ggx_isotropic_setup(bsdf); + sd->flag |= bsdf_microfacet_ggx_setup(bsdf); } ccl_device void osl_closure_microfacet_ggx_aniso_setup( @@ -652,9 +638,9 @@ ccl_device void osl_closure_microfacet_beckmann_setup( } bsdf->N = ensure_valid_reflection(sd->Ng, sd->wi, closure->N); - bsdf->alpha_x = closure->alpha_x; + bsdf->alpha_x = bsdf->alpha_y = closure->alpha_x; - sd->flag |= bsdf_microfacet_beckmann_isotropic_setup(bsdf); + sd->flag |= bsdf_microfacet_beckmann_setup(bsdf); } ccl_device void osl_closure_microfacet_beckmann_aniso_setup( ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2627635ff3a] master: Cleanup: use nullptr in C++
Commit: 2627635ff3aeb790f3d653f1a52c652066764bda Author: Campbell Barton Date: Mon Feb 6 12:46:53 2023 +1100 Branches: master https://developer.blender.org/rB2627635ff3aeb790f3d653f1a52c652066764bda Cleanup: use nullptr in C++ === M source/blender/blenkernel/intern/cdderivedmesh.cc M source/blender/blenkernel/intern/mesh_mirror.cc M source/blender/blenkernel/intern/subdiv_converter_mesh.cc M source/blender/draw/engines/workbench/workbench_shadow.cc M source/blender/draw/engines/workbench/workbench_state.cc M source/blender/editors/sculpt_paint/sculpt.cc M source/blender/editors/sculpt_paint/sculpt_undo.cc M source/blender/modifiers/intern/MOD_explode.cc === diff --git a/source/blender/blenkernel/intern/cdderivedmesh.cc b/source/blender/blenkernel/intern/cdderivedmesh.cc index 9cf5f7ecedf..2a98dbe6fb9 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.cc +++ b/source/blender/blenkernel/intern/cdderivedmesh.cc @@ -131,7 +131,7 @@ static void cdDM_recalc_looptri(DerivedMesh *dm) BLI_assert(cddm->dm.looptris.array == NULL); atomic_cas_ptr( (void **)>dm.looptris.array, cddm->dm.looptris.array, cddm->dm.looptris.array_wip); - cddm->dm.looptris.array_wip = NULL; + cddm->dm.looptris.array_wip = nullptr; } static void cdDM_free_internal(CDDerivedMesh *cddm) @@ -232,7 +232,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh, #if 0 cddm->mface = CustomData_get_layer(>faceData, CD_MFACE); #else - cddm->mface = NULL; + cddm->mface = nullptr; #endif /* commented since even when CD_ORIGINDEX was first added this line fails diff --git a/source/blender/blenkernel/intern/mesh_mirror.cc b/source/blender/blenkernel/intern/mesh_mirror.cc index 21b8ab83ebd..95f8008a4f9 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.cc +++ b/source/blender/blenkernel/intern/mesh_mirror.cc @@ -204,7 +204,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, /* Subdivision-surface for eg won't have mesh data in the custom-data arrays. * Now add position/#MEdge/#MPoly layers. */ - if (BKE_mesh_vert_positions(mesh) != NULL) { + if (BKE_mesh_vert_positions(mesh) != nullptr) { memcpy(BKE_mesh_vert_positions_for_write(result), BKE_mesh_vert_positions(mesh), sizeof(float[3]) * mesh->totvert); diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.cc b/source/blender/blenkernel/intern/subdiv_converter_mesh.cc index 05fa391dcaa..8be3f128e10 100644 --- a/source/blender/blenkernel/intern/subdiv_converter_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.cc @@ -161,7 +161,7 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter, int manif return 10.0f; } #endif - if (!storage->settings.use_creases || storage->cd_edge_crease == NULL) { + if (!storage->settings.use_creases || storage->cd_edge_crease == nullptr) { return 0.0f; } const int edge_index = storage->manifold_edge_index_reverse[manifold_edge_index]; @@ -184,7 +184,7 @@ static bool is_infinite_sharp_vertex(const OpenSubdiv_Converter *converter, static float get_vertex_sharpness(const OpenSubdiv_Converter *converter, int manifold_vertex_index) { ConverterStorage *storage = static_cast(converter->user_data); - if (!storage->settings.use_creases || storage->cd_vertex_crease == NULL) { + if (!storage->settings.use_creases || storage->cd_vertex_crease == nullptr) { return 0.0f; } const int vertex_index = storage->manifold_vertex_index_reverse[manifold_vertex_index]; @@ -208,7 +208,7 @@ static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int la const int num_vert = mesh->totvert; const float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT}; /* Initialize memory required for the operations. */ - if (storage->loop_uv_indices == NULL) { + if (storage->loop_uv_indices == nullptr) { storage->loop_uv_indices = static_cast( MEM_malloc_arrayN(mesh->totloop, sizeof(int), "loop uv vertex index")); } @@ -227,7 +227,7 @@ static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int la storage->num_uv_coordinates = -1; for (int vertex_index = 0; vertex_index < num_vert; vertex_index++) { const UvMapVert *uv_vert = BKE_mesh_uv_vert_map_get_vert(uv_vert_map, vertex_index); -while (uv_vert != NULL) { +while (uv_vert != nullptr) { if (uv_vert->separate) { storage->num_uv_coordinates++; } @@ -287,17 +287,17 @@ static void init_functions(OpenSubdiv_Converter *converter) converter->getNumFaceVertices = get_num_face_vertices; converter->getFaceVertices = get_face_vertices; - converter->getFaceEdges = NULL; + converter->getFaceEdges = nullptr; converter->getEdgeVertices = get_edge_vertices; -
[Bf-blender-cvs] [9f5c17f4af6] master: Cleanup: comments in code
Commit: 9f5c17f4af6ea54385c40f62e0337c13fc4680a5 Author: Campbell Barton Date: Mon Feb 6 12:23:01 2023 +1100 Branches: master https://developer.blender.org/rB9f5c17f4af6ea54385c40f62e0337c13fc4680a5 Cleanup: comments in code === M source/blender/editors/interface/interface.cc M source/blender/editors/interface/interface_widgets.cc M source/blender/editors/object/object_vgroup.cc M source/blender/editors/sculpt_paint/paint_image_proj.cc M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c M source/blender/makesrna/intern/rna_internal.h === diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 3e355af823a..d64c1f56a17 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -3955,7 +3955,7 @@ void UI_block_align_begin(uiBlock *block) block->flag |= UI_BUT_ALIGN_DOWN; block->alignnr++; - /* buttons declared after this call will get this align nr */ /* XXX flag? */ + /* Buttons declared after this call will get this `alignnr`. */ /* XXX flag? */ } void UI_block_align_end(uiBlock *block) diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index beddc6c7ae7..7b8015cf5a2 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -5022,7 +5022,7 @@ static void ui_draw_popover_back_impl(const uiWidgetColors *wcol, const float unit_size, const float mval_origin[2]) { - /* tsk, this isn't nice. */ + /* Alas, this isn't nice. */ const float unit_half = unit_size / 2; const float cent_x = mval_origin ? CLAMPIS(mval_origin[0], rect->xmin + unit_size, diff --git a/source/blender/editors/object/object_vgroup.cc b/source/blender/editors/object/object_vgroup.cc index 78a55aab5e9..5fbd5efa9d1 100644 --- a/source/blender/editors/object/object_vgroup.cc +++ b/source/blender/editors/object/object_vgroup.cc @@ -2130,8 +2130,8 @@ static void vgroup_smooth_subset(Object *ob, static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2) { - /* qsort sorts in ascending order. We want descending order to save a memcopy - * so this compare function is inverted from the standard greater than comparison qsort needs. + /* #qsort sorts in ascending order. We want descending order to save a #memcpy + * so this compare function is inverted from the standard greater than comparison #qsort needs. * A normal compare function is called with two pointer arguments and should return an integer * less than, equal to, or greater than zero corresponding to whether its first argument is * considered less than, equal to, or greater than its second argument. diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index db16931d6fb..9bf9f668a6b 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -191,7 +191,7 @@ BLI_INLINE uchar f_to_char(const float val) /** * This is mainly a convenience struct used so we can keep an array of images we use - - * their imbufs, etc, in 1 array, When using threads this array is copied for each thread + * their #ImBuf's, etc, in 1 array, When using threads this array is copied for each thread * because 'partRedrawRect' and 'touch' values would not be thread safe. */ struct ProjPaintImage { @@ -2882,7 +2882,8 @@ static void project_bucket_clip_face(const bool is_ortho, #endif } -/* +/** + * \code{.py} * # This script creates faces in a blender scene from printed data above. * * project_ls = [ @@ -2896,7 +2897,7 @@ static void project_bucket_clip_face(const bool is_ortho, * V = Mathutils.Vector * * def main(): - * sce = bpy.data.scenes.active + * scene = bpy.data.scenes.active * * for item in project_ls: * bb = item[0] @@ -2904,7 +2905,7 @@ static void project_bucket_clip_face(const bool is_ortho, * poly = item[2] * * me = bpy.data.meshes.new() - * ob = sce.objects.new(me) + * ob = scene.objects.new(me) * * me.verts.extend([V(bb[0]).xyz, V(bb[1]).xyz, V(bb[2]).xyz, V(bb[3]).xyz]) * me.faces.extend([(0,1,2,3),]) @@ -2926,6 +2927,7 @@ static void project_bucket_clip_face(const bool is_ortho, * * if __name__ == '__main__': * main() + * \endcode */ #undef ISECT_1 diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index 9ffe10360af..4367189c997 100644 ---
[Bf-blender-cvs] [d6b6050e5b8] master: Cleanup: use function style casts in C++
Commit: d6b6050e5b8a9e2534edd9ae8963a85a26164bc7 Author: Campbell Barton Date: Mon Feb 6 12:35:51 2023 +1100 Branches: master https://developer.blender.org/rBd6b6050e5b8a9e2534edd9ae8963a85a26164bc7 Cleanup: use function style casts in C++ === M source/blender/blenkernel/intern/pbvh.cc M source/blender/blenkernel/intern/pbvh_bmesh.cc M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/draw/engines/workbench/workbench_mesh_passes.cc M source/blender/draw/engines/workbench/workbench_shader_cache.cc === diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 1f3583a7f7e..b45a136f28c 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -393,8 +393,8 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, /* grid hidden layer is present, so have to check each grid for * visibility */ - int depth1 = int(log2((double)gridsize - 1.0) + DBL_EPSILON); - int depth2 = int(log2((double)display_gridsize - 1.0) + DBL_EPSILON); + int depth1 = int(log2(double(gridsize) - 1.0) + DBL_EPSILON); + int depth2 = int(log2(double(display_gridsize) - 1.0) + DBL_EPSILON); int skip = depth2 < depth1 ? 1 << (depth1 - depth2 - 1) : 1; @@ -3667,7 +3667,7 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step) } BMFace *f = (BMFace *)BLI_gsetIterator_getKey(>bm_faces_iter_); - fd->face.i = (intptr_t)f; + fd->face.i = intptr_t(f); fd->index = f->head.index; if (fd->cd_face_set_ != -1) { @@ -3683,7 +3683,7 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step) BMLoop *l = f->l_first; do { -fd->verts[vertex_i++].i = (intptr_t)l->v; +fd->verts[vertex_i++].i = intptr_t(l->v); } while ((l = l->next) != f->l_first); break; diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.cc b/source/blender/blenkernel/intern/pbvh_bmesh.cc index e7a9266c423..f8d4bdc88da 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.cc +++ b/source/blender/blenkernel/intern/pbvh_bmesh.cc @@ -1528,7 +1528,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node, if (j == 0 || len_squared_v3v3(location, cos[j]) < len_squared_v3v3(location, nearest_vertex_co)) { copy_v3_v3(nearest_vertex_co, cos[j]); - r_active_vertex->i = (intptr_t)node->bm_orvert[node->bm_ortri[i][j]]; + r_active_vertex->i = intptr_t(node->bm_orvert[node->bm_ortri[i][j]]); } } } @@ -1560,7 +1560,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node, if (j == 0 || len_squared_v3v3(location, v_tri[j]->co) < len_squared_v3v3(location, nearest_vertex_co)) { copy_v3_v3(nearest_vertex_co, v_tri[j]->co); -r_active_vertex->i = (intptr_t)v_tri[j]; +r_active_vertex->i = intptr_t(v_tri[j]); } } } diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 4a792fedf23..f18345b9eab 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -116,7 +116,7 @@ static void split_pixel_node( const int axis = BB_widest_axis(); const float mid = (cb.bmax[axis] + cb.bmin[axis]) * 0.5f; - node->flag = (PBVHNodeFlags)((int)node->flag & (int)~PBVH_TexLeaf); + node->flag = (PBVHNodeFlags)(int(node->flag) & int(~PBVH_TexLeaf)); SplitNodePair *split1 = MEM_new("split_pixel_node split1", split); SplitNodePair *split2 = MEM_new("split_pixel_node split1", split); @@ -188,7 +188,7 @@ static void split_pixel_node( float2 delta = uv_prim.delta_barycentric_coord_u; float2 uv1 = row.start_barycentric_coord; - float2 uv2 = row.start_barycentric_coord + delta * (float)row.num_pixels; + float2 uv2 = row.start_barycentric_coord + delta * float(row.num_pixels); float co1[3]; float co2[3]; @@ -210,7 +210,7 @@ static void split_pixel_node( t = (mid - co1[axis]) / (co2[axis] - co1[axis]); } -int num_pixels = (int)floorf((float)row.num_pixels * t); +int num_pixels = int(floorf(float(row.num_pixels) * t)); if (num_pixels) { row1.num_pixels = num_pixels; @@ -223,7 +223,7 @@ static void split_pixel_node( row2.num_pixels = row.num_pixels - num_pixels; row2.start_barycentric_coord = row.start_barycentric_coord + - uv_prim.delta_barycentric_coord_u * (float)num_pixels; + uv_prim.delta_barycentric_coord_u * float(num_pixels);
[Bf-blender-cvs] [4fcc9f5e7e3] master: Cleanup: use back-slash doxygen commands, de-duplicate doc-string
Commit: 4fcc9f5e7e3039485f81345b1d376593e4f0967d Author: Campbell Barton Date: Mon Feb 6 12:18:30 2023 +1100 Branches: master https://developer.blender.org/rB4fcc9f5e7e3039485f81345b1d376593e4f0967d Cleanup: use back-slash doxygen commands, de-duplicate doc-string === M source/blender/blenkernel/BKE_nla.h M source/blender/blenkernel/intern/nla.c === diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index d4d94618cc9..086f21aa897 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -133,19 +133,19 @@ void BKE_nlastrips_sort_strips(ListBase *strips); /** * Add the given NLA-Strip to the given list of strips, assuming that it - * isn't currently a member of another list, NULL, or conflicting with existing - * strips position. + * isn't currently a member of another list, NULL, or conflicting with existing + * strips position. */ void BKE_nlastrips_add_strip_unsafe(ListBase *strips, struct NlaStrip *strip); /** - * @brief NULL checks incoming strip and verifies no overlap / invalid - * configuration against other strips in NLA Track. + * \brief NULL checks incoming strip and verifies no overlap / invalid + * configuration against other strips in NLA Track. * - * @param strips - * @param strip - * @return true - * @return false + * \param strips: + * \param strip: + * \return true + * \return false */ bool BKE_nlastrips_add_strip(ListBase *strips, struct NlaStrip *strip); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index defa67ed664..6b631462ebd 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -787,7 +787,6 @@ void BKE_nlastrips_add_strip_unsafe(ListBase *strips, NlaStrip *strip) } } -/** NULL and Space check before adding in nlastrip */ bool BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip) { if (ELEM(NULL, strips, strip)) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [731c3efd97b] master: Cleanup: format
Commit: 731c3efd97bd84f3cda4d8bb3e0dea58b12951e7 Author: Campbell Barton Date: Mon Feb 6 12:32:45 2023 +1100 Branches: master https://developer.blender.org/rB731c3efd97bd84f3cda4d8bb3e0dea58b12951e7 Cleanup: format === M intern/cycles/kernel/closure/bsdf.h M intern/cycles/kernel/closure/bsdf_util.h M source/blender/blenkernel/BKE_mesh_legacy_convert.h M source/blender/blenkernel/intern/nla_test.cc M source/blender/bmesh/intern/bmesh_construct.h === diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h index 28829262ac9..e7754bde7c5 100644 --- a/intern/cycles/kernel/closure/bsdf.h +++ b/intern/cycles/kernel/closure/bsdf.h @@ -661,7 +661,8 @@ ccl_device void bsdf_blur(KernelGlobals kg, ccl_private ShaderClosure *sc, float #endif } -ccl_device_inline Spectrum bsdf_albedo(ccl_private const ShaderData *sd, ccl_private const ShaderClosure *sc) +ccl_device_inline Spectrum bsdf_albedo(ccl_private const ShaderData *sd, + ccl_private const ShaderClosure *sc) { Spectrum albedo = sc->weight; /* Some closures include additional components such as Fresnel terms that cause their albedo to diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h index 5d7fd989ef2..ee992375914 100644 --- a/intern/cycles/kernel/closure/bsdf_util.h +++ b/intern/cycles/kernel/closure/bsdf_util.h @@ -90,8 +90,10 @@ ccl_device float schlick_fresnel(float u) } /* Calculate the fresnel color, which is a blend between white and the F0 color */ -ccl_device_forceinline Spectrum -interpolate_fresnel_color(float3 L, float3 H, float ior, Spectrum F0) +ccl_device_forceinline Spectrum interpolate_fresnel_color(float3 L, + float3 H, + float ior, + Spectrum F0) { /* Compute the real Fresnel term and remap it from real_F0..1 to F0..1. * The reason why we use this remapping instead of directly doing the diff --git a/source/blender/blenkernel/BKE_mesh_legacy_convert.h b/source/blender/blenkernel/BKE_mesh_legacy_convert.h index ee33d535179..087716706e1 100644 --- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h +++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h @@ -36,7 +36,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh); * Move face sets to the legacy type from a generic type. */ void BKE_mesh_legacy_face_set_from_generic( - blender::MutableSpan poly_layers_to_write); +blender::MutableSpan poly_layers_to_write); /** * Copy face sets to the generic data type from the legacy type. */ diff --git a/source/blender/blenkernel/intern/nla_test.cc b/source/blender/blenkernel/intern/nla_test.cc index b138baaaea0..ef9ca83e25f 100644 --- a/source/blender/blenkernel/intern/nla_test.cc +++ b/source/blender/blenkernel/intern/nla_test.cc @@ -50,7 +50,7 @@ TEST(nla_strip, BKE_nlastrips_add_strip) NlaStrip strip2{}; strip2.start = 5; strip2.end = 10; - + /* can't add a null NLA strip to an NLA Track. */ EXPECT_FALSE(BKE_nlastrips_add_strip(, NULL)); diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h index 0b85abdaa92..036605e6b67 100644 --- a/source/blender/bmesh/intern/bmesh_construct.h +++ b/source/blender/bmesh/intern/bmesh_construct.h @@ -170,7 +170,6 @@ void BM_mesh_copy_init_customdata_all_layers(BMesh *bm_dst, const struct BMAllocTemplate *allocsize); BMesh *BM_mesh_copy(BMesh *bm_old); - #ifdef __cplusplus } #endif ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7de1a4d1d81] master: Fix GHOST/Wayland thread-unsafe timer-manager manipulation
Commit: 7de1a4d1d81ffd4cd2e75d911426edc847267244 Author: Campbell Barton Date: Mon Feb 6 11:38:04 2023 +1100 Branches: master https://developer.blender.org/rB7de1a4d1d81ffd4cd2e75d911426edc847267244 Fix GHOST/Wayland thread-unsafe timer-manager manipulation Mutex locks for manipulating GHOST_System::m_timerManager from GHOST_SystemWayland relied on WAYLAND being the only user of the timer-manager. This isn't the case as timers are fired from `GHOST_System::dispatchEvents`. Resolve by using a separate timer-manager for wayland key-repeat timers. === M intern/ghost/intern/GHOST_SystemWayland.cpp M intern/ghost/intern/GHOST_SystemWayland.h === diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 8587438a34b..014f3d24bae 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -82,6 +82,8 @@ #include "CLG_log.h" #ifdef USE_EVENT_BACKGROUND_THREAD +# include "GHOST_TimerTask.h" + # include #endif @@ -848,7 +850,14 @@ static void gwl_seat_key_repeat_timer_add(GWL_Seat *seat, GHOST_SystemWayland *system = seat->system; const uint64_t time_step = 1000 / seat->key_repeat.rate; const uint64_t time_start = use_delay ? seat->key_repeat.delay : time_step; +#ifdef USE_EVENT_BACKGROUND_THREAD + GHOST_TimerTask *timer = new GHOST_TimerTask( + system->getMilliSeconds() + time_start, time_step, key_repeat_fn, payload); + seat->key_repeat.timer = timer; + system->ghost_timer_manager()->addTimer(timer); +#else seat->key_repeat.timer = system->installTimer(time_start, time_step, key_repeat_fn, payload); +#endif } /** @@ -857,7 +866,12 @@ static void gwl_seat_key_repeat_timer_add(GWL_Seat *seat, static void gwl_seat_key_repeat_timer_remove(GWL_Seat *seat) { GHOST_SystemWayland *system = seat->system; +#ifdef USE_EVENT_BACKGROUND_THREAD + system->ghost_timer_manager()->removeTimer( + static_cast(seat->key_repeat.timer)); +#else system->removeTimer(seat->key_repeat.timer); +#endif seat->key_repeat.timer = nullptr; } @@ -935,6 +949,16 @@ struct GWL_Display { /** Guard against multiple threads accessing `events_pending` at once. */ std::mutex events_pending_mutex; + /** + * A separate timer queue, needed so the WAYLAND thread can lock access. + * Using the system's #GHOST_Sysem::getTimerManager is not thread safe because + * access to the timer outside of WAYLAND specific logic will not lock. + * + * Needed because #GHOST_System::dispatchEvents fires timers + * outside of WAYLAND (without locking the `timer_mutex`). + */ + GHOST_TimerManager *ghost_timer_manager; + #endif /* USE_EVENT_BACKGROUND_THREAD */ }; @@ -951,6 +975,9 @@ static void gwl_display_destroy(GWL_Display *display) ghost_wl_display_lock_without_input(display->wl_display, display->system->server_mutex); display->events_pthread_is_active = false; } + + delete display->ghost_timer_manager; + display->ghost_timer_manager = nullptr; #endif /* For typical WAYLAND use this will always be set. @@ -5453,6 +5480,8 @@ GHOST_SystemWayland::GHOST_SystemWayland(bool background) #ifdef USE_EVENT_BACKGROUND_THREAD gwl_display_event_thread_create(display_); + + display_->ghost_timer_manager = new GHOST_TimerManager(); #endif } @@ -5533,10 +5562,16 @@ bool GHOST_SystemWayland::processEvents(bool waitForEvent) #endif /* USE_EVENT_BACKGROUND_THREAD */ { +const uint64_t now = getMilliSeconds(); #ifdef USE_EVENT_BACKGROUND_THREAD -std::lock_guard lock_timer_guard{*display_->system->timer_mutex}; +{ + std::lock_guard lock_timer_guard{*display_->system->timer_mutex}; + if (ghost_timer_manager()->fireTimers(now)) { +any_processed = true; + } +} #endif -if (getTimerManager()->fireTimers(getMilliSeconds())) { +if (getTimerManager()->fireTimers(now)) { any_processed = true; } } @@ -6759,6 +6794,13 @@ struct wl_shm *GHOST_SystemWayland::wl_shm() const return display_->wl_shm; } +#ifdef USE_EVENT_BACKGROUND_THREAD +GHOST_TimerManager *GHOST_SystemWayland::ghost_timer_manager() +{ + return display_->ghost_timer_manager; +} +#endif + /** \} */ /* */ diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h index 44026d5efad..153931a0a39 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.h +++ b/intern/ghost/intern/GHOST_SystemWayland.h @@ -165,6 +165,16 @@ class GHOST_SystemWayland : public GHOST_System { bool cursor_grab_use_software_display_get(const GHOST_TGrabCursorMode mode); +#ifdef USE_EVENT_BACKGROUND_THREAD + /** + * Return a separate WAYLAND local timer manager to #GHOST_System::getTimerManager + * Manipulation
[Bf-blender-cvs] [d3949a4fdb1] master: Fix GHOST/Wayland thread-unsafe key-repeat timer checks
Commit: d3949a4fdb1c4ebc67e6ebd3af5792a3c2a51044 Author: Campbell Barton Date: Mon Feb 6 11:09:29 2023 +1100 Branches: master https://developer.blender.org/rBd3949a4fdb1c4ebc67e6ebd3af5792a3c2a51044 Fix GHOST/Wayland thread-unsafe key-repeat timer checks Resolve a thread safety issue reported by valgrind's helgrind checker, although I wasn't able to redo the error in practice. NULL check on the key-repeat timer also needs to lock, otherwise it's possible the timer is set in another thread before the lock is acquired. Now all key-repeat timer access which may run from a thread locks the timer mutex before any checks or timer manipulation. === M intern/ghost/intern/GHOST_SystemWayland.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 496179fc826..8587438a34b 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -768,7 +768,12 @@ struct GWL_Seat { int32_t rate = 0; /** Time (milliseconds) after which to start repeating keys. */ int32_t delay = 0; -/** Timer for key repeats. */ +/** + * Timer for key repeats. + * + * \note For as long as #USE_EVENT_BACKGROUND_THREAD is defined, any access to this + * (including null checks, must lock `timer_mutex` first. + */ GHOST_ITimerTask *timer = nullptr; } key_repeat; @@ -832,6 +837,30 @@ static bool gwl_seat_key_depressed_suppress_warning(const GWL_Seat *seat) return suppress_warning; } +/** + * \note Caller must lock `timer_mutex`. + */ +static void gwl_seat_key_repeat_timer_add(GWL_Seat *seat, + GHOST_TimerProcPtr key_repeat_fn, + GHOST_TUserDataPtr payload, + const bool use_delay) +{ + GHOST_SystemWayland *system = seat->system; + const uint64_t time_step = 1000 / seat->key_repeat.rate; + const uint64_t time_start = use_delay ? seat->key_repeat.delay : time_step; + seat->key_repeat.timer = system->installTimer(time_start, time_step, key_repeat_fn, payload); +} + +/** + * \note The caller must lock `timer_mutex`. + */ +static void gwl_seat_key_repeat_timer_remove(GWL_Seat *seat) +{ + GHOST_SystemWayland *system = seat->system; + system->removeTimer(seat->key_repeat.timer); + seat->key_repeat.timer = nullptr; +} + /** \} */ /* */ @@ -3718,9 +3747,14 @@ static void keyboard_handle_leave(void *data, GWL_Seat *seat = static_cast(data); seat->keyboard.wl_surface_window = nullptr; - /* Losing focus must stop repeating text. */ - if (seat->key_repeat.timer) { -keyboard_handle_key_repeat_cancel(seat); + { +#ifdef USE_EVENT_BACKGROUND_THREAD +std::lock_guard lock_timer_guard{*seat->system->timer_mutex}; +#endif +/* Losing focus must stop repeating text. */ +if (seat->key_repeat.timer) { + keyboard_handle_key_repeat_cancel(seat); +} } #ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING @@ -3780,36 +3814,32 @@ static xkb_keysym_t xkb_state_key_get_one_sym_without_modifiers( return sym; } +/** + * \note Caller must lock `timer_mutex`. + */ static void keyboard_handle_key_repeat_cancel(GWL_Seat *seat) { -#ifdef USE_EVENT_BACKGROUND_THREAD - std::lock_guard lock_timer_guard{*seat->system->timer_mutex}; -#endif GHOST_ASSERT(seat->key_repeat.timer != nullptr, "Caller much check for timer"); delete static_cast(seat->key_repeat.timer->getUserData()); - seat->system->removeTimer(seat->key_repeat.timer); - seat->key_repeat.timer = nullptr; + + gwl_seat_key_repeat_timer_remove(seat); } /** * Restart the key-repeat timer. * \param use_delay: When false, use the interval * (prevents pause when the setting changes while the key is held). + * + * \note Caller must lock `timer_mutex`. */ static void keyboard_handle_key_repeat_reset(GWL_Seat *seat, const bool use_delay) { -#ifdef USE_EVENT_BACKGROUND_THREAD - std::lock_guard lock_timer_guard{*seat->system->timer_mutex}; -#endif GHOST_ASSERT(seat->key_repeat.timer != nullptr, "Caller much check for timer"); - GHOST_SystemWayland *system = seat->system; - GHOST_ITimerTask *timer = seat->key_repeat.timer; - GHOST_TimerProcPtr key_repeat_fn = timer->getTimerProc(); + GHOST_TimerProcPtr key_repeat_fn = seat->key_repeat.timer->getTimerProc(); GHOST_TUserDataPtr payload = seat->key_repeat.timer->getUserData(); - seat->system->removeTimer(seat->key_repeat.timer); - const uint64_t time_step = 1000 / seat->key_repeat.rate; - const uint64_t time_start = use_delay ? seat->key_repeat.delay : time_step; - seat->key_repeat.timer = system->installTimer(time_start, time_step, key_repeat_fn, payload); + + gwl_seat_key_repeat_timer_remove(seat); +
[Bf-blender-cvs] [b642dc7bc7d] master: Fix: Incorrect forward-compatible saving of face sets
Commit: b642dc7bc7d8db7a2fc3f6c8c58d69429c57d338 Author: Hans Goudey Date: Sun Feb 5 18:09:22 2023 -0500 Branches: master https://developer.blender.org/rBb642dc7bc7d8db7a2fc3f6c8c58d69429c57d338 Fix: Incorrect forward-compatible saving of face sets There were two errors with the function used to convert face sets to the legacy mesh format for keeping forward compatibility: - It was moved before `CustomData_blend_write_prepare` so it operated on an empty span. - It modified the mesh when it's only supposed to change the copy of the layers written to the file. Differential Revision: https://developer.blender.org/D17210 === M source/blender/blenkernel/BKE_mesh_legacy_convert.h M source/blender/blenkernel/intern/mesh.cc M source/blender/blenkernel/intern/mesh_legacy_convert.cc === diff --git a/source/blender/blenkernel/BKE_mesh_legacy_convert.h b/source/blender/blenkernel/BKE_mesh_legacy_convert.h index 5b72d85a433..ee33d535179 100644 --- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h +++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h @@ -36,7 +36,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh); * Move face sets to the legacy type from a generic type. */ void BKE_mesh_legacy_face_set_from_generic( -Mesh *mesh, blender::MutableSpan poly_layers_to_write); + blender::MutableSpan poly_layers_to_write); /** * Copy face sets to the generic data type from the legacy type. */ diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 71275444028..dfdad20cc48 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -270,7 +270,6 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address BKE_mesh_legacy_convert_selection_layers_to_flags(mesh); BKE_mesh_legacy_convert_material_indices_to_mpoly(mesh); BKE_mesh_legacy_bevel_weight_from_layers(mesh); - BKE_mesh_legacy_face_set_from_generic(mesh, poly_layers); BKE_mesh_legacy_edge_crease_from_layers(mesh); BKE_mesh_legacy_sharp_edges_to_flags(mesh); BKE_mesh_legacy_attribute_strings_to_flags(mesh); @@ -292,6 +291,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address if (!BLO_write_is_undo(writer)) { BKE_mesh_legacy_convert_uvs_to_struct(mesh, temp_arrays_for_legacy_format, loop_layers); + BKE_mesh_legacy_face_set_from_generic(poly_layers); } } diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index c380a61dce2..b789fbcc0a0 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -1224,23 +1224,26 @@ void BKE_mesh_tessface_ensure(struct Mesh *mesh) /** \name Face Set Conversion * \{ */ -void BKE_mesh_legacy_face_set_from_generic(Mesh *mesh, - blender::MutableSpan poly_layers) +void BKE_mesh_legacy_face_set_from_generic(blender::MutableSpan poly_layers) { using namespace blender; - void *faceset_data = nullptr; + bool changed = false; for (CustomDataLayer : poly_layers) { if (StringRef(layer.name) == ".sculpt_face_set") { - faceset_data = layer.data; - layer.data = nullptr; - CustomData_free_layer_named(>pdata, ".sculpt_face_set", mesh->totpoly); + layer.type = CD_SCULPT_FACE_SETS; + layer.name[0] = '\0'; + changed = true; break; } } - if (faceset_data != nullptr) { -CustomData_add_layer( ->pdata, CD_SCULPT_FACE_SETS, CD_ASSIGN, faceset_data, mesh->totpoly); + if (!changed) { +return; } + /* #CustomData expects the layers to be sorted in increasing order based on type. */ + std::stable_sort( + poly_layers.begin(), + poly_layers.end(), + [](const CustomDataLayer , const CustomDataLayer ) { return a.type < b.type; }); } void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [07ea01767f7] refactor-mesh-sharp-face-generic: Merge branch 'master' into refactor-mesh-sharp-face-generic
Commit: 07ea01767f78e464951d23738ace5fef047c78f5 Author: Hans Goudey Date: Sun Feb 5 17:45:10 2023 -0500 Branches: refactor-mesh-sharp-face-generic https://developer.blender.org/rB07ea01767f78e464951d23738ace5fef047c78f5 Merge branch 'master' into refactor-mesh-sharp-face-generic === === diff --cc source/blender/blenkernel/intern/pbvh.cc index 209b8c40872,1f3583a7f7e..9c87d2a1ef7 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@@ -623,18 -615,16 +624,18 @@@ static void build_sub(PBVH *pbvh /* Build children */ build_sub(pbvh, +sharp_faces, pbvh->nodes[node_index].children_offset, - NULL, + nullptr, prim_bbc, offset, end - offset, prim_scratch, depth + 1); build_sub(pbvh, +sharp_faces, pbvh->nodes[node_index].children_offset + 1, - NULL, + nullptr, prim_bbc, end, offset + count - end, @@@ -668,7 -659,7 +670,7 @@@ static void pbvh_build(PBVH *pbvh, cons } pbvh->totnode = 1; - build_sub(pbvh, sharp_faces, 0, cb, prim_bbc, 0, totprim, NULL, 0); - build_sub(pbvh, 0, cb, prim_bbc, 0, totprim, nullptr, 0); ++ build_sub(pbvh, sharp_faces, 0, cb, prim_bbc, 0, totprim, nullptr, 0); } static void pbvh_draw_args_init(PBVH *pbvh, PBVH_GPU_Args *args, PBVHNode *node) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d5cfe4383e7] refactor-mesh-corners-generic: Merge branch 'master' into refactor-mesh-corners-generic
Commit: d5cfe4383e7868e454dc54a9dec70185d61c9848 Author: Hans Goudey Date: Sun Feb 5 17:44:29 2023 -0500 Branches: refactor-mesh-corners-generic https://developer.blender.org/rBd5cfe4383e7868e454dc54a9dec70185d61c9848 Merge branch 'master' into refactor-mesh-corners-generic === === diff --cc source/blender/blenkernel/intern/pbvh.cc index c2bdfec8094,1f3583a7f7e..ddfe4f52606 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@@ -811,12 -812,12 +813,12 @@@ static void pbvh_validate_node_prims(PB void BKE_pbvh_build_mesh(PBVH *pbvh, Mesh *mesh, const MPoly *mpoly, - const MLoop *mloop, + const int *corner_verts, float (*vert_positions)[3], int totvert, - struct CustomData *vdata, - struct CustomData *ldata, - struct CustomData *pdata, + CustomData *vdata, + CustomData *ldata, + CustomData *pdata, const MLoopTri *looptri, int looptri_num) { @@@ -826,11 -827,11 +828,11 @@@ pbvh->mesh = mesh; pbvh->header.type = PBVH_FACES; pbvh->mpoly = mpoly; - pbvh->hide_poly = (bool *)CustomData_get_layer_named_for_write( - >pdata, CD_PROP_BOOL, ".hide_poly", mesh->totpoly); - pbvh->material_indices = (const int *)CustomData_get_layer_named( - >pdata, CD_PROP_INT32, "material_index"); + pbvh->hide_poly = static_cast(CustomData_get_layer_named_for_write( + >pdata, CD_PROP_BOOL, ".hide_poly", mesh->totpoly)); + pbvh->material_indices = static_cast( + CustomData_get_layer_named(>pdata, CD_PROP_INT32, "material_index")); - pbvh->mloop = mloop; + pbvh->corner_verts = corner_verts; pbvh->looptri = looptri; pbvh->vert_positions = vert_positions; BKE_mesh_vertex_normals_ensure(mesh); diff --cc source/blender/blenkernel/intern/pbvh_intern.hh index 892a3abee32,d41eeb0b70b..7757275f6de --- a/source/blender/blenkernel/intern/pbvh_intern.hh +++ b/source/blender/blenkernel/intern/pbvh_intern.hh @@@ -8,24 -6,21 +6,20 @@@ * \ingroup bke */ - #ifdef __cplusplus - extern "C" { - #endif - + struct PBVHGPUFormat; -struct MLoop; struct MLoopTri; struct MPoly; + struct MeshElemMap; /* Axis-aligned bounding box */ - typedef struct { + struct BB { float bmin[3], bmax[3]; - } BB; + }; /* Axis-aligned bounding box with centroid */ - typedef struct { + struct BBC { float bmin[3], bmax[3], bcentroid[3]; - } BBC; - - struct MeshElemMap; + }; /* NOTE: this structure is getting large, might want to split it into * union'd structs */ @@@ -163,8 -161,8 +160,8 @@@ struct PBVH bool *hide_poly; /** Material indices. Only valid for polygon meshes. */ const int *material_indices; - const MLoop *mloop; + const int *corner_verts; - const struct MLoopTri *looptri; + const MLoopTri *looptri; CustomData *vdata; CustomData *ldata; CustomData *pdata; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [501352ef05c] master: Cleanup: Move PBVH files to C++
Commit: 501352ef05ca3ca262e0eaf3e1b0753376cf1d1a Author: Hans Goudey Date: Sun Feb 5 16:56:37 2023 -0500 Branches: master https://developer.blender.org/rB501352ef05ca3ca262e0eaf3e1b0753376cf1d1a Cleanup: Move PBVH files to C++ For continued refactoring of the Mesh data structure. See T103343. === M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/CMakeLists.txt R091source/blender/blenkernel/intern/pbvh.c source/blender/blenkernel/intern/pbvh.cc R092source/blender/blenkernel/intern/pbvh_bmesh.c source/blender/blenkernel/intern/pbvh_bmesh.cc M source/blender/blenkernel/intern/pbvh_colors.cc R091source/blender/blenkernel/intern/pbvh_intern.h source/blender/blenkernel/intern/pbvh_intern.hh M source/blender/blenkernel/intern/pbvh_pixels.cc === diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 7153f05c0c3..367dc9a3035 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -167,6 +167,7 @@ typedef enum { PBVH_TopologyUpdated = 1 << 17, /* Used internally by pbvh_bmesh.c */ } PBVHNodeFlags; +ENUM_OPERATORS(PBVHNodeFlags, PBVH_TopologyUpdated); typedef struct PBVHFrustumPlanes { float (*planes)[4]; diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c5d3f6eb3ab..850c55de7e9 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -248,9 +248,9 @@ set(SRC intern/particle_child.c intern/particle_distribute.c intern/particle_system.c - intern/pbvh.c + intern/pbvh.cc intern/pbvh_colors.cc - intern/pbvh_bmesh.c + intern/pbvh_bmesh.cc intern/pbvh_pixels.cc intern/pbvh_uv_islands.cc intern/pointcache.c @@ -505,7 +505,7 @@ set(SRC intern/multires_reshape.hh intern/multires_unsubdivide.h intern/ocean_intern.h - intern/pbvh_intern.h + intern/pbvh_intern.hh intern/pbvh_uv_islands.hh intern/subdiv_converter.h intern/subdiv_inline.h diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.cc similarity index 91% rename from source/blender/blenkernel/intern/pbvh.c rename to source/blender/blenkernel/intern/pbvh.cc index 6b21568ba38..1f3583a7f7e 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -6,13 +6,14 @@ #include "MEM_guardedalloc.h" -#include "BLI_utildefines.h" +#include #include "BLI_bitmap.h" #include "BLI_ghash.h" #include "BLI_math.h" #include "BLI_rand.h" #include "BLI_task.h" +#include "BLI_utildefines.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -33,9 +34,7 @@ #include "atomic_ops.h" -#include "pbvh_intern.h" - -#include +#include "pbvh_intern.hh" #define LEAF_LIMIT 1 @@ -50,12 +49,12 @@ //#define PERFCNTRS #define STACK_FIXED_DEPTH 100 -typedef struct PBVHStack { +struct PBVHStack { PBVHNode *node; bool revisiting; -} PBVHStack; +}; -typedef struct PBVHIter { +struct PBVHIter { PBVH *pbvh; BKE_pbvh_SearchCallback scb; void *search_data; @@ -65,7 +64,7 @@ typedef struct PBVHIter { PBVHStack stackfixed[STACK_FIXED_DEPTH]; int stackspace; -} PBVHIter; +}; void BB_reset(BB *bb) { @@ -273,7 +272,8 @@ void pbvh_grow_nodes(PBVH *pbvh, int totnode) if (pbvh->node_mem_count < totnode) { pbvh->node_mem_count = totnode; } -pbvh->nodes = MEM_recallocN(pbvh->nodes, sizeof(PBVHNode) * pbvh->node_mem_count); +pbvh->nodes = static_cast( +MEM_recallocN(pbvh->nodes, sizeof(PBVHNode) * pbvh->node_mem_count)); } pbvh->totnode = totnode; @@ -315,7 +315,8 @@ static void build_mesh_leaf_node(PBVH *pbvh, PBVHNode *node) /* reserve size is rough guess */ GHash *map = BLI_ghash_int_new_ex("build_mesh_leaf_node gh", 2 * totface); - int(*face_vert_indices)[3] = MEM_mallocN(sizeof(int[3]) * totface, "bvh node face vert indices"); + int(*face_vert_indices)[3] = static_cast( + MEM_mallocN(sizeof(int[3]) * totface, __func__)); node->face_vert_indices = (const int(*)[3])face_vert_indices; @@ -337,8 +338,8 @@ static void build_mesh_leaf_node(PBVH *pbvh, PBVHNode *node) } } - int *vert_indices = MEM_callocN(sizeof(int) * (node->uniq_verts + node->face_verts), - "bvh node vert indices"); + int *vert_indices = static_cast( + MEM_callocN(sizeof(int) * (node->uniq_verts + node->face_verts), __func__)); node->vert_indices = vert_indices; /* Build the vertex list, unique verts first */ @@ -368,7 +369,7 @@ static void build_mesh_leaf_node(PBVH *pbvh, PBVHNode *node) BKE_pbvh_node_fully_hidden_set(node, !has_visible); - BLI_ghash_free(map, NULL, NULL); + BLI_ghash_free(map, nullptr, nullptr); } static void
[Bf-blender-cvs] [a094f30a745] master: Fix T104363: BLI_assert 'attr->comp_len == 3' failed in cage 2d gizmo
Commit: a094f30a74524bef8db4d91ef056bd464e3bf7f5 Author: RiverIntheSky Date: Sun Feb 5 21:21:30 2023 +0100 Branches: master https://developer.blender.org/rBa094f30a74524bef8db4d91ef056bd464e3bf7f5 Fix T104363: BLI_assert 'attr->comp_len == 3' failed in cage 2d gizmo === M source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c === diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index b1bf1a7b542..55f7319b2f0 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -592,7 +592,7 @@ static void cage2d_draw_rect_handles(const rctf *r, static void cage2d_draw_central_handle(const float color[3], const float margin[2]) { - uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); const float rad[2] = {margin[0] * 0.25f, margin[1] * 0.25f}; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3d6ceb737d8] master: Geometry Nodes: parallelize part of Duplicate Elements node
Commit: 3d6ceb737d81361fb27edb017ede826692efa75c Author: Jacques Lucke Date: Sun Feb 5 20:59:39 2023 +0100 Branches: master https://developer.blender.org/rB3d6ceb737d81361fb27edb017ede826692efa75c Geometry Nodes: parallelize part of Duplicate Elements node This implements two optimizations: * If the duplication count is constant, the offsets array can be filled directly in parallel. * Otherwise, extracting the counts from the virtual array is parallelized. But there is still a serial loop over all elements in the end to compute the offsets. === M source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index 586b14ff29f..da4d3c7e641 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -81,8 +81,22 @@ static OffsetIndices accumulate_counts_to_offsets(const IndexMask selection Array _offset_data) { r_offset_data.reinitialize(selection.size() + 1); - counts.materialize_compressed(selection, r_offset_data); - offset_indices::accumulate_counts_to_offsets(r_offset_data); + if (counts.is_single()) { +const int count = counts.get_internal_single(); +threading::parallel_for(selection.index_range(), 1024, [&](const IndexRange range) { + for (const int64_t i : range) { +r_offset_data[i] = count * i; + } +}); +r_offset_data.last() = count * selection.size(); + } + else { +threading::parallel_for(selection.index_range(), 1024, [&](const IndexRange range) { + counts.materialize_compressed(selection.slice(range), + r_offset_data.as_mutable_span().slice(range)); +}); +offset_indices::accumulate_counts_to_offsets(r_offset_data); + } return OffsetIndices(r_offset_data); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [04accc6fd95] temp-angavrilov: Shape Key editing: propagate updates through basis chains.
Commit: 04accc6fd95d8a40d6522676670283765246eb65 Author: Alexander Gavrilov Date: Sun Feb 5 17:20:41 2023 +0200 Branches: temp-angavrilov https://developer.blender.org/rB04accc6fd95d8a40d6522676670283765246eb65 Shape Key editing: propagate updates through basis chains. It is possible to organize shape keys into a tree through the reference key setting. Mesh editing and sculpting a reference key is supposed to update all its children, but this was only done for one level of dependencies. === M source/blender/blenkernel/BKE_key.h M source/blender/blenkernel/intern/key.cc M source/blender/bmesh/intern/bmesh_mesh_convert.cc M source/blender/editors/curve/editcurve.c M source/blender/editors/sculpt_paint/sculpt.cc === diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 10c95253f38..5d6f5e3c201 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -185,6 +185,12 @@ bool BKE_keyblock_move(struct Object *ob, int org_index, int new_index); */ bool BKE_keyblock_is_basis(const struct Key *key, int index); +/** + * Returns an array containing true for every key that has this one as basis. + * If none are found, returns null. + */ +bool *BKE_keyblock_get_dependent_keys(const struct Key *key, int index); + /* */ /** \name Key-Block Data Access * \{ */ diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index b8ff350917e..b8d8442b93d 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -2592,3 +2592,50 @@ bool BKE_keyblock_is_basis(const Key *key, const int index) return false; } + +bool *BKE_keyblock_get_dependent_keys(const struct Key *key, int index) +{ + /* Simple checks. */ + if (key->type != KEY_RELATIVE) { +return nullptr; + } + + const int count = BLI_listbase_count(>block); + + if (index < 0 || index >= count) { +return nullptr; + } + + /* Seed the table with the specified key. */ + bool *marked = static_cast(MEM_callocN(sizeof(bool) * count, __func__)); + + marked[index] = true; + + /* Iterative breadth-first search through the key list. */ + int updated, total = 0; + + do { +const KeyBlock *kb; +int i; + +updated = 0; + +for (i = 0, kb = static_cast(key->block.first); kb; i++, kb = kb->next) { + if (!marked[i] && kb->relative >= 0 && kb->relative < count && marked[kb->relative]) { +marked[i] = true; +updated++; +total++; + } +} + } while (updated > 0); + + if (total == 0) { +MEM_freeN(marked); +return nullptr; + } + else { +/* After the search is complete, exclude the original key. */ +marked[index] = false; +return marked; + } +} diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index d58337400a2..55b6b37e7b1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -721,6 +721,7 @@ static void bm_to_mesh_shape(BMesh *bm, BMIter iter; BMVert *eve; float(*ofs)[3] = nullptr; + bool *dependent = nullptr; /* Editing the basis key updates others. */ if ((key->type == KEY_RELATIVE) && @@ -729,7 +730,7 @@ static void bm_to_mesh_shape(BMesh *bm, /* Original key-indices are only used to check the vertex existed when entering edit-mode. */ (cd_shape_keyindex_offset != -1) && /* Offsets are only needed if the current shape is a basis for others. */ - BKE_keyblock_is_basis(key, bm->shapenr - 1)) { + (dependent = BKE_keyblock_get_dependent_keys(key, bm->shapenr - 1)) != nullptr) { BLI_assert(actkey != nullptr); /* Assured by `actkey_has_layer` check. */ const int actkey_uuid = bm_to_mesh_shape_layer_index_from_kb(bm, actkey); @@ -755,6 +756,8 @@ static void bm_to_mesh_shape(BMesh *bm, * ones, creating a mess when doing e.g. subdivide + translate. */ MEM_freeN(ofs); ofs = nullptr; +MEM_freeN(dependent); +dependent = nullptr; break; } } @@ -781,7 +784,9 @@ static void bm_to_mesh_shape(BMesh *bm, } } - LISTBASE_FOREACH (KeyBlock *, currkey, >block) { + int currkey_i; + + LISTBASE_FOREACH_INDEX (KeyBlock *, currkey, >block, currkey_i) { int keyi; float(*currkey_data)[3]; @@ -792,8 +797,7 @@ static void bm_to_mesh_shape(BMesh *bm, /* Common case, the layer data is available, use it where possible. */ if (cd_shape_offset != -1) { - const bool apply_offset = (ofs != nullptr) && (currkey != actkey) && -(bm->shapenr - 1 == currkey->relative); + const bool apply_offset = (ofs !=
[Bf-blender-cvs] [a97607dcfa2] master: Cleanup: use typed enum for the handler flag in wm_event_system
Commit: a97607dcfa25149c70972ad868fbc1eee9f88b9a Author: Campbell Barton Date: Sun Feb 5 21:21:04 2023 +1100 Branches: master https://developer.blender.org/rBa97607dcfa25149c70972ad868fbc1eee9f88b9a Cleanup: use typed enum for the handler flag in wm_event_system === M source/blender/windowmanager/intern/wm_event_system.cc === diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 590b0c72b79..406ca7f16d4 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -99,13 +99,15 @@ /** * Return value of handler-operator call. */ -enum { - WM_HANDLER_CONTINUE = 0, +using eHandlerActionFlag = enum eHandlerActionFlag { WM_HANDLER_BREAK = 1 << 0, WM_HANDLER_HANDLED = 1 << 1, /** `WM_HANDLER_MODAL | WM_HANDLER_BREAK` means unhandled. */ WM_HANDLER_MODAL = 1 << 2, }; +ENUM_OPERATORS(eHandlerActionFlag, WM_HANDLER_MODAL); +/** Comparison, for readability. */ +#define WM_HANDLER_CONTINUE ((eHandlerActionFlag)0) static void wm_notifier_clear(wmNotifier *note); static bool wm_notifier_is_clear(const wmNotifier *note); @@ -740,7 +742,7 @@ static bool wm_event_always_pass(const wmEvent *event) */ BLI_INLINE void wm_event_handler_return_value_check(const bContext *C, const wmEvent *event, -const int action) +const eHandlerActionFlag action) { #ifndef NDEBUG if (C == nullptr || CTX_wm_window(C)) { @@ -757,10 +759,10 @@ BLI_INLINE void wm_event_handler_return_value_check(const bContext *C, /** \name UI Handling * \{ */ -static int wm_handler_ui_call(bContext *C, - wmEventHandler_UI *handler, - const wmEvent *event, - int always_pass) +static eHandlerActionFlag wm_handler_ui_call(bContext *C, + wmEventHandler_UI *handler, + const wmEvent *event, + int always_pass) { ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); @@ -789,7 +791,7 @@ static int wm_handler_ui_call(bContext *C, /* Don't block file-select events. Those are triggered by a separate file browser window. * See T75292. */ if (event->type == EVT_FILESELECT) { -return WM_UI_HANDLER_CONTINUE; +return WM_HANDLER_CONTINUE; } /* We set context to where UI handler came from. */ @@ -2405,12 +2407,12 @@ static void wm_event_modalkeymap_end(wmEvent *event, const wmEvent_ModalMapStore /** * \warning this function removes a modal handler, when finished. */ -static int wm_handler_operator_call(bContext *C, -ListBase *handlers, -wmEventHandler *handler_base, -wmEvent *event, -PointerRNA *properties, -const char *kmi_idname) +static eHandlerActionFlag wm_handler_operator_call(bContext *C, + ListBase *handlers, + wmEventHandler *handler_base, + wmEvent *event, + PointerRNA *properties, + const char *kmi_idname) { int retval = OPERATOR_PASS_THROUGH; @@ -2616,13 +2618,13 @@ static void wm_operator_free_for_fileselect(wmOperator *file_operator) * File-select handlers are only in the window queue, * so it's safe to switch screens or area types. */ -static int wm_handler_fileselect_do(bContext *C, -ListBase *handlers, -wmEventHandler_Op *handler, -int val) +static eHandlerActionFlag wm_handler_fileselect_do(bContext *C, + ListBase *handlers, + wmEventHandler_Op *handler, + int val) { wmWindowManager *wm = CTX_wm_manager(C); - int action = WM_HANDLER_CONTINUE; + eHandlerActionFlag action = WM_HANDLER_CONTINUE; switch (val) { case EVT_FILESELECT_FULL_OPEN: { @@ -2841,12 +2843,12 @@ static int wm_handler_fileselect_do(bContext *C, return action; } -static int wm_handler_fileselect_call(bContext *C, - ListBase *handlers, - wmEventHandler_Op *handler, -
[Bf-blender-cvs] [b7034e7280f] master: Cleanup: use boolean instead of int, use const arguments, variable
Commit: b7034e7280f510d3d50531c35917d74491db9c02 Author: Campbell Barton Date: Sun Feb 5 21:26:45 2023 +1100 Branches: master https://developer.blender.org/rBb7034e7280f510d3d50531c35917d74491db9c02 Cleanup: use boolean instead of int, use const arguments, variable === M source/blender/windowmanager/intern/wm_event_system.cc === diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 406ca7f16d4..bd8fa98cb6b 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -762,7 +762,7 @@ BLI_INLINE void wm_event_handler_return_value_check(const bContext *C, static eHandlerActionFlag wm_handler_ui_call(bContext *C, wmEventHandler_UI *handler, const wmEvent *event, - int always_pass) + const bool always_pass) { ScrArea *area = CTX_wm_area(C); ARegion *region = CTX_wm_region(C); @@ -783,7 +783,7 @@ static eHandlerActionFlag wm_handler_ui_call(bContext *C, if (is_wheel) { return WM_HANDLER_CONTINUE; } -if (wm_event_always_pass(event) == 0) { +if (!wm_event_always_pass(event)) { do_wheel_ui = true; } } @@ -1039,7 +1039,10 @@ void WM_operator_region_active_win_set(bContext *C) /** * \param caller_owns_reports: True when called from Python. */ -static void wm_operator_reports(bContext *C, wmOperator *op, int retval, bool caller_owns_reports) +static void wm_operator_reports(bContext *C, +wmOperator *op, +const int retval, +const bool caller_owns_reports) { if (G.background == 0 && caller_owns_reports == false) { /* Popup. */ if (op->reports->list.first) { @@ -3255,7 +3258,7 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C, } else if (handler_base->poll == nullptr || handler_base->poll(CTX_wm_region(C), event)) { /* In advance to avoid access to freed event on window close. */ - const int always_pass = wm_event_always_pass(event); + const bool always_pass = wm_event_always_pass(event); /* Modal+blocking handler_base. */ if (handler_base->flag & WM_HANDLER_BLOCKING) { @@ -4154,7 +4157,7 @@ void wm_event_do_handlers(bContext *C) /** \name File Selector Handling * \{ */ -void WM_event_fileselect_event(wmWindowManager *wm, void *ophandle, int eventval) +void WM_event_fileselect_event(wmWindowManager *wm, void *ophandle, const int eventval) { /* Add to all windows! */ LISTBASE_FOREACH (wmWindow *, win, >windows) { @@ -4301,7 +4304,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) #if 0 /* Lets not expose struct outside wm? */ -static void WM_event_set_handler_flag(wmEventHandler *handler, int flag) +static void WM_event_set_handler_flag(wmEventHandler *handler, const int flag) { handler->flag = flag; } @@ -5204,7 +5207,7 @@ static wmEvent *wm_event_add_trackpad(wmWindow *win, const wmEvent *event, int d { /* Ignore in between track-pad events for performance, we only need high accuracy * for painting with mouse moves, for navigation using the accumulated value is ok. */ - wmEvent *event_last = static_cast(win->event_queue.last); + const wmEvent *event_last = static_cast(win->event_queue.last); if (event_last && event_last->type == event->type) { deltax += event_last->xy[0] - event_last->prev_xy[0]; deltay += event_last->xy[1] - event_last->prev_xy[1]; @@ -5320,7 +5323,7 @@ static bool wm_event_is_ignorable_key_press(const wmWindow *win, const wmEvent & return wm_event_is_same_key_press(last_event, event); } -void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void *customdata) +void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, const int type, void *customdata) { if (UNLIKELY(G.f & G_FLAG_EVENT_SIMULATE)) { return; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f1314f3d5b4] master: Cleanup: make WM_HANDLER_* action flags local to wm_event_system
Commit: f1314f3d5b4bdc11fc4ce52f1585413d051533eb Author: Campbell Barton Date: Sun Feb 5 21:10:01 2023 +1100 Branches: master https://developer.blender.org/rBf1314f3d5b4bdc11fc4ce52f1585413d051533eb Cleanup: make WM_HANDLER_* action flags local to wm_event_system === M source/blender/editors/interface/interface_handlers.cc M source/blender/windowmanager/intern/wm_event_system.cc M source/blender/windowmanager/wm_event_system.h === diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index 36737b20f83..706d8c5b374 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -9449,10 +9449,10 @@ static int ui_list_handle_click_drag(bContext *C, const wmEvent *event) { if (event->type != LEFTMOUSE) { -return WM_HANDLER_CONTINUE; +return WM_UI_HANDLER_CONTINUE; } - int retval = WM_HANDLER_CONTINUE; + int retval = WM_UI_HANDLER_CONTINUE; const bool is_draggable = ui_list_is_hovering_draggable_but(C, ui_list, region, event); bool activate = false; diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 1bfcfa3da32..590b0c72b79 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -96,6 +96,17 @@ */ #define USE_GIZMO_MOUSE_PRIORITY_HACK +/** + * Return value of handler-operator call. + */ +enum { + WM_HANDLER_CONTINUE = 0, + WM_HANDLER_BREAK = 1 << 0, + WM_HANDLER_HANDLED = 1 << 1, + /** `WM_HANDLER_MODAL | WM_HANDLER_BREAK` means unhandled. */ + WM_HANDLER_MODAL = 1 << 2, +}; + static void wm_notifier_clear(wmNotifier *note); static bool wm_notifier_is_clear(const wmNotifier *note); diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index f49be20e174..9031b33f80d 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -7,12 +7,6 @@ #pragma once -/* return value of handler-operator call */ -#define WM_HANDLER_CONTINUE 0 -#define WM_HANDLER_BREAK 1 -#define WM_HANDLER_HANDLED 2 -#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */ - struct ARegion; struct GHOST_TabletData; struct ScrArea; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d6cd7d1138b] master: WM: correct the return flag from wm_handler_fileselect_do
Commit: d6cd7d1138bbddfe9a9d8e39295163023ac861a4 Author: Campbell Barton Date: Sun Feb 5 21:03:19 2023 +1100 Branches: master https://developer.blender.org/rBd6cd7d1138bbddfe9a9d8e39295163023ac861a4 WM: correct the return flag from wm_handler_fileselect_do In the unlikely case an area could not be created OPERATOR_CANCELLED was returned, this has the same value of WM_HANDLER_HANDLED however break is logical in this situation and both flags work. === M source/blender/windowmanager/intern/wm_event_system.cc === diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index c1ee3d522b6..1bfcfa3da32 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -2643,7 +2643,7 @@ static int wm_handler_fileselect_do(bContext *C, } else { BKE_report(>reports, RPT_ERROR, "Failed to open window!"); -return OPERATOR_CANCELLED; +return WM_HANDLER_BREAK; } action = WM_HANDLER_BREAK; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs