Commit: 1e13733b44ffd205c2443daeac567cb3853a9cb0
Author: Phil Gosch
Date:   Tue Jun 21 15:07:15 2016 +0200
Branches: soc-2016-uv_tools
https://developer.blender.org/rB1e13733b44ffd205c2443daeac567cb3853a9cb0

Implemented a function to compute the area used by UV charts

This will be handy when calculating the used/wasted space during packing

===================================================================

M       source/blender/editors/uvedit/uvedit_parametrizer.c

===================================================================

diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c 
b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 5e19f84..53652b8 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -425,6 +425,24 @@ static float p_face_uv_area_signed(PFace *f)
                       ((v3->uv[0] - v1->uv[0]) * (v2->uv[1] - v1->uv[1])));
 }
 
+/* returns the sum of the areas of all charts */
+static float p_face_uv_area_combined(ParamHandle *handle)
+{
+       PHandle *phandle = (PHandle *)handle;
+       PChart *chart;
+       PFace *f;
+       float used_area = 0.0f;
+       int i;
+
+       for (i = 0; i < phandle->ncharts; i++) {
+               for (f = phandle->charts[i]->faces; f; f = f->nextlink) {
+                       used_area += fabsf(p_face_uv_area_signed(f));
+               }
+       }
+
+       return used_area;
+}
+
 static float p_edge_length(PEdge *e)
 {
        PVert *v1 = e->vert, *v2 = e->next->vert;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to