[Bf-blender-cvs] [e4f77c1a6c9] master: Cleanup: format
Commit: e4f77c1a6c980155c22304f827f348c0d29c1eb7 Author: Chris Blackbourn Date: Tue Feb 7 16:57:35 2023 +1300 Branches: master https://developer.blender.org/rBe4f77c1a6c980155c22304f827f348c0d29c1eb7 Cleanup: format === M source/blender/draw/intern/draw_manager_data.cc === diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 569fea083ef..de78c8216de 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -698,7 +698,7 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) drw_call_calc_orco(ob, ob_infos->orcotexfac); /* Random float value. */ uint random = (DST.dupli_source) ? -DST.dupli_source->random_id : + DST.dupli_source->random_id : /* TODO(fclem): this is rather costly to do at runtime. Maybe we can * put it in ob->runtime and make depsgraph ensure it is up to date. */ BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0); ___ 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] [cef03c867b0] master: UV: cleanup winding
Commit: cef03c867b050523bc374f28d3973ba0ca0038da Author: Chris Blackbourn Date: Sat Jan 28 10:50:59 2023 +1300 Branches: master https://developer.blender.org/rBcef03c867b050523bc374f28d3973ba0ca0038da UV: cleanup winding Simplify `BM_uv_element_map_create` by using `BM_face_calc_area_uv_signed`. Remove unused UV winding code in `BM_uv_vert_map_create`. Fixes unlikely memory leak in `BKE_mesh_uv_vert_map_create`. No functional changes. Differential Revision: https://developer.blender.org/D17137 === M source/blender/blenkernel/intern/mesh_mapping.cc M source/blender/editors/include/ED_mesh.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/uvedit/uvedit_select.c === diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc index 15bdf58849a..32c8638fbcf 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@ -47,7 +47,6 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, uint a; int i, totuv, nverts; - bool *winding = nullptr; BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, 32); totuv = 0; @@ -67,15 +66,17 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly, vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap"); buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * size_t(totuv), "UvMapVert"); vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*"); - if (use_winding) { -winding = static_cast(MEM_callocN(sizeof(*winding) * totpoly, "winding")); - } if (!vmap->vert || !vmap->buf) { BKE_mesh_uv_vert_map_free(vmap); return nullptr; } + bool *winding = nullptr; + if (use_winding) { +winding = static_cast(MEM_callocN(sizeof(*winding) * totpoly, "winding")); + } + mp = mpoly; for (a = 0; a < totpoly; a++, mp++) { if (!selected || (!(hide_poly && hide_poly[a]) && (select_poly && select_poly[a]))) { diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 8ab6e31bef3..70e553abb50 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -167,7 +167,7 @@ struct UvMapVert *BM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v /** * Return a new #UvVertMap from the edit-mesh. */ -struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm, bool use_select, bool use_winding); +struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm, bool use_select); void EDBM_flag_enable_all(struct BMEditMesh *em, char hflag); void EDBM_flag_disable_all(struct BMEditMesh *em, char hflag); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index c0815257afa..a2343bb297e 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -444,7 +444,7 @@ void EDBM_flag_enable_all(BMEditMesh *em, const char hflag) /** \name UV Vertex Map API * \{ */ -UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select, const bool use_winding) +UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select) { BMVert *ev; BMFace *efa; @@ -452,7 +452,6 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select, const bool us BMIter iter, liter; uint a; const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_PROP_FLOAT2); - BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE); @@ -478,11 +477,6 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select, const bool us vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totverts, "UvMapVert_pt"); UvMapVert *buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert"); - bool *winding = NULL; - if (use_winding) { -winding = MEM_callocN(sizeof(*winding) * totfaces, "winding"); - } - if (!vmap->vert || !vmap->buf) { BKE_mesh_uv_vert_map_free(vmap); return NULL; @@ -490,12 +484,6 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select, const bool us BM_ITER_MESH_INDEX (efa, , bm, BM_FACES_OF_MESH, a) { if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { - float(*tf_uv)[2] = NULL; - - if (use_winding) { -tf_uv = (float(*)[2])BLI_buffer_reinit_data(_uv_buf, vec2f, efa->len); - } - int i; BM_ITER_ELEM_INDEX (l, , efa, BM_LOOPS_OF_FACE, i) { buf->loop_of_poly_index = i; @@ -505,15 +493,6 @@ UvVertM
[Bf-blender-cvs] [2b4bafeac68] master: UV: add "similar object" and "similar winding" to uv "select similar"
Commit: 2b4bafeac68ea6fbb7b42760c9fc864d094d67f8 Author: Chris Blackbourn Date: Fri Jan 27 17:52:31 2023 +1300 Branches: master https://developer.blender.org/rB2b4bafeac68ea6fbb7b42760c9fc864d094d67f8 UV: add "similar object" and "similar winding" to uv "select similar" Adds new options to UV Face selection in the UV Editor, with UV > Select > Select Similar In multi object edit mode, "Similar Object" selects faces which have the same object. "Similar Winding" will select faces which have the same winding, i.e. are they facing upwards or downwards. Resolves: T103975 Differential Revision: https://developer.blender.org/D17125 === M source/blender/bmesh/intern/bmesh_polygon.c M source/blender/bmesh/intern/bmesh_polygon.h M source/blender/editors/uvedit/uvedit_select.c === diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index a2aecf80456..8b185b17a3a 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -225,20 +225,26 @@ float BM_face_calc_area_with_mat3(const BMFace *f, const float mat3[3][3]) return len_v3(n) * 0.5f; } -float BM_face_calc_area_uv(const BMFace *f, int cd_loop_uv_offset) +float BM_face_calc_area_uv_signed(const BMFace *f, int cd_loop_uv_offset) { /* inline 'area_poly_v2' logic, avoid creating a temp array */ const BMLoop *l_iter, *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(f); - /* The Trapezium Area Rule */ + /* Green's theorem applied to area of a polygon. + * TODO: `cross` should be of type `double` to reduce rounding error. */ float cross = 0.0f; do { const float *luv = BM_ELEM_CD_GET_FLOAT_P(l_iter, cd_loop_uv_offset); const float *luv_next = BM_ELEM_CD_GET_FLOAT_P(l_iter->next, cd_loop_uv_offset); cross += (luv_next[0] - luv[0]) * (luv_next[1] + luv[1]); } while ((l_iter = l_iter->next) != l_first); - return fabsf(cross * 0.5f); + return cross * 0.5f; +} + +float BM_face_calc_area_uv(const BMFace *f, int cd_loop_uv_offset) +{ + return fabsf(BM_face_calc_area_uv_signed(f, cd_loop_uv_offset)); } float BM_face_calc_perimeter(const BMFace *f) diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index 6262f185eca..bff1d1d587d 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -73,7 +73,12 @@ float BM_face_calc_area(const BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); float BM_face_calc_area_with_mat3(const BMFace *f, const float mat3[3][3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); /** - * get the area of UV face + * Calculate the signed area of UV face. + */ +float BM_face_calc_area_uv_signed(const BMFace *f, int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(); +/** + * Calculate the area of UV face. */ float BM_face_calc_area_uv(const BMFace *f, int cd_loop_uv_offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index 50185049fe1..99ee1ca0002 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -87,9 +87,11 @@ typedef enum { UV_SSIM_FACE, UV_SSIM_LENGTH_UV, UV_SSIM_LENGTH_3D, - UV_SSIM_SIDES, - UV_SSIM_PIN, UV_SSIM_MATERIAL, + UV_SSIM_OBJECT, + UV_SSIM_PIN, + UV_SSIM_SIDES, + UV_SSIM_WINDING, } eUVSelectSimilar; /* */ @@ -4633,6 +4635,7 @@ static float get_uv_edge_needle(const eUVSelectSimilar type, static float get_uv_face_needle(const eUVSelectSimilar type, BMFace *face, +int ob_index, const float ob_m3[3][3], const BMUVOffsets offsets) { @@ -4646,6 +4649,8 @@ static float get_uv_face_needle(const eUVSelectSimilar type, return BM_face_calc_area_with_mat3(face, ob_m3); case UV_SSIM_SIDES: return face->len; +case UV_SSIM_OBJECT: + return ob_index; case UV_SSIM_PIN: { BMLoop *l; BMIter liter; @@ -4657,6 +4662,8 @@ static float get_uv_face_needle(const eUVSelectSimilar type, } break; case UV_SSIM_MATERIAL: return face->mat_nr; +case UV_SSIM_WINDING: + return signum_i(BM_face_calc_area_uv_signed(face, offsets.uv)); default: BLI_assert_unreachable(); return false; @@ -4966,7 +4973,7 @@ static int uv_select_similar_face_exec(bContext *C, wmOperator *op) continue; } - float needle = get_uv_face_needle(type, face, ob_m3, offsets); + float needle = get_uv_f
[Bf-blender-cvs] [6c8db7c22ba] master: Fix T103868: render uv transform gizmo even if it has zero area
Commit: 6c8db7c22ba48c49df0de0ab655b79342d866281 Author: Chris Blackbourn Date: Fri Jan 27 17:05:15 2023 +1300 Branches: master https://developer.blender.org/rB6c8db7c22ba48c49df0de0ab655b79342d866281 Fix T103868: render uv transform gizmo even if it has zero area Change the 2D Gizmo drawing function to provide a usable transform matrix, if it would otherwise be degenerate. Differential Revision: https://developer.blender.org/D17113 === M source/blender/editors/transform/transform_gizmo_2d.c === diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index a6eb25975e9..b99a650c3c0 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -604,8 +604,11 @@ static void gizmo2d_xform_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) UI_view2d_view_to_region_m4(>v2d, ggd->cage->matrix_space); /* Define the bounding box of the gizmo in the offset transform matrix. */ unit_m4(ggd->cage->matrix_offset); - ggd->cage->matrix_offset[0][0] = (ggd->max[0] - ggd->min[0]); - ggd->cage->matrix_offset[1][1] = (ggd->max[1] - ggd->min[1]); + const float min_gizmo_pixel_size = 0.001f; /* Draw Gizmo larger than this many pixels. */ + const float min_scale_axis_x = min_gizmo_pixel_size / ggd->cage->matrix_space[0][0]; + const float min_scale_axis_y = min_gizmo_pixel_size / ggd->cage->matrix_space[1][1]; + ggd->cage->matrix_offset[0][0] = max_ff(min_scale_axis_x, ggd->max[0] - ggd->min[0]); + ggd->cage->matrix_offset[1][1] = max_ff(min_scale_axis_y, ggd->max[1] - ggd->min[1]); ScrArea *area = CTX_wm_area(C); ___ 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] [34a6591a073] master: Fix T98594: missing uv editor redraw with geometry nodes modifier
Commit: 34a6591a073f90620b6bcff458a407368b5dd02f Author: Chris Blackbourn Date: Fri Jan 27 16:38:12 2023 +1300 Branches: master https://developer.blender.org/rB34a6591a073f90620b6bcff458a407368b5dd02f Fix T98594: missing uv editor redraw with geometry nodes modifier If an object has a geometry nodes modifier, the UVs on that object might change in response to any change on any other object. Now we will redraw the UV editor on any object change, not just the active object. Differential Revision: https://developer.blender.org/D17124 === M source/blender/editors/space_image/space_image.c === diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 53e1bc0a1e5..fd8c161687e 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -405,7 +405,10 @@ static void image_listener(const wmSpaceTypeListenerParams *params) ViewLayer *view_layer = WM_window_get_active_view_layer(win); BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); - if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) { + /* \note With a geometry nodes modifier, the UVs on `ob` can change in response to + * any change on `wmn->reference`. If we could track the upstream dependencies, + * unnecessary redraws could be reduced. Until then, just redraw. See T98594. */ + if (ob && (ob->mode & OB_MODE_EDIT)) { if (sima->lock && (sima->flag & SI_DRAWSHADOW)) { ED_area_tag_refresh(area); ED_area_tag_redraw(area); ___ 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] [742c2e46bb1] master: Cleanup: format
Commit: 742c2e46bb1eee2d874b137e973658db57683f78 Author: Chris Blackbourn Date: Fri Jan 27 14:45:37 2023 +1300 Branches: master https://developer.blender.org/rB742c2e46bb1eee2d874b137e973658db57683f78 Cleanup: format === M source/blender/io/usd/intern/usd_reader_stage.cc === diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc index 3ee5e666d38..393d8acba4a 100644 --- a/source/blender/io/usd/intern/usd_reader_stage.cc +++ b/source/blender/io/usd/intern/usd_reader_stage.cc @@ -355,7 +355,8 @@ void USDStageReader::fake_users_for_unused_materials() { /* Iterate over the imported materials and set a fake user for any unused * materials. */ - for (const std::pair _mat_pair : settings_.usd_path_to_mat_name) { + for (const std::pair _mat_pair : + settings_.usd_path_to_mat_name) { std::map::iterator mat_it = settings_.mat_name_to_mat.find( path_mat_pair.second); ___ 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] [6672b5373f1] master: Fix T103971: uv packing wasn't ignoring uv islands on hidden faces
Commit: 6672b5373f172e32351ee4d233c8a434ff95417a Author: Chris Blackbourn Date: Fri Jan 20 13:18:38 2023 +1300 Branches: master https://developer.blender.org/rB6672b5373f172e32351ee4d233c8a434ff95417a Fix T103971: uv packing wasn't ignoring uv islands on hidden faces Fixes the packing operators that use ED_uvedit_pack_islands_multi Also fixes UV Select Similar with hidden UV islands. Packing operators using GEO_uv_parametrizer should remain unchanged. Add a check to BM_elem_flag_test(efa, BM_ELEM_HIDDEN). Note that BM_mesh_calc_face_groups doesn't easily support XOR of flags, requiring logic to be moved to a preprocess step on BM_ELEM_TAG. Regression in rBe3075f3cf7ce. Differential Revision: https://developer.blender.org/D17055 === M source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index ad4527affb8..2d1db757fb5 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -335,6 +335,35 @@ static bool bm_loop_uv_shared_edge_check(const BMLoop *l_a, const BMLoop *l_b, v return BM_loop_uv_share_edge_check((BMLoop *)l_a, (BMLoop *)l_b, data->offsets.uv); } +/** + * returns true if `BMFace *efa` is able to be affected by a packing operation, given various + * parameters. + * + * Checks if it's (not) hidden, and optionally selected, and/or UV selected. + * + * Will eventually be superseded by `BM_uv_element_map_create()`. + * + * Loosely based on`uvedit_is_face_affected`, but "bug-compatible" with previous code. + */ +static bool uvedit_is_face_affected_for_calc_uv_islands(const Scene *scene, +BMFace *efa, +const bool only_selected_faces, +const bool only_selected_uvs, +const BMUVOffsets _offsets) +{ + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { +return false; + } + if (only_selected_faces) { +if (only_selected_uvs) { + return BM_elem_flag_test(efa, BM_ELEM_SELECT) && + uvedit_face_select_test(scene, efa, uv_offsets); +} +return BM_elem_flag_test(efa, BM_ELEM_SELECT); + } + return true; +} + /** * Calculate islands and add them to \a island_list returning the number of items added. */ @@ -356,25 +385,13 @@ int bm_mesh_calc_uv_islands(const Scene *scene, int(*group_index)[2]; - /* Calculate the tag to use. */ - uchar hflag_face_test = 0; - if (only_selected_faces) { -if (only_selected_uvs) { - BMFace *f; - BMIter iter; - BM_ITER_MESH (f, , bm, BM_FACES_OF_MESH) { -bool value = false; -if (BM_elem_flag_test(f, BM_ELEM_SELECT) && -uvedit_face_select_test(scene, f, uv_offsets)) { - value = true; -} -BM_elem_flag_set(f, BM_ELEM_TAG, value); - } - hflag_face_test = BM_ELEM_TAG; -} -else { - hflag_face_test = BM_ELEM_SELECT; -} + /* Set the tag for `BM_mesh_calc_face_groups`. */ + BMFace *f; + BMIter iter; + BM_ITER_MESH (f, , bm, BM_FACES_OF_MESH) { +const bool face_affected = uvedit_is_face_affected_for_calc_uv_islands( +scene, f, only_selected_faces, only_selected_uvs, uv_offsets); +BM_elem_flag_set(f, BM_ELEM_TAG, face_affected); } struct SharedUVLoopData user_data = {{0}}; @@ -387,7 +404,7 @@ int bm_mesh_calc_uv_islands(const Scene *scene, nullptr, bm_loop_uv_shared_edge_check, _data, - hflag_face_test, + BM_ELEM_TAG, BM_EDGE); for (int i = 0; i < group_len; i++) { ___ 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] [bbeb37696d2] master: Cleanup: format
Commit: bbeb37696d21e6c3461d7ae75dd4db932ce2dc6d Author: Chris Blackbourn Date: Fri Jan 20 11:43:28 2023 +1300 Branches: master https://developer.blender.org/rBbbeb37696d21e6c3461d7ae75dd4db932ce2dc6d Cleanup: format === M release/scripts/startup/bl_operators/wm.py M source/blender/draw/intern/DRW_gpu_wrapper.hh M source/blender/geometry/intern/fillet_curves.cc === diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index cb881ad024e..e82694249fd 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1588,7 +1588,7 @@ class WM_OT_properties_edit(Operator): self.default_string = rna_data["default"] elif self.property_type in {'BOOL', 'BOOL_ARRAY'}: self.default_bool = self._convert_new_value_array(rna_data["default"], bool, 32) - + if self.property_type in {'FLOAT_ARRAY', 'INT_ARRAY', 'BOOL_ARRAY'}: self.array_length = len(item[name]) diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 3e53f1510f6..0bb005dd160 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -1012,7 +1012,8 @@ class TextureRef : public Texture { * Dummy type to bind texture as image. * It is just a GPUTexture in disguise. */ -class Image {}; +class Image { +}; static inline Image *as_image(GPUTexture *tex) { diff --git a/source/blender/geometry/intern/fillet_curves.cc b/source/blender/geometry/intern/fillet_curves.cc index f666a6b6b40..0107eafba9d 100644 --- a/source/blender/geometry/intern/fillet_curves.cc +++ b/source/blender/geometry/intern/fillet_curves.cc @@ -39,7 +39,8 @@ static void duplicate_fillet_point_data(const bke::CurvesGeometry _curves, for (const int curve_i : curve_selection.slice(range)) { const IndexRange src_points = src_points_by_curve[curve_i]; const IndexRange dst_points = dst_points_by_curve[curve_i]; - const IndexRange offsets_range = bke::curves::per_curve_point_offsets_range(src_points, curve_i); + const IndexRange offsets_range = bke::curves::per_curve_point_offsets_range(src_points, + curve_i); const OffsetIndices offsets(all_point_offsets.slice(offsets_range)); threaded_slice_fill(src.slice(src_points), offsets, dst.slice(dst_points)); } @@ -75,7 +76,8 @@ static void calculate_result_offsets(const bke::CurvesGeometry _curves, threading::parallel_for(selection.index_range(), 512, [&](IndexRange range) { for (const int curve_i : selection.slice(range)) { const IndexRange src_points = points_by_curve[curve_i]; - const IndexRange offsets_range = bke::curves::per_curve_point_offsets_range(src_points, curve_i); + const IndexRange offsets_range = bke::curves::per_curve_point_offsets_range(src_points, + curve_i); MutableSpan point_offsets = dst_point_offsets.slice(offsets_range); MutableSpan point_counts = point_offsets.drop_back(1); @@ -456,7 +458,8 @@ static bke::CurvesGeometry fillet_curves( for (const int curve_i : curve_selection.slice(range)) { const IndexRange src_points = src_points_by_curve[curve_i]; - const IndexRange offsets_range = bke::curves::per_curve_point_offsets_range(src_points, curve_i); + const IndexRange offsets_range = bke::curves::per_curve_point_offsets_range(src_points, + curve_i); const OffsetIndices offsets(all_point_offsets.slice(offsets_range)); const IndexRange dst_points = dst_points_by_curve[curve_i]; const Span src_positions = positions.slice(src_points); ___ 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] [6769acbbba7] master: BLI_math: simplify matrix multiply logic
Commit: 6769acbbba7f0beb50dafcae3f49de9caee55787 Author: Chris Blackbourn Date: Tue Jan 17 11:14:52 2023 +1300 Branches: master https://developer.blender.org/rB6769acbbba7f0beb50dafcae3f49de9caee55787 BLI_math: simplify matrix multiply logic Improve safety and correctness of matrix multiplication by using temporary storage if one of the inputs is also the output. No functional changes. Differential Revision: https://developer.blender.org/D16876 Reviewed By: Campbell Barton, Sergey Sharybin === M source/blender/blenlib/BLI_math_matrix.h M source/blender/blenlib/intern/math_matrix.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc M source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c === diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 538474f58b6..1278bc90e44 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -83,16 +83,12 @@ void mul_m3_m4m4(float R[3][3], const float A[4][4], const float B[4][4]); /** * Special matrix multiplies - * - uniq: `R <-- AB`, R is neither A nor B * - pre: `R <-- AR` * - post: `R <-- RB`. */ -void mul_m3_m3m3_uniq(float R[3][3], const float A[3][3], const float B[3][3]); void mul_m3_m3_pre(float R[3][3], const float A[3][3]); void mul_m3_m3_post(float R[3][3], const float B[3][3]); -void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4]); -void mul_m4_m4m4_db_uniq(double R[4][4], const double A[4][4], const double B[4][4]); -void mul_m4db_m4db_m4fl_uniq(double R[4][4], const double A[4][4], const float B[4][4]); +void mul_m4db_m4db_m4fl(double R[4][4], const double A[4][4], const float B[4][4]); void mul_m4_m4_pre(float R[4][4], const float A[4][4]); void mul_m4_m4_post(float R[4][4], const float B[4][4]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index d997eae26fb..7322a9facec 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -257,22 +257,14 @@ void shuffle_m4(float R[4][4], const int index[4]) void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4]) { - if (A == R) { -mul_m4_m4_post(R, B); - } - else if (B == R) { -mul_m4_m4_pre(R, A); - } - else { -mul_m4_m4m4_uniq(R, A, B); + if (R == A || R == B) { +float T[4][4]; +mul_m4_m4m4(T, A, B); +copy_m4_m4(R, T); +return; } -} - -void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4]) -{ - BLI_assert(!ELEM(R, A, B)); - /* Matrix product: `R[j][k] = A[j][i] . B[i][k]`. */ + /* Matrix product: `R[j][k] = B[j][i] . A[i][k]`. */ #ifdef BLI_HAVE_SSE2 __m128 A0 = _mm_loadu_ps(A[0]); __m128 A1 = _mm_loadu_ps(A[1]); @@ -313,39 +305,16 @@ void mul_m4_m4m4_uniq(float R[4][4], const float A[4][4], const float B[4][4]) #endif } -void mul_m4_m4m4_db_uniq(double R[4][4], const double A[4][4], const double B[4][4]) +void mul_m4db_m4db_m4fl(double R[4][4], const double A[4][4], const float B[4][4]) { - BLI_assert(!ELEM(R, A, B)); - - /* Matrix product: `R[j][k] = A[j][i] . B[i][k]`. */ - - R[0][0] = B[0][0] * A[0][0] + B[0][1] * A[1][0] + B[0][2] * A[2][0] + B[0][3] * A[3][0]; - R[0][1] = B[0][0] * A[0][1] + B[0][1] * A[1][1] + B[0][2] * A[2][1] + B[0][3] * A[3][1]; - R[0][2] = B[0][0] * A[0][2] + B[0][1] * A[1][2] + B[0][2] * A[2][2] + B[0][3] * A[3][2]; - R[0][3] = B[0][0] * A[0][3] + B[0][1] * A[1][3] + B[0][2] * A[2][3] + B[0][3] * A[3][3]; - - R[1][0] = B[1][0] * A[0][0] + B[1][1] * A[1][0] + B[1][2] * A[2][0] + B[1][3] * A[3][0]; - R[1][1] = B[1][0] * A[0][1] + B[1][1] * A[1][1] + B[1][2] * A[2][1] + B[1][3] * A[3][1]; - R[1][2] = B[1][0] * A[0][2] + B[1][1] * A[1][2] + B[1][2] * A[2][2] + B[1][3] * A[3][2]; - R[1][3] = B[1][0] * A[0][3] + B[1][1] * A[1][3] + B[1][2] * A[2][3] + B[1][3] * A[3][3]; - - R[2][0] = B[2][0] * A[0][0] + B[2][1] * A[1][0] + B[2][2] * A[2][0] + B[2][3] * A[3][0]; - R[2][1] = B[2][0] * A[0][1] + B[2][1] * A[1][1] + B[2][2] * A[2][1] + B[2][3] * A[3][1]; - R[2][2] = B[2][0] * A[0][2] + B[2][1] * A[1][2] + B[2][2] * A[2][2] + B[2][3] * A[3][2]; - R[2][3] = B[2][0] * A[0][3] + B[2][1] * A[1][3] + B[2][2] * A[2][3] + B[2][3] * A[3][3]; - - R[3][0] = B[3][0] * A[0][0] + B[3][1] * A[1][0] + B[3][2] * A[2][0] + B[3][3] * A[3][0]; - R[3][1] = B[3][0] * A[0][1] + B[3][1] * A[1][1] + B[3][2] * A[2][1] + B[3][3] * A[3][1]; - R[3][2] = B[3][0] * A[0][2] + B[3][1] * A[1][2] + B[3][2] * A[2][2] + B[3][3] * A[3][2]; - R[3][3] = B[3][0] * A[0][3] + B[3][1] * A[1][3] + B[3][2] * A[2][3] + B[3][3] * A[3][3]; -} - -void mul_m4db_m4db_m4fl_uniq(double R[4][4], const double A[4][4], const float B[4][4]) -{ - /* Remove second check si
[Bf-blender-cvs] [4160da187c9] master: Fix T103670: correct seam calculation when finding unique uvs
Commit: 4160da187c9ed003354c08d3be2a4cbd504cd973 Author: Chris Blackbourn Date: Sat Jan 14 10:46:19 2023 +1300 Branches: master https://developer.blender.org/rB4160da187c9ed003354c08d3be2a4cbd504cd973 Fix T103670: correct seam calculation when finding unique uvs Fixes bugs where UV islands with `mark seam` would tear at boundaries. Modify seam_connected to search both it's edges instead of only one, as this could fail if the edge was a seam or did not fan to the other loop. Also fixes bug in `seam_connected_recursive`: - `loop->prev == needle` changed to `loop == needle` Maniphest Tasks: T103787 Reviewed By: Campbell Barton Differential Revision: https://developer.blender.org/D16992 Test File: F14145477, F14137755, T79304 === M source/blender/editors/mesh/editmesh_utils.c === diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 99aa256b3d0..21fb223e1de 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -927,7 +927,7 @@ static bool seam_connected_recursive(BMEdge *edge, continue; /* `loop` is disjoint in UV space. */ } - if (loop->prev == needle) { + if (loop == needle) { return true; /* Success. */ } @@ -971,9 +971,17 @@ static bool seam_connected(BMLoop *loop_a, BMLoop *loop_b, GSet *visited, int cd BLI_gset_clear(visited, NULL); const float *luv_anchor = BM_ELEM_CD_GET_FLOAT_P(loop_a, cd_loop_uv_offset); - const float *luv_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->next, cd_loop_uv_offset); - const bool result = seam_connected_recursive( - loop_a->e, luv_anchor, luv_fan, loop_b, visited, cd_loop_uv_offset); + const float *luv_next_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->next, cd_loop_uv_offset); + bool result = seam_connected_recursive( + loop_a->e, luv_anchor, luv_next_fan, loop_b, visited, cd_loop_uv_offset); + if (!result) { +/* Search around `loop_a` in the opposite direction, as one of the edges may be delimited by + * a boundary, seam or disjoint UV, or itself be one of these. See: T103670, T103787. */ +float *luv_prev_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->prev, cd_loop_uv_offset); +result = seam_connected_recursive( +loop_a->prev->e, luv_anchor, luv_prev_fan, loop_b, visited, cd_loop_uv_offset); + } + return result; } ___ 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] [326e1eeb569] master: UV: cleanup
Commit: 326e1eeb569f0281d9e0169da09fca402cabe2d0 Author: Chris Blackbourn Date: Sat Jan 14 11:21:31 2023 +1300 Branches: master https://developer.blender.org/rB326e1eeb569f0281d9e0169da09fca402cabe2d0 UV: cleanup Cleanup ahead of D16992 Changes in `seam_connected_recursive`: - Remove redundant `anchor` parameter. - Improve const correctness No functional changes. === M source/blender/editors/mesh/editmesh_utils.c === diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 3f1981b1e75..99aa256b3d0 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -899,18 +899,17 @@ static bool loop_uv_match(BMLoop *loop, compare_v2v2(luv_b, luv_d, STD_UV_CONNECT_LIMIT); } -/* Given `anchor` and `edge`, return true if there are edges that fan between them that are +/* Given `luv_anchor` and `needle`, return true if there are edges that fan between them that are * seam-free. */ -static bool seam_connected_recursive(BMVert *anchor, - BMEdge *edge, - float luv_anchor[2], - float luv_fan[2], +static bool seam_connected_recursive(BMEdge *edge, + const float luv_anchor[2], + const float luv_fan[2], BMLoop *needle, GSet *visited, int cd_loop_uv_offset) { + BMVert *anchor = needle->v; BLI_assert(edge->v1 == anchor || edge->v2 == anchor); - BLI_assert(needle->v == anchor || needle->next->v == anchor); if (BM_elem_flag_test(edge, BM_ELEM_SEAM)) { return false; /* Edge is a seam, don't traverse. */ @@ -934,7 +933,7 @@ static bool seam_connected_recursive(BMVert *anchor, float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->prev, cd_loop_uv_offset); if (seam_connected_recursive( - anchor, loop->prev->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { + loop->prev->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { return true; } } @@ -950,7 +949,7 @@ static bool seam_connected_recursive(BMVert *anchor, float *luv_far = BM_ELEM_CD_GET_FLOAT_P(loop->next->next, cd_loop_uv_offset); if (seam_connected_recursive( - anchor, loop->next->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { + loop->next->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { return true; } } @@ -971,10 +970,10 @@ static bool seam_connected(BMLoop *loop_a, BMLoop *loop_b, GSet *visited, int cd BLI_gset_clear(visited, NULL); - float *luv_anchor = BM_ELEM_CD_GET_FLOAT_P(loop_a, cd_loop_uv_offset); - float *luv_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->next, cd_loop_uv_offset); + const float *luv_anchor = BM_ELEM_CD_GET_FLOAT_P(loop_a, cd_loop_uv_offset); + const float *luv_fan = BM_ELEM_CD_GET_FLOAT_P(loop_a->next, cd_loop_uv_offset); const bool result = seam_connected_recursive( - loop_a->v, loop_a->e, luv_anchor, luv_fan, loop_b, visited, cd_loop_uv_offset); + loop_a->e, luv_anchor, luv_fan, loop_b, visited, cd_loop_uv_offset); return result; } ___ 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] [b55b671955f] master: Cleanup: format
Commit: b55b671955f29f4856d182067c534c06fa1497de Author: Chris Blackbourn Date: Sat Jan 14 10:38:53 2023 +1300 Branches: master https://developer.blender.org/rBb55b671955f29f4856d182067c534c06fa1497de Cleanup: format === M source/blender/io/alembic/exporter/abc_writer_mesh.cc M source/blender/io/usd/intern/usd_writer_mesh.cc M source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc === diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc index fb7cef96cc5..77d42d905c7 100644 --- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc +++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc @@ -537,7 +537,8 @@ static void get_loop_normals(struct Mesh *mesh, } BKE_mesh_calc_normals_split(mesh); - const float(*lnors)[3] = static_cast(CustomData_get_layer(>ldata, CD_NORMAL)); + const float(*lnors)[3] = static_cast( + CustomData_get_layer(>ldata, CD_NORMAL)); BLI_assert_msg(lnors != nullptr, "BKE_mesh_calc_normals_split() should have computed CD_NORMAL"); normals.resize(mesh->totloop); diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 3d08f9ac2a9..9551fea75fb 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -400,7 +400,8 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext , void USDGenericMeshWriter::write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh) { pxr::UsdTimeCode timecode = get_export_time_code(); - const float(*lnors)[3] = static_cast(CustomData_get_layer(>ldata, CD_NORMAL)); + const float(*lnors)[3] = static_cast( + CustomData_get_layer(>ldata, CD_NORMAL)); const Span polys = mesh->polys(); const Span loops = mesh->loops(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc index 75b9d0e49cd..65f88f23aff 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc @@ -190,7 +190,8 @@ void register_node_type_geo_evaluate_at_index() static bNodeType ntype; - geo_node_type_base(, GEO_NODE_EVALUATE_AT_INDEX, "Evaluate at Index", NODE_CLASS_CONVERTER); + geo_node_type_base( + , GEO_NODE_EVALUATE_AT_INDEX, "Evaluate at Index", NODE_CLASS_CONVERTER); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_layout; ___ 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] [280502e630e] master: Fix T103469: improve uv cylinder projection and uv sphere projection
Commit: 280502e630e99a6723861a9cae156fabd53a7eb1 Author: Chris Blackbourn Date: Fri Jan 6 17:10:28 2023 +1300 Branches: master https://developer.blender.org/rB280502e630e99a6723861a9cae156fabd53a7eb1 Fix T103469: improve uv cylinder projection and uv sphere projection Multiple improvements to UV Cylinder and UV Sphere projection including: * New option "Pinch" or "Fan" to improve unwrap of faces at the poles. * Support for "Polar ZY" option on "View On Equator" and "Align To Object" * Better handling of inputs with round-off error. * Improved handling of faces touching the unit square border. * Improved handling of very wide quads spanning the right hand border. * Improved accuracy near to (0, 0). * Code cleanup and simplification. Differential Revision: https://developer.blender.org/D16869 === M source/blender/blenlib/BLI_math_geom.h M source/blender/blenlib/intern/math_geom.c M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index d056c42e019..e24f3c3bde8 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -1164,8 +1164,8 @@ void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], floa /** \name Mapping * \{ */ -void map_to_tube(float *r_u, float *r_v, float x, float y, float z); -void map_to_sphere(float *r_u, float *r_v, float x, float y, float z); +bool map_to_tube(float *r_u, float *r_v, float x, float y, float z); +bool map_to_sphere(float *r_u, float *r_v, float x, float y, float z); void map_to_plane_v2_v3v3(float r_co[2], const float co[3], const float no[3]); void map_to_plane_axis_angle_v2_v3v3fl(float r_co[2], const float co[3], diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 08152976f7d..415e21cd272 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -4914,39 +4914,59 @@ void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], floa /** Mapping **/ -void map_to_tube(float *r_u, float *r_v, const float x, const float y, const float z) +static float snap_coordinate(float u) { - float len; - - *r_v = (z + 1.0f) / 2.0f; + /* Adjust a coordinate value `u` to obtain a value inside the (closed) unit interval. + * i.e. 0.0 <= snap_coordinate(u) <= 1.0. + * Due to round-off errors, it is possible that the value of `u` may be close to the boundary of + * the unit interval, but not exactly on it. In order to handle these cases, `snap_coordinate` + * checks whether `u` is within `epsilon` of the boundary, and if so, it snaps the return value + * to the boundary. */ + if (u < 0.0f) { +u += 1.0f; /* Get back into the unit interval. */ + } + BLI_assert(0.0f <= u); + BLI_assert(u <= 1.0f); + const float epsilon = 0.25f / 65536.0f; /* i.e. Quarter of a texel on a 65536 x 65536 texture. */ + if (u < epsilon) { +return 0.0f; /* `u` is close to 0, just return 0. */ + } + if (1.0f - epsilon < u) { +return 1.0f; /* `u` is close to 1, just return 1. */ + } + return u; +} - len = sqrtf(x * x + y * y); - if (len > 0.0f) { -*r_u = (1.0f - (atan2f(x / len, y / len) / (float)M_PI)) / 2.0f; +bool map_to_tube(float *r_u, float *r_v, const float x, const float y, const float z) +{ + bool regular = true; + if (x * x + y * y < 1e-6f * 1e-6f) { +regular = false; /* We're too close to the cylinder's axis. */ +*r_u = 0.5f; } else { -*r_v = *r_u = 0.0f; /* to avoid un-initialized variables */ +/* The "Regular" case, just compute the coordinate. */ +*r_u = snap_coordinate(atan2f(x, -y) / (float)(2.0f * M_PI)); } + *r_v = (z + 1.0f) / 2.0f; + return regular; } -void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z) +bool map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z) { - float len; - - len = sqrtf(x * x + y * y + z * z); - if (len > 0.0f) { -if (UNLIKELY(x == 0.0f && y == 0.0f)) { - *r_u = 0.0f; /* Otherwise domain error. */ -} -else { - *r_u = (1.0f - atan2f(x, y) / (float)M_PI) / 2.0f; -} - -*r_v = 1.0f - saacos(z / len) / (float)M_PI; + bool regular = true; + const float epsilon = 0.25f / 65536.0f; /* i.e. Quarter of a texel on a 65536 x 65536 texture. */ + const float len_xy = sqrtf(x * x + y * y); + if (len_xy <= fabsf(z) * epsilon) { +regular = false; /* We're on the line that runs through the north and south poles. */ +*r_u = 0.5f; } else { -
[Bf-blender-cvs] [496d736adca] master: Cleanup: format
Commit: 496d736adca5f38c589370246c1c2fe4c69243f6 Author: Chris Blackbourn Date: Thu Jan 5 11:21:51 2023 +1300 Branches: master https://developer.blender.org/rB496d736adca5f38c589370246c1c2fe4c69243f6 Cleanup: format === M intern/cycles/device/metal/kernel.mm === diff --git a/intern/cycles/device/metal/kernel.mm b/intern/cycles/device/metal/kernel.mm index 97ac47dbdb8..ec2025e78fe 100644 --- a/intern/cycles/device/metal/kernel.mm +++ b/intern/cycles/device/metal/kernel.mm @@ -313,17 +313,15 @@ void ShaderCache::load_kernel(DeviceKernel device_kernel, pipeline->threads_per_threadgroup = device->max_threads_per_threadgroup; if (occupancy_tuning[device_kernel].threads_per_threadgroup) { -pipeline->threads_per_threadgroup = -occupancy_tuning[device_kernel].threads_per_threadgroup; -pipeline->num_threads_per_block = -occupancy_tuning[device_kernel].num_threads_per_block; +pipeline->threads_per_threadgroup = occupancy_tuning[device_kernel].threads_per_threadgroup; +pipeline->num_threads_per_block = occupancy_tuning[device_kernel].num_threads_per_block; } /* metalrt options */ pipeline->use_metalrt = device->use_metalrt; pipeline->metalrt_features = device->use_metalrt ? - (device->kernel_features & METALRT_FEATURE_MASK) : - 0; + (device->kernel_features & METALRT_FEATURE_MASK) : + 0; { thread_scoped_lock lock(cache_mutex); @@ -742,8 +740,7 @@ void MetalKernelPipeline::compile() if (!num_threads_per_block) { num_threads_per_block = round_down(pipeline.maxTotalThreadsPerThreadgroup, pipeline.threadExecutionWidth); -num_threads_per_block = std::max(num_threads_per_block, - (int)pipeline.threadExecutionWidth); +num_threads_per_block = std::max(num_threads_per_block, (int)pipeline.threadExecutionWidth); } if (@available(macOS 11.0, *)) { ___ 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] [4924f8cffd4] master: Cleanup: format
Commit: 4924f8cffd4522f46161258ff33cf036a5a11eae Author: Chris Blackbourn Date: Mon Jan 2 11:53:40 2023 +1300 Branches: master https://developer.blender.org/rB4924f8cffd4522f46161258ff33cf036a5a11eae Cleanup: format === M source/blender/blenkernel/intern/node.cc M source/blender/blenloader/intern/versioning_common.h M source/blender/editors/space_node/drawnode.cc === diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 3cd0cf2f7ca..69d2b2a12e6 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -3558,8 +3558,6 @@ void nodeSetActive(bNodeTree *ntree, bNode *node) node->flag |= flags_to_set; } - - void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, bool is_available) { const bool was_available = (sock->flag & SOCK_UNAVAIL) == 0; diff --git a/source/blender/blenloader/intern/versioning_common.h b/source/blender/blenloader/intern/versioning_common.h index c99fb60be30..40f383a27b2 100644 --- a/source/blender/blenloader/intern/versioning_common.h +++ b/source/blender/blenloader/intern/versioning_common.h @@ -88,8 +88,8 @@ struct bNodeSocket *version_node_add_socket_if_not_exist(struct bNodeTree *ntree const char *name); /** - * The versioning code generally expects `SOCK_IS_LINKED` to be set correctly. This function updates - * the flag on all sockets after changes to the node tree. + * The versioning code generally expects `SOCK_IS_LINKED` to be set correctly. This function + * updates the flag on all sockets after changes to the node tree. */ void version_socket_update_is_used(bNodeTree *ntree); ARegion *do_versions_add_region(int regiontype, const char *name); diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index efe7c2e91b6..7c2e7c003a3 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1293,7 +1293,8 @@ static void std_node_socket_draw( return; } - if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IS_LINKED) || (sock->flag & SOCK_HIDE_VALUE)) { + if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IS_LINKED) || + (sock->flag & SOCK_HIDE_VALUE)) { node_socket_button_label(C, layout, ptr, node_ptr, text); 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] [8c194e1ba6a] master: Cleanup: format
Commit: 8c194e1ba6aefa0cffafcc7edccb47f8ba8589c0 Author: Chris Blackbourn Date: Thu Dec 29 20:49:08 2022 +1300 Branches: master https://developer.blender.org/rB8c194e1ba6aefa0cffafcc7edccb47f8ba8589c0 Cleanup: format === M source/blender/blenkernel/BKE_image_partial_update.hh M source/blender/editors/mesh/editmesh_mask_extract.c M source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c M source/blender/gpu/intern/gpu_codegen.cc M source/blender/modifiers/intern/MOD_util.cc M source/blender/nodes/intern/node_socket.cc M source/blender/nodes/texture/node_texture_util.cc M tests/python/bl_blendfile_io.py M tests/python/modifiers.py === diff --git a/source/blender/blenkernel/BKE_image_partial_update.hh b/source/blender/blenkernel/BKE_image_partial_update.hh index 6c7776c091c..8f962ace268 100644 --- a/source/blender/blenkernel/BKE_image_partial_update.hh +++ b/source/blender/blenkernel/BKE_image_partial_update.hh @@ -29,7 +29,6 @@ struct PartialUpdateUser; namespace blender::bke::image { - namespace partial_update { /* --- image_partial_update.cc --- */ diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c index bb4d745a677..9988bdcb367 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.c +++ b/source/blender/editors/mesh/editmesh_mask_extract.c @@ -293,7 +293,7 @@ static int paint_mask_extract_exec(bContext *C, wmOperator *op) * Note: A second push happens after the operator due to * the OPTYPE_UNDO flag; having an initial undo step here * is just needed to preserve the active object pointer. - * + * * Fixes T103261. */ ED_undo_push_op(C, op); diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c index 7ac1ecb3796..26352f8ed54 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c @@ -588,7 +588,7 @@ static void lineart_shadow_edge_cut(LineartData *ld, new_seg_2->ratio = end; } - double r_fb_co_1[4]={0}, r_fb_co_2[4]={0}, r_gloc_1[3]={0}, r_gloc_2[3]={0}; + double r_fb_co_1[4] = {0}, r_fb_co_2[4] = {0}, r_gloc_1[3] = {0}, r_gloc_2[3] = {0}; double r_new_in_the_middle[4], r_new_in_the_middle_global[3], r_new_at; double *s1_fb_co_1, *s1_fb_co_2, *s1_gloc_1, *s1_gloc_2; diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index c4c0e403af1..465a621e864 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -211,7 +211,8 @@ static std::ostream <<(std::ostream , const GPUOutput *output) } /* Trick type to change overload and keep a somewhat nice syntax. */ -struct GPUConstant : public GPUInput {}; +struct GPUConstant : public GPUInput { +}; /* Print data constructor (i.e: vec2(1.0f, 1.0f)). */ static std::ostream <<(std::ostream , const GPUConstant *input) diff --git a/source/blender/modifiers/intern/MOD_util.cc b/source/blender/modifiers/intern/MOD_util.cc index 6b7072db121..844e2d19a58 100644 --- a/source/blender/modifiers/intern/MOD_util.cc +++ b/source/blender/modifiers/intern/MOD_util.cc @@ -40,7 +40,6 @@ #include "MEM_guardedalloc.h" - void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx) { Tex *tex = dmd->texture; diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index e179740aafb..8f2c36152c5 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -482,7 +482,6 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from) to->flag |= (from->flag & SOCK_HIDE_VALUE); } - static void standard_node_socket_interface_init_socket(bNodeTree * /*ntree*/, const bNodeSocket *interface_socket, bNode * /*node*/, diff --git a/source/blender/nodes/texture/node_texture_util.cc b/source/blender/nodes/texture/node_texture_util.cc index 2c2f14d0316..46d8417bfce 100644 --- a/source/blender/nodes/texture/node_texture_util.cc +++ b/source/blender/nodes/texture/node_texture_util.cc @@ -23,7 +23,9 @@ #include "node_texture_util.hh" -bool tex_node_poll_default(const bNodeType * /*ntype*/, const bNodeTree *ntree, const char **r_disabled_hint) +bool tex_node_poll_default(const bNodeType * /*ntype*/, + const bNodeTree *ntree, + const char **r_disabled_hint) { if (!STREQ(ntree->idname, "TextureNodeTree")) { *
[Bf-blender-cvs] [0403d77a0f4] geometry-nodes-simulation: Fix T103237: Prevent UV Unwrap from packing hidden UV islands
Commit: 0403d77a0f4495f555df4e10fd454a4fea1580ae Author: Chris Blackbourn Date: Fri Dec 16 16:20:11 2022 +1300 Branches: geometry-nodes-simulation https://developer.blender.org/rB0403d77a0f4495f555df4e10fd454a4fea1580ae Fix T103237: Prevent UV Unwrap from packing hidden UV islands When migrating to the new packing API, pin_unselected was not implemented correctly. Regression from rB143e74c0b8eb, rBe3075f3cf7ce, rB0ce18561bc82. Differential Revision: https://developer.blender.org/D16788 Reviewed By: Campbell Barton Duplicated in blender-v3.4-release as rB3dcd9992676a === M source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index efba43b7ffd..893fd22a405 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -618,13 +618,21 @@ static BoxPack *pack_islands_params(const blender::Vector _ return box_array; } -static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected) +static bool island_has_pins(const Scene *scene, +FaceIsland *island, +const UVPackIsland_Params *params) { + const bool pin_unselected = params->pin_unselected; + const bool only_selected_faces = params->only_selected_faces; BMLoop *l; BMIter iter; const int cd_loop_uv_offset = island->cd_loop_uv_offset; for (int i = 0; i < island->faces_len; i++) { -BM_ITER_ELEM (l, , island->faces[i], BM_LOOPS_OF_FACE) { +BMFace *efa = island->faces[i]; +if (pin_unselected && only_selected_faces && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { + return true; +} +BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset)); if (luv->flag & MLOOPUV_PINNED) { return true; @@ -697,7 +705,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Remove from linked list and append to blender::Vector. */ LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, _list) { BLI_remlink(_list, island); - if (params->ignore_pinned && island_has_pins(scene, island, params->pin_unselected)) { + if (params->ignore_pinned && island_has_pins(scene, island, params)) { MEM_freeN(island->faces); MEM_freeN(island); continue; ___ 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] [a12614d1668] geometry-nodes-simulation: Fix T102923: replace zero check with epsilons with uv constrain to bounds
Commit: a12614d16682b25771e45595a9067386f7d37172 Author: Chris Blackbourn Date: Fri Dec 16 17:22:41 2022 +1300 Branches: geometry-nodes-simulation https://developer.blender.org/rBa12614d16682b25771e45595a9067386f7d37172 Fix T102923: replace zero check with epsilons with uv constrain to bounds Small roundoff errors during UV editing can sometimes occur, most likely due to so-called "catastrophic cancellation". Here we set a tolerance around zero when using Constrain-To-Bounds and UV Scaling. The tolerance is set at one quarter of a texel, on a 65536 x 65536 texture. TODO: If this fix holds, we should formalize the tolerance into the UV editing subsystem, perhaps as a helper function, and investigate where else it needs to be applied. Differential Revision: https://developer.blender.org/D16702 === M source/blender/editors/transform/transform_mode_resize.c === diff --git a/source/blender/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c index 70599c3577c..4e671768721 100644 --- a/source/blender/editors/transform/transform_mode_resize.c +++ b/source/blender/editors/transform/transform_mode_resize.c @@ -95,9 +95,14 @@ static void constrain_scale_to_boundary(const float numerator, const float denominator, float *scale) { - if (denominator == 0.0f) { -/* The origin of the scale is on the edge of the boundary. */ -if (numerator < 0.0f) { + /* It's possible the numerator or denominator can be very close to zero due to so-called + * "catastrophic cancellation". See T102923 for an example. We use epsilon tests here to + * distinguish between genuine negative coordinates versus coordinates that should be rounded off + * to zero. */ + const float epsilon = 0.25f / 65536.0f; /* i.e. Quarter of a texel on a 65536 x 65536 texture. */ + if (fabsf(denominator) < epsilon) { +/* The origin of the scale is very near the edge of the boundary. */ +if (numerator < -epsilon) { /* Negative scale will wrap around and put us outside the boundary. */ *scale = 0.0f; /* Hold at the boundary instead. */ } ___ 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] [fe7a0ebce4c] geometry-nodes-simulation: Cleanup: format
Commit: fe7a0ebce4c5b2e13dc0bf33eb254b1ca29ea74f Author: Chris Blackbourn Date: Fri Dec 16 16:55:16 2022 +1300 Branches: geometry-nodes-simulation https://developer.blender.org/rBfe7a0ebce4c5b2e13dc0bf33eb254b1ca29ea74f Cleanup: format === M source/blender/blenkernel/intern/mesh_convert.cc === diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index db4d6396c92..8354de20e20 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -1104,7 +1104,6 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain, return mesh_in_bmain; } - static KeyBlock *keyblock_ensure_from_uid(Key , const int uid, const StringRefNull name) { if (KeyBlock *kb = BKE_keyblock_find_uid(, uid)) { ___ 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] [0079460dc79] master: Fix T102923: replace zero check with epsilons with uv constrain to bounds
Commit: 0079460dc79a6c4798ec41e86550d8f0882ed313 Author: Chris Blackbourn Date: Fri Dec 16 17:22:41 2022 +1300 Branches: master https://developer.blender.org/rB0079460dc79a6c4798ec41e86550d8f0882ed313 Fix T102923: replace zero check with epsilons with uv constrain to bounds Small roundoff errors during UV editing can sometimes occur, most likely due to so-called "catastrophic cancellation". Here we set a tolerance around zero when using Constrain-To-Bounds and UV Scaling. The tolerance is set at one quarter of a texel, on a 65536 x 65536 texture. TODO: If this fix holds, we should formalize the tolerance into the UV editing subsystem, perhaps as a helper function, and investigate where else it needs to be applied. Differential Revision: https://developer.blender.org/D16702 === M source/blender/editors/transform/transform_mode_resize.c === diff --git a/source/blender/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c index 70599c3577c..4e671768721 100644 --- a/source/blender/editors/transform/transform_mode_resize.c +++ b/source/blender/editors/transform/transform_mode_resize.c @@ -95,9 +95,14 @@ static void constrain_scale_to_boundary(const float numerator, const float denominator, float *scale) { - if (denominator == 0.0f) { -/* The origin of the scale is on the edge of the boundary. */ -if (numerator < 0.0f) { + /* It's possible the numerator or denominator can be very close to zero due to so-called + * "catastrophic cancellation". See T102923 for an example. We use epsilon tests here to + * distinguish between genuine negative coordinates versus coordinates that should be rounded off + * to zero. */ + const float epsilon = 0.25f / 65536.0f; /* i.e. Quarter of a texel on a 65536 x 65536 texture. */ + if (fabsf(denominator) < epsilon) { +/* The origin of the scale is very near the edge of the boundary. */ +if (numerator < -epsilon) { /* Negative scale will wrap around and put us outside the boundary. */ *scale = 0.0f; /* Hold at the boundary instead. */ } ___ 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] [a6c30e1a0c6] master: Fix T103237: Prevent UV Unwrap from packing hidden UV islands
Commit: a6c30e1a0c62041c02f03270a15334d6de22db5e Author: Chris Blackbourn Date: Fri Dec 16 16:20:11 2022 +1300 Branches: master https://developer.blender.org/rBa6c30e1a0c62041c02f03270a15334d6de22db5e Fix T103237: Prevent UV Unwrap from packing hidden UV islands When migrating to the new packing API, pin_unselected was not implemented correctly. Regression from rB143e74c0b8eb, rBe3075f3cf7ce, rB0ce18561bc82. Differential Revision: https://developer.blender.org/D16788 Reviewed By: Campbell Barton Duplicated in blender-v3.4-release as rB3dcd9992676a === M source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index efba43b7ffd..893fd22a405 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -618,13 +618,21 @@ static BoxPack *pack_islands_params(const blender::Vector _ return box_array; } -static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected) +static bool island_has_pins(const Scene *scene, +FaceIsland *island, +const UVPackIsland_Params *params) { + const bool pin_unselected = params->pin_unselected; + const bool only_selected_faces = params->only_selected_faces; BMLoop *l; BMIter iter; const int cd_loop_uv_offset = island->cd_loop_uv_offset; for (int i = 0; i < island->faces_len; i++) { -BM_ITER_ELEM (l, , island->faces[i], BM_LOOPS_OF_FACE) { +BMFace *efa = island->faces[i]; +if (pin_unselected && only_selected_faces && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { + return true; +} +BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset)); if (luv->flag & MLOOPUV_PINNED) { return true; @@ -697,7 +705,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Remove from linked list and append to blender::Vector. */ LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, _list) { BLI_remlink(_list, island); - if (params->ignore_pinned && island_has_pins(scene, island, params->pin_unselected)) { + if (params->ignore_pinned && island_has_pins(scene, island, params)) { MEM_freeN(island->faces); MEM_freeN(island); continue; ___ 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] [75c2e811039] master: Cleanup: format
Commit: 75c2e8110395e0082fec365d80337ffe2fcef64e Author: Chris Blackbourn Date: Fri Dec 16 16:55:16 2022 +1300 Branches: master https://developer.blender.org/rB75c2e8110395e0082fec365d80337ffe2fcef64e Cleanup: format === M source/blender/blenkernel/intern/mesh_convert.cc === diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index db4d6396c92..8354de20e20 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -1104,7 +1104,6 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain, return mesh_in_bmain; } - static KeyBlock *keyblock_ensure_from_uid(Key , const int uid, const StringRefNull name) { if (KeyBlock *kb = BKE_keyblock_find_uid(, uid)) { ___ 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] [3dcd9992676] blender-v3.4-release: Fix T103237: Prevent UV Unwrap from packing hidden UV islands
Commit: 3dcd9992676aba2ff7d15872a9f355fdfb626566 Author: Chris Blackbourn Date: Fri Dec 16 16:20:11 2022 +1300 Branches: blender-v3.4-release https://developer.blender.org/rB3dcd9992676aba2ff7d15872a9f355fdfb626566 Fix T103237: Prevent UV Unwrap from packing hidden UV islands When migrating to the new packing API, pin_unselected was not implemented correctly. Regression from rB143e74c0b8eb, rBe3075f3cf7ce, rB0ce18561bc82. Differential Revision: https://developer.blender.org/D16788 Reviewed By: Campbell Barton === M source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 27a951779c0..457e70eef67 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -600,13 +600,21 @@ static BoxPack *pack_islands_params(const blender::Vector _ return box_array; } -static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected) +static bool island_has_pins(const Scene *scene, +FaceIsland *island, +const UVPackIsland_Params *params) { + const bool pin_unselected = params->pin_unselected; + const bool only_selected_faces = params->only_selected_faces; BMLoop *l; BMIter iter; const int cd_loop_uv_offset = island->cd_loop_uv_offset; for (int i = 0; i < island->faces_len; i++) { -BM_ITER_ELEM (l, , island->faces[i], BM_LOOPS_OF_FACE) { +BMFace *efa = island->faces[i]; +if (pin_unselected && only_selected_faces && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { + return true; +} +BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset)); if (luv->flag & MLOOPUV_PINNED) { return true; @@ -679,7 +687,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Remove from linked list and append to blender::Vector. */ LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, _list) { BLI_remlink(_list, island); - if (params->ignore_pinned && island_has_pins(scene, island, params->pin_unselected)) { + if (params->ignore_pinned && island_has_pins(scene, island, params)) { MEM_freeN(island->faces); MEM_freeN(island); continue; ___ 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] [34e99240861] blender-v2.93-release: Fix T100926: Show UV outline in texture paint mode
Commit: 34e99240861ade6e03511cb7550f88de3271ff05 Author: Chris Blackbourn Date: Wed Nov 16 11:13:45 2022 +1300 Branches: blender-v2.93-release https://developer.blender.org/rB34e99240861ade6e03511cb7550f88de3271ff05 Fix T100926: Show UV outline in texture paint mode After rB716ea1547989 the UV overlay is no longer displayed in the UV Editor. It only appears for the Image Editor. So restore the previous behavior, displaying the "UV shadow" overlay in the UV editor as well. Reviewed By: Jeroen Bakker, Germano Cavalcante Maniphest Tasks: T92614, T100926 Differential Revision: https://developer.blender.org/D16490 === M source/blender/draw/engines/overlay/overlay_edit_uv.c === diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c index 9c58a2b574f..db07a5494ec 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.c +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c @@ -145,6 +145,8 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) ((is_paint_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) || + (is_uv_editor && do_tex_paint_shadows && + ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (is_view_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (do_uv_overlay && (show_modified_uvs))); ___ 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] [0e90896cba3] master: Cleanup: simplify udim parameters when uv packing
Commit: 0e90896cba3750a34f2fca9c0bf26d92be307883 Author: Chris Blackbourn Date: Wed Dec 7 15:26:06 2022 +1300 Branches: master https://developer.blender.org/rB0e90896cba3750a34f2fca9c0bf26d92be307883 Cleanup: simplify udim parameters when uv packing Migrate (some) of the UDIM offset calculation from inside one of the packing engines (where it's consumed) to the packing operator (where it's produced). This change (and others) will help simplify the future migration of the packing engine inside editors/uvedit/uvedit_islands.cc to the Geometry module, so it can eventually replace the other packing engine in geometry/intern/uv_parametrizer.cc === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 4a7081baa38..20c4b3f5700 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -332,12 +332,7 @@ struct UVMapUDIM_Params { const struct Image *image; /** Copied from #SpaceImage.tile_grid_shape */ int grid_shape[2]; - bool use_target_udim; - int target_udim; }; -bool ED_uvedit_udim_params_from_image_space(const struct SpaceImage *sima, -bool use_active, -struct UVMapUDIM_Params *udim_params); typedef enum { ED_UVPACK_MARGIN_SCALED = 0, /* Use scale of existing UVs to multiply margin. */ @@ -356,6 +351,7 @@ struct UVPackIsland_Params { bool pin_unselected; /* Treat unselected UVs as if they were pinned. */ eUVPackIsland_MarginMethod margin_method; /* Which formula to use when scaling island margin. */ float margin; /* Additional space to add around each island. */ + float udim_base_offset[2];/* Additional translation for bottom left corner. */ }; /** @@ -382,7 +378,7 @@ void ED_uvedit_pack_islands_multi(const struct Scene *scene, Object **objects, uint objects_len, struct BMesh **bmesh_override, - const struct UVMapUDIM_Params *udim_params, + const struct UVMapUDIM_Params *closest_udim, const struct UVPackIsland_Params *params); #ifdef __cplusplus diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 61fd1c53b95..7bce94a4d90 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -647,7 +647,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, Object **objects, const uint objects_len, BMesh **bmesh_override, - const struct UVMapUDIM_Params *udim_params, + const struct UVMapUDIM_Params *closest_udim, const struct UVPackIsland_Params *params) { blender::Vector island_vector; @@ -716,19 +716,12 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, for (int index = 0; index < island_vector.size(); index++) { FaceIsland *island = island_vector[index]; -/* Skip calculation if using specified UDIM option. */ -if (udim_params && (udim_params->use_target_udim == false)) { - float bounds_min[2], bounds_max[2]; - INIT_MINMAX2(bounds_min, bounds_max); +if (closest_udim) { + /* Only calculate selection bounding box if using closest_udim. */ for (int i = 0; i < island->faces_len; i++) { BMFace *f = island->faces[i]; -BM_face_uv_minmax(f, bounds_min, bounds_max, island->cd_loop_uv_offset); +BM_face_uv_minmax(f, selection_min_co, selection_max_co, island->cd_loop_uv_offset); } - - selection_min_co[0] = MIN2(bounds_min[0], selection_min_co[0]); - selection_min_co[1] = MIN2(bounds_min[1], selection_min_co[1]); - selection_max_co[0] = MAX2(bounds_max[0], selection_max_co[0]); - selection_max_co[1] = MAX2(bounds_max[1], selection_max_co[1]); } if (params->rotate) { @@ -741,7 +734,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Center of bounding box containing all selected UVs. */ float selection_center[2]; - if (udim_params && (udim_params->use_target_udim == false)) { + if (closest_udim) { selection_center[0] = (selection_min_co[0] + selection_max_co[0]) / 2.0f; selection_center[1] = (selection_min_co[1] + s
[Bf-blender-cvs] [f450d39ada1] master: Fix T84078: improve UV unwrapping for quads with an internal reflex angle
Commit: f450d39ada1f8629f2050288f413eceb2d173005 Author: Chris Blackbourn Date: Tue Dec 6 13:48:23 2022 +1300 Branches: master https://developer.blender.org/rBf450d39ada1f8629f2050288f413eceb2d173005 Fix T84078: improve UV unwrapping for quads with an internal reflex angle When triangulating meshes, the UV unwrapper was previously using a heuristic to split quads into triangles. If one of the internal angles is greater than 180degrees, a so-called "reflex angle", the heuristic was giving a poor choice of split. Instead of using a special case for quads, this change routes everything through the generic n-gon `BLI_polyfill_beautify` method instead. Reviewed By: Brecht Van Lommel Differential Revision: https://developer.blender.org/D16505 === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 5a363b4bf17..4236872f057 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -1124,16 +1124,6 @@ static PFace *p_face_add_fill(ParamHandle *handle, PChart *chart, PVert *v1, PVe return f; } -static bool p_quad_split_direction(ParamHandle *handle, const float **co, const ParamKey *vkeys) -{ - /* Slight bias to prefer one edge over the other in case they are equal, so - * that in symmetric models we choose the same split direction instead of - * depending on floating point errors to decide. */ - float bias = 1.0f + 1e-6f; - float fac = len_v3v3(co[0], co[2]) * bias - len_v3v3(co[1], co[3]); - return fac <= 0.0f; -} - /* Construction: boundary filling */ static void p_chart_boundaries(PChart *chart, PEdge **r_outer) @@ -3946,21 +3936,10 @@ void GEO_uv_parametrizer_face_add(ParamHandle *phandle, } /* No "ears" have previously been inserted. Continue as normal. */ } - if (nverts > 4) { + if (nverts > 3) { /* ngon */ p_add_ngon(phandle, key, nverts, vkeys, co, uv, pin, select); } - else if (nverts == 4) { -/* quad */ -if (p_quad_split_direction(phandle, co, vkeys)) { - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select); - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 2, 3, pin, select); -} -else { - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 3, pin, select); - p_face_add_construct(phandle, key, vkeys, co, uv, 1, 2, 3, pin, select); -} - } else if (!p_face_exists(phandle, vkeys, 0, 1, 2)) { /* triangle */ p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select); ___ 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] [644afda7eb6] master: Fix T102543: improve uv unwrapping with n-gons and shared vertices
Commit: 644afda7eb6c58d4ca745b3a16870569913ae0f9 Author: Chris Blackbourn Date: Tue Dec 6 13:39:02 2022 +1300 Branches: master https://developer.blender.org/rB644afda7eb6c58d4ca745b3a16870569913ae0f9 Fix T102543: improve uv unwrapping with n-gons and shared vertices When n-gons share vertices, their triangulation can be non-manifold, even if the original mesh is manifold. The UV Unwrapper does not currently work with non-manifold meshes. This workaround attempts to modify the triangulation of n-gons in the UV unwrapper to preserve the manifold property. This change replaces the previous fix for quads, and extends it to all n-gons. See T84078 as motivation for this change. Differential Revision: https://developer.blender.org/D16521 === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 15b0962d39e..5a363b4bf17 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_array.hh" #include "BLI_boxpack_2d.h" #include "BLI_convexhull_2d.h" #include "BLI_ghash.h" @@ -16,6 +17,7 @@ #include "BLI_polyfill_2d.h" #include "BLI_polyfill_2d_beautify.h" #include "BLI_rand.h" +#include "BLI_vector.hh" #include "eigen_capi.h" @@ -1129,23 +1131,7 @@ static bool p_quad_split_direction(ParamHandle *handle, const float **co, const * depending on floating point errors to decide. */ float bias = 1.0f + 1e-6f; float fac = len_v3v3(co[0], co[2]) * bias - len_v3v3(co[1], co[3]); - bool dir = (fac <= 0.0f); - - /* The face exists check is there because of a special case: - * when two quads share three vertices, they can each be split into two triangles, - * resulting in two identical triangles. For example in Suzanne's nose. */ - if (dir) { -if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3)) { - return !dir; -} - } - else { -if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3)) { - return !dir; -} - } - - return dir; + return fac <= 0.0f; } /* Construction: boundary filling */ @@ -3895,6 +3881,71 @@ void GEO_uv_parametrizer_face_add(ParamHandle *phandle, BLI_assert(nverts >= 3); param_assert(phandle->state == PHANDLE_STATE_ALLOCATED); + if (nverts > 3) { +/* Protect against (manifold) geometry which has a non-manifold triangulation. + * See T102543. */ + +blender::Vector permute; +permute.reserve(nverts); +for (int i = 0; i < nverts; i++) { + permute.append_unchecked(i); +} + +int i = nverts - 1; +while (i >= 0) { + /* Just check the "ears" of the n-gon. + * For quads, this is sufficient. + * For pents and higher, we might miss internal duplicate triangles, but note + * that such cases are rare if the source geometry is manifold and non-intersecting. */ + int pm = permute.size(); + BLI_assert(pm > 3); + int i0 = permute[i]; + int i1 = permute[(i + 1) % pm]; + int i2 = permute[(i + 2) % pm]; + if (!p_face_exists(phandle, vkeys, i0, i1, i2)) { +i--; /* ...All good...*/ +continue; + } + + /* An existing triangle has already been inserted. As a heuristic, attempt to add the + * *previous* triangle. \note: Should probably call `GEO_uv_parametrizer_face_add` instead of + * `p_face_add_construct`. */ + int iprev = permute[(i + pm - 1) % pm]; + p_face_add_construct(phandle, key, vkeys, co, uv, iprev, i0, i1, pin, select); + + permute.remove(i); + if (permute.size() == 3) { +break; + } +} +if (permute.size() != nverts) { + int pm = permute.size(); + /* Add the remaining pm-gon. */ + blender::Array vkeys_sub(pm); + blender::Array co_sub(pm); + blender::Array uv_sub(pm); + blender::Array pin_sub(pm); + blender::Array select_sub(pm); + for (int i = 0; i < pm; i++) { +int j = permute[i]; +vkeys_sub[i] = vkeys[j]; +co_sub[i] = co[j]; +uv_sub[i] = uv[j]; +pin_sub[i] = pin && pin[j]; +select_sub[i] = select && select[j]; + } + p_add_ngon(phandle, + key, + pm, + _sub.first(), + _sub.first(), + _sub.first(), + _sub.first(), + _sub.first()); + return; /* Nothing more to do. */ +} +/* No "ears" have previously been inserted. Continue as normal. */ + } if (nverts >
[Bf-blender-cvs] [9719fd69648] master: Cleanup: format
Commit: 9719fd6964883210b8c13a48fe0571330a5c63e8 Author: Chris Blackbourn Date: Sat Dec 3 10:53:44 2022 +1300 Branches: master https://developer.blender.org/rB9719fd6964883210b8c13a48fe0571330a5c63e8 Cleanup: format === M source/blender/gpu/vulkan/vk_pixel_buffer.cc === diff --git a/source/blender/gpu/vulkan/vk_pixel_buffer.cc b/source/blender/gpu/vulkan/vk_pixel_buffer.cc index 65780778d59..177f19d8acd 100644 --- a/source/blender/gpu/vulkan/vk_pixel_buffer.cc +++ b/source/blender/gpu/vulkan/vk_pixel_buffer.cc @@ -9,7 +9,7 @@ namespace blender::gpu { -VKPixelBuffer::VKPixelBuffer(int64_t size): PixelBuffer(size) +VKPixelBuffer::VKPixelBuffer(int64_t size) : PixelBuffer(size) { } ___ 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] [8842a8c4c3b] master: Cleanup: format
Commit: 8842a8c4c3b1ed175c4987657e6b26683a7f9eef Author: Chris Blackbourn Date: Fri Dec 2 10:14:50 2022 +1300 Branches: master https://developer.blender.org/rB8842a8c4c3b1ed175c4987657e6b26683a7f9eef Cleanup: format === M source/blender/blenkernel/intern/scene.cc === diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 830122474e1..f86292c1471 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -761,8 +761,7 @@ static void scene_foreach_layer_collection(LibraryForeachIDData *data, ListBase (lc->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ? IDWALK_CB_EMBEDDED : IDWALK_CB_NOP; -BKE_LIB_FOREACHID_PROCESS_IDSUPER( -data, lc->collection, cb_flag | IDWALK_CB_DIRECT_WEAK_LINK); +BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, lc->collection, cb_flag | IDWALK_CB_DIRECT_WEAK_LINK); scene_foreach_layer_collection(data, >layer_collections); } } @@ -835,11 +834,10 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data) BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, view_layer->mat_override, IDWALK_CB_USER); BKE_view_layer_synced_ensure(scene, view_layer); LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, -base->object, -IDWALK_CB_NOP | - IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE | -IDWALK_CB_DIRECT_WEAK_LINK); + BKE_LIB_FOREACHID_PROCESS_IDSUPER( + data, + base->object, + IDWALK_CB_NOP | IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE | IDWALK_CB_DIRECT_WEAK_LINK); } BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL( ___ 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] [ae081b2de1d] master: Cleanup: reduce variable scope in uv parametrizer
Commit: ae081b2de1d44603fb5322dcacbfc6e6e0118b99 Author: Chris Blackbourn Date: Wed Nov 30 12:01:40 2022 +1300 Branches: master https://developer.blender.org/rBae081b2de1d44603fb5322dcacbfc6e6e0118b99 Cleanup: reduce variable scope in uv parametrizer Also improve const correctness and update comments. Simplify future fix for T78101 === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index e7217fc4106..15b0962d39e 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -3087,29 +3087,21 @@ static void p_chart_lscm_begin(PChart *chart, bool live, bool abf) static bool p_chart_lscm_solve(ParamHandle *handle, PChart *chart) { LinearSolver *context = chart->u.lscm.context; - PVert *v, *pin1 = chart->u.lscm.pin1, *pin2 = chart->u.lscm.pin2; - PFace *f; - const float *alpha = chart->u.lscm.abf_alpha; - float area_pinned_up, area_pinned_down; - bool flip_faces; - int row; - -#if 0 - /* TODO: make loading pins work for simplify/complexify. */ -#endif - for (v = chart->verts; v; v = v->nextlink) { + for (PVert *v = chart->verts; v; v = v->nextlink) { if (v->flag & PVERT_PIN) { - p_vert_load_pin_select_uvs(handle, v); /* reload for live */ + p_vert_load_pin_select_uvs(handle, v); /* Reload for Live Unwrap. */ } } if (chart->u.lscm.single_pin) { -/* If only one pin, save area and pin for transform later. */ +/* If only one pin, save pin location for transform later. */ copy_v2_v2(chart->u.lscm.single_pin_uv, chart->u.lscm.single_pin->uv); } if (chart->u.lscm.pin1) { +PVert *pin1 = chart->u.lscm.pin1; +PVert *pin2 = chart->u.lscm.pin2; EIG_linear_solver_variable_lock(context, 2 * pin1->u.id); EIG_linear_solver_variable_lock(context, 2 * pin1->u.id + 1); EIG_linear_solver_variable_lock(context, 2 * pin2->u.id); @@ -3121,8 +3113,8 @@ static bool p_chart_lscm_solve(ParamHandle *handle, PChart *chart) EIG_linear_solver_variable_set(context, 0, 2 * pin2->u.id + 1, pin2->uv[1]); } else { -/* set and lock the pins */ -for (v = chart->verts; v; v = v->nextlink) { +/* Set and lock the pins. */ +for (PVert *v = chart->verts; v; v = v->nextlink) { if (v->flag & PVERT_PIN) { EIG_linear_solver_variable_lock(context, 2 * v->u.id); EIG_linear_solver_variable_lock(context, 2 * v->u.id + 1); @@ -3133,16 +3125,16 @@ static bool p_chart_lscm_solve(ParamHandle *handle, PChart *chart) } } - /* detect up direction based on pinned vertices */ - area_pinned_up = 0.0f; - area_pinned_down = 0.0f; + /* Detect "up" direction based on pinned vertices. */ + float area_pinned_up = 0.0f; + float area_pinned_down = 0.0f; - for (f = chart->faces; f; f = f->nextlink) { + for (PFace *f = chart->faces; f; f = f->nextlink) { PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert; if ((v1->flag & PVERT_PIN) && (v2->flag & PVERT_PIN) && (v3->flag & PVERT_PIN)) { - float area = p_face_uv_area_signed(f); + const float area = p_face_uv_area_signed(f); if (area > 0.0f) { area_pinned_up += area; @@ -3153,19 +3145,18 @@ static bool p_chart_lscm_solve(ParamHandle *handle, PChart *chart) } } - flip_faces = (area_pinned_down > area_pinned_up); - - /* construct matrix */ + const bool flip_faces = (area_pinned_down > area_pinned_up); - row = 0; - for (f = chart->faces; f; f = f->nextlink) { + /* Construct matrix. */ + const float *alpha = chart->u.lscm.abf_alpha; + int row = 0; + for (PFace *f = chart->faces; f; f = f->nextlink) { PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert; -float a1, a2, a3, ratio, cosine, sine; -float sina1, sina2, sina3, sinmax; +float a1, a2, a3; if (alpha) { - /* use abf angles if passed on */ + /* Use abf angles if present. */ a1 = *(alpha++); a2 = *(alpha++); a3 = *(alpha++); @@ -3180,13 +3171,13 @@ static bool p_chart_lscm_solve(ParamHandle *handle, PChart *chart) SWAP(PVert *, v2, v3); } -sina1 = sinf(a1); -sina2 = sinf(a2); -sina3 = sinf(a3); +float sina1 = sinf(a1); +float sina2 = sinf(a2); +float sina3 = sinf(a3); -sinmax = max_fff(sina1, sina2, sina3); +const float sinmax = max_fff(sina1, sina2, sina3); -/* shift vertices to find most stable ord
[Bf-blender-cvs] [d602d4f15f5] master: Cleanup: reduce variable scope in uv parametrizer
Commit: d602d4f15f5c9b67ce86bd84005b94dabd87531d Author: Chris Blackbourn Date: Wed Nov 30 11:56:00 2022 +1300 Branches: master https://developer.blender.org/rBd602d4f15f5c9b67ce86bd84005b94dabd87531d Cleanup: reduce variable scope in uv parametrizer Simplify future fix for T78101 === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 199e43ab0d8..e7217fc4106 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -426,9 +426,7 @@ static float p_chart_uv_area(PChart *chart) static void p_chart_uv_scale(PChart *chart, float scale) { - PVert *v; - - for (v = chart->verts; v; v = v->nextlink) { + for (PVert *v = chart->verts; v; v = v->nextlink) { v->uv[0] *= scale; v->uv[1] *= scale; } @@ -436,9 +434,7 @@ static void p_chart_uv_scale(PChart *chart, float scale) static void p_chart_uv_scale_xy(PChart *chart, float x, float y) { - PVert *v; - - for (v = chart->verts; v; v = v->nextlink) { + for (PVert *v = chart->verts; v; v = v->nextlink) { v->uv[0] *= x; v->uv[1] *= y; } @@ -446,9 +442,7 @@ static void p_chart_uv_scale_xy(PChart *chart, float x, float y) static void p_chart_uv_translate(PChart *chart, const float trans[2]) { - PVert *v; - - for (v = chart->verts; v; v = v->nextlink) { + for (PVert *v = chart->verts; v; v = v->nextlink) { v->uv[0] += trans[0]; v->uv[1] += trans[1]; } @@ -456,9 +450,7 @@ static void p_chart_uv_translate(PChart *chart, const float trans[2]) static void p_chart_uv_transform(PChart *chart, const float mat[2][2]) { - PVert *v; - - for (v = chart->verts; v; v = v->nextlink) { + for (PVert *v = chart->verts; v; v = v->nextlink) { mul_m2_v2(mat, v->uv); } } @@ -4000,14 +3992,11 @@ void GEO_uv_parametrizer_construct_end(ParamHandle *phandle, void GEO_uv_parametrizer_lscm_begin(ParamHandle *phandle, bool live, bool abf) { - PFace *f; - int i; - param_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED); phandle->state = PHANDLE_STATE_LSCM; - for (i = 0; i < phandle->ncharts; i++) { -for (f = phandle->charts[i]->faces; f; f = f->nextlink) { + for (int i = 0; i < phandle->ncharts; i++) { +for (PFace *f = phandle->charts[i]->faces; f; f = f->nextlink) { p_face_backup_uvs(f); } p_chart_lscm_begin(phandle->charts[i], live, abf); ___ 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] [5ce72bba7e9] master: Cleanup: simplify flush/blend logic in uv parametrizer
Commit: 5ce72bba7e936d0e41cc86e40ace880c71af6377 Author: Chris Blackbourn Date: Wed Nov 30 11:50:12 2022 +1300 Branches: master https://developer.blender.org/rB5ce72bba7e936d0e41cc86e40ace880c71af6377 Cleanup: simplify flush/blend logic in uv parametrizer Simplify future fix for T78101 === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 289dd4372c6..199e43ab0d8 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -617,25 +617,18 @@ static void p_vert_load_pin_select_uvs(ParamHandle *handle, PVert *v) static void p_flush_uvs(ParamHandle *handle, PChart *chart) { - PEdge *e; - - for (e = chart->edges; e; e = e->nextlink) { -if (e->orig_uv) { - e->orig_uv[0] = e->vert->uv[0] / handle->aspx; - e->orig_uv[1] = e->vert->uv[1] / handle->aspy; -} - } -} - -static void p_flush_uvs_blend(ParamHandle *handle, PChart *chart, float blend) -{ - PEdge *e; - float invblend = 1.0f - blend; - - for (e = chart->edges; e; e = e->nextlink) { + const float blend = handle->blend; + const float invblend = 1.0f - blend; + for (PEdge *e = chart->edges; e; e = e->nextlink) { if (e->orig_uv) { - e->orig_uv[0] = blend * e->old_uv[0] + invblend * e->vert->uv[0] / handle->aspx; - e->orig_uv[1] = blend * e->old_uv[1] + invblend * e->vert->uv[1] / handle->aspy; + if (blend) { +e->orig_uv[0] = blend * e->old_uv[0] + invblend * e->vert->uv[0] / handle->aspx; +e->orig_uv[1] = blend * e->old_uv[1] + invblend * e->vert->uv[1] / handle->aspy; + } + else { +e->orig_uv[0] = e->vert->uv[0] / handle->aspx; +e->orig_uv[1] = e->vert->uv[1] / handle->aspy; + } } } } @@ -4023,13 +4016,10 @@ void GEO_uv_parametrizer_lscm_begin(ParamHandle *phandle, bool live, bool abf) void GEO_uv_parametrizer_lscm_solve(ParamHandle *phandle, int *count_changed, int *count_failed) { - PChart *chart; - int i; - param_assert(phandle->state == PHANDLE_STATE_LSCM); - for (i = 0; i < phandle->ncharts; i++) { -chart = phandle->charts[i]; + for (int i = 0; i < phandle->ncharts; i++) { +PChart *chart = phandle->charts[i]; if (chart->u.lscm.context) { const bool result = p_chart_lscm_solve(phandle, chart); @@ -4416,12 +4406,7 @@ void GEO_uv_parametrizer_flush(ParamHandle *phandle) continue; } -if (phandle->blend == 0.0f) { - p_flush_uvs(phandle, chart); -} -else { - p_flush_uvs_blend(phandle, chart, phandle->blend); -} +p_flush_uvs(phandle, chart); } } ___ 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] [b99cdf74722] master: Cleanup: use blenlib geometry functions in uv parametrizer
Commit: b99cdf74722421fd5d4fc7c225a62a2096ba3ae6 Author: Chris Blackbourn Date: Wed Nov 30 11:44:13 2022 +1300 Branches: master https://developer.blender.org/rBb99cdf74722421fd5d4fc7c225a62a2096ba3ae6 Cleanup: use blenlib geometry functions in uv parametrizer Simplify future fix for T78101 === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index c12c1443f1a..289dd4372c6 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -297,17 +297,6 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link) return link; } -/* Geometry */ - -static float p_vec_angle(const float v1[3], const float v2[3], const float v3[3]) -{ - return angle_v3v3v3(v1, v2, v3); -} -static float p_vec2_angle(const float v1[2], const float v2[2], const float v3[2]) -{ - return angle_v2v2v2(v1, v2, v3); -} - /* Angles close to 0 or 180 degrees cause rows filled with zeros in the linear_solver. * The matrix will then be rank deficient and / or have poor conditioning. * => Reduce the maximum angle to 179 degrees, and spread the remainder to the other angles. @@ -358,9 +347,9 @@ static void fix_large_angle(const float v_fix[3], static void p_triangle_angles( const float v1[3], const float v2[3], const float v3[3], float *r_a1, float *r_a2, float *r_a3) { - *r_a1 = p_vec_angle(v3, v1, v2); - *r_a2 = p_vec_angle(v1, v2, v3); - *r_a3 = p_vec_angle(v2, v3, v1); + *r_a1 = angle_v3v3v3(v3, v1, v2); + *r_a2 = angle_v3v3v3(v1, v2, v3); + *r_a3 = angle_v3v3v3(v2, v3, v1); /* Fix for degenerate geometry e.g. v1 = sum(v2 + v3). See T100874 */ fix_large_angle(v1, v2, v3, r_a1, r_a2, r_a3); @@ -1229,7 +1218,7 @@ static float p_edge_boundary_angle(PEdge *e) do { v1 = we->next->vert; v2 = we->next->next->vert; -angle -= p_vec_angle(v1->co, v->co, v2->co); +angle -= angle_v3v3v3(v1->co, v->co, v2->co); we = we->next->next->pair; n++; @@ -3588,7 +3577,7 @@ static float p_chart_minimum_area_angle(PChart *chart) p2 = points[i]; p3 = (i == npoints - 1) ? points[0] : points[i + 1]; -angles[i] = float(M_PI) - p_vec2_angle(p1->uv, p2->uv, p3->uv); +angles[i] = float(M_PI) - angle_v2v2v2(p1->uv, p2->uv, p3->uv); if (points[i]->uv[1] < miny) { miny = points[i]->uv[1]; @@ -3608,19 +3597,19 @@ static float p_chart_minimum_area_angle(PChart *chart) v[0] = points[idx[0]]->uv[0]; v[1] = points[idx[0]]->uv[1] + 1.0f; - a[0] = p_vec2_angle(points[(idx[0] + 1) % npoints]->uv, points[idx[0]]->uv, v); + a[0] = angle_v2v2v2(points[(idx[0] + 1) % npoints]->uv, points[idx[0]]->uv, v); v[0] = points[idx[1]]->uv[0] + 1.0f; v[1] = points[idx[1]]->uv[1]; - a[1] = p_vec2_angle(points[(idx[1] + 1) % npoints]->uv, points[idx[1]]->uv, v); + a[1] = angle_v2v2v2(points[(idx[1] + 1) % npoints]->uv, points[idx[1]]->uv, v); v[0] = points[idx[2]]->uv[0]; v[1] = points[idx[2]]->uv[1] - 1.0f; - a[2] = p_vec2_angle(points[(idx[2] + 1) % npoints]->uv, points[idx[2]]->uv, v); + a[2] = angle_v2v2v2(points[(idx[2] + 1) % npoints]->uv, points[idx[2]]->uv, v); v[0] = points[idx[3]]->uv[0] - 1.0f; v[1] = points[idx[3]]->uv[1]; - a[3] = p_vec2_angle(points[(idx[3] + 1) % npoints]->uv, points[idx[3]]->uv, v); + a[3] = angle_v2v2v2(points[(idx[3] + 1) % npoints]->uv, points[idx[3]]->uv, v); /* 4 rotating calipers */ ___ 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] [4067e6bc415] master: Cleanup: format
Commit: 4067e6bc41507f81dcb398afdede8828eeb43624 Author: Chris Blackbourn Date: Tue Nov 29 17:32:28 2022 +1300 Branches: master https://developer.blender.org/rB4067e6bc41507f81dcb398afdede8828eeb43624 Cleanup: format === M source/blender/blenkernel/BKE_uv_islands.hh M source/blender/editors/sculpt_paint/sculpt_paint_image.cc === diff --git a/source/blender/blenkernel/BKE_uv_islands.hh b/source/blender/blenkernel/BKE_uv_islands.hh index cf274e415b9..406ecf39b71 100644 --- a/source/blender/blenkernel/BKE_uv_islands.hh +++ b/source/blender/blenkernel/BKE_uv_islands.hh @@ -17,7 +17,6 @@ #include "DNA_meshdata_types.h" - namespace blender::bke::uv_islands { struct MeshEdge; diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc index d9981cbb557..6244cf8e33d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc @@ -362,12 +362,18 @@ static void do_paint_pixels(void *__restrict userdata, } bool pixels_painted = false; if (image_buffer->rect_float != nullptr) { -pixels_painted = kernel_float4.paint( -pbvh_data.geom_primitives, node_data.uv_primitives, pixel_row, image_buffer, _data); +pixels_painted = kernel_float4.paint(pbvh_data.geom_primitives, + node_data.uv_primitives, + pixel_row, + image_buffer, + _data); } else { -pixels_painted = kernel_byte4.paint( -pbvh_data.geom_primitives, node_data.uv_primitives, pixel_row, image_buffer, _data); +pixels_painted = kernel_byte4.paint(pbvh_data.geom_primitives, +node_data.uv_primitives, +pixel_row, +image_buffer, +_data); } if (pixels_painted) { ___ 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] [3d1594417b0] master: UV: support constrain-to-bounds for uv shear operator
Commit: 3d1594417b0ee8608230ad4941eccdc57271ec60 Author: Chris Blackbourn Date: Tue Nov 29 12:02:41 2022 +1300 Branches: master https://developer.blender.org/rB3d1594417b0ee8608230ad4941eccdc57271ec60 UV: support constrain-to-bounds for uv shear operator For uv rotation operator, see rBd527aa4dd53d4. === M source/blender/editors/transform/transform_mode_shear.c === diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c index 68fe9f35965..d419916ee4c 100644 --- a/source/blender/editors/transform/transform_mode_shear.c +++ b/source/blender/editors/transform/transform_mode_shear.c @@ -175,53 +175,28 @@ static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event) return status; } -static void applyShear(TransInfo *t, const int UNUSED(mval[2])) +static void apply_shear_value(TransInfo *t, const float value) { - float smat[3][3], axismat[3][3], axismat_inv[3][3], mat_final[3][3]; - float value; - int i; - char str[UI_MAX_DRAW_STR]; - const bool is_local_center = transdata_check_local_center(t, t->around); - - value = t->values[0] + t->values_modal_offset[0]; - - transform_snap_increment(t, ); - - applyNumInput(>num, ); - - t->values_final[0] = value; - - /* header print for NumInput */ - if (hasNumInput(>num)) { -char c[NUM_STR_REP_LEN]; - -outputNumInput(&(t->num), c, >scene->unit); - -BLI_snprintf(str, sizeof(str), TIP_("Shear: %s %s"), c, t->proptext); - } - else { -/* default header print */ -BLI_snprintf(str, - sizeof(str), - TIP_("Shear: %.3f %s (Press X or Y to set shear axis)"), - value, - t->proptext); - } - + float smat[3][3]; unit_m3(smat); smat[1][0] = value; + float axismat_inv[3][3]; copy_v3_v3(axismat_inv[0], t->spacemtx[t->orient_axis_ortho]); copy_v3_v3(axismat_inv[2], t->spacemtx[t->orient_axis]); cross_v3_v3v3(axismat_inv[1], axismat_inv[0], axismat_inv[2]); + float axismat[3][3]; invert_m3_m3(axismat, axismat_inv); + float mat_final[3][3]; mul_m3_series(mat_final, axismat_inv, smat, axismat); + const bool is_local_center = transdata_check_local_center(t, t->around); + FOREACH_TRANS_DATA_CONTAINER (t, tc) { if (tc->data_len < TRANSDATA_THREAD_LIMIT) { TransData *td = tc->data; - for (i = 0; i < tc->data_len; i++, td++) { + for (int i = 0; i < tc->data_len; i++, td++) { if (td->flag & TD_SKIP) { continue; } @@ -241,16 +216,117 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) BLI_task_parallel_range(0, tc->data_len, , transdata_elem_shear_fn, ); } } +} + +static bool uv_shear_in_clip_bounds_test(const TransInfo *t, const float value) +{ + const int axis = t->orient_axis_ortho; + if (axis < 0 || 1 < axis) { +return true; /* Non standard axis, nothing to do. */ + } + const float *center = t->center_global; + FOREACH_TRANS_DATA_CONTAINER (t, tc) { +TransData *td = tc->data; +for (int i = 0; i < tc->data_len; i++, td++) { + if (td->flag & TD_SKIP) { +continue; + } + if (td->factor < 1.0f) { +continue; /* Proportional edit, will get picked up in next phase. */ + } + + float uv[2]; + sub_v2_v2v2(uv, td->iloc, center); + uv[axis] = uv[axis] + value * uv[1 - axis] * (2 * axis - 1); + add_v2_v2(uv, center); + /* TODO: udim support. */ + if (uv[axis] < 0.0f || 1.0f < uv[axis]) { +return false; + } +} + } + return true; +} + +static bool clip_uv_transform_shear(const TransInfo *t, float *vec, float *vec_inside_bounds) +{ + float value = vec[0]; + if (uv_shear_in_clip_bounds_test(t, value)) { +vec_inside_bounds[0] = value; /* Store for next iteration. */ +return false; /* Nothing to do. */ + } + float value_inside_bounds = vec_inside_bounds[0]; + if (!uv_shear_in_clip_bounds_test(t, value_inside_bounds)) { +return false; /* No known way to fix, may as well shear anyway. */ + } + const int max_i = 32; /* Limit iteration, mainly for debugging. */ + for (int i = 0; i < max_i; i++) { +/* Binary search. */ +const float value_mid = (value_inside_bounds + value) / 2.0f; +if (value_mid == value_inside_bounds || value_mid == value) { + break; /* float precision reached. */ +} +if (uv_shear_in_clip_bounds_test(t, value_mid)) { + value_inside_bounds = value_mid; +} +else { + value = value_mid; +} + } + + vec_inside_bounds[0] = value_inside_bounds; /* Store for next iteration. */ + vec[0] = value_inside_bounds;
[Bf-blender-cvs] [5a03d212a9a] blender-v3.3-release: Fix T100926: Show UV outline in texture paint mode
Commit: 5a03d212a9ac25b44c299f05baf1b0f54d34c733 Author: Chris Blackbourn Date: Wed Nov 16 11:13:45 2022 +1300 Branches: blender-v3.3-release https://developer.blender.org/rB5a03d212a9ac25b44c299f05baf1b0f54d34c733 Fix T100926: Show UV outline in texture paint mode After rB716ea1547989 the UV overlay is no longer displayed in the UV Editor. It only appears for the Image Editor. So restore the previous behavior, displaying the "UV shadow" overlay in the UV editor as well. Reviewed By: Jeroen Bakker, Germano Cavalcante Maniphest Tasks: T92614, T100926 Differential Revision: https://developer.blender.org/D16490 === M source/blender/draw/engines/overlay/overlay_edit_uv.c === diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c index adbe5e7155e..2513e923c12 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.c +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c @@ -137,6 +137,8 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) ((is_paint_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) || + (is_uv_editor && do_tex_paint_shadows && + ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (is_view_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (do_uv_overlay && (show_modified_uvs))); ___ 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] [c02ec744057] master: Cleanup: format
Commit: c02ec744057737f056a61a445cc8d34b94ddb389 Author: Chris Blackbourn Date: Mon Nov 28 13:13:54 2022 +1300 Branches: master https://developer.blender.org/rBc02ec744057737f056a61a445cc8d34b94ddb389 Cleanup: format === M source/blender/editors/gpencil/gpencil_select.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 0156b272a81..0b11d6bf2ba 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -2442,11 +2442,11 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* if select mode is stroke, use whole stroke */ if ((ob) && (ob->mode == OB_MODE_SCULPT_GPENCIL)) { whole |= (bool)(gpencil_select_mode_from_sculpt(ts->gpencil_selectmode_sculpt) == - GP_SELECTMODE_STROKE); +GP_SELECTMODE_STROKE); } else if ((ob) && (ob->mode == OB_MODE_VERTEX_GPENCIL)) { whole |= (bool)(gpencil_select_mode_from_vertex(ts->gpencil_selectmode_sculpt) == - GP_SELECTMODE_STROKE); +GP_SELECTMODE_STROKE); } else { whole |= (bool)(ts->gpencil_selectmode_edit == GP_SELECTMODE_STROKE); diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc index 2f30f030297..1fa2f2fbb03 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc @@ -3542,7 +3542,8 @@ static LineartData *lineart_create_render_buffer(Scene *scene, copy_v3db_v3fl(ld->conf.active_camera_pos, active_camera->object_to_world[3]); } copy_m4_m4(ld->conf.cam_obmat, camera->object_to_world); - /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and lights. */ + /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and + * lights. */ normalize_v3(ld->conf.cam_obmat[0]); normalize_v3(ld->conf.cam_obmat[1]); normalize_v3(ld->conf.cam_obmat[2]); @@ -3574,7 +3575,8 @@ static LineartData *lineart_create_render_buffer(Scene *scene, Object *light_obj = lmd->light_contour_object; copy_v3db_v3fl(ld->conf.camera_pos_secondary, light_obj->object_to_world[3]); copy_m4_m4(ld->conf.cam_obmat_secondary, light_obj->object_to_world); -/* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and lights. */ +/* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and + * lights. */ normalize_v3(ld->conf.cam_obmat_secondary[0]); normalize_v3(ld->conf.cam_obmat_secondary[1]); normalize_v3(ld->conf.cam_obmat_secondary[2]); ___ 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] [143e74c0b8e] blender-v3.4-release: Fix (unreported) uv unwrap selected was splitting selection
Commit: 143e74c0b8ebd7248d2a50353d0baf67347b83bf Author: Chris Blackbourn Date: Mon Nov 28 13:14:42 2022 +1300 Branches: blender-v3.4-release https://developer.blender.org/rB143e74c0b8ebd7248d2a50353d0baf67347b83bf Fix (unreported) uv unwrap selected was splitting selection Add support for `pin_unselected` in new UV Packing API. Regression introduced by API change in rBe3075f3cf7ce. Duplicate change to rB0ce18561bc82 in master. === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index b97cd6a9099..0cc2f317564 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -353,6 +353,7 @@ struct UVPackIsland_Params { uint use_seams : 1; uint correct_aspect : 1; bool ignore_pinned; /* Ignore islands which have any pinned UVs. */ + bool pin_unselected; /* Treat unselected UVs as if they were pinned. */ eUVPackIsland_MarginMethod margin_method; /* Which formula to use when scaling island margin. */ float margin; /* Additional space to add around each island. */ }; diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 92745667505..27a951779c0 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -600,7 +600,7 @@ static BoxPack *pack_islands_params(const blender::Vector _ return box_array; } -static bool island_has_pins(FaceIsland *island) +static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected) { BMLoop *l; BMIter iter; @@ -611,6 +611,9 @@ static bool island_has_pins(FaceIsland *island) if (luv->flag & MLOOPUV_PINNED) { return true; } + if (pin_unselected && !uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { +return true; + } } } return false; @@ -657,12 +660,18 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, } } +bool only_selected_faces = params->only_selected_faces; +bool only_selected_uvs = params->only_selected_uvs; +if (params->ignore_pinned && params->pin_unselected) { + only_selected_faces = false; + only_selected_uvs = false; +} ListBase island_list = {nullptr}; bm_mesh_calc_uv_islands(scene, bm, _list, -params->only_selected_faces, -params->only_selected_uvs, +only_selected_faces, +only_selected_uvs, params->use_seams, aspect_y, cd_loop_uv_offset); @@ -670,7 +679,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Remove from linked list and append to blender::Vector. */ LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, _list) { BLI_remlink(_list, island); - if (params->ignore_pinned && island_has_pins(island)) { + if (params->ignore_pinned && island_has_pins(scene, island, params->pin_unselected)) { MEM_freeN(island->faces); MEM_freeN(island); continue; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 071f1c44c6b..81e1d673d08 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1101,6 +1101,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op) .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect = options.correct_aspect, .ignore_pinned = false, + .pin_unselected = options.pin_unselected, .margin_method = RNA_enum_get(op->ptr, "margin_method"), .margin = RNA_float_get(op->ptr, "margin"), }; @@ -1879,6 +1880,7 @@ void ED_uvedit_live_unwrap(const Scene *scene, Object **objects, int objects_len .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect = options.correct_aspect, .ignore_pinned = true, +.pin_unselected = options.pin_unselected, .margin_method = ED_UVPACK_MARGIN_SCALED, .margin = scene->toolsettings->uvcalc_margin, }; @@ -2026,6 +2028,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) .use_seams = !options.topology_from_uvs || options.to
[Bf-blender-cvs] [e010890e826] blender-v3.4-release: Cleanup: format
Commit: e010890e826abf7846769e6399fd4ee10fd1086e Author: Chris Blackbourn Date: Mon Nov 28 13:13:54 2022 +1300 Branches: blender-v3.4-release https://developer.blender.org/rBe010890e826abf7846769e6399fd4ee10fd1086e Cleanup: format === M source/blender/editors/gpencil/gpencil_select.c M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 0156b272a81..0b11d6bf2ba 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -2442,11 +2442,11 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* if select mode is stroke, use whole stroke */ if ((ob) && (ob->mode == OB_MODE_SCULPT_GPENCIL)) { whole |= (bool)(gpencil_select_mode_from_sculpt(ts->gpencil_selectmode_sculpt) == - GP_SELECTMODE_STROKE); +GP_SELECTMODE_STROKE); } else if ((ob) && (ob->mode == OB_MODE_VERTEX_GPENCIL)) { whole |= (bool)(gpencil_select_mode_from_vertex(ts->gpencil_selectmode_sculpt) == - GP_SELECTMODE_STROKE); +GP_SELECTMODE_STROKE); } else { whole |= (bool)(ts->gpencil_selectmode_edit == GP_SELECTMODE_STROKE); diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index d5d5a8214f5..05c3ae56a0a 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -3594,7 +3594,8 @@ static LineartData *lineart_create_render_buffer(Scene *scene, copy_v3db_v3fl(ld->conf.active_camera_pos, active_camera->object_to_world[3]); } copy_m4_m4(ld->conf.cam_obmat, camera->object_to_world); - /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and lights. */ + /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and + * lights. */ normalize_v3(ld->conf.cam_obmat[0]); normalize_v3(ld->conf.cam_obmat[1]); normalize_v3(ld->conf.cam_obmat[2]); @@ -3626,7 +3627,8 @@ static LineartData *lineart_create_render_buffer(Scene *scene, Object *light_obj = lmd->light_contour_object; copy_v3db_v3fl(ld->conf.camera_pos_secondary, light_obj->object_to_world[3]); copy_m4_m4(ld->conf.cam_obmat_secondary, light_obj->object_to_world); -/* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and lights. */ +/* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and + * lights. */ normalize_v3(ld->conf.cam_obmat_secondary[0]); normalize_v3(ld->conf.cam_obmat_secondary[1]); normalize_v3(ld->conf.cam_obmat_secondary[2]); ___ 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] [0ce18561bc8] master: Fix (unreported) uv unwrap selected was splitting selection
Commit: 0ce18561bc82f533d248f0f7268263abc0fc6fe1 Author: Chris Blackbourn Date: Fri Nov 25 15:48:17 2022 +1300 Branches: master https://developer.blender.org/rB0ce18561bc82f533d248f0f7268263abc0fc6fe1 Fix (unreported) uv unwrap selected was splitting selection Add support for `pin_unselected` in new UV Packing API. Regression introduced by API change in rBe3075f3cf7ce. === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 5fea8711a84..4a7081baa38 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -353,6 +353,7 @@ struct UVPackIsland_Params { uint use_seams : 1; uint correct_aspect : 1; bool ignore_pinned; /* Ignore islands which have any pinned UVs. */ + bool pin_unselected; /* Treat unselected UVs as if they were pinned. */ eUVPackIsland_MarginMethod margin_method; /* Which formula to use when scaling island margin. */ float margin; /* Additional space to add around each island. */ }; diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index d8e10435146..61fd1c53b95 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -618,7 +618,7 @@ static BoxPack *pack_islands_params(const blender::Vector _ return box_array; } -static bool island_has_pins(FaceIsland *island) +static bool island_has_pins(const Scene *scene, FaceIsland *island, const bool pin_unselected) { BMLoop *l; BMIter iter; @@ -629,6 +629,9 @@ static bool island_has_pins(FaceIsland *island) if (luv->flag & MLOOPUV_PINNED) { return true; } + if (pin_unselected && !uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { +return true; + } } } return false; @@ -675,12 +678,18 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, } } +bool only_selected_faces = params->only_selected_faces; +bool only_selected_uvs = params->only_selected_uvs; +if (params->ignore_pinned && params->pin_unselected) { + only_selected_faces = false; + only_selected_uvs = false; +} ListBase island_list = {nullptr}; bm_mesh_calc_uv_islands(scene, bm, _list, -params->only_selected_faces, -params->only_selected_uvs, +only_selected_faces, +only_selected_uvs, params->use_seams, aspect_y, cd_loop_uv_offset); @@ -688,7 +697,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, /* Remove from linked list and append to blender::Vector. */ LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, _list) { BLI_remlink(_list, island); - if (params->ignore_pinned && island_has_pins(island)) { + if (params->ignore_pinned && island_has_pins(scene, island, params->pin_unselected)) { MEM_freeN(island->faces); MEM_freeN(island); continue; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index ce9a083dfeb..b310132bdd2 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1100,6 +1100,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op) .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect = options.correct_aspect, .ignore_pinned = false, + .pin_unselected = options.pin_unselected, .margin_method = RNA_enum_get(op->ptr, "margin_method"), .margin = RNA_float_get(op->ptr, "margin"), }; @@ -1878,6 +1879,7 @@ void ED_uvedit_live_unwrap(const Scene *scene, Object **objects, int objects_len .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect = options.correct_aspect, .ignore_pinned = true, +.pin_unselected = options.pin_unselected, .margin_method = ED_UVPACK_MARGIN_SCALED, .margin = scene->toolsettings->uvcalc_margin, }; @@ -2025,6 +2027,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) .use_seams = !options.topology_from_uvs || options.topology_from_uvs_use_seams, .correct_aspect
[Bf-blender-cvs] [60523ea5236] master: Cleanup: format
Commit: 60523ea5236a2c19564b9982fc521ee37ff07bf7 Author: Chris Blackbourn Date: Wed Nov 16 12:59:34 2022 +1300 Branches: master https://developer.blender.org/rB60523ea5236a2c19564b9982fc521ee37ff07bf7 Cleanup: format === M intern/cycles/integrator/denoiser_gpu.cpp M source/blender/blenkernel/BKE_curves.hh === diff --git a/intern/cycles/integrator/denoiser_gpu.cpp b/intern/cycles/integrator/denoiser_gpu.cpp index 3d17902ac8f..0bd8989293b 100644 --- a/intern/cycles/integrator/denoiser_gpu.cpp +++ b/intern/cycles/integrator/denoiser_gpu.cpp @@ -24,9 +24,9 @@ DenoiserGPU::~DenoiserGPU() } bool DenoiserGPU::denoise_buffer(const BufferParams _params, -RenderBuffers *render_buffers, -const int num_samples, -bool allow_inplace_modification) + RenderBuffers *render_buffers, + const int num_samples, + bool allow_inplace_modification) { Device *denoiser_device = get_denoiser_device(); if (!denoiser_device) { diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index ff11090ca12..50543092aef 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -18,11 +18,11 @@ #include "BLI_generic_virtual_array.hh" #include "BLI_index_mask.hh" #include "BLI_math_vec_types.hh" +#include "BLI_shared_cache.hh" #include "BLI_span.hh" #include "BLI_task.hh" #include "BLI_vector.hh" #include "BLI_virtual_array.hh" -#include "BLI_shared_cache.hh" #include "BKE_attribute.hh" #include "BKE_attribute_math.hh" ___ 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] [9f2f9dbca67] master: Merge branch 'blender-v3.4-release'
Commit: 9f2f9dbca6749d44edb9a09b68854b598ddaa1fd Author: Chris Blackbourn Date: Wed Nov 16 11:28:57 2022 +1300 Branches: master https://developer.blender.org/rB9f2f9dbca6749d44edb9a09b68854b598ddaa1fd Merge branch 'blender-v3.4-release' === === ___ 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] [4401c93e452] blender-v3.4-release: Fix T100926: Show UV outline in texture paint mode
Commit: 4401c93e452fdfa537c701ddbd693a70a5247cd6 Author: Chris Blackbourn Date: Wed Nov 16 11:13:45 2022 +1300 Branches: blender-v3.4-release https://developer.blender.org/rB4401c93e452fdfa537c701ddbd693a70a5247cd6 Fix T100926: Show UV outline in texture paint mode After rB716ea1547989 the UV overlay is no longer displayed in the UV Editor. It only appears for the Image Editor. So restore the previous behavior, displaying the "UV shadow" overlay in the UV editor as well. Reviewed By: Jeroen Bakker, Germano Cavalcante Maniphest Tasks: T92614, T100926 Differential Revision: https://developer.blender.org/D16490 === M source/blender/draw/engines/overlay/overlay_edit_uv.cc === diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index 0fcbe5ab07d..613df1bb957 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -139,6 +139,8 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) ((is_paint_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) || + (is_uv_editor && do_tex_paint_shadows && + ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (is_view_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (do_uv_overlay && (show_modified_uvs))); ___ 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] [da82d46a5ae] master: Cleanup: simplify asserts in uv unwrapper
Commit: da82d46a5ae66206a49a3bc95630b9a9f1c1f1d7 Author: Chris Blackbourn Date: Wed Nov 16 10:26:20 2022 +1300 Branches: master https://developer.blender.org/rBda82d46a5ae66206a49a3bc95630b9a9f1c1f1d7 Cleanup: simplify asserts in uv unwrapper === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 070703f5228..c12c1443f1a 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -3927,9 +3927,8 @@ void GEO_uv_parametrizer_face_add(ParamHandle *phandle, const bool *pin, const bool *select) { - param_assert(phash_lookup(phandle->hash_faces, key) == nullptr); + BLI_assert(nverts >= 3); param_assert(phandle->state == PHANDLE_STATE_ALLOCATED); - param_assert(ELEM(nverts, 3, 4)); if (nverts > 4) { /* ngon */ ___ 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] [909f47e0e19] master: UV: fix crash with uv copy on empty selection
Commit: 909f47e0e19799df34d7bdf2a81867f2ea7f2cdc Author: Chris Blackbourn Date: Mon Nov 14 13:35:43 2022 +1300 Branches: master https://developer.blender.org/rB909f47e0e19799df34d7bdf2a81867f2ea7f2cdc UV: fix crash with uv copy on empty selection Introduced in 721fc9c1c950 === M source/blender/editors/uvedit/uvedit_clipboard.cc === diff --git a/source/blender/editors/uvedit/uvedit_clipboard.cc b/source/blender/editors/uvedit/uvedit_clipboard.cc index d7222f04ba8..7ededf516bc 100644 --- a/source/blender/editors/uvedit/uvedit_clipboard.cc +++ b/source/blender/editors/uvedit/uvedit_clipboard.cc @@ -281,9 +281,10 @@ static int uv_copy_exec(bContext *C, wmOperator * /*op*/) const bool use_seams = false; UvElementMap *element_map = BM_uv_element_map_create( em->bm, scene, true, false, use_seams, true); - -const int cd_loop_uv_offset = CustomData_get_offset(>bm->ldata, CD_MLOOPUV); -uv_clipboard->append(element_map, cd_loop_uv_offset); +if (element_map) { + const int cd_loop_uv_offset = CustomData_get_offset(>bm->ldata, CD_MLOOPUV); + uv_clipboard->append(element_map, cd_loop_uv_offset); +} BM_uv_element_map_free(element_map); } @@ -317,6 +318,10 @@ static int uv_paste_exec(bContext *C, wmOperator * /*op*/) UvElementMap *dest_element_map = BM_uv_element_map_create( em->bm, scene, true, false, use_seams, true); +if (!dest_element_map) { + continue; +} + for (int i = 0; i < dest_element_map->total_islands; i++) { blender::Vector label; const bool found = uv_clipboard->find_isomorphism( ___ 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] [fba7461e1a5] master: UV: fix compile on windows
Commit: fba7461e1a51643ea4762f2dc5d4811b49cedbef Author: Chris Blackbourn Date: Mon Nov 14 08:20:53 2022 +1300 Branches: master https://developer.blender.org/rBfba7461e1a51643ea4762f2dc5d4811b49cedbef UV: fix compile on windows Remove VLAs for compiling on windows. Regression from 721fc9c1c950 === M source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc === diff --git a/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc b/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc index 43975d0d382..897361472a8 100644 --- a/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc +++ b/source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc @@ -309,9 +309,11 @@ static void maximum_common_subgraph_internal( { int min = std::min(n0, n1); - uint8_t cur[min][2]; - uint8_t domains[min * min][BDS]; - uint8_t left[n0], right[n1]; + uint8_t(*cur)[2] = (uint8_t(*)[2])MEM_mallocN(min * sizeof(*cur), __func__); + uint8_t(*domains)[BDS] = (uint8_t(*)[8])MEM_mallocN(min * min * sizeof(*domains), __func__); + uint8_t *left = static_cast(MEM_mallocN(n0 * sizeof *left, __func__)); + uint8_t *right = static_cast(MEM_mallocN(n1 * sizeof *right, __func__)); + uint8_t v, w, *bd; int bd_pos = 0; for (int i = 0; i < n0; i++) { @@ -330,7 +332,8 @@ static void maximum_common_subgraph_internal( * Can occur with moderate sized inputs where the graph has lots of symmetry, e.g. a cube * subdivided 3x times. */ - return; + *inc_pos = 0; + break; } bd = [bd_pos - 1][L]; if (calc_bound(domains, bd_pos, bd[P]) + bd[P] <= *inc_pos || @@ -354,6 +357,11 @@ static void maximum_common_subgraph_internal( } } } + + MEM_freeN(cur); + MEM_freeN(domains); + MEM_freeN(right); + MEM_freeN(left); } static bool check_automorphism(const GraphISO *g0, ___ 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] [721fc9c1c95] master: UV: implement copy and paste for uv
Commit: 721fc9c1c95017d55785ea42e7ba473a0285b9ad Author: Chris Blackbourn Date: Sun Nov 13 12:27:28 2022 +1300 Branches: master https://developer.blender.org/rB721fc9c1c95017d55785ea42e7ba473a0285b9ad UV: implement copy and paste for uv Implement a new topology-based copy and paste solution for UVs. Usage notes: * Open the UV Editor * Use the selection tools to select a Quad joined to a Triangle joined to another Quad. * From the menu, choose UV > UV Copy * The UV co-ordinates for your quad<=>tri<=>quad are now stored internally * Use the selection tools to select a different Quad joined to a Triangle joined to a Quad. * (Optional) From the menu, choose UV > Split > Selection * From the menu, choose UV > UV Paste * The UV co-ordinates for the new selection will be moved to match the stored UVs. Repeat selection / UV Paste steps as many times as desired. For performance considerations, see https://en.wikipedia.org/wiki/Graph_isomorphism_problem In theory, UV Copy and Paste should work with all UV selection modes. Please report any problems. A copy has been made of the Graph Isomorphism code from https://github.com/stefanoquer/graphISO Copyright (c) 2019 Stefano Quer stefano.q...@polito.it GPL v3 or later. Additional integration code Copyright (c) 2022 by Blender Foundation, GPL v2 or later. Maniphest Tasks: T77911 Differential Revision: https://developer.blender.org/D16278 === M release/scripts/startup/bl_ui/space_image.py M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/uvedit/CMakeLists.txt A source/blender/editors/uvedit/uvedit_clipboard.cc A source/blender/editors/uvedit/uvedit_clipboard_graph_iso.cc A source/blender/editors/uvedit/uvedit_clipboard_graph_iso.hh M source/blender/editors/uvedit/uvedit_intern.h M source/blender/editors/uvedit/uvedit_ops.c M source/blender/windowmanager/intern/wm_init_exit.c === diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index fcbd7bb423d..f4c64831b3e 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -440,6 +440,11 @@ class IMAGE_MT_uvs(Menu): layout.separator() +layout.operator("uv.copy") +layout.operator("uv.paste") + +layout.separator() + layout.menu("IMAGE_MT_uvs_showhide") layout.separator() diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index 705158bec0b..c5c81b31b79 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -343,6 +343,9 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge, #endif #ifdef __cplusplus + +# include "DNA_meshdata_types.h" /* MPoly */ + namespace blender::bke::mesh_topology { Array build_loop_to_poly_map(Span polys, int loops_num); diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index 4574c745d93..9a9f79b7972 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -21,6 +21,8 @@ set(INC set(SRC uvedit_buttons.c + uvedit_clipboard.cc + uvedit_clipboard_graph_iso.cc uvedit_draw.c uvedit_islands.cc uvedit_ops.c @@ -30,6 +32,7 @@ set(SRC uvedit_smart_stitch.c uvedit_unwrap_ops.c + uvedit_clipboard_graph_iso.hh uvedit_intern.h ) diff --git a/source/blender/editors/uvedit/uvedit_clipboard.cc b/source/blender/editors/uvedit/uvedit_clipboard.cc new file mode 100644 index 000..7e6d6a2e0d0 --- /dev/null +++ b/source/blender/editors/uvedit/uvedit_clipboard.cc @@ -0,0 +1,369 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2022 Blender Foundation. All rights reserved. */ + +/** \file + * \ingroup eduv + * + * Attempt to find a graph isomorphism between the topology of two different UV islands. + * + * \note On terminology, for the purposes of this file: + * * An iso_graph is a "Graph" in Graph Theory. + * * An iso_graph has an unordered set of iso_verts. + * * An iso_graph has an unordered set of iso_edges. + * * An iso_vert is a "Vertex" in Graph Theory + * * Each iso_vert has a label. + * * An iso_edge is an "Edge" in Graph Theory + * * Each iso_edge connects two iso_verts. + * * An iso_edge is undirected. + */ + +#include "BLI_math.h" + +#include "BKE_context.h" +#include "BKE_customdata.h" +#include "BKE_editmesh.h" +#include "BKE_layer.h" +#include "BKE_mesh_mapping.h" /* UvElementMap */ + +#include "DEG_depsgraph.h" + +#include "ED_mesh.h" +#include "ED_screen
[Bf-blender-cvs] [2d9d08677ec] master: Cleanup: fix types from f04f9cc3d021
Commit: 2d9d08677ecfa2684a67c39ab1d632865716ccb4 Author: Chris Blackbourn Date: Wed Nov 9 14:54:37 2022 +1300 Branches: master https://developer.blender.org/rB2d9d08677ecfa2684a67c39ab1d632865716ccb4 Cleanup: fix types from f04f9cc3d021 === M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/include/ED_mesh.h M source/blender/editors/mesh/editmesh_utils.c === diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index d0813ebb168..705158bec0b 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -83,7 +83,7 @@ typedef struct UvElementMap { struct UvElement **head_table; /** If Non-NULL, pointer to index of each unique UV. */ - int **unique_index_table; + int *unique_index_table; /** Number of islands, or zero if not calculated. */ int total_islands; diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 7dfebf58bef..52527f6c1b8 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -150,7 +150,7 @@ struct UvElement *BM_uv_element_get_head(struct UvElementMap *element_map, int BM_uv_element_get_unique_index(struct UvElementMap *element_map, struct UvElement *child); struct UvElement **BM_uv_element_map_ensure_head_table(struct UvElementMap *element_map); -int **BM_uv_element_map_ensure_unique_index(struct UvElementMap *element_map); +int *BM_uv_element_map_ensure_unique_index(struct UvElementMap *element_map); /** * Can we edit UV's for this mesh? diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 33162cd2256..bbc092d0a99 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -619,7 +619,7 @@ struct UvElement **BM_uv_element_map_ensure_head_table(struct UvElementMap *elem return element_map->head_table; } -int **BM_uv_element_map_ensure_unique_index(struct UvElementMap *element_map) +int *BM_uv_element_map_ensure_unique_index(struct UvElementMap *element_map) { if (!element_map->unique_index_table) { element_map->unique_index_table = MEM_callocN( @@ -650,7 +650,7 @@ int **BM_uv_element_map_ensure_unique_index(struct UvElementMap *element_map) int BM_uv_element_get_unique_index(struct UvElementMap *element_map, struct UvElement *child) { - int **unique_index = BM_uv_element_map_ensure_unique_index(element_map); + int *unique_index = BM_uv_element_map_ensure_unique_index(element_map); int index = child - element_map->storage; BLI_assert(0 <= index); BLI_assert(index < element_map->total_uvs); ___ 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] [f0b5f94cb56] master: Cleanup: format
Commit: f0b5f94cb56dcacd90205a9a0347f220c2b86765 Author: Chris Blackbourn Date: Wed Nov 9 11:59:51 2022 +1300 Branches: master https://developer.blender.org/rBf0b5f94cb56dcacd90205a9a0347f220c2b86765 Cleanup: format === M source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc M source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_vertex.cc M source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc index d442a8823cb..459f45ef8fb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_curve_of_point.cc @@ -49,7 +49,7 @@ class CurveOfPointInput final : public bke::CurvesFieldInput { return false; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/)const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { return ATTR_DOMAIN_POINT; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc index 02457043281..7f69503831f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc @@ -114,7 +114,7 @@ class PointsOfCurveInput final : public bke::CurvesFieldInput { return false; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/)const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { return ATTR_DOMAIN_CURVE; } @@ -152,7 +152,7 @@ class CurvePointCountInput final : public bke::CurvesFieldInput { return false; } - std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/)const final + std::optional preferred_domain(const bke::CurvesGeometry & /*curves*/) const final { return ATTR_DOMAIN_CURVE; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc index 95ae169a6e4..b464832409c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc @@ -118,7 +118,7 @@ class CornersOfFaceInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/)const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { return ATTR_DOMAIN_FACE; } @@ -159,7 +159,7 @@ class CornersOfFaceCountInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/)const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { return ATTR_DOMAIN_FACE; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc index cf579e498a5..c01c4149864 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc @@ -139,7 +139,7 @@ class CornersOfVertInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/)const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { return ATTR_DOMAIN_POINT; } @@ -180,7 +180,7 @@ class CornersOfVertCountInput final : public bke::MeshFieldInput { return false; } - std::optional preferred_domain(const Mesh & /*mesh*/)const final + std::optional preferred_domain(const Mesh & /*mesh*/) const final { return ATTR_DOMAIN_POINT; } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc index af41ae03588..e46061e0d65 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges
[Bf-blender-cvs] [f04f9cc3d02] master: Cleanup: add unique_index_table to UvElementMap
Commit: f04f9cc3d02168ce6ef779954f9db39c8c734775 Author: Chris Blackbourn Date: Wed Nov 9 11:42:30 2022 +1300 Branches: master https://developer.blender.org/rBf04f9cc3d02168ce6ef779954f9db39c8c734775 Cleanup: add unique_index_table to UvElementMap In anticipation of UV Copy+Paste, we need fast access to indices of unique UvElements. Can also be used to improve performance and simplify code for UV Sculpt tools and UV Stitch. No user visible changes expected. Maniphest Tasks: T77911 See also: D16278 === M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/include/ED_mesh.h M source/blender/editors/mesh/editmesh_utils.c === diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index 9d9c2f57f89..d0813ebb168 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -63,6 +63,10 @@ typedef struct UvElement { * If islands are calculated, it also stores UvElements * belonging to the same uv island in sequence and * the number of uvs per island. + * + * \note in C++, #head_table and #unique_index_table would + * be `mutable`, as they are created on demand, and never + * changed after creation. */ typedef struct UvElementMap { /** UvElement Storage. */ @@ -78,6 +82,9 @@ typedef struct UvElementMap { /** If Non-NULL, pointer to local head of each unique UV. */ struct UvElement **head_table; + /** If Non-NULL, pointer to index of each unique UV. */ + int **unique_index_table; + /** Number of islands, or zero if not calculated. */ int total_islands; /** Array of starting index in #storage where each island begins. */ diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index c100bf9b60b..7dfebf58bef 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -142,12 +142,15 @@ struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm, bool use_seams, bool do_islands); void BM_uv_element_map_free(struct UvElementMap *element_map); -struct UvElement *BM_uv_element_get(const struct UvElementMap *map, +struct UvElement *BM_uv_element_get(const struct UvElementMap *element_map, const struct BMFace *efa, const struct BMLoop *l); -struct UvElement *BM_uv_element_get_head(struct UvElementMap *map, struct UvElement *child); +struct UvElement *BM_uv_element_get_head(struct UvElementMap *element_map, + struct UvElement *child); +int BM_uv_element_get_unique_index(struct UvElementMap *element_map, struct UvElement *child); struct UvElement **BM_uv_element_map_ensure_head_table(struct UvElementMap *element_map); +int **BM_uv_element_map_ensure_unique_index(struct UvElementMap *element_map); /** * Can we edit UV's for this mesh? diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index f6ffbec094e..33162cd2256 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -619,6 +619,44 @@ struct UvElement **BM_uv_element_map_ensure_head_table(struct UvElementMap *elem return element_map->head_table; } +int **BM_uv_element_map_ensure_unique_index(struct UvElementMap *element_map) +{ + if (!element_map->unique_index_table) { +element_map->unique_index_table = MEM_callocN( +element_map->total_uvs * sizeof(*element_map->unique_index_table), __func__); + +int j = 0; +for (int i = 0; i < element_map->total_uvs; i++) { + UvElement *element = element_map->storage + i; + if (!element->separate) { +continue; + } + BLI_assert(0 <= j); + BLI_assert(j < element_map->total_unique_uvs); + while (element) { +element_map->unique_index_table[element - element_map->storage] = j; +element = element->next; +if (!element || element->separate) { + break; +} + } + j++; +} +BLI_assert(j == element_map->total_unique_uvs); + } + + return element_map->unique_index_table; +} + +int BM_uv_element_get_unique_index(struct UvElementMap *element_map, struct UvElement *child) +{ + int **unique_index = BM_uv_element_map_ensure_unique_index(element_map); + int index = child - element_map->storage; + BLI_assert(0 <= index); + BLI_assert(index < element_map->total_uvs); + return unique_index[index]; +} + #define INVALID_ISLAND ((uint)-1) static void bm_uv_assign_island(UvElementMap *element_map, @@ -1163,6 +1201,7 @@ void BM_uv_element_map_free(
[Bf-blender-cvs] [c6aacd718a5] master: Cleanup: Improve precision during UV packing.
Commit: c6aacd718a51dea2f0736280a6bd605898a320f2 Author: Chris Blackbourn Date: Wed Nov 9 08:37:14 2022 +1300 Branches: master https://developer.blender.org/rBc6aacd718a51dea2f0736280a6bd605898a320f2 Cleanup: Improve precision during UV packing. Simplify API and improve accuracy of uv packing placement by using pre-translation and double precision internally. Will protect against future precision problems with UDIM. No user visible changes expected. Maniphest Tasks: T68889 Differential Revision: https://developer.blender.org/D16362 === M source/blender/bmesh/intern/bmesh_query_uv.cc M source/blender/bmesh/intern/bmesh_query_uv.h M source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/bmesh/intern/bmesh_query_uv.cc b/source/blender/bmesh/intern/bmesh_query_uv.cc index 33b2ca7a828..0e2385ff4e2 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.cc +++ b/source/blender/bmesh/intern/bmesh_query_uv.cc @@ -113,17 +113,6 @@ void BM_face_uv_minmax(const BMFace *f, float min[2], float max[2], const int cd } while ((l_iter = l_iter->next) != l_first); } -void BM_face_uv_transform(BMFace *f, const float matrix[2][2], const int cd_loop_uv_offset) -{ - BMLoop *l_iter; - BMLoop *l_first; - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { -MLoopUV *luv = (MLoopUV *)BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset); -mul_m2_v2(matrix, luv->uv); - } while ((l_iter = l_iter->next) != l_first); -} - bool BM_loop_uv_share_edge_check(BMLoop *l_a, BMLoop *l_b, const int cd_loop_uv_offset) { BLI_assert(l_a->e == l_b->e); diff --git a/source/blender/bmesh/intern/bmesh_query_uv.h b/source/blender/bmesh/intern/bmesh_query_uv.h index 2b0833f9185..6aa82653535 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.h +++ b/source/blender/bmesh/intern/bmesh_query_uv.h @@ -34,7 +34,6 @@ float BM_face_uv_calc_cross(const BMFace *f, int cd_loop_uv_offset) ATTR_WARN_UN ATTR_NONNULL(); void BM_face_uv_minmax(const BMFace *f, float min[2], float max[2], int cd_loop_uv_offset); -void BM_face_uv_transform(BMFace *f, const float matrix[2][2], int cd_loop_uv_offset); bool BM_loop_uv_share_edge_check_with_limit(BMLoop *l_a, BMLoop *l_b, diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 92745667505..d8e10435146 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -36,29 +36,48 @@ #include "bmesh.h" -/* */ -/** \name UV Face Utilities - * \{ */ +static void mul_v2_m2_add_v2v2(float r[2], + const float mat[2][2], + const float a[2], + const float b[2]) +{ + /* Compute `r = mat * (a + b)` with high precision. */ + const double x = static_cast(a[0]) + static_cast(b[0]); + const double y = static_cast(a[1]) + static_cast(b[1]); + + r[0] = static_cast(mat[0][0] * x + mat[1][0] * y); + r[1] = static_cast(mat[0][1] * x + mat[1][1] * y); +} -static void bm_face_uv_translate_and_scale_around_pivot(BMFace *f, -const float offset[2], -const float scale[2], -const float pivot[2], -const int cd_loop_uv_offset) +static void island_uv_transform(FaceIsland *island, +const float matrix[2][2],/* Scale and rotation. */ +const float pre_translate[2] /* (pre) Translation. */ +) { - BMLoop *l_iter; - BMLoop *l_first; - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { -MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset)); -for (int i = 0; i < 2; i++) { - luv->uv[i] = offset[i] + (((luv->uv[i] - pivot[i]) * scale[i]) + pivot[i]); + /* Use a pre-transform to compute `A * (x+b)` + * + * \note Ordinarily, we'd use a post_transform like `A * x + b` + * In general, post-transforms are easier to work with when using homogenous co-ordinates. + * + * When UV mapping into the unit square, post-transforms can lose precision on small islands. + * Instead we're using a pre-transform to maintain precision. + * + * To convert post-transform to pre-transform, use `A * x + b == A * (x + c), c = A^-1 * b` + */ + + const int cd_loop_uv_offset = island->cd_loop_uv_offset; + const int faces_len = island->faces_len; + for (int i = 0; i < faces_len; i++) { +BMFace *f = island->faces[i]; +BMLoop *l; +BMIter ite
[Bf-blender-cvs] [4b57bc4e5d4] master: Cleanup: format
Commit: 4b57bc4e5d4cada4a40d51745cc951f69f9aab08 Author: Chris Blackbourn Date: Wed Nov 9 08:30:18 2022 +1300 Branches: master https://developer.blender.org/rB4b57bc4e5d4cada4a40d51745cc951f69f9aab08 Cleanup: format === M intern/cycles/device/cuda/device_impl.cpp M intern/cycles/device/cuda/device_impl.h M source/blender/blenloader/intern/versioning_legacy.c M source/blender/nodes/texture/nodes/node_texture_curves.c === diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index b56765208ee..c9764d1c21b 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -232,7 +232,7 @@ string CUDADevice::compile_kernel_get_common_cflags(const uint kernel_features) return cflags; } -string CUDADevice::compile_kernel(const string& common_cflags, +string CUDADevice::compile_kernel(const string _cflags, const char *name, const char *base, bool force_ptx) diff --git a/intern/cycles/device/cuda/device_impl.h b/intern/cycles/device/cuda/device_impl.h index bd6d806561b..c18f2811161 100644 --- a/intern/cycles/device/cuda/device_impl.h +++ b/intern/cycles/device/cuda/device_impl.h @@ -79,7 +79,7 @@ class CUDADevice : public Device { string compile_kernel_get_common_cflags(const uint kernel_features); - string compile_kernel(const string& cflags, + string compile_kernel(const string , const char *name, const char *base = "cuda", bool force_ptx = false); diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 23d514a7b12..8685db377d4 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -58,11 +58,11 @@ #include "BKE_lattice.h" #include "BKE_main.h" /* for Main */ #include "BKE_mesh.h" /* for ME_ defines (patching) */ +#include "BKE_mesh_legacy_convert.h" #include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_mesh_legacy_convert.h" #include "SEQ_iterator.h" #include "SEQ_sequencer.h" diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index df75847dbe3..bdee2adb1ba 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -104,9 +104,8 @@ void register_node_type_tex_curve_rgb(void) node_type_size_preset(, NODE_SIZE_LARGE); ntype.initfunc = rgb_init; node_type_storage(, "CurveMapping", node_free_curves, node_copy_curves); - ntype.init_exec_fn = node_initexec_curves ; - ntype.exec_fn =rgb_exec ; - + ntype.init_exec_fn = node_initexec_curves; + ntype.exec_fn = rgb_exec; nodeRegisterType(); } ___ 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] [c3e4fa74044] master: Cleanup: fix translation for rare UV unwrapping with unit scale
Commit: c3e4fa74044a5a2a38ec28cf66be45c98f982501 Author: Chris Blackbourn Date: Tue Nov 1 12:50:16 2022 +1300 Branches: master https://developer.blender.org/rBc3e4fa74044a5a2a38ec28cf66be45c98f982501 Cleanup: fix translation for rare UV unwrapping with unit scale Fixes very rare cases where the UV Cylinder Project, UV Sphere Project and UV From View might not set the translation correctly if the scale is exactly 1.0. Mainly fixed because this code might later be reused elsewhere. === M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index ecaba3234a7..92efaf79de7 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1774,8 +1774,8 @@ static void uv_map_clip_correct(const Scene *scene, dy = 1.0f / dy; } -if (dx == 1.0f && dy == 1.0f) { - /* Scaling by 1.0 has no effect. */ +if (dx == 1.0f && dy == 1.0f && min[0] == 0.0f && min[1] == 0.0f) { + /* Scaling by 1.0, without translating, has no effect. */ 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] [4a87f8107eb] master: Cleanup: format
Commit: 4a87f8107ebbb4da33ea278a1e7dcd75aba96b7b Author: Chris Blackbourn Date: Wed Oct 26 09:33:22 2022 +1300 Branches: master https://developer.blender.org/rB4a87f8107ebbb4da33ea278a1e7dcd75aba96b7b Cleanup: format === M source/blender/draw/intern/draw_manager_data.cc === diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index b9e0db71122..792db9d0a6b 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -695,7 +695,7 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob) drw_call_calc_orco(ob, ob_infos->orcotexfac); /* Random float value. */ uint random = (DST.dupli_source) ? -DST.dupli_source->random_id : + DST.dupli_source->random_id : /* TODO(fclem): this is rather costly to do at runtime. Maybe we can * put it in ob->runtime and make depsgraph ensure it is up to date. */ BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0); ___ 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] [e3075f3cf7c] master: Cleanup: simplify uv packing api
Commit: e3075f3cf7ce2fae086f3cd09867e4f0455e4115 Author: Chris Blackbourn Date: Thu Oct 20 12:35:17 2022 +1300 Branches: master https://developer.blender.org/rBe3075f3cf7ce2fae086f3cd09867e4f0455e4115 Cleanup: simplify uv packing api Part of a wider set of changes to migrate UV packing from uv_parametrizer.cc to uvedit_islands.cc. This allows UV packing improvements including margin calculation, correctness fixes such as support for non-manifold geometry, and new packing algorithms including speed and quality improvements. See for example c2256bf7f714, T82637 This change migrates UV.unwrap and Live UV Unwrap. Differential Revision: https://developer.blender.org/D16296 === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index c8ffbb9acb1..b97cd6a9099 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -345,12 +345,14 @@ typedef enum { ED_UVPACK_MARGIN_FRACTION, /* Specify a precise fraction of final UV output. */ } eUVPackIsland_MarginMethod; +/** See also #UnwrapOptions. */ struct UVPackIsland_Params { uint rotate : 1; uint only_selected_uvs : 1; uint only_selected_faces : 1; uint use_seams : 1; uint correct_aspect : 1; + bool ignore_pinned; /* Ignore islands which have any pinned UVs. */ eUVPackIsland_MarginMethod margin_method; /* Which formula to use when scaling island margin. */ float margin; /* Additional space to add around each island. */ }; diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index bdd05b06d94..92745667505 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -600,6 +600,22 @@ static BoxPack *pack_islands_params(const blender::Vector _ return box_array; } +static bool island_has_pins(FaceIsland *island) +{ + BMLoop *l; + BMIter iter; + const int cd_loop_uv_offset = island->cd_loop_uv_offset; + for (int i = 0; i < island->faces_len; i++) { +BM_ITER_ELEM (l, , island->faces[i], BM_LOOPS_OF_FACE) { + MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset)); + if (luv->flag & MLOOPUV_PINNED) { +return true; + } +} + } + return false; +} + /* */ /** \name Public UV Island Packing * @@ -651,8 +667,14 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, aspect_y, cd_loop_uv_offset); -int index; -LISTBASE_FOREACH_INDEX (struct FaceIsland *, island, _list, index) { +/* Remove from linked list and append to blender::Vector. */ +LISTBASE_FOREACH_MUTABLE (struct FaceIsland *, island, _list) { + BLI_remlink(_list, island); + if (params->ignore_pinned && island_has_pins(island)) { +MEM_freeN(island->faces); +MEM_freeN(island); +continue; + } island_vector.append(island); } } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 2c977552e72..ecaba3234a7 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1050,31 +1050,6 @@ void UV_OT_minimize_stretch(wmOperatorType *ot) /** \name Pack UV Islands Operator * \{ */ -/** - * \warning Since this uses #ParamHandle it doesn't work with non-manifold meshes (see T82637). - * Use #ED_uvedit_pack_islands_multi for a more general solution. - * - * TODO: remove this function, in favor of #ED_uvedit_pack_islands_multi. - */ -static void uvedit_pack_islands_multi(const Scene *scene, - Object **objects, - const uint objects_len, - const UnwrapOptions *options, - bool rotate, - bool ignore_pinned) -{ - ParamHandle *handle = construct_param_handle_multi(scene, objects, objects_len, options); - GEO_uv_parametrizer_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned); - GEO_uv_parametrizer_flush(handle); - GEO_uv_parametrizer_delete(handle); - - for (uint ob_index = 0; ob_index < objects_len; ob_index++) { -Object *obedit = objects[ob_index]; -DEG_id_tag_update(obedit->data, ID_RECALC_GEOMETRY); -WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data); - } -} - /* Packing
[Bf-blender-cvs] [ba6f25dd1b6] master: Fix T101907: restore snapping in node editor
Commit: ba6f25dd1b6d746c361d78b9c6c898ff96fd50d4 Author: Chris Blackbourn Date: Thu Oct 20 10:10:39 2022 +1300 Branches: master https://developer.blender.org/rBba6f25dd1b6d746c361d78b9c6c898ff96fd50d4 Fix T101907: restore snapping in node editor Regression from 1edebb794b76 === M source/blender/editors/transform/transform_snap.c === diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 553202b5798..06aec3b45a6 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -523,6 +523,10 @@ void applyGridAbsolute(TransInfo *t) float grid_size_y = (t->modifiers & MOD_PRECISION) ? t->snap_spatial_y[1] : t->snap_spatial_y[0]; float grid_size_z = grid_size_x; + if (grid_size_y == 0.0f) { +grid_size_y = grid_size_x; /* Just use `grid_size_x` when `grid_size_y` isn't set correctly. */ + } + /* Early exit on unusable grid size. */ if (grid_size_x == 0.0f || grid_size_y == 0.0f || grid_size_z == 0.0f) { 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] [1edebb794b7] master: UV: support snapping on non-uniform grids
Commit: 1edebb794b76326e06b527fd0a04eba34d51ab7c Author: Chris Blackbourn Date: Tue Oct 18 15:59:35 2022 +1300 Branches: master https://developer.blender.org/rB1edebb794b76326e06b527fd0a04eba34d51ab7c UV: support snapping on non-uniform grids Part of a wider set of changes to Grid and Pixel snapping in the UV Editor. This change fixes snapping behavior for non-uniform grids, either manually specified Fixed grids, or pixel grids where the underlying image is non-square. See a24fc6bbc1ae for visual changes. Maniphest Tasks: T78391 Differential Revision: https://developer.blender.org/D16275 === M source/blender/editors/transform/transform.c M source/blender/editors/transform/transform.h M source/blender/editors/transform/transform_mode_translate.c M source/blender/editors/transform/transform_snap.c === diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 93e99f97387..34e5b78c48f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -60,8 +60,6 @@ * and being able to set it to zero is handy. */ /* #define USE_NUM_NO_ZERO */ -static void initSnapSpatial(TransInfo *t, float r_snap[2]); - bool transdata_check_local_islands(TransInfo *t, short around) { if (t->options & (CTX_CURSOR | CTX_TEXTURE_SPACE)) { @@ -1723,7 +1721,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } -static void initSnapSpatial(TransInfo *t, float r_snap[2]) +static void initSnapSpatial(TransInfo *t, float r_snap[2], float r_snap_y[2]) { if (t->spacetype == SPACE_VIEW3D) { if (t->region->regiondata) { @@ -1737,18 +1735,15 @@ static void initSnapSpatial(TransInfo *t, float r_snap[2]) View2D *v2d = >region->v2d; int grid_size = SI_GRID_STEPS_LEN; float zoom_factor = ED_space_image_zoom_level(v2d, grid_size); -float grid_steps[SI_GRID_STEPS_LEN]; +float grid_steps_x[SI_GRID_STEPS_LEN]; float grid_steps_y[SI_GRID_STEPS_LEN]; -ED_space_image_grid_steps(sima, grid_steps, grid_steps_y, grid_size); +ED_space_image_grid_steps(sima, grid_steps_x, grid_steps_y, grid_size); /* Snapping value based on what type of grid is used (adaptive-subdividing or custom-grid). */ -r_snap[0] = ED_space_image_increment_snap_value(grid_size, grid_steps, zoom_factor); +r_snap[0] = ED_space_image_increment_snap_value(grid_size, grid_steps_x, zoom_factor); r_snap[1] = r_snap[0] / 2.0f; - -/* TODO: Implement snapping for custom grid sizes with `grid_steps[0] != grid_steps_y[0]`. - * r_snap_y[0] = ED_space_image_increment_snap_value(grid_size, grid_steps_y, zoom_factor); - * r_snap_y[1] = r_snap_y[0] / 2.0f; - */ +r_snap_y[0] = ED_space_image_increment_snap_value(grid_size, grid_steps_y, zoom_factor); +r_snap_y[1] = r_snap_y[0] / 2.0f; } else if (t->spacetype == SPACE_CLIP) { r_snap[0] = 0.125f; @@ -1903,7 +1898,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve initSnapping(t, op); /* Initialize snapping data AFTER mode flags */ - initSnapSpatial(t, t->snap_spatial); + initSnapSpatial(t, t->snap_spatial_x, t->snap_spatial_y); /* EVIL! posemode code can switch translation to rotate when 1 bone is selected. * will be removed (ton) */ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index e2bab378cad..95686f12fe2 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -555,7 +555,9 @@ typedef struct TransInfo { /** Snapping Gears. */ float snap[2]; /** Spatial snapping gears(even when rotating, scaling... etc). */ - float snap_spatial[2]; + float snap_spatial_x[2]; + /** Spatial snapping in the Y coordinate, for non-uniform grid in UV Editor. */ + float snap_spatial_y[2]; /** Mouse side of the current frame, 'L', 'R' or 'B' */ char frame_side; diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index 8f6ec7bd98f..91388ecd661 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -590,7 +590,7 @@ void initTranslation(TransInfo *t) t->num.flag = 0; t->num.idx_max = t->idx_max; - copy_v2_v2(t->snap, t->snap_spatial); + copy_v2_v2(t->snap, t->snap_spatial_x); copy_v3_fl(t->num.val_inc, t->snap[0]); t->num.unit_sys = t->scene->unit.system; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 3f9cca55138..553202b5798 100644 --- a/source/blender/edi
[Bf-blender-cvs] [4767a8eb4aa] master: Cleanup: simplify uv packing api
Commit: 4767a8eb4aae460ecbee8e6c3eacf4aa81a24c07 Author: Chris Blackbourn Date: Thu Oct 13 23:06:52 2022 +1300 Branches: master https://developer.blender.org/rB4767a8eb4aae460ecbee8e6c3eacf4aa81a24c07 Cleanup: simplify uv packing api Affects paint.add_simple_uvs No user visible changes. Differential Revision: https://developer.blender.org/D16231 === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index e485fd2b061..c8ffbb9acb1 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -361,9 +361,24 @@ struct UVPackIsland_Params { bool uv_coords_isect_udim(const struct Image *image, const int udim_grid[2], const float coords[2]); + +/** + * Pack UV islands from multiple objects. + * + * \param scene: Scene containing the objects to be packed. + * \param objects: Array of Objects to pack. + * \param objects_len: Length of `objects` array. + * \param bmesh_override: BMesh array aligned with `objects`. + * Optional, when non-null this overrides object's BMesh. + * This is needed to perform UV packing on objects that aren't in edit-mode. + * \param udim_params: Parameters to specify UDIM target and UDIM source image. + * \param params: Parameters and options to pass to the packing engine. + * + */ void ED_uvedit_pack_islands_multi(const struct Scene *scene, Object **objects, uint objects_len, + struct BMesh **bmesh_override, const struct UVMapUDIM_Params *udim_params, const struct UVPackIsland_Params *params); diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 4009447ba7e..bdd05b06d94 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -609,6 +609,7 @@ static BoxPack *pack_islands_params(const blender::Vector _ void ED_uvedit_pack_islands_multi(const Scene *scene, Object **objects, const uint objects_len, + BMesh **bmesh_override, const struct UVMapUDIM_Params *udim_params, const struct UVPackIsland_Params *params) { @@ -616,9 +617,17 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; -BMEditMesh *em = BKE_editmesh_from_object(obedit); - -const int cd_loop_uv_offset = CustomData_get_offset(>bm->ldata, CD_MLOOPUV); +BMesh *bm = nullptr; +if (bmesh_override) { + /* Note: obedit is still required for aspect ratio and ID_RECALC_GEOMETRY. */ + bm = bmesh_override[ob_index]; +} +else { + BMEditMesh *em = BKE_editmesh_from_object(obedit); + bm = em->bm; +} +BLI_assert(bm); +const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); if (cd_loop_uv_offset == -1) { continue; } @@ -634,7 +643,7 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, ListBase island_list = {nullptr}; bm_mesh_calc_uv_islands(scene, -em->bm, +bm, _list, params->only_selected_faces, params->only_selected_uvs, diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index cedca88de6a..2c977552e72 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1050,25 +1050,6 @@ void UV_OT_minimize_stretch(wmOperatorType *ot) /** \name Pack UV Islands Operator * \{ */ -static void uvedit_pack_islands(const Scene *scene, Object *ob, BMesh *bm) -{ - const UnwrapOptions options = { - .topology_from_uvs = true, - .only_selected_faces = false, - .only_selected_uvs = true, - .fill_holes = false, - .correct_aspect = false, - }; - - bool rotate = true; - bool ignore_pinned = false; - - ParamHandle *handle = construct_param_handle(scene, ob, bm, , NULL); - GEO_uv_parametrizer_pack(handle, scene->toolsettings->uvcalc_margin, rotate, ignore_pinned); - GEO_uv_parametrizer_flush(handle); - GEO_uv_parametrizer_delete(handle); -} - /** * \warning Since this uses #ParamHandle it doesn't
[Bf-blender-cvs] [b7decab07ef] master: UV: add grid shape source to the uv editor, and add new "pixel" option
Commit: b7decab07ef85aeda1be3391c2e85e3265b12091 Author: Chris Blackbourn Date: Wed Oct 12 11:26:14 2022 +1300 Branches: master https://developer.blender.org/rBb7decab07ef85aeda1be3391c2e85e3265b12091 UV: add grid shape source to the uv editor, and add new "pixel" option This change is part of a wider set of changes to implement Grid and Pixel snapping in the UV Editor. This particular change adds a new third option, `pixel grid`, to the previous grid options, `dynamic grid` and `fixed grid`. Maniphest Tasks : T78391 Differential Revision: https://developer.blender.org/D16197 === M release/scripts/startup/bl_ui/space_image.py M source/blender/blenloader/intern/versioning_280.c M source/blender/blenloader/intern/versioning_300.cc M source/blender/draw/engines/overlay/overlay_grid.cc M source/blender/editors/space_image/image_draw.c M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index cefa4bf7d1d..fcbd7bb423d 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -1528,36 +1528,23 @@ class IMAGE_PT_overlay_guides(Panel): layout.active = overlay.show_overlays row = layout.row() -row_el = row.column() -row_el.prop(overlay, "show_grid_background", text="Grid") +row.prop(overlay, "show_grid_background", text="Grid") if overlay.show_grid_background: -layout.use_property_split = True - -col = layout.column(align=False, heading="Grid Over Image") -col.use_property_decorate = False -row = col.row(align=True) -sub = row.row(align=True) -sub.prop(uvedit, "show_grid_over_image", text="") +sub = row.row() +sub.prop(uvedit, "show_grid_over_image", text="Over Image") sub.active = sima.image is not None -col = layout.column(align=False, heading="Fixed Subdivisions") -col.use_property_decorate = False +layout.row().prop(uvedit, "grid_shape_source", expand=True) -row = col.row(align=True) -sub = row.row(align=True) -sub.prop(uvedit, "use_custom_grid", text="") -if uvedit.use_custom_grid: -row = layout.row() -row.use_property_split = True -row.use_property_decorate = False -sub = sub.row(align=True) -sub.prop(uvedit, "custom_grid_subdivisions", text="") +layout.use_property_split = True +layout.use_property_decorate = False row = layout.row() -row.use_property_split = True -row.use_property_decorate = False -row.prop(uvedit, "tile_grid_shape", text="Tiles") +row.prop(uvedit, "custom_grid_subdivisions", text="Fixed Subdivisions") +row.active = uvedit.grid_shape_source == 'FIXED' + +layout.prop(uvedit, "tile_grid_shape", text="Tiles") class IMAGE_PT_overlay_uv_edit(Panel): diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 061840aee7a..1a8fec49516 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3379,7 +3379,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) SpaceImage *sima = (SpaceImage *)sl; sima->flag &= ~(SI_FLAG_UNUSED_0 | SI_FLAG_UNUSED_1 | SI_FLAG_UNUSED_3 | SI_FLAG_UNUSED_6 | SI_FLAG_UNUSED_7 | SI_FLAG_UNUSED_8 | - SI_FLAG_UNUSED_17 | SI_CUSTOM_GRID | SI_FLAG_UNUSED_23 | + SI_FLAG_UNUSED_17 | SI_FLAG_UNUSED_18 | SI_FLAG_UNUSED_23 | SI_FLAG_UNUSED_24); break; } diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 0584dd6b059..5328107e1f2 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -3604,6 +3604,13 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) v3d->overlay.flag |= V3D_OVERLAY_VIEWER_ATTRIBUTE; v3d->overlay.viewer_attribute_opacity = 1.0f; } + if (sl->spacetype == SPACE_IMAGE) { +
[Bf-blender-cvs] [c2256bf7f71] master: Fix T90782: add uv pack option to specify margin as a fraction
Commit: c2256bf7f714bbd41388af3e184b3d84b496fbf3 Author: Chris Blackbourn Date: Wed Oct 12 10:57:17 2022 +1300 Branches: master https://developer.blender.org/rBc2256bf7f714bbd41388af3e184b3d84b496fbf3 Fix T90782: add uv pack option to specify margin as a fraction A refactor of the margin calculation of UV packing, in anticipation of multiple packing methods soon becoming available. Three margin scaling methods are now available: * "Add", Simple method, just add the margin. [0] (The default margin scale from Blender 2.8 and earlier.) * "Scaled", Use scale of existing UVs to multiply margin. (The default from Blender 3.3+) * "Fraction", a new (slow) method to precisely specify a fraction of the UV unit square for margin. [1] The "fraction" code path implements a novel combined search / secant root finding method which exploits domain knowledge to accelerate convergence while remaining robust against bad input. [0]: Resolves T85978 [1]: Resolves T90782 Differential Revision: https://developer.blender.org/D16121 === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index b499ae0ce59..e485fd2b061 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -339,12 +339,20 @@ bool ED_uvedit_udim_params_from_image_space(const struct SpaceImage *sima, bool use_active, struct UVMapUDIM_Params *udim_params); +typedef enum { + ED_UVPACK_MARGIN_SCALED = 0, /* Use scale of existing UVs to multiply margin. */ + ED_UVPACK_MARGIN_ADD,/* Just add the margin, ignoring any UV scale. */ + ED_UVPACK_MARGIN_FRACTION, /* Specify a precise fraction of final UV output. */ +} eUVPackIsland_MarginMethod; + struct UVPackIsland_Params { uint rotate : 1; uint only_selected_uvs : 1; uint only_selected_faces : 1; uint use_seams : 1; uint correct_aspect : 1; + eUVPackIsland_MarginMethod margin_method; /* Which formula to use when scaling island margin. */ + float margin; /* Additional space to add around each island. */ }; /** diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 2648ec5e2f6..4009447ba7e 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -403,6 +403,203 @@ int bm_mesh_calc_uv_islands(const Scene *scene, /** \} */ +static float pack_islands_scale_margin(const blender::Vector _vector, + BoxPack *box_array, + const float scale, + const float margin) +{ + for (const int index : island_vector.index_range()) { +FaceIsland *island = island_vector[index]; +BoxPack *box = _array[index]; +box->index = index; +box->w = BLI_rctf_size_x(>bounds_rect) * scale + 2 * margin; +box->h = BLI_rctf_size_y(>bounds_rect) * scale + 2 * margin; + } + float max_u, max_v; + BLI_box_pack_2d(box_array, island_vector.size(), _u, _v); + return max_ff(max_u, max_v); +} + +static float pack_islands_margin_fraction(const blender::Vector _vector, + BoxPack *box_array, + const float margin_fraction) +{ + /* + * Root finding using a combined search / modified-secant method. + * First, use a robust search procedure to bracket the root within a factor of 10. + * Then, use a modified-secant method to converge. + * + * This is a specialized solver using domain knowledge to accelerate convergence. + */ + + float scale_low = 0.0f; + float value_low = 0.0f; + float scale_high = 0.0f; + float value_high = 0.0f; + float scale_last = 0.0f; + + /* Scaling smaller than `min_scale_roundoff` is unlikely to fit and + * will destroy information in existing UVs. */ + float min_scale_roundoff = 1e-5f; + + /* Certain inputs might have poor convergence properties. + * Use `max_iteration` to prevent an infinite loop. */ + int max_iteration = 25; + for (int iteration = 0; iteration < max_iteration; iteration++) { +float scale = 1.0f; + +if (iteration == 0) { + BLI_assert(iteration == 0); + BLI_assert(scale == 1.0f); + BLI_assert(scale_low == 0.0f); + BLI_assert(scale_high == 0.0f); +} +else if (scale_low == 0.0f) { + BLI_assert(scale_high > 0.0f); + /* Search mode, shrink layout until we can find a scale tha
[Bf-blender-cvs] [170e03aa98b] blender-v2.93-release: Fix T101138: remove console spam when hovering over toolbar in uv editor
Commit: 170e03aa98b20d9444884d37ae8fe8b48426fde4 Author: Chris Blackbourn Date: Wed Sep 21 09:34:11 2022 +1200 Branches: blender-v2.93-release https://developer.blender.org/rB170e03aa98b20d9444884d37ae8fe8b48426fde4 Fix T101138: remove console spam when hovering over toolbar in uv editor Reviewers: Campbell Barton , Ryan Inch Differential Revision: https://developer.blender.org/D16015 === M release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py === diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py index ef398d5e08f..c1e6a5c6c77 100644 --- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py +++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py @@ -191,7 +191,7 @@ def generate(context, space_type, use_fallback_keys=True, use_reset=True): mode = context.active_object.mode # See: BKE_paint_get_tool_prop_id_from_paintmode if space_type == 'IMAGE_EDITOR': -if context.space_data.ui_mode == 'PAINT': +if context.space_data.mode == 'PAINT': attr = "image_tool" else: attr = None @@ -217,7 +217,7 @@ def generate(context, space_type, use_fallback_keys=True, use_reset=True): properties=kmi_hack_brush_select_properties, include={'KEYBOARD'}, )[1] -elif mode in {'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: +elif mode in {'EDIT', 'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: # Doesn't use brushes pass else: ___ 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] [e5ccbfab09f] master: Cleanup: simplify uv packing for non-square materials
Commit: e5ccbfab09ff427ee2b31c5452c6fc63dff4ec59 Author: Chris Blackbourn Date: Sat Oct 1 17:29:14 2022 +1300 Branches: master https://developer.blender.org/rBe5ccbfab09ff427ee2b31c5452c6fc63dff4ec59 Cleanup: simplify uv packing for non-square materials === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_islands.cc M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 38e542fc0ca..23cbcabbc0e 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -341,8 +341,6 @@ bool ED_uvedit_udim_params_from_image_space(const struct SpaceImage *sima, struct UVPackIsland_Params { uint rotate : 1; - /** -1 not to align to axis, otherwise 0,1 for X,Y. */ - int rotate_align_axis : 2; uint only_selected_uvs : 1; uint only_selected_faces : 1; uint use_seams : 1; diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 1ac2985aafb..c226ad4c461 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -40,17 +40,6 @@ /** \name UV Face Utilities * \{ */ -static void bm_face_uv_scale_y(BMFace *f, const float scale_y, const int cd_loop_uv_offset) -{ - BMLoop *l_iter; - BMLoop *l_first; - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { -MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset)); -luv->uv[1] *= scale_y; - } while ((l_iter = l_iter->next) != l_first); -} - static void bm_face_uv_translate_and_scale_around_pivot(BMFace *f, const float offset[2], const float scale[2], @@ -159,68 +148,66 @@ static float (*bm_face_array_calc_unique_uv_coords( return coords; } -/** - * \param align_to_axis: - * - -1: don't align to an axis. - * - 0: align horizontally. - * - 1: align vertically. - */ -static void bm_face_array_uv_rotate_fit_aabb(BMFace **faces, - int faces_len, - int align_to_axis, - const int cd_loop_uv_offset) +static void face_island_uv_rotate_fit_aabb(FaceIsland *island) { + BMFace **faces = island->faces; + const int faces_len = island->faces_len; + const float aspect_y = island->aspect_y; + const int cd_loop_uv_offset = island->cd_loop_uv_offset; + /* Calculate unique coordinates since calculating a convex hull can be an expensive operation. */ int coords_len; float(*coords)[2] = bm_face_array_calc_unique_uv_coords( faces, faces_len, cd_loop_uv_offset, _len); - float angle = BLI_convexhull_aabb_fit_points_2d(coords, coords_len); - - if (align_to_axis != -1) { -if (angle != 0.0f) { - float matrix[2][2]; - angle_to_mat2(matrix, angle); - for (int i = 0; i < coords_len; i++) { -mul_m2_v2(matrix, coords[i]); - } + /* Correct aspect ratio. */ + if (aspect_y != 1.0f) { +for (int i = 0; i < coords_len; i++) { + coords[i][1] /= aspect_y; } + } -float bounds_min[2], bounds_max[2]; -INIT_MINMAX2(bounds_min, bounds_max); + float angle = BLI_convexhull_aabb_fit_points_2d(coords, coords_len); + + /* Rotate coords by `angle` before computing bounding box. */ + if (angle != 0.0f) { +float matrix[2][2]; +angle_to_mat2(matrix, angle); +matrix[0][1] *= aspect_y; +matrix[1][1] *= aspect_y; for (int i = 0; i < coords_len; i++) { - minmax_v2v2_v2(bounds_min, bounds_max, coords[i]); + mul_m2_v2(matrix, coords[i]); } + } -float size[2]; -sub_v2_v2v2(size, bounds_max, bounds_min); -if (align_to_axis ? (size[1] < size[0]) : (size[0] < size[1])) { - angle += DEG2RAD(90.0); -} + /* Compute new AABB. */ + float bounds_min[2], bounds_max[2]; + INIT_MINMAX2(bounds_min, bounds_max); + for (int i = 0; i < coords_len; i++) { +minmax_v2v2_v2(bounds_min, bounds_max, coords[i]); + } + + float size[2]; + sub_v2_v2v2(size, bounds_max, bounds_min); + if (size[1] < size[0]) { +angle += DEG2RADF(90.0f); } MEM_freeN(coords); + /* Apply rotation back to BMesh. */ if (angle != 0.0f) { float matrix[2][2]; angle_to_mat2(matrix, angle); +matrix[1][0] *= 1.0f / aspect_y; +/* matrix[1][1] *= aspect_y / aspect_y; */ +matrix[0][1] *= aspect_y; for (int i = 0; i < faces_len; i++) { BM_face_uv_transform(faces[i], matrix, cd_loop_uv_offset); } } } -static void bm_face_array_uv_scale_y(BMFace **faces, -
[Bf-blender-cvs] [aa7449e691f] blender-v3.3-release: Fix T101138: remove console spam when hovering over toolbar in uv editor
Commit: aa7449e691f54b58d0a5af7986b2f7bf57e1d056 Author: Chris Blackbourn Date: Wed Sep 21 09:34:11 2022 +1200 Branches: blender-v3.3-release https://developer.blender.org/rBaa7449e691f54b58d0a5af7986b2f7bf57e1d056 Fix T101138: remove console spam when hovering over toolbar in uv editor Reviewers: Campbell Barton , Ryan Inch Differential Revision: https://developer.blender.org/D16015 === M release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py === diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py index f75a38c1c66..09a55827128 100644 --- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py +++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py @@ -173,7 +173,7 @@ def generate(context, space_type, *, use_fallback_keys=True, use_reset=True): mode = context.active_object.mode # See: BKE_paint_get_tool_prop_id_from_paintmode if space_type == 'IMAGE_EDITOR': -if context.space_data.ui_mode == 'PAINT': +if context.space_data.mode == 'PAINT': attr = "image_tool" else: attr = None @@ -200,7 +200,7 @@ def generate(context, space_type, *, use_fallback_keys=True, use_reset=True): properties=kmi_hack_brush_select_properties, include={'KEYBOARD'}, )[1] -elif mode in {'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: +elif mode in {'EDIT', 'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: # Doesn't use brushes pass else: ___ 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] [91db47e914e] master: Cleanup: simplify storage when uv island packing
Commit: 91db47e914e73f619b0b6f70a8c04e77794bab5f Author: Chris Blackbourn Date: Thu Sep 29 15:44:30 2022 +1300 Branches: master https://developer.blender.org/rB91db47e914e73f619b0b6f70a8c04e77794bab5f Cleanup: simplify storage when uv island packing Refactor ahead of upcoming packing changes. Differential Revision: https://developer.blender.org/D16096 === M source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index d28aba9816f..1ac2985aafb 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -75,7 +75,7 @@ static void bm_face_uv_translate_and_scale_around_pivot(BMFace *f, * \{ */ static void bm_face_array_calc_bounds(BMFace **faces, - int faces_len, + const int faces_len, const int cd_loop_uv_offset, rctf *r_bounds_rect) { @@ -276,7 +276,7 @@ static float uv_nearest_image_tile_distance(const Image *image, * Calculates distance to nearest UDIM grid tile in UV space and its UDIM tile number. */ static float uv_nearest_grid_tile_distance(const int udim_grid[2], - float coords[2], + const float coords[2], float nearest_tile_co[2]) { const float coords_floor[2] = {floorf(coords[0]), floorf(coords[1])}; @@ -419,7 +419,7 @@ int bm_mesh_calc_uv_islands(const Scene *scene, /* */ /** \name Public UV Island Packing * - * \note This behavior follows #param_pack. + * \note This behavior loosely follows #GEO_uv_parametrizer_pack. * \{ */ void ED_uvedit_pack_islands_multi(const Scene *scene, @@ -428,17 +428,13 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, const struct UVMapUDIM_Params *udim_params, const struct UVPackIsland_Params *params) { - /* Align to the Y axis, could make this configurable. */ - const int rotate_align_axis = 1; - ListBase island_list = {NULL}; - int island_list_len = 0; + blender::Vector island_vector; for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; BMEditMesh *em = BKE_editmesh_from_object(obedit); -BMesh *bm = em->bm; -const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); +const int cd_loop_uv_offset = CustomData_get_offset(>bm->ldata, CD_MLOOPUV); if (cd_loop_uv_offset == -1) { continue; } @@ -452,34 +448,38 @@ void ED_uvedit_pack_islands_multi(const Scene *scene, } } -island_list_len += bm_mesh_calc_uv_islands(scene, - bm, - _list, - params->only_selected_faces, - params->only_selected_uvs, - params->use_seams, - aspect_y, - cd_loop_uv_offset); +ListBase island_list = {NULL}; +bm_mesh_calc_uv_islands(scene, +em->bm, +_list, +params->only_selected_faces, +params->only_selected_uvs, +params->use_seams, +aspect_y, +cd_loop_uv_offset); + +int index; +LISTBASE_FOREACH_INDEX (struct FaceIsland *, island, _list, index) { + island_vector.append(island); +} } - if (island_list_len == 0) { + if (island_vector.size() == 0) { return; } float margin = scene->toolsettings->uvcalc_margin; double area = 0.0f; - struct FaceIsland **island_array = static_cast( - MEM_mallocN(sizeof(*island_array) * island_list_len, __func__)); BoxPack *boxarray = static_cast( - MEM_mallocN(sizeof(*boxarray) * island_list_len, __func__)); + MEM_mallocN(sizeof(*boxarray) * island_vector.size(), __func__)); - int index; /* Coordinates of bounding box containing all selected UVs. */ float selection_min_co[2], selection_max_co[2]; INIT_MINMAX2(selection_min_co, selection_max_co); - LISTBASE_FOREACH_INDEX (struct FaceIsland *, island, _list, index) { + for (int index = 0; index < island_vector.size(); index++) { +FaceIsland *island = island_vector[index]; /* Skip calculation if using s
[Bf-blender-cvs] [5beaecb33e7] master: Fix T101414: in 3d viewport, smart uv project failed to pack
Commit: 5beaecb33e74abbdb0adb9144eee5f094ed41f9c Author: Chris Blackbourn Date: Wed Sep 28 12:35:29 2022 +1300 Branches: master https://developer.blender.org/rB5beaecb33e74abbdb0adb9144eee5f094ed41f9c Fix T101414: in 3d viewport, smart uv project failed to pack Regression from https://developer.blender.org/rBa5c696a0c2b9 === M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index e66629f8fb0..e45c7410b3b 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -2421,7 +2421,7 @@ static int smart_project_exec(bContext *C, wmOperator *op) .rotate = true, /* We could make this optional. */ .rotate_align_axis = 1, - .only_selected_uvs = true, + .only_selected_uvs = only_selected_uvs, .only_selected_faces = true, .correct_aspect = correct_aspect, .use_seams = true, ___ 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] [5c93c37678d] master: Cleanup: improve 2D convex hull
Commit: 5c93c37678d16e4c6ee52c579e51fdafb7d0a879 Author: Chris Blackbourn Date: Sun Sep 25 13:09:44 2022 +1300 Branches: master https://developer.blender.org/rB5c93c37678d16e4c6ee52c579e51fdafb7d0a879 Cleanup: improve 2D convex hull Improve correctness, API, comments, memory usage and performance of the 2D convex hull calculation. Pre-requisite for UV packing improvements. Differential Revision: https://developer.blender.org/D16055 === M source/blender/blenlib/BLI_convexhull_2d.h M source/blender/blenlib/intern/convexhull_2d.c M source/blender/python/mathutils/mathutils_geometry.c === diff --git a/source/blender/blenlib/BLI_convexhull_2d.h b/source/blender/blenlib/BLI_convexhull_2d.h index 0b4c3d486fb..f4e4e4d66f1 100644 --- a/source/blender/blenlib/BLI_convexhull_2d.h +++ b/source/blender/blenlib/BLI_convexhull_2d.h @@ -11,43 +11,26 @@ extern "C" { #endif /** - * A.M. Andrew's monotone chain 2D convex hull algorithm. - * - * \param points: An array of 2D points presorted by increasing x and y-coords. - * \param n: The number of points in points. - * \param r_points: An array of the convex hull vertex indices (max is n). - * \returns the number of points in r_points. - */ -int BLI_convexhull_2d_sorted(const float (*points)[2], int n, int r_points[]); -/** - * A.M. Andrew's monotone chain 2D convex hull algorithm. + * Extract 2D convex hull. * * \param points: An array of 2D points. * \param n: The number of points in points. * \param r_points: An array of the convex hull vertex indices (max is n). - * _must_ be allocated as `n * 2` because of how its used internally, - * even though the final result will be no more than \a n in size. - * \returns the number of points in r_points. - */ -int BLI_convexhull_2d(const float (*points)[2], int n, int r_points[]); - -/** - * \return The best angle for fitting the convex hull to an axis aligned bounding box. - * - * Intended to be used with #BLI_convexhull_2d + * \return The number of indices in r_points. * - * \param points_hull: Ordered hull points - * (result of #BLI_convexhull_2d mapped to a contiguous array). + * \note Performance is O(n.log(n)), same as qsort. * - * \note we could return the index of the best edge too if its needed. */ -float BLI_convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], unsigned int n); +int BLI_convexhull_2d(const float (*points)[2], int n, int r_points[/* n */]); + /** - * Wrap #BLI_convexhull_aabb_fit_hull_2d and do the convex hull calculation. + * \return The best angle for fitting the points to an axis aligned bounding box. + * + * \note We could return the index of the best edge too if its needed. * - * \param points: arbitrary 2d points. + * \param points: Arbitrary 2d points. */ -float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], unsigned int n); +float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int n); #ifdef __cplusplus } diff --git a/source/blender/blenlib/intern/convexhull_2d.c b/source/blender/blenlib/intern/convexhull_2d.c index ee5d000b72f..fee6241a817 100644 --- a/source/blender/blenlib/intern/convexhull_2d.c +++ b/source/blender/blenlib/intern/convexhull_2d.c @@ -39,8 +39,9 @@ static float is_left(const float p0[2], const float p1[2], const float p2[2]) return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p2[0] - p0[0]) * (p1[1] - p0[1]); } -int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points[]) +static int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points[]) { + BLI_assert(n >= 2); /* Doesn't handle trivial cases. */ /* the output array r_points[] will be used as the stack */ int bot = 0; int top = -1; /* indices for bottom and top of the stack */ @@ -66,6 +67,7 @@ int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points r_points[++top] = minmax; } r_points[++top] = minmin; /* add polygon endpoint */ +BLI_assert(top + 1 <= n); return top + 1; } @@ -122,16 +124,18 @@ int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points } if (points[i][0] == points[r_points[0]][0] && points[i][1] == points[r_points[0]][1]) { + BLI_assert(top + 1 <= n); return top + 1; /* special case (mgomes) */ } r_points[++top] = i; /* push points[i] onto stack */ } - if (minmax != minmin) { + if (minmax != minmin && r_points[0] != minmin) { r_points[++top] = minmin; /* push joining endpoint onto stack */ } + BLI_assert(top + 1 <= n); return top + 1; } @@ -162,35 +166,38 @@ static int pointref_cmp_yx(const void *a_, const void *b_) int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[]) { - struct PointRef *points_ref = MEM_mallocN(sizeof(*points_
[Bf-blender-cvs] [c50335b359e] master: UV: add toggle to show the grid over the image
Commit: c50335b359e06751cba81e3d33a4ee0ae71daffb Author: Chris Blackbourn Date: Thu Sep 22 13:16:34 2022 +1200 Branches: master https://developer.blender.org/rBc50335b359e06751cba81e3d33a4ee0ae71daffb UV: add toggle to show the grid over the image In UV editor, previously unable to see grid and image at same time. Maniphest Tasks: T78391 Differential Revision: https://developer.blender.org/D16038 === M release/scripts/startup/bl_ui/space_image.py M source/blender/draw/engines/overlay/overlay_grid.cc M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index b624d024843..89d025814f2 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -1531,6 +1531,14 @@ class IMAGE_PT_overlay_guides(Panel): if overlay.show_grid_background: layout.use_property_split = True + +col = layout.column(align=False, heading="Grid Over Image") +col.use_property_decorate = False +row = col.row(align=True) +sub = row.row(align=True) +sub.prop(uvedit, "show_grid_over_image", text="") +sub.active = context.space_data.image is not None + col = layout.column(align=False, heading="Fixed Subdivisions") col.use_property_decorate = False diff --git a/source/blender/draw/engines/overlay/overlay_grid.cc b/source/blender/draw/engines/overlay/overlay_grid.cc index 4a4d9ee6c19..89fc6ec2eb7 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.cc +++ b/source/blender/draw/engines/overlay/overlay_grid.cc @@ -51,6 +51,9 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) true; if (background_enabled) { grid_flag = GRID_BACK | PLANE_IMAGE; + if (sima->flag & SI_GRID_OVER_IMAGE) { +grid_flag = PLANE_IMAGE; + } } const bool draw_grid = is_uv_edit || !ED_space_image_has_buffer(sima); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 6bb8dc6aa18..5a819ead4ec 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1319,6 +1319,8 @@ typedef enum eSpaceImage_Flag { SI_SHOW_R = (1 << 27), SI_SHOW_G = (1 << 28), SI_SHOW_B = (1 << 29), + + SI_GRID_OVER_IMAGE = (1 << 30), } eSpaceImage_Flag; typedef enum eSpaceImageOverlay_Flag { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 18f686b8946..9bbe37b5187 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3614,6 +3614,12 @@ static void rna_def_space_image_uv(BlenderRNA *brna) prop, "Tile Grid Shape", "How many tiles will be shown in the background"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); + prop = RNA_def_property(srna, "show_grid_over_image", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_GRID_OVER_IMAGE); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text(prop, "Grid Over Image", "Show the grid over the image"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); + prop = RNA_def_property(srna, "use_custom_grid", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_CUSTOM_GRID); RNA_def_property_boolean_default(prop, true); ___ 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] [7f284f5134c] master: Fix T101138: remove console spam when hovering over toolbar in uv editor
Commit: 7f284f5134ca0cf37c18302975c9632ef13f269d Author: Chris Blackbourn Date: Wed Sep 21 09:34:11 2022 +1200 Branches: master https://developer.blender.org/rB7f284f5134ca0cf37c18302975c9632ef13f269d Fix T101138: remove console spam when hovering over toolbar in uv editor Reviewers: Campbell Barton , Ryan Inch Differential Revision: https://developer.blender.org/D16015 === M release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py === diff --git a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py index f75a38c1c66..09a55827128 100644 --- a/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py +++ b/release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py @@ -173,7 +173,7 @@ def generate(context, space_type, *, use_fallback_keys=True, use_reset=True): mode = context.active_object.mode # See: BKE_paint_get_tool_prop_id_from_paintmode if space_type == 'IMAGE_EDITOR': -if context.space_data.ui_mode == 'PAINT': +if context.space_data.mode == 'PAINT': attr = "image_tool" else: attr = None @@ -200,7 +200,7 @@ def generate(context, space_type, *, use_fallback_keys=True, use_reset=True): properties=kmi_hack_brush_select_properties, include={'KEYBOARD'}, )[1] -elif mode in {'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: +elif mode in {'EDIT', 'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: # Doesn't use brushes pass else: ___ 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] [a24fc6bbc1a] master: UV: extend custom grid sizes to set each axis separately
Commit: a24fc6bbc1ae3c0ee5a26c5b964af219215de692 Author: Chris Blackbourn Date: Sun Sep 18 17:03:40 2022 +1200 Branches: master https://developer.blender.org/rBa24fc6bbc1ae3c0ee5a26c5b964af219215de692 UV: extend custom grid sizes to set each axis separately For example, allows a custom UV grid size of 4 x 12. TODO: Fix snapping with custom UV grid sizes. Manifest Tasks: T78391 Differential Revision: https://developer.blender.org/D16000 === M release/scripts/startup/bl_ui/space_image.py M source/blender/blenloader/intern/versioning_300.cc M source/blender/draw/engines/overlay/overlay_grid.cc M source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl M source/blender/editors/include/ED_image.h M source/blender/editors/space_image/image_draw.c M source/blender/editors/space_image/space_image.c M source/blender/editors/transform/transform.c M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index da752b5fe00..b624d024843 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -1537,9 +1537,12 @@ class IMAGE_PT_overlay_guides(Panel): row = col.row(align=True) sub = row.row(align=True) sub.prop(uvedit, "use_custom_grid", text="") -sub = sub.row(align=True) -sub.active = uvedit.use_custom_grid -sub.prop(uvedit, "custom_grid_subdivisions", text="") +if uvedit.use_custom_grid: +row = layout.row() +row.use_property_split = True +row.use_property_decorate = False +sub = sub.row(align=True) +sub.prop(uvedit, "custom_grid_subdivisions", text="") row = layout.row() row.use_property_split = True diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index e789cd66632..8f1f2fa2c17 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -2401,11 +2401,6 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } break; } -case SPACE_IMAGE: { - SpaceImage *sima = (SpaceImage *)sl; - sima->custom_grid_subdiv = 10; - break; -} } } } @@ -3426,5 +3421,21 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + +/* Custom grids in UV Editor have separate X and Y divisions. */ +LISTBASE_FOREACH (bScreen *, screen, >screens) { + LISTBASE_FOREACH (ScrArea *, area, >areabase) { +LISTBASE_FOREACH (SpaceLink *, sl, >spacedata) { + switch (sl->spacetype) { +case SPACE_IMAGE: { + SpaceImage *sima = (SpaceImage *)sl; + sima->custom_grid_subdiv[0] = 10; + sima->custom_grid_subdiv[1] = 10; + break; +} + } +} + } +} } } diff --git a/source/blender/draw/engines/overlay/overlay_grid.cc b/source/blender/draw/engines/overlay/overlay_grid.cc index 71abcf91223..4a4d9ee6c19 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.cc +++ b/source/blender/draw/engines/overlay/overlay_grid.cc @@ -31,6 +31,7 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) float *zplane_axes = pd->grid.zplane_axes; float grid_steps[SI_GRID_STEPS_LEN] = { 0.001f, 0.01f, 0.1f, 1.0f, 10.0f, 100.0f, 1000.0f, 1.0f}; + float grid_steps_y[SI_GRID_STEPS_LEN] = {0.0f}; /* When zero, use value from grid_steps. */ OVERLAY_GridBits grid_flag = OVERLAY_GridBits(0), zneg_flag = OVERLAY_GridBits(0), zpos_flag = OVERLAY_GridBits(0); grid->line_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f; @@ -68,7 +69,7 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) } grid->zoom_factor = ED_space_image_zoom_level(v2d, SI_GRID_STEPS_LEN); -ED_space_image_grid_steps(sima, grid_steps, SI_GRID_STEPS_LEN); +ED_space_image_grid_steps(sima, grid_steps, grid_steps_y, SI_GRID_STEPS_LEN); } else { /* SPACE_VIEW3D */ @@ -197,6 +198,7 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) /* Convert to UBO alignment. */ for (int i = 0; i < SI_GRID_STEPS_LEN; i++) { grid->steps[i][0] = grid_steps[i]; +grid->steps[i][1] = (grid_steps_y[i] != 0.0f) ? grid_steps_y[i] : grid_steps[i]; } pd->grid.grid_flag = grid_flag; pd->grid.zneg_flag = zneg_fla
[Bf-blender-cvs] [7a67d69ca4f] master: Cleanup: spelling
Commit: 7a67d69ca4fe807ea36c57166b89a6e42c25b909 Author: Chris Blackbourn Date: Tue Sep 20 09:20:55 2022 +1200 Branches: master https://developer.blender.org/rB7a67d69ca4fe807ea36c57166b89a6e42c25b909 Cleanup: spelling === M source/blender/editors/include/ED_image.h M source/blender/editors/space_image/image_draw.c === diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index 91ae8286531..ef75277b1ea 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -39,7 +39,7 @@ void ED_space_image_grid_steps(struct SpaceImage *sima, * The code in here (except the offset part) is used in `grid_frag.glsl` (see `grid_res`) for * drawing the grid overlay for the UV/Image editor. */ -float ED_space_image_increment_snap_value(int grid_dimesnions, +float ED_space_image_increment_snap_value(int grid_dimensions, const float grid_steps[SI_GRID_STEPS_LEN], float zoom_factor); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index b55bac0bc2f..37a6e6dfcb1 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -601,18 +601,18 @@ void ED_space_image_grid_steps(SpaceImage *sima, } } -float ED_space_image_increment_snap_value(const int grid_dimesnions, +float ED_space_image_increment_snap_value(const int grid_dimensions, const float grid_steps[SI_GRID_STEPS_LEN], const float zoom_factor) { /* Small offset on each grid_steps[] so that snapping value doesn't change until grid lines are * significantly visible. - * `Offset = 3/4 * (grid_steps[i] - (grid_steps[i] / grid_dimesnsions))` + * `Offset = 3/4 * (grid_steps[i] - (grid_steps[i] / grid_dimensions))` * * Refer `grid_frag.glsl` to find out when grid lines actually start appearing */ for (int step = 0; step < SI_GRID_STEPS_LEN; step++) { -float offset = (3.0f / 4.0f) * (grid_steps[step] - (grid_steps[step] / grid_dimesnions)); +float offset = (3.0f / 4.0f) * (grid_steps[step] - (grid_steps[step] / grid_dimensions)); if ((grid_steps[step] - offset) > zoom_factor) { return grid_steps[step]; ___ 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] [b5115ed80f1] master: UV: rename "Pixel Snap Mode" to "Pixel Round Mode"
Commit: b5115ed80f197af3f0298f3c2a1e5d177804f9c4 Author: Chris Blackbourn Date: Tue Sep 13 16:43:06 2022 +1200 Branches: master https://developer.blender.org/rBb5115ed80f197af3f0298f3c2a1e5d177804f9c4 UV: rename "Pixel Snap Mode" to "Pixel Round Mode" Maniphest Tasks: T78391 Differential Revision: https://developer.blender.org/D15952 === M release/scripts/startup/bl_ui/space_image.py M source/blender/editors/transform/transform_convert_mesh_uv.c M source/blender/makesdna/DNA_space_types.h M source/blender/makesdna/intern/dna_rename_defs.h M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 0b26f0b1203..da752b5fe00 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -402,7 +402,7 @@ class IMAGE_MT_uvs(Menu): layout.menu("IMAGE_MT_uvs_mirror") layout.menu("IMAGE_MT_uvs_snap") -layout.prop_menu_enum(uv, "pixel_snap_mode") +layout.prop_menu_enum(uv, "pixel_round_mode") layout.prop(uv, "lock_bounds") layout.separator() diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c b/source/blender/editors/transform/transform_convert_mesh_uv.c index 27f12137e3a..78281e5f8e5 100644 --- a/source/blender/editors/transform/transform_convert_mesh_uv.c +++ b/source/blender/editors/transform/transform_convert_mesh_uv.c @@ -399,7 +399,7 @@ static void createTransUVs(bContext *C, TransInfo *t) static void flushTransUVs(TransInfo *t) { SpaceImage *sima = t->area->spacedata.first; - const bool use_pixel_snap = ((sima->pixel_snap_mode != SI_PIXEL_SNAP_DISABLED) && + const bool use_pixel_round = ((sima->pixel_round_mode != SI_PIXEL_ROUND_DISABLED) && (t->state != TRANS_CANCEL)); FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -410,7 +410,7 @@ static void flushTransUVs(TransInfo *t) aspect_inv[0] = 1.0f / t->aspect[0]; aspect_inv[1] = 1.0f / t->aspect[1]; -if (use_pixel_snap) { +if (use_pixel_round) { int size_i[2]; ED_space_image_get_size(sima, _i[0], _i[1]); size[0] = size_i[0]; @@ -422,16 +422,16 @@ static void flushTransUVs(TransInfo *t) td->loc2d[0] = td->loc[0] * aspect_inv[0]; td->loc2d[1] = td->loc[1] * aspect_inv[1]; - if (use_pixel_snap) { + if (use_pixel_round) { td->loc2d[0] *= size[0]; td->loc2d[1] *= size[1]; -switch (sima->pixel_snap_mode) { - case SI_PIXEL_SNAP_CENTER: +switch (sima->pixel_round_mode) { + case SI_PIXEL_ROUND_CENTER: td->loc2d[0] = roundf(td->loc2d[0] - 0.5f) + 0.5f; td->loc2d[1] = roundf(td->loc2d[1] - 0.5f) + 0.5f; break; - case SI_PIXEL_SNAP_CORNER: + case SI_PIXEL_ROUND_CORNER: td->loc2d[0] = roundf(td->loc2d[0]); td->loc2d[1] = roundf(td->loc2d[1]); break; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index d13f3fad270..f25201bf5b4 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1218,7 +1218,7 @@ typedef struct SpaceImage { char pin; - char pixel_snap_mode; + char pixel_round_mode; char lock; /** UV draw type. */ @@ -1260,12 +1260,12 @@ typedef enum eSpaceImage_UVDT_Stretch { SI_UVDT_STRETCH_AREA = 1, } eSpaceImage_UVDT_Stretch; -/** #SpaceImage.pixel_snap_mode */ -typedef enum eSpaceImage_PixelSnapMode { - SI_PIXEL_SNAP_DISABLED = 0, - SI_PIXEL_SNAP_CENTER = 1, - SI_PIXEL_SNAP_CORNER = 2, -} eSpaceImage_Snap_Mode; +/** #SpaceImage.pixel_round_mode */ +typedef enum eSpaceImage_PixelRoundMode { + SI_PIXEL_ROUND_DISABLED = 0, + SI_PIXEL_ROUND_CENTER = 1, + SI_PIXEL_ROUND_CORNER = 2, +} eSpaceImage_Round_Mode; /** #SpaceImage.mode */ typedef enum eSpaceImage_Mode { diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index 257e60eae98..facf6199dce 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -109,6 +109,7 @@ DNA_STRUCT_RENAME_ELEM(RenderData, bake_filter, bake_margin) DNA_STRUCT_RENAME_ELEM(RigidBodyWorld, steps_per_second, substeps_per_frame) DNA_STRUCT_RENAME_ELEM(SDefBind, numverts, verts_num) DNA_STRUCT_RENAME_ELEM(SDefVert, numbinds, binds_num) +DNA_STRUCT_RENAME_ELEM(SpaceImage, pixel_snap_mode, pixel_round_mode) DNA_STRUCT_RENAME_ELEM(SpaceSeq, overlay_type, overlay_frame_type) DNA_STRUCT_RENAME_ELEM(Su
[Bf-blender-cvs] [94e211ced91] master: Fix T100874: improve uv unwrap of degenerate geometry
Commit: 94e211ced914faff7c1f8d0f68209038afa974bf Author: Chris Blackbourn Date: Mon Sep 12 12:58:14 2022 +1200 Branches: master https://developer.blender.org/rB94e211ced914faff7c1f8d0f68209038afa974bf Fix T100874: improve uv unwrap of degenerate geometry Provide reasonable defaults for UV unwrap for triangles with zero area: * Three vertices are arranged in a line. * Two vertices are at the same 3D location. * All three vertices are at the same 3D location. Change fixes quads / ngons which have triangulations with zero area. Change fixes both "Angle Based" method and "Conformal" method. Differential Revision: https://developer.blender.org/D15922 === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 4f763b09bef..f074febe23a 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -307,12 +307,70 @@ static float p_vec2_angle(const float v1[2], const float v2[2], const float v3[2 { return angle_v2v2v2(v1, v2, v3); } + +/* Angles close to 0 or 180 degrees cause rows filled with zeros in the linear_solver. + * The matrix will then be rank deficient and / or have poor conditioning. + * => Reduce the maximum angle to 179 degrees, and spread the remainder to the other angles. + */ +static void fix_large_angle(const float v_fix[3], +const float v1[3], +const float v2[3], +float *r_fix, +float *r_a1, +float *r_a2) +{ + const float max_angle = (float)M_PI * (179.0f / 180.0f); + const float fix_amount = *r_fix - max_angle; + if (fix_amount < 0.0f) { +return; /* angle is reasonable, i.e. less than 179 degrees. */ + } + + /* The triangle is probably degenerate, or close to it. + * Without loss of generality, transform the triangle such that + * v_fix == { 0, s}, *r_fix = 180 degrees + * v1== {-x1, 0}, *r_a1 = 0 + * v2== { x2, 0}, *r_a2 = 0 + * + * With `s = 0`, `x1 > 0`, `x2 > 0` + * + * Now make `s` a small number and do some math: + * tan(*r_a1) = s / x1 + * tan(*r_a2) = s / x2 + * + * Remember that `tan = sin / cos`, `sin(s) ~= s` and `cos(s) = 1` + * + * Rearrange to obtain: + * *r_a1 = fix_amount * x2 / (x1 + x2) + * *r_a2 = fix_amount * x1 / (x1 + x2) + */ + + const float dist_v1 = len_v3v3(v_fix, v1); + const float dist_v2 = len_v3v3(v_fix, v2); + const float sum = dist_v1 + dist_v2; + const float weight = (sum > 1e-20f) ? dist_v2 / sum : 0.5f; + + /* Ensure sum of angles in triangle is unchanged. */ + *r_fix -= fix_amount; + *r_a1 += fix_amount * weight; + *r_a2 += fix_amount * (1.0f - weight); +} + static void p_triangle_angles( const float v1[3], const float v2[3], const float v3[3], float *r_a1, float *r_a2, float *r_a3) { *r_a1 = p_vec_angle(v3, v1, v2); *r_a2 = p_vec_angle(v1, v2, v3); - *r_a3 = (float)M_PI - *r_a2 - *r_a1; + *r_a3 = p_vec_angle(v2, v3, v1); + + /* Fix for degenerate geometry e.g. v1 = sum(v2 + v3). See T100874 */ + fix_large_angle(v1, v2, v3, r_a1, r_a2, r_a3); + fix_large_angle(v2, v3, v1, r_a2, r_a3, r_a1); + fix_large_angle(v3, v1, v2, r_a3, r_a1, r_a2); + + /* Workaround for degenerate geometry, e.g. v1 == v2 == v3. */ + *r_a1 = max_ff(*r_a1, 0.001f); + *r_a2 = max_ff(*r_a2, 0.001f); + *r_a3 = max_ff(*r_a3, 0.001f); } static void p_face_angles(PFace *f, float *r_a1, float *r_a2, float *r_a3) @@ -2266,7 +2324,6 @@ using PAbfSystem = struct PAbfSystem { float *bAlpha, *bTriangle, *bInterior; float *lambdaTriangle, *lambdaPlanar, *lambdaLength; float (*J2dt)[3], *bstar, *dstar; - float minangle, maxangle; }; static void p_abf_setup_system(PAbfSystem *sys) @@ -2294,9 +2351,6 @@ static void p_abf_setup_system(PAbfSystem *sys) for (i = 0; i < sys->ninterior; i++) { sys->lambdaLength[i] = 1.0; } - - sys->minangle = 1.0 * M_PI / 180.0; - sys->maxangle = (float)M_PI - sys->minangle; } static void p_abf_free_system(PAbfSystem *sys) @@ -2707,25 +2761,6 @@ static bool p_chart_abf_solve(PChart *chart) e3 = e2->next; p_face_angles(f, , , ); -if (a1 < sys.minangle) { - a1 = sys.minangle; -} -else if (a1 > sys.maxangle) { - a1 = sys.maxangle; -} -if (a2 < sys.minangle) { - a2 = sys.minangle; -} -else if (a2 > sys.maxangle) { - a2 = sys.maxangle; -} -if (a3 < sys.minangle) { - a3 = sys.minangle; -} -else if (a3 > sys.maxangle) { - a3 = sys.maxangle; -} - sys.alpha[e1->u.id] = sys.beta[e1->u.id] = a1; sys.alpha[e2->
[Bf-blender-cvs] [caf6225a3d0] master: UV: support uv seams when computing uv islands
Commit: caf6225a3d01b3a5d471dc62bb4508477fc4e7df Author: Chris Blackbourn Date: Mon Sep 12 12:22:46 2022 +1200 Branches: master https://developer.blender.org/rBcaf6225a3d01b3a5d471dc62bb4508477fc4e7df UV: support uv seams when computing uv islands An edge can be marked BM_ELEM_SEAM, which means the UV co-ordinates on either side of the edge are actually independent, even if they happen to currently have the same value. This commit optionally add support for UV Seams when computing islands. Affects UV sculpt tools, individual origins, UV stitch and changing UV selection modes etc. Required for upcoming packing refactor which requires seam support when computing islands. Differential Revision: https://developer.blender.org/D15875 === M source/blender/editors/include/ED_mesh.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/sculpt_paint/sculpt_uv.c M source/blender/editors/transform/transform_convert_mesh_uv.c M source/blender/editors/uvedit/uvedit_ops.c M source/blender/editors/uvedit/uvedit_select.c M source/blender/editors/uvedit/uvedit_smart_stitch.c === diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index b6a652bd3ab..26743a2bd08 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -139,6 +139,7 @@ struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm, const struct Scene *scene, bool uv_selected, bool use_winding, + bool use_seams, bool do_islands); void BM_uv_element_map_free(struct UvElementMap *element_map); struct UvElement *BM_uv_element_get(const struct UvElementMap *map, diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index a6a6b095c31..cca2aa11ac3 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -851,10 +851,99 @@ static void bm_uv_build_islands(UvElementMap *element_map, MEM_SAFE_FREE(map); } +/* return true if `loop` has UV co-ordinates which match `luv_a` and `luv_b` */ +static bool loop_uv_match(BMLoop *loop, MLoopUV *luv_a, MLoopUV *luv_b, int cd_loop_uv_offset) +{ + MLoopUV *luv_c = BM_ELEM_CD_GET_VOID_P(loop, cd_loop_uv_offset); + MLoopUV *luv_d = BM_ELEM_CD_GET_VOID_P(loop->next, cd_loop_uv_offset); + return compare_v2v2(luv_a->uv, luv_c->uv, STD_UV_CONNECT_LIMIT) && + compare_v2v2(luv_b->uv, luv_d->uv, STD_UV_CONNECT_LIMIT); +} + +/* Given `anchor` and `edge`, return true if there are edges that fan between them that are + * seam-free. */ +static bool seam_connected_recursive(BMVert *anchor, + BMEdge *edge, + MLoopUV *luv_anchor, + MLoopUV *luv_fan, + BMLoop *needle, + GSet *visited, + int cd_loop_uv_offset) +{ + BLI_assert(edge->v1 == anchor || edge->v2 == anchor); + BLI_assert(needle->v == anchor || needle->next->v == anchor); + + if (BM_elem_flag_test(edge, BM_ELEM_SEAM)) { +return false; /* Edge is a seam, don't traverse. */ + } + + if (!BLI_gset_add(visited, edge)) { +return false; /* Already visited. */ + } + + BMLoop *loop; + BMIter liter; + BM_ITER_ELEM (loop, , edge, BM_LOOPS_OF_EDGE) { +if (loop->v == anchor) { + if (!loop_uv_match(loop, luv_anchor, luv_fan, cd_loop_uv_offset)) { +continue; /* `loop` is disjoint in UV space. */ + } + + if (loop->prev == needle) { +return true; /* Success. */ + } + + MLoopUV *luv_far = BM_ELEM_CD_GET_VOID_P(loop->prev, cd_loop_uv_offset); + if (seam_connected_recursive( + anchor, loop->prev->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { +return true; + } +} +else { + BLI_assert(loop->next->v == anchor); + if (!loop_uv_match(loop, luv_fan, luv_anchor, cd_loop_uv_offset)) { +continue; /* `loop` is disjoint in UV space. */ + } + + if (loop->next == needle) { +return true; /* Success. */ + } + + MLoopUV *luv_far = BM_ELEM_CD_GET_VOID_P(loop->next->next, cd_loop_uv_offset); + if (seam_connected_recursive( + anchor, loop->next->e, luv_anchor, luv_far, needle, visited, cd_loop_uv_offset)) { +return true; + } +} + } + + return false; +} + +/* Given `loop_a` and `loop_b` originate from t
[Bf-blender-cvs] [20daaeffce4] master: UV: add new operator, uvcalc_align_rotation
Commit: 20daaeffce4cf9bfe48ab7c84cb9e2b1d71d2c91 Author: Chris Blackbourn Date: Wed Sep 7 13:22:45 2022 +1200 Branches: master https://developer.blender.org/rB20daaeffce4cf9bfe48ab7c84cb9e2b1d71d2c91 UV: add new operator, uvcalc_align_rotation Adds a new operator to automatically rotate UV Islands into alignment. Modes: * Auto (All edges) * Geometry (V direction will point in geometry direction) [1] * Edge (Rotate until selected edge is in V direction) Also adds uv_sync_selection support to UV Randomize Transform. Resolves: T78399 Differential Revision: https://developer.blender.org/D15820 [1] Listed as "World" in Task description. === M release/scripts/startup/bl_operators/__init__.py D release/scripts/startup/bl_operators/uvcalc_randomize_transform.py A release/scripts/startup/bl_operators/uvcalc_transform.py M release/scripts/startup/bl_ui/space_image.py === diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py index 6f61d7e7129..de0b7798072 100644 --- a/release/scripts/startup/bl_operators/__init__.py +++ b/release/scripts/startup/bl_operators/__init__.py @@ -31,7 +31,7 @@ _modules = [ "userpref", "uvcalc_follow_active", "uvcalc_lightmap", -"uvcalc_randomize_transform", +"uvcalc_transform", "vertexpaint_dirt", "view3d", "wm", diff --git a/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py b/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py deleted file mode 100644 index 2867164a72e..000 --- a/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py +++ /dev/null @@ -1,212 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later - -from bpy.types import Operator -from mathutils import Vector - -import math - - -def get_random_transform(transform_params, entropy): -from random import uniform -from random import seed as random_seed - -(seed, loc, rot, scale, scale_even) = transform_params - -# First, seed the RNG. -random_seed(seed + entropy) - -# Next, call uniform a known number of times. -offset_u = uniform(0, 1) -offset_v = uniform(0, 1) -angle = uniform(0, 1) -scale_u = uniform(0, 1) -scale_v = uniform(0, 1) - -# Apply the transform_params. -if loc: -offset_u *= loc[0] -offset_v *= loc[1] -else: -offset_u = 0 -offset_v = 0 - -if rot: -angle *= rot -else: -angle = 0 - -if scale: -scale_u = scale_u * (2 * scale[0] - 2.0) + 2.0 - scale[0] -scale_v = scale_v * (2 * scale[1] - 2.0) + 2.0 - scale[1] -else: -scale_u = 1 -scale_v = 1 - -if scale_even: -scale_v = scale_u - -# Results in homogenous co-ordinates. -return [[scale_u * math.cos(angle), -scale_v * math.sin(angle), offset_u], -[scale_u * math.sin(angle), scale_v * math.cos(angle), offset_v]] - - -def randomize_uv_transform_island(bm, uv_layer, faces, transform_params): -# Ensure consistent random values for island, regardless of selection etc. -entropy = min(f.index for f in faces) - -transform = get_random_transform(transform_params, entropy) - -# Find bounding box. -minmax = [1e30, 1e30, -1e30, -1e30] -for face in faces: -for loop in face.loops: -u, v = loop[uv_layer].uv -minmax[0] = min(minmax[0], u) -minmax[1] = min(minmax[1], v) -minmax[2] = max(minmax[2], u) -minmax[3] = max(minmax[3], v) - -mid_u = (minmax[0] + minmax[2]) / 2 -mid_v = (minmax[1] + minmax[3]) / 2 - -del_u = transform[0][2] + mid_u - transform[0][0] * mid_u - transform[0][1] * mid_v -del_v = transform[1][2] + mid_v - transform[1][0] * mid_u - transform[1][1] * mid_v - -# Apply transform. -for face in faces: -for loop in face.loops: -pre_uv = loop[uv_layer].uv -u = transform[0][0] * pre_uv[0] + transform[0][1] * pre_uv[1] + del_u -v = transform[1][0] * pre_uv[0] + transform[1][1] * pre_uv[1] + del_v -loop[uv_layer].uv = (u, v) - - -def is_face_uv_selected(face, uv_layer): -for loop in face.loops: -if not loop[uv_layer].select: -return False -return True - - -def is_island_uv_selected(bm, island, uv_layer): -for face in island: -if is_face_uv_selected(face, uv_layer): -return True -return False - - -def randomize_uv_transform_bmesh(mesh, bm, transform_params): -import bpy_extras.bmesh_utils -uv_layer = bm.loops.layers.uv.verify() -islands = bpy_extras.bmesh_utils.bmesh_linked_uv_islands(bm, uv_layer) -for island in islands: -if is_island_uv_selec
[Bf-blender-cvs] [3ebf6a7f38e] master: Cleanup: Remove use of designated initializers in C++ code
Commit: 3ebf6a7f38e9ef0e74073f442d369dc426912ac9 Author: Chris Blackbourn Date: Tue Sep 6 18:28:55 2022 +1200 Branches: master https://developer.blender.org/rB3ebf6a7f38e9ef0e74073f442d369dc426912ac9 Cleanup: Remove use of designated initializers in C++ code Does not compile on Windows. === M source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/editors/uvedit/uvedit_islands.cc b/source/blender/editors/uvedit/uvedit_islands.cc index 836d997f6e4..42415be656a 100644 --- a/source/blender/editors/uvedit/uvedit_islands.cc +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -348,11 +348,6 @@ int bm_mesh_calc_uv_islands(const Scene *scene, int island_added = 0; BM_mesh_elem_table_ensure(bm, BM_FACE); - struct SharedUVLoopData user_data = { - .cd_loop_uv_offset = cd_loop_uv_offset, - .use_seams = use_seams, - }; - int *groups_array = static_cast( MEM_mallocN(sizeof(*groups_array) * (size_t)bm->totface, __func__)); @@ -379,6 +374,10 @@ int bm_mesh_calc_uv_islands(const Scene *scene, } } + struct SharedUVLoopData user_data = {0}; + user_data.cd_loop_uv_offset = cd_loop_uv_offset; + user_data.use_seams = use_seams; + const int group_len = BM_mesh_calc_face_groups(bm, groups_array, _index, ___ 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] [d9db79dbe5b] master: Cleanup: Move uvedit_islands to c++
Commit: d9db79dbe5bec8ba541660940bf981de1c7c5c52 Author: Chris Blackbourn Date: Tue Sep 6 15:51:53 2022 +1200 Branches: master https://developer.blender.org/rBd9db79dbe5bec8ba541660940bf981de1c7c5c52 Cleanup: Move uvedit_islands to c++ Differential Revision: https://developer.blender.org/D15870 === M source/blender/editors/uvedit/CMakeLists.txt R093source/blender/editors/uvedit/uvedit_islands.c source/blender/editors/uvedit/uvedit_islands.cc === diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index fd3f7c49dc4..4574c745d93 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -22,7 +22,7 @@ set(INC set(SRC uvedit_buttons.c uvedit_draw.c - uvedit_islands.c + uvedit_islands.cc uvedit_ops.c uvedit_path.c uvedit_rip.c diff --git a/source/blender/editors/uvedit/uvedit_islands.c b/source/blender/editors/uvedit/uvedit_islands.cc similarity index 93% rename from source/blender/editors/uvedit/uvedit_islands.c rename to source/blender/editors/uvedit/uvedit_islands.cc index 68c00b18b09..836d997f6e4 100644 --- a/source/blender/editors/uvedit/uvedit_islands.c +++ b/source/blender/editors/uvedit/uvedit_islands.cc @@ -46,7 +46,7 @@ static void bm_face_uv_scale_y(BMFace *f, const float scale_y, const int cd_loop BMLoop *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { -MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset); +MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset)); luv->uv[1] *= scale_y; } while ((l_iter = l_iter->next) != l_first); } @@ -61,7 +61,7 @@ static void bm_face_uv_translate_and_scale_around_pivot(BMFace *f, BMLoop *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { -MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset); +MLoopUV *luv = static_cast(BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset)); for (int i = 0; i < 2; i++) { luv->uv[i] = offset[i] + (((luv->uv[i] - pivot[i]) * scale[i]) + pivot[i]); } @@ -111,7 +111,8 @@ static float (*bm_face_array_calc_unique_uv_coords( coords_len_alloc += f->len; } - float(*coords)[2] = MEM_mallocN(sizeof(*coords) * coords_len_alloc, __func__); + float(*coords)[2] = static_cast( + MEM_mallocN(sizeof(*coords) * coords_len_alloc, __func__)); int coords_len = 0; for (int i = 0; i < faces_len; i++) { @@ -125,7 +126,8 @@ static float (*bm_face_array_calc_unique_uv_coords( } BM_elem_flag_disable(l_iter, BM_ELEM_TAG); - const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset); + const MLoopUV *luv = static_cast( + BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset)); copy_v2_v2(coords[coords_len++], luv->uv); /* Un tag all connected so we don't add them twice. @@ -140,7 +142,8 @@ static float (*bm_face_array_calc_unique_uv_coords( do { if (l_radial->v == l_iter->v) { if (BM_elem_flag_test(l_radial, BM_ELEM_TAG)) { -const MLoopUV *luv_radial = BM_ELEM_CD_GET_VOID_P(l_radial, cd_loop_uv_offset); +const MLoopUV *luv_radial = static_cast( +BM_ELEM_CD_GET_VOID_P(l_radial, cd_loop_uv_offset)); if (equals_v2v2(luv->uv, luv_radial->uv)) { /* Don't add this UV when met in another face in `faces`. */ BM_elem_flag_disable(l_iter, BM_ELEM_TAG); @@ -152,7 +155,6 @@ static float (*bm_face_array_calc_unique_uv_coords( } while ((e = BM_DISK_EDGE_NEXT(e, v_pivot)) != e_first); } while ((l_iter = l_iter->next) != l_first); } - coords = MEM_reallocN(coords, sizeof(*coords) * coords_len); *r_coords_len = coords_len; return coords; } @@ -319,7 +321,7 @@ struct SharedUVLoopData { static bool bm_loop_uv_shared_edge_check(const BMLoop *l_a, const BMLoop *l_b, void *user_data) { - const struct SharedUVLoopData *data = user_data; + const struct SharedUVLoopData *data = static_cast(user_data); if (data->use_seams) { if (BM_elem_flag_test(l_a->e, BM_ELEM_SEAM)) { @@ -351,7 +353,8 @@ int bm_mesh_calc_uv_islands(const Scene *scene, .use_seams = use_seams, }; - int *groups_array = MEM_mallocN(sizeof(*groups_array) * (size_t)bm->totface, __func__); + int *groups_array = static_cast( + MEM_mallocN(sizeof(*groups_array) * (size_t)bm->totface, __func__)); int(*group_index)[2]; @@ -388,7 +391,7 @@ int bm_mesh_calc_uv_islands(const Scene *scene, for (int i = 0; i < group_len; i++) { const int faces_start = group_index[i][0]; const int faces_len = group_index[i][1]; -BMFace **faces = MEM_mallocN(sizeof(*faces) * faces_len, __func__); +
[Bf-blender-cvs] [d527aa4dd53] master: UV: support constrain-to-bounds for uv rotation operator
Commit: d527aa4dd53d4f8bd226477b2d7913abf6424c57 Author: Chris Blackbourn Date: Sat Aug 27 16:51:53 2022 +1200 Branches: master https://developer.blender.org/rBd527aa4dd53d4f8bd226477b2d7913abf6424c57 UV: support constrain-to-bounds for uv rotation operator Differential Revision: https://developer.blender.org/D15730 === M source/blender/editors/transform/transform.h M source/blender/editors/transform/transform_mode_rotate.c === diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 0429e37a077..09fc07f57f4 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -620,6 +620,9 @@ typedef struct TransInfo { * value of the input parameter, except when a constrain is entered. */ float values_final[4]; + /** Cache safe value for constraints that require iteration or are slow to calculate. */ + float values_inside_constraints[4]; + /* Axis members for modes that use an axis separate from the orientation (rotate & shear). */ /** Primary axis, rotate only uses this. */ diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c index a7207b36578..18c517fa5b4 100644 --- a/source/blender/editors/transform/transform_mode_rotate.c +++ b/source/blender/editors/transform/transform_mode_rotate.c @@ -286,9 +286,72 @@ static void applyRotationValue(TransInfo *t, } } +static bool uv_rotation_in_clip_bounds_test(const TransInfo *t, const float angle) +{ + const float cos_angle = cosf(angle); + const float sin_angle = sinf(angle); + const float *center = t->center_global; + FOREACH_TRANS_DATA_CONTAINER (t, tc) { +TransData *td = tc->data; +for (int i = 0; i < tc->data_len; i++, td++) { + if (td->flag & TD_SKIP) { +continue; + } + if (td->factor < 1.0f) { +continue; /* Proportional edit, will get picked up in next phase. */ + } + + float uv[2]; + sub_v2_v2v2(uv, td->iloc, center); + float pr[2]; + pr[0] = cos_angle * uv[0] + sin_angle * uv[1]; + pr[1] = -sin_angle * uv[0] + cos_angle * uv[1]; + add_v2_v2(pr, center); + /* TODO: udim support. */ + if (pr[0] < 0.0f || 1.0f < pr[0]) { +return false; + } + if (pr[1] < 0.0f || 1.0f < pr[1]) { +return false; + } +} + } + return true; +} + +static bool clip_uv_transform_rotate(const TransInfo *t, float *vec, float *vec_inside_bounds) +{ + float angle = vec[0]; + if (uv_rotation_in_clip_bounds_test(t, angle)) { +vec_inside_bounds[0] = angle; /* Store for next iteration. */ +return false; /* Nothing to do. */ + } + float angle_inside_bounds = vec_inside_bounds[0]; + if (!uv_rotation_in_clip_bounds_test(t, angle_inside_bounds)) { +return false; /* No known way to fix, may as well rotate anyway. */ + } + const int max_i = 32; /* Limit iteration, mainly for debugging. */ + for (int i = 0; i < max_i; i++) { +/* Binary search. */ +const float angle_mid = (angle_inside_bounds + angle) / 2.0f; +if (angle_mid == angle_inside_bounds || angle_mid == angle) { + break; /* float precision reached. */ +} +if (uv_rotation_in_clip_bounds_test(t, angle_mid)) { + angle_inside_bounds = angle_mid; +} +else { + angle = angle_mid; +} + } + + vec_inside_bounds[0] = angle_inside_bounds; /* Store for next iteration. */ + vec[0] = angle_inside_bounds; /* Update rotation angle. */ + return true; +} + static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) { - char str[UI_MAX_DRAW_STR]; float axis_final[3]; float final = t->values[0] + t->values_modal_offset[0]; @@ -313,13 +376,27 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) t->values_final[0] = final; - headerRotation(t, str, sizeof(str), final); - const bool is_large_rotation = hasNumInput(>num); applyRotationValue(t, final, axis_final, is_large_rotation); + if (t->flag & T_CLIP_UV) { +if (clip_uv_transform_rotate(t, t->values_final, t->values_inside_constraints)) { + applyRotationValue(t, t->values_final[0], axis_final, is_large_rotation); +} + +/* In proportional edit it can happen that */ +/* vertices in the radius of the brush end */ +/* outside the clipping area */ +/* XXX HACK - dg */ +if (t->flag & T_PROP_EDIT) { + clipUVData(t); +} + } + recalcData(t); + char str[UI_MAX_DRAW_STR]; + headerRotation(t, str, sizeof(str), t->values_final[0]); ED_area_status_text(t->area, str); } ___ Bf-blender-cvs mailing
[Bf-blender-cvs] [3cba80039d5] master: UV: bpy_extras.mesh_utils.mesh_linked_uv_islands raises error in edit mode
Commit: 3cba80039d5db1d2d23ff754ab427f8ed66a71f8 Author: Chris Blackbourn Date: Sat Aug 27 16:01:56 2022 +1200 Branches: master https://developer.blender.org/rB3cba80039d5db1d2d23ff754ab427f8ed66a71f8 UV: bpy_extras.mesh_utils.mesh_linked_uv_islands raises error in edit mode Maniphest Tasks: T86484 Differential Revision: https://developer.blender.org/D15778 === M release/scripts/modules/bpy_extras/mesh_utils.py === diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index f6dc33e4f02..d593ce6a1e4 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -13,14 +13,22 @@ __all__ = ( def mesh_linked_uv_islands(mesh): """ -Splits the mesh into connected polygons, use this for separating cubes from -other mesh elements within 1 mesh datablock. +Returns lists of polygon indices connected by UV islands. :arg mesh: the mesh used to group with. :type mesh: :class:`bpy.types.Mesh` -:return: lists of lists containing polygon indices +:return: list of lists containing polygon indices :rtype: list """ + +if mesh.polygons and not mesh.uv_layers.active.data: +# Currently, when in edit mode, UV Layer data will always be empty +# when accessed though RNA. This may change in the future. +raise ValueError( +"UV Layers are not currently available from python in Edit Mode. " +"Use bmesh and bpy_extras.bmesh_utils.bmesh_linked_uv_islands instead." +) + uv_loops = [luv.uv[:] for luv in mesh.uv_layers.active.data] poly_loops = [poly.loop_indices for poly in mesh.polygons] luv_hash = {} ___ 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] [51178fd4da9] master: UV: improve consistency for scale parameter of uvcalc_randomize_transform
Commit: 51178fd4da90c3b5c2c5767fe54dd3189ca047a6 Author: Chris Blackbourn Date: Fri Aug 26 21:19:46 2022 +1200 Branches: master https://developer.blender.org/rB51178fd4da90c3b5c2c5767fe54dd3189ca047a6 UV: improve consistency for scale parameter of uvcalc_randomize_transform === M release/scripts/startup/bl_operators/uvcalc_randomize_transform.py === diff --git a/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py b/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py index 9b9e016cb9a..2867164a72e 100644 --- a/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py +++ b/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py @@ -36,8 +36,8 @@ def get_random_transform(transform_params, entropy): angle = 0 if scale: -scale_u *= scale[0] -scale_v *= scale[1] +scale_u = scale_u * (2 * scale[0] - 2.0) + 2.0 - scale[0] +scale_v = scale_v * (2 * scale[1] - 2.0) + 2.0 - scale[1] else: scale_u = 1 scale_v = 1 ___ 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] [de570dc87ed] master: Fix T78406: create uv randomize islands operator
Commit: de570dc87ed17cae2d2d1ed4347793c440266b4b Author: Chris Blackbourn Date: Thu Aug 25 17:59:39 2022 +1200 Branches: master https://developer.blender.org/rBde570dc87ed17cae2d2d1ed4347793c440266b4b Fix T78406: create uv randomize islands operator Implement a new operator to randomize the scale, rotation and offset of selected UV islands. === A release/scripts/modules/bpy_extras/bmesh_utils.py M release/scripts/startup/bl_operators/__init__.py A release/scripts/startup/bl_operators/uvcalc_randomize_transform.py M release/scripts/startup/bl_ui/space_image.py === diff --git a/release/scripts/modules/bpy_extras/bmesh_utils.py b/release/scripts/modules/bpy_extras/bmesh_utils.py new file mode 100644 index 000..baf1f9d863f --- /dev/null +++ b/release/scripts/modules/bpy_extras/bmesh_utils.py @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +__all__ = ( +"bmesh_linked_uv_islands", +) + +import bmesh + +def match_uv(face, vert, uv, uv_layer): +for loop in face.loops: +if loop.vert == vert: +return uv == loop[uv_layer].uv +return False + + +def bmesh_linked_uv_islands(bm, uv_layer): +""" +Returns lists of face indices connected by UV islands. + +For `bpy.types.Mesh`, use `mesh_linked_uv_islands` instead. + +:arg bm: the bmesh used to group with. +:type bmesh: :class: `BMesh` +:arg uv_layer: the UV layer to source UVs from. +:type bmesh: :class: `BMLayerItem` +:return: list of lists containing polygon indices +:rtype: list +""" + +result = [] +bm.faces.ensure_lookup_table() + +used = {} +for seed_face in bm.faces: +seed_index = seed_face.index +if used.get(seed_index): +continue # Face has already been processed. +used[seed_index] = True +island = [seed_index] +stack = [seed_face] # Faces still to consider on this island. +while stack: +current_face = stack.pop() +for loop in current_face.loops: +v = loop.vert +uv = loop[uv_layer].uv +for f in v.link_faces: +if used.get(f.index): +continue +if not match_uv(f, v, uv, uv_layer): +continue + +# `f` is part of island, add to island and stack +used[f.index] = True +island.append(f.index) +stack.append(f) +result.append(island) + +return result diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py index 14dc72336f6..6f61d7e7129 100644 --- a/release/scripts/startup/bl_operators/__init__.py +++ b/release/scripts/startup/bl_operators/__init__.py @@ -31,6 +31,7 @@ _modules = [ "userpref", "uvcalc_follow_active", "uvcalc_lightmap", +"uvcalc_randomize_transform", "vertexpaint_dirt", "view3d", "wm", diff --git a/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py b/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py new file mode 100644 index 000..22ae5ed9a6f --- /dev/null +++ b/release/scripts/startup/bl_operators/uvcalc_randomize_transform.py @@ -0,0 +1,210 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +from bpy.types import Operator +from mathutils import Vector + +import bpy.ops +import math + + +def get_random_transform(transform_params, entropy): +from random import uniform +from random import seed as random_seed + +(seed, loc, rot, scale, scale_even) = transform_params + +# First, seed the RNG. +random_seed(seed + entropy) + +# Next, call uniform a known number of times. +offset_u = uniform(0, 1) +offset_v = uniform(0, 1) +angle = uniform(0, 1) +scale_u = uniform(0, 1) +scale_v = uniform(0, 1) + +# Apply the transform_params. +if loc: +offset_u *= loc[0] +offset_v *= loc[1] +else: +offset_u = 0 +offset_v = 0 + +if rot: +angle *= rot +else: +angle = 0 + +if scale: +scale_u *= scale[0] +scale_v *= scale[1] +else: +scale_u = 1 +scale_v = 1 + +if scale_even: +scale_v = scale_u + +# Results in homogenous co-ordinates. +return [[scale_u * math.cos(angle), -scale_v * math.sin(angle), offset_u], +[scale_u * math.sin(angle), scale_v * math.cos(angle), offset_v]] + + +def randomize_uv_transform_island(bm, uv_layer, faces, transform_params): +entropy = min(faces) # Ensure consistent random values for island, regardless of selection etc. +transform = get_random_transform(trans
[Bf-blender-cvs] [cd516d76b64] master: Cleanup: replace uint cd_loop_uv_offset with int
Commit: cd516d76b6403246d9a34c3b3a67ac54050f3aef Author: Chris Blackbourn Date: Fri Aug 19 14:19:13 2022 +1200 Branches: master https://developer.blender.org/rBcd516d76b6403246d9a34c3b3a67ac54050f3aef Cleanup: replace uint cd_loop_uv_offset with int See https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Integer_Types === M source/blender/bmesh/tools/bmesh_path_region_uv.c M source/blender/bmesh/tools/bmesh_path_region_uv.h M source/blender/bmesh/tools/bmesh_path_uv.c M source/blender/bmesh/tools/bmesh_path_uv.h M source/blender/editors/include/ED_uvedit.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/mesh/mesh_data.cc M source/blender/editors/uvedit/uvedit_islands.c M source/blender/editors/uvedit/uvedit_path.c M source/blender/editors/uvedit/uvedit_select.c M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/bmesh/tools/bmesh_path_region_uv.c b/source/blender/bmesh/tools/bmesh_path_region_uv.c index 5c70f7fa5ec..56090ed9916 100644 --- a/source/blender/bmesh/tools/bmesh_path_region_uv.c +++ b/source/blender/bmesh/tools/bmesh_path_region_uv.c @@ -109,9 +109,10 @@ static bool bm_loop_region_test_chain(BMLoop *l, int *const depths[2], const int static LinkNode *mesh_calc_path_region_elem(BMesh *bm, BMElem *ele_src, BMElem *ele_dst, -const uint cd_loop_uv_offset, +const int cd_loop_uv_offset, const char path_htype) { + BLI_assert(cd_loop_uv_offset >= 0); int ele_loops_len[2]; BMLoop **ele_loops[2]; @@ -397,7 +398,7 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm, LinkNode *BM_mesh_calc_path_uv_region_vert(BMesh *bm, BMElem *ele_src, BMElem *ele_dst, - const uint cd_loop_uv_offset, + const int cd_loop_uv_offset, bool (*filter_fn)(BMLoop *, void *user_data), void *user_data) { @@ -426,7 +427,7 @@ LinkNode *BM_mesh_calc_path_uv_region_vert(BMesh *bm, LinkNode *BM_mesh_calc_path_uv_region_edge(BMesh *bm, BMElem *ele_src, BMElem *ele_dst, - const uint cd_loop_uv_offset, + const int cd_loop_uv_offset, bool (*filter_fn)(BMLoop *, void *user_data), void *user_data) { @@ -455,7 +456,7 @@ LinkNode *BM_mesh_calc_path_uv_region_edge(BMesh *bm, LinkNode *BM_mesh_calc_path_uv_region_face(BMesh *bm, BMElem *ele_src, BMElem *ele_dst, - const uint cd_loop_uv_offset, + const int cd_loop_uv_offset, bool (*filter_fn)(BMFace *, void *user_data), void *user_data) { diff --git a/source/blender/bmesh/tools/bmesh_path_region_uv.h b/source/blender/bmesh/tools/bmesh_path_region_uv.h index fa1b2bfcf9b..f399395e051 100644 --- a/source/blender/bmesh/tools/bmesh_path_region_uv.h +++ b/source/blender/bmesh/tools/bmesh_path_region_uv.h @@ -9,7 +9,7 @@ struct LinkNode *BM_mesh_calc_path_uv_region_vert(BMesh *bm, BMElem *ele_src, BMElem *ele_dst, - uint cd_loop_uv_offset, + int cd_loop_uv_offset, bool (*filter_fn)(BMLoop *, void *user_data), void *user_data) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2, 3); @@ -17,7 +17,7 @@ struct LinkNode *BM_mesh_calc_path_uv_region_vert(BMesh *bm, struct LinkNode *BM_mesh_calc_path_uv_region_edge(BMesh *bm, BMElem *ele_src, BMElem *ele_dst, - uint cd_loop_uv_offset, + int cd_loop_uv_offset, bool (*filter_fn)(BMLoop *, void *user_data), v
[Bf-blender-cvs] [e80a9d2645c] master: Cleanup: lint, unused_vars
Commit: e80a9d2645cdc2e73e3984ccf83abfbb744b3eeb Author: Chris Blackbourn Date: Fri Aug 19 13:44:55 2022 +1200 Branches: master https://developer.blender.org/rBe80a9d2645cdc2e73e3984ccf83abfbb744b3eeb Cleanup: lint, unused_vars === M source/blender/editors/physics/physics_fluid.c === diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 80de8fae072..1d3cf7c36af 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -502,6 +502,7 @@ static void fluid_free_startjob(void *customdata, short *stop, short *do_update, BKE_fluid_cache_free(fds, job->ob, cache_map); #else UNUSED_VARS(fds); + UNUSED_VARS(cache_map); #endif *do_update = true; ___ 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] [a5c696a0c2b] master: UV: respect uv selection for smart uv, cube, sphere and cylinder projection
Commit: a5c696a0c2b95d108a24e3060010e452c98b297d Author: Chris Blackbourn Date: Fri Aug 19 13:35:03 2022 +1200 Branches: master https://developer.blender.org/rBa5c696a0c2b95d108a24e3060010e452c98b297d UV: respect uv selection for smart uv, cube, sphere and cylinder projection Differential Revision: https://developer.blender.org/D15711 === M source/blender/editors/uvedit/uvedit_unwrap_ops.c === diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 2c7ad012dd2..fb71623f4eb 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1714,10 +1714,12 @@ static void uv_map_clip_correct_properties(wmOperatorType *ot) * such as "Unwrap" & "Smart UV Projections" will need to handle aspect correction themselves. * For now keep using a single aspect for all faces in this case. */ -static void uv_map_clip_correct_multi(Object **objects, - uint objects_len, - wmOperator *op, - bool per_face_aspect) +static void uv_map_clip_correct(const Scene *scene, +Object **objects, +uint objects_len, +wmOperator *op, +bool per_face_aspect, +bool only_selected_uvs) { BMFace *efa; BMLoop *l; @@ -1754,6 +1756,10 @@ static void uv_map_clip_correct_multi(Object **objects, continue; } +if (only_selected_uvs && !uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) { + continue; +} + BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); minmax_v2v2_v2(min, max, luv->uv); @@ -1767,6 +1773,10 @@ static void uv_map_clip_correct_multi(Object **objects, continue; } +if (only_selected_uvs && !uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) { + continue; +} + BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); clamp_v2(luv->uv, 0.0f, 1.0f); @@ -1803,6 +1813,10 @@ static void uv_map_clip_correct_multi(Object **objects, continue; } +if (only_selected_uvs && !uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) { + continue; +} + BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -1814,11 +1828,6 @@ static void uv_map_clip_correct_multi(Object **objects, } } -static void uv_map_clip_correct(Object *ob, wmOperator *op) -{ - uv_map_clip_correct_multi(, 1, op, true); -} - /** \} */ /* */ @@ -2245,6 +2254,12 @@ static int smart_project_exec(bContext *C, wmOperator *op) /* May be NULL. */ View3D *v3d = CTX_wm_view3d(C); + bool only_selected_uvs = false; + if (CTX_wm_space_image(C)) { +/* Inside the UV Editor, only project selected UVs. */ +only_selected_uvs = true; + } + const float project_angle_limit = RNA_float_get(op->ptr, "angle_limit"); const float island_margin = RNA_float_get(op->ptr, "island_margin"); const float area_weight = RNA_float_get(op->ptr, "area_weight"); @@ -2283,6 +2298,14 @@ static int smart_project_exec(bContext *C, wmOperator *op) if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { continue; } + + if (only_selected_uvs) { +if (!uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) { + uvedit_face_select_disable(scene, em->bm, efa, cd_loop_uv_offset); + continue; +} + } + thick_faces[thick_faces_len].area = BM_face_calc_area(efa); thick_faces[thick_faces_len].efa = efa; thick_faces_len++; @@ -2397,6 +2420,7 @@ static int smart_project_exec(bContext *C, wmOperator *op) .rotate = true, /* We could make this optional. */ .rotate_align_axis = 1, + .only_selected_uvs = true, .only_selected_faces = true, .correct_aspect = correct_aspect, .use_seams = true, @@ -2404,7 +2428,8 @@ static int smart_project_exec(bContext *C, wmOperator *op) /* #ED_uvedit_pack_islands_multi only supports `per_face_aspect = false`. */ const bool per_face_aspect =
[Bf-blender-cvs] [aa82f91c922] master: Cleanup: uvedit_*_select, replace `BMEditMesh*` with `BMesh*`
Commit: aa82f91c922d81456ffc6a418fd1907675de47e3 Author: Chris Blackbourn Date: Fri Aug 19 12:56:13 2022 +1200 Branches: master https://developer.blender.org/rBaa82f91c922d81456ffc6a418fd1907675de47e3 Cleanup: uvedit_*_select, replace `BMEditMesh*` with `BMesh*` Change `cd_loop_uv_offset` from signed to unsigned, forcing a crash if passed invalid input. Differential Revision: https://developer.blender.org/D15722 === M source/blender/editors/include/ED_uvedit.h M source/blender/editors/uvedit/uvedit_ops.c M source/blender/editors/uvedit/uvedit_path.c M source/blender/editors/uvedit/uvedit_rip.c M source/blender/editors/uvedit/uvedit_select.c M source/blender/editors/uvedit/uvedit_smart_stitch.c === diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index 24d6819536d..3b269189aa9 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -107,64 +107,64 @@ bool uvedit_uv_select_test(const struct Scene *scene, struct BMLoop *l, int cd_l * Changes selection state of a single UV Face. */ void uvedit_face_select_set(const struct Scene *scene, -struct BMEditMesh *em, +struct BMesh *em, struct BMFace *efa, bool select, bool do_history, -int cd_loop_uv_offset); +uint cd_loop_uv_offset); /** * \brief Select UV Edge * * Changes selection state of a single UV Edge. */ void uvedit_edge_select_set(const struct Scene *scene, -struct BMEditMesh *em, +struct BMesh *em, struct BMLoop *l, bool select, bool do_history, -int cd_loop_uv_offset); +uint cd_loop_uv_offset); /** * \brief Select UV Vertex * * Changes selection state of a single UV vertex. */ void uvedit_uv_select_set(const struct Scene *scene, - struct BMEditMesh *em, + struct BMesh *em, struct BMLoop *l, bool select, bool do_history, - int cd_loop_uv_offset); + uint cd_loop_uv_offset); /* Low level functions for (de)selecting individual UV elements. Ensure UV face visibility before * use. */ void uvedit_face_select_enable(const struct Scene *scene, - struct BMEditMesh *em, + struct BMesh *bm, struct BMFace *efa, bool do_history, - int cd_loop_uv_offset); + uint cd_loop_uv_offset); void uvedit_face_select_disable(const struct Scene *scene, -struct BMEditMesh *em, +struct BMesh *bm, struct BMFace *efa, -int cd_loop_uv_offset); +uint cd_loop_uv_offset); void uvedit_edge_select_enable(const struct Scene *scene, - struct BMEditMesh *em, + struct BMesh *bm, struct BMLoop *l, bool do_history, - int cd_loop_uv_offset); + uint cd_loop_uv_offset); void uvedit_edge_select_disable(const struct Scene *scene, -struct BMEditMesh *em, +struct BMesh *bm, struct BMLoop *l, -int cd_loop_uv_offset); +uint cd_loop_uv_offset); void uvedit_uv_select_enable(const struct Scene *scene, - struct BMEditMesh *em, + struct BMesh *bm, struct BMLoop *l, bool do_history, - int cd_loop_uv_offset); + uint cd_loop_uv_offset); void uvedit_uv_select_disable(const struct Scene *scene, - struct BMEditMesh *em, + struct BMesh *bm, struct BMLoop *l, - int cd_loop_uv_offset); + uint cd_loop_uv_offset); /* Sticky mode UV element selection functions. */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors
[Bf-blender-cvs] [836c07f29c7] master: UV: grab tool supports live unwrap
Commit: 836c07f29c76cd2c2743f72865b22e6fd2e01b03 Author: Chris Blackbourn Date: Wed Aug 17 14:46:57 2022 +1200 Branches: master https://developer.blender.org/rB836c07f29c76cd2c2743f72865b22e6fd2e01b03 UV: grab tool supports live unwrap Differential Revision: https://developer.blender.org/D15709 === M source/blender/editors/include/ED_mesh.h M source/blender/editors/sculpt_paint/sculpt_uv.c === diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index a0eaf4232c0..740a736b784 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -133,7 +133,6 @@ void EDBM_update(struct Mesh *me, const struct EDBMUpdate_Params *params); void EDBM_update_extern(struct Mesh *me, bool do_tessellation, bool is_destructive); /** - * * A specialized vert map used by stitch operator. */ struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm, diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 936fde8ac59..8135da1eb9c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -31,6 +31,7 @@ #include "ED_image.h" #include "ED_mesh.h" #include "ED_screen.h" +#include "ED_uvedit.h" #include "WM_api.h" #include "WM_types.h" @@ -579,11 +580,19 @@ static void uv_sculpt_stroke_apply(bContext *C, copy_v2_v2(luv->uv, sculptdata->uv[uvindex].uv); } } +SpaceImage *sima = CTX_wm_space_image(C); +if (sima->flag & SI_LIVE_UNWRAP) { + ED_uvedit_live_unwrap_re_solve(); +} } } static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op) { + SpaceImage *sima = CTX_wm_space_image(C); + if (sima->flag & SI_LIVE_UNWRAP) { +ED_uvedit_live_unwrap_end(false); + } UvSculptData *data = op->customdata; if (data->timer) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), data->timer); @@ -895,6 +904,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm } data->initial_stroke->totalInitialSelected = counter; + if (sima->flag & SI_LIVE_UNWRAP) { +ED_uvedit_live_unwrap_begin(scene, obedit); + } } } ___ 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] [74ea0bee9c0] master: UV: add geometry driven uv relax brush
Commit: 74ea0bee9c0af14ddd2105aafe4b9597885fa3c1 Author: Chris Blackbourn Date: Tue Aug 16 19:41:35 2022 +1200 Branches: master https://developer.blender.org/rB74ea0bee9c0af14ddd2105aafe4b9597885fa3c1 UV: add geometry driven uv relax brush Differential Revision: https://developer.blender.org/D15530 === M source/blender/editors/include/ED_mesh.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/sculpt_paint/sculpt_uv.c M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_scene.c M source/tools === diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index a1c1c816d4c..a0eaf4232c0 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -133,6 +133,7 @@ void EDBM_update(struct Mesh *me, const struct EDBMUpdate_Params *params); void EDBM_update_extern(struct Mesh *me, bool do_tessellation, bool is_destructive); /** + * * A specialized vert map used by stitch operator. */ struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm, @@ -141,11 +142,13 @@ struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm, bool use_winding, bool do_islands); void BM_uv_element_map_free(struct UvElementMap *element_map); -struct UvElement *BM_uv_element_get(struct UvElementMap *map, -struct BMFace *efa, -struct BMLoop *l); +struct UvElement *BM_uv_element_get(const struct UvElementMap *map, +const struct BMFace *efa, +const struct BMLoop *l); struct UvElement *BM_uv_element_get_head(struct UvElementMap *map, struct UvElement *child); +struct UvElement **BM_uv_element_map_ensure_head_table(struct UvElementMap *element_map); + /** * Can we edit UV's for this mesh? */ diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index e931dd02a9e..941965357c1 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -593,10 +593,10 @@ UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, uint v) return vmap->vert[v]; } -static void bm_uv_ensure_head_table(UvElementMap *element_map) +struct UvElement **BM_uv_element_map_ensure_head_table(struct UvElementMap *element_map) { if (element_map->head_table) { -return; +return element_map->head_table; } /* For each UvElement, locate the "separate" UvElement that precedes it in the linked list. */ @@ -616,6 +616,7 @@ static void bm_uv_ensure_head_table(UvElementMap *element_map) } } } + return element_map->head_table; } #define INVALID_ISLAND ((unsigned int)-1) @@ -645,7 +646,7 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, bool uv_selected, int cd_loop_uv_offset) { - bm_uv_ensure_head_table(element_map); + BM_uv_element_map_ensure_head_table(element_map); int total_uvs = element_map->total_uvs; @@ -1070,7 +1071,7 @@ void BM_uv_element_map_free(UvElementMap *element_map) } } -UvElement *BM_uv_element_get(UvElementMap *element_map, BMFace *efa, BMLoop *l) +UvElement *BM_uv_element_get(const UvElementMap *element_map, const BMFace *efa, const BMLoop *l) { UvElement *element = element_map->vertex[BM_elem_index_get(l->v)]; while (element) { diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index ccfcc82f006..936fde8ac59 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -9,7 +9,7 @@ #include "MEM_guardedalloc.h" #include "BLI_ghash.h" -#include "BLI_math.h" +#include "BLI_math_base_safe.h" #include "BLI_utildefines.h" #include "DNA_brush_types.h" @@ -43,6 +43,11 @@ #include "UI_view2d.h" +/* When set, the UV element is on the boundary of the graph. + * i.e. Instead of a 2-dimensional laplace operator, use a 1-dimensional version. + * Visually, UV elements on the graph boundary appear as borders of the UV Island. */ +#define MARK_BOUNDARY 1 + typedef struct UvAdjacencyElement { /* pointer to original uvelement */ UvElement *element; @@ -230,6 +235,13 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em, MEM_SAFE_FREE(tmp_uvdata); } +/* Legacy version which only does laplacian relaxation. + * Probably a little faster as it caches UvEdges. + * Mostly preserved for comparison wi
[Bf-blender-cvs] [3c351da89f7] master: UV: improve uv sculpt tools with boundary support and pin support
Commit: 3c351da89f7067171132fd865951f5586fe36fc1 Author: Chris Blackbourn Date: Tue Aug 16 17:13:29 2022 +1200 Branches: master https://developer.blender.org/rB3c351da89f7067171132fd865951f5586fe36fc1 UV: improve uv sculpt tools with boundary support and pin support Fix boundary conditions for the Relax UV tool with the Laplacian method. Add Pinned UV support to Relax UV tool (all modes) and Pinch UV tool. Differential Revision: https://developer.blender.org/D15669 === M source/blender/editors/sculpt_paint/sculpt_uv.c === diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 14b06f888fe..60d0c6d47de 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -42,23 +42,22 @@ #include "UI_view2d.h" -#define MARK_BOUNDARY 1 - typedef struct UvAdjacencyElement { /* pointer to original uvelement */ UvElement *element; /* uv pointer for convenience. Caution, this points to the original UVs! */ float *uv; - /* general use flag (Used to check if Element is boundary here) */ - char flag; + /* Are we on locked in place? */ + bool is_locked; + /* Are we on the boundary? */ + bool is_boundary; } UvAdjacencyElement; typedef struct UvEdge { uint uv1; uint uv2; - /* general use flag - * (Used to check if edge is boundary here, and propagates to adjacency elements) */ - char flag; + /* Are we in the interior? */ + bool is_interior; } UvEdge; typedef struct UVInitialStrokeElement { @@ -170,17 +169,14 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em, } for (i = 0; i < sculptdata->totalUniqueUvs; i++) { -float dist; -/* This is supposed to happen only if "Pin Edges" is on, - * since we have initialization on stroke start. - * If ever uv brushes get their own mode we should check for toolsettings option too. */ -if (sculptdata->uv[i].flag & MARK_BOUNDARY) { +if (sculptdata->uv[i].is_locked) { continue; } sub_v2_v2v2(diff, sculptdata->uv[i].uv, mouse_coord); diff[1] /= aspectRatio; -if ((dist = dot_v2v2(diff, diff)) <= radius) { +float dist = dot_v2v2(diff, diff); +if (dist <= radius) { UvElement *element; float strength; strength = alpha * BKE_brush_curve_strength_clamped(brush, sqrtf(dist), radius_root); @@ -233,11 +229,16 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, /* counting neighbors */ for (i = 0; i < sculptdata->totalUvEdges; i++) { UvEdge *tmpedge = sculptdata->uvedges + i; -tmp_uvdata[tmpedge->uv1].ncounter++; -tmp_uvdata[tmpedge->uv2].ncounter++; - -add_v2_v2(tmp_uvdata[tmpedge->uv2].sum_co, sculptdata->uv[tmpedge->uv1].uv); -add_v2_v2(tmp_uvdata[tmpedge->uv1].sum_co, sculptdata->uv[tmpedge->uv2].uv); +bool code1 = sculptdata->uv[sculptdata->uvedges[i].uv1].is_boundary; +bool code2 = sculptdata->uv[sculptdata->uvedges[i].uv2].is_boundary; +if (code1 || (code1 == code2)) { + tmp_uvdata[tmpedge->uv2].ncounter++; + add_v2_v2(tmp_uvdata[tmpedge->uv2].sum_co, sculptdata->uv[tmpedge->uv1].uv); +} +if (code2 || (code1 == code2)) { + tmp_uvdata[tmpedge->uv1].ncounter++; + add_v2_v2(tmp_uvdata[tmpedge->uv1].sum_co, sculptdata->uv[tmpedge->uv2].uv); +} } /* Original Laplacian algorithm included removal of normal component of translation. @@ -248,17 +249,14 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, } for (i = 0; i < sculptdata->totalUniqueUvs; i++) { -float dist; -/* This is supposed to happen only if "Pin Edges" is on, - * since we have initialization on stroke start. - * If ever uv brushes get their own mode we should check for toolsettings option too. */ -if (sculptdata->uv[i].flag & MARK_BOUNDARY) { +if (sculptdata->uv[i].is_locked) { continue; } sub_v2_v2v2(diff, sculptdata->uv[i].uv, mouse_coord); diff[1] /= aspectRatio; -if ((dist = dot_v2v2(diff, diff)) <= radius) { +float dist = dot_v2v2(diff, diff); +if (dist <= radius) { UvElement *element; float strength; strength = alpha * BKE_brush_curve_strength_clamped(brush, sqrtf(dist), radius_root); @@ -327,17 +325,15 @@ static void uv_sculpt_stroke_apply(bContext *C, int i; alpha *= invert; for (i = 0; i < sculptdata->totalUniqueUvs; i++) { - float dist, diff[2]; - /* This is supposed to happen only if "Lock Borders" is on, - * since we have initialization on stroke start. - * If ever uv brushes get their own mode we should check for toolset
[Bf-blender-cvs] [66822319d3e] master: UV: add constrain-to-bounds support for uv relax, uv grab and uv pinch
Commit: 66822319d3ee68196e9e296498a762f3852db1a1 Author: Chris Blackbourn Date: Tue Aug 16 18:26:04 2022 +1200 Branches: master https://developer.blender.org/rB66822319d3ee68196e9e296498a762f3852db1a1 UV: add constrain-to-bounds support for uv relax, uv grab and uv pinch Differential Revision: https://developer.blender.org/D15683 === M source/blender/editors/sculpt_paint/sculpt_uv.c === diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 60d0c6d47de..ccfcc82f006 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -22,6 +22,7 @@ #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_editmesh.h" +#include "BKE_image.h" #include "BKE_mesh_mapping.h" #include "BKE_paint.h" @@ -89,13 +90,13 @@ typedef struct UvSculptData { * to their coincident UV's */ UvAdjacencyElement *uv; - /* ...Is what it says */ + /* Total number of unique UVs. */ int totalUniqueUvs; /* Edges used for adjacency info, used with laplacian smoothing */ UvEdge *uvedges; - /* need I say more? */ + /* Total number of #UvEdge. */ int totalUvEdges; /* data for initial stroke, used by tools like grab */ @@ -115,8 +116,25 @@ typedef struct UvSculptData { /* store invert flag here */ char invert; + + /* Is constrain to image bounds active? */ + bool constrain_to_bounds; + + /* Base for constrain_to_bounds. */ + float uv_base_offset[2]; } UvSculptData; +static void apply_sculpt_data_constraints(UvSculptData *sculptdata, float uv[2]) +{ + if (!sculptdata->constrain_to_bounds) { +return; + } + float u = sculptdata->uv_base_offset[0]; + float v = sculptdata->uv_base_offset[1]; + uv[0] = clamp_f(uv[0], u, u + 1.0f); + uv[1] = clamp_f(uv[1], v, v + 1.0f); +} + /*** Improved Laplacian Relaxation Operator / /* original code by Raul Fernandez Hernandez "farsthary" * * adapted to uv smoothing by Antony Riakiatakis * @@ -192,6 +210,8 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em, 0.5f * (tmp_uvdata[i].b[1] + tmp_uvdata[i].sum_b[1] / tmp_uvdata[i].ncounter)); + apply_sculpt_data_constraints(sculptdata, sculptdata->uv[i].uv); + for (element = sculptdata->uv[i].element; element; element = element->next) { MLoopUV *luv; BMLoop *l; @@ -266,6 +286,8 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, sculptdata->uv[i].uv[1] = (1.0f - strength) * sculptdata->uv[i].uv[1] + strength * tmp_uvdata[i].p[1]; + apply_sculpt_data_constraints(sculptdata, sculptdata->uv[i].uv); + for (element = sculptdata->uv[i].element; element; element = element->next) { MLoopUV *luv; BMLoop *l; @@ -342,6 +364,8 @@ static void uv_sculpt_stroke_apply(bContext *C, sculptdata->uv[i].uv[0] -= strength * diff[0] * 0.001f; sculptdata->uv[i].uv[1] -= strength * diff[1] * 0.001f; +apply_sculpt_data_constraints(sculptdata, sculptdata->uv[i].uv); + for (element = sculptdata->uv[i].element; element; element = element->next) { MLoopUV *luv; BMLoop *l; @@ -388,6 +412,8 @@ static void uv_sculpt_stroke_apply(bContext *C, sculptdata->uv[uvindex].uv[1] = sculptdata->initial_stroke->initialSelection[i].initial_uv[1] + strength * diff[1]; + apply_sculpt_data_constraints(sculptdata, sculptdata->uv[uvindex].uv); + for (element = sculptdata->uv[uvindex].element; element; element = element->next) { MLoopUV *luv; BMLoop *l; @@ -643,11 +669,14 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm } } +SpaceImage *sima = CTX_wm_space_image(C); +data->constrain_to_bounds = (sima->flag & SI_CLIP_UV); +BKE_image_find_nearest_tile_with_offset(sima->image, co, data->uv_base_offset); + /* Allocate initial selection for grab tool */ if (data->tool == UV_SCULPT_TOOL_GRAB) { float radius, radius_root; UvSculptData *sculptdata = (UvSculptData *)op->customdata; - SpaceImage *sima; int width, height; float aspectRatio; float alpha, zoomx, zoomy; @@ -656,7 +685,6 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm alpha = BKE_brush_alpha_get(scene, brush); radius = BKE_brush_size_get(scene, brush); - sima = CTX_wm_space_image(C); ED_space_image_get_size(sima,
[Bf-blender-cvs] [77c867a5ee0] master: Cleanup: simplify sin_cos_from_fraction
Commit: 77c867a5ee0141c6115c82f155ce5e1b7a487a66 Author: Chris Blackbourn Date: Mon Aug 15 15:39:07 2022 +1200 Branches: master https://developer.blender.org/rB77c867a5ee0141c6115c82f155ce5e1b7a487a66 Cleanup: simplify sin_cos_from_fraction Multiply numerator and denominator by 8 to split circle into octants. Use symmetry and negation to increase precision. === M source/blender/blenlib/intern/math_rotation.c === diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 03275ce19b4..ddfaadced60 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -915,107 +915,63 @@ float tri_to_quat(float q[4], const float a[3], const float b[3], const float c[ return len; } -void sin_cos_from_fraction(int numerator, const int denominator, float *r_sin, float *r_cos) +void sin_cos_from_fraction(int numerator, int denominator, float *r_sin, float *r_cos) { - /* By default, creating an circle from an integer: calling #sinf & #cosf on the fraction doesn't - * create symmetrical values (because of float imprecision). + /* By default, creating a circle from an integer: calling #sinf & #cosf on the fraction doesn't + * create symmetrical values (because floats can't represent Pi exactly). * Resolve this when the rotation is calculated from a fraction by mapping the `numerator` * to lower values so X/Y values for points around a circle are exactly symmetrical, see T87779. * - * - Numbers divisible by 4 are mapped to the lower 8th (8 axis symmetry). - * - Even numbers are mapped to the lower quarter (4 axis symmetry). - * - Odd numbers are mapped to the lower half (1 axis symmetry). + * Multiply both the `numerator` and `denominator` by eight to ensure we can divide the circle + * into 8 octants. For each octant, we then use symmetry and negation to bring the `numerator` + * closer to the origin where precision is highest. * - * Once the values are calculated, the are mapped back to their position in the circle - * using negation & swapping values. */ - - BLI_assert((numerator <= denominator) && (denominator > 0)); - enum { NEGATE_SIN_BIT = 0, NEGATE_COS_BIT = 1, SWAP_SIN_COS_BIT = 2 }; - enum { -NEGATE_SIN = (1 << NEGATE_SIN_BIT), -NEGATE_COS = (1 << NEGATE_COS_BIT), -SWAP_SIN_COS = (1 << SWAP_SIN_COS_BIT), - } xform = 0; - if ((denominator & 3) == 0) { -/* The denominator divides by 4, determine the quadrant then further refine the upper 8th. */ -const int denominator_4 = denominator / 4; -if (numerator < denominator_4) { - /* Fall through. */ -} -else { - if (numerator < denominator_4 * 2) { -numerator -= denominator_4; -xform = NEGATE_SIN | SWAP_SIN_COS; - } - else if (numerator == denominator_4 * 2) { -numerator = 0; -xform = NEGATE_COS; - } - else if (numerator < denominator_4 * 3) { -numerator -= denominator_4 * 2; -xform = NEGATE_SIN | NEGATE_COS; - } - else if (numerator == denominator_4 * 3) { -numerator = 0; -xform = NEGATE_COS | SWAP_SIN_COS; - } - else { -numerator -= denominator_4 * 3; -xform = NEGATE_COS | SWAP_SIN_COS; - } -} -/* Further increase accuracy by using the range of the upper 8th. */ -const int numerator_test = denominator_4 - numerator; -if (numerator_test < numerator) { - numerator = numerator_test; - xform ^= SWAP_SIN_COS; - /* Swap #NEGATE_SIN, #NEGATE_COS flags. */ - xform = (xform & (uint)(~(NEGATE_SIN | NEGATE_COS))) | - (((xform & NEGATE_SIN) >> NEGATE_SIN_BIT) << NEGATE_COS_BIT) | - (((xform & NEGATE_COS) >> NEGATE_COS_BIT) << NEGATE_SIN_BIT); -} - } - else if ((denominator & 1) == 0) { -/* The denominator divides by 2, determine the quadrant then further refine the upper 4th. */ -const int denominator_2 = denominator / 2; -if (numerator < denominator_2) { - /* Fall through. */ -} -else if (numerator == denominator_2) { - numerator = 0; - xform = NEGATE_COS; -} -else { - numerator -= denominator_2; - xform = NEGATE_SIN | NEGATE_COS; -} -/* Further increase accuracy by using the range of the upper 4th. */ -const int numerator_test = denominator_2 - numerator; -if (numerator_test < numerator) { - numerator = numerator_test; - xform ^= NEGATE_COS; -} - } - else { -/* The denominator is an odd number, only refine the upper half. */ -const int numerator_test = denominator - numerator; -if (numerator_test < numerator) { - numerator = numera
[Bf-blender-cvs] [4a11c0aabb0] master: Fix regression: crash with uv constrain to bounds without image
Commit: 4a11c0aabb0d9a01a6e16ab290adb3df4ee1db58 Author: Chris Blackbourn Date: Sat Aug 13 18:10:44 2022 +1200 Branches: master https://developer.blender.org/rB4a11c0aabb0d9a01a6e16ab290adb3df4ee1db58 Fix regression: crash with uv constrain to bounds without image Merge confusion between cc1daa9b766d and 0d62e963b06e. === M source/blender/blenkernel/intern/image.cc === diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index d915a9db76c..3e5d997c873 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -926,7 +926,7 @@ int BKE_image_find_nearest_tile_with_offset(const Image *image, zero_v2(r_uv_offset); int tile_number_best = -1; - if (image->source != IMA_SRC_TILED) { + if (!image || image->source != IMA_SRC_TILED) { return tile_number_best; } ___ 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] [f35d671f466] master: Cleanup: refactoring uvislands to prepare for python api
Commit: f35d671f466da324ebe70eef3edf12bd3b2b63c9 Author: Chris Blackbourn Date: Thu Aug 11 14:18:31 2022 +1200 Branches: master https://developer.blender.org/rBf35d671f466da324ebe70eef3edf12bd3b2b63c9 Cleanup: refactoring uvislands to prepare for python api Add element_map->island_total_uvs. Add element_map->island_total_unique_uvs. Simplify callers based on new members. Add comments. Resolves: D15598 === M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/sculpt_paint/sculpt_uv.c M source/blender/editors/transform/transform_convert_mesh_uv.c M source/blender/editors/uvedit/uvedit_ops.c M source/blender/editors/uvedit/uvedit_select.c M source/blender/editors/uvedit/uvedit_smart_stitch.c === diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index 455f42366cc..525483bae19 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -68,16 +68,20 @@ typedef struct UvElementMap { /** Total number of unique UVs. */ int total_unique_uvs; - /* If Non-NULL, address UvElements by `BM_elem_index_get(BMVert*)`. */ + /** If Non-NULL, address UvElements by `BM_elem_index_get(BMVert*)`. */ struct UvElement **vertex; - /* If Non-NULL, pointer to local head of each unique UV. */ + /** If Non-NULL, pointer to local head of each unique UV. */ struct UvElement **head_table; - /* Number of Islands in the mesh */ - int totalIslands; - /* Stores the starting index in buf where each island begins */ - int *islandIndices; + /** Number of islands, or zero if not calculated. */ + int total_islands; + /** Array of starting index in #storage where each island begins. */ + int *island_indices; + /** Array of number of UVs in each island. */ + int *island_total_uvs; + /** Array of number of unique UVs in each island. */ + int *island_total_unique_uvs; } UvElementMap; /* Connectivity data */ diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index a0e20e4db8a..e931dd02a9e 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -820,28 +820,32 @@ static void bm_uv_build_islands(UvElementMap *element_map, } } - element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands, - "UvElementMap_island_indices"); + element_map->island_indices = MEM_callocN(sizeof(*element_map->island_indices) * nislands, +__func__); + element_map->island_total_uvs = MEM_callocN(sizeof(*element_map->island_total_uvs) * nislands, + __func__); + element_map->island_total_unique_uvs = MEM_callocN( + sizeof(*element_map->island_total_unique_uvs) * nislands, __func__); int j = 0; for (int i = 0; i < totuv; i++) { -UvElement *element = element_map->storage[i].next; -if (element == NULL) { - islandbuf[map[i]].next = NULL; -} -else { - islandbuf[map[i]].next = [map[element - element_map->storage]]; -} +UvElement *next = element_map->storage[i].next; +islandbuf[map[i]].next = next ? [map[next - element_map->storage]] : NULL; if (islandbuf[i].island != j) { j++; - element_map->islandIndices[j] = i; + element_map->island_indices[j] = i; +} +BLI_assert(islandbuf[i].island == j); +element_map->island_total_uvs[j]++; +if (islandbuf[i].separate) { + element_map->island_total_unique_uvs[j]++; } } MEM_SAFE_FREE(element_map->storage); element_map->storage = islandbuf; islandbuf = NULL; - element_map->totalIslands = nislands; + element_map->total_islands = nislands; MEM_SAFE_FREE(stack); MEM_SAFE_FREE(map); } @@ -1059,7 +1063,9 @@ void BM_uv_element_map_free(UvElementMap *element_map) MEM_SAFE_FREE(element_map->storage); MEM_SAFE_FREE(element_map->vertex); MEM_SAFE_FREE(element_map->head_table); -MEM_SAFE_FREE(element_map->islandIndices); +MEM_SAFE_FREE(element_map->island_indices); +MEM_SAFE_FREE(element_map->island_total_uvs); +MEM_SAFE_FREE(element_map->island_total_unique_uvs); MEM_SAFE_FREE(element_map); } } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 2e2abd30ea2..14b06f888fe 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -518,13 +518,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *
[Bf-blender-cvs] [fb7ef40006b] master: Cleanup: refactoring uvislands to prepare for python api
Commit: fb7ef40006b938bab25f4bb60d8a23fc9ef2e8dc Author: Chris Blackbourn Date: Thu Aug 11 11:20:00 2022 +1200 Branches: master https://developer.blender.org/rBfb7ef40006b938bab25f4bb60d8a23fc9ef2e8dc Cleanup: refactoring uvislands to prepare for python api Add #bm_uv_ensure_head_table See also: D15598 === M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/mesh/editmesh_utils.c === diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index 2bc6289af85..455f42366cc 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -71,6 +71,9 @@ typedef struct UvElementMap { /* If Non-NULL, address UvElements by `BM_elem_index_get(BMVert*)`. */ struct UvElement **vertex; + /* If Non-NULL, pointer to local head of each unique UV. */ + struct UvElement **head_table; + /* Number of Islands in the mesh */ int totalIslands; /* Stores the starting index in buf where each island begins */ diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index c446fb8b3e1..a0e20e4db8a 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -593,6 +593,31 @@ UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, uint v) return vmap->vert[v]; } +static void bm_uv_ensure_head_table(UvElementMap *element_map) +{ + if (element_map->head_table) { +return; + } + + /* For each UvElement, locate the "separate" UvElement that precedes it in the linked list. */ + element_map->head_table = MEM_mallocN(sizeof(*element_map->head_table) * element_map->total_uvs, +"uv_element_map_head_table"); + UvElement **head_table = element_map->head_table; + for (int i = 0; i < element_map->total_uvs; i++) { +UvElement *head = element_map->storage + i; +if (head->separate) { + UvElement *element = head; + while (element) { +head_table[element - element_map->storage] = head; +element = element->next; +if (element && element->separate) { + break; +} + } +} + } +} + #define INVALID_ISLAND ((unsigned int)-1) static void bm_uv_assign_island(UvElementMap *element_map, @@ -620,23 +645,9 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, bool uv_selected, int cd_loop_uv_offset) { - int total_uvs = element_map->total_uvs; + bm_uv_ensure_head_table(element_map); - /* For each UvElement, locate the "separate" UvElement that precedes it in the linked list. */ - UvElement **head_table = MEM_mallocN(sizeof(*head_table) * total_uvs, "uv_island_head_table"); - for (int i = 0; i < total_uvs; i++) { -UvElement *head = element_map->storage + i; -if (head->separate) { - UvElement *element = head; - while (element) { -head_table[element - element_map->storage] = head; -element = element->next; -if (element && element->separate) { - break; -} - } -} - } + int total_uvs = element_map->total_uvs; /* Depth first search the graph, building islands as we go. */ int nislands = 0; @@ -676,7 +687,7 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, if (!uv_selected || uvedit_edge_select_test(scene, element->l, cd_loop_uv_offset)) { UvElement *next = BM_uv_element_get(element_map, element->l->next->f, element->l->next); if (next->island == INVALID_ISLAND) { -UvElement *tail = head_table[next - element_map->storage]; +UvElement *tail = element_map->head_table[next - element_map->storage]; stack_uv[stacksize_uv++] = tail; while (tail) { bm_uv_assign_island(element_map, tail, nislands, map, islandbuf, islandbufsize++); @@ -692,7 +703,7 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, if (!uv_selected || uvedit_edge_select_test(scene, element->l->prev, cd_loop_uv_offset)) { UvElement *prev = BM_uv_element_get(element_map, element->l->prev->f, element->l->prev); if (prev->island == INVALID_ISLAND) { -UvElement *tail = head_table[prev - element_map->storage]; +UvElement *tail = element_map->head_table[prev - element_map->storage]; stack_uv[stacksize_uv++] = tail; while (tail) { bm_uv_assign_island(element_map, tail, nislands, map, islandbuf, islandbufsize++)
[Bf-blender-cvs] [e19986482f1] master: Cleanup: reduce asan lint and clang-tidy warnings on uv_parametrizer
Commit: e19986482f1fdb546195b97d82ccff4c7ac44804 Author: Chris Blackbourn Date: Wed Aug 10 20:13:17 2022 +1200 Branches: master https://developer.blender.org/rBe19986482f1fdb546195b97d82ccff4c7ac44804 Cleanup: reduce asan lint and clang-tidy warnings on uv_parametrizer === M source/blender/geometry/GEO_uv_parametrizer.h M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/GEO_uv_parametrizer.h b/source/blender/geometry/GEO_uv_parametrizer.h index 5285aefbd4c..ff110f18ffb 100644 --- a/source/blender/geometry/GEO_uv_parametrizer.h +++ b/source/blender/geometry/GEO_uv_parametrizer.h @@ -13,8 +13,8 @@ extern "C" { #endif typedef struct ParamHandle ParamHandle; /* Handle to an array of charts. */ -typedef intptr_t ParamKey; /* Key (hash) for identifying verts and faces. */ -#define PARAM_KEY_MAX INTPTR_MAX +typedef uintptr_t ParamKey; /* Key (hash) for identifying verts and faces. */ +#define PARAM_KEY_MAX UINTPTR_MAX /* */ /** \name Chart Construction: diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index 26de4679768..27e6ea642f6 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -30,7 +30,7 @@ /* Special Purpose Hash */ -typedef intptr_t PHashKey; +typedef uintptr_t PHashKey; typedef struct PHashLink { struct PHashLink *next; @@ -45,7 +45,7 @@ typedef struct PHash { /* Simplices */ -typedef struct PVert { +struct PVert { struct PVert *nextlink; union PVertUnion { @@ -58,9 +58,9 @@ typedef struct PVert { float co[3]; float uv[2]; uint flag; -} PVert; +}; -typedef struct PEdge { +struct PEdge { struct PEdge *nextlink; union PEdgeUnion { @@ -76,9 +76,9 @@ typedef struct PEdge { struct PFace *face; float *orig_uv, old_uv[2]; uint flag; -} PEdge; +}; -typedef struct PFace { +struct PFace { struct PFace *nextlink; union PFaceUnion { @@ -89,8 +89,8 @@ typedef struct PFace { } u; struct PEdge *edge; - uchar flag; -} PFace; + uint flag; +}; enum PVertFlag { PVERT_PIN = 1, @@ -123,7 +123,7 @@ enum PFaceFlag { /* Chart */ -typedef struct PChart { +struct PChart { PVert *verts; PEdge *edges; PFace *faces; @@ -151,7 +151,7 @@ typedef struct PChart { } u; bool has_pins; -} PChart; +}; enum PHandleState { PHANDLE_STATE_ALLOCATED, @@ -160,7 +160,7 @@ enum PHandleState { PHANDLE_STATE_STRETCH, }; -typedef struct ParamHandle { +struct ParamHandle { enum PHandleState state; MemArena *arena; MemArena *polyfill_arena; @@ -181,7 +181,7 @@ typedef struct ParamHandle { RNG *rng; float blend; -} ParamHandle; +}; /* PHash * - special purpose hash that keeps all its elements in a single linked list. @@ -3684,9 +3684,9 @@ static void p_chart_rotate_fit_aabb(PChart *chart) /* Exported */ -ParamHandle *GEO_uv_parametrizer_construct_begin(void) +ParamHandle *GEO_uv_parametrizer_construct_begin() { - ParamHandle *handle = (ParamHandle *)MEM_callocN(sizeof(*handle), "ParamHandle"); + ParamHandle *handle = new ParamHandle(); handle->construction_chart = (PChart *)MEM_callocN(sizeof(PChart), "PChart"); handle->state = PHANDLE_STATE_ALLOCATED; handle->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param construct arena"); @@ -3710,6 +3710,9 @@ void GEO_uv_parametrizer_aspect_ratio(ParamHandle *phandle, float aspx, float as void GEO_uv_parametrizer_delete(ParamHandle *phandle) { + if (!phandle) { +return; + } param_assert(ELEM(phandle->state, PHANDLE_STATE_ALLOCATED, PHANDLE_STATE_CONSTRUCTED)); for (int i = 0; i < phandle->ncharts; i++) { @@ -3738,7 +3741,7 @@ void GEO_uv_parametrizer_delete(ParamHandle *phandle) phandle->rng = NULL; } - MEM_freeN(phandle); + delete phandle; } typedef struct GeoUVPinIndex { ___ 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] [13c5f6e08ff] master: Cleanup: refactoring uvislands to prepare for python api
Commit: 13c5f6e08ff783b2bf8060e36b73affa28a5e7ac Author: Chris Blackbourn Date: Wed Aug 10 20:13:17 2022 +1200 Branches: master https://developer.blender.org/rB13c5f6e08ff783b2bf8060e36b73affa28a5e7ac Cleanup: refactoring uvislands to prepare for python api Migrate island calculation to #bm_uv_build_islands. Simplify connectedness calculation. Reduce memory pressure. No functional changes. See also: D15598 === M source/blender/editors/mesh/editmesh_utils.c === diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 208022326d3..c446fb8b3e1 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -721,6 +721,120 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, return nislands; } +static void bm_uv_build_islands(UvElementMap *element_map, +BMesh *bm, +const Scene *scene, +bool uv_selected) +{ + int totuv = element_map->total_uvs; + int nislands = 0; + int islandbufsize = 0; + + /* map holds the map from current vmap->buf to the new, sorted map */ + uint *map = MEM_mallocN(sizeof(*map) * totuv, "uvelement_remap"); + BMFace **stack = MEM_mallocN(sizeof(*stack) * bm->totface, "uv_island_face_stack"); + UvElement *islandbuf = MEM_callocN(sizeof(*islandbuf) * totuv, "uvelement_island_buffer"); + /* Island number for BMFaces. */ + int *island_number = MEM_callocN(sizeof(*island_number) * bm->totface, "uv_island_number_face"); + copy_vn_i(island_number, bm->totface, INVALID_ISLAND); + + const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); + + const bool use_uv_edge_connectivity = scene->toolsettings->uv_flag & UV_SYNC_SELECTION ? +scene->toolsettings->selectmode & SCE_SELECT_EDGE : +scene->toolsettings->uv_selectmode & UV_SELECT_EDGE; + if (use_uv_edge_connectivity) { +nislands = bm_uv_edge_select_build_islands( +element_map, scene, islandbuf, map, uv_selected, cd_loop_uv_offset); +islandbufsize = totuv; + } + + for (int i = 0; i < totuv; i++) { +if (element_map->storage[i].island == INVALID_ISLAND) { + int stacksize = 0; + element_map->storage[i].island = nislands; + stack[0] = element_map->storage[i].l->f; + island_number[BM_elem_index_get(stack[0])] = nislands; + stacksize = 1; + + while (stacksize > 0) { +BMFace *efa = stack[--stacksize]; + +BMLoop *l; +BMIter liter; +BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { + if (uv_selected && !uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { +continue; + } + + UvElement *initelement = element_map->vertex[BM_elem_index_get(l->v)]; + + for (UvElement *element = initelement; element; element = element->next) { +if (element->separate) { + initelement = element; +} + +if (element->l->f == efa) { + /* found the uv corresponding to our face and vertex. + * Now fill it to the buffer */ + bm_uv_assign_island(element_map, element, nislands, map, islandbuf, islandbufsize++); + + for (element = initelement; element; element = element->next) { +if (element->separate && element != initelement) { + break; +} + +if (island_number[BM_elem_index_get(element->l->f)] == INVALID_ISLAND) { + stack[stacksize++] = element->l->f; + island_number[BM_elem_index_get(element->l->f)] = nislands; +} + } + break; +} + } +} + } + + nislands++; +} + } + + MEM_SAFE_FREE(island_number); + + /* remap */ + for (int i = 0; i < bm->totvert; i++) { +/* important since we may do selection only. Some of these may be NULL */ +if (element_map->vertex[i]) { + element_map->vertex[i] = [map[element_map->vertex[i] - element_map->storage]]; +} + } + + element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands, + "UvElementMap_island_indices"); + int j = 0; + for (int i = 0; i < totuv; i++) { +UvElement *element = element_map->storage[i].next; +if (element == NULL) { + islandbuf[map[i]].next = NULL; +} +else { + islandbuf[map[i]].next = [map[element - element_map->storage]]; +
[Bf-blender-cvs] [39f706a76c1] master: Cleanup: fix attr_nonnull error found by asan
Commit: 39f706a76c1db12e4d6e9f89bc9ed0a522ec2562 Author: Chris Blackbourn Date: Wed Aug 10 16:55:43 2022 +1200 Branches: master https://developer.blender.org/rB39f706a76c1db12e4d6e9f89bc9ed0a522ec2562 Cleanup: fix attr_nonnull error found by asan === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index ae2794bf9bc..26de4679768 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -3733,8 +3733,10 @@ void GEO_uv_parametrizer_delete(ParamHandle *phandle) BLI_memarena_free(phandle->polyfill_arena); BLI_heap_free(phandle->polyfill_heap, NULL); - BLI_rng_free(phandle->rng); - phandle->rng = NULL; + if (phandle->rng) { +BLI_rng_free(phandle->rng); +phandle->rng = NULL; + } MEM_freeN(phandle); } ___ 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] [e22628c70bf] master: Cleanup: refactoring uvislands to prepare for python api
Commit: e22628c70bf221acf084e20373da9d40ebc2bfa8 Author: Chris Blackbourn Date: Mon Aug 8 19:59:33 2022 +1200 Branches: master https://developer.blender.org/rBe22628c70bf221acf084e20373da9d40ebc2bfa8 Cleanup: refactoring uvislands to prepare for python api Fix copy+paste bug === M source/blender/editors/mesh/editmesh_utils.c === diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 78390db5349..195a3686b3b 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -836,7 +836,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, UvElement *v = vlist; vlist = vlist->next; v->next = newvlist; - UvElement *newvlist = v; + newvlist = v; luv = BM_ELEM_CD_GET_VOID_P(v->l, cd_loop_uv_offset); const float *uv = luv->uv; ___ 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] [bb8488c62c9] master: Cleanup: refactoring uvislands to prepare for python api
Commit: bb8488c62c9ae5a62e46c50d9e3a69d413c28ded Author: Chris Blackbourn Date: Mon Aug 8 11:47:30 2022 +1200 Branches: master https://developer.blender.org/rBbb8488c62c9ae5a62e46c50d9e3a69d413c28ded Cleanup: refactoring uvislands to prepare for python api Rename vert -> vertex. Add `BM_uv_element_get_head`. See also: D15598 === M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/include/ED_mesh.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/sculpt_paint/sculpt_uv.c M source/blender/editors/uvedit/uvedit_smart_stitch.c === diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index 0c1839f9ac8..44588a06119 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -61,14 +61,16 @@ typedef struct UvElement { * the number of uvs per island. */ typedef struct UvElementMap { - /* address UvElements by their vertex */ - struct UvElement **vert; /** UvElement Storage. */ struct UvElement *storage; /** Total number of UVs. */ int total_uvs; /** Total number of unique UVs. */ int total_unique_uvs; + + /* If Non-NULL, address UvElements by `BM_elem_index_get(BMVert*)`. */ + struct UvElement **vertex; + /* Number of Islands in the mesh */ int totalIslands; /* Stores the starting index in buf where each island begins */ diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 1981b069011..9d3fd5af47f 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -144,6 +144,7 @@ void BM_uv_element_map_free(struct UvElementMap *element_map); struct UvElement *BM_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l); +struct UvElement *BM_uv_element_get_head(struct UvElementMap *map, struct UvElement *child); /** * Can we edit UV's for this mesh? diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 134532f0b21..78390db5349 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -732,25 +732,18 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, BMVert *ev; BMFace *efa; - BMLoop *l; BMIter iter, liter; - /* vars from original func */ - UvElementMap *element_map; - bool *winding = NULL; BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); - MLoopUV *luv; - int totverts, totfaces, i, totuv, j; - const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); + if (cd_loop_uv_offset < 0) { +return NULL; + } BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE); - totfaces = bm->totface; - totverts = bm->totvert; - totuv = 0; - - /* generate UvElement array */ + /* Count total uvs. */ + int totuv = 0; BM_ITER_MESH (efa, , bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { continue; @@ -764,6 +757,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, totuv += efa->len; } else { + BMLoop *l; BM_ITER_ELEM (l, , efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { totuv++; @@ -776,18 +770,17 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, return NULL; } - element_map = (UvElementMap *)MEM_callocN(sizeof(*element_map), "UvElementMap"); + UvElementMap *element_map = (UvElementMap *)MEM_callocN(sizeof(*element_map), "UvElementMap"); element_map->total_uvs = totuv; - element_map->vert = (UvElement **)MEM_callocN(sizeof(*element_map->vert) * totverts, -"UvElementVerts"); + element_map->vertex = (UvElement **)MEM_callocN(sizeof(*element_map->vertex) * bm->totvert, + "UvElementVerts"); element_map->storage = (UvElement *)MEM_callocN(sizeof(*element_map->storage) * totuv, "UvElement"); - if (use_winding) { -winding = MEM_callocN(sizeof(*winding) * totfaces, "winding"); - } + bool *winding = use_winding ? MEM_callocN(sizeof(*winding) * bm->totface, "winding") : NULL; UvElement *buf = element_map->storage; + int j; BM_ITER_MESH_INDEX (efa, , bm, BM_FACES_OF_MESH, j) { if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { @@ -804,18 +797,20 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, tf_uv = (float(*)[2])BLI_buffer_reinit_data(_uv_buf, vec2f, efa->le
[Bf-blender-cvs] [64984126a2b] master: Cleanup: refactoring uvislands to prepare for python api
Commit: 64984126a2b688a4bdd64bea4bcac1091756adab Author: Chris Blackbourn Date: Mon Aug 8 10:15:13 2022 +1200 Branches: master https://developer.blender.org/rB64984126a2b688a4bdd64bea4bcac1091756adab Cleanup: refactoring uvislands to prepare for python api Rename buf -> storage. See also: D15598 === M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/sculpt_paint/sculpt_uv.c M source/blender/editors/uvedit/uvedit_ops.c M source/blender/editors/uvedit/uvedit_smart_stitch.c === diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index f9dda7f5737..0c1839f9ac8 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -17,11 +17,10 @@ struct MLoopUV; struct MPoly; struct MVert; -/* map from uv vertex to face (for select linked, stitch, uv suburf) */ - /* UvVertMap */ #define STD_UV_CONNECT_LIMIT 0.0001f +/* Map from uv vertex to face. Used by select linked, uv subsurf and obj exporter. */ typedef struct UvVertMap { struct UvMapVert **vert; struct UvMapVert *buf; @@ -64,8 +63,8 @@ typedef struct UvElement { typedef struct UvElementMap { /* address UvElements by their vertex */ struct UvElement **vert; - /* UvElement Store */ - struct UvElement *buf; + /** UvElement Storage. */ + struct UvElement *storage; /** Total number of UVs. */ int total_uvs; /** Total number of unique UVs. */ diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index fb7120b19ae..134532f0b21 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -603,7 +603,7 @@ static void bm_uv_assign_island(UvElementMap *element_map, int islandbufsize) { element->island = nisland; - map[element - element_map->buf] = islandbufsize; + map[element - element_map->storage] = islandbufsize; /* Copy *element to islandbuf[islandbufsize]. */ islandbuf[islandbufsize].l = element->l; @@ -625,11 +625,11 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, /* For each UvElement, locate the "separate" UvElement that precedes it in the linked list. */ UvElement **head_table = MEM_mallocN(sizeof(*head_table) * total_uvs, "uv_island_head_table"); for (int i = 0; i < total_uvs; i++) { -UvElement *head = element_map->buf + i; +UvElement *head = element_map->storage + i; if (head->separate) { UvElement *element = head; while (element) { -head_table[element - element_map->buf] = head; +head_table[element - element_map->storage] = head; element = element->next; if (element && element->separate) { break; @@ -646,7 +646,7 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, "uv_island_element_stack"); int stacksize_uv = 0; for (int i = 0; i < total_uvs; i++) { -UvElement *element = element_map->buf + i; +UvElement *element = element_map->storage + i; if (element->island != INVALID_ISLAND) { /* Unique UV (element and all it's children) are already part of an island. */ continue; @@ -676,7 +676,7 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, if (!uv_selected || uvedit_edge_select_test(scene, element->l, cd_loop_uv_offset)) { UvElement *next = BM_uv_element_get(element_map, element->l->next->f, element->l->next); if (next->island == INVALID_ISLAND) { -UvElement *tail = head_table[next - element_map->buf]; +UvElement *tail = head_table[next - element_map->storage]; stack_uv[stacksize_uv++] = tail; while (tail) { bm_uv_assign_island(element_map, tail, nislands, map, islandbuf, islandbufsize++); @@ -692,7 +692,7 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, if (!uv_selected || uvedit_edge_select_test(scene, element->l->prev, cd_loop_uv_offset)) { UvElement *prev = BM_uv_element_get(element_map, element->l->prev->f, element->l->prev); if (prev->island == INVALID_ISLAND) { -UvElement *tail = head_table[prev - element_map->buf]; +UvElement *tail = head_table[prev - element_map->storage]; stack_uv[stacksize_uv++] = tail; while (tail) { bm_uv_assign_island(element_map, tail, nislands, map, islandbuf, islandbufsize++); @@ -736,7 +736,6 @@ UvElementMap *BM_uv_element_map_
[Bf-blender-cvs] [e441e21d74f] master: Cleanup: refactoring uvislands to prepare for python api
Commit: e441e21d74f9b1d28a5384ac14386e1465035b35 Author: Chris Blackbourn Date: Sun Aug 7 16:11:47 2022 +1200 Branches: master https://developer.blender.org/rBe441e21d74f9b1d28a5384ac14386e1465035b35 Cleanup: refactoring uvislands to prepare for python api See also: D15598 === M source/blender/blenkernel/BKE_mesh_mapping.h M source/blender/editors/mesh/editmesh_utils.c M source/blender/editors/sculpt_paint/sculpt_uv.c M source/blender/editors/uvedit/uvedit_ops.c M source/blender/editors/uvedit/uvedit_smart_stitch.c === diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index c58bcbea242..f9dda7f5737 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -52,17 +52,24 @@ typedef struct UvElement { unsigned int island; } UvElement; -/* UvElementMap is a container for UvElements of a mesh. It stores some UvElements belonging to the - * same uv island in sequence and the number of uvs per island so it is possible to access all uvs - * belonging to an island directly by iterating through the buffer. +/** UvElementMap is a container for UvElements of a BMesh. + * + * It simplifies access to UV information and ensures the + * different UV selection modes are respected. + * + * If islands are calculated, it also stores UvElements + * belonging to the same uv island in sequence and + * the number of uvs per island. */ typedef struct UvElementMap { /* address UvElements by their vertex */ struct UvElement **vert; /* UvElement Store */ struct UvElement *buf; - /* Total number of UVs in the layer. Useful to know */ - int totalUVs; + /** Total number of UVs. */ + int total_uvs; + /** Total number of unique UVs. */ + int total_unique_uvs; /* Number of Islands in the mesh */ int totalIslands; /* Stores the starting index in buf where each island begins */ diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index ac5530c8ea9..fb7120b19ae 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -620,11 +620,11 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, bool uv_selected, int cd_loop_uv_offset) { - int totuv = element_map->totalUVs; + int total_uvs = element_map->total_uvs; /* For each UvElement, locate the "separate" UvElement that precedes it in the linked list. */ - UvElement **head_table = MEM_mallocN(sizeof(*head_table) * totuv, "uv_island_head_table"); - for (int i = 0; i < totuv; i++) { + UvElement **head_table = MEM_mallocN(sizeof(*head_table) * total_uvs, "uv_island_head_table"); + for (int i = 0; i < total_uvs; i++) { UvElement *head = element_map->buf + i; if (head->separate) { UvElement *element = head; @@ -641,11 +641,11 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, /* Depth first search the graph, building islands as we go. */ int nislands = 0; int islandbufsize = 0; - int stack_upper_bound = totuv; + int stack_upper_bound = total_uvs; UvElement **stack_uv = MEM_mallocN(sizeof(*stack_uv) * stack_upper_bound, "uv_island_element_stack"); int stacksize_uv = 0; - for (int i = 0; i < totuv; i++) { + for (int i = 0; i < total_uvs; i++) { UvElement *element = element_map->buf + i; if (element->island != INVALID_ISLAND) { /* Unique UV (element and all it's children) are already part of an island. */ @@ -713,7 +713,7 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map, } nislands++; } - BLI_assert(islandbufsize == totuv); + BLI_assert(islandbufsize == total_uvs); MEM_SAFE_FREE(stack_uv); MEM_SAFE_FREE(head_table); @@ -778,7 +778,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, } element_map = (UvElementMap *)MEM_callocN(sizeof(*element_map), "UvElementMap"); - element_map->totalUVs = totuv; + element_map->total_uvs = totuv; element_map->vert = (UvElement **)MEM_callocN(sizeof(*element_map->vert) * totverts, "UvElementVerts"); buf = element_map->buf = (UvElement *)MEM_callocN(sizeof(*element_map->buf) * totuv, @@ -1006,6 +1006,13 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, BLI_buffer_free(_uv_buf); + element_map->total_unique_uvs = 0; + for (int i = 0; i < element_map->total_uvs; i++) { +if (element_map->buf[i].separate) { + element_map->total_unique_uvs++; +} + } + return elemen
[Bf-blender-cvs] [8b51bd61fd2] master: Cleanup: make format
Commit: 8b51bd61fd20fca6654de74f7e4c304cebd6bc5b Author: Chris Blackbourn Date: Sun Aug 7 10:09:31 2022 +1200 Branches: master https://developer.blender.org/rB8b51bd61fd20fca6654de74f7e4c304cebd6bc5b Cleanup: make format === M source/blender/geometry/intern/uv_parametrizer.cc === diff --git a/source/blender/geometry/intern/uv_parametrizer.cc b/source/blender/geometry/intern/uv_parametrizer.cc index efda55e2669..ae2794bf9bc 100644 --- a/source/blender/geometry/intern/uv_parametrizer.cc +++ b/source/blender/geometry/intern/uv_parametrizer.cc @@ -3666,7 +3666,8 @@ static void p_chart_rotate_minimum_area(PChart *chart) static void p_chart_rotate_fit_aabb(PChart *chart) { - float(*points)[2] = static_cast(MEM_mallocN(sizeof(*points) * chart->nverts, __func__)); + float(*points)[2] = static_cast( + MEM_mallocN(sizeof(*points) * chart->nverts, __func__)); p_chart_uv_to_array(chart, points); @@ -3827,8 +3828,10 @@ static void p_add_ngon(ParamHandle *handle, MemArena *arena = handle->polyfill_arena; Heap *heap = handle->polyfill_heap; uint nfilltri = nverts - 2; - uint(*tris)[3] = static_cast(BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri)); - float(*projverts)[2] = static_cast(BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)nverts)); + uint(*tris)[3] = static_cast( + BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)nfilltri)); + float(*projverts)[2] = static_cast( + BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)nverts)); /* Calc normal, flipped: to get a positive 2d cross product. */ float normal[3]; ___ 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