-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some more infastructure to allow testing of both asset system and new material system
- Loading branch information
1 parent
ac13c70
commit dfa6677
Showing
16 changed files
with
182 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ namespace Arcane | |
{ | ||
enum class AssetType | ||
{ | ||
MESH | ||
MESH, | ||
TEXTURE | ||
}; | ||
|
||
class Asset | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "TextureAsset.h" | ||
|
||
namespace Arcane | ||
{ | ||
TextureAsset::TextureAsset(std::filesystem::path filepath) | ||
{ | ||
SetAssetType(AssetType::TEXTURE); | ||
m_Texture = Texture::Create(filepath.string()); | ||
} | ||
|
||
Texture* TextureAsset::GetTexture() | ||
{ | ||
return m_Texture; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <filesystem> | ||
#include "Asset.h" | ||
#include "Arcane/Renderer/Texture.h" | ||
|
||
namespace Arcane | ||
{ | ||
class TextureAsset : public Asset | ||
{ | ||
public: | ||
TextureAsset(std::filesystem::path filepath); | ||
|
||
Texture* GetTexture(); | ||
private: | ||
Texture* m_Texture; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ namespace Arcane | |
|
||
struct MeshComponent | ||
{ | ||
Mesh* mesh; | ||
Mesh* mesh = nullptr; | ||
std::string filepath; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,60 @@ | ||
#include <nlohmann/json.hpp> | ||
#include "FileWatcher.h" | ||
|
||
namespace Arcane | ||
{ | ||
FileWatcher::FileWatcher(std::string path_to_watch, std::chrono::duration<int, std::milli> delay) | ||
{ | ||
m_Directory = path_to_watch; | ||
for (auto& file : std::filesystem::recursive_directory_iterator(path_to_watch)) { | ||
m_Paths[file.path().string()] = std::filesystem::last_write_time(file); | ||
} | ||
//for (auto& file : std::filesystem::directory_iterator(path_to_watch)) { | ||
|
||
// m_Paths[file.path().string()] = std::filesystem::last_write_time(file); | ||
//} | ||
} | ||
|
||
void FileWatcher::Start(const std::function<void(std::string, FileStatus)>& action) | ||
void FileWatcher::Update() | ||
{ | ||
auto it = m_Paths.begin(); | ||
while (it != m_Paths.end()) | ||
{ | ||
if (!std::filesystem::exists(it->first)) { | ||
action(it->first, FileStatus::Deleted); | ||
it = m_Paths.erase(it); | ||
} | ||
else { | ||
it++; | ||
} | ||
} | ||
|
||
for (auto& file : std::filesystem::recursive_directory_iterator(m_Directory)) { | ||
for (auto& file : std::filesystem::directory_iterator(m_Directory)) { | ||
auto current_file_last_write_time = std::filesystem::last_write_time(file); | ||
|
||
if (!contains(file.path().string())) | ||
{ | ||
m_Paths[file.path().string()] = current_file_last_write_time; | ||
action(file.path().string(), FileStatus::Created); | ||
} | ||
else { | ||
if (m_Paths[file.path().string()] != current_file_last_write_time) { | ||
m_Paths[file.path().string()] = current_file_last_write_time; | ||
action(file.path().string(), FileStatus::Modified); | ||
if (file.path().extension() != ".arcmeta") { | ||
if (!contains(file.path().string())) | ||
{ | ||
|
||
FileInfo newFileInfo; | ||
newFileInfo.name = file.path().stem().string(); | ||
|
||
if (file.is_regular_file()) | ||
newFileInfo.assetID = GetAssetID(file.path()); | ||
else | ||
newFileInfo.isDirectory = true; | ||
|
||
m_Paths[file.path().string()] = newFileInfo; | ||
} | ||
} | ||
} | ||
} | ||
|
||
int FileWatcher::GetAssetID(std::filesystem::path metaPath) | ||
{ | ||
std::string metaFileName = metaPath.stem().string() + ".arcmeta"; | ||
std::filesystem::path metaFile = metaPath.parent_path() / metaFileName; | ||
|
||
std::ifstream i(metaFile.string()); | ||
|
||
nlohmann::json metaJson; | ||
i >> metaJson; | ||
|
||
return metaJson["id"]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.