[Bf-blender-cvs] [139606bd370] soc-2021-uv-edge-select-support: Code cleanup and minor fixes
Siddhartha Jejurkar
noreply at git.blender.org
Fri Nov 19 19:35:27 CET 2021
Commit: 139606bd370f96e0a8685547d515a2335591d5de
Author: Siddhartha Jejurkar
Date: Fri Nov 19 23:54:27 2021 +0530
Branches: soc-2021-uv-edge-select-support
https://developer.blender.org/rB139606bd370f96e0a8685547d515a2335591d5de
Code cleanup and minor fixes
===================================================================
M source/blender/editors/uvedit/uvedit_intern.h
M source/blender/editors/uvedit/uvedit_select.c
===================================================================
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index 2d516e3f677..9bc8a165b1f 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -127,13 +127,13 @@ BMLoop *uv_find_nearest_loop_from_edge(struct Scene *scene,
/* flush uv selection */
void uv_flush_vert_to_edge(struct Scene *scene,
- struct Object *obedit,
+ struct BMEditMesh *em,
const int cd_loop_uv_offset);
void uv_flush_edge_to_vert(struct Scene *scene,
- struct Object *obedit,
+ struct BMEditMesh *em,
const int cd_loop_uv_offset);
-void uv_flush_edge_to_vert_with_sticky_loc(Scene *scene,
- Object *obedit,
+void uv_flush_edge_to_vert_with_sticky_loc(struct Scene *scene,
+ struct BMEditMesh *em,
const int cd_loop_uv_offset);
/* utility tool functions */
diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c
index 5b4a8d7393f..83e8259f693 100644
--- a/source/blender/editors/uvedit/uvedit_select.c
+++ b/source/blender/editors/uvedit/uvedit_select.c
@@ -93,9 +93,9 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima,
Scene *scene,
Object *obedit,
const bool select);
-static void uv_select_flush_from_tag_loop(SpaceImage *sima,
+static void uv_select_flush_from_tag_loop(const SpaceImage *sima,
Scene *scene,
- Object *obedit,
+ BMEditMesh *em,
const bool select);
static void uv_select_tag_update_for_object(Depsgraph *depsgraph,
const ToolSettings *ts,
@@ -108,10 +108,6 @@ static bool uvedit_vert_is_any_other_face_selected(const Scene *scene,
BMLoop *l,
BMVert *v,
const int cd_loop_uv_offset);
-static bool uvedit_vert_is_any_other_not_face_selected(const Scene *scene,
- BMLoop *l,
- BMVert *v,
- const int cd_loop_uv_offset);
/* -------------------------------------------------------------------- */
/** \name Active Selection Tracking
@@ -307,27 +303,25 @@ void uvedit_face_select_set_with_sticky(const SpaceImage *sima,
if (uvedit_face_visible_test(scene, efa)) {
/* Sticky location and vertex modes. */
/* Fallback, in case sima->sticky is invalid */
- BMLoop *l_iter, *l_first;
- l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
- do {
- MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_iter, cd_loop_uv_offset);
+ BMLoop *l;
+ MLoopUV *luv;
+ BMIter liter;
+
+ BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (select) {
- /* Set selection flag for only the internal edges of the face that is being selected */
luv->flag |= MLOOPUV_EDGESEL;
- /* Select all shared vertices */
uvedit_uv_select_shared_location(
- scene, em, l_iter, select, false, do_history, cd_loop_uv_offset);
+ scene, em, l, select, false, do_history, cd_loop_uv_offset);
}
else {
luv->flag &= ~MLOOPUV_EDGESEL;
-
- if (!uvedit_vert_is_any_other_face_selected(
- scene, l_iter, l_iter->v, cd_loop_uv_offset)) {
+ if (!uvedit_vert_is_any_other_face_selected(scene, l, l->v, cd_loop_uv_offset)) {
uvedit_uv_select_shared_location(
- scene, em, l_iter, select, false, do_history, cd_loop_uv_offset);
+ scene, em, l, select, false, do_history, cd_loop_uv_offset);
}
}
- } while ((l_iter = l_iter->next) != l_first);
+ }
}
break;
}
@@ -452,66 +446,15 @@ void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima,
break;
}
case SI_STICKY_VERTEX: {
- BMLoop *l_radial_iter = l;
- do {
- if (uvedit_face_visible_test(scene, l_radial_iter->f)) {
- uvedit_edge_select_set(scene, em, l_radial_iter, select, do_history, cd_loop_uv_offset);
-
- if (select) {
- uvedit_uv_select_shared_location(
- scene, em, l_radial_iter, select, false, do_history, cd_loop_uv_offset);
- uvedit_uv_select_shared_location(
- scene, em, l_radial_iter->next, select, false, do_history, cd_loop_uv_offset);
- }
- else {
- if (!uvedit_vert_is_any_other_edge_selected(scene, l_radial_iter, cd_loop_uv_offset)) {
- uvedit_uv_select_shared_location(
- scene, em, l_radial_iter, select, false, do_history, cd_loop_uv_offset);
- }
- if (!uvedit_vert_is_any_other_edge_selected(
- scene, l_radial_iter->next, cd_loop_uv_offset)) {
- uvedit_uv_select_shared_location(
- scene, em, l_radial_iter->next, select, false, do_history, cd_loop_uv_offset);
- }
- }
- }
- } while ((l_radial_iter = l_radial_iter->radial_next) != l);
+ uvedit_edge_select_shared_location(
+ scene, em, l, select, true, do_history, cd_loop_uv_offset);
break;
}
default: {
/* SI_STICKY_LOC
* Fallback to SI_STICKY_LOC, in case sima->sticky is invalid */
- if (select) {
- uvedit_edge_select_shared_location(
- scene, em, l, select, false, do_history, cd_loop_uv_offset);
-
- /* NOTE (Design tradeoff): This is a case where we deviate from the logic of: "EDGE
- * SELECTION MODE SHOULD IMPLY ONLY EDGES MUST BE SELECTED". The UV vertex selections done
- * below are to avoid the cases of edge selections breaking away (/become separate
- * entities) from the vertices/edges they were connected to */
- uvedit_uv_select_shared_location(
- scene, em, l, select, false, do_history, cd_loop_uv_offset);
- uvedit_uv_select_shared_location(
- scene, em, l->next, select, false, do_history, cd_loop_uv_offset);
- }
- else {
- BMLoop *l_radial_iter = l;
- do {
- if (BM_loop_uv_share_edge_check(l, l_radial_iter, cd_loop_uv_offset)) {
- MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l_radial_iter, cd_loop_uv_offset);
- luv->flag &= ~MLOOPUV_EDGESEL;
- }
- } while ((l_radial_iter = l_radial_iter->radial_next) != l);
-
- if (!uvedit_vert_is_any_other_edge_selected(scene, l, cd_loop_uv_offset)) {
- uvedit_uv_select_shared_location(
- scene, em, l, select, false, do_history, cd_loop_uv_offset);
- }
- if (!uvedit_vert_is_any_other_edge_selected(scene, l->next, cd_loop_uv_offset)) {
- uvedit_uv_select_shared_location(
- scene, em, l->next, select, false, do_history, cd_loop_uv_offset);
- }
- }
+ uvedit_edge_select_shared_location(
+ scene, em, l, select, false, do_history, cd_loop_uv_offset);
break;
}
}
@@ -530,31 +473,65 @@ void uvedit_edge_select_shared_location(const Scene *scene,
const bool do_history,
const uint cd_loop_uv_offset)
{
- const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
BMLoop *l_radial_iter = l;
do {
if (uvedit_face_visible_test(scene, l_radial_iter->f)) {
if (use_mesh_location) {
- uvedit_edge_select_set(scene, em, l_radial_iter, select, do_history, cd_loop_uv_offset);
+ MLoopUV *luv_radial = BM_ELEM_CD_GET_VOID_P(l_radial_iter, cd_loop_uv_offset);
+ if (select) {
+ luv_radial->flag |= MLOOPUV_EDGESEL;
+ uvedit_uv_select_shared_location(
+ scene, em, l_radial_iter, select, false, do_history, cd_loop_uv_offset);
+ uvedit_uv_select_shared_location(
+ scene, em, l_radial_iter->next, select, false, do_history, cd_loop_uv_offset);
+ }
+ else {
+ luv_radial->flag &= ~MLOOPUV_EDGESEL;
+ if (!uvedit_vert_is_any_other_edge_selected(scene, l_radial_iter, cd_loop_uv_offset)) {
+ uvedit_uv_select_shared_location(
+ scene, em, l_radial_iter, select, false, do_history, cd_loop_uv_offset);
+ }
+ if (!uvedit_vert_is_any_other_edge_selected(
+ scene, l_radial_iter->next, cd_loop_uv_offset)) {
+ uvedit_uv_select_shared_location(
+ scene, em, l_radial_iter->next, select, false, do_history, cd_loop_uv_offset);
+ }
+ }
}
else {
- const MLoopUV *luv_other, *luv_next, *luv_other_next;
- luv_other = BM_ELEM_CD_GET_VOID_P(l_radial_iter, cd_loop_uv_offset);
- luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset);
- luv_other_next = BM_ELEM_CD_GET_VOID_P(l_radial_iter->next, cd_loop_uv_offset);
- /* Check the current and next loop to account for the possibilty of opposite directions
- * of a loop in a particular edge's radial cycle */
- if (equals_v2v2(luv->uv, luv_other->uv) && equals_v2v2(luv_next->uv, luv_other_next->uv)) {
- uvedit_edge_select_set(scene, em, l_radial_iter, select, do_history, cd_loop_uv_offset);
- }
- else if (equals_v2v2(luv->uv, luv_other_next->uv) &&
- equals_v2v2(luv_next->uv, luv_other->uv)) {
- uvedit_edge_select_set(scene, em,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list