Skip to content

Commit c888dd5

Browse files
Merge pull request #3 from shreyaspranav/main
chore: Cleanup of other branches to the main branch
2 parents 2720d87 + 8566ea2 commit c888dd5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1282
-109
lines changed

core/Xen/Xen.premake.lua

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ project "Xen"
22

33
kind "ConsoleApp"
44
language "C++"
5-
staticruntime "on"
5+
staticruntime "off"
66

77
targetdir ("%{wks.location}/bin/" .. bin_folder .. "/bin/%{prj.name}")
88
objdir ("%{wks.location}/bin/" .. bin_folder .. "/obj/%{prj.name}")
@@ -41,7 +41,8 @@ project "Xen"
4141
}
4242

4343
defines {
44-
"EDITOR_RESOURCES=\"%{EDITOR_RESOURCES_PATH}\""
44+
"EDITOR_RESOURCES=\"%{EDITOR_RESOURCES_PATH}\"",
45+
"PROJECTS=\"%{PROJECTS_PATH}\""
4546
}
4647

4748
filter "files:deps/ImGuizmo/*.cpp"
@@ -72,10 +73,12 @@ project "Xen"
7273
filter "configurations:Debug"
7374
defines {"XEN_DEBUG", "XEN_LOG_ON"}
7475
symbols "On"
76+
-- buildoptions "/MTd"
7577

7678
filter "configurations:Release_Debug"
7779
defines {"XEN_RELEASE", "XEN_LOG_ON"}
7880
optimize "On"
81+
-- buildoptions "/MT"
7982

8083
filter "configurations:Production"
8184
kind "WindowedApp"
@@ -107,14 +110,20 @@ project "Xen"
107110

108111
filter { "system:windows", "configurations:Debug" }
109112
links {
110-
"%{Library.ShaderC_Debug}"
113+
"%{Library.ShaderC_Debug}",
114+
"%{Library.SpirVCrossCore_Debug}",
115+
"%{Library.SpirVCrossGLSL_Debug}"
111116
}
112117
filter { "system:windows", "configurations:Release_Debug" }
113118
links {
114-
"%{Library.ShaderC_Release}"
119+
"%{Library.ShaderC_Release}",
120+
"%{Library.SpirVCrossCore_Release}",
121+
"%{Library.SpirVCrossGLSL_Release}"
115122
}
116123
filter { "system:windows", "configurations:Production" }
117124
links {
118-
"%{Library.ShaderC_Release}"
125+
"%{Library.ShaderC_Release}",
126+
"%{Library.SpirVCrossCore_Release}",
127+
"%{Library.SpirVCrossGLSL_Release}",
119128
}
120129

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "AssetResourceManager.h"
2+
3+
#include <project/ProjectManager.h>
4+
#include <core/asset/AssetManagerUtil.h>
5+
6+
struct AssetResourceManagerData
7+
{
8+
std::filesystem::path assetPath;
9+
Xen::Ref<Xen::EditorAssetManager> assetManager;
10+
11+
} assetDiscoveryManagerState;
12+
13+
// Implementation: ------------------------------------------------------------------------------------
14+
void AssetResourceManager::Init()
15+
{
16+
Xen::Ref<Xen::Project> currentProject = Xen::ProjectManager::GetCurrentProject();
17+
std::filesystem::path currentProjectPath = Xen::ProjectManager::GetCurrentProjectPath();
18+
19+
assetDiscoveryManagerState.assetPath = currentProjectPath / currentProject->GetProjectSettings().relAssetDirectory;
20+
21+
// This class is supposed to be used only in the editor.(not on the runtime)
22+
assetDiscoveryManagerState.assetManager = Xen::AssetManagerUtil::GetEditorAssetManager();
23+
}
24+
25+
void AssetResourceManager::Load()
26+
{
27+
// This function needs to be run in a different thread.
28+
AssetResourceManager::LoadDirectory(std::filesystem::directory_entry(assetDiscoveryManagerState.assetPath));
29+
}
30+
31+
void AssetResourceManager::StartFileWatcher()
32+
{
33+
34+
}
35+
36+
// Private functions: ----------------------------------------------------------------------------------
37+
38+
// This function will run in a different thread.
39+
void AssetResourceManager::LoadDirectory(const std::filesystem::directory_entry& directory)
40+
{
41+
std::filesystem::recursive_directory_iterator iterator(directory);
42+
43+
for (auto& directoryEntry : iterator)
44+
{
45+
if (directoryEntry.is_regular_file())
46+
{
47+
// Calculate the relative path from the project's asset directory.
48+
std::filesystem::path relativePath = std::filesystem::relative(directoryEntry.path(), assetDiscoveryManagerState.assetPath);
49+
50+
bool loaded = assetDiscoveryManagerState.assetManager->ImportAssetFromFile(relativePath);
51+
52+
// TODO: Dispatch a AssetLoad Event or something.
53+
}
54+
}
55+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
#include <Xenode.h>
3+
4+
// TODO: Include this in Xenode.h
5+
#include <core/asset/EditorAssetManager.h>
6+
7+
// This class discovers assets in the assets directory, loads them, builds cache and loads from cache
8+
// If needed.
9+
// The Assets are imported through AssetManager(EditorAssetManager to be precise), and
10+
// reimports(by some notification) them if the assets are changed.
11+
class AssetResourceManager
12+
{
13+
public:
14+
// Sets the current asset path and asset manager instance.
15+
static void Init();
16+
17+
// Loads all the assets in the assetPath to the asset manager.
18+
// This will load from cache if needed.
19+
// This will happen in an different thread.
20+
static void Load();
21+
22+
// Starts the file watcher thread. When any changes are done to the
23+
// asset file, an event is dispatched that the asset has changed.
24+
static void StartFileWatcher();
25+
private:
26+
static void LoadDirectory(const std::filesystem::directory_entry& directory);
27+
};

core/Xen/src/LevelEditorLayer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "LevelEditorLayer.h"
22
#include "core/scene/ScriptableEntity.h"
3+
#include "AssetResourceManager.h"
34

45
#include <core/app/Timer.h>
56
#include <core/app/Utils.h>
@@ -23,6 +24,8 @@
2324
#include <core/scene/SceneRuntime.h>
2425
#include <core/scene/Components.h>
2526

27+
#include <core/asset/AssetManagerUtil.h>
28+
2629
Xen::Vec2 mouseInitialPos;
2730

2831
bool operator&(const KeyTransformOperation& o1, const KeyTransformOperation& o2) { return static_cast<uint16_t>(o1) & static_cast<uint16_t>(o2); }
@@ -40,9 +43,6 @@ void LevelEditorLayer::OnAttach()
4043
{
4144
m_GameMode = Xen::GetApplicationInstance()->GetGameType();
4245

43-
// input = Xen::Input::GetInputInterface();
44-
// input->SetWindow(Xen::DesktopApplication::GetWindow());
45-
4646
m_EditorCamera = std::make_shared<Xen::Camera>(
4747
m_EditorCameraType == Xen::EditorCameraType::_2D ? Xen::CameraType::Orthographic : Xen::CameraType::Perspective,
4848
m_ViewportFrameBufferWidth,
@@ -147,6 +147,11 @@ void LevelEditorLayer::OnAttach()
147147
Xen::SceneRuntime::SetAdditionalCamera(m_EditorCamera);
148148

149149
m_SceneSettings.renderSource = Xen::RenderSource::AdditionalCamera;
150+
151+
AssetResourceManager::Init();
152+
AssetResourceManager::Load();
153+
154+
Xen::AssetManagerUtil::GetEditorAssetManager()->SerializeRegistry();
150155
}
151156

152157
void LevelEditorLayer::OnDetach()

core/Xen/src/Main.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

core/Xen/src/ProjectManagerLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ProjectManagerLayer : Xen::Layer
99

1010
virtual void OnAttach() override;
1111
virtual void OnDetach() override;
12-
virtual void OnUpdate(double timestep) override;
12+
virtual void OnUpdate(float timestep) override;
1313
virtual void OnFixedUpdate() override;
1414
virtual void OnRender() override;
1515
};

core/Xen/src/XenEditorApp.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ class XenEditorApp : public Xen::DesktopGameApplication
3232
Xen::DesktopGameApplication::OnStart();
3333

3434
#ifndef XEN_PRODUCTION
35-
// Load the default project in case of debug and release_debug builds:
36-
Xen::Ref<Xen::Project> p = Xen::ProjectManager::LoadProject("../../resources/projects/default_project/default_project.xenproject");
35+
// Load the default project in case of debug and release_debug builds:
36+
std::filesystem::path defaultProjectPath(PROJECTS);
37+
defaultProjectPath = defaultProjectPath / "default_project" / "default_project.xenproject";
38+
// In future, this has to be an ABSOLUTE PATH.
39+
Xen::Ref<Xen::Project> p = Xen::ProjectManager::LoadProject(defaultProjectPath);
3740
#else
3841
// TEMP: Implement project creation UI:
3942
XEN_ENGINE_LOG_ERROR("Project Creation UI Not implemented!");

core/Xen/src/panel/ContentBrowserPanel.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <core/renderer/Texture.h>
88
#include <core/app/GameApplication.h>
99

10+
#include <core/asset/AssetManagerUtil.h>
11+
1012
#include "StringValues.h"
1113

1214
class ContentBrowserPanel
@@ -23,7 +25,6 @@ class ContentBrowserPanel
2325

2426
void OnImGuiRender()
2527
{
26-
2728
// Load Textures of the icons here:
2829
if (!m_LoadedTextures)
2930
{
@@ -74,6 +75,25 @@ class ContentBrowserPanel
7475

7576
ImGui::Columns(column_count, "##FileColumns", false);
7677

78+
Xen::AssetPtrRegistry assetRegistry = Xen::AssetManagerUtil::GetEditorAssetManager()->GetLoadedAssetRegistry();
79+
80+
for (auto&& assetPair : assetRegistry)
81+
{
82+
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
83+
84+
Xen::Ref<Xen::Texture2D> texture = Xen::AssetManagerUtil::GetAsset<Xen::Texture2D>(assetPair.first);
85+
86+
ImGui::PushID(assetPair.first);
87+
ImGui::ImageButton((ImTextureID)(texture->GetNativeTextureID()), { (float)m_IconSize, (float)m_IconSize });
88+
89+
ImGui::PopID();
90+
91+
ImGui::TextWrapped("%u", assetPair.first);
92+
ImGui::PopStyleColor();
93+
ImGui::NextColumn();
94+
}
95+
96+
#if 0
7797
for (auto& p : std::filesystem::directory_iterator{ m_CurrentPath })
7898
{
7999
const auto& path = p.path();
@@ -117,6 +137,7 @@ class ContentBrowserPanel
117137
ImGui::NextColumn();
118138

119139
}
140+
#endif
120141
ImGui::Columns(1);
121142
ImGui::End();
122143
}
@@ -136,9 +157,9 @@ class ContentBrowserPanel
136157
std::filesystem::path m_CurrentPath;
137158

138159
// Drag drop types:
139-
std::string m_SceneLoadDropType = "XEN_CONTENT_BROWSER_SCENE_LOAD";
140-
std::string m_TextureLoadDropType = "XEN_CONTENT_BROWSER_TEXTURE_LOAD";
141-
std::string m_ScriptLoadDropType = "XEN_CONTENT_BROWSER_SCRIPT_LOAD";
160+
std::string m_SceneLoadDropType = "XEN_CONTENT_BROWSER_SCENE_LOAD";
161+
std::string m_TextureLoadDropType = "XEN_CONTENT_BROWSER_TEXTURE_LOAD";
162+
std::string m_ScriptLoadDropType = "XEN_CONTENT_BROWSER_SCRIPT_LOAD";
142163

143164
Xen::Ref<Xen::Texture2D> m_FolderTexture;
144165
Xen::Ref<Xen::Texture2D> m_FileTexture;

0 commit comments

Comments
 (0)