Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2005-12-01 15:45:17 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2005-12-01 15:45:17 +0300
commita09fbc080dea64078a6cfb307a720194ee30e6db (patch)
treed1b3d61b00d95522d4496b3b029f6a2da9cc7743 /source/blender/src/parametrizer.c
parent1a59b16b4831987a12906a1821755c4b249287bb (diff)
Small addition to stretch minimize: with pad +/- or the wheel mouse
you can now blend between the original and minimized. Stretch minimizing trades conformality (= perfect squares in checkerboard texture) for a better sampling of the texture (= often not so well shaped checkerboard), so it is useful to let the user find a balance between the two.
Diffstat (limited to 'source/blender/src/parametrizer.c')
-rw-r--r--source/blender/src/parametrizer.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/source/blender/src/parametrizer.c b/source/blender/src/parametrizer.c
index ff5d92e4604..32e8f6ac187 100644
--- a/source/blender/src/parametrizer.c
+++ b/source/blender/src/parametrizer.c
@@ -1135,6 +1135,19 @@ static void p_flush_uvs(PChart *chart)
}
}
+static void p_flush_uvs_blend(PChart *chart, float blend)
+{
+ PEdge *e;
+ float invblend = 1.0f - blend;
+
+ for (e=(PEdge*)chart->edges->first; e; e=e->link.next) {
+ if (e->orig_uv) {
+ e->orig_uv[0] = blend*e->old_uv[0] + invblend*e->vert->uv[0];
+ e->orig_uv[1] = blend*e->old_uv[1] + invblend*e->vert->uv[1];
+ }
+ }
+}
+
/* Exported */
ParamHandle *param_construct_begin()
@@ -1620,6 +1633,7 @@ void param_stretch_begin(ParamHandle *handle)
phandle->state = PHANDLE_STATE_STRETCH;
phandle->rng = rng_new(31415926);
+ phandle->blend = 0.0f;
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
@@ -1636,6 +1650,28 @@ void param_stretch_begin(ParamHandle *handle)
}
}
+void param_stretch_blend(ParamHandle *handle, float blend)
+{
+ PHandle *phandle = (PHandle*)handle;
+ PChart *chart;
+ int i;
+
+ param_assert(phandle->state == PHANDLE_STATE_STRETCH);
+
+ if (phandle->blend != blend) {
+ phandle->blend = blend;
+
+ for (i = 0; i < phandle->ncharts; i++) {
+ chart = phandle->charts[i];
+
+ if (blend == 0.0f)
+ p_flush_uvs(chart);
+ else
+ p_flush_uvs_blend(chart, blend);
+ }
+ }
+}
+
void param_stretch_iter(ParamHandle *handle)
{
PHandle *phandle = (PHandle*)handle;
@@ -1648,7 +1684,11 @@ void param_stretch_iter(ParamHandle *handle)
chart = phandle->charts[i];
p_chart_stretch_minimize(chart, phandle->rng);
- p_flush_uvs(chart);
+
+ if (phandle->blend == 0.0f)
+ p_flush_uvs(chart);
+ else
+ p_flush_uvs_blend(chart, phandle->blend);
}
}