Skip to content

Commit

Permalink
Auto select strongest attractor when mutual attraction is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Yilmaz4 committed Jun 21, 2024
1 parent f11ed26 commit a251f2e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ struct Scene {
float central_temperature = 3e+3;
float central_luminosity = 15.f;

bool prevent_overlap = true;
bool prevent_overlap = false;
};

struct Controls {
Expand Down Expand Up @@ -1370,7 +1370,7 @@ class NBodiment {
ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoMove
)) {
ImGui::SliderInt("# Particles", &scene.num_particles, 0, 10000, "%d", ImGuiSliderFlags_Logarithmic);
ImGui::SliderInt("# Particles", &scene.num_particles, 0, mutual_attraction ? 10000 : 400000, "%d", ImGuiSliderFlags_Logarithmic);
ImGui::DragFloatRange2("Distance", &scene.min_distance, &scene.max_distance, scene.max_distance / 10.f, FLT_MIN, FLT_MAX, "%.9g m", nullptr, ImGuiSliderFlags_AlwaysClamp);
ImGui::DragFloatRange2("Mass", &scene.min_mass, &scene.max_mass, scene.max_mass / 10.f, FLT_MIN, FLT_MAX, "%.9g kg", nullptr, ImGuiSliderFlags_AlwaysClamp);
ImGui::DragFloatRange2("Density", &scene.min_density, &scene.max_density, scene.max_density / 10.f, FLT_MIN, FLT_MAX, u8"%.9g kg/m³", nullptr, ImGuiSliderFlags_AlwaysClamp);
Expand Down Expand Up @@ -1707,6 +1707,12 @@ class NBodiment {
if (lockedToParticle && i == following) continue;
Particle p = pBuffer[i];
current_avgKineticEnergy += p.mass * pow(glm::length(p.vel), 2) / (2 * pBuffer.size());
if (p.mass > pBuffer[strongestAttractor].mass) {
strongestAttractor = i;
cmptshader->use();
glUniform1i(glGetUniformLocation(cmptshader->id, "strongestAttractor"), strongestAttractor);
shader->use();
}

glm::vec3 origin = camera.position - p.pos;
float a = glm::dot(direction, direction);
Expand Down

0 comments on commit a251f2e

Please sign in to comment.