Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/ocean.c
| Show First 20 Lines • Show All 674 Lines • ▼ Show 20 Lines | void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount) | ||||
| scale *= o->normalize_factor; | scale *= o->normalize_factor; | ||||
| osd.o = o; | osd.o = o; | ||||
| osd.t = t; | osd.t = t; | ||||
| osd.scale = scale; | osd.scale = scale; | ||||
| osd.chop_amount = chop_amount; | osd.chop_amount = chop_amount; | ||||
| pool = BLI_task_pool_create(scheduler, &osd); | pool = BLI_task_pool_create(scheduler, &osd, TASK_PRIORITY_HIGH); | ||||
| BLI_rw_mutex_lock(&o->oceanmutex, THREAD_LOCK_WRITE); | BLI_rw_mutex_lock(&o->oceanmutex, THREAD_LOCK_WRITE); | ||||
| /* Note about multi-threading here: we have to run a first set of computations (htilda one) | /* Note about multi-threading here: we have to run a first set of computations (htilda one) | ||||
| * before we can run all others, since they all depend on it. | * before we can run all others, since they all depend on it. | ||||
| * So we make a first parallelized forloop run for htilda, | * So we make a first parallelized forloop run for htilda, | ||||
| * and then pack all other computations into a set of parallel tasks. | * and then pack all other computations into a set of parallel tasks. | ||||
| * This is not optimal in all cases, | * This is not optimal in all cases, | ||||
| * but remains reasonably simple and should be OK most of the time. */ | * but remains reasonably simple and should be OK most of the time. */ | ||||
| /* compute a new htilda */ | /* compute a new htilda */ | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BLI_parallel_range_settings_defaults(&settings); | BLI_parallel_range_settings_defaults(&settings); | ||||
| settings.use_threading = (o->_M > 16); | settings.use_threading = (o->_M > 16); | ||||
| BLI_task_parallel_range(0, o->_M, &osd, ocean_compute_htilda, &settings); | BLI_task_parallel_range(0, o->_M, &osd, ocean_compute_htilda, &settings); | ||||
| if (o->_do_disp_y) { | if (o->_do_disp_y) { | ||||
| BLI_task_pool_push(pool, ocean_compute_displacement_y, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_displacement_y, NULL, false, NULL); | ||||
| } | } | ||||
| if (o->_do_chop) { | if (o->_do_chop) { | ||||
| BLI_task_pool_push(pool, ocean_compute_displacement_x, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_displacement_x, NULL, false, NULL); | ||||
| BLI_task_pool_push(pool, ocean_compute_displacement_z, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_displacement_z, NULL, false, NULL); | ||||
| } | } | ||||
| if (o->_do_jacobian) { | if (o->_do_jacobian) { | ||||
| BLI_task_pool_push(pool, ocean_compute_jacobian_jxx, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_jacobian_jxx, NULL, false, NULL); | ||||
| BLI_task_pool_push(pool, ocean_compute_jacobian_jzz, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_jacobian_jzz, NULL, false, NULL); | ||||
| BLI_task_pool_push(pool, ocean_compute_jacobian_jxz, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_jacobian_jxz, NULL, false, NULL); | ||||
| } | } | ||||
| if (o->_do_normals) { | if (o->_do_normals) { | ||||
| BLI_task_pool_push(pool, ocean_compute_normal_x, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_normal_x, NULL, false, NULL); | ||||
| BLI_task_pool_push(pool, ocean_compute_normal_z, NULL, false, TASK_PRIORITY_HIGH); | BLI_task_pool_push(pool, ocean_compute_normal_z, NULL, false, NULL); | ||||
| o->_N_y = 1.0f / scale; | o->_N_y = 1.0f / scale; | ||||
| } | } | ||||
| BLI_task_pool_work_and_wait(pool); | BLI_task_pool_work_and_wait(pool); | ||||
| BLI_rw_mutex_unlock(&o->oceanmutex); | BLI_rw_mutex_unlock(&o->oceanmutex); | ||||
| BLI_task_pool_free(pool); | BLI_task_pool_free(pool); | ||||
| ▲ Show 20 Lines • Show All 913 Lines • Show Last 20 Lines | |||||