diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-03 19:12:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-03 19:12:39 +0300 |
commit | e52beb373323122f6d706e887a8ee3e2c58beb2e (patch) | |
tree | 0e409009d8aa4df733fe50dee504ae361040a171 /source/blender/blenkernel/intern | |
parent | c713e9c4724f2f75e28eb421021ed0428e919aab (diff) | |
parent | ab695c32974fde8720c04dff47d240b7fa0f8151 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/undo_system.c | 38 |
6 files changed, 42 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d38987c942f..d421d780343 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2740,7 +2740,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) if (BKE_image_has_packedfile(ima)) { const int totfiles = image_num_files(ima); - if (totfiles != BLI_listbase_count_ex(&ima->packedfiles, totfiles + 1)) { + if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) { /* in case there are new available files to be loaded */ image_free_packedfiles(ima); BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(G.main, &ima->id)); @@ -2895,7 +2895,7 @@ void BKE_image_multiview_index(Image *ima, ImageUser *iuser) iuser->multi_index = iuser->multiview_eye; } else { - if ((iuser->view < 0) || (iuser->view >= BLI_listbase_count_ex(&ima->views, iuser->view + 1))) { + if ((iuser->view < 0) || (iuser->view >= BLI_listbase_count_at_most(&ima->views, iuser->view + 1))) { iuser->multi_index = iuser->view = 0; } else { @@ -3362,7 +3362,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) const int totfiles = image_num_files(ima); int i; - if (totfiles != BLI_listbase_count_ex(&ima->anims, totfiles + 1)) { + if (totfiles != BLI_listbase_count_at_most(&ima->anims, totfiles + 1)) { image_free_anims(ima); for (i = 0; i < totfiles; i++) { @@ -3518,7 +3518,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* this should never happen, but just playing safe */ if (has_packed) { - if (totfiles != BLI_listbase_count_ex(&ima->packedfiles, totfiles + 1)) { + if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) { image_free_packedfiles(ima); has_packed = false; } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 2e44c941791..3ed2aeb6582 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -421,7 +421,7 @@ void BKE_paint_curve_clamp_endpoint_add_index(PaintCurve *pc, const int add_inde /* remove colour from palette. Must be certain color is inside the palette! */ void BKE_palette_color_remove(Palette *palette, PaletteColor *color) { - if (BLI_listbase_count_ex(&palette->colors, palette->active_color) == palette->active_color) { + if (BLI_listbase_count_at_most(&palette->colors, palette->active_color) == palette->active_color) { palette->active_color--; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 94f37c3e02c..5a30b3dacf8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3180,7 +3180,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->part = BKE_particlesettings_add(NULL, DATA_("ParticleSettings")); - if (BLI_listbase_count_ex(&ob->particlesystem, 2) > 1) + if (BLI_listbase_count_at_most(&ob->particlesystem, 2) > 1) BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_listbase_count(&ob->particlesystem)); else BLI_strncpy(psys->name, DATA_("ParticleSystem"), sizeof(psys->name)); diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 6b6f2605dc3..e32a5d0681e 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -555,9 +555,9 @@ static int pbvh_bmesh_node_vert_use_count(PBVH *bvh, PBVHNode *node, BMVert *v) #endif #define pbvh_bmesh_node_vert_use_count_is_equal(bvh, node, v, n) \ - (pbvh_bmesh_node_vert_use_count_ex(bvh, node, v, (n) + 1) == n) + (pbvh_bmesh_node_vert_use_count_at_most(bvh, node, v, (n) + 1) == n) -static int pbvh_bmesh_node_vert_use_count_ex(PBVH *bvh, PBVHNode *node, BMVert *v, const int count_max) +static int pbvh_bmesh_node_vert_use_count_at_most(PBVH *bvh, PBVHNode *node, BMVert *v, const int count_max) { int count = 0; BMFace *f; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5a6f33e0e8c..184016100c4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2959,7 +2959,7 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context, Sequence *seq int totviews; int i; - if (totfiles != BLI_listbase_count_ex(&seq->anims, totfiles + 1)) + if (totfiles != BLI_listbase_count_at_most(&seq->anims, totfiles + 1)) goto monoview_movie; totviews = BKE_scene_multiview_num_views_get(&context->scene->r); diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index ddcd16f998e..2de7dd96867 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -355,7 +355,7 @@ void BKE_undosys_step_push_init_with_type(UndoStack *ustack, bContext *C, const if (ut->step_encode_init) { undosys_stack_validate(ustack, false); UndoStep *us = MEM_callocN(ut->step_size, __func__); - CLOG_INFO(&LOG, 1, "%p, '%s', type='%s'", us, name, us->type->name); + CLOG_INFO(&LOG, 1, "%p, '%s', type='%s'", us, name, ut->name); if (name != NULL) { BLI_strncpy(us->name, name, sizeof(us->name)); } @@ -720,6 +720,9 @@ static bool undosys_ID_map_lookup_index(const UndoIDPtrMap *map, const void *key max = mid - 1; } } + if (r_index) { + *r_index = min; + } return false; } @@ -772,11 +775,13 @@ void BKE_undosys_ID_map_add(UndoIDPtrMap *map, ID *id) #endif map->refs[len_src].ptr = id; - map->pmap[len_src].ptr = id; - map->pmap[len_src].index = len_src; - map->len = len_dst; + if (len_src != 0 && index != len_src) { + memmove(&map->pmap[index + 1], &map->pmap[index], sizeof(*map->pmap) * (len_src - index)); + } + map->pmap[index].ptr = id; + map->pmap[index].index = len_src; - qsort(map->pmap, map->len, sizeof(*map->pmap), BLI_sortutil_cmp_ptr); + map->len = len_dst; } ID *BKE_undosys_ID_map_lookup(const UndoIDPtrMap *map, const ID *id_src) @@ -786,10 +791,33 @@ ID *BKE_undosys_ID_map_lookup(const UndoIDPtrMap *map, const ID *id_src) if (!undosys_ID_map_lookup_index(map, id_src, &index)) { BLI_assert(0); } + index = map->pmap[index].index; ID *id_dst = map->refs[index].ptr; BLI_assert(id_dst != NULL); BLI_assert(STREQ(id_dst->name, map->refs[index].name)); return id_dst; } +void BKE_undosys_ID_map_add_with_prev(UndoIDPtrMap *map, ID *id, ID **id_prev) +{ + if (id == *id_prev) { + return; + } + *id_prev = id; + BKE_undosys_ID_map_add(map, id); +} + +ID *BKE_undosys_ID_map_lookup_with_prev(const UndoIDPtrMap *map, ID *id_src, ID *id_prev_match[2]) +{ + if (id_src == id_prev_match[0]) { + return id_prev_match[1]; + } + else { + ID *id_dst = BKE_undosys_ID_map_lookup(map, id_src); + id_prev_match[0] = id_src; + id_prev_match[1] = id_dst; + return id_dst; + } +} + /** \} */ |