Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle_system.c
| Show First 20 Lines • Show All 3,686 Lines • ▼ Show 20 Lines | typedef struct DynamicStepSolverTaskData { | ||||
| float cfra; | float cfra; | ||||
| float timestep; | float timestep; | ||||
| float dtime; | float dtime; | ||||
| SpinLock spin; | SpinLock spin; | ||||
| } DynamicStepSolverTaskData; | } DynamicStepSolverTaskData; | ||||
| static void dynamics_step_finalize_sphdata(void *__restrict UNUSED(userdata), | static void dynamics_step_sphdata_reduce(const void *__restrict UNUSED(userdata), | ||||
| void *__restrict tls_userdata_chunk) | void *__restrict UNUSED(join_v), | ||||
| void *__restrict chunk_v) | |||||
| { | { | ||||
| SPHData *sphdata = tls_userdata_chunk; | SPHData *sphdata = chunk_v; | ||||
| psys_sph_flush_springs(sphdata); | psys_sph_flush_springs(sphdata); | ||||
| } | } | ||||
| static void dynamics_step_sph_ddr_task_cb_ex(void *__restrict userdata, | static void dynamics_step_sph_ddr_task_cb_ex(void *__restrict userdata, | ||||
| const int p, | const int p, | ||||
| const TaskParallelTLS *__restrict tls) | const TaskParallelTLS *__restrict tls) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | case PART_PHYS_FLUID: { | ||||
| /* Apply SPH forces using double-density relaxation algorithm | /* Apply SPH forces using double-density relaxation algorithm | ||||
| * (Clavat et. al.) */ | * (Clavat et. al.) */ | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BLI_parallel_range_settings_defaults(&settings); | BLI_parallel_range_settings_defaults(&settings); | ||||
| settings.use_threading = (psys->totpart > 100); | settings.use_threading = (psys->totpart > 100); | ||||
| settings.userdata_chunk = &sphdata; | settings.userdata_chunk = &sphdata; | ||||
| settings.userdata_chunk_size = sizeof(sphdata); | settings.userdata_chunk_size = sizeof(sphdata); | ||||
| settings.func_finalize = dynamics_step_finalize_sphdata; | settings.func_reduce = dynamics_step_sphdata_reduce; | ||||
| BLI_task_parallel_range( | BLI_task_parallel_range( | ||||
| 0, psys->totpart, &task_data, dynamics_step_sph_ddr_task_cb_ex, &settings); | 0, psys->totpart, &task_data, dynamics_step_sph_ddr_task_cb_ex, &settings); | ||||
| sph_springs_modify(psys, timestep); | sph_springs_modify(psys, timestep); | ||||
| } | } | ||||
| else { | else { | ||||
| /* SPH_SOLVER_CLASSICAL */ | /* SPH_SOLVER_CLASSICAL */ | ||||
| /* Apply SPH forces using classical algorithm (due to Gingold | /* Apply SPH forces using classical algorithm (due to Gingold | ||||
| Show All 15 Lines | case PART_PHYS_FLUID: { | ||||
| /* Note that we could avoid copying sphdata for each thread here (it's only read here), | /* Note that we could avoid copying sphdata for each thread here (it's only read here), | ||||
| * but doubt this would gain us anything except confusion... */ | * but doubt this would gain us anything except confusion... */ | ||||
| { | { | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BLI_parallel_range_settings_defaults(&settings); | BLI_parallel_range_settings_defaults(&settings); | ||||
| settings.use_threading = (psys->totpart > 100); | settings.use_threading = (psys->totpart > 100); | ||||
| settings.userdata_chunk = &sphdata; | settings.userdata_chunk = &sphdata; | ||||
| settings.userdata_chunk_size = sizeof(sphdata); | settings.userdata_chunk_size = sizeof(sphdata); | ||||
| settings.func_finalize = dynamics_step_finalize_sphdata; | settings.func_reduce = dynamics_step_sphdata_reduce; | ||||
| BLI_task_parallel_range(0, | BLI_task_parallel_range(0, | ||||
| psys->totpart, | psys->totpart, | ||||
| &task_data, | &task_data, | ||||
| dynamics_step_sph_classical_calc_density_task_cb_ex, | dynamics_step_sph_classical_calc_density_task_cb_ex, | ||||
| &settings); | &settings); | ||||
| } | } | ||||
| /* do global forces & effectors */ | /* do global forces & effectors */ | ||||
| { | { | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BLI_parallel_range_settings_defaults(&settings); | BLI_parallel_range_settings_defaults(&settings); | ||||
| settings.use_threading = (psys->totpart > 100); | settings.use_threading = (psys->totpart > 100); | ||||
| settings.userdata_chunk = &sphdata; | settings.userdata_chunk = &sphdata; | ||||
| settings.userdata_chunk_size = sizeof(sphdata); | settings.userdata_chunk_size = sizeof(sphdata); | ||||
| settings.func_finalize = dynamics_step_finalize_sphdata; | settings.func_reduce = dynamics_step_sphdata_reduce; | ||||
| BLI_task_parallel_range(0, | BLI_task_parallel_range(0, | ||||
| psys->totpart, | psys->totpart, | ||||
| &task_data, | &task_data, | ||||
| dynamics_step_sph_classical_integrate_task_cb_ex, | dynamics_step_sph_classical_integrate_task_cb_ex, | ||||
| &settings); | &settings); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | #else | ||||
| FluidModifierData *mmd = (FluidModifierData *)modifiers_findByType(ob, eModifierType_Fluid); | FluidModifierData *mmd = (FluidModifierData *)modifiers_findByType(ob, eModifierType_Fluid); | ||||
| if (mmd && mmd->domain && mmd->domain->fluid) { | if (mmd && mmd->domain && mmd->domain->fluid) { | ||||
| FluidDomainSettings *mds = mmd->domain; | FluidDomainSettings *mds = mmd->domain; | ||||
| ParticleSettings *part = psys->part; | ParticleSettings *part = psys->part; | ||||
| ParticleData *pa = NULL; | ParticleData *pa = NULL; | ||||
| int p, totpart, tottypepart = 0; | int p, totpart = 0, tottypepart = 0; | ||||
| int flagActivePart, activeParts = 0; | int flagActivePart, activeParts = 0; | ||||
| float posX, posY, posZ, velX, velY, velZ; | float posX, posY, posZ, velX, velY, velZ; | ||||
| float resX, resY, resZ; | float resX, resY, resZ; | ||||
| int upres = 1; | int upres = 1; | ||||
| char debugStrBuffer[256]; | char debugStrBuffer[256]; | ||||
| float tmp[3] = {0}, tmp2[3] = {0}; | float tmp[3] = {0}, tmp2[3] = {0}; | ||||
| /* Helper variables for scaling. */ | /* Helper variables for scaling. */ | ||||
| ▲ Show 20 Lines • Show All 824 Lines • Show Last 20 Lines | |||||