diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-09-06 13:46:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-09-06 13:49:31 +0300 |
commit | c89791ba788da65bc0ebe57af3a1dfa754d77863 (patch) | |
tree | 98f227066ac6d2927506cddf565388083a137766 /source/blender/editors/uvedit | |
parent | f1c8c25a3edfbb03795250965ece9d39fef58356 (diff) |
Multi object support for UV live unwrap
D3658 by @Al
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 5186b65f77c..12d8d902fda 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -964,10 +964,14 @@ void UV_OT_average_islands_scale(wmOperatorType *ot) /**************** Live Unwrap *****************/ -static ParamHandle *liveHandle = NULL; +static struct { + ParamHandle **handles; + uint len, len_alloc; +} g_live_unwrap = {NULL}; void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit) { + ParamHandle *handle = NULL; BMEditMesh *em = BKE_editmesh_from_object(obedit); const bool abf = (scene->toolsettings->unwrapper == 0); const bool fillholes = (scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES) != 0; @@ -980,29 +984,49 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit) } if (use_subsurf) - liveHandle = construct_param_handle_subsurfed(scene, obedit, em, fillholes, false, true); + handle = construct_param_handle_subsurfed(scene, obedit, em, fillholes, false, true); else - liveHandle = construct_param_handle(scene, obedit, em->bm, false, fillholes, false, true); + handle = construct_param_handle(scene, obedit, em->bm, false, fillholes, false, true); - param_lscm_begin(liveHandle, PARAM_TRUE, abf); + param_lscm_begin(handle, PARAM_TRUE, abf); + + /* Create or increase size of g_live_unwrap.handles array */ + if (g_live_unwrap.handles == NULL) { + g_live_unwrap.len_alloc = 32; + g_live_unwrap.handles = MEM_mallocN(sizeof(ParamHandle *) * g_live_unwrap.len_alloc, "uvedit_live_unwrap_liveHandles"); + g_live_unwrap.len = 0; + } + if (g_live_unwrap.len >= g_live_unwrap.len_alloc) { + g_live_unwrap.len_alloc *= 2; + g_live_unwrap.handles = MEM_reallocN(g_live_unwrap.handles, sizeof(ParamHandle *) * g_live_unwrap.len_alloc); + } + g_live_unwrap.handles[g_live_unwrap.len] = handle; + g_live_unwrap.len++; } void ED_uvedit_live_unwrap_re_solve(void) { - if (liveHandle) { - param_lscm_solve(liveHandle); - param_flush(liveHandle); + if (g_live_unwrap.handles) { + for (int i = 0; i < g_live_unwrap.len; i++) { + param_lscm_solve(g_live_unwrap.handles[i]); + param_flush(g_live_unwrap.handles[i]); + } } } void ED_uvedit_live_unwrap_end(short cancel) { - if (liveHandle) { - param_lscm_end(liveHandle); - if (cancel) - param_flush_restore(liveHandle); - param_delete(liveHandle); - liveHandle = NULL; + if (g_live_unwrap.handles) { + for (int i = 0; i < g_live_unwrap.len; i++) { + param_lscm_end(g_live_unwrap.handles[i]); + if (cancel) + param_flush_restore(g_live_unwrap.handles[i]); + param_delete(g_live_unwrap.handles[i]); + } + MEM_freeN(g_live_unwrap.handles); + g_live_unwrap.handles = NULL; + g_live_unwrap.len = 0; + g_live_unwrap.len_alloc = 0; } } |