Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle.c
| Show First 20 Lines • Show All 2,821 Lines • ▼ Show 20 Lines | void psys_cache_child_paths(ParticleSimulationData *sim, | ||||
| } | } | ||||
| /* create a task pool for child path tasks */ | /* create a task pool for child path tasks */ | ||||
| if (!psys_thread_context_init_path(&ctx, sim, sim->scene, cfra, editupdate, use_render_params)) { | if (!psys_thread_context_init_path(&ctx, sim, sim->scene, cfra, editupdate, use_render_params)) { | ||||
| return; | return; | ||||
| } | } | ||||
| task_scheduler = BLI_task_scheduler_get(); | task_scheduler = BLI_task_scheduler_get(); | ||||
| task_pool = BLI_task_pool_create(task_scheduler, &ctx); | task_pool = BLI_task_pool_create(task_scheduler, &ctx, TASK_PRIORITY_LOW); | ||||
| totchild = ctx.totchild; | totchild = ctx.totchild; | ||||
| totparent = ctx.totparent; | totparent = ctx.totparent; | ||||
| if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { | if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { | ||||
| /* just overwrite the existing cache */ | /* just overwrite the existing cache */ | ||||
| } | } | ||||
| else { | else { | ||||
| /* clear out old and create new empty path cache */ | /* clear out old and create new empty path cache */ | ||||
| free_child_path_cache(sim->psys); | free_child_path_cache(sim->psys); | ||||
| sim->psys->childcache = psys_alloc_path_cache_buffers( | sim->psys->childcache = psys_alloc_path_cache_buffers( | ||||
| &sim->psys->childcachebufs, totchild, ctx.segments + ctx.extra_segments + 1); | &sim->psys->childcachebufs, totchild, ctx.segments + ctx.extra_segments + 1); | ||||
| sim->psys->totchildcache = totchild; | sim->psys->totchildcache = totchild; | ||||
| } | } | ||||
| /* cache parent paths */ | /* cache parent paths */ | ||||
| ctx.parent_pass = 1; | ctx.parent_pass = 1; | ||||
| psys_tasks_create(&ctx, 0, totparent, &tasks_parent, &numtasks_parent); | psys_tasks_create(&ctx, 0, totparent, &tasks_parent, &numtasks_parent); | ||||
| for (i = 0; i < numtasks_parent; i++) { | for (i = 0; i < numtasks_parent; i++) { | ||||
| ParticleTask *task = &tasks_parent[i]; | ParticleTask *task = &tasks_parent[i]; | ||||
| psys_task_init_path(task, sim); | psys_task_init_path(task, sim); | ||||
| BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW); | BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, NULL); | ||||
| } | } | ||||
| BLI_task_pool_work_and_wait(task_pool); | BLI_task_pool_work_and_wait(task_pool); | ||||
| /* cache child paths */ | /* cache child paths */ | ||||
| ctx.parent_pass = 0; | ctx.parent_pass = 0; | ||||
| psys_tasks_create(&ctx, totparent, totchild, &tasks_child, &numtasks_child); | psys_tasks_create(&ctx, totparent, totchild, &tasks_child, &numtasks_child); | ||||
| for (i = 0; i < numtasks_child; i++) { | for (i = 0; i < numtasks_child; i++) { | ||||
| ParticleTask *task = &tasks_child[i]; | ParticleTask *task = &tasks_child[i]; | ||||
| psys_task_init_path(task, sim); | psys_task_init_path(task, sim); | ||||
| BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, TASK_PRIORITY_LOW); | BLI_task_pool_push(task_pool, exec_child_path_cache, task, false, NULL); | ||||
| } | } | ||||
| BLI_task_pool_work_and_wait(task_pool); | BLI_task_pool_work_and_wait(task_pool); | ||||
| BLI_task_pool_free(task_pool); | BLI_task_pool_free(task_pool); | ||||
| psys_tasks_free(tasks_parent, numtasks_parent); | psys_tasks_free(tasks_parent, numtasks_parent); | ||||
| psys_tasks_free(tasks_child, numtasks_child); | psys_tasks_free(tasks_child, numtasks_child); | ||||
| ▲ Show 20 Lines • Show All 2,084 Lines • Show Last 20 Lines | |||||