[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28323] trunk/blender: option to use curve point weights to influence particle effectors.

Campbell Barton ideasman42 at gmail.com
Wed Apr 21 13:59:47 CEST 2010


Revision: 28323
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28323
Author:   campbellbarton
Date:     2010-04-21 13:59:47 +0200 (Wed, 21 Apr 2010)

Log Message:
-----------
option to use curve point weights to influence particle effectors.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_physics_field.py
    trunk/blender/source/blender/blenkernel/BKE_anim.h
    trunk/blender/source/blender/blenkernel/BKE_curve.h
    trunk/blender/source/blender/blenkernel/intern/anim.c
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/blenkernel/intern/curve.c
    trunk/blender/source/blender/blenkernel/intern/displist.c
    trunk/blender/source/blender/blenkernel/intern/effect.c
    trunk/blender/source/blender/blenkernel/intern/font.c
    trunk/blender/source/blender/blenkernel/intern/lattice.c
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/blenkernel/intern/particle_system.c
    trunk/blender/source/blender/blenkernel/intern/pointcache.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/makesdna/DNA_curve_types.h
    trunk/blender/source/blender/makesdna/DNA_object_force.h
    trunk/blender/source/blender/makesrna/intern/rna_object_force.c

Modified: trunk/blender/release/scripts/ui/properties_physics_field.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_physics_field.py	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/release/scripts/ui/properties_physics_field.py	2010-04-21 11:59:47 UTC (rev 28323)
@@ -72,6 +72,7 @@
             col.prop(field, "guide_free")
             col.prop(field, "falloff_power")
             col.prop(field, "guide_path_add")
+            col.prop(field, "use_guide_path_weight")
 
             if wide_ui:
                 col = split.column()

Modified: trunk/blender/source/blender/blenkernel/BKE_anim.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_anim.h	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/source/blender/blenkernel/BKE_anim.h	2010-04-21 11:59:47 UTC (rev 28323)
@@ -63,7 +63,7 @@
 void free_path(struct Path *path);
 void calc_curvepath(struct Object *ob);
 int interval_test(int min, int max, int p1, int cycl);
-int where_on_path(struct Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius);
+int where_on_path(struct Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius, float *weight);
 
 /* ---------------------------------------------------- */
 /* Dupli-Geometry */

Modified: trunk/blender/source/blender/blenkernel/BKE_curve.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_curve.h	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/source/blender/blenkernel/BKE_curve.h	2010-04-21 11:59:47 UTC (rev 28323)
@@ -72,7 +72,7 @@
 void makeknots( struct Nurb *nu, short uv);
 
 void makeNurbfaces(struct Nurb *nu, float *coord_array, int rowstride);
-void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu, int stride);
+void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride);
 void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
 float *make_orco_curve(struct Scene *scene, struct Object *ob);
 float *make_orco_surf( struct Object *ob);

Modified: trunk/blender/source/blender/blenkernel/intern/anim.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim.c	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/source/blender/blenkernel/intern/anim.c	2010-04-21 11:59:47 UTC (rev 28323)
@@ -460,6 +460,7 @@
 		interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
 		pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa;
 		pp->radius= fac1*bevp->radius + fac2*bevpn->radius;
+		pp->weight= fac1*bevp->weight + fac2*bevpn->weight;
 		interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2);
 		normalize_qt(pp->quat);
 		
@@ -491,7 +492,7 @@
  * 	- *vec needs FOUR items!
  *	- ctime is normalized range <0-1>
  */
-int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius)	/* returns OK */
+int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius, float *weight)	/* returns OK */
 {
 	Curve *cu;
 	Nurb *nu;
@@ -587,6 +588,9 @@
 	if(radius)
 		*radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius;
 
+	if(weight)
+		*weight= data[0]*p0->weight + data[1]*p1->weight + data[2]*p2->weight + data[3]*p3->weight;
+
 	return 1;
 }
 

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2010-04-21 11:59:47 UTC (rev 28323)
@@ -1941,7 +1941,7 @@
 		}
 		
 		/* tail endpoint */
-		if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) {
+		if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad, NULL) ) {
 			/* apply curve's object-mode transforms to the position 
 			 * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root)
 			 */
@@ -1957,7 +1957,7 @@
 		}
 		
 		/* head endpoint */
-		if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) {
+		if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad, NULL) ) {
 			/* apply curve's object-mode transforms to the position 
 			 * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root)
 			 */

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-04-21 11:59:47 UTC (rev 28323)
@@ -1242,7 +1242,7 @@
 				curvetime= data->offset_fac;
 			}
 			
-			if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) {
+			if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius, NULL) ) {
 				if (data->followflag & FOLLOWPATH_FOLLOW) {
 					vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag);
 					
@@ -3261,7 +3261,7 @@
 			}
 			
 			/* 3. position on curve */
-			if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL) ) {
+			if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL, NULL) ) {
 				unit_m4(totmat);
 				VECCOPY(totmat[3], vec);
 				

Modified: trunk/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/curve.c	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/source/blender/blenkernel/intern/curve.c	2010-04-21 11:59:47 UTC (rev 28323)
@@ -887,14 +887,14 @@
 	MEM_freeN(jend);
 }
 
-void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu, int stride)
+void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
 /* coord_array has to be 3*4*pntsu*resolu in size and zero-ed
  * tilt_array and radius_array will be written to if valid */
 {
 	BPoint *bp;
 	float u, ustart, uend, ustep, sumdiv;
 	float *basisu, *sum, *fp;
-	float *coord_fp= coord_array, *tilt_fp= tilt_array, *radius_fp= radius_array;
+	float *coord_fp= coord_array, *tilt_fp= tilt_array, *radius_fp= radius_array, *weight_fp= weight_array;
 	int i, len, istart, iend, cycl;
 
 	if(nu->knotsu==NULL) return;
@@ -967,6 +967,9 @@
 				
 				if (radius_fp)
 					(*radius_fp) += (*fp) * bp->radius;
+
+				if (weight_fp)
+					(*weight_fp) += (*fp) * bp->weight;
 				
 			}
 		}
@@ -975,6 +978,7 @@
 		
 		if (tilt_fp)	tilt_fp = (float *)(((char *)tilt_fp) + stride);
 		if (radius_fp)	radius_fp = (float *)(((char *)radius_fp) + stride);
+		if (weight_fp)	weight_fp = (float *)(((char *)weight_fp) + stride);
 		
 		u+= ustep;
 	}
@@ -1538,7 +1542,7 @@
 
 }
 
-static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, int resolu, int stride)
+static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
 {
 	BezTriple *pprev, *next, *last;
 	float fac, dfac, t[4];
@@ -1595,6 +1599,13 @@
 			
 			radius_array = (float *)(((char *)radius_array) + stride); 
 		}
+
+		if(weight_array) {
+			/* basic interpolation for now, could copy tilt interp too  */
+			*weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
+
+			weight_array = (float *)(((char *)weight_array) + stride);
+		}
 	}
 }
 
@@ -1980,7 +1991,7 @@
 	float min, inp, x1, x2, y1, y2;
 	struct bevelsort *sortdata, *sd, *sd1;
 	int a, b, nr, poly, resolu = 0, len = 0;
-	int do_tilt, do_radius;
+	int do_tilt, do_radius, do_weight;
 	
 	/* this function needs an object, because of tflag and upflag */
 	cu= ob->data;
@@ -1999,6 +2010,7 @@
 		/* check if we will calculate tilt data */
 		do_tilt = CU_DO_TILT(cu, nu);
 		do_radius = CU_DO_RADIUS(cu, nu); /* normal display uses the radius, better just to calculate them */
+		do_weight = 1;
 		
 		/* check we are a single point? also check we are not a surface and that the orderu is sane,
 		 * enforced in the UI but can go wrong possibly */
@@ -2028,6 +2040,7 @@
 					VECCOPY(bevp->vec, bp->vec);
 					bevp->alfa= bp->alfa;
 					bevp->radius= bp->radius;
+					bevp->weight= bp->weight;
 					bevp->split_tag= TRUE;
 					bevp++;
 					bp++;
@@ -2060,6 +2073,7 @@
 						VECCOPY(bevp->vec, prevbezt->vec[1]);
 						bevp->alfa= prevbezt->alfa;
 						bevp->radius= prevbezt->radius;
+						bevp->weight= prevbezt->weight;
 						bevp->split_tag= TRUE;
 						bevp->dupe_tag= FALSE;
 						bevp++;
@@ -2081,6 +2095,7 @@
 						alfa_bezpart(	prevbezt, bezt, nu,
 										 do_tilt	? &bevp->alfa : NULL,
 										 do_radius	? &bevp->radius : NULL,
+										 do_weight	? &bevp->weight : NULL,
 										 resolu, sizeof(BevPoint));
 
 						
@@ -2110,6 +2125,7 @@
 					VECCOPY(bevp->vec, prevbezt->vec[1]);
 					bevp->alfa= prevbezt->alfa;
 					bevp->radius= prevbezt->radius;
+					bevp->weight= prevbezt->weight;
 					bl->nr++;
 				}
 			}
@@ -2128,6 +2144,7 @@
 					makeNurbcurve(	nu, &bevp->vec[0],
 									do_tilt		? &bevp->alfa : NULL,
 									do_radius	? &bevp->radius : NULL,
+									do_weight	? &bevp->weight : NULL,
 									resolu, sizeof(BevPoint));
 				}
 			}

Modified: trunk/blender/source/blender/blenkernel/intern/displist.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/displist.c	2010-04-21 09:45:11 UTC (rev 28322)
+++ trunk/blender/source/blender/blenkernel/intern/displist.c	2010-04-21 11:59:47 UTC (rev 28323)
@@ -895,7 +895,7 @@
 				data= dl->verts;
 				if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
 				else dl->type= DL_SEGM;
-				makeNurbcurve(nu, data, NULL, NULL, resolu, 3*sizeof(float));
+				makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
 			}
 			else if(nu->type == CU_POLY) {
 				len= nu->pntsu;
@@ -1598,7 +1598,7 @@
 				if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
 				else dl->type= DL_SEGM;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list