1
1

Compare commits

...

23 Commits

Author SHA1 Message Date
dbc41b30f8 Merge branch 'master' into soc-2021-uv-edge-select-support 2021-12-17 18:31:32 +05:30
99a2af76d1 Merge branch 'master' into soc-2021-uv-edge-select-support 2021-11-20 00:04:44 +05:30
139606bd37 Code cleanup and minor fixes 2021-11-19 23:54:27 +05:30
4e6f73e5df Merge branch 'master' into soc-2021-uv-edge-select-support 2021-11-03 17:16:00 +05:30
7f8f2ff1a8 Merge branch 'master' into soc-2021-uv-edge-select-support 2021-10-04 16:37:02 +05:30
52822b218d Merge branch 'master' into soc-2021-uv-edge-select-support 2021-10-02 12:40:33 +05:30
90707ca72f Merge branch 'master' into soc-2021-uv-edge-select-support 2021-09-22 18:51:28 +05:30
29deaaee00 Fix: Deselecting edges in sticky vertex mode
Fixes the bug where deselecting an UV edge in sticky vertex mode would
deselect the UV vertices as well.
2021-09-11 15:25:40 +05:30
fdc9318360 UV: Drawing selected edges
* Changes vertex count for UV edge polygon from 4 to 6 in the geometry
  shader
* Edge center for a selected edge will not be highlighted if the edge is
  not selected. This new behavior provides a visual aid to the user that
  helps in identifying selected and unselected UV edges
2021-09-10 14:55:02 +05:30
64d640d196 Merge branch 'master' into soc-2021-uv-edge-select-support 2021-08-27 09:18:46 +05:30
2766e00ecf Merge branch 'master' into soc-2021-uv-edge-select-support 2021-08-16 10:38:50 +05:30
6f61cd90cc Cleanup: Use utility function 2021-08-14 20:12:38 +05:30
70824abc3f Merge branch 'master' into soc-2021-uv-editor-improvements-edge-selection 2021-08-09 07:05:27 +05:30
a7f24a8307 Edge selection support for Edge ring and loop select operator
* Adds edge selection support for edge ring and edge loop select operator
* Selecting face loops in the UV editor is now done through the loop
  select operator
2021-08-09 03:00:27 +05:30
752c840f1e Cleanup and fix: UV Invert selection
* Code and comment cleanup
* Fix: Make invert selection respect sticky modes when using edge select
  mode
2021-08-07 23:39:29 +05:30
ddbbbf40f6 Fix: Check edge selection only for common vertex
Allow edge selection test only for UV edges that share a common UV
vertex. Previous logic didn't check if the UV edges shared the same
UV vertex.
2021-08-07 20:38:18 +05:30
a4af0f530c UV: Edge selection for UV select pinned operator
Ensure edge selection for UV select pinned operator by flushing the
selection upwards (verts to edge)
2021-08-07 14:07:06 +05:30
a342ea1cf5 UV: Refactor UV select split operator
Refactor UV select split operator to use MLOOPUV_EDGESEL flag
2021-08-07 13:39:40 +05:30
e88563e472 Merge branch 'master' into soc-2021-uv-editor-improvements-edge-selection 2021-08-05 16:42:53 +05:30
db821af172 Fix: Invert selection and free unreleased memory
- Free unreleased memory from vertex map
- Select Invert operator now works with UV face select mode as well
2021-08-04 06:19:27 +05:30
d6e02d92e1 UV: Extend edge selection support
- Add edge selection support for operators: mouse select, box select,
  circle select, lasso select, (de)select all, invert selection and
  select more/less
- Flush selections between UV verts and edges
- Fix: prevent deselection of neighbouring edges when deselecting an
  edge in sticky location + edge select mode
2021-08-04 06:19:26 +05:30
8b3b353caf Fix: Prevent deselection of surrounding UV faces
With face + sticky loc/vertex mode, trying to deselect UV faces would
sometimes result in surrounding UV faces being deselected as well. This
commit fixes that allowing conditional deselection of shared UV
vertices based on the selection state of surrounding UV faces.
2021-08-04 06:19:25 +05:30
035fa7985d UV: Edge selection support - Initial
* Add UV edge selection flag - MLOOPUV_EDGESEL
* Refactor existing UV element selection functions to use the edge
  selection flag wherever required
* Refactor existing UV element check functions to ensure proper
  selection states using the edge selection flag
* Refactor UV select all operator to use edge selection flag
* New functions for selecting vertices or edges that share the same
  location, either on 3D mesh or in UV space.
* Add small penalty for finding the nearest UV edge. Ensures that UV edge
  selection will select other edges sharing the same location in
  successive selection attempts.
* Expose UV edge selection flag as boolean in Python

Differential Revision: https://developer.blender.org/D12028
2021-08-04 06:19:24 +05:30
10 changed files with 878 additions and 162 deletions

View File

@@ -2,9 +2,10 @@
#pragma BLENDER_REQUIRE(common_overlay_lib.glsl)
layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;
layout(triangle_strip, max_vertices = 6) out;
in float selectionFac[2];
in float edgeSelectionFac[2];
flat in vec2 stippleStart[2];
noperspective in vec2 stipplePos[2];
@@ -35,6 +36,12 @@ void main()
vec2 ss_pos[2];
vec4 pos0 = gl_in[0].gl_Position;
vec4 pos1 = gl_in[1].gl_Position;
/* TODO(verify): Calculating edge-center in clip space might cause errors due to precision loss?? */
vec4 edgeCenter = (pos0 + pos1) / 2.0;
bool is_edge_selected = edgeSelectionFac[0] == 1.0;
/* Depth value as specified in vertex shader */
edgeCenter.z = is_edge_selected ? 0.25 : 0.35;
ss_pos[0] = pos0.xy / pos0.w;
ss_pos[1] = pos1.xy / pos1.w;
@@ -54,8 +61,14 @@ void main()
vec2 line_perp = vec2(-line_dir.y, line_dir.x);
vec2 edge_ofs = line_perp * sizeViewportInv * ceil(half_size);
vec2 stippleStartCenter, stipplePosCenter;
/* TODO(stipple pattern): Probable incorrect implementation - used as specified in vertex shader */
stippleStartCenter = stipplePosCenter = 500.0 + 500.0 * (edgeCenter.xy / edgeCenter.w);
do_vertex(pos0, selectionFac[0], stippleStart[0], stipplePos[0], half_size, edge_ofs.xy);
do_vertex(pos0, selectionFac[0], stippleStart[0], stipplePos[0], -half_size, -edge_ofs.xy);
do_vertex(edgeCenter, edgeSelectionFac[0], stippleStartCenter, stipplePosCenter, half_size, edge_ofs.xy);
do_vertex(edgeCenter, edgeSelectionFac[0], stippleStartCenter, stipplePosCenter, -half_size, -edge_ofs.xy);
do_vertex(pos1, selectionFac[1], stippleStart[1], stipplePos[1], half_size, edge_ofs.xy);
do_vertex(pos1, selectionFac[1], stippleStart[1], stipplePos[1], -half_size, -edge_ofs.xy);

View File

@@ -6,6 +6,7 @@ in vec2 au;
in int flag;
out float selectionFac;
out float edgeSelectionFac;
noperspective out vec2 stipplePos;
flat out vec2 stippleStart;
@@ -20,7 +21,9 @@ void main()
half_pixel_offset;
bool is_select = (flag & VERT_UV_SELECT) != 0;
bool is_edge_selected = (flag & EDGE_UV_SELECT) != 0;
selectionFac = is_select ? 1.0 : 0.0;
edgeSelectionFac = is_edge_selected ? 1.0 : 0.0;
/* Move selected edges to the top
* Vertices are between 0.0 and 0.2, Edges between 0.2 and 0.4
* actual pixels are at 0.75, 1.0 is used for the background. */

View File

@@ -149,6 +149,13 @@ void uvedit_edge_select_set_with_sticky(const struct SpaceImage *sima,
const bool select,
const bool do_history,
const uint cd_loop_uv_offset);
void uvedit_edge_select_shared_location(const struct Scene *scene,
struct BMEditMesh *em,
struct BMLoop *l,
const bool select,
const bool use_mesh_location,
const bool do_history,
const uint cd_loop_uv_offset);
void uvedit_edge_select_set(const struct Scene *scene,
struct BMEditMesh *em,
struct BMLoop *l,
@@ -172,6 +179,13 @@ void uvedit_uv_select_set_with_sticky(const struct SpaceImage *sima,
const bool select,
const bool do_history,
const uint cd_loop_uv_offset);
void uvedit_uv_select_shared_location(const struct Scene *scene,
struct BMEditMesh *em,
struct BMLoop *l,
const bool select,
const bool use_mesh_location,
const bool do_history,
const uint cd_loop_uv_offset);
void uvedit_uv_select_set(const struct Scene *scene,
struct BMEditMesh *em,
struct BMLoop *l,

View File

@@ -86,11 +86,13 @@ bool uv_find_nearest_vert_multi(struct Scene *scene,
bool uv_find_nearest_edge(struct Scene *scene,
struct Object *obedit,
const float co[2],
const float penalty,
struct UvNearestHit *hit);
bool uv_find_nearest_edge_multi(struct Scene *scene,
struct Object **objects,
const uint objects_len,
const float co[2],
const float penalty,
struct UvNearestHit *hit);
/**
@@ -132,6 +134,17 @@ BMLoop *uv_find_nearest_loop_from_edge(struct Scene *scene,
struct BMEdge *e,
const float co[2]);
/* flush uv selection */
void uv_flush_vert_to_edge(struct Scene *scene,
struct BMEditMesh *em,
const int cd_loop_uv_offset);
void uv_flush_edge_to_vert(struct Scene *scene,
struct BMEditMesh *em,
const int cd_loop_uv_offset);
void uv_flush_edge_to_vert_with_sticky_loc(struct Scene *scene,
struct BMEditMesh *em,
const int cd_loop_uv_offset);
/* utility tool functions */
void uvedit_live_unwrap_update(struct SpaceImage *sima,

View File

@@ -627,7 +627,7 @@ static int uv_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEve
else if (uv_selectmode & UV_SELECT_EDGE) {
UvNearestHit hit = UV_NEAREST_HIT_INIT_MAX(&region->v2d);
if (!uv_find_nearest_edge(scene, obedit, co, &hit)) {
if (!uv_find_nearest_edge(scene, obedit, co, 0.0f, &hit)) {
return OPERATOR_CANCELLED;
}

File diff suppressed because it is too large Load Diff

View File

@@ -2561,7 +2561,7 @@ static StitchState *stitch_select(bContext *C,
return state;
}
}
else if (uv_find_nearest_edge_multi(scene, ssc->objects, ssc->objects_len, co, &hit)) {
else if (uv_find_nearest_edge_multi(scene, ssc->objects, ssc->objects_len, co, 0.0f, &hit)) {
/* find StitchState from hit->ob */
StitchState *state = NULL;
for (uint ob_index = 0; ob_index < ssc->objects_len; ob_index++) {

View File

@@ -347,7 +347,7 @@ typedef struct MLoopUV {
/** #MLoopUV.flag */
enum {
/* MLOOPUV_DEPRECATED = (1 << 0), MLOOPUV_EDGESEL removed */
MLOOPUV_EDGESEL = (1 << 0),
MLOOPUV_VERTSEL = (1 << 1),
MLOOPUV_PINNED = (1 << 2),
};

View File

@@ -2102,6 +2102,10 @@ static void rna_def_mloopuv(BlenderRNA *brna)
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_VERTSEL);
RNA_def_property_ui_text(prop, "UV Select", "");
prop = RNA_def_property(srna, "select_edge", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MLOOPUV_EDGESEL);
RNA_def_property_ui_text(prop, "UV Edge Select", "");
}
static void rna_def_mloopcol(BlenderRNA *brna)

View File

@@ -72,6 +72,7 @@ static int bpy_bmloopuv_uv_set(BPy_BMLoopUV *self, PyObject *value, void *UNUSED
PyDoc_STRVAR(bpy_bmloopuv_flag__pin_uv_doc, "UV pin state.\n\n:type: boolean");
PyDoc_STRVAR(bpy_bmloopuv_flag__select_doc, "UV select state.\n\n:type: boolean");
PyDoc_STRVAR(bpy_bmloopuv_flag__select_edge_doc, "UV edge select state.\n\n:type: boolean");
static PyObject *bpy_bmloopuv_flag_get(BPy_BMLoopUV *self, void *flag_p)
{
@@ -109,6 +110,11 @@ static PyGetSetDef bpy_bmloopuv_getseters[] = {
(setter)bpy_bmloopuv_flag_set,
bpy_bmloopuv_flag__select_doc,
(void *)MLOOPUV_VERTSEL},
{"select_edge",
(getter)bpy_bmloopuv_flag_get,
(setter)bpy_bmloopuv_flag_set,
bpy_bmloopuv_flag__select_edge_doc,
(void *)MLOOPUV_EDGESEL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};