Verlet integration method for particles (patch provided by farsthary).

This commit is contained in:
Janne Karhu 2009-11-25 17:46:10 +00:00
parent 553374bd4c
commit 323aa65671
3 changed files with 12 additions and 0 deletions

@ -2287,6 +2287,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
case PART_INT_RK4:
steps=4;
break;
case PART_INT_VERLET:
steps=1;
break;
}
copy_particle_key(states,&pa->state,1);
@ -2392,6 +2395,13 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
VECADDFAC(pa->state.vel,pa->state.vel,dv[3],1.0f/6.0f);
}
break;
case PART_INT_VERLET: /* Verlet integration */
VECADDFAC(pa->state.vel,pa->state.vel,force,dtime);
VECADDFAC(pa->state.co,pa->state.co,pa->state.vel,dtime);
VECSUB(pa->state.vel,pa->state.co,pa->prev_state.co);
mul_v3_fl(pa->state.vel,1.0f/dtime);
break;
}
}

@ -391,6 +391,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in
#define PART_INT_EULER 0
#define PART_INT_MIDPOINT 1
#define PART_INT_RK4 2
#define PART_INT_VERLET 3
/* part->rotmode */
#define PART_ROT_NOR 1

@ -917,6 +917,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
static EnumPropertyItem integrator_type_items[] = {
{PART_INT_EULER, "EULER", 0, "Euler", ""},
{PART_INT_VERLET, "VERLET", 0, "Verlet", ""},
{PART_INT_MIDPOINT, "MIDPOINT", 0, "Midpoint", ""},
{PART_INT_RK4, "RK4", 0, "RK4", ""},
{0, NULL, 0, NULL, NULL}