[Bf-blender-cvs] [a3f5e6c] master: Fix T39266: Weird Skin modifier shutdown

Sergey Sharybin noreply at git.blender.org
Fri Apr 11 13:56:19 CEST 2014


Commit: a3f5e6c76f08cfb60556c18e1605ed9b8cfa0d5d
Author: Sergey Sharybin
Date:   Fri Apr 11 17:40:07 2014 +0600
https://developer.blender.org/rBa3f5e6c76f08cfb60556c18e1605ed9b8cfa0d5d

Fix T39266: Weird Skin modifier shutdown

Fix wrong quat being calculated for curve's path.
Also avoid some divisions by zero.

Happened in cases when all the curve points have the same coord.

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

M	source/blender/blenkernel/intern/anim.c
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/lattice.c

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

diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 167baec..875e19e 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -535,6 +535,9 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
 	bevp = bevpfirst;
 	bevpn = bevp + 1;
 	bevplast = bevpfirst + (bl->nr - 1);
+	if (UNLIKELY(bevpn > bevplast)) {
+		bevpn = cycl ? bevpfirst : bevplast;
+	}
 	fp = dist + 1;
 	maxdist = dist + tot;
 	fac = 1.0f / ((float)path->len - 1.0f);
@@ -545,17 +548,23 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
 		d = ((float)a) * fac;
 		
 		/* we're looking for location (distance) 'd' in the array */
-		while ((fp < maxdist) && (d >= *fp)) {
-			fp++;
-			if (bevp < bevplast) bevp++;
-			bevpn = bevp + 1;
-			if (UNLIKELY(bevpn > bevplast)) {
-				bevpn = cycl ? bevpfirst : bevplast;
+		if (LIKELY(tot > 0)) {
+			while ((fp < maxdist) && (d >= *fp)) {
+				fp++;
+				if (bevp < bevplast) bevp++;
+				bevpn = bevp + 1;
+				if (UNLIKELY(bevpn > bevplast)) {
+					bevpn = cycl ? bevpfirst : bevplast;
+				}
 			}
+
+			fac1 = (*(fp) - d) / (*(fp) - *(fp - 1));
+			fac2 = 1.0f - fac1;
+		}
+		else {
+			fac1 = 1.0f;
+			fac1 = 0.0f;
 		}
-		
-		fac1 = (*(fp) - d) / (*(fp) - *(fp - 1));
-		fac2 = 1.0f - fac1;
 
 		interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
 		pp->vec[3] = fac1 * bevp->alfa   + fac2 * bevpn->alfa;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 2c94525..96da03d 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -2872,7 +2872,8 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
 		/* 2D Curves */
 		for (bl = bev->first; bl; bl = bl->next) {
 			if (bl->nr < 2) {
-				/* do nothing */
+				BevPoint *bevp = (BevPoint *)(bl + 1);
+				unit_qt(bevp->quat);
 			}
 			else if (bl->nr == 2) {   /* 2 pnt, treat separate */
 				make_bevel_list_segment_2D(bl);
@@ -2886,7 +2887,8 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
 		/* 3D Curves */
 		for (bl = bev->first; bl; bl = bl->next) {
 			if (bl->nr < 2) {
-				/* do nothing */
+				BevPoint *bevp = (BevPoint *)(bl + 1);
+				unit_qt(bevp->quat);
 			}
 			else if (bl->nr == 2) {   /* 2 pnt, treat separate */
 				make_bevel_list_segment_3D(bl);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index c2760b8..06a0327 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -647,10 +647,17 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
 	}
 	else {
 		index = axis;
-		if (cu->flag & CU_STRETCH)
+		if (cu->flag & CU_STRETCH) {
 			fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]);
-		else
-			fac = +(co[index] - cd->dmin[index]) / (par->curve_cache->path->totdist);
+		}
+		else {
+			if (LIKELY(par->curve_cache->path->totdist > FLT_EPSILON)) {
+				fac = +(co[index] - cd->dmin[index]) / (par->curve_cache->path->totdist);
+			}
+			else {
+				fac = 0.0f;
+			}
+		}
 	}
 	
 	if (where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) {  /* returns OK */




More information about the Bf-blender-cvs mailing list