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 501 Lines • ▼ Show 20 Lines | static void psys_task_init_distribute(ParticleTask *task, ParticleSimulationData *sim) | ||||
| /* init random number generator */ | /* init random number generator */ | ||||
| int seed = 31415926 + sim->psys->seed; | int seed = 31415926 + sim->psys->seed; | ||||
| task->rng = BLI_rng_new(seed); | task->rng = BLI_rng_new(seed); | ||||
| } | } | ||||
| static void distribute_particles_on_dm(ParticleSimulationData *sim, int from) | static void distribute_particles_on_dm(ParticleSimulationData *sim, int from) | ||||
| { | { | ||||
| TaskScheduler *task_scheduler; | |||||
| TaskPool *task_pool; | TaskPool *task_pool; | ||||
| ParticleThreadContext ctx; | ParticleThreadContext ctx; | ||||
| ParticleTask *tasks; | ParticleTask *tasks; | ||||
| 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_pool = BLI_task_pool_create(&ctx, TASK_PRIORITY_LOW); | ||||
| task_pool = BLI_task_pool_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) { | ||||
| ▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines | |||||