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; | ||||
| cpa = psys->child + task->begin; | cpa = psys->child + task->begin; | ||||
| for (i = task->begin; i < task->end; i++, cpa++) { | for (i = task->begin; i < task->end; i++, cpa++) { | ||||
| BLI_assert(i < psys->totchildcache); | BLI_assert(i < psys->totchildcache); | ||||
| psys_thread_create_path(task, cpa, cache[i], i); | psys_thread_create_path(task, cpa, cache[i], i); | ||||
| } | } | ||||
| } | } | ||||
| void psys_cache_child_paths(ParticleSimulationData *sim, | void psys_cache_child_paths(ParticleSimulationData *sim, | ||||
| float cfra, | float cfra, | ||||
| const bool editupdate, | const bool editupdate, | ||||
| const bool use_render_params) | const bool use_render_params) | ||||
| { | { | ||||
| TaskScheduler *task_scheduler; | |||||
| TaskPool *task_pool; | TaskPool *task_pool; | ||||
| ParticleThreadContext ctx; | ParticleThreadContext ctx; | ||||
| ParticleTask *tasks_parent, *tasks_child; | ParticleTask *tasks_parent, *tasks_child; | ||||
| int numtasks_parent, numtasks_child; | int numtasks_parent, numtasks_child; | ||||
| int i, totchild, totparent; | int i, totchild, totparent; | ||||
| if (sim->psys->flag & PSYS_GLOBAL_HAIR) { | 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_pool = BLI_task_pool_create(&ctx, TASK_PRIORITY_LOW); | ||||
| 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 */ | ||||
| ▲ Show 20 Lines • Show All 533 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 | |||||