diff --git a/psystem b/psystem index e5756f1..b39fa10 100755 Binary files a/psystem and b/psystem differ diff --git a/pthread_barrier.h b/pthread_barrier.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/main.cpp b/source/main.cpp index ef2f1a3..ebabd3b 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -31,7 +31,7 @@ const unsigned int SCR_WIDTH = 2560; const unsigned int SCR_HEIGHT = 1440; const char *glsl_version; -const unsigned int PARTICLE_COUNT = 8; +const unsigned int PARTICLE_COUNT = 10000; GLFWwindow *window; unsigned int VBO, VAO; @@ -48,6 +48,7 @@ pthread_barrier_t barrier; // INFO: Debug views toggles bool viewThreads = 0; +bool enablePhysics = 1; static void cursor_callback(GLFWwindow *w, double xpos, double ypos) { #ifndef NDEBUG @@ -246,7 +247,7 @@ int main() { default_particle_color[i] = {x, y, z, 255.0f}; particles[i] = particle_init({x, y, z}, {x, y, z, 255.0f}); - particles[i].radius = (float)(rand() % 50) / 1000.0f; + particles[i].radius = (float)((rand() % 5) + 5) / 1000.0f; } /* @@ -309,21 +310,23 @@ int main() { glm::mat4 projection = camera_projection(camera, aspect); glm::mat4 mvp = projection * view; // model is identity - pthread_mutex_lock(&mutex); - for (int i = 0; i < THREAD_COUNT; i++) { - thread_params[i].time = delta_time; - thread_params[i].run = 1; + if (enablePhysics) { + pthread_mutex_lock(&mutex); + for (int i = 0; i < THREAD_COUNT; i++) { + thread_params[i].time = delta_time; + thread_params[i].run = 1; + } + pthread_cond_broadcast(&cond); + pthread_mutex_unlock(&mutex); + + pthread_barrier_wait(&barrier); + + alive_count = 0; + for (int i = 0; i < THREAD_COUNT; i++) + alive_count += thread_params[i].alive_count; + + // collision_update(particles, alive_count, 0.3f); } - pthread_cond_broadcast(&cond); - pthread_mutex_unlock(&mutex); - - pthread_barrier_wait(&barrier); - - alive_count = 0; - for (int i = 0; i < THREAD_COUNT; i++) - alive_count += thread_params[i].alive_count; - - // collision_update(particles, alive_count, 0.3f); // Render glClearColor(0.03f, 0.03f, 0.03f, 1.0f); @@ -368,6 +371,15 @@ int main() { snprintf(errLog, 128, "Switched views to thread view\n"); } } + + if (ImGui::Checkbox("Enable Physics", &enablePhysics)) { + if (!enablePhysics) { + snprintf(errLog, 128, "Disabled phyics\n"); + } else { + snprintf(errLog, 128, "Enable physics\n"); + } + } + ImGui::End(); // Render ImGui @@ -389,7 +401,7 @@ int main() { free(threads); free(thread_params); free(particles); - free(default_particle_color); + free(default_particle_color); ImGui_ImplGlfw_Shutdown(); ImGui_ImplOpenGL3_Shutdown();