Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,17 @@ set(SOURCE_FILES
${FUNGT_BASE_DIR}/GUI/gui.cpp
${FUNGT_BASE_DIR}/GUI/particle_rtc_window.cpp
${FUNGT_BASE_DIR}/GUI/physics/simulation_controller_window.cpp
${FUNGT_BASE_DIR}/GUI/demo_particles_window.cpp
${FUNGT_BASE_DIR}/GUI/render_action_window.cpp
${FUNGT_BASE_DIR}/GUI/physics/debug_rigidbody_renderer.cpp
${FUNGT_BASE_DIR}/SimpleModel/simple_model.cpp
${FUNGT_BASE_DIR}/SimpleGeometry/simple_geometry.cpp
${FUNGT_BASE_DIR}/Physics/Collisions/simple_collision.cpp
${FUNGT_BASE_DIR}/Physics/Collisions/manifold_collision.cpp
${FUNGT_BASE_DIR}/Physics/CollisionManager/collision_manager.cpp
${FUNGT_BASE_DIR}/Physics/Collider/collider.cpp
${FUNGT_BASE_DIR}/Physics/Clothing/clothing.cpp
${FUNGT_BASE_DIR}/Physics/AnimationCreator/key_frame_recorder.cpp
${FUNGT_BASE_DIR}/Physics/AnimationCreator/animation_exporter.cpp
${FUNGT_BASE_DIR}/ViewPort/viewport.cpp
${FUNGT_BASE_DIR}/ViewPort/progressive_path_tracer_viewport.cpp
${FUNGT_BASE_DIR}/Renders/framebuffer.cpp
Expand Down Expand Up @@ -494,9 +496,24 @@ elseif (UNIX)
else()
set(SYCL_TARGETS spir64)
endif()
target_compile_options(FunGT PRIVATE -fsycl -fsycl-targets=${SYCL_TARGETS})
set(SYCL_SOURCES
${FUNGT_BASE_DIR}/InfoDevice/sycl_backend.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_simulation.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_simulation_rtc.cpp
${FUNGT_BASE_DIR}/Physics/AnimationCreator/animation_exporter.cpp
${FUNGT_BASE_DIR}/GUI/demo_particles_window.cpp
${FUNGT_BASE_DIR}/GUI/particle_rtc_window.cpp
${FUNGT_BASE_DIR}/GUI/demo_particles_window.cpp
${FUNGT_BASE_DIR}/GUI/render_action_window.cpp
${FUNGT_BASE_DIR}/PBR/Space/space.cpp
${FUNGT_BASE_DIR}/PBR/TriangleExtractor/triangle_extractor.cpp
${FUNGT_BASE_DIR}/ViewPort/progressive_path_tracer_viewport.cpp
)

set_source_files_properties(${SYCL_SOURCES}
PROPERTIES COMPILE_FLAGS "-fsycl -fsycl-targets=${SYCL_TARGETS}"
)
target_link_options(FunGT PRIVATE -fsycl -fsycl-targets=${SYCL_TARGETS})

if(FUNGT_USE_SYCL)
target_compile_definitions(FunGT PRIVATE FUNGT_USE_SYCL)
endif()
Expand Down
1 change: 1 addition & 0 deletions ComputationalGeom/aabb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Vector/vector3.hpp"
#include "gpu/include/fgt_cpu_device.hpp"
#include <cmath>
#include <cfloat>
class AABB {

public:
Expand Down
79 changes: 79 additions & 0 deletions GUI/demo_particles_window.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "demo_particles_window.hpp"
#include "ParticleSimulation/particle_simulation.hpp"
#include "ParticleSimulation/particle_demos.hpp"

void ParticleSimDemoWindow::onImGuiRender() {
m_frameCount++;
auto currentTime = std::chrono::high_resolution_clock::now();
float elapsed = std::chrono::duration<float>(currentTime - m_lastFPSTime).count();

if (elapsed >= 0.5f) {
m_measuredFPS = m_frameCount / elapsed;
m_frameCount = 0;
m_lastFPSTime = currentTime;
}

ImGui::Begin("Particle Demos");

if (!m_sceneManager) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No scene manager");
ImGui::End();
return;
}

const auto& allObjects = m_sceneManager->getRenderable();
std::shared_ptr<ParticleSimulation> particleSim = nullptr;

for (auto& obj : allObjects) {
auto sim = std::dynamic_pointer_cast<ParticleSimulation>(obj);
if (sim) {
particleSim = sim;
break;
}
}

if (!particleSim) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No particle simulation");
ImGui::End();
return;
}

ImGui::TextColored(ImVec4(0.4f, 0.7f, 1.0f, 1.0f), "Active:");
ImGui::SameLine();
ImGui::Text("%s", fgt::demoNames[particleSim->getCurrentDemo()].c_str());
ImGui::Separator();

if (ImGui::BeginCombo("##Demo", fgt::demoNames[m_selectedDemoIndex].c_str())) {
for (size_t i = 0; i < fgt::demoNames.size(); i++) {
bool isSelected = (m_selectedDemoIndex == static_cast<int>(i));
if (ImGui::Selectable(fgt::demoNames[i].c_str(), isSelected)) {
m_selectedDemoIndex = static_cast<int>(i);
if (m_autoApply) {
particleSim->loadDemo(m_selectedDemoIndex);
}
}
if (isSelected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}

ImGui::TextWrapped("%s", m_descriptions[m_selectedDemoIndex].c_str());

if (ImGui::Button("Load Demo", ImVec2(-1, 0))) {
particleSim->loadDemo(m_selectedDemoIndex);
}

ImGui::Checkbox("Auto-load", &m_autoApply);

if (ImGui::CollapsingHeader("Info")) {
ImGui::Text("Particles: %zu", particleSim->getParticleCount());
ImGui::Text("Measured FPS: %.1f", m_measuredFPS);
ImGui::Text("ImGui FPS: %.1f", ImGui::GetIO().Framerate);
ImGui::Text("Frame time: %.2f ms", 1000.0f / m_measuredFPS);
ImGui::Text("Recommended: %d", m_recommendedCounts[m_selectedDemoIndex]);
}

ImGui::End();
}
89 changes: 5 additions & 84 deletions GUI/demo_particles_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
#define _PARTICLE_SIM_DEMO_WINDOW_H_
#include "imgui_window.hpp"
#include "SceneManager/scene_manager.hpp"
#include "ParticleSimulation/particle_simulation.hpp"
#include "ParticleSimulation/particle_demos.hpp"
#include <memory>
#include <chrono>
#include <vector>
#include <string>

class ParticleSimulation;

class ParticleSimDemoWindow : public ImGuiWindow {
private:
std::shared_ptr<SceneManager> m_sceneManager;
int m_selectedDemoIndex;
bool m_autoApply;

// FPS measurement
std::chrono::high_resolution_clock::time_point m_lastFPSTime;
int m_frameCount;
float m_measuredFPS;
Expand Down Expand Up @@ -42,87 +43,7 @@ class ParticleSimDemoWindow : public ImGuiWindow {
{
}

void onImGuiRender() override {
// Measure FPS
m_frameCount++;
auto currentTime = std::chrono::high_resolution_clock::now();
float elapsed = std::chrono::duration<float>(currentTime - m_lastFPSTime).count();

if (elapsed >= 0.5f) { // Update twice per second for smooth display
m_measuredFPS = m_frameCount / elapsed;
m_frameCount = 0;
m_lastFPSTime = currentTime;
}

ImGui::Begin("Particle Demos");

if (!m_sceneManager) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No scene manager");
ImGui::End();
return;
}

const auto& allObjects = m_sceneManager->getRenderable();
std::shared_ptr<ParticleSimulation> particleSim = nullptr;

for (auto& obj : allObjects) {
auto sim = std::dynamic_pointer_cast<ParticleSimulation>(obj);
if (sim) {
particleSim = sim;
break;
}
}

if (!particleSim) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No particle simulation");
ImGui::End();
return;
}

// Current demo indicator (compact)
ImGui::TextColored(ImVec4(0.4f, 0.7f, 1.0f, 1.0f), "Active:");
ImGui::SameLine();
ImGui::Text("%s", fgt::demoNames[particleSim->getCurrentDemo()].c_str());
ImGui::Separator();

// Demo selection
if (ImGui::BeginCombo("##Demo", fgt::demoNames[m_selectedDemoIndex].c_str())) {
for (int i = 0; i < fgt::demoNames.size(); i++) {
bool isSelected = (m_selectedDemoIndex == i);
if (ImGui::Selectable(fgt::demoNames[i].c_str(), isSelected)) {
m_selectedDemoIndex = i;
if (m_autoApply) {
particleSim->loadDemo(m_selectedDemoIndex);
}
}
if (isSelected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}

// Compact description
ImGui::TextWrapped("%s", m_descriptions[m_selectedDemoIndex].c_str());

// Load button
if (ImGui::Button("Load Demo", ImVec2(-1, 0))) {
particleSim->loadDemo(m_selectedDemoIndex);
}

ImGui::Checkbox("Auto-load", &m_autoApply);

// Collapsing info section
if (ImGui::CollapsingHeader("Info")) {
ImGui::Text("Particles: %zu", particleSim->getParticleCount());
ImGui::Text("Measured FPS: %.1f", m_measuredFPS);
ImGui::Text("ImGui FPS: %.1f", ImGui::GetIO().Framerate);
ImGui::Text("Frame time: %.2f ms", 1000.0f / m_measuredFPS);
ImGui::Text("Recommended: %d", m_recommendedCounts[m_selectedDemoIndex]);
}

ImGui::End();
}
void onImGuiRender() override;
};

#endif // _PARTICLE_SIM_DEMO_WINDOW_H_
7 changes: 5 additions & 2 deletions GUI/imgui_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "imgui_window.hpp"
#include "Layer/layer.hpp"
#include "InfoDevice/gpu_device_info.hpp"
#include "Path_Manager/path_manager.hpp"
#include "render_settings_window.hpp"
#include <memory>

Expand Down Expand Up @@ -191,8 +192,10 @@ class ImGuiLayer : public Layer {
io.Fonts->Clear();

// Load your font file (TTF)
//
std::string fontPath = getAssetPath("GUI/fonts/Nunito/static/Nunito-Regular.ttf");
ImFont* myFont = io.Fonts->AddFontFromFileTTF(
"/home/juanchuletas/Documents/Development/FunGT/GUI/fonts/Nunito/static/Nunito-Regular.ttf", 18.0f
fontPath.c_str(), 18.0f
);

if (myFont == nullptr)
Expand Down Expand Up @@ -358,4 +361,4 @@ class ImGuiLayer : public Layer {
}
};

#endif // _IMGUI_LAYER_H_
#endif // _IMGUI_LAYER_H_
1 change: 1 addition & 0 deletions GUI/particle_rtc_window.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "particle_rtc_window.hpp"
#include "ParticleSimulation/particle_simulation_rtc.hpp"
#include <imgui.h>
#include <curl/curl.h>
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
Expand Down
3 changes: 1 addition & 2 deletions GUI/particle_rtc_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
#define PARTICLE_RTC_WINDOW_HPP

#include "GUI/imgui_window.hpp"
#include "ParticleSimulation/particle_simulation_rtc.hpp"
#include <string>
#include <future>
#include <atomic>
#include <memory>


class ParticleRTC;



Expand Down
Loading