[Bf-committers] Fixed bug of Verlet integrator (Farsthary)

Raul Fernandez Hernandez raulf at info.upr.edu.cu
Mon Nov 30 21:23:44 CET 2009


Hi all :)

  Thanks to mcmacsurfer feedback I could spot the bug in the verlet
integrator and the solution was quite simple also, I was using the
pa->prev_state.co but aparently that state is modifyed/used in several
parts of the particle pippeline so changes in it could lead to strange
particle behaviours, instead return to my original proposal of using a
temporal variable that store the initial particle position at the
beginning of the function apply_particle_forces().
  Now everything works as should do.
                           Thanks for the feedback
                                                   Farsthary


Here´s the solution: http://www.pasteall.org/9538/diff

in function apply_particle_forces()

-- float force[3],impulse[3],dx[4][3],dv[4][3],diff[3];
++ float force[3],impulse[3],dx[4][3],dv[4][3],diff[3],tempos[3];

  ...

	/* maintain angular velocity */
	VECCOPY(pa->state.ave,pa->prev_state.ave);
++	VECCOPY(tempos,pa->state.co);

  ...

	case PART_INT_VERLET:
			        VECADDFAC(pa->state.vel,pa->state.vel,force,dtime);
VecMulf(pa->state.vel,dtime);
VecAddf(pa->state.co,pa->state.co,pa->state.vel);


--VecSubf(diff,pa->state.co,pa->prev_state.co);
++VecSubf(diff,pa->state.co,tempos);    								 VecMulf(diff,1.f/dtime);
VECCOPY(pa->state.vel,diff);
break;





More information about the Bf-committers mailing list