[Bf-blender-cvs] [dfa8f25] soc-2016-uv_tools: Move flushing uvs including selection tags to own function
Phil Gosch
noreply at git.blender.org
Tue Aug 9 00:11:55 CEST 2016
Commit: dfa8f25de842c15bb354fc447a241e65f2198fe8
Author: Phil Gosch
Date: Mon Aug 8 02:00:32 2016 +0200
Branches: soc-2016-uv_tools
https://developer.blender.org/rBdfa8f25de842c15bb354fc447a241e65f2198fe8
Move flushing uvs including selection tags to own function
This fixes crashes when unwrapping a mesh for the first time
===================================================================
M source/blender/editors/uvedit/uvedit_parametrizer.c
M source/blender/editors/uvedit/uvedit_parametrizer.h
M source/blender/editors/uvedit/uvedit_unwrap_ops.c
===================================================================
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index f6cf042..2bd65f9 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -821,6 +821,18 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
static void p_flush_uvs(PHandle *handle, PChart *chart)
{
PEdge *e;
+
+ for (e = chart->edges; e; e = e->nextlink) {
+ if (e->orig_uv) {
+ e->orig_uv[0] = e->vert->uv[0] / handle->aspx;
+ e->orig_uv[1] = e->vert->uv[1] / handle->aspy;
+ }
+ }
+}
+
+static void p_flush_uvs_selection(PHandle *handle, PChart *chart)
+{
+ PEdge *e;
int sel_flag = 0;
/* ToDo (SaphireS): Find sensible variable names*/
int MLOOPEDGE_SELECTED = (1 << 0); /* MLOOPUV_EDGESEL*/
@@ -832,12 +844,12 @@ static void p_flush_uvs(PHandle *handle, PChart *chart)
e->orig_uv[1] = e->vert->uv[1] / handle->aspy;
}
- /* ToDo (SaphireS): Move to own p_flush_uvs_selection() function ?*/
if (e->flag & PEDGE_SELECT) {
+
sel_flag = *e->orig_flag;
sel_flag |= MLOOPEDGE_SELECTED;/* MLOOPUV_EDGESEL*/
sel_flag |= MLOOPVERT_SELECTED; /* MLOOPUV_VERTSEL*/
- *(e->orig_flag) = sel_flag;
+ *(e->orig_flag) = sel_flag;
}
else {
sel_flag = *e->orig_flag;
@@ -6189,6 +6201,26 @@ void param_flush(ParamHandle *handle)
}
}
+/* Use this function if you need to flush position + selection tags */
+void param_flush_sel(ParamHandle *handle)
+{
+ PHandle *phandle = (PHandle *)handle;
+ PChart *chart;
+ int i;
+
+ for (i = 0; i < phandle->ncharts; i++) {
+ chart = phandle->charts[i];
+
+ if ((phandle->state == PHANDLE_STATE_LSCM) && !chart->u.lscm.context)
+ continue;
+
+ if (phandle->blend == 0.0f)
+ p_flush_uvs_selection(phandle, chart);
+ else
+ p_flush_uvs_blend(phandle, chart, phandle->blend);
+ }
+}
+
void param_flush_restore(ParamHandle *handle)
{
PHandle *phandle = (PHandle *)handle;
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index f22d24c..6bc0e8a 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -129,11 +129,12 @@ void param_shortest_path(ParamHandle *handle, bool *p_found, bool topological_di
/* Select Overlapping */
-void param_select_overlapping(ParamHandle *handle, bool extend);
+void param_select_overlapping(ParamHandle *handle, const bool extend);
/* Flushing */
void param_flush(ParamHandle *handle);
+void param_flush_sel(ParamHandle *handle);
void param_flush_restore(ParamHandle *handle);
/* XXX (SaphireS): Remove */
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 020d727..39bb0d1 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -746,7 +746,7 @@ bool ED_uvedit_shortest_path_select(Scene *scene, Object *ob, BMesh *bm, bool to
int hparams = set_handle_params(true, false, false, true, true);
handle = construct_param_handle(scene, ob, bm, hparams);
param_shortest_path(handle, &path_found, topo_dist);
- param_flush(handle);
+ param_flush_sel(handle);
param_delete(handle);
return path_found;
}
More information about the Bf-blender-cvs
mailing list