Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-08-11 18:03:47 +0300
committerHans Goudey <h.goudey@me.com>2022-08-11 18:03:47 +0300
commit9b01fc7f2ab998f460dd7ac5bbdd593dca832c38 (patch)
tree2f43a3ae60daa97bcdd677753c3c561018e13aed /source/blender/editors
parent96f1e44119ceff2d4f8a00e998910eed479eab03 (diff)
parent4cbd799373d07498813ad84f8cee5f3a8c269631 (diff)
Merge branch 'master' into refactor-mesh-hide-generic
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/curve/editcurve.c2
-rw-r--r--source/blender/editors/include/ED_view3d.h10
-rw-r--r--source/blender/editors/io/io_obj.c39
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c319
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c9
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_overrides.cc3
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_smoothview.c54
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c18
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c16
-rw-r--r--source/blender/editors/transform/transform_convert_mesh_uv.c6
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c13
-rw-r--r--source/blender/editors/uvedit/uvedit_select.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c43
15 files changed, 298 insertions, 243 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2ff18599b02..164336c4b22 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1975,7 +1975,7 @@ static int sel_to_copy_ints(const BPoint *bp,
else if (not_full == -1) {
not_full = selected_in_curr_leg;
}
- /* We have partialy selected leg in opposite dimension if condition is met. */
+ /* We have partially selected leg in opposite dimension if condition is met. */
else if (not_full != selected_in_curr_leg) {
return -1;
}
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 7d31950c869..bb95ea97c1c 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -1171,7 +1171,7 @@ void ED_view3d_camera_lock_init(const struct Depsgraph *depsgraph,
*
* Apply the 3D Viewport transformation back to the camera object.
*
- * \return true if the camera is moved.
+ * \return true if the camera (or one of it's parents) was moved.
*/
bool ED_view3d_camera_lock_sync(const struct Depsgraph *depsgraph,
struct View3D *v3d,
@@ -1211,8 +1211,8 @@ bool ED_view3d_camera_lock_undo_test(const View3D *v3d,
* \return true when the call to push an undo step was made.
*/
bool ED_view3d_camera_lock_undo_push(const char *str,
- View3D *v3d,
- struct RegionView3D *rv3d,
+ const View3D *v3d,
+ const struct RegionView3D *rv3d,
struct bContext *C);
/**
@@ -1222,8 +1222,8 @@ bool ED_view3d_camera_lock_undo_push(const char *str,
* where adding a separate undo step each time isn't desirable.
*/
bool ED_view3d_camera_lock_undo_grouped_push(const char *str,
- View3D *v3d,
- struct RegionView3D *rv3d,
+ const View3D *v3d,
+ const struct RegionView3D *rv3d,
struct bContext *C);
#define VIEW3D_MARGIN 1.4f
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index 662ff601e29..c151baf13ef 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -382,11 +382,6 @@ static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
static int wm_obj_import_exec(bContext *C, wmOperator *op)
{
- if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
- BKE_report(op->reports, RPT_ERROR, "No filename given");
- return OPERATOR_CANCELLED;
- }
-
struct OBJImportParams import_params;
RNA_string_get(op->ptr, "filepath", import_params.filepath);
import_params.clamp_size = RNA_float_get(op->ptr, "clamp_size");
@@ -395,8 +390,35 @@ static int wm_obj_import_exec(bContext *C, wmOperator *op)
import_params.import_vertex_groups = RNA_boolean_get(op->ptr, "import_vertex_groups");
import_params.validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes");
import_params.relative_paths = ((U.flag & USER_RELPATHS) != 0);
-
- OBJ_import(C, &import_params);
+ import_params.clear_selection = true;
+
+ int files_len = RNA_collection_length(op->ptr, "files");
+ if (files_len) {
+ /* Importing multiple files: loop over them and import one by one. */
+ PointerRNA fileptr;
+ PropertyRNA *prop;
+ char dir_only[FILE_MAX], file_only[FILE_MAX];
+
+ RNA_string_get(op->ptr, "directory", dir_only);
+ prop = RNA_struct_find_property(op->ptr, "files");
+ for (int i = 0; i < files_len; i++) {
+ RNA_property_collection_lookup_int(op->ptr, prop, i, &fileptr);
+ RNA_string_get(&fileptr, "name", file_only);
+ BLI_join_dirfile(
+ import_params.filepath, sizeof(import_params.filepath), dir_only, file_only);
+ import_params.clear_selection = (i == 0);
+ OBJ_import(C, &import_params);
+ }
+ }
+ else if (RNA_struct_property_is_set(op->ptr, "filepath")) {
+ /* Importing one file. */
+ RNA_string_get(op->ptr, "filepath", import_params.filepath);
+ OBJ_import(C, &import_params);
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "No filename given");
+ return OPERATOR_CANCELLED;
+ }
Scene *scene = CTX_data_scene(C);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -454,7 +476,8 @@ void WM_OT_obj_import(struct wmOperatorType *ot)
FILE_TYPE_FOLDER,
FILE_BLENDER,
FILE_OPENFILE,
- WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
+ WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS |
+ WM_FILESEL_DIRECTORY | WM_FILESEL_FILES,
FILE_DEFAULTDISPLAY,
FILE_SORT_ALPHA);
RNA_def_float(
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 208022326d3..e931dd02a9e 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++);
@@ -716,11 +727,129 @@ static int bm_uv_edge_select_build_islands(UvElementMap *element_map,
BLI_assert(islandbufsize == total_uvs);
MEM_SAFE_FREE(stack_uv);
- MEM_SAFE_FREE(head_table);
+ MEM_SAFE_FREE(element_map->head_table);
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(&bm->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, &liter, 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] = &islandbuf[map[element_map->vertex[i] - element_map->storage]];
+ }
+ }
+
+ 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 *next = element_map->storage[i].next;
+ islandbuf[map[i]].next = next ? &islandbuf[map[next - element_map->storage]] : NULL;
+
+ if (islandbuf[i].island != j) {
+ j++;
+ 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->total_islands = nislands;
+ MEM_SAFE_FREE(stack);
+ MEM_SAFE_FREE(map);
+}
+
UvElementMap *BM_uv_element_map_create(BMesh *bm,
const Scene *scene,
const bool uv_selected,
@@ -824,6 +953,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
winding[j] = cross_poly_v2(tf_uv, efa->len) > 0;
}
}
+ BLI_buffer_free(&tf_uv_buf);
/* For each BMVert, sort associated linked list into unique uvs. */
int ev_index;
@@ -845,21 +975,32 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
UvElement *lastv = NULL;
UvElement *iterv = vlist;
- /* Scan through unsorted list, finding UvElements which match `v`. */
+ /* Scan through unsorted list, finding UvElements which are connected to `v`. */
while (iterv) {
UvElement *next = iterv->next;
-
luv = BM_ELEM_CD_GET_VOID_P(iterv->l, cd_loop_uv_offset);
- const float *uv2 = luv->uv;
- const bool uv2_vert_sel = uvedit_uv_select_test(scene, iterv->l, cd_loop_uv_offset);
- /* Check if the uv loops share the same selection state (if not, they are not connected as
- * they have been ripped or other edit commands have separated them). */
- const bool connected = (uv_vert_sel == uv2_vert_sel) &&
- compare_v2v2(uv2, uv, STD_UV_CONNECT_LIMIT);
+ bool connected = true; /* Assume connected unless we can prove otherwise. */
+
+ if (connected) {
+ /* Are the two UVs close together? */
+ const float *uv2 = luv->uv;
+ connected = compare_v2v2(uv2, uv, STD_UV_CONNECT_LIMIT);
+ }
+
+ if (connected) {
+ /* Check if the uv loops share the same selection state (if not, they are not connected
+ * as they have been ripped or other edit commands have separated them). */
+ const bool uv2_vert_sel = uvedit_uv_select_test(scene, iterv->l, cd_loop_uv_offset);
+ connected = (uv_vert_sel == uv2_vert_sel);
+ }
+
+ if (connected && use_winding) {
+ connected = winding[BM_elem_index_get(iterv->l->f)] ==
+ winding[BM_elem_index_get(v->l->f)];
+ }
- if (connected && (!use_winding || winding[BM_elem_index_get(iterv->l->f)] ==
- winding[BM_elem_index_get(v->l->f)])) {
+ if (connected) {
if (lastv) {
lastv->next = next;
}
@@ -886,120 +1027,13 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
MEM_SAFE_FREE(winding);
+ /* at this point, every UvElement in vert points to a UvElement sharing the same vertex.
+ * Now we should sort uv's in islands. */
if (do_islands) {
- uint *map;
- UvElement *islandbuf;
-
- int nislands = 0, islandbufsize = 0;
-
- /* map holds the map from current vmap->buf to the new, sorted map */
- map = MEM_mallocN(sizeof(*map) * totuv, "uvelement_remap");
- BMFace **stack = MEM_mallocN(sizeof(*stack) * bm->totface, "uv_island_face_stack");
- 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 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;
- }
-
- /* at this point, every UvElement in vert points to a UvElement sharing the same vertex.
- * Now we should sort uv's in islands. */
- 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) {
- efa = stack[--stacksize];
-
- BMLoop *l;
- BM_ITER_ELEM (l, &liter, 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] = &islandbuf[map[element_map->vertex[i] - element_map->storage]];
- }
- }
-
- element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands,
- "UvElementMap_island_indices");
- 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 = &islandbuf[map[element - element_map->storage]];
- }
-
- if (islandbuf[i].island != j) {
- j++;
- element_map->islandIndices[j] = i;
- }
- }
-
- MEM_SAFE_FREE(element_map->storage);
- element_map->storage = islandbuf;
- islandbuf = NULL;
- element_map->totalIslands = nislands;
- MEM_SAFE_FREE(stack);
- MEM_SAFE_FREE(map);
+ bm_uv_build_islands(element_map, bm, scene, uv_selected);
}
- BLI_buffer_free(&tf_uv_buf);
-
+ /* TODO: Confirm element_map->total_unique_uvs doesn't require recalculating. */
element_map->total_unique_uvs = 0;
for (int i = 0; i < element_map->total_uvs; i++) {
if (element_map->storage[i].separate) {
@@ -1028,7 +1062,10 @@ void BM_uv_element_map_free(UvElementMap *element_map)
if (element_map) {
MEM_SAFE_FREE(element_map->storage);
MEM_SAFE_FREE(element_map->vertex);
- MEM_SAFE_FREE(element_map->islandIndices);
+ MEM_SAFE_FREE(element_map->head_table);
+ 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 *op, const wm
/* Count 'unique' UV's */
int unique_uvs = data->elementMap->total_unique_uvs;
if (do_island_optimization) {
- unique_uvs = 0;
- for (int i = 0; i < data->elementMap->total_uvs; i++) {
- if (data->elementMap->storage[i].separate &&
- (data->elementMap->storage[i].island == island_index)) {
- unique_uvs++;
- }
- }
+ unique_uvs = data->elementMap->island_total_unique_uvs[island_index];
}
/* Allocate the unique uv buffers */
@@ -572,6 +566,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
uniqueUv[element - data->elementMap->storage] = counter;
}
}
+ BLI_assert(counter + 1 == unique_uvs);
/* Now, on to generate our uv connectivity data */
counter = 0;
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
index e19459ced61..49cabd5117f 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
@@ -371,8 +371,7 @@ void OverrideRNAPathTreeBuilder::ensure_entire_collection(
const char *coll_prop_path,
short &index)
{
- AbstractTreeElement *abstract_parent = tree_element_cast<AbstractTreeElement>(&te_to_expand);
- BLI_assert(abstract_parent != nullptr);
+ BLI_assert(tree_element_cast<AbstractTreeElement>(&te_to_expand) != nullptr);
TreeElement *previous_te = nullptr;
int item_idx = 0;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 4408f254c68..1a2eb20d1a9 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1210,6 +1210,9 @@ static void view3d_main_region_listener(const wmRegionListenerParams *params)
break;
}
break;
+ case NC_NODE:
+ ED_region_tag_redraw(region);
+ break;
case NC_WORLD:
switch (wmn->data) {
case ND_WORLD_DRAW:
diff --git a/source/blender/editors/space_view3d/view3d_navigate.h b/source/blender/editors/space_view3d/view3d_navigate.h
index 721476ace57..925acd90573 100644
--- a/source/blender/editors/space_view3d/view3d_navigate.h
+++ b/source/blender/editors/space_view3d/view3d_navigate.h
@@ -266,12 +266,12 @@ void ED_view3d_smooth_view(struct bContext *C,
* or when calling #ED_view3d_smooth_view_ex.
* Otherwise pass in #V3D_SmoothParams.undo_str so an undo step is pushed as needed.
*/
-void ED_view3d_smooth_view_undo_begin(struct bContext *C, struct ScrArea *area);
+void ED_view3d_smooth_view_undo_begin(struct bContext *C, const struct ScrArea *area);
/**
* Run after multiple smooth-view operations have run to push undo as needed.
*/
void ED_view3d_smooth_view_undo_end(struct bContext *C,
- struct ScrArea *area,
+ const struct ScrArea *area,
const char *undo_str,
bool undo_grouped);
diff --git a/source/blender/editors/space_view3d/view3d_navigate_smoothview.c b/source/blender/editors/space_view3d/view3d_navigate_smoothview.c
index 8125e334492..6b150d1e771 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_smoothview.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_smoothview.c
@@ -23,7 +23,7 @@
#include "view3d_navigate.h" /* own include */
static void view3d_smoothview_apply_with_interp(
- bContext *C, View3D *v3d, ARegion *region, const bool use_autokey, const float factor);
+ bContext *C, View3D *v3d, RegionView3D *rv3d, const bool use_autokey, const float factor);
/* -------------------------------------------------------------------- */
/** \name Smooth View Undo Handling
@@ -40,7 +40,7 @@ static void view3d_smoothview_apply_with_interp(
* operations are executed once smooth-view has started.
* \{ */
-void ED_view3d_smooth_view_undo_begin(bContext *C, ScrArea *area)
+void ED_view3d_smooth_view_undo_begin(bContext *C, const ScrArea *area)
{
const View3D *v3d = area->spacedata.first;
Object *camera = v3d->camera;
@@ -53,11 +53,11 @@ void ED_view3d_smooth_view_undo_begin(bContext *C, ScrArea *area)
* NOTE: It doesn't matter if the actual object being manipulated is the camera or not. */
camera->id.tag &= ~LIB_TAG_DOIT;
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+ LISTBASE_FOREACH (const ARegion *, region, &area->regionbase) {
if (region->regiontype != RGN_TYPE_WINDOW) {
continue;
}
- RegionView3D *rv3d = region->regiondata;
+ const RegionView3D *rv3d = region->regiondata;
if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) {
camera->id.tag |= LIB_TAG_DOIT;
break;
@@ -66,7 +66,7 @@ void ED_view3d_smooth_view_undo_begin(bContext *C, ScrArea *area)
}
void ED_view3d_smooth_view_undo_end(bContext *C,
- ScrArea *area,
+ const ScrArea *area,
const char *undo_str,
const bool undo_grouped)
{
@@ -89,15 +89,15 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
* so even in the case there is a quad-view with multiple camera views set, these will all
* reference the same camera. In this case it doesn't matter which region is used.
* If in the future multiple cameras are supported, this logic can be extended. */
- ARegion *region_camera = NULL;
+ const ARegion *region_camera = NULL;
/* An undo push should be performed. */
bool is_interactive = false;
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
+ LISTBASE_FOREACH (const ARegion *, region, &area->regionbase) {
if (region->regiontype != RGN_TYPE_WINDOW) {
continue;
}
- RegionView3D *rv3d = region->regiondata;
+ const RegionView3D *rv3d = region->regiondata;
if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) {
region_camera = region;
if (rv3d->sms) {
@@ -110,12 +110,13 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
return;
}
+ RegionView3D *rv3d = region_camera->regiondata;
+
/* Fast forward, undo push, then rewind. */
if (is_interactive) {
- view3d_smoothview_apply_with_interp(C, v3d, region_camera, false, 1.0f);
+ view3d_smoothview_apply_with_interp(C, v3d, rv3d, false, 1.0f);
}
- RegionView3D *rv3d = region_camera->regiondata;
if (undo_grouped) {
ED_view3d_camera_lock_undo_grouped_push(undo_str, v3d, rv3d, C);
}
@@ -124,7 +125,7 @@ void ED_view3d_smooth_view_undo_end(bContext *C,
}
if (is_interactive) {
- view3d_smoothview_apply_with_interp(C, v3d, region_camera, false, 0.0f);
+ view3d_smoothview_apply_with_interp(C, v3d, rv3d, false, 0.0f);
}
}
@@ -391,9 +392,8 @@ void ED_view3d_smooth_view(bContext *C,
* Apply with interpolation, on completion run #view3d_smoothview_apply_and_finish.
*/
static void view3d_smoothview_apply_with_interp(
- bContext *C, View3D *v3d, ARegion *region, const bool use_autokey, const float factor)
+ bContext *C, View3D *v3d, RegionView3D *rv3d, const bool use_autokey, const float factor)
{
- RegionView3D *rv3d = region->regiondata;
struct SmoothView3DStore *sms = rv3d->sms;
interp_qt_qtqt(rv3d->viewquat, sms->src.quat, sms->dst.quat, factor);
@@ -410,21 +410,19 @@ static void view3d_smoothview_apply_with_interp(
v3d->lens = interpf(sms->dst.lens, sms->src.lens, factor);
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
- ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
- if (use_autokey) {
- ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
+ if (ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d)) {
+ if (use_autokey) {
+ ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
+ }
}
-
- ED_region_tag_redraw(region);
}
/**
* Apply the view-port transformation & free smooth-view related data.
*/
-static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, ARegion *region)
+static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, RegionView3D *rv3d)
{
wmWindowManager *wm = CTX_wm_manager(C);
- RegionView3D *rv3d = region->regiondata;
struct SmoothView3DStore *sms = rv3d->sms;
wmWindow *win = CTX_wm_window(C);
@@ -439,8 +437,9 @@ static void view3d_smoothview_apply_and_finish(bContext *C, View3D *v3d, ARegion
view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d);
- ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
- ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
+ if (ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d)) {
+ ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
+ }
}
if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) {
@@ -481,18 +480,20 @@ static void view3d_smoothview_apply_from_timer(bContext *C, View3D *v3d, ARegion
factor = 1.0f;
}
if (factor >= 1.0f) {
- view3d_smoothview_apply_and_finish(C, v3d, region);
+ view3d_smoothview_apply_and_finish(C, v3d, rv3d);
}
else {
/* Ease in/out smoothing. */
factor = (3.0f * factor * factor - 2.0f * factor * factor * factor);
const bool use_autokey = ED_screen_animation_playing(wm);
- view3d_smoothview_apply_with_interp(C, v3d, region, use_autokey, factor);
+ view3d_smoothview_apply_with_interp(C, v3d, rv3d, use_autokey, factor);
}
if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
view3d_boxview_copy(CTX_wm_area(C), region);
}
+
+ ED_region_tag_redraw(region);
}
static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
@@ -514,11 +515,10 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
{
RegionView3D *rv3d = region->regiondata;
-
if (rv3d && rv3d->sms) {
- view3d_smoothview_apply_and_finish(C, v3d, region);
+ view3d_smoothview_apply_and_finish(C, v3d, rv3d);
- /* force update of view matrix so tools that run immediately after
+ /* Force update of view matrix so tools that run immediately after
* can use them without redrawing first */
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index ecbf20cef68..fbfd9046112 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2897,11 +2897,6 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
bool changed = false;
int mval[2];
- RNA_int_get_array(op->ptr, "location", mval);
-
- view3d_operator_needs_opengl(C);
- BKE_object_update_select_id(CTX_data_main(C));
-
if (object_only) {
obedit = NULL;
obact = NULL;
@@ -2912,6 +2907,19 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
center = false;
}
+ if (obedit && enumerate) {
+ /* Enumerate makes no sense in edit-mode unless also explicitly picking objects or bones.
+ * Pass the event through so the event may be handled by loop-select for e.g. see: T100204. */
+ if (obedit->type != OB_ARMATURE) {
+ return OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED;
+ }
+ }
+
+ RNA_int_get_array(op->ptr, "location", mval);
+
+ view3d_operator_needs_opengl(C);
+ BKE_object_update_select_id(CTX_data_main(C));
+
if (obedit && object_only == false) {
if (obedit->type == OB_MESH) {
changed = EDBM_select_pick(C, mval, &params);
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 0d88824a784..5f2a4e8c4cc 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -708,8 +708,11 @@ bool ED_view3d_camera_lock_undo_test(const View3D *v3d,
* unnecessary undo steps so undo push for them is not supported for now. Also operators that uses
* smooth view for navigation are excluded too, but they can be supported, see: D15345.
*/
-static bool view3d_camera_lock_undo_ex(
- const char *str, View3D *v3d, RegionView3D *rv3d, struct bContext *C, bool undo_group)
+static bool view3d_camera_lock_undo_ex(const char *str,
+ const View3D *v3d,
+ const RegionView3D *rv3d,
+ struct bContext *C,
+ const bool undo_group)
{
if (ED_view3d_camera_lock_undo_test(v3d, rv3d, C)) {
if (undo_group) {
@@ -723,14 +726,17 @@ static bool view3d_camera_lock_undo_ex(
return false;
}
-bool ED_view3d_camera_lock_undo_push(const char *str, View3D *v3d, RegionView3D *rv3d, bContext *C)
+bool ED_view3d_camera_lock_undo_push(const char *str,
+ const View3D *v3d,
+ const RegionView3D *rv3d,
+ bContext *C)
{
return view3d_camera_lock_undo_ex(str, v3d, rv3d, C, false);
}
bool ED_view3d_camera_lock_undo_grouped_push(const char *str,
- View3D *v3d,
- RegionView3D *rv3d,
+ const View3D *v3d,
+ const RegionView3D *rv3d,
bContext *C)
{
return view3d_camera_lock_undo_ex(str, v3d, rv3d, C, true);
diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c b/source/blender/editors/transform/transform_convert_mesh_uv.c
index d95bc7b976f..f3bef2c283b 100644
--- a/source/blender/editors/transform/transform_convert_mesh_uv.c
+++ b/source/blender/editors/transform/transform_convert_mesh_uv.c
@@ -270,7 +270,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
continue;
}
- island_center = MEM_callocN(sizeof(*island_center) * elementmap->totalIslands, __func__);
+ island_center = MEM_callocN(sizeof(*island_center) * elementmap->total_islands, __func__);
}
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
@@ -315,9 +315,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
}
if (is_island_center) {
- int i;
-
- for (i = 0; i < elementmap->totalIslands; i++) {
+ for (int i = 0; i < elementmap->total_islands; i++) {
mul_v2_fl(island_center[i].co, 1.0f / island_center[i].co_num);
mul_v2_v2(island_center[i].co, t->aspect);
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 092f0c49d8a..6755630d3ef 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -541,14 +541,11 @@ static bool uvedit_uv_straighten(Scene *scene, BMesh *bm, eUVWeldAlign tool)
}
bool changed = false;
-
- /* Loop backwards to simplify logic. */
- int j1 = element_map->total_uvs;
- for (int i = element_map->totalIslands - 1; i >= 0; --i) {
- int j0 = element_map->islandIndices[i];
- changed |= uvedit_uv_straighten_elements(
- element_map->storage + j0, j1 - j0, cd_loop_uv_offset, tool);
- j1 = j0;
+ for (int i = 0; i < element_map->total_islands; i++) {
+ changed |= uvedit_uv_straighten_elements(element_map->storage + element_map->island_indices[i],
+ element_map->island_total_uvs[i],
+ cd_loop_uv_offset,
+ tool);
}
BM_uv_element_map_free(element_map);
diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c
index 749c59ea6a4..d88da21ef98 100644
--- a/source/blender/editors/uvedit/uvedit_select.c
+++ b/source/blender/editors/uvedit/uvedit_select.c
@@ -5395,7 +5395,7 @@ static void uv_isolate_selected_islands(const Scene *scene,
return;
}
- int num_islands = elementmap->totalIslands;
+ int num_islands = elementmap->total_islands;
/* Boolean array that tells if island with index i is completely selected or not. */
bool *is_island_not_selected = MEM_callocN(sizeof(bool) * (num_islands), __func__);
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 26ed98ba236..4a2ea5c3aa6 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -287,14 +287,6 @@ static void stitch_update_header(StitchStateContainer *ssc, bContext *C)
}
}
-static int getNumOfIslandUvs(UvElementMap *elementMap, int island)
-{
- if (island == elementMap->totalIslands - 1) {
- return elementMap->total_uvs - elementMap->islandIndices[island];
- }
- return elementMap->islandIndices[island + 1] - elementMap->islandIndices[island];
-}
-
static void stitch_uv_rotate(const float mat[2][2],
const float medianPoint[2],
float uv[2],
@@ -419,10 +411,9 @@ static void stitch_calculate_island_snapping(StitchState *state,
int final)
{
BMesh *bm = state->em->bm;
- int i;
UvElement *element;
- for (i = 0; i < state->element_map->totalIslands; i++) {
+ for (int i = 0; i < state->element_map->total_islands; i++) {
if (island_stitch_data[i].addedForPreview) {
int numOfIslandUVs = 0, j;
int totelem = island_stitch_data[i].num_rot_elements_neg +
@@ -464,8 +455,8 @@ static void stitch_calculate_island_snapping(StitchState *state,
}
angle_to_mat2(rotation_mat, rotation);
- numOfIslandUVs = getNumOfIslandUvs(state->element_map, i);
- element = &state->element_map->storage[state->element_map->islandIndices[i]];
+ numOfIslandUVs = state->element_map->island_total_uvs[i];
+ element = &state->element_map->storage[state->element_map->island_indices[i]];
for (j = 0; j < numOfIslandUVs; j++, element++) {
/* stitchable uvs have already been processed, don't process */
if (!(element->flag & STITCH_PROCESSED)) {
@@ -984,7 +975,7 @@ static int stitch_process_data(StitchStateContainer *ssc,
preview_position[i].data_position = STITCH_NO_PREVIEW;
}
- island_stitch_data = MEM_callocN(sizeof(*island_stitch_data) * state->element_map->totalIslands,
+ island_stitch_data = MEM_callocN(sizeof(*island_stitch_data) * state->element_map->total_islands,
"stitch_island_data");
if (!island_stitch_data) {
return 0;
@@ -1009,7 +1000,7 @@ static int stitch_process_data(StitchStateContainer *ssc,
}
/* Remember stitchable candidates as places the 'I' button will stop at. */
- for (int island_idx = 0; island_idx < state->element_map->totalIslands; island_idx++) {
+ for (int island_idx = 0; island_idx < state->element_map->total_islands; island_idx++) {
state->island_is_stitchable[island_idx] = island_stitch_data[island_idx].stitchableCandidate ?
true :
false;
@@ -1017,10 +1008,10 @@ static int stitch_process_data(StitchStateContainer *ssc,
if (is_active_state) {
/* set static island to one that is added for preview */
- ssc->static_island %= state->element_map->totalIslands;
+ ssc->static_island %= state->element_map->total_islands;
while (!(island_stitch_data[ssc->static_island].stitchableCandidate)) {
ssc->static_island++;
- ssc->static_island %= state->element_map->totalIslands;
+ ssc->static_island %= state->element_map->total_islands;
/* this is entirely possible if for example limit stitching
* with no stitchable verts or no selection */
if (ssc->static_island == previous_island) {
@@ -1141,13 +1132,11 @@ static int stitch_process_data(StitchStateContainer *ssc,
* Setup preview for stitchable islands *
****************************************/
if (ssc->snap_islands) {
- for (i = 0; i < state->element_map->totalIslands; i++) {
+ for (i = 0; i < state->element_map->total_islands; i++) {
if (island_stitch_data[i].addedForPreview) {
- int numOfIslandUVs = 0, j;
- UvElement *element;
- numOfIslandUVs = getNumOfIslandUvs(state->element_map, i);
- element = &state->element_map->storage[state->element_map->islandIndices[i]];
- for (j = 0; j < numOfIslandUVs; j++, element++) {
+ int numOfIslandUVs = state->element_map->island_total_uvs[i];
+ UvElement *element = &state->element_map->storage[state->element_map->island_indices[i]];
+ for (int j = 0; j < numOfIslandUVs; j++, element++) {
stitch_set_face_preview_buffer_position(element->l->f, preview, preview_position);
}
}
@@ -2120,8 +2109,8 @@ static StitchState *stitch_init(bContext *C,
/***** initialize static island preview data *****/
state->tris_per_island = MEM_mallocN(
- sizeof(*state->tris_per_island) * state->element_map->totalIslands, "stitch island tris");
- for (i = 0; i < state->element_map->totalIslands; i++) {
+ sizeof(*state->tris_per_island) * state->element_map->total_islands, "stitch island tris");
+ for (i = 0; i < state->element_map->total_islands; i++) {
state->tris_per_island[i] = 0;
}
@@ -2133,7 +2122,7 @@ static StitchState *stitch_init(bContext *C,
}
}
- state->island_is_stitchable = MEM_callocN(sizeof(bool) * state->element_map->totalIslands,
+ state->island_is_stitchable = MEM_callocN(sizeof(bool) * state->element_map->total_islands,
"stitch I stops");
if (!state->island_is_stitchable) {
state_delete(state);
@@ -2157,7 +2146,7 @@ static bool goto_next_island(StitchStateContainer *ssc)
do {
ssc->static_island++;
- if (ssc->static_island >= active_state->element_map->totalIslands) {
+ if (ssc->static_island >= active_state->element_map->total_islands) {
/* go to next object */
ssc->active_object_index++;
ssc->active_object_index %= ssc->objects_len;
@@ -2307,7 +2296,7 @@ static int stitch_init_all(bContext *C, wmOperator *op)
ssc->static_island = RNA_int_get(op->ptr, "static_island");
StitchState *state = ssc->states[ssc->active_object_index];
- ssc->static_island %= state->element_map->totalIslands;
+ ssc->static_island %= state->element_map->total_islands;
/* If the initial active object doesn't have any stitchable islands
* then no active island will be seen in the UI.