diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-14 18:45:49 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-01-14 18:45:49 +0100 |
| commit | bf498dca2c333bd66775005571ef915cf27c3ee8 (patch) | |
| tree | f528892036788a3ec8f28aa842cb5cb63a6790d3 /examples/particles_gpu/particles_gpu.cpp | |
| parent | 0651825aca44dc09b6aa4995280a65fed859cfc4 (diff) | |
| download | libs-lbm-bf498dca2c333bd66775005571ef915cf27c3ee8.tar.gz | |
Got physics working again
Diffstat (limited to 'examples/particles_gpu/particles_gpu.cpp')
| -rw-r--r-- | examples/particles_gpu/particles_gpu.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/particles_gpu/particles_gpu.cpp b/examples/particles_gpu/particles_gpu.cpp index dfd5af3..abbc192 100644 --- a/examples/particles_gpu/particles_gpu.cpp +++ b/examples/particles_gpu/particles_gpu.cpp @@ -42,12 +42,15 @@ saw::error_or<void> lbm_main(int argc, char** argv){ } } + saw::data<sch::Scalar<sch::Float32>> time_step; + time_step.at({}).set(0.05f); + for(saw::data<sch::UInt64> dt{0u}; dt < saw::data<sch::UInt64>{32ul}; ++dt){ // Do Verlet Step for(saw::data<sch::UInt64> i{0u}; i < particles.size(); ++i){ auto& part_i = particles.at(i); - verlet_step_lambda<sch::Float32,2u>(part_i,{0.05f}); + verlet_step_lambda<sch::Float32,2u>(part_i,time_step); auto& body_i = part_i.template get<"rigid_body">(); auto& acc_i = body_i.template get<"acceleration">(); @@ -70,23 +73,23 @@ saw::error_or<void> lbm_main(int argc, char** argv){ auto& pos_j = body_j.template get<"position">(); auto& pos_old_j = body_j.template get<"position_old">(); - auto res = broadphase_collision_distance<sch::Float32,2u>(part_i, part_j); + auto res = broadphase_collision_distance_squared<sch::Float32,2u>(part_i, part_j); if(res.first){ //std::cout<<"Collision"<<std::endl; // Do collision - auto vel_i = pos_i - pos_old_i; - auto vel_j = pos_j - pos_old_j; + auto vel_i = (pos_i - pos_old_i)/time_step; + auto vel_j = (pos_j - pos_old_j)/time_step; auto vel_rel = vel_i - vel_j; auto pos_rel = pos_i - pos_j; auto vel_pos_rel_dot = saw::math::dot(vel_rel,pos_rel); if(vel_pos_rel_dot.at({}).get() < 0.0){ - + auto pos_rel_normed = pos_rel / saw::math::sqrt(res.second); } - auto vel_ij = saw::math::dot(vel_i,vel_j); + // auto vel_ij = saw::math::dot(vel_i,vel_j); } } |
