Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle_distribute.c
| Show First 20 Lines • Show All 767 Lines • ▼ Show 20 Lines | if (ctx->tree) { | ||||
| cpa->parent = cpa->pa[0]; | cpa->parent = cpa->pa[0]; | ||||
| } | } | ||||
| if (rng_skip_tot > 0) { /* should never be below zero */ | if (rng_skip_tot > 0) { /* should never be below zero */ | ||||
| BLI_rng_skip(thread->rng, rng_skip_tot); | BLI_rng_skip(thread->rng, rng_skip_tot); | ||||
| } | } | ||||
| } | } | ||||
| static void exec_distribute_parent(TaskPool *__restrict UNUSED(pool), | static void exec_distribute_parent(TaskPool *__restrict UNUSED(pool), void *taskdata) | ||||
| void *taskdata, | |||||
| int UNUSED(threadid)) | |||||
| { | { | ||||
| ParticleTask *task = taskdata; | ParticleTask *task = taskdata; | ||||
| ParticleSystem *psys = task->ctx->sim.psys; | ParticleSystem *psys = task->ctx->sim.psys; | ||||
| ParticleData *pa; | ParticleData *pa; | ||||
| int p; | int p; | ||||
| BLI_rng_skip(task->rng, PSYS_RND_DIST_SKIP * task->begin); | BLI_rng_skip(task->rng, PSYS_RND_DIST_SKIP * task->begin); | ||||
| Show All 12 Lines | switch (psys->part->from) { | ||||
| case PART_FROM_VERT: | case PART_FROM_VERT: | ||||
| for (p = task->begin; p < task->end; p++, pa++) { | for (p = task->begin; p < task->end; p++, pa++) { | ||||
| distribute_from_verts_exec(task, pa, p); | distribute_from_verts_exec(task, pa, p); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| static void exec_distribute_child(TaskPool *__restrict UNUSED(pool), | static void exec_distribute_child(TaskPool *__restrict UNUSED(pool), void *taskdata) | ||||
| void *taskdata, | |||||
| int UNUSED(threadid)) | |||||
| { | { | ||||
| ParticleTask *task = taskdata; | ParticleTask *task = taskdata; | ||||
| ParticleSystem *psys = task->ctx->sim.psys; | ParticleSystem *psys = task->ctx->sim.psys; | ||||
| ChildParticle *cpa; | ChildParticle *cpa; | ||||
| int p; | int p; | ||||
| /* RNG skipping at the beginning */ | /* RNG skipping at the beginning */ | ||||
| cpa = psys->child; | cpa = psys->child; | ||||
| ▲ Show 20 Lines • Show All 513 Lines • ▼ Show 20 Lines | static void distribute_particles_on_dm(ParticleSimulationData *sim, int from) | ||||
| Mesh *final_mesh = sim->psmd->mesh_final; | Mesh *final_mesh = sim->psmd->mesh_final; | ||||
| int i, totpart, numtasks; | int i, totpart, numtasks; | ||||
| /* create a task pool for distribution tasks */ | /* create a task pool for distribution tasks */ | ||||
| if (!psys_thread_context_init_distribute(&ctx, sim, from)) { | if (!psys_thread_context_init_distribute(&ctx, sim, from)) { | ||||
| 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); | ||||
| totpart = (from == PART_FROM_CHILD ? sim->psys->totchild : sim->psys->totpart); | totpart = (from == PART_FROM_CHILD ? sim->psys->totchild : sim->psys->totpart); | ||||
| psys_tasks_create(&ctx, 0, totpart, &tasks, &numtasks); | psys_tasks_create(&ctx, 0, totpart, &tasks, &numtasks); | ||||
| for (i = 0; i < numtasks; i++) { | for (i = 0; i < numtasks; i++) { | ||||
| ParticleTask *task = &tasks[i]; | ParticleTask *task = &tasks[i]; | ||||
| psys_task_init_distribute(task, sim); | psys_task_init_distribute(task, sim); | ||||
| if (from == PART_FROM_CHILD) { | if (from == PART_FROM_CHILD) { | ||||
| BLI_task_pool_push(task_pool, exec_distribute_child, task, false, NULL); | BLI_task_pool_tbb_push(task_pool, exec_distribute_child, task, false, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_task_pool_push(task_pool, exec_distribute_parent, task, false, NULL); | BLI_task_pool_tbb_push(task_pool, exec_distribute_parent, 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_calc_dmcache(sim->ob, final_mesh, sim->psmd->mesh_original, sim->psys); | psys_calc_dmcache(sim->ob, final_mesh, sim->psmd->mesh_original, sim->psys); | ||||
| if (ctx.mesh != final_mesh) { | if (ctx.mesh != final_mesh) { | ||||
| BKE_id_free(NULL, ctx.mesh); | BKE_id_free(NULL, ctx.mesh); | ||||
| } | } | ||||
| psys_tasks_free(tasks, numtasks); | psys_tasks_free(tasks, numtasks); | ||||
| Show All 35 Lines | |||||