Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle.c
| Show First 20 Lines • Show All 2,781 Lines • ▼ Show 20 Lines | static void psys_thread_create_path(ParticleTask *task, | ||||
| } | } | ||||
| /* Hide virtual parents */ | /* Hide virtual parents */ | ||||
| if (i < ctx->totparent) { | if (i < ctx->totparent) { | ||||
| child_keys->segments = -1; | child_keys->segments = -1; | ||||
| } | } | ||||
| } | } | ||||
| static void exec_child_path_cache(TaskPool *__restrict UNUSED(pool), | static void exec_child_path_cache(TaskPool *__restrict UNUSED(pool), void *taskdata) | ||||
| void *taskdata, | |||||
| int UNUSED(threadid)) | |||||
| { | { | ||||
| ParticleTask *task = taskdata; | ParticleTask *task = taskdata; | ||||
| ParticleThreadContext *ctx = task->ctx; | ParticleThreadContext *ctx = task->ctx; | ||||
| ParticleSystem *psys = ctx->sim.psys; | ParticleSystem *psys = ctx->sim.psys; | ||||
| ParticleCacheKey **cache = psys->childcache; | ParticleCacheKey **cache = psys->childcache; | ||||
| ChildParticle *cpa; | ChildParticle *cpa; | ||||
| int i; | int i; | ||||
| Show All 20 Lines | if (sim->psys->flag & PSYS_GLOBAL_HAIR) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* 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_legacy_get(); | ||||
| task_pool = BLI_task_pool_create(task_scheduler, &ctx, TASK_PRIORITY_LOW); | task_pool = BLI_task_pool_tbb_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, NULL); | BLI_task_pool_tbb_push(task_pool, exec_child_path_cache, task, false, NULL); | ||||
| } | } | ||||
| BLI_task_pool_work_and_wait(task_pool); | BLI_task_pool_tbb_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, NULL); | BLI_task_pool_tbb_push(task_pool, exec_child_path_cache, task, false, NULL); | ||||
| } | } | ||||
| BLI_task_pool_work_and_wait(task_pool); | BLI_task_pool_tbb_work_and_wait(task_pool); | ||||
| BLI_task_pool_free(task_pool); | BLI_task_pool_tbb_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); | ||||
| psys_thread_context_free(&ctx); | psys_thread_context_free(&ctx); | ||||
| } | } | ||||
| /* figure out incremental rotations along path starting from unit quat */ | /* figure out incremental rotations along path starting from unit quat */ | ||||
| ▲ Show 20 Lines • Show All 495 Lines • ▼ Show 20 Lines | void psys_cache_edit_paths(Depsgraph *depsgraph, | ||||
| iter_data.edit = edit; | iter_data.edit = edit; | ||||
| iter_data.psmd = edit->psmd_eval; | iter_data.psmd = edit->psmd_eval; | ||||
| iter_data.pa = pa; | iter_data.pa = pa; | ||||
| iter_data.segments = segments; | iter_data.segments = segments; | ||||
| iter_data.use_weight = use_weight; | iter_data.use_weight = use_weight; | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BLI_parallel_range_settings_defaults(&settings); | BLI_parallel_range_settings_defaults(&settings); | ||||
| settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC; | |||||
| BLI_task_parallel_range(0, edit->totpoint, &iter_data, psys_cache_edit_paths_iter, &settings); | BLI_task_parallel_range(0, edit->totpoint, &iter_data, psys_cache_edit_paths_iter, &settings); | ||||
| edit->totcached = totpart; | edit->totcached = totpart; | ||||
| if (psys) { | if (psys) { | ||||
| ParticleSimulationData sim = {0}; | ParticleSimulationData sim = {0}; | ||||
| sim.depsgraph = depsgraph; | sim.depsgraph = depsgraph; | ||||
| sim.scene = scene; | sim.scene = scene; | ||||
| ▲ Show 20 Lines • Show All 1,568 Lines • Show Last 20 Lines | |||||