Commit: a7178954bf8c69caf44d04ffaa37c7de130e95c5 Author: Lukas Tönne Date: Thu Feb 26 14:05:49 2015 +0100 Branches: alembic_pointcache https://developer.blender.org/rBa7178954bf8c69caf44d04ffaa37c7de130e95c5
Cache reading for particle paths. =================================================================== M source/blender/blenkernel/BKE_cache_library.h M source/blender/blenkernel/intern/cache_library.c M source/blender/blenkernel/intern/particle.c =================================================================== diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h index 7c56ad8..c5160e6 100644 --- a/source/blender/blenkernel/BKE_cache_library.h +++ b/source/blender/blenkernel/BKE_cache_library.h @@ -38,6 +38,7 @@ struct ListBase; struct Main; struct Object; struct Scene; +struct ParticleSystem; struct ClothModifierData; @@ -90,5 +91,7 @@ void BKE_cache_library_group_update(struct Main *bmain, struct CacheLibrary *cac bool BKE_cache_read_derived_mesh(struct Main *bmain, struct Scene *scene, float frame, struct Object *ob, struct DerivedMesh **r_dm); bool BKE_cache_read_cloth(struct Main *bmain, struct Scene *scene, float frame, struct Object *ob, struct ClothModifierData *clmd); bool BKE_cache_read_hair_dynamics(struct Main *bmain, struct Scene *scene, float frame, struct Object *ob, struct ParticleSystem *psys); +bool BKE_cache_read_particle_pathcache_parents(struct Main *bmain, struct Scene *scene, float frame, struct Object *ob, struct ParticleSystem *psys); +bool BKE_cache_read_particle_pathcache_children(struct Main *bmain, struct Scene *scene, float frame, struct Object *ob, struct ParticleSystem *psys); #endif diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c index a5bfd92..5914a62 100644 --- a/source/blender/blenkernel/intern/cache_library.c +++ b/source/blender/blenkernel/intern/cache_library.c @@ -547,3 +547,25 @@ bool BKE_cache_read_hair_dynamics(Main *bmain, Scene *scene, float frame, Object } return false; } + +bool BKE_cache_read_particle_pathcache_parents(Main *bmain, Scene *scene, float frame, Object *ob, struct ParticleSystem *psys) +{ + CacheLibrary *cachelib; + + for (cachelib = bmain->cache_library.first; cachelib; cachelib = cachelib->id.next) { + if (PTC_cachelib_read_sample_particle_pathcache_parents(scene, frame, cachelib, ob, psys) != PTC_READ_SAMPLE_INVALID) + return true; + } + return false; +} + +bool BKE_cache_read_particle_pathcache_children(Main *bmain, Scene *scene, float frame, Object *ob, struct ParticleSystem *psys) +{ + CacheLibrary *cachelib; + + for (cachelib = bmain->cache_library.first; cachelib; cachelib = cachelib->id.next) { + if (PTC_cachelib_read_sample_particle_pathcache_children(scene, frame, cachelib, ob, psys) != PTC_READ_SAMPLE_INVALID) + return true; + } + return false; +} diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 291efd0..c0ed7c3 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -63,6 +63,7 @@ #include "BKE_animsys.h" #include "BKE_boids.h" +#include "BKE_cache_library.h" #include "BKE_cloth.h" #include "BKE_colortools.h" #include "BKE_effect.h" @@ -2327,6 +2328,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd ParticleTask *tasks_parent, *tasks_child; int numtasks_parent, numtasks_child; int i, totchild, totparent; + bool cache_result; if (sim->psys->flag & PSYS_GLOBAL_HAIR) return; @@ -2351,32 +2353,40 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd sim->psys->totchildcache = totchild; } - /* cache parent paths */ - ctx.parent_pass = 1; - psys_tasks_create(&ctx, totparent, &tasks_parent, &numtasks_parent); - for (i = 0; i < numtasks_parent; ++i) { - ParticleTask *task = &tasks_parent[i]; + /* try reading from point cache */ + cache_result = BKE_cache_read_particle_pathcache_parents(G.main, sim->scene, cfra, sim->ob, sim->psys); + if (!cache_result) { + /* cache parent paths */ + ctx.parent_pass = 1; + psys_tasks_create(&ctx, totparent, &tasks_parent, &numtasks_parent); + for (i = 0; i < numtasks_parent; ++i) { + ParticleTask *task = &tasks_parent[i]; + + psys_task_init_path(task, sim); + BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW); + } + BLI_task_pool_work_and_wait(task_pool); - psys_task_init_path(task, sim); - BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW); + psys_tasks_free(tasks_parent, numtasks_parent); } - BLI_task_pool_work_and_wait(task_pool); - /* cache child paths */ - ctx.parent_pass = 0; - psys_tasks_create(&ctx, totchild, &tasks_child, &numtasks_child); - for (i = 0; i < numtasks_child; ++i) { - ParticleTask *task = &tasks_child[i]; + cache_result = BKE_cache_read_particle_pathcache_children(G.main, sim->scene, cfra, sim->ob, sim->psys); + if (!cache_result) { + /* cache child paths */ + ctx.parent_pass = 0; + psys_tasks_create(&ctx, totchild, &tasks_child, &numtasks_child); + for (i = 0; i < numtasks_child; ++i) { + ParticleTask *task = &tasks_child[i]; + + psys_task_init_path(task, sim); + BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW); + } + BLI_task_pool_work_and_wait(task_pool); - psys_task_init_path(task, sim); - BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW); + psys_tasks_free(tasks_child, numtasks_child); } - BLI_task_pool_work_and_wait(task_pool); - - BLI_task_pool_free(task_pool); - psys_tasks_free(tasks_parent, numtasks_parent); - psys_tasks_free(tasks_child, numtasks_child); + BLI_task_pool_free(task_pool); psys_thread_context_free(&ctx); } @@ -2454,6 +2464,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) float *vg_effector = NULL; float *vg_length = NULL, pa_length = 1.0f; int keyed, baked; + bool cache_result; /* we don't have anything valid to create paths from so let's quit here */ if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0) @@ -2470,6 +2481,11 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) psys_free_path_cache(psys, psys->edit); cache = psys->pathcache = psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, segments + 1); + /* try reading from cache */ + cache_result = BKE_cache_read_particle_pathcache_parents(G.main, sim->scene, cfra, sim->ob, sim->psys); + if (cache_result) + return; + psys->lattice_deform_data = psys_create_lattice_deform_data(sim); ma = give_current_material(sim->ob, psys->part->omat); if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT)) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs