diff --git a/src/services/model_preview/model_preview_service.cpp b/src/services/model_preview/model_preview_service.cpp index 4566c7da..8a5f8d37 100644 --- a/src/services/model_preview/model_preview_service.cpp +++ b/src/services/model_preview/model_preview_service.cpp @@ -131,6 +131,8 @@ namespace big g_fiber_pool->queue_job([this] { m_loop_running = true; + m_heading = 0; + start_time = std::chrono::steady_clock::now(); while (g_running && m_running && g_gui->is_open() && (m_ped_model_hash || m_veh_model_hash || !m_current_persisted_vehicle_name.empty())) { @@ -204,10 +206,11 @@ namespace big ENTITY::SET_ENTITY_COORDS(m_current_ent, location.x, location.y, location.z, 0, 0, 0, 0); } - if (m_heading += 0.11111f; m_heading > 359) - { - m_heading = 0; - } + auto now = std::chrono::steady_clock::now(); + auto elapsed_time = std::chrono::duration_cast(now - start_time).count() / 1000.0; // Convert to seconds + + m_heading = (elapsed_time / 10.0) * 360.0; // Rotate 360 degrees every 10 seconds + m_heading = fmod(m_heading, 360.0); // Ensure rotation is always between 0 and 360 script::get_current()->yield(); } diff --git a/src/services/model_preview/model_preview_service.hpp b/src/services/model_preview/model_preview_service.hpp index 2571f917..e3154b65 100644 --- a/src/services/model_preview/model_preview_service.hpp +++ b/src/services/model_preview/model_preview_service.hpp @@ -5,9 +5,6 @@ namespace big { class model_preview_service { - std::condition_variable m_cond; - std::mutex m_mutex; - Entity m_current_ent = 0; Hash m_veh_model_hash = 0; @@ -24,6 +21,8 @@ namespace big std::string m_current_persisted_vehicle_name; + std::chrono::time_point start_time; + public: model_preview_service(); ~model_preview_service(); @@ -36,7 +35,10 @@ namespace big void show_vehicle_persisted(std::string vehicle_name); void show_vehicle(Vehicle veh); + private: void preview_loop(); + + public: void stop_preview(); };