[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23152] trunk/blender: Use curve radius for paths
Campbell Barton
ideasman42 at gmail.com
Sat Sep 12 18:25:50 CEST 2009
Revision: 23152
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23152
Author: campbellbarton
Date: 2009-09-12 18:25:49 +0200 (Sat, 12 Sep 2009)
Log Message:
-----------
Use curve radius for paths
- use_radius option, off by default for 2.4x files, on by default on new curves.
- curve deform modifiers (think tentacles)
- follow path (parent mode and constraint)
- curve guides
- added back Alt+S to scale point radius
- Mat3Scale and Mat4Scale arithb.c functions to make a new uniform scale matrix.
- TODO, effectors, looks like they have no way to scale from the radius yet.
Modified Paths:
--------------
trunk/blender/release/ui/buttons_data_curve.py
trunk/blender/release/ui/buttons_object_constraint.py
trunk/blender/source/blender/blenkernel/intern/constraint.c
trunk/blender/source/blender/blenkernel/intern/curve.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/blenlib/BLI_arithb.h
trunk/blender/source/blender/blenlib/intern/arithb.c
trunk/blender/source/blender/editors/curve/curve_ops.c
trunk/blender/source/blender/makesdna/DNA_constraint_types.h
trunk/blender/source/blender/makesdna/DNA_curve_types.h
trunk/blender/source/blender/makesrna/intern/rna_constraint.c
trunk/blender/source/blender/makesrna/intern/rna_curve.c
Modified: trunk/blender/release/ui/buttons_data_curve.py
===================================================================
--- trunk/blender/release/ui/buttons_data_curve.py 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/release/ui/buttons_data_curve.py 2009-09-12 16:25:49 UTC (rev 23152)
@@ -142,6 +142,7 @@
col = split.column()
col.itemR(curve, "use_stretch")
+ col.itemR(curve, "use_radius")
col.itemR(curve, "use_time_offset", text="Offset Children")
class DATA_PT_active_spline(DataButtonsPanelActive):
Modified: trunk/blender/release/ui/buttons_object_constraint.py
===================================================================
--- trunk/blender/release/ui/buttons_object_constraint.py 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/release/ui/buttons_object_constraint.py 2009-09-12 16:25:49 UTC (rev 23152)
@@ -124,11 +124,12 @@
split = layout.split()
col = split.column()
- col.itemR(con, "curve_follow")
+ col.itemR(con, "use_curve_follow")
+ col.itemR(con, "use_curve_radius")
col = split.column()
- col.itemR(con, "fixed_position")
- if con.fixed_position:
+ col.itemR(con, "use_fixed_position")
+ if con.use_fixed_position:
col.itemR(con, "offset_percentage", text="Offset")
else:
col.itemR(con, "offset")
Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c 2009-09-12 16:25:49 UTC (rev 23152)
@@ -1162,7 +1162,7 @@
if (VALID_CONS_TARGET(ct)) {
Curve *cu= ct->tar->data;
- float q[4], vec[4], dir[3], quat[4], x1;
+ float q[4], vec[4], dir[3], quat[4], radius, x1;
float totmat[4][4];
float curvetime;
@@ -1196,7 +1196,7 @@
curvetime= data->offset; // XXX might need a more sensible value
}
- if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL) ) {
+ if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) {
if (data->followflag & FOLLOWPATH_FOLLOW) {
vectoquat(dir, (short) data->trackflag, (short) data->upflag, quat);
@@ -1210,6 +1210,14 @@
QuatToMat4(quat, totmat);
}
+
+ if (data->followflag & FOLLOWPATH_RADIUS) {
+ float tmat[4][4], rmat[4][4];
+ Mat4Scale(tmat, radius);
+ Mat4MulMat4(rmat, totmat, tmat);
+ Mat4CpyMat4(totmat, rmat);
+ }
+
VECCOPY(totmat[3], vec);
Mat4MulSerie(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL);
@@ -1227,7 +1235,8 @@
/* only evaluate if there is a target */
if (VALID_CONS_TARGET(ct)) {
float obmat[4][4];
- float size[3], obsize[3];
+ float size[3];
+ bFollowPathConstraint *data= con->data;
/* get Object local transform (loc/rot/size) to determine transformation from path */
//object_to_mat4(ob, obmat);
@@ -1240,13 +1249,17 @@
Mat4MulSerie(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL);
/* un-apply scaling caused by path */
- Mat4ToSize(cob->matrix, obsize);
- if (obsize[0])
- VecMulf(cob->matrix[0], size[0] / obsize[0]);
- if (obsize[1])
- VecMulf(cob->matrix[1], size[1] / obsize[1]);
- if (obsize[2])
- VecMulf(cob->matrix[2], size[2] / obsize[2]);
+ if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */
+ float obsize[3];
+
+ Mat4ToSize(cob->matrix, obsize);
+ if (obsize[0])
+ VecMulf(cob->matrix[0], size[0] / obsize[0]);
+ if (obsize[1])
+ VecMulf(cob->matrix[1], size[1] / obsize[1]);
+ if (obsize[2])
+ VecMulf(cob->matrix[2], size[2] / obsize[2]);
+ }
}
}
Modified: trunk/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/curve.c 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenkernel/intern/curve.c 2009-09-12 16:25:49 UTC (rev 23152)
@@ -136,7 +136,7 @@
cu= alloc_libblock(&G.main->curve, ID_CU, name);
cu->size[0]= cu->size[1]= cu->size[2]= 1.0;
- cu->flag= CU_FRONT+CU_BACK;
+ cu->flag= CU_FRONT|CU_BACK|CU_PATH_RADIUS;
cu->pathlen= 100;
cu->resolu= cu->resolv= 12;
cu->width= 1.0;
Modified: trunk/blender/source/blender/blenkernel/intern/lattice.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/lattice.c 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenkernel/intern/lattice.c 2009-09-12 16:25:49 UTC (rev 23152)
@@ -524,7 +524,7 @@
static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, CurveDeform *cd, float *quatp)
{
Curve *cu= par->data;
- float fac, loc[4], dir[3], cent[3];
+ float fac, loc[4], dir[3], cent[3], radius;
short upflag, index;
if(axis==MOD_CURVE_POSX || axis==MOD_CURVE_NEGX) {
@@ -579,7 +579,7 @@
}
#endif // XXX old animation system
- if( where_on_path_deform(par, fac, loc, dir, NULL, NULL)) { /* returns OK */
+ if( where_on_path_deform(par, fac, loc, dir, NULL, &radius)) { /* returns OK */
float q[4], mat[3][3], quat[4];
if(cd->no_rot_axis) /* set by caller */
@@ -599,7 +599,14 @@
QuatMul(quat, q, quat);
}
QuatToMat3(quat, mat);
-
+
+ if(cu->flag & CU_PATH_RADIUS) {
+ float tmat[3][3], rmat[3][3];
+ Mat3Scale(tmat, radius);
+ Mat3MulMat3(rmat, mat, tmat);
+ Mat3CpyMat3(mat, rmat);
+ }
+
/* local rotation */
Mat3MulVecfl(mat, cent);
Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenkernel/intern/object.c 2009-09-12 16:25:49 UTC (rev 23152)
@@ -1646,7 +1646,7 @@
static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
{
Curve *cu;
- float q[4], vec[4], dir[3], quat[4], x1, ctime;
+ float q[4], vec[4], dir[3], quat[4], radius, x1, ctime;
float timeoffs = 0.0, sf_orig = 0.0;
Mat4One(mat);
@@ -1694,7 +1694,7 @@
/* vec: 4 items! */
- if( where_on_path(par, ctime, vec, dir, NULL, NULL) ) {
+ if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) {
if(cu->flag & CU_FOLLOW) {
vectoquat(dir, ob->trackflag, ob->upflag, quat);
@@ -1711,6 +1711,13 @@
QuatToMat4(quat, mat);
}
+ if(cu->flag & CU_PATH_RADIUS) {
+ float tmat[4][4], rmat[4][4];
+ Mat4Scale(tmat, radius);
+ Mat4MulMat4(rmat, mat, tmat);
+ Mat4CpyMat4(mat, rmat);
+ }
+
VECCOPY(mat[3], vec);
}
Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c 2009-09-12 16:25:49 UTC (rev 23152)
@@ -1932,7 +1932,7 @@
ParticleKey key, par;
float effect[3]={0.0,0.0,0.0}, distance, f_force, mindist, totforce=0.0;
- float guidevec[4], guidedir[3], rot2[4], temp[3], angle, pa_loc[3], pa_zero[3]={0.0f,0.0f,0.0f};
+ float guidevec[4], guidedir[3], rot2[4], radius, temp[3], angle, pa_loc[3], pa_zero[3]={0.0f,0.0f,0.0f};
float veffect[3]={0.0,0.0,0.0}, guidetime;
effect[0]=effect[1]=effect[2]=0.0;
@@ -1975,9 +1975,9 @@
}
if(pd->flag & PFIELD_GUIDE_PATH_ADD)
- where_on_path(eob, f_force*guidetime, guidevec, guidedir, NULL, NULL);
+ where_on_path(eob, f_force*guidetime, guidevec, guidedir, NULL, &radius);
else
- where_on_path(eob, guidetime, guidevec, guidedir, NULL, NULL);
+ where_on_path(eob, guidetime, guidevec, guidedir, NULL, &radius);
Mat4MulVecfl(ec->ob->obmat,guidevec);
Mat4Mul3Vecfl(ec->ob->obmat,guidedir);
@@ -2007,10 +2007,12 @@
/* curve taper */
if(cu->taperobj)
VecMulf(pa_loc, calc_taper(scene, cu->taperobj, (int)(f_force*guidetime*100.0), 100));
- /* TODO */
- //else{
- ///* curve size*/
- //}
+
+ else{ /* curve size*/
+ if(cu->flag & CU_PATH_RADIUS) {
+ VecMulf(pa_loc, radius);
+ }
+ }
par.co[0]=par.co[1]=par.co[2]=0.0f;
VECCOPY(key.co,pa_loc);
do_prekink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, pd->kink, pd->kink_axis, 0);
Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c 2009-09-12 16:25:49 UTC (rev 23152)
@@ -2526,7 +2526,7 @@
ParticleSettings *part=psys->part;
PARTICLE_P;
int totpart;
- float vec2[3],loc[3],*co=0;
+ float vec2[3],loc[3],radius,*co=0;
for(ec= lb->first; ec; ec= ec->next) {
PartDeflect *pd= ec->ob->pd;
@@ -2536,7 +2536,7 @@
&& part->phystype!=PART_PHYS_BOIDS) {
float vec[4];
- where_on_path(ec->ob, 0.0, vec, vec2, NULL, NULL);
+ where_on_path(ec->ob, 0.0, vec, vec2, NULL, &radius);
Mat4MulVecfl(ec->ob->obmat,vec);
Mat4Mul3Vecfl(ec->ob->obmat,vec2);
@@ -2544,6 +2544,8 @@
QUATCOPY(ec->firstloc,vec);
VECCOPY(ec->firstdir,vec2);
+ /* TODO - use 'radius' to adjust the effector */
+
totpart=psys->totpart;
if(totpart){
Modified: trunk/blender/source/blender/blenlib/BLI_arithb.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_arithb.h 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenlib/BLI_arithb.h 2009-09-12 16:25:49 UTC (rev 23152)
@@ -320,6 +320,9 @@
void Mat3One(float m[][3]);
void Mat4One(float m[][4]);
+void Mat3Scale(float m[][3], float scale);
+void Mat4Scale(float m[][4], float scale);
+
void Mat3Ortho(float mat[][3]);
void Mat4Ortho(float mat[][4]);
Modified: trunk/blender/source/blender/blenlib/intern/arithb.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/arithb.c 2009-09-12 14:12:37 UTC (rev 23151)
+++ trunk/blender/source/blender/blenlib/intern/arithb.c 2009-09-12 16:25:49 UTC (rev 23152)
@@ -854,6 +854,26 @@
m[2][0]= m[2][1]= 0.0;
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list