[tuhopuu-devel] updated particle experiments patch - gravity and other mods
Leon Turner
tuhopuu-devel@blender.org
Sun, 22 Feb 2004 09:04:38 +0000 (GMT)
--0-1439739806-1077440678=:9785
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Id:
Content-Disposition: inline
hi all,
here's the patch file for the latest changes to the
code (it's also at
http://reblended.com/www/leon/p_patch.txt for those
who have problems with included text files).
It's based on a CVS checkout from this morning, so
there shouldn't be any problems importing.
The changes are (from the first patch):
- Now uses arith.c functions rather than MTC_vector
- A new function for calculating whether a point is in
a triangle (which gives better results for small
deflectors).
- Two extra sliders for particle deflection: "Random
damping" and "Permeability". Random damping adds a
random element to the damping factor, permeability
controls the percentage of particles which pass
through the mesh without deflection.
- Gravity. A mesh can have gravity switched on in the
particle interaction panel, and it's vertices will
then attract or repel particles. Generally best to use
very small numbers of vertices (i.e. 1 or 2!!!). The
two sliders are strength and fall-off. Fall-off
controls how quickly the gravity effect falls off with
distance from the vertex (use 2 for "real" gravity).
- I've upped the maximum number of particle keys to
100, which gives much nicer results for longer
particle lifes.
- The calculation of particles can now take a while,
so I've added an output to the console (counts every
1000 particles).
As always, just let me know any changes I need to
make!
Cheers
Leon
___________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
--0-1439739806-1077440678=:9785
Content-Type: text/plain; name="p_patch.txt"
Content-Description: p_patch.txt
Content-Disposition: inline; filename="p_patch.txt"
? obj
? user-def.mk
Index: source/blender/blenkernel/intern/effect.c
===================================================================
RCS file: /cvsroot/tuhopuu/tuhopuu2/source/blender/blenkernel/intern/effect.c,v
retrieving revision 1.6
diff -r1.6 effect.c
372,406c372,391
< /* This function checks whether a point (p) is within a triangle formed by */
< /* three other points (v1, v2, v3. */
< /* It does this by checking the area of the total triangle compared to the areas of */
< /* the three triangles formed by the point and the three points */
< /* It assumes the points are all in the same plane, it doesn't check this */
< /* I'm sure this isn't a very good method, but it just about works!!! */
< /* Check whether the result is below is below a very small */
< /* number to see if the point is inside, since it won't ever be zero */
< float total_area;
< float a1,a2,a3;
< float vect1[3], vect2[3], wvect[3];
< float result;
< /*First total area, between v1 and v2 will do*/
< VecSubf(vect1, v1,v2);
< VecSubf(vect2, v2,v3);
< Crossf(wvect,vect1,vect2);
< total_area = mag_vect(wvect) / 2;
< /*Now area 1 - p/v1, p/v2*/
< VecSubf(vect1,p,v1);
< VecSubf(vect2,p,v2);
< Crossf(wvect,vect1,vect2);
< a1 = mag_vect(wvect) / 2;
< /*Now area 2 - p/v2, p/v3*/
< VecSubf(vect1,p,v2);
< VecSubf(vect2,p,v3);
< Crossf(wvect,vect1,vect2);
< a2 = mag_vect(wvect) / 2;
< /*Now area 2 - p/v3, p/v1*/
< VecSubf(vect1,p,v3);
< VecSubf(vect2,p,v1);
< Crossf(wvect,vect1,vect2);
< a3 = mag_vect(wvect) / 2;
< result = total_area - a1 - a2 - a3;
< result = abs(result);
< return result;
---
> /* A check for points in triangles */
> float vect1[3], vect2[3], vect3[3];
> float angle_result;
> /*first form the three vectors to the central point*/
> VecSubf(vect1,p,v1);
> VecSubf(vect2,p,v2);
> VecSubf(vect3,p,v3);
> /*Now normalise */
> Normalise(vect1);
> Normalise(vect2);
> Normalise(vect3);
> /*Now calculate the total angles */
> angle_result = 0;
> angle_result = acos(Inpf(vect1,vect2));
> angle_result += acos(Inpf(vect2,vect3));
> angle_result += acos(Inpf(vect3,vect1));
> /*Finish the maths.... */
> angle_result = fabs(angle_result - 6.283185308);
> /* And return the result */
> return angle_result;
408a394,445
> void get_gravity(float opco[3], float force[3])
> {
> float vect_to_vert[3];
> float vert[3];
> float g_force, distance;
> float mat[3][3];
> int a;
> Mesh *def_mesh;
> MVert *g_vert;
> Main *mn;
> Object *myobject;
> /* Gravity code */
> /* Work out gravity according to distance from vertices */
> /* of objects with gravity settings */
> /* Add "force" to gravity and recalculate new positions */
>
> /* Initial settings */
> mn= G.main;
> myobject = mn->object.first;
>
> /* Cycle through objects, get total of (1/(gravity_strength * dist^gravity_power)) */
> /* Check for min distance here? */
> while (myobject) {
> def_mesh = get_mesh(myobject);
> object_to_mat3(myobject, mat);
> if (def_mesh!=0) {
> if (def_mesh->gravity_on) {
> g_vert = def_mesh->mvert;
> a = def_mesh->totvert;
> while (a--) {
> /* Calculate additional force */
> VECCOPY (vert, g_vert->co);
> /* Apply the objects deformation matrix to get */
> /* the correct vertex positions */
> Mat3MulVecfl(mat, vert);
> VecAddf(vert, vert, myobject->loc);
> /* Now calculate the gravitational force */
> VecSubf(vect_to_vert,vert,opco);
> distance = Normalise(vect_to_vert);
> if (distance < 0.001) {
> distance = 0.001;
> }
> g_force = (def_mesh->g_strength)*(1/(1000 * powf(distance, def_mesh->g_power)));
> force[0] += (vect_to_vert[0] * g_force );
> force[1] += (vect_to_vert[1] * g_force );
> force[2] += (vect_to_vert[2] * g_force );
> g_vert++;
> }
> }
> }
> myobject = myobject->id.next;
> }
410c447,449
< void make_particle_keys(int depth, int nr, PartEff *paf, Particle *part, float *force, int deform, MTex *mtex)
---
> }
>
> int get_deflection(float opco[3], float npco[3], float opno[3], float npno[3], float life, float force[3], int def_depth)
412,413d450
< Particle *pa, *opa = NULL;
< float damp, deltalife;
416c453,455
< float nvect[3], vect_to_int[3], intersect_co[3], refl_vel[3];
---
> float nvect[3], vect_to_int[3], intersect_co[3], refl_vel[3], rand_vel[3];
> float d_intersect_co[3], d_intersect_vect[3], d_nvect[3], d_i_co_above[3];
> float i_co_above[3];
418c457,459
< float icalctop, icalcbot, int_u;
---
> float first_dist;
> float dk_plane, dk_point1;
> float icalctop, icalcbot, int_u, n_mag;
420c461,463
< int a, b, rt1, rt2, deflected;
---
> float damping, perm_thresh;
> int a, deflected, deflected_now;
> int srch_up;
426,444c469
< Object *myobject;
<
< damp= 1.0f-paf->damp;
< pa= part;
<
< /* start speed: random */
< if(paf->randfac!=0.0) {
< pa->no[0]+= (float)(paf->randfac*( BLI_drand() -0.5));
< pa->no[1]+= (float)(paf->randfac*( BLI_drand() -0.5));
< pa->no[2]+= (float)(paf->randfac*( BLI_drand() -0.5));
< }
<
< /* start speed: texture */
< if(mtex && paf->texfac!=0.0) {
< particle_tex(mtex, paf, pa->co, pa->no);
< }
<
< if(paf->totkey>1) deltalife= pa->lifetime/(paf->totkey-1);
< else deltalife= pa->lifetime;
---
> Object *myobject, *deflection_object;
446,452d470
< opa= pa;
< pa++;
<
< b= paf->totkey-1;
< while(b--) {
< /* new time */
< pa->time= opa->time+deltalife;
454,457c472,571
< /* new location */
< pa->co[0]= opa->co[0] + deltalife*opa->no[0];
< pa->co[1]= opa->co[1] + deltalife*opa->no[1];
< pa->co[2]= opa->co[2] + deltalife*opa->no[2];
---
> /* Particle deflection code */
> /* Code is in two parts - first establish if a collision */
> /* has taken place, second work out the new co-ordinates */
> /* and speed of the particle*/
> /* This has the limitation you can only have one collision */
> /* per particle per key frame - so you do get "leaks" at */
> /* joints between deflecting meshes*/
> /* First part: loop through all meshes, and all faces of meshes*/
> mn= G.main;
> /* Cycle through the objects in different orders depending on the */
> /* depth we are currently at. This makes it harder for particle to "leak" */
> /* where objects overlap*/
> srch_up = (def_depth % 2);
> if (srch_up) {
> myobject = mn->object.first;
> }
> else {
> myobject = mn->object.last;
> }
> deflected = 0;
> deflected_now = 0;
> first_dist = 200000;
>
> while (myobject) {
> def_mesh = get_mesh(myobject);
> /* Don't go any further if we've already got a collision */
> if (def_mesh!=0) {
> if(def_mesh->pdeflect) {
> mface= def_mesh->mface;
> a = def_mesh->totface;
> object_to_mat3(myobject, mat);
> while (a--) {
>
> /* Calculate the global co-ordinates of the vertices*/
> v1= (def_mesh->mvert+(mface->v1))->co;
> v2= (def_mesh->mvert+(mface->v2))->co;
> v3= (def_mesh->mvert+(mface->v3))->co;
> v4= (def_mesh->mvert+(mface->v4))->co;
>
> VECCOPY(nv1, v1);
> VECCOPY(nv2, v2);
> VECCOPY(nv3, v3);
> VECCOPY(nv4, v4);
>
> /*Apply the objects deformation matrix*/
> Mat3MulVecfl(mat, nv1);
> Mat3MulVecfl(mat, nv2);
> Mat3MulVecfl(mat, nv3);
> Mat3MulVecfl(mat, nv4);
>
> VecAddf(nv1, nv1, myobject->loc);
> VecAddf(nv2, nv2, myobject->loc);
> VecAddf(nv3, nv3, myobject->loc);
> VecAddf(nv4, nv4, myobject->loc);
>
> /* Now calculate the normal vector of the face */
> /* Just use the first three points */
> /* First the edges */
> VecSubf(edge1, nv1, nv2);
> VecSubf(edge2, nv3, nv2);
>
> /*Now cross product and normalise*/
> Crossf(nvect, edge1, edge2);
> n_mag = Normalise(nvect);
>
> /* Now calculate K */
> k_plane = Inpf(nvect, nv1);
> k_point1 = Inpf(nvect,opco);
> k_point2 = Inpf(nvect,npco);
>
> deflected_now = 0;
>
> /* If the old co-ordinates and new co-ordinates were the same side of */
> /* the plane, we don't need to go any further, since no collision is possible */
> if (((k_plane > k_point1) && (k_plane < k_point2))||((k_plane < k_point1) && (k_plane > k_point2))) {
>
> /* Now check if the intersection point lies within */
> /* any of the triangles of the face */
> /* So first get the intersection point */
> icalctop = (k_plane - (Inpf(npco,nvect)));
> VecSubf(intersect_vect, npco, opco);
> icalcbot = (Inpf(intersect_vect,nvect));
> int_u = icalctop / icalcbot;
> intersect_co[0] = (npco[0] + (int_u * intersect_vect[0]));
> intersect_co[1] = (npco[1] + (int_u * intersect_vect[1]));
> intersect_co[2] = (npco[2] + (int_u * intersect_vect[2]));
> /* Work out a point just before the intersection */
>
> i_co_above[0] = (npco[0] + (int_u * 1.0001 * intersect_vect[0]));
> i_co_above[1] = (npco[1] + (int_u * 1.0001 * intersect_vect[1]));
> i_co_above[2] = (npco[2] + (int_u * 1.0001 * intersect_vect[2]));
>
>
> /* Now check if intersection point is inside first three vertices */
> pintri = pointintriangle(intersect_co, nv1, nv2, nv3);
> if (pintri < 0.001) {
> deflected = 1;
> deflected_now = 1;
> }
> else {
459,542c573,578
< /* new speed */
< pa->no[0]= opa->no[0] + deltalife*force[0];
< pa->no[1]= opa->no[1] + deltalife*force[1];
< pa->no[2]= opa->no[2] + deltalife*force[2];
<
< /* Particle deflection code */
< /* Code is in two parts - first establish if a collision */
< /* has taken place, second work out the new co-ordinates */
< /* and speed of the particle*/
< /* This has the limitation you can only have one collision */
< /* per particle per key frame - so you do get "leaks" at */
< /* joints between deflecting meshes*/
< /* First part: loop through all meshes, and all faces of meshes*/
< mn= G.main;
< myobject = mn->object.first;
< deflected = 0;
< while (myobject) {
< def_mesh = get_mesh(myobject);
< /* Don't go any further if we've already got a collision */
< if (def_mesh!=0) {
< if(def_mesh->pdeflect && (deflected == 0)) {
< mface= def_mesh->mface;
< a = def_mesh->totface;
< object_to_mat3(myobject, mat);
< while (a--) {
< if (deflected == 0) {
<
< /* Calculate the global co-ordinates of the vertices*/
< v1= (def_mesh->mvert+(mface->v1))->co;
< v2= (def_mesh->mvert+(mface->v2))->co;
< v3= (def_mesh->mvert+(mface->v3))->co;
< v4= (def_mesh->mvert+(mface->v4))->co;
<
< VECCOPY(nv1, v1);
< VECCOPY(nv2, v2);
< VECCOPY(nv3, v3);
< VECCOPY(nv4, v4);
<
< /*Apply the objects deformation matrix*/
< Mat3MulVecfl(mat, nv1);
< Mat3MulVecfl(mat, nv2);
< Mat3MulVecfl(mat, nv3);
< Mat3MulVecfl(mat, nv4);
<
< VecAddf(nv1, nv1, myobject->loc);
< VecAddf(nv2, nv2, myobject->loc);
< VecAddf(nv3, nv3, myobject->loc);
< VecAddf(nv4, nv4, myobject->loc);
<
< /* Now calculate the normal vector of the face */
< /* Just use the first three points */
< /* First the edges */
< VecSubf(edge1, nv1, nv2);
< VecSubf(edge2, nv3, nv2);
<
< /*Now cross product and normalise*/
< Crossf(nvect, edge1, edge2);
< Normalise(nvect);
<
< /* Now calculate K */
< k_plane = Inpf(nvect, nv1);
< k_point1 = Inpf(nvect,pa->co);
< k_point2 = Inpf(nvect,opa->co);
<
< /* If the old co-ordinates and new co-ordinates were the same side of */
< /* the plane, we don't need to go any further, since no collision is possible */
< if (((k_plane > k_point1) && (k_plane < k_point2))||((k_plane < k_point1) && (k_plane > k_point2))) {
<
< /* Now check if the intersection point lies within */
< /* any of the triangles of the face */
< /* So first get the intersection point */
< icalctop = (k_plane - (Inpf(pa->co,nvect)));
< VecSubf(intersect_vect, pa->co, opa->co);
< icalcbot = (Inpf(intersect_vect,nvect));
< int_u = icalctop / icalcbot;
< intersect_co[0] = (pa->co[0] + (int_u * intersect_vect[0]));
< intersect_co[1] = (pa->co[1] + (int_u * intersect_vect[1]));
< intersect_co[2] = (pa->co[2] + (int_u * intersect_vect[2]));
<
< /* Now check if intersection point is inside first three vertices */
< pintri = pointintriangle(intersect_co, nv1, nv2, nv3);
< if (pintri < 0.00000001) {
< deflected = 1;
< deflection_mesh = def_mesh;
---
> /* Only check the other triangle if the face has 4 vertices */
> if (mface->v4) {
> pintri = pointintriangle(intersect_co, nv1, nv3, nv4);
> if (pintri < 0.001) {
> deflected = 1;
> deflected_now = 1;
544,553d579
< else {
<
< /* Only check the other triangle if the face has 4 vertices */
< if (mface->v4) {
< pintri = pointintriangle(intersect_co, nv1, nv3, nv4);
< if (pintri < 0.00000001) {
< deflected = 1;
< deflection_mesh = def_mesh;
< }
< }
554a581,601
> }
> /*If we had a deflection, check whether the deflection */
> /*earlier than a previous deflection*/
> /*So check the magnitude of the distance vector between */
> /*opco and intersect_co */
> if (deflected_now) {
> /*if it did occur earlier, store the following for later use */
> VecSubf(vect_to_int, opco, intersect_co);
> mag_intersect = Normalise(vect_to_int);
> if (mag_intersect < first_dist) {
> VECCOPY(d_intersect_co,intersect_co);
> VECCOPY(d_intersect_vect,intersect_vect);
> VECCOPY(d_nvect,nvect);
> VECCOPY(d_i_co_above,i_co_above);
> dk_plane = k_plane;
> dk_point1 = k_point1;
> deflection_mesh = def_mesh;
> deflection_object = myobject;
> first_dist = mag_intersect;
> }
> }
556d602
< }
561c607,613
< myobject = myobject->id.next;
---
> if (srch_up) {
> myobject = myobject->id.next;
> }
> else {
> myobject = myobject->id.prev;
> }
>
562a615,623
> /*Here's the point to do the permeability calculation */
> /*Set deflected to 0 if a random number is below the value */
> if (deflected) {
> perm_thresh = BLI_drand() - deflection_mesh->pdef_perm;
> if (perm_thresh < 0 ) {
> deflected = 0;
> }
> }
>
568,573c629,630
< mag_iv = Normalise(intersect_vect);
< VecSubf(vect_to_int, opa->co, intersect_co);
< mag_intersect = Normalise(vect_to_int);
< pa->co[0] = intersect_co[0];
< pa->co[1] = intersect_co[1];
< pa->co[2] = intersect_co[2];
---
> mag_iv = Normalise(d_intersect_vect);
> VECCOPY(npco, d_intersect_co);
576,577c633,634
< time_before = (deltalife*(mag_intersect / (mag_iv)));
< time_after = (deltalife*((mag_iv - mag_intersect) / (mag_iv)));
---
> time_before = (life*(mag_intersect / (mag_iv)));
> time_after = (life*((mag_iv - mag_intersect) / (mag_iv)));
581,583c638,640
< pa->no[0]= opa->no[0] + time_before*force[0];
< pa->no[1]= opa->no[1] + time_before*force[1];
< pa->no[2]= opa->no[2] + time_before*force[2];
---
> npno[0]= opno[0] + time_before*force[0];
> npno[1]= opno[1] + time_before*force[1];
> npno[2]= opno[2] + time_before*force[2];
586,591c643,652
< x_m = (2 * pa->no[0] * nvect[0]);
< y_m = (2 * pa->no[1] * nvect[1]);
< z_m = (2 * pa->no[2] * nvect[2]);
< refl_vel[0] = pa->no[0] - (nvect[0] * (x_m + y_m + z_m));
< refl_vel[1] = pa->no[1] - (nvect[1] * (x_m + y_m + z_m));
< refl_vel[2] = pa->no[2] - (nvect[2] * (x_m + y_m + z_m));
---
> x_m = (2 * npno[0] * d_nvect[0]);
> y_m = (2 * npno[1] * d_nvect[1]);
> z_m = (2 * npno[2] * d_nvect[2]);
> refl_vel[0] = npno[0] - (d_nvect[0] * (x_m + y_m + z_m));
> refl_vel[1] = npno[1] - (d_nvect[1] * (x_m + y_m + z_m));
> refl_vel[2] = npno[2] - (d_nvect[2] * (x_m + y_m + z_m));
>
> /*A random variation in the damping factor........ */
> damping = deflection_mesh->pdef_damp;
> damping = damping + ((1 - damping) * (BLI_drand()*deflection_mesh->pdef_rdamp));
595,597c656,662
< pa->no[0] = (refl_vel[0] * (1 + (nvect[0] * deflection_mesh->pdef_damp)));
< pa->no[1] = (refl_vel[1] * (1 + (nvect[1] * deflection_mesh->pdef_damp)));
< pa->no[2] = (refl_vel[2] * (1 + (nvect[2] * deflection_mesh->pdef_damp)));
---
> npno[0] = (refl_vel[0] * (1 + (d_nvect[0] * damping)));
> npno[1] = (refl_vel[1] * (1 + (d_nvect[1] * damping)));
> npno[2] = (refl_vel[2] * (1 + (d_nvect[2] * damping)));
>
>
> /* Now reset opno */
> VECCOPY(opno,npno);
601,603c666,668
< pa->no[0]= pa->no[0] + time_after*force[0];
< pa->no[1]= pa->no[1] + time_after*force[1];
< pa->no[2]= pa->no[2] + time_after*force[2];
---
> npno[0]= npno[0] + time_after*force[0];
> npno[1]= npno[1] + time_after*force[1];
> npno[2]= npno[2] + time_after*force[2];
607,609c672,680
< pa->co[0]= pa->co[0] + time_after*pa->no[0];
< pa->co[1]= pa->co[1] + time_after*pa->no[1];
< pa->co[2]= pa->co[2] + time_after*pa->no[2];
---
> npco[0]= npco[0] + time_after*npno[0];
> npco[1]= npco[1] + time_after*npno[1];
> npco[2]= npco[2] + time_after*npno[2];
>
> /* And set the old co-ordinates back to the point just above the intersection */
> VECCOPY(opco, d_i_co_above);
>
> /* Finally update the time */
> life = time_after;
614,631c685,796
< k_point3 = Inpf(nvect,pa->co);
< if (((k_plane > k_point3) && (k_plane < k_point2))||((k_plane < k_point3) && (k_plane > k_point2))) {
<
< /* Yup, the pesky particle may have fallen through a hole!!! */
< /* So we'll cheat a bit and move the particle along the normal vector */
< /* until it's just the other side of the plane */
< icalctop = (k_plane - nvect[0]*pa->co[0] - nvect[1]*pa->co[1] - nvect[2]*pa->co[2]);
< icalcbot = (nvect[0]*nvect[0] + nvect[1]*nvect[1] + nvect[2]*nvect[2]);
< dist_to_plane = icalctop / icalcbot;
<
< /* Now just increase the distance a little to place */
< /* the point the other side of the plane */
< dist_to_plane *= 1.001;
< pa->co[0]= pa->co[0] + (dist_to_plane * nvect[0]);
< pa->co[1]= pa->co[1] + (dist_to_plane * nvect[1]);
< pa->co[2]= pa->co[2] + (dist_to_plane * nvect[2]);
< /* And hope it works!!! */
< }
---
> /* But only do this as a last resort, if we've got to the end of the */
> /* number of collisions allowed */
> if (def_depth==2) {
> k_point3 = Inpf(d_nvect,npco);
> if (((dk_plane > k_point3) && (dk_plane < dk_point1))||((dk_plane < k_point3) && (dk_plane > dk_point1))) {
>
> /* Yup, the pesky particle may have fallen through a hole!!! */
> /* So we'll cheat a bit and move the particle along the normal vector */
> /* until it's just the other side of the plane */
> icalctop = (dk_plane - d_nvect[0]*npco[0] - d_nvect[1]*npco[1] - d_nvect[2]*npco[2]);
> icalcbot = (d_nvect[0]*d_nvect[0] + d_nvect[1]*d_nvect[1] + d_nvect[2]*d_nvect[2]);
> dist_to_plane = icalctop / icalcbot;
>
> /* Now just increase the distance a little to place */
> /* the point the other side of the plane */
> dist_to_plane *= 1.001;
> npco[0]= npco[0] + (dist_to_plane * d_nvect[0]);
> npco[1]= npco[1] + (dist_to_plane * d_nvect[1]);
> npco[2]= npco[2] + (dist_to_plane * d_nvect[2]);
> }
> }
> }
> return deflected;
> }
>
> void make_particle_keys(int depth, int nr, PartEff *paf, Particle *part, float *force, int deform, MTex *mtex)
> {
> Particle *pa, *opa = NULL;
> float damp, deltalife, life;
> float opco[3], opno[3], npco[3], npno[3], new_force[3];
> int b, rt1, rt2, deflected, deflection, finish_defs, def_count;
>
> damp= 1.0f-paf->damp;
> pa= part;
>
> /* start speed: random */
> if(paf->randfac!=0.0) {
> pa->no[0]+= (float)(paf->randfac*( BLI_drand() -0.5));
> pa->no[1]+= (float)(paf->randfac*( BLI_drand() -0.5));
> pa->no[2]+= (float)(paf->randfac*( BLI_drand() -0.5));
> }
>
> /* start speed: texture */
> if(mtex && paf->texfac!=0.0) {
> particle_tex(mtex, paf, pa->co, pa->no);
> }
>
> if(paf->totkey>1) deltalife= pa->lifetime/(paf->totkey-1);
> else deltalife= pa->lifetime;
>
> opa= pa;
> pa++;
>
> b= paf->totkey-1;
> while(b--) {
> /* new time */
> pa->time= opa->time+deltalife;
>
> /* set initial variables */
> opco[0] = opa->co[0];
> opco[1] = opa->co[1];
> opco[2] = opa->co[2];
>
> new_force[0] = force[0];
> new_force[1] = force[1];
> new_force[2] = force[2];
>
> /* Check gravity */
> get_gravity(opco, new_force);
>
> /* new location */
> pa->co[0]= opa->co[0] + deltalife*opa->no[0];
> pa->co[1]= opa->co[1] + deltalife*opa->no[1];
> pa->co[2]= opa->co[2] + deltalife*opa->no[2];
>
> /* new speed */
> pa->no[0]= opa->no[0] + deltalife*new_force[0];
> pa->no[1]= opa->no[1] + deltalife*new_force[1];
> pa->no[2]= opa->no[2] + deltalife*new_force[2];
>
> /* Particle deflection code */
> /* now loop until no deflection or limit reached */
> /* If a deflection has occurred, update pa-co and pa-no */
> deflection = 0;
> finish_defs = 1;
> def_count = 0;
>
> VECCOPY(opno, opa->no);
> VECCOPY(npco, pa->co);
> VECCOPY(npno, pa->no);
>
> life = deltalife;
>
> while (finish_defs) {
> deflected = get_deflection(opco, npco, opno, npno, life, new_force, def_count);
> if (deflected) {
> def_count = def_count + 1;
> deflection = 1;
> if (def_count==3) finish_defs = 0;
> }
> else {
> finish_defs = 0;
> }
> }
>
> if (deflection) {
> pa->co[0] = npco[0];
> pa->co[1] = npco[1];
> pa->co[2] = npco[2];
> pa->no[0] = npno[0];
> pa->no[1] = npno[1];
> pa->no[2] = npno[2];
683a849
>
814c980
< int deform=0, a, cur, cfraont, cfralast, totpart;
---
> int deform=0, a, b, cur, cfraont, cfralast, totpart;
898c1064,1067
<
---
>
> printf("\n");
> printf("Calculating particles......... \n");
>
903a1073,1077
> b=(a%1000);
> if (b==0) {
> printf("%d \n", a);
> }
>
977a1152,1153
> printf("Finished particle calculation \n");
>
Index: source/blender/include/butspace.h
===================================================================
RCS file: /cvsroot/tuhopuu/tuhopuu2/source/blender/include/butspace.h,v
retrieving revision 1.8
diff -r1.8 butspace.h
348a349,353
> #define B_GRAVITY 2087
> #define B_GRAVSTRENGTH 2088
> #define B_GRAVPOWER 2089
> #define B_PDEFRDAMP 2090
> #define B_PDEFPERM 2091
Index: source/blender/makesdna/DNA_mesh_types.h
===================================================================
RCS file: /cvsroot/tuhopuu/tuhopuu2/source/blender/makesdna/DNA_mesh_types.h,v
retrieving revision 1.9
diff -r1.9 DNA_mesh_types.h
138a139,144
> float pdef_rdamp; /* Random element of damping for deflection */
> float pdef_perm; /* Chance of particle passing through mesh */
>
> int gravity_on; /* Do the vertices attract / repel particles ? */
> float g_strength; /* The strength of the gravity (+ or - ) */
> float g_power; /* The power law - real gravity is 2 (square) */
151c157
< short reserved1; /* Padding */
---
> short reserved1, reserved2, reserved3; /* Padding */
Index: source/blender/src/buttons_editing.c
===================================================================
RCS file: /cvsroot/tuhopuu/tuhopuu2/source/blender/src/buttons_editing.c,v
retrieving revision 1.16
diff -r1.16 buttons_editing.c
1642a1643,1652
> case B_PDEFRDAMP:
> break;
> case B_PDEFPERM:
> break;
> case B_GRAVITY:
> break;
> case B_GRAVSTRENGTH:
> break;
> case B_GRAVPOWER:
> break;
1803c1813
< if(uiNewPanel(curarea, block, "Particle Interaction", "Editing", 640, 0, 174, 204)==0) return;
---
> if(uiNewPanel(curarea, block, "Particle Interaction", "Editing", 640, 0, 190, 204)==0) return;
1810,1811c1820,1826
< uiDefButI(block, TOG|BIT|0, B_ISDEFLECTOR, "Deflection", 143,40,140,20, &me->pdeflect, 0, 0, 0, 0, "Deflects particles");
< uiDefButF(block, NUM, B_PDEFDAMPING, "Surface damping", 143,15,140,20, &me->pdef_damp, 0, 1, 0, 0, "Amount of damping during particle collision");
---
> uiDefButI(block, TOG|BIT|0, B_ISDEFLECTOR, "Deflection", 143,130,150,20, &me->pdeflect, 0, 0, 0, 0, "Deflects particles");
> uiDefButF(block, NUM, B_PDEFDAMPING, "Surface damping", 143,110,150,20, &me->pdef_damp, 0, 1, 0, 0, "Amount of damping during particle collision");
> uiDefButF(block, NUM, B_PDEFRDAMP, "Random damping", 143,90,150,20, &me->pdef_rdamp, 0, 1, 0, 0, "Random variation of damping");
> uiDefButF(block, NUM, B_PDEFPERM, "Permeability", 143,70,150,20, &me->pdef_perm, 0, 1, 0, 0, "Chance that the particle will pass through the mesh");
> uiDefButI(block, TOG|BIT|0, B_GRAVITY, "Gravity", 143,40,150,20, &me->gravity_on, 0, 0, 0, 0, "Vertices attract or repel particles");
> uiDefButF(block, NUM, B_GRAVSTRENGTH, "Strength", 143,20,150,20, &me->g_strength, -100, 100, 0, 0, "Strength of gravitational force");
> uiDefButF(block, NUM, B_GRAVPOWER, "Fall-off", 143,0,150,20, &me->g_power, 0, 10, 0, 0, "Falloff power (real gravity = 2)");
Index: source/blender/src/buttons_object.c
===================================================================
RCS file: /cvsroot/tuhopuu/tuhopuu2/source/blender/src/buttons_object.c,v
retrieving revision 1.9
diff -r1.9 buttons_object.c
1567c1567
< uiDefButI(block, NUM, B_CALCEFFECT, "Keys:", 922,146,80,20, &paf->totkey, 1.0, 32.0, 0, 0, "Specify the number of key positions");
---
> uiDefButI(block, NUM, B_CALCEFFECT, "Keys:", 922,146,80,20, &paf->totkey, 1.0, 100.0, 0, 0, "Specify the number of key positions");
--0-1439739806-1077440678=:9785--