diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-04-20 13:06:26 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-04-20 13:06:26 +0300 |
commit | c9c207f093b91c2d72cc053284171108a2cb8aee (patch) | |
tree | 775c55f5fd07bdb1ccf1b2665d9dbde0fde91b17 /source/blender/blenkernel/intern | |
parent | a2d5380f621e963dd7d7a99bbf7d3c5231571f8d (diff) | |
parent | 9b4c8a25076fcba566997137140fd23166d52654 (diff) |
Merge branch 'master' into gooseberry
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 30 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/camera.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_bmesh.c | 92 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 34 |
9 files changed, 134 insertions, 60 deletions
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 4b2c6ef5e0e..2085fefdb93 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -687,7 +687,7 @@ static int read_undosave(bContext *C, UndoElem *uel) } /* name can be a dynamic string */ -void BKE_write_undo(bContext *C, const char *name) +void BKE_undo_write(bContext *C, const char *name) { uintptr_t maxmem, totmem, memused; int nr /*, success */ /* UNUSED */; @@ -705,7 +705,7 @@ void BKE_write_undo(bContext *C, const char *name) while (undobase.last != curundo) { uel = undobase.last; BLI_remlink(&undobase, uel); - BLO_free_memfile(&uel->memfile); + BLO_memfile_free(&uel->memfile); MEM_freeN(uel); } @@ -727,7 +727,7 @@ void BKE_write_undo(bContext *C, const char *name) UndoElem *first = undobase.first; BLI_remlink(&undobase, first); /* the merge is because of compression */ - BLO_merge_memfile(&first->memfile, &first->next->memfile); + BLO_memfile_merge(&first->memfile, &first->next->memfile); MEM_freeN(first); } } @@ -782,7 +782,7 @@ void BKE_write_undo(bContext *C, const char *name) UndoElem *first = undobase.first; BLI_remlink(&undobase, first); /* the merge is because of compression */ - BLO_merge_memfile(&first->memfile, &first->next->memfile); + BLO_memfile_merge(&first->memfile, &first->next->memfile); MEM_freeN(first); } } @@ -821,13 +821,13 @@ void BKE_undo_step(bContext *C, int step) } } -void BKE_reset_undo(void) +void BKE_undo_reset(void) { UndoElem *uel; uel = undobase.first; while (uel) { - BLO_free_memfile(&uel->memfile); + BLO_memfile_free(&uel->memfile); uel = uel->next; } @@ -854,7 +854,7 @@ void BKE_undo_name(bContext *C, const char *name) } /* name optional */ -int BKE_undo_valid(const char *name) +bool BKE_undo_is_valid(const char *name) { if (name) { UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); @@ -866,15 +866,16 @@ int BKE_undo_valid(const char *name) /* get name of undo item, return null if no item with this index */ /* if active pointer, set it to 1 if true */ -const char *BKE_undo_get_name(int nr, int *active) +const char *BKE_undo_get_name(int nr, bool *r_active) { UndoElem *uel = BLI_findlink(&undobase, nr); - if (active) *active = 0; + if (r_active) *r_active = false; if (uel) { - if (active && uel == curundo) - *active = 1; + if (r_active && (uel == curundo)) { + *r_active = true; + } return uel->name; } return NULL; @@ -940,15 +941,16 @@ bool BKE_undo_save_file(const char *filename) } /* sets curscene */ -Main *BKE_undo_get_main(Scene **scene) +Main *BKE_undo_get_main(Scene **r_scene) { Main *mainp = NULL; BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); if (bfd) { mainp = bfd->main; - if (scene) - *scene = bfd->curscene; + if (r_scene) { + *r_scene = bfd->curscene; + } MEM_freeN(bfd); } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index d62628baa9e..87d81a9e921 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -728,7 +728,8 @@ static void camera_stereo3d_model_matrix(Object *camera, const bool is_left, flo if (((pivot == CAM_S3D_PIVOT_LEFT) && is_left) || ((pivot == CAM_S3D_PIVOT_RIGHT) && !is_left)) { - return camera_model_matrix(camera, r_modelmat); + camera_model_matrix(camera, r_modelmat); + return; } else { float size[3]; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 71404a81c68..724ca6de3fc 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2306,7 +2306,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest, } } - if (count > SOURCE_BUF_SIZE) MEM_freeN(sources); + if (count > SOURCE_BUF_SIZE) MEM_freeN((void *)sources); } void CustomData_swap(struct CustomData *data, int index, const int *corner_indices) @@ -3864,7 +3864,7 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap, const CustomDataTra if (tmp_data_src) { if (UNLIKELY(sources_num > tmp_buff_size)) { tmp_buff_size = (size_t)sources_num; - tmp_data_src = MEM_reallocN(tmp_data_src, sizeof(*tmp_data_src) * tmp_buff_size); + tmp_data_src = MEM_reallocN((void *)tmp_data_src, sizeof(*tmp_data_src) * tmp_buff_size); } for (j = 0; j < sources_num; j++) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index bb9fdba94fa..a09c42e9178 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -960,8 +960,10 @@ void BKE_image_memorypack(Image *ima) { ImBuf *ibuf; - if ((ima->flag & IMA_IS_MULTIVIEW)) - return image_memorypack_multiview(ima); + if ((ima->flag & IMA_IS_MULTIVIEW)) { + image_memorypack_multiview(ima); + return; + } ibuf = image_get_cached_ibuf_for_index_frame(ima, IMA_NO_INDEX, 0); @@ -2494,7 +2496,7 @@ static void image_init_imageuser(Image *ima, ImageUser *iuser) void BKE_image_init_imageuser(Image *ima, ImageUser *iuser) { - return image_init_imageuser(ima, iuser); + image_init_imageuser(ima, iuser); } void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 43db4b75e65..23206823604 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1821,8 +1821,9 @@ float (*BKE_mesh_vertexCos_get(const Mesh *me, int *r_numVerts))[3] * Find the index of the loop in 'poly' which references vertex, * returns -1 if not found */ -int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, - unsigned vert) +int poly_find_loop_from_vert( + const MPoly *poly, const MLoop *loopstart, + unsigned vert) { int j; for (j = 0; j < poly->totloop; j++, loopstart++) { @@ -1838,20 +1839,22 @@ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, * vertex. Returns the index of the loop matching vertex, or -1 if the * vertex is not in \a poly */ -int poly_get_adj_loops_from_vert(unsigned r_adj[3], const MPoly *poly, - const MLoop *mloop, unsigned vert) +int poly_get_adj_loops_from_vert( + unsigned r_adj[2], const MPoly *poly, + const MLoop *mloop, unsigned vert) { int corner = poly_find_loop_from_vert(poly, &mloop[poly->loopstart], vert); if (corner != -1) { +#if 0 /* unused - this loop */ const MLoop *ml = &mloop[poly->loopstart + corner]; +#endif /* vertex was found */ r_adj[0] = ME_POLY_LOOP_PREV(mloop, poly, corner)->v; - r_adj[1] = ml->v; - r_adj[2] = ME_POLY_LOOP_NEXT(mloop, poly, corner)->v; + r_adj[1] = ME_POLY_LOOP_NEXT(mloop, poly, corner)->v; } return corner; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 650efea2e96..1ad6446eb05 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1649,6 +1649,12 @@ bool BKE_nla_action_stash(AnimData *adt) nlt->flag = (NLATRACK_MUTED | NLATRACK_PROTECTED); strip->flag &= ~(NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE); + /* also mark the strip for auto syncing the length, so that the strips accurately + * reflect the length of the action + * XXX: we could do with some extra flags here to prevent repeats/scaling options from working! + */ + strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH; + /* succeeded */ return true; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 4845f669f75..a86b5720614 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1084,7 +1084,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name) ob->jump_speed = 10.0f; ob->fall_speed = 55.0f; ob->col_group = 0x01; - ob->col_mask = 0xff; + ob->col_mask = 0xffff; /* NT fluid sim defaults */ ob->fluidsimSettings = NULL; diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index d54c598e988..5977243a21c 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -49,6 +49,15 @@ /* don't add edges into the queue multiple times */ #define USE_EDGEQUEUE_TAG +/** + * Ensure we don't have dirty tags for the edge queue, and that they are left cleared. + * (slow, even for debug mode, so leave disabled for now). + */ +#if defined(USE_EDGEQUEUE_TAG) && 0 +# if !defined(NDEBUG) +# define USE_EDGEQUEUE_TAG_VERIFY +# endif +#endif // #define USE_VERIFY @@ -606,6 +615,37 @@ typedef struct { # define EDGE_QUEUE_DISABLE(e) BM_elem_flag_disable((CHECK_TYPE_INLINE(e, BMEdge *), e), BM_ELEM_TAG) #endif +#ifdef USE_EDGEQUEUE_TAG_VERIFY +/* simply check no edges are tagged + * (it's a requirement that edges enter and leave a clean tag state) */ +static void pbvh_bmesh_edge_tag_verify(PBVH *bvh) +{ + int n; + + for (n = 0; n < bvh->totnode; n++) { + PBVHNode *node = &bvh->nodes[n]; + GSetIterator gs_iter; + if (node->bm_faces) { + GSET_ITER (gs_iter, node->bm_faces) { + BMFace *f = BLI_gsetIterator_getKey(&gs_iter); + BMEdge *e_tri[3]; + BMLoop *l_iter; + + BLI_assert(f->len == 3); + l_iter = BM_FACE_FIRST_LOOP(f); + e_tri[0] = l_iter->e; l_iter = l_iter->next; + e_tri[1] = l_iter->e; l_iter = l_iter->next; + e_tri[2] = l_iter->e; + + BLI_assert((EDGE_QUEUE_TEST(e_tri[0]) == false) && + (EDGE_QUEUE_TEST(e_tri[1]) == false) && + (EDGE_QUEUE_TEST(e_tri[2]) == false)); + } + } + } +} +#endif + static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f) { BMVert *v_tri[3]; @@ -675,7 +715,13 @@ static void long_edge_queue_edge_add_recursive( const float len_sq, float limit_len) { BLI_assert(len_sq > SQUARE(limit_len)); - edge_queue_insert(eq_ctx, l_edge->e, -len_sq); + +#ifdef USE_EDGEQUEUE_TAG + if (EDGE_QUEUE_TEST(l_edge->e) == false) +#endif + { + edge_queue_insert(eq_ctx, l_edge->e, -len_sq); + } /* temp support previous behavior! */ if (UNLIKELY(G.debug_value == 1234)) { @@ -703,17 +749,12 @@ static void long_edge_queue_edge_add_recursive( BMLoop *l_adjacent[2] = {l_iter->next, l_iter->prev}; int i; for (i = 0; i < ARRAY_SIZE(l_adjacent); i++) { -#ifdef USE_EDGEQUEUE_TAG - if (EDGE_QUEUE_TEST(l_adjacent[i]->e) == false) -#endif - { - len_sq_other = BM_edge_calc_length_squared(l_adjacent[i]->e); - if (len_sq_other > max_ff(len_sq_cmp, limit_len_sq)) { -// edge_queue_insert(eq_ctx, l_adjacent[i]->e, -len_sq_other); - long_edge_queue_edge_add_recursive( - eq_ctx, l_adjacent[i]->radial_next, l_adjacent[i], - len_sq_other, limit_len); - } + len_sq_other = BM_edge_calc_length_squared(l_adjacent[i]->e); + if (len_sq_other > max_ff(len_sq_cmp, limit_len_sq)) { +// edge_queue_insert(eq_ctx, l_adjacent[i]->e, -len_sq_other); + long_edge_queue_edge_add_recursive( + eq_ctx, l_adjacent[i]->radial_next, l_adjacent[i], + len_sq_other, limit_len); } } } while ((l_iter = l_iter->radial_next) != l_end); @@ -748,9 +789,6 @@ static void long_edge_queue_face_add(EdgeQueueContext *eq_ctx, /* Check each edge of the face */ l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { -#ifdef USE_EDGEQUEUE_TAG - if (EDGE_QUEUE_TEST(l_iter->e) == false) -#endif { #ifdef USE_EDGEQUEUE_EVEN_SUBDIV const float len_sq = BM_edge_calc_length_squared(l_iter->e); @@ -805,6 +843,11 @@ static void long_edge_queue_create(EdgeQueueContext *eq_ctx, eq_ctx->q->limit_len = bvh->bm_max_edge_len; #endif +#ifdef USE_EDGEQUEUE_TAG_VERIFY + pbvh_bmesh_edge_tag_verify(bvh); +#endif + + for (n = 0; n < bvh->totnode; n++) { PBVHNode *node = &bvh->nodes[n]; @@ -999,9 +1042,8 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *bvh, { bool any_subdivided = false; -#if defined(USE_EDGEQUEUE_TAG) && !defined(NDEBUG) -# define USE_EDGEQUEUE_TAG_VALIDATE - int heap_tot = 0, heap_overlap = 0; +#ifdef USE_EDGEQUEUE_TAG_VERIFY + pbvh_bmesh_edge_tag_verify(bvh); #endif @@ -1013,15 +1055,8 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *bvh, BLI_mempool_free(eq_ctx->pool, pair); pair = NULL; -#ifdef USE_EDGEQUEUE_TAG_VALIDATE - heap_tot += 1; -#endif - /* Check that the edge still exists */ if (!(e = BM_edge_exists(v1, v2))) { -#ifdef USE_EDGEQUEUE_TAG_VALIDATE - heap_overlap += 1; -#endif continue; } #ifdef USE_EDGEQUEUE_TAG @@ -1052,11 +1087,10 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *bvh, pbvh_bmesh_split_edge(eq_ctx, bvh, e, edge_loops); } -#ifdef USE_EDGEQUEUE_TAG_VALIDATE - // printf("%d %d\n", heap_total, heap_overlap); - BLI_assert(heap_overlap == 0); -#undef USE_EDGEQUEUE_TAG_VALIDATE +#ifdef USE_EDGEQUEUE_TAG_VERIFY + pbvh_bmesh_edge_tag_verify(bvh); #endif + return any_subdivided; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 462f20c2b73..5b9b85dc90a 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -5286,10 +5286,6 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup MEM_dupallocN(seq->strip->stripdata); } else if (seq->type >= SEQ_TYPE_EFFECT) { - if (seq->seq1 && seq->seq1->tmp) seqn->seq1 = seq->seq1->tmp; - if (seq->seq2 && seq->seq2->tmp) seqn->seq2 = seq->seq2->tmp; - if (seq->seq3 && seq->seq3->tmp) seqn->seq3 = seq->seq3->tmp; - if (seq->type & SEQ_TYPE_EFFECT) { struct SeqEffectHandle sh; sh = BKE_sequence_get_effect(seq); @@ -5314,6 +5310,28 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup return seqn; } +static void seq_new_fix_links_recursive(Sequence *seq) +{ + SequenceModifierData *smd; + + if (seq->type >= SEQ_TYPE_EFFECT) { + if (seq->seq1 && seq->seq1->tmp) seq->seq1 = seq->seq1->tmp; + if (seq->seq2 && seq->seq2->tmp) seq->seq2 = seq->seq2->tmp; + if (seq->seq3 && seq->seq3->tmp) seq->seq3 = seq->seq3->tmp; + } + else if (seq->type == SEQ_TYPE_META) { + Sequence *seqn; + for (seqn = seq->seqbase.first; seqn; seqn = seqn->next) { + seq_new_fix_links_recursive(seqn); + } + } + + for (smd = seq->modifiers.first; smd; smd = smd->next) { + if (smd->mask_sequence && smd->mask_sequence->tmp) + smd->mask_sequence = smd->mask_sequence->tmp; + } +} + Sequence *BKE_sequence_dupli_recursive(Scene *scene, Scene *scene_to, Sequence *seq, int dupe_flag) { Sequence *seqn = seq_dupli(scene, scene_to, seq, dupe_flag); @@ -5326,6 +5344,9 @@ Sequence *BKE_sequence_dupli_recursive(Scene *scene, Scene *scene_to, Sequence * } } } + + seq_new_fix_links_recursive(seqn); + return seqn; } @@ -5364,6 +5385,11 @@ void BKE_sequence_base_dupli_recursive( } } } + + /* fix modifier linking */ + for (seq = nseqbase->first; seq; seq = seq->next) { + seq_new_fix_links_recursive(seq); + } } /* called on draw, needs to be fast, |