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:
authorCampbell Barton <ideasman42@gmail.com>2010-08-06 12:27:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-06 12:27:07 +0400
commit14fe11bd8118fcd4f5605305cd23cb269d38fc75 (patch)
tree8124199a5b1141bc2cd13ff597528ee92f843bf0 /source/blender/blenkernel/intern/lattice.c
parent6820d13511ac3a96296ab3f7b65d69a45cb732f4 (diff)
bugfix [#19525] Curve modifier moves mesh geometry first
more of a request then a bug but shows up a strange limitation with curve deform modifier, The mesh bounding box would set the deform axis start/end to map the deformation of the curve to. This means it ignored offset in the object location and object data location (you could use a dummy vertex to trick it). Old files wont change, added an option (next to stretch), called 'Bounds Clamp', old files have this behavior but newly made curves have it disabled. Double checked this gives useful results with stretch on/off and negative axis.
Diffstat (limited to 'source/blender/blenkernel/intern/lattice.c')
-rw-r--r--source/blender/blenkernel/intern/lattice.c105
1 files changed, 75 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 7d8c7a08690..1eb7b5d2021 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -713,7 +713,18 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh
cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist
init_curve_deform(cuOb, target, &cd, (cu->flag & CU_STRETCH)==0);
-
+
+ /* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */
+ if(defaxis < 3) {
+ cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f;
+ cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f;
+ }
+ else {
+ /* negative, these bounds give a good rest position */
+ cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= -1.0f;
+ cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 0.0f;
+ }
+
/* check whether to use vertex groups (only possible if target is a Mesh)
* we want either a Mesh with no derived data, or derived data with
* deformverts
@@ -735,43 +746,77 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh
MDeformVert *dvert = me->dvert;
float vec[3];
float weight;
+
- INIT_MINMAX(cd.dmin, cd.dmax);
-
- for(a = 0; a < numVerts; a++, dvert++) {
- if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+ if(cu->flag & CU_DEFORM_BOUNDS_OFF) {
+ /* dummy bounds */
+ cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f;
+ cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f;
- if(defvert_find_weight(dvert, index) > 0.0f) {
- mul_m4_v3(cd.curvespace, vertexCos[a]);
- DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
+ dvert = me->dvert;
+ for(a = 0; a < numVerts; a++, dvert++) {
+ if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+ weight= defvert_find_weight(dvert, index);
+
+ if(weight > 0.0f) {
+ mul_m4_v3(cd.curvespace, vertexCos[a]);
+ copy_v3_v3(vec, vertexCos[a]);
+ calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+ interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
+ mul_m4_v3(cd.objectspace, vertexCos[a]);
+ }
}
}
-
- dvert = me->dvert;
- for(a = 0; a < numVerts; a++, dvert++) {
- if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
-
- weight= defvert_find_weight(dvert, index);
-
- if(weight > 0.0f) {
- copy_v3_v3(vec, vertexCos[a]);
- calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
- interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
- mul_m4_v3(cd.objectspace, vertexCos[a]);
+ else {
+ /* set mesh min/max bounds */
+ INIT_MINMAX(cd.dmin, cd.dmax);
+
+ for(a = 0; a < numVerts; a++, dvert++) {
+ if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+
+ if(defvert_find_weight(dvert, index) > 0.0f) {
+ mul_m4_v3(cd.curvespace, vertexCos[a]);
+ DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
+ }
+ }
+
+ dvert = me->dvert;
+ for(a = 0; a < numVerts; a++, dvert++) {
+ if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
+
+ weight= defvert_find_weight(dvert, index);
+
+ if(weight > 0.0f) {
+ copy_v3_v3(vec, vertexCos[a]);
+ calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+ interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
+ mul_m4_v3(cd.objectspace, vertexCos[a]);
+ }
}
}
}
- } else {
- INIT_MINMAX(cd.dmin, cd.dmax);
-
- for(a = 0; a < numVerts; a++) {
- mul_m4_v3(cd.curvespace, vertexCos[a]);
- DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
+ }
+ else {
+ if(cu->flag & CU_DEFORM_BOUNDS_OFF) {
+ for(a = 0; a < numVerts; a++) {
+ mul_m4_v3(cd.curvespace, vertexCos[a]);
+ calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+ mul_m4_v3(cd.objectspace, vertexCos[a]);
+ }
}
-
- for(a = 0; a < numVerts; a++) {
- calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
- mul_m4_v3(cd.objectspace, vertexCos[a]);
+ else {
+ /* set mesh min max bounds */
+ INIT_MINMAX(cd.dmin, cd.dmax);
+
+ for(a = 0; a < numVerts; a++) {
+ mul_m4_v3(cd.curvespace, vertexCos[a]);
+ DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
+ }
+
+ for(a = 0; a < numVerts; a++) {
+ calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+ mul_m4_v3(cd.objectspace, vertexCos[a]);
+ }
}
}
cu->flag = flag;