Big cleanup of particle system core, also some minor pointcache cleanup. Shouldn't contain any functional changes.
This commit is contained in:
@@ -302,4 +302,10 @@ void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid);
|
||||
/* 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
|
||||
|
||||
@@ -356,14 +356,12 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
|
||||
/* 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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
* 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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
|
||||
/* 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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
|
||||
/* 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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
}
|
||||
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
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);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2081,9 +2081,8 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
|
||||
}
|
||||
|
||||
if(reset) {
|
||||
cache->flag &= ~(PTCACHE_REDO_NEEDED|PTCACHE_SIMULATION_VALID);
|
||||
cache->simframe= 0;
|
||||
cache->last_exact= 0;
|
||||
BKE_ptcache_invalidate(cache);
|
||||
cache->flag &= ~PTCACHE_REDO_NEEDED;
|
||||
|
||||
if(pid->type == PTCACHE_TYPE_CLOTH)
|
||||
cloth_free_modifier(pid->ob, pid->calldata);
|
||||
@@ -2861,3 +2860,15 @@ void BKE_ptcache_update_info(PTCacheID *pid)
|
||||
else
|
||||
sprintf(cache->info, "%s.", mem_info);
|
||||
}
|
||||
|
||||
void BKE_ptcache_validate(PointCache *cache, int framenr)
|
||||
{
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe = framenr;
|
||||
}
|
||||
void BKE_ptcache_invalidate(PointCache *cache)
|
||||
{
|
||||
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe = 0;
|
||||
cache->last_exact = 0;
|
||||
}
|
||||
@@ -1197,8 +1197,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
|
||||
if(cache_result == PTCACHE_READ_EXACT)
|
||||
{
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe= framenr;
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
|
||||
if(sds->wt)
|
||||
{
|
||||
@@ -1206,8 +1205,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
|
||||
if(cache_result_wt == PTCACHE_READ_EXACT)
|
||||
{
|
||||
cache_wt->flag |= PTCACHE_SIMULATION_VALID;
|
||||
cache_wt->simframe= framenr;
|
||||
BKE_ptcache_validate(cache_wt, framenr);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -1223,8 +1221,6 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
/* do simulation */
|
||||
|
||||
// low res
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe= framenr;
|
||||
|
||||
// simulate the actual smoke (c++ code in intern/smoke)
|
||||
// DG: interesting commenting this line + deactivating loading of noise files
|
||||
@@ -1239,6 +1235,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
if(get_lamp(scene, light))
|
||||
smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx);
|
||||
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
BKE_ptcache_write_cache(&pid, framenr);
|
||||
|
||||
if(sds->wt)
|
||||
@@ -1250,8 +1247,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
smoke_turbulence_step(sds->wt, sds->fluid);
|
||||
}
|
||||
|
||||
cache_wt->flag |= PTCACHE_SIMULATION_VALID;
|
||||
cache_wt->simframe= framenr;
|
||||
BKE_ptcache_validate(cache_wt, framenr);
|
||||
BKE_ptcache_write_cache(&pid_wt, framenr);
|
||||
}
|
||||
|
||||
|
||||
@@ -4058,17 +4058,13 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
/* check for changes in mesh, should only happen in case the mesh
|
||||
* structure changes during an animation */
|
||||
if(sb->bpoint && numVerts != sb->totpoint) {
|
||||
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe= 0;
|
||||
cache->last_exact= 0;
|
||||
BKE_ptcache_invalidate(cache);
|
||||
return;
|
||||
}
|
||||
|
||||
/* clamp frame ranges */
|
||||
if(framenr < startframe) {
|
||||
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe= 0;
|
||||
//cache->last_exact= 0;
|
||||
BKE_ptcache_invalidate(cache);
|
||||
return;
|
||||
}
|
||||
else if(framenr > endframe) {
|
||||
@@ -4101,8 +4097,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
|
||||
/* continue physics special case */
|
||||
if(BKE_ptcache_get_continue_physics()) {
|
||||
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
||||
cache->simframe= 0;
|
||||
BKE_ptcache_invalidate(cache);
|
||||
/* do simulation */
|
||||
dtime = timescale;
|
||||
softbody_update_positions(ob, sb, vertexCos, numVerts);
|
||||
@@ -4121,8 +4116,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
/* first frame, no simulation to do, just set the positions */
|
||||
softbody_update_positions(ob, sb, vertexCos, numVerts);
|
||||
|
||||
cache->simframe= framenr;
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
cache->flag &= ~PTCACHE_REDO_NEEDED;
|
||||
return;
|
||||
}
|
||||
@@ -4133,8 +4127,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
|
||||
softbody_to_object(ob, vertexCos, numVerts, sb->local);
|
||||
|
||||
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);
|
||||
@@ -4142,13 +4135,11 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
return;
|
||||
}
|
||||
else if(cache_result==PTCACHE_READ_OLD) {
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
; /* do nothing */
|
||||
}
|
||||
else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) {
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -4166,8 +4157,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
|
||||
softbody_to_object(ob, vertexCos, numVerts, 0);
|
||||
|
||||
cache->simframe= framenr;
|
||||
cache->flag |= PTCACHE_SIMULATION_VALID;
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
BKE_ptcache_write_cache(&pid, framenr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user