diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-04-17 10:31:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-17 10:34:14 +0300 |
commit | e05f719b8bc11457b4555bdd8bddf8fe6858ef9d (patch) | |
tree | 3b8be1532be93cc7c2f4f91ac02c3710f2c1ae13 /source | |
parent | 50522cba927e7280fb88e216fd19278fc2290b52 (diff) |
Dyntopo: avoid redundant lookup on original data
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_log.c | 18 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_log.h | 5 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 20 |
3 files changed, 31 insertions, 12 deletions
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c index d2397faa7d1..abc502dae3e 100644 --- a/source/blender/bmesh/intern/bmesh_log.c +++ b/source/blender/bmesh/intern/bmesh_log.c @@ -1086,6 +1086,24 @@ float BM_log_original_mask(BMLog *log, BMVert *v) return lv->mask; } +void BM_log_original_vert_data( + BMLog *log, BMVert *v, + const float **r_co, const short **r_no) +{ + BMLogEntry *entry = log->current_entry; + const BMLogVert *lv; + unsigned v_id = bm_log_vert_id_get(log, v); + void *key = SET_UINT_IN_POINTER(v_id); + + BLI_assert(entry); + + BLI_assert(BLI_ghash_haskey(entry->modified_verts, key)); + + lv = BLI_ghash_lookup(entry->modified_verts, key); + *r_co = lv->co; + *r_no = lv->no; +} + /************************ Debugging and Testing ***********************/ /* For internal use only (unit testing) */ diff --git a/source/blender/bmesh/intern/bmesh_log.h b/source/blender/bmesh/intern/bmesh_log.h index 2147b5c64b4..dd1772af068 100644 --- a/source/blender/bmesh/intern/bmesh_log.h +++ b/source/blender/bmesh/intern/bmesh_log.h @@ -96,6 +96,11 @@ const short *BM_log_original_vert_no(BMLog *log, BMVert *v); /* Get the logged mask of a vertex */ float BM_log_original_mask(BMLog *log, BMVert *v); +/* Get the logged data of a vertex (avoid multiple lookups) */ +void BM_log_original_vert_data( + BMLog *log, BMVert *v, + const float **r_co, const short **r_no); + /* For internal use only (unit testing) */ BMLogEntry *BM_log_current_entry(BMLog *log); struct RangeTreeUInt *BM_log_unused_ids(BMLog *log); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 165de4ca791..2c76b3dee21 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -285,26 +285,22 @@ static void sculpt_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter) { if (orig_data->unode->type == SCULPT_UNDO_COORDS) { - if (orig_data->coords) { - orig_data->co = orig_data->coords[iter->i]; + if (orig_data->bm_log) { + BM_log_original_vert_data( + orig_data->bm_log, iter->bm_vert, + &orig_data->co, &orig_data->no); } else { - orig_data->co = BM_log_original_vert_co(orig_data->bm_log, iter->bm_vert); - } - - if (orig_data->normals) { + orig_data->co = orig_data->coords[iter->i]; orig_data->no = orig_data->normals[iter->i]; } - else { - orig_data->no = BM_log_original_vert_no(orig_data->bm_log, iter->bm_vert); - } } else if (orig_data->unode->type == SCULPT_UNDO_MASK) { - if (orig_data->vmasks) { - orig_data->mask = orig_data->vmasks[iter->i]; + if (orig_data->bm_log) { + orig_data->mask = BM_log_original_mask(orig_data->bm_log, iter->bm_vert); } else { - orig_data->mask = BM_log_original_mask(orig_data->bm_log, iter->bm_vert); + orig_data->mask = orig_data->vmasks[iter->i]; } } } |