[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27649] trunk/blender/source/blender/ blenkernel: Big cleanup of particle system core, also some minor pointcache cleanup.
Janne Karhu
jhkarh at gmail.com
Sun Mar 21 21:36:06 CET 2010
Revision: 27649
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27649
Author: jhk
Date: 2010-03-21 21:36:06 +0100 (Sun, 21 Mar 2010)
Log Message:
-----------
Big cleanup of particle system core, also some minor pointcache cleanup. Shouldn't contain any functional changes.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_pointcache.h
trunk/blender/source/blender/blenkernel/intern/cloth.c
trunk/blender/source/blender/blenkernel/intern/particle_system.c
trunk/blender/source/blender/blenkernel/intern/pointcache.c
trunk/blender/source/blender/blenkernel/intern/smoke.c
trunk/blender/source/blender/blenkernel/intern/softbody.c
Modified: trunk/blender/source/blender/blenkernel/BKE_pointcache.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_pointcache.h 2010-03-21 19:55:51 UTC (rev 27648)
+++ trunk/blender/source/blender/blenkernel/BKE_pointcache.h 2010-03-21 20:36:06 UTC (rev 27649)
@@ -302,4 +302,10 @@
/* Loads simulation from external (disk) cache files. */
void BKE_ptcache_load_external(struct PTCacheID *pid);
+/* Set correct flags after successful simulation step */
+void BKE_ptcache_validate(struct PointCache *cache, int framenr);
+
+/* Set correct flags after unsuccessful simulation step */
+void BKE_ptcache_invalidate(struct PointCache *cache);
+
#endif
Modified: trunk/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cloth.c 2010-03-21 19:55:51 UTC (rev 27648)
+++ trunk/blender/source/blender/blenkernel/intern/cloth.c 2010-03-21 20:36:06 UTC (rev 27649)
@@ -356,14 +356,12 @@
/* initialize simulation data if it didn't exist already */
if(clmd->clothObject == NULL) {
if(!cloth_from_object(ob, clmd, result, framenr, 1)) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
+ BKE_ptcache_invalidate(cache);
return 0;
}
if(clmd->clothObject == NULL) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
+ BKE_ptcache_invalidate(cache);
return 0;
}
@@ -436,20 +434,17 @@
clmd->sim_parms->timescale= timescale;
if(!result) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
- cache->last_exact= 0;
+ BKE_ptcache_invalidate(cache);
return dm;
}
if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll)))
{
clmd->sim_parms->reset = 0;
- cache->flag |= PTCACHE_REDO_NEEDED;
+ cache->flag |= PTCACHE_OUTDATED;
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
- cache->simframe= 0;
+ BKE_ptcache_validate(cache, 0);
cache->last_exact= 0;
- cache->flag |= PTCACHE_SIMULATION_VALID;
cache->flag &= ~PTCACHE_REDO_NEEDED;
return result;
}
@@ -460,9 +455,7 @@
* happen because of object changes! */
if(clmd->clothObject) {
if(result->getNumVerts(result) != clmd->clothObject->numverts) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
- cache->last_exact= 0;
+ BKE_ptcache_invalidate(cache);
return result;
}
}
@@ -472,9 +465,7 @@
/* handle continuous simulation with the play button */
if(BKE_ptcache_get_continue_physics() || ((clmd->sim_parms->preroll > 0) && (framenr > startframe - clmd->sim_parms->preroll) && (framenr < startframe))) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
- cache->last_exact= 0;
+ BKE_ptcache_invalidate(cache);
/* do simulation */
if(!do_init_cloth(ob, clmd, result, framenr))
@@ -488,9 +479,7 @@
/* simulation is only active during a specific period */
if(framenr < startframe) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
- cache->last_exact= 0;
+ BKE_ptcache_invalidate(cache);
return result;
}
else if(framenr > endframe) {
@@ -509,8 +498,7 @@
if((framenr == startframe) && (clmd->sim_parms->preroll == 0)) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
do_init_cloth(ob, clmd, result, framenr);
- cache->simframe= framenr;
- cache->flag |= PTCACHE_SIMULATION_VALID;
+ BKE_ptcache_validate(cache, framenr);
cache->flag &= ~PTCACHE_REDO_NEEDED;
return result;
}
@@ -522,8 +510,7 @@
implicit_set_positions(clmd);
cloth_to_object (ob, clmd, result);
- cache->simframe= framenr;
- cache->flag |= PTCACHE_SIMULATION_VALID;
+ BKE_ptcache_validate(cache, framenr);
if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_write_cache(&pid, framenr);
@@ -532,13 +519,10 @@
}
else if(cache_result==PTCACHE_READ_OLD) {
implicit_set_positions(clmd);
- cache->flag |= PTCACHE_SIMULATION_VALID;
}
else if( /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
/* if baked and nothing in cache, do nothing */
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
- cache->last_exact= 0;
+ BKE_ptcache_invalidate(cache);
return result;
}
@@ -549,13 +533,10 @@
clmd->sim_parms->timescale *= framenr - cache->simframe;
/* do simulation */
- cache->flag |= PTCACHE_SIMULATION_VALID;
- cache->simframe= framenr;
+ BKE_ptcache_validate(cache, framenr);
if(!do_step_cloth(ob, clmd, result, framenr)) {
- cache->flag &= ~PTCACHE_SIMULATION_VALID;
- cache->simframe= 0;
- cache->last_exact= 0;
+ BKE_ptcache_invalidate(cache);
}
else
BKE_ptcache_write_cache(&pid, framenr);
Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c 2010-03-21 19:55:51 UTC (rev 27648)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c 2010-03-21 20:36:06 UTC (rev 27649)
@@ -159,8 +159,7 @@
psys_free_path_cache(psys, psys->edit);
/* reset point cache */
- psys->pointcache->flag &= ~PTCACHE_SIMULATION_VALID;
- psys->pointcache->simframe= 0;
+ BKE_ptcache_invalidate(psys->pointcache);
}
static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
@@ -2215,21 +2214,17 @@
void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys)
{
PointCache *cache = psys->pointcache;
- PTCacheID pid;
- if((cache->flag & PTCACHE_DISK_CACHE)==0 || cache->mem_cache.first)
- return;
-
- BKE_ptcache_id_from_particles(&pid, ob, psys);
-
- BKE_ptcache_disk_to_mem(&pid);
+ if(cache->flag & PTCACHE_DISK_CACHE && cache->mem_cache.first == NULL) {
+ PTCacheID pid;
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+ BKE_ptcache_disk_to_mem(&pid);
+ }
}
static void psys_clear_temp_pointcache(ParticleSystem *psys)
{
- if((psys->pointcache->flag & PTCACHE_DISK_CACHE)==0)
- return;
-
- BKE_ptcache_free_mem(&psys->pointcache->mem_cache);
+ if(psys->pointcache->flag & PTCACHE_DISK_CACHE)
+ BKE_ptcache_free_mem(&psys->pointcache->mem_cache);
}
void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
{
@@ -3202,15 +3197,11 @@
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part=psys->part;
- KDTree *tree=0;
- //IpoCurve *icu_esize=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system
-/* Material *ma=give_current_material(sim->ob, part->omat); */
BoidBrainData bbd;
PARTICLE_P;
float timestep;
- int totpart;
/* current time */
- float ctime, ipotime; // XXX old animation system
+ float ctime;
/* frame & time changes */
float dfra, dtime, pa_dtime, pa_dfra=0.0;
float birthtime, dietime;
@@ -3218,200 +3209,157 @@
/* where have we gone in time since last time */
dfra= cfra - psys->cfra;
- totpart=psys->totpart;
-
timestep = psys_get_timestep(sim);
dtime= dfra*timestep;
ctime= cfra*timestep;
- ipotime= cfra; // XXX old animation system
-#if 0 // XXX old animation system
- if(part->flag&PART_ABS_TIME && part->ipo){
- calc_ipo(part->ipo, cfra);
- execute_ipo((ID *)part, part->ipo);
- }
-#endif // XXX old animation system
-
if(dfra<0.0){
- float *vg_size=0;
- //if(part->type==PART_REACTOR)
- // vg_size=psys_cache_vgroup(sim->psmd->dm,psys,PSYS_VG_SIZE);
-
LOOP_EXISTING_PARTICLES {
- /* set correct ipo timing */
-#if 0 // XXX old animation system
- if((part->flag&PART_ABS_TIME)==0 && part->ipo){
- ipotime=100.0f*(cfra-pa->time)/pa->lifetime;
- calc_ipo(part->ipo, ipotime);
- execute_ipo((ID *)part, part->ipo);
- }
-#endif // XXX old animation system
pa->size = part->size;
if(part->randsize > 0.0)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
reset_particle(sim, pa, dtime, cfra);
}
-
- if(vg_size)
- MEM_freeN(vg_size);
+ return;
}
- else{
- BLI_srandom(31415926 + (int)cfra + psys->seed);
- psys_update_effectors(sim);
+ BLI_srandom(31415926 + (int)cfra + psys->seed);
- if(part->type != PART_HAIR)
- sim->colliders = get_collider_cache(sim->scene, NULL);
+ psys_update_effectors(sim);
- if(part->phystype==PART_PHYS_BOIDS){
- ParticleTarget *pt = psys->targets.first;
- bbd.sim = sim;
- bbd.part = part;
- bbd.cfra = cfra;
- bbd.dfra = dfra;
- bbd.timestep = timestep;
+ if(part->type != PART_HAIR)
+ sim->colliders = get_collider_cache(sim->scene, NULL);
- psys_update_particle_tree(psys, cfra);
+ if(part->phystype==PART_PHYS_BOIDS){
+ ParticleTarget *pt = psys->targets.first;
+ bbd.sim = sim;
+ bbd.part = part;
+ bbd.cfra = cfra;
+ bbd.dfra = dfra;
+ bbd.timestep = timestep;
- boids_precalc_rules(part, cfra);
+ psys_update_particle_tree(psys, cfra);
- for(; pt; pt=pt->next) {
- if(pt->ob)
- psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra);
- }
+ boids_precalc_rules(part, cfra);
+
+ for(; pt; pt=pt->next) {
+ if(pt->ob)
+ psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra);
}
+ }
- /* main loop: calculate physics for all particles */
- LOOP_SHOWN_PARTICLES {
- copy_particle_key(&pa->prev_state,&pa->state,1);
-
- /* set correct ipo timing */
-#if 0 // XXX old animation system
- if((part->flag&PART_ABS_TIME)==0 && part->ipo){
- ipotime=100.0f*(cfra-pa->time)/pa->lifetime;
- calc_ipo(part->ipo, ipotime);
- execute_ipo((ID *)part, part->ipo);
- }
-#endif // XXX old animation system
- //update_particle_settings(psys, part, &tpart, pa);
+ /* main loop: calculate physics for all particles */
+ LOOP_SHOWN_PARTICLES {
+ copy_particle_key(&pa->prev_state,&pa->state,1);
- pa->size = part->size;
- if(part->randsize > 0.0)
- pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
+ pa->size = part->size;
+ if(part->randsize > 0.0)
+ pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
- ///* reactions can change birth time so they need to be checked first */
- //if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0)
- // react_to_events(psys,p);
+ ///* reactions can change birth time so they need to be checked first */
+ //if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0)
+ // react_to_events(psys,p);
- birthtime = pa->time;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list