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>2009-04-20 19:06:46 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-04-20 19:06:46 +0400
commit874c29cea8e6f9bc411fccf2d6f4cb07e94328d0 (patch)
tree5971e577cf7c02e05a1e37b5ad058c71a6744877 /source/blender/editors/uvedit
parent7555bfa793a2b0fc187c6211c56986f35b2d7b09 (diff)
parentc5bc4e4fb1a33eda8c31f2ea02e91f32f74c8fa5 (diff)
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323:HEAD
Notes: * blenderbuttons and ICON_SNAP_PEEL_OBJECT were not merged.
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c1
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c32
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.h2
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c4
4 files changed, 34 insertions, 5 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 7b5a264a440..aded5a4cff9 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -38,6 +38,7 @@
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 0fcd0062044..5cc471ebc22 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -4311,8 +4311,8 @@ void param_smooth_area(ParamHandle *handle)
}
}
-void param_pack(ParamHandle *handle)
-{
+void param_pack(ParamHandle *handle, float margin)
+{
/* box packing variables */
boxPack *boxarray, *box;
float tot_width, tot_height, scale;
@@ -4320,6 +4320,7 @@ void param_pack(ParamHandle *handle)
PChart *chart;
int i, unpacked=0;
float trans[2];
+ double area= 0.0;
PHandle *phandle = (PHandle*)handle;
@@ -4332,6 +4333,7 @@ void param_pack(ParamHandle *handle)
/* we may not use all these boxes */
boxarray = MEM_mallocN( phandle->ncharts*sizeof(boxPack), "boxPack box");
+
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
@@ -4352,6 +4354,32 @@ void param_pack(ParamHandle *handle)
box->w = chart->u.pack.size[0] + trans[0];
box->h = chart->u.pack.size[1] + trans[1];
box->index = i; /* warning this index skips PCHART_NOPACK boxes */
+
+ if(margin>0.0f)
+ area += sqrt(box->w*box->h);
+ }
+
+ if(margin>0.0f) {
+ /* multiply the margin by the area to give pradictable results not dependant on UV scale,
+ * ...Without using the area running pack multiple times also gives a bad feedback loop.
+ * multiply by 0.1 so the margin value from the UI can be from 0.0 to 1.0 but not give a massive margin */
+ margin = (margin*(float)area) * 0.1;
+ unpacked= 0;
+ for (i = 0; i < phandle->ncharts; i++) {
+ chart = phandle->charts[i];
+
+ if (chart->flag & PCHART_NOPACK) {
+ unpacked++;
+ continue;
+ }
+
+ box = boxarray+(i-unpacked);
+ trans[0] = margin * area;
+ trans[1] = margin * area;
+ p_chart_uv_translate(chart, trans);
+ box->w += (margin * area) *2;
+ box->h += (margin * area) *2;
+ }
}
boxPack2D(boxarray, phandle->ncharts-unpacked, &tot_width, &tot_height);
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index c468b8d62c5..f1454ee3865 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -73,7 +73,7 @@ void param_smooth_area(ParamHandle *handle);
/* Packing */
-void param_pack(ParamHandle *handle);
+void param_pack(ParamHandle *handle, float margin);
/* Average area for all charts */
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index e9dd1969ee2..4d12700d98c 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -409,7 +409,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
ParamHandle *handle;
handle = construct_param_handle(scene, em, 1, 0, 1, 1);
- param_pack(handle);
+ param_pack(handle, scene->toolsettings->uvcalc_margin);
param_flush(handle);
param_delete(handle);
@@ -804,7 +804,7 @@ static int unwrap_exec(bContext *C, wmOperator *op)
param_lscm_solve(handle);
param_lscm_end(handle);
- param_pack(handle);
+ param_pack(handle, scene->toolsettings->uvcalc_margin);
param_flush(handle);