[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56838] trunk/blender/source/blender/bmesh /operators/bmo_grid_fill.c: bmesh grid fill: interpolate vertex customdata (useful for vertex weights and shapekeys)
Campbell Barton
ideasman42 at gmail.com
Thu May 16 09:21:35 CEST 2013
Revision: 56838
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56838
Author: campbellbarton
Date: 2013-05-16 07:21:34 +0000 (Thu, 16 May 2013)
Log Message:
-----------
bmesh grid fill: interpolate vertex customdata (useful for vertex weights and shapekeys)
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/operators/bmo_grid_fill.c
Modified: trunk/blender/source/blender/bmesh/operators/bmo_grid_fill.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_grid_fill.c 2013-05-16 03:55:47 UTC (rev 56837)
+++ trunk/blender/source/blender/bmesh/operators/bmo_grid_fill.c 2013-05-16 07:21:34 UTC (rev 56838)
@@ -31,6 +31,8 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BKE_customdata.h"
+
#include "bmesh.h"
#include "intern/bmesh_operators_private.h" /* own include */
@@ -110,6 +112,7 @@
const short mat_nr, const bool use_smooth,
const bool use_flip)
{
+ const bool use_vert_interp = CustomData_has_interp(&bm->vdata);
int x, y;
#define XY(_x, _y) ((_x) + ((_y) * (xtot)))
@@ -186,6 +189,19 @@
v = BM_vert_create(bm, co, NULL, 0);
v_grid[(y * xtot) + x] = v;
+
+ /* interpolate only along one axis, this could be changed
+ * but from user pov gives predictable results since these are selected loop */
+ if (use_vert_interp) {
+ void *v_cdata[2] = {
+ v_grid[XY(x, 0)]->head.data,
+ v_grid[XY(x, (ytot - 1))]->head.data,
+ };
+ const float t = (float)y / ((float)ytot - 1);
+ const float w[2] = {1.0f - t, t};
+ CustomData_bmesh_interp(&bm->vdata, v_cdata, w, NULL, 2, v->head.data);
+ }
+
}
}
@@ -272,7 +288,9 @@
for (el = lb_b->first, i = 0; el; el = el->next, i++) { v_grid[(ytot * xtot) + (i - xtot)] = el->data; }
for (el = lb_rail_a->first, i = 0; el; el = el->next, i++) { v_grid[xtot * i] = el->data; }
for (el = lb_rail_b->first, i = 0; el; el = el->next, i++) { v_grid[(xtot * i) + (xtot - 1)] = el->data; }
+#ifdef DEBUG
for (x = 1; x < xtot - 1; x++) { for (y = 1; y < ytot - 1; y++) { BLI_assert(v_grid[(y * xtot) + x] == NULL); }}
+#endif
#ifdef USE_FLIP_DETECT
{
More information about the Bf-blender-cvs
mailing list