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

◆ initialize_particle_positions()

void MayaFlux::Nodes::Network::ParticleNetwork::initialize_particle_positions ( InitializationMode  mode)
private

Initialize particles based on mode.

Definition at line 547 of file ParticleNetwork.cpp.

548{
549 switch (mode) {
551 for (auto& particle : m_particles) {
552 particle.point->set_position(random_position_volume());
553 }
554 break;
555
557 for (auto& particle : m_particles) {
558 particle.point->set_position(random_position_surface());
559 }
560 break;
561
563 auto grid_size = static_cast<size_t>(std::cbrt(m_particles.size()));
564 glm::vec3 spacing = (m_bounds_max - m_bounds_min) / static_cast<float>(grid_size);
565
566 size_t idx = 0;
567 for (size_t x = 0; x < grid_size && idx < m_particles.size(); ++x) {
568 for (size_t y = 0; y < grid_size && idx < m_particles.size(); ++y) {
569 for (size_t z = 0; z < grid_size && idx < m_particles.size(); ++z) {
570 glm::vec3 pos = m_bounds_min + glm::vec3(x, y, z) * spacing;
571 m_particles[idx++].point->set_position(pos);
572 }
573 }
574 }
575 break;
576 }
577
579 glm::vec3 center = (m_bounds_min + m_bounds_max) * 0.5F;
580 float radius = glm::length(m_bounds_max - center);
581 for (auto& particle : m_particles) {
582 particle.point->set_position(center + random_position_sphere(radius));
583 }
584 break;
585 }
586
588 glm::vec3 center = (m_bounds_min + m_bounds_max) * 0.5F;
589 float radius = glm::length(m_bounds_max - center);
590 for (auto& particle : m_particles) {
591 particle.point->set_position(center + random_position_sphere_surface(radius));
592 }
593 break;
594 }
595
597 break;
598 }
599
601}
@ CUSTOM
User-provided initialization function.
glm::vec3 random_position_surface() const
Random position on bounds surface.
glm::vec3 random_position_sphere(float radius) const
Random position in sphere.
glm::vec3 random_position_volume() const
Random position in bounds volume.
glm::vec3 random_position_sphere_surface(float radius) const
Random position on sphere surface.
void update_point_nodes()
Update PointNode states from physics.

References CUSTOM, GRID, m_bounds_max, m_bounds_min, m_particles, random_position_sphere(), random_position_sphere_surface(), random_position_surface(), random_position_volume(), RANDOM_SURFACE, RANDOM_VOLUME, SPHERE_SURFACE, SPHERE_VOLUME, and update_point_nodes().

Referenced by initialize(), reinitialize_positions(), and reset().

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