@@ -21,24 +21,41 @@ namespace Tetragrama::Components
21
21
std::string DockspaceUIComponent::s_asset_importer_report_msg = " " ;
22
22
float DockspaceUIComponent::s_editor_scene_serializer_progress = 0 .0f ;
23
23
24
- DockspaceUIComponent::DockspaceUIComponent () : m_asset_importer(CreateScope<Importers::AssimpImporter>()), m_editor_serializer(CreateScope<Serializers::EditorSceneSerializer>()) {}
24
+ DockspaceUIComponent::DockspaceUIComponent () {}
25
25
26
26
DockspaceUIComponent::~DockspaceUIComponent () {}
27
27
28
28
void DockspaceUIComponent::Initialize (Layers::ImguiLayer* parent, const char * name, bool visibility, bool closed)
29
29
{
30
30
UIComponent::Initialize (parent, name, visibility, closed);
31
31
32
- m_dockspace_node_flag = ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_PassthruCentralNode ;
33
- m_window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus ;
32
+ m_asset_importer = ZPushStructCtor (&(parent-> LayerArena ), Importers::AssimpImporter) ;
33
+ m_editor_serializer = ZPushStructCtor (&(parent-> LayerArena ), Serializers::EditorSceneSerializer) ;
34
34
35
- auto context = reinterpret_cast <EditorContext*>(ParentLayer->ParentContext );
36
- m_editor_serializer->Context = context;
37
- m_asset_importer->Context = context;
35
+ m_editor_serializer->Initialize (&(parent->LayerArena ));
36
+ m_asset_importer->Initialize (&(parent->LayerArena ));
38
37
39
- const auto & editor_config = *context-> ConfigurationPtr ;
38
+ m_editor_serializer-> AssetImporter = m_asset_importer ;
40
39
41
- m_default_import_configuration = {.OutputModelFilePath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.SceneDataPath ), .OutputMeshFilePath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.SceneDataPath ), .OutputTextureFilesPath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.DefaultImportTexturePath ), .OutputMaterialsPath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.SceneDataPath )};
40
+ m_dockspace_node_flag = ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_PassthruCentralNode;
41
+ m_window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
42
+
43
+ auto context = reinterpret_cast <EditorContext*>(ParentLayer->ParentContext );
44
+ m_editor_serializer->Context = context;
45
+ m_asset_importer->Context = context;
46
+
47
+ const auto & editor_config = *context->ConfigurationPtr ;
48
+
49
+ auto o_model_fpath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.SceneDataPath );
50
+ auto o_mesh_fpath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.SceneDataPath );
51
+ auto o_texture_fpath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.DefaultImportTexturePath );
52
+ auto o_material_fpath = fmt::format (" {0}/{1}" , editor_config.WorkingSpacePath , editor_config.SceneDataPath );
53
+
54
+ m_default_import_configuration = {};
55
+ m_default_import_configuration.OutputModelFilePath .init (&(parent->LayerArena ), o_model_fpath.c_str ());
56
+ m_default_import_configuration.OutputMeshFilePath .init (&(parent->LayerArena ), o_mesh_fpath.c_str ());
57
+ m_default_import_configuration.OutputTextureFilesPath .init (&(parent->LayerArena ), o_texture_fpath.c_str ());
58
+ m_default_import_configuration.OutputMaterialsPath .init (&(parent->LayerArena ), o_material_fpath.c_str ());
42
59
43
60
#ifdef _WIN32
44
61
std::replace (m_default_import_configuration.OutputModelFilePath .begin (), m_default_import_configuration.OutputModelFilePath .end (), ' /' , ' \\ ' );
@@ -305,8 +322,8 @@ namespace Tetragrama::Components
305
322
306
323
if (ImGui::Button (" Save" , ImVec2 (80 , 0 )) && is_save_button_enabled)
307
324
{
308
- auto context = reinterpret_cast <EditorContext*>(ParentLayer->ParentContext );
309
- ZEngine::Helpers::secure_strcpy ( context->CurrentScenePtr ->Name , 50 , s_save_as_input_buffer) ;
325
+ auto context = reinterpret_cast <EditorContext*>(ParentLayer->ParentContext );
326
+ context->CurrentScenePtr ->Name = s_save_as_input_buffer;
310
327
m_editor_serializer->Serialize (context->CurrentScenePtr );
311
328
312
329
m_open_save_scene_as = false ;
@@ -422,7 +439,7 @@ namespace Tetragrama::Components
422
439
// {
423
440
// data.SerializedModelPath.replace(data.SerializedModelPath.find(ws), ws.size(), "");
424
441
// }
425
-
442
+ //
426
443
// context_ptr->CurrentScenePtr->Push(data.SerializedMeshesPath, data.SerializedModelPath, data.SerializedMaterialsPath);
427
444
}
428
445
@@ -513,8 +530,9 @@ namespace Tetragrama::Components
513
530
auto ctx = reinterpret_cast <EditorContext*>(context);
514
531
515
532
// Todo : Ensure no data race on CurrentScenePtr
516
- ZEngine::Helpers::secure_strcpy (ctx->CurrentScenePtr -> Name , 50 , scene.Name );
533
+ ZEngine::Helpers::secure_strcpy (ctx->ConfigurationPtr -> ActiveSceneName , ZEngine::Helpers::secure_strlen (scene. Name ) , scene.Name );
517
534
535
+ ctx->CurrentScenePtr ->Name = ctx->ConfigurationPtr ->ActiveSceneName ;
518
536
ctx->CurrentScenePtr ->Data = scene.Data ;
519
537
ctx->CurrentScenePtr ->MeshFiles = scene.MeshFiles ;
520
538
ctx->CurrentScenePtr ->ModelFiles = scene.ModelFiles ;
@@ -552,11 +570,11 @@ namespace Tetragrama::Components
552
570
{
553
571
if (!filename.empty ())
554
572
{
555
- auto parent_path = std::filesystem::path (filename).parent_path ().string ();
556
- auto asset_name = fs::path (filename).filename ().replace_extension ().string ();
557
- auto import_config = m_default_import_configuration;
558
- import_config.AssetFilename = asset_name;
559
- import_config.InputBaseAssetFilePath = parent_path;
573
+ auto parent_path = std::filesystem::path (filename).parent_path ().string ();
574
+ auto asset_name = fs::path (filename).filename ().replace_extension ().string ();
575
+ auto import_config = m_default_import_configuration;
576
+ import_config.AssetFilename . init (&(ParentLayer-> LayerArena ), asset_name. c_str ()) ;
577
+ import_config.InputBaseAssetFilePath . init (&(ParentLayer-> LayerArena ), parent_path. c_str ()) ;
560
578
co_await m_asset_importer->ImportAsync (filename, import_config);
561
579
}
562
580
co_return ;
0 commit comments