| 371 | } |
| 372 | |
| 373 | void SceneParser::dispatch_texture_loading(Scene& parsed_scene, const std::string& scene_path, int nb_threads, const std::vector<std::pair<aiTextureType, std::string>>& texture_paths, const std::vector<int>& material_indices) |
| 374 | { |
| 375 | if (nb_threads == -1) |
| 376 | // As many threads as there are textures if -1 was given |
| 377 | nb_threads = texture_paths.size(); |
| 378 | |
| 379 | // Creating a state to keep the data that the threads need alive |
| 380 | std::shared_ptr<TextureLoadingThreadState> texture_threads_state = std::make_shared<TextureLoadingThreadState>(); |
| 381 | texture_threads_state->scene_filepath = scene_path; |
| 382 | texture_threads_state->texture_paths = texture_paths; |
| 383 | texture_threads_state->material_indices = material_indices; |
| 384 | |
| 385 | ThreadManager::set_thread_data(ThreadManager::SCENE_TEXTURES_LOADING_THREAD_KEY, texture_threads_state); |
| 386 | |
| 387 | for (int i = 0; i < nb_threads; i++) |
| 388 | ThreadManager::start_thread(ThreadManager::SCENE_TEXTURES_LOADING_THREAD_KEY, ThreadFunctions::load_scene_texture, std::ref(parsed_scene), texture_threads_state->scene_filepath, std::ref(texture_threads_state->texture_paths), std::ref(texture_threads_state->material_indices), i, nb_threads); |
| 389 | } |
| 390 | |
| 391 | void SceneParser::read_material_properties(aiMaterial* mesh_material, CPUMaterial& renderer_material) |
| 392 | { |