MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ handle_bounds()

void MayaFlux::Nodes::Network::ParticleNetwork::handle_bounds ( )
private

Handle boundary conditions.

Definition at line 435 of file ParticleNetwork.cpp.

436{
438 return;
439 }
440
441 for (auto& particle : m_particles) {
442 glm::vec3 pos = particle.point->get_position();
443 bool out_of_bounds = false;
444
445 for (int axis = 0; axis < 3; ++axis) {
446 if (pos[axis] < m_bounds_min[axis] || pos[axis] > m_bounds_max[axis]) {
447 out_of_bounds = true;
448
449 switch (m_bounds_mode) {
451 if (pos[axis] < m_bounds_min[axis]) {
452 pos[axis] = m_bounds_min[axis];
453 particle.velocity[axis] = -particle.velocity[axis] * 0.8F; // Energy loss
454 } else if (pos[axis] > m_bounds_max[axis]) {
455 pos[axis] = m_bounds_max[axis];
456 particle.velocity[axis] = -particle.velocity[axis] * 0.8F;
457 }
458 break;
459
460 case BoundsMode::WRAP:
461 if (pos[axis] < m_bounds_min[axis]) {
462 pos[axis] = m_bounds_max[axis];
463 } else if (pos[axis] > m_bounds_max[axis]) {
464 pos[axis] = m_bounds_min[axis];
465 }
466 break;
467
469 pos[axis] = glm::clamp(pos[axis], m_bounds_min[axis], m_bounds_max[axis]);
470 particle.velocity[axis] = 0.0F;
471 break;
472
475 particle.velocity = glm::vec3(0.0F);
476 break;
477
478 case BoundsMode::NONE:
479 break;
480 }
481 }
482 }
483
484 if (out_of_bounds) {
485 particle.point->set_position(pos);
486 }
487 }
488}
glm::vec3 random_position_volume() const
Random position in bounds volume.
@ DESTROY
Remove particle at boundary (respawn optional)

References BOUNCE, CLAMP, DESTROY, m_bounds_max, m_bounds_min, m_bounds_mode, m_particles, NONE, random_position_volume(), and WRAP.

Referenced by process_batch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: