Merge branch 'RenderingEditorVPIntegration' into SP3-1-Rendering

This commit is contained in:
Brandon Mak 2022-10-19 12:27:05 +08:00
commit 95310b99bd
42 changed files with 1157 additions and 204 deletions

2
.gitignore vendored
View File

@ -362,3 +362,5 @@ MigrationBackup/
*.csproj *.csproj
*.filters *.filters
Assets/Editor/Layouts/UserLayout.ini

View File

@ -0,0 +1,3 @@
Name: Cube.003
ID: 110152941
Type: 

View File

@ -0,0 +1,3 @@
Name: Cube.012
ID: 107348815
Type: 

View File

@ -0,0 +1,48 @@
[Window][MainStatusBar]
Pos=0,1060
Size=1920,20
Collapsed=0
[Window][SHEditorMenuBar]
Pos=0,24
Size=1920,1036
Collapsed=0
[Window][Hierarchy Panel]
Pos=0,120
Size=225,940
Collapsed=0
DockId=0x00000004,0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Inspector]
Pos=1686,24
Size=234,1036
Collapsed=0
DockId=0x00000006,0
[Window][Profiler]
Pos=0,24
Size=225,94
Collapsed=0
DockId=0x00000003,0
[Window][Viewport]
Pos=227,24
Size=1457,1036
Collapsed=0
DockId=0x00000002,0
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=8,55 Size=1920,1036 Split=X
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1684,1036 Split=X
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=225,1036 Split=Y Selected=0x1E6EB881
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Selected=0xE096E5AE
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1293,1036 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=234,1036 Selected=0xE7039252

View File

@ -0,0 +1,48 @@
[Window][MainStatusBar]
Pos=0,1060
Size=1920,20
Collapsed=0
[Window][SHEditorMenuBar]
Pos=0,48
Size=1920,1012
Collapsed=0
[Window][Hierarchy Panel]
Pos=0,142
Size=321,918
Collapsed=0
DockId=0x00000004,0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Inspector]
Pos=1649,48
Size=271,1012
Collapsed=0
DockId=0x00000006,0
[Window][Profiler]
Pos=0,48
Size=321,92
Collapsed=0
DockId=0x00000003,0
[Window][Viewport]
Pos=323,48
Size=1324,1012
Collapsed=0
DockId=0x00000002,0
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=617,298 Size=1920,1012 Split=X
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1992,1036 Split=X
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=321,1036 Split=Y Selected=0x1E6EB881
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Selected=0xE096E5AE
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1324,1036 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=271,1036 Selected=0xE7039252

View File

@ -0,0 +1,3 @@
Name: RaccoonPreTexturedVer1_Base9
ID: 91918845
Type: 

View File

@ -104,10 +104,10 @@ namespace Sandbox
//TODO: REMOVE AFTER PRESENTATION //TODO: REMOVE AFTER PRESENTATION
//SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf"); //SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf");
SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh"); //SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh");
//SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds"); //SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds");
//SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds"); //SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds");
SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.shtex"); //SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.shtex");
//TODO: REMOVE AFTER PRESENTATION //TODO: REMOVE AFTER PRESENTATION
@ -125,19 +125,26 @@ namespace Sandbox
SHSceneManager::InitSceneManager<SBTestScene>("TestScene"); SHSceneManager::InitSceneManager<SBTestScene>("TestScene");
SHFrameRateController::UpdateFRC(); SHFrameRateController::UpdateFRC();
SHAssetManager::Load();
} }
void SBApplication::Update(void) void SBApplication::Update(void)
{ {
SHGraphicsSystem* graphicsSystem = SHADE::SHSystemManager::GetSystem<SHGraphicsSystem>(); SHGraphicsSystem* graphicsSystem = SHADE::SHSystemManager::GetSystem<SHGraphicsSystem>();
SHEditor* editor = SHADE::SHSystemManager::GetSystem<SHEditor>();
//TODO: Change true to window is open //TODO: Change true to window is open
while (!window.WindowShouldClose()) while (!window.WindowShouldClose())
{ {
SHFrameRateController::UpdateFRC(); SHFrameRateController::UpdateFRC();
SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime()); SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime());
SHSceneManager::UpdateSceneManager(); SHSceneManager::UpdateSceneManager();
SHSceneManager::SceneUpdate(0.016f); #ifdef SHEDITOR
SHSystemManager::RunRoutines(false, 0.016f); if(editor->editorState == SHEditor::State::PLAY)
SHSceneManager::SceneUpdate(0.016f);
#endif
SHSystemManager::RunRoutines(editor->editorState != SHEditor::State::PLAY, 0.016f);
editor->PollPicking();
} }
// Finish all graphics jobs first // Finish all graphics jobs first
@ -154,6 +161,7 @@ namespace Sandbox
SHSceneManager::Exit(); SHSceneManager::Exit();
SHSystemManager::Exit(); SHSystemManager::Exit();
SHAssetManager::Unload();
} }
} }

View File

@ -9,6 +9,7 @@ namespace SHADE
{ {
bool compiled; bool compiled;
std::string name;
uint32_t numBytes; uint32_t numBytes;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;

View File

@ -16,7 +16,7 @@
#include <fstream> #include <fstream>
void SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept std::string SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept
{ {
std::string newPath{ path.string() }; std::string newPath{ path.string() };
newPath = newPath.substr(0, newPath.find_last_of('/') + 1); newPath = newPath.substr(0, newPath.find_last_of('/') + 1);
@ -67,4 +67,6 @@ void SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPat
); );
file.close(); file.close();
return newPath;
} }

View File

@ -21,6 +21,6 @@ namespace SHADE
{ {
private: private:
public: public:
static void CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept; static std::string CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept;
}; };
} }

View File

@ -142,8 +142,7 @@ namespace SHADE
SHLOG_ERROR("Unable to open SHMesh File: {}", path.string()); SHLOG_ERROR("Unable to open SHMesh File: {}", path.string());
} }
std::string name{ path.filename().string() }; const std::string name{ path.stem().string() };
name = name.substr(0, name.find_last_of('.'));
file.seekg(0); file.seekg(0);

View File

@ -29,8 +29,8 @@ namespace SHADE
static void LoadExternal(std::vector<SHMeshAsset>& meshes, AssetPath path) noexcept; static void LoadExternal(std::vector<SHMeshAsset>& meshes, AssetPath path) noexcept;
static void LoadSHMesh(SHMeshAsset& meshes, AssetPath path) noexcept;
public: public:
static void LoadMesh(std::vector<SHMeshAsset>& meshes, AssetPath path) noexcept; static void LoadMesh(std::vector<SHMeshAsset>& meshes, AssetPath path) noexcept;
static void LoadSHMesh(SHMeshAsset& meshes, AssetPath path) noexcept;
}; };
} }

View File

@ -17,7 +17,7 @@
namespace SHADE namespace SHADE
{ {
void SHTextureCompiler::CompileTextureBinary(SHTextureAsset const& asset, AssetPath path) std::string SHTextureCompiler::CompileTextureBinary(SHTextureAsset const& asset, AssetPath path)
{ {
std::string newPath{ path.string() }; std::string newPath{ path.string() };
newPath = newPath.substr(0, newPath.find_last_of('.')); newPath = newPath.substr(0, newPath.find_last_of('.'));
@ -69,5 +69,7 @@ namespace SHADE
); );
file.close(); file.close();
return newPath;
} }
} }

View File

@ -19,6 +19,6 @@ namespace SHADE
{ {
struct SHTextureCompiler struct SHTextureCompiler
{ {
static void CompileTextureBinary(SHTextureAsset const& asset, AssetPath path); static std::string CompileTextureBinary(SHTextureAsset const& asset, AssetPath path);
}; };
} }

View File

@ -93,6 +93,7 @@ namespace SHADE
std::memcpy(pixel, file.GetImageData()->m_mem, totalBytes); std::memcpy(pixel, file.GetImageData()->m_mem, totalBytes);
//pixel = std::move(reinterpret_cast<SHTexture::PixelChannel const*>(file.GetDDSData())); //pixel = std::move(reinterpret_cast<SHTexture::PixelChannel const*>(file.GetDDSData()));
asset.name = path.stem().string();
asset.compiled = false; asset.compiled = false;
asset.numBytes = static_cast<uint32_t>(totalBytes); asset.numBytes = static_cast<uint32_t>(totalBytes);
asset.width = file.GetWidth(); asset.width = file.GetWidth();

View File

@ -26,8 +26,8 @@ namespace SHADE
static void LoadTinyDDS(AssetPath path, SHTextureAsset& asset) noexcept; static void LoadTinyDDS(AssetPath path, SHTextureAsset& asset) noexcept;
static void LoadSHTexture(AssetPath path, SHTextureAsset& asset) noexcept;
public: public:
static void LoadImageAsset(AssetPath paths, SHTextureAsset& image); static void LoadImageAsset(AssetPath paths, SHTextureAsset& image);
static void LoadSHTexture(AssetPath path, SHTextureAsset& asset) noexcept;
}; };
} }

View File

@ -40,7 +40,7 @@ typedef FMOD::Sound* SHSound;
#define ASSET_META_VER "1.0" #define ASSET_META_VER "1.0"
// Asset type enum // Asset type enum
enum class AssetType : uint8_t enum class AssetType : AssetTypeMeta
{ {
INVALID = 0, INVALID = 0,
AUDIO = 1, AUDIO = 1,
@ -57,7 +57,12 @@ enum class AssetType : uint8_t
}; };
//Directory //Directory
#define ASSET_ROOT "./Assets/" #ifdef _PUBLISH
#define ASSET_ROOT "Assets"
#else
#define ASSET_ROOT "../../Assets"
#endif
// ASSET EXTENSIONS // ASSET EXTENSIONS
#define META_EXTENSION ".shmeta" #define META_EXTENSION ".shmeta"

View File

@ -255,6 +255,26 @@ namespace SHADE
return result; return result;
} }
SHMeshAsset const* SHAssetManager::GetMesh(AssetID id) noexcept
{
if (meshCollection.find(id) == meshCollection.end())
{
return nullptr;
}
return &meshCollection[id];
}
SHTextureAsset const* SHAssetManager::GetTexture(AssetID id) noexcept
{
if (textureCollection.find(id) == textureCollection.end())
{
return nullptr;
}
return &textureCollection[id];
}
/**************************************************************************** /****************************************************************************
* \param Path for meta data file * \param Path for meta data file
* \param Path for asset file * \param Path for asset file
@ -307,12 +327,22 @@ namespace SHADE
for (auto const& mesh : meshes) for (auto const& mesh : meshes)
{ {
meshCollection.emplace(GenerateAssetID(AssetType::MESH), mesh); auto id{ GenerateAssetID(AssetType::MESH) };
meshCollection.emplace(id, mesh);
AssetPath path;
if (!mesh.compiled) if (!mesh.compiled)
{ {
SHMeshCompiler::CompileMeshBinary(mesh, asset.path); path = SHMeshCompiler::CompileMeshBinary(mesh, asset.path);
} }
assetCollection.emplace_back(
mesh.header.meshName,
id,
AssetType::MESH,
path,
0
);
} }
} }
@ -322,11 +352,20 @@ namespace SHADE
SHTextureLoader::LoadImageAsset(asset.path, image); SHTextureLoader::LoadImageAsset(asset.path, image);
textureCollection.emplace(GenerateAssetID(AssetType::DDS), image);
if (!image.compiled) if (!image.compiled)
{ {
SHTextureCompiler::CompileTextureBinary(image, asset.path); auto id{ GenerateAssetID(AssetType::TEXTURE) };
textureCollection.emplace(id, image);
auto path{ SHTextureCompiler::CompileTextureBinary(image, asset.path) };
assetCollection.emplace_back(
image.name,
id,
AssetType::TEXTURE,
path,
0
);
} }
} }
@ -344,8 +383,24 @@ namespace SHADE
****************************************************************************/ ****************************************************************************/
void SHAssetManager::LoadAllData() noexcept void SHAssetManager::LoadAllData() noexcept
{ {
//TODO Remove when on demand loading is done
for (auto const& asset : assetCollection) for (auto const& asset : assetCollection)
{ {
switch (asset.type)
{
case AssetType::MESH:
meshCollection.emplace(asset.id, SHMeshAsset());
SHMeshLoader::LoadSHMesh(meshCollection[asset.id], asset.path);
break;
case AssetType::TEXTURE:
textureCollection.emplace(asset.id, SHTextureAsset());
SHTextureLoader::LoadSHTexture(asset.path, textureCollection[asset.id]);
break;
default:
void;
}
} }
} }
@ -362,40 +417,51 @@ namespace SHADE
std::vector<AssetPath> metaFiles; std::vector<AssetPath> metaFiles;
std::vector<AssetPath> AssetFiles; std::vector<AssetPath> AssetFiles;
//TODO: Write new function for file manager to loop through all files for (auto const dir : std::filesystem::recursive_directory_iterator(ASSET_ROOT))
SHFileSystem::StartupFillDirectories(ASSET_ROOT);
FolderPointer rootFolder = SHFileSystem::GetRoot();
for (auto const& meta : metaFiles)
{ {
for (std::vector<AssetPath>::const_iterator it{ AssetFiles.cbegin() }; if (dir.path().extension().string() == META_EXTENSION)
it != AssetFiles.cend();
++it)
{ {
// Asset exists for meta file auto meta{ SHAssetMetaHandler::RetrieveMetaData(dir.path()) };
std::string fileExtCheck{ it->filename().string() };
fileExtCheck += META_EXTENSION; assetCollection.push_back(meta);
if (meta.filename().string() == fileExtCheck) assetRegistry.emplace(meta.id, meta);
{
RegisterAsset(meta, *it);
AssetFiles.erase(it);
break;
}
} }
} }
//TODO: Write new function for file manager to loop through all files
//SHFileSystem::StartupFillDirectories(ASSET_ROOT);
//FolderPointer rootFolder = SHFileSystem::GetRoot();
//for (auto const& meta : metaFiles)
//{
// for (std::vector<AssetPath>::const_iterator it{ AssetFiles.cbegin() };
// it != AssetFiles.cend();
// ++it)
// {
// // Asset exists for meta file
// std::string fileExtCheck{ it->filename().string() };
// fileExtCheck += META_EXTENSION;
// if (meta.filename().string() == fileExtCheck)
// {
// RegisterAsset(meta, *it);
// AssetFiles.erase(it);
// break;
// }
// }
//}
//TODO: Handle if meta does not match all assets (if meta exist and asset doesnt, vice versa) //TODO: Handle if meta does not match all assets (if meta exist and asset doesnt, vice versa)
for (auto const& file : AssetFiles) //for (auto const& file : AssetFiles)
{ //{
if (IsRecognised(file.extension().string().c_str())) // if (IsRecognised(file.extension().string().c_str()))
{ // {
SHAssetMetaHandler::WriteMetaData(RegisterAssetNew(file)); // SHAssetMetaHandler::WriteMetaData(RegisterAssetNew(file));
} // }
else // else
{ // {
std::cout << "Unsupported File Format: " << file.filename() << "\n"; // std::cout << "Unsupported File Format: " << file.filename() << "\n";
} // }
} //}
} }
AssetID SHAssetManager::RetrieveAsset(char const* path) noexcept AssetID SHAssetManager::RetrieveAsset(char const* path) noexcept

View File

@ -75,6 +75,8 @@ namespace SHADE
static std::vector<SHMeshAsset> GetAllMeshes() noexcept; static std::vector<SHMeshAsset> GetAllMeshes() noexcept;
static std::vector<SHTextureAsset> GetAllTextures() noexcept; static std::vector<SHTextureAsset> GetAllTextures() noexcept;
static SHMeshAsset const* GetMesh(AssetID id) noexcept;
static SHTextureAsset const* GetTexture(AssetID id) noexcept;
private: private:
/**************************************************************************** /****************************************************************************
* \brief Load resource data into memory * \brief Load resource data into memory

View File

@ -72,6 +72,13 @@ namespace SHADE
std::string line; std::string line;
SHAsset meta; SHAsset meta;
// Get resource name
GetFieldValue(metaFile, line);
std::stringstream nameStream{ line };
AssetName name;
nameStream >> name;
meta.name = name;
// Get resource id // Get resource id
GetFieldValue(metaFile, line); GetFieldValue(metaFile, line);
std::stringstream idStream{ line }; std::stringstream idStream{ line };
@ -88,6 +95,8 @@ namespace SHADE
metaFile.close(); metaFile.close();
meta.path = path.parent_path().string() + "/" + path.stem().string();
return meta; return meta;
} }
@ -103,7 +112,7 @@ namespace SHADE
std::string path{ meta.path.string() }; std::string path{ meta.path.string() };
path.append(META_EXTENSION); path.append(META_EXTENSION);
std::ofstream metaFile{ path, std::ios_base::out }; std::ofstream metaFile{ path, std::ios_base::out | std::ios_base::trunc };
if (!metaFile.is_open()) if (!metaFile.is_open())
{ {
@ -113,17 +122,17 @@ namespace SHADE
metaFile << "Name: " << meta.name << "\n"; metaFile << "Name: " << meta.name << "\n";
metaFile << "ID: " << meta.id << "\n"; metaFile << "ID: " << meta.id << "\n";
metaFile << "Type: " << static_cast<int>(meta.type) << std::endl; metaFile << "Type: " << static_cast<AssetTypeMeta>(meta.type) << std::endl;
//TODO Add in information that is specific to types like mesh ////TODO Add in information that is specific to types like mesh
switch(meta.type) //switch(meta.type)
{ //{
case AssetType::MESH: //case AssetType::MESH:
break; // break;
default: //default:
break; // break;
} //}
metaFile.close(); metaFile.close();
} }

View File

@ -66,8 +66,8 @@ namespace SHADE
editor->selectedEntities.clear(); editor->selectedEntities.clear();
} }
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal); ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
ImGui::End();
} }
ImGui::End();
} }
void SHHierarchyPanel::Exit() void SHHierarchyPanel::Exit()
@ -75,6 +75,11 @@ namespace SHADE
SHEditorWindow::Exit(); SHEditorWindow::Exit();
} }
void SHHierarchyPanel::SetScrollTo(EntityID eid)
{
scrollTo = eid;
}
//#==============================================================# //#==============================================================#
//|| Private Member Functions || //|| Private Member Functions ||
//#==============================================================# //#==============================================================#
@ -82,7 +87,20 @@ namespace SHADE
{ {
if (ImGui::BeginMenuBar()) if (ImGui::BeginMenuBar())
{ {
if (ImGui::SmallButton(ICON_MD_ADD))
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x - 35.0f);
if(ImGui::SmallButton(ICON_MD_DESELECT))
{
auto editor = SHSystemManager::GetSystem<SHEditor>();
editor->selectedEntities.clear();
}
if (ImGui::IsItemHovered())
{
ImGui::BeginTooltip();
ImGui::Text("Clear Selections");
ImGui::EndTooltip();
}
if (ImGui::SmallButton(ICON_MD_ADD_CIRCLE))
{ {
SHEntityManager::CreateEntity(); SHEntityManager::CreateEntity();
} }
@ -103,6 +121,13 @@ namespace SHADE
//Get node data (Children, eid, selected) //Get node data (Children, eid, selected)
auto& children = currentNode->GetChildren(); auto& children = currentNode->GetChildren();
EntityID eid = currentNode->GetEntityID(); EntityID eid = currentNode->GetEntityID();
if(scrollTo != MAX_EID && eid == scrollTo)
{
ImGui::SetScrollHereY();
scrollTo = MAX_EID;
}
auto editor = SHSystemManager::GetSystem<SHEditor>(); auto editor = SHSystemManager::GetSystem<SHEditor>();
const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end()); const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end());
@ -157,7 +182,7 @@ namespace SHADE
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }
//Handle node selection //Handle node selection
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
{ {

View File

@ -23,11 +23,13 @@ namespace SHADE
void Init() override; void Init() override;
void Update() override; void Update() override;
void Exit() override; void Exit() override;
void SetScrollTo(EntityID eid);
private: private:
void DrawMenuBar() const noexcept; void DrawMenuBar() const noexcept;
ImRect RecursivelyDrawEntityNode(SHSceneNode*); ImRect RecursivelyDrawEntityNode(SHSceneNode*);
void CreateChildEntity(EntityID parentEID) const noexcept; void CreateChildEntity(EntityID parentEID) const noexcept;
std::string filter; std::string filter;
bool isAnyNodeSelected = false; bool isAnyNodeSelected = false;
EntityID scrollTo = MAX_EID;
};//class SHHierarchyPanel };//class SHHierarchyPanel
}//namespace SHADE }//namespace SHADE

View File

@ -207,8 +207,10 @@ namespace SHADE
auto& colliders = component->GetColliders(); auto& colliders = component->GetColliders();
int const size = static_cast<int>(colliders.size()); int const size = static_cast<int>(colliders.size());
ImGui::BeginChild("Colliders", {0.0f, colliders.empty() ? 1.0f : 250.0f}, true); ImGui::BeginChild("Colliders", {0.0f, colliders.empty() ? 1.0f : 250.0f}, true);
std::optional<int> colliderToDelete{std::nullopt};
for (int i{}; i < size; ++i) for (int i{}; i < size; ++i)
{ {
ImGui::PushID(i);
SHCollider& collider = component->GetCollider(i); SHCollider& collider = component->GetCollider(i);
auto cursorPos = ImGui::GetCursorPos(); auto cursorPos = ImGui::GetCursorPos();
@ -235,9 +237,14 @@ namespace SHADE
} }
if(ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data())) if(ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data()))
{ {
component->RemoveCollider(i); colliderToDelete = i;
} }
SHEditorWidgets::EndPanel(); SHEditorWidgets::EndPanel();
ImGui::PopID();
}
if(colliderToDelete.has_value())
{
component->RemoveCollider(colliderToDelete.value());
} }
ImGui::EndChild(); ImGui::EndChild();

View File

@ -99,8 +99,8 @@ namespace SHADE
} }
} }
ImGui::End();
} }
ImGui::End();
} }
void SHEditorInspector::Exit() void SHEditorInspector::Exit()

View File

@ -36,6 +36,11 @@ namespace SHADE
void SHEditorMenuBar::Init() void SHEditorMenuBar::Init()
{ {
SHEditorWindow::Init(); SHEditorWindow::Init();
constexpr std::string_view path = "../../Assets/Editor/Layouts";
for(auto const& entry : std::filesystem::directory_iterator(path))
{
layoutPaths.push_back(entry.path());
}
} }
void SHEditorMenuBar::Update() void SHEditorMenuBar::Update()
@ -87,20 +92,6 @@ namespace SHADE
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::EndMenu(); ImGui::EndMenu();
} }
if(ImGui::BeginMenu("Theme"))
{
auto styles = rttr::type::get<SHEditor::Style>().get_enumeration();
auto values = styles.get_values();
for (auto style : values)
{
if(ImGui::Selectable(style.to_string().c_str()))
{
if(auto editor = SHSystemManager::GetSystem<SHEditor>())
editor->SetStyle(style.convert<SHEditor::Style>());
}
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Scripts")) if (ImGui::BeginMenu("Scripts"))
{ {
if (ImGui::Selectable("Generate Visual Studio Project")) if (ImGui::Selectable("Generate Visual Studio Project"))
@ -120,18 +111,79 @@ namespace SHADE
} }
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (ImGui::BeginMenu("Window"))
{
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
{
if (window.get() != this)
ImGui::Checkbox(window->windowName.data(), &window->isOpen);
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Theme"))
{
const auto styles = rttr::type::get<SHEditor::Style>().get_enumeration();
auto values = styles.get_values();
for (auto style : values)
{
if (ImGui::Selectable(style.to_string().c_str()))
{
if (auto editor = SHSystemManager::GetSystem<SHEditor>())
editor->SetStyle(style.convert<SHEditor::Style>());
}
}
ImGui::EndMenu();
}
if(ImGui::BeginMenu("Layout"))
{
for(auto const& entry : layoutPaths)
{
if(ImGui::Selectable(entry.stem().string().c_str()))
{
ImGui::LoadIniSettingsFromDisk(entry.string().c_str());
}
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar(); ImGui::EndMainMenuBar();
} }
const ImGuiID dockspace_id = ImGui::GetID("DockSpace"); const ImGuiID dockspaceId = ImGui::GetID("DockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspaceFlags); ImGui::DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
ImGui::End(); ImGui::End();
} }
} }
void SHEditorMenuBar::DrawSecondaryBar() const noexcept void SHEditorMenuBar::DrawSecondaryBar() const noexcept
{ {
ImGuiViewport* viewport = ImGui::GetMainViewport();
if(ImGui::BeginViewportSideBar("##SecondaryMenuBar", viewport, ImGuiDir_Up, ImGui::GetFrameHeight(), ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_MenuBar))
{
ImGui::BeginMenuBar();
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x * 0.5f - 80.f);
const auto editor = SHSystemManager::GetSystem<SHEditor>();
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PLAY);
if(ImGui::SmallButton(ICON_MD_PLAY_ARROW))
{
editor->editorState = SHEditor::State::PLAY;
}
ImGui::EndDisabled();
ImGui::BeginDisabled(editor->editorState == SHEditor::State::PAUSE);
if(ImGui::SmallButton(ICON_MD_PAUSE))
{
editor->editorState = SHEditor::State::PAUSE;
}
ImGui::EndDisabled();
ImGui::BeginDisabled(editor->editorState == SHEditor::State::STOP);
if(ImGui::SmallButton(ICON_MD_STOP))
{
editor->editorState = SHEditor::State::STOP;
}
ImGui::EndDisabled();
ImGui::EndMenuBar();
}
ImGui::End();
} }
void SHEditorMenuBar::DrawStatusBar() const noexcept void SHEditorMenuBar::DrawStatusBar() const noexcept
@ -142,8 +194,8 @@ namespace SHADE
if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags)) if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags))
{ {
ImGui::Text("Entity count: "); ImGui::Text("Entity count: ");
ImGui::End();
} }
ImGui::End();
ImGui::PopStyleVar(3); ImGui::PopStyleVar(3);
} }

View File

@ -18,5 +18,6 @@ namespace SHADE
void DrawSecondaryBar() const noexcept; void DrawSecondaryBar() const noexcept;
void DrawStatusBar() const noexcept; void DrawStatusBar() const noexcept;
float menuBarHeight = 20.0f; float menuBarHeight = 20.0f;
std::vector<std::filesystem::path> layoutPaths;
};//class SHEditorMenuBar };//class SHEditorMenuBar
}//namespace SHADE }//namespace SHADE

View File

@ -37,8 +37,8 @@ namespace SHADE
if(Begin()) if(Begin())
{ {
ImGui::PlotLines("DT", frames.data(), static_cast<int>(frames.size()), 0, nullptr, 0.0f, 16.0f); ImGui::PlotLines("DT", frames.data(), static_cast<int>(frames.size()), 0, nullptr, 0.0f, 16.0f);
ImGui::End();
} }
ImGui::End();
} }
void SHEditorProfiler::Exit() void SHEditorProfiler::Exit()

View File

@ -19,7 +19,7 @@ namespace SHADE
//|| Public Member Functions || //|| Public Member Functions ||
//#==============================================================# //#==============================================================#
SHEditorWindow::SHEditorWindow(std::string_view const& name, ImGuiWindowFlags const& inFlags) SHEditorWindow::SHEditorWindow(std::string_view const& name, ImGuiWindowFlags const& inFlags)
: isOpen(true), windowName(name), windowFlags(inFlags), io(ImGui::GetIO()) : windowName(name), windowFlags(inFlags), io(ImGui::GetIO())
{ {
} }
@ -40,7 +40,30 @@ namespace SHADE
//#==============================================================# //#==============================================================#
bool SHEditorWindow::Begin() bool SHEditorWindow::Begin()
{ {
return ImGui::Begin(windowName.data(), &isOpen, windowFlags); bool result = ImGui::Begin(windowName.data(), &isOpen, windowFlags);
auto wndSize = ImGui::GetWindowSize();
if(windowSize.x != wndSize.x || windowSize.y != wndSize.y)
{
windowSize = {wndSize.x, wndSize.y};
OnResize();
}
auto wndPos = ImGui::GetWindowPos();
if(windowPos.x != wndPos.x || windowPos.y != wndPos.y)
{
windowPos = {wndPos.x, wndPos.y};
OnPosChange();
}
isWindowHovered = ImGui::IsWindowHovered();
return result;
}
void SHEditorWindow::OnResize()
{
}
void SHEditorWindow::OnPosChange()
{
} }
}//namespace SHADE }//namespace SHADE

View File

@ -5,6 +5,8 @@
//#==============================================================# //#==============================================================#
#include <string> #include <string>
#include "Math/Vector/SHVec2.h"
//#==============================================================# //#==============================================================#
//|| Forward Declarations || //|| Forward Declarations ||
//#==============================================================# //#==============================================================#
@ -21,11 +23,18 @@ namespace SHADE
virtual void Init(); virtual void Init();
virtual void Update(); virtual void Update();
virtual void Exit(); virtual void Exit();
bool isOpen = false; bool isOpen;
bool isWindowHovered;
std::string_view windowName; std::string_view windowName;
protected: protected:
virtual bool Begin(); virtual bool Begin();
virtual void OnResize();
virtual void OnPosChange();
ImGuiWindowFlags windowFlags = 0; ImGuiWindowFlags windowFlags = 0;
ImGuiIO& io; ImGuiIO& io;
SHVec2 windowSize;
SHVec2 windowPos;
SHVec2 viewportMousePos;
};//class SHEditorWindow };//class SHEditorWindow
}//namespace SHADE }//namespace SHADE

View File

@ -2,4 +2,5 @@
#include "MenuBar/SHEditorMenuBar.h" //Menu Bar #include "MenuBar/SHEditorMenuBar.h" //Menu Bar
#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel #include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel
#include "Inspector/SHEditorInspector.h" //Inspector #include "Inspector/SHEditorInspector.h" //Inspector
#include "Profiling/SHEditorProfiler.h" //Profiler #include "Profiling/SHEditorProfiler.h" //Profiler
#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport

View File

@ -0,0 +1,84 @@
#include "SHpch.h"
#include "SHEditorViewport.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Editor/SHEditor.hpp"
#include "Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "Graphics/MiddleEnd/Interface/SHMousePickSystem.h"
namespace SHADE
{
SHEditorViewport::SHEditorViewport()
:SHEditorWindow("Viewport", ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar)
{
}
void SHEditorViewport::Init()
{
SHEditorWindow::Init();
}
void SHEditorViewport::Update()
{
SHEditorWindow::Update();
if(Begin())
{
DrawMenuBar();
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
auto const& descriptorSet = gfxSystem->GetPostOffscreenRenderSystem()->GetDescriptorSetGroup()->GetVkHandle()[0];
auto mousePos = ImGui::GetMousePos();
auto cursorPos = ImGui::GetCursorScreenPos();
viewportMousePos = {mousePos.x - cursorPos.x, mousePos.y - cursorPos.y};
gfxSystem->GetMousePickSystem ()->SetViewportMousePos (viewportMousePos);
//if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
//{
// auto eid = gfxSystem->GetMousePickSystem ()->GetPickedEntity();
// if(eid != MAX_EID)
// {
// auto editor = SHSystemManager::GetSystem<SHEditor>();
// editor->selectedEntities.clear();
// editor->selectedEntities.push_back(eid);
// if (const auto hierarchyPanel = SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>())
// {
// hierarchyPanel->SetScrollTo(eid);
// }
// }
//}
ImGui::Image((ImTextureID)descriptorSet, ImGui::GetWindowSize());
}
ImGui::End();
}
void SHEditorViewport::Exit()
{
SHEditorWindow::Exit();
}
void SHEditorViewport::OnResize()
{
SHEditorWindow::OnResize();
//Get graphics system to resize swapchain image
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
//auto pos = ImGui::GetCursorPos();
//windowCursorPos = {}
gfxSystem->PrepareResize(static_cast<uint32_t>(windowSize.x), static_cast<uint32_t>(windowSize.y));
}
void SHEditorViewport::OnPosChange()
{
SHEditorWindow::OnPosChange();
}
void SHEditorViewport::DrawMenuBar() const noexcept
{
if(ImGui::BeginMenuBar())
{
ImGui::EndMenuBar();
}
}
}//namespace SHADE

View File

@ -0,0 +1,29 @@
#pragma once
//#==============================================================#
//|| Library Includes ||
//#==============================================================#
#include <imgui.h>
//#==============================================================#
//|| SHADE Includes ||
//#==============================================================#
#include "imgui_internal.h"
#include "ECS_Base/SHECSMacros.h"
#include "Editor/EditorWindow/SHEditorWindow.h"
namespace SHADE
{
class SHEditorViewport final : public SHEditorWindow
{
public:
SHEditorViewport();
void Init() override;
void Update() override;
void Exit() override;
protected:
void OnResize() override;
void OnPosChange() override;
private:
void DrawMenuBar() const noexcept;
};//class SHEditorViewport
}//namespace SHADE

View File

@ -43,6 +43,8 @@
#include <backends/imgui_impl_sdl.h> #include <backends/imgui_impl_sdl.h>
#include <backends/imgui_impl_vulkan.h> #include <backends/imgui_impl_vulkan.h>
#include "Graphics/MiddleEnd/Interface/SHMousePickSystem.h"
RTTR_REGISTRATION RTTR_REGISTRATION
{ {
using namespace SHADE; using namespace SHADE;
@ -73,6 +75,7 @@ namespace SHADE
//#==============================================================# //#==============================================================#
void SHEditor::Init() void SHEditor::Init()
{ {
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
if(auto context = ImGui::CreateContext()) if(auto context = ImGui::CreateContext())
{ {
@ -82,11 +85,21 @@ namespace SHADE
} }
} }
ImGuiIO& io = ImGui::GetIO(); (void)io; //Add editor windows
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io = &ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; //Enable for Multi-Viewports
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; //Enable docking io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; //Enable for Multi-Viewports
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; //Enable docking
io->IniFilename = "../../Assets/Editor/Layouts/UserLayout.ini";
InitLayout();
InitFonts(); InitFonts();
@ -98,11 +111,11 @@ namespace SHADE
SetStyle(Style::SHADE); SetStyle(Style::SHADE);
//Add editor windows
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>(); for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>(); {
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>(); window->Init();
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>(); }
SHLOG_INFO("Successfully initialised SHADE Engine Editor") SHLOG_INFO("Successfully initialised SHADE Engine Editor")
} }
@ -116,7 +129,7 @@ namespace SHADE
if(window->isOpen) if(window->isOpen)
window->Update(); window->Update();
} }
if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_Z)) if(ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_Z))
{ {
SHCommandManager::RedoCommand(); SHCommandManager::RedoCommand();
@ -125,36 +138,46 @@ namespace SHADE
{ {
SHCommandManager::UndoCommand(); SHCommandManager::UndoCommand();
} }
Render(); Render();
} }
void SHEditor::Render() void SHEditor::Render()
{ {
ImGui::Render(); ImGui::Render();
ImGuiIO& io = ImGui::GetIO(); if (io->ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{ {
ImGui::UpdatePlatformWindows(); ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault(); ImGui::RenderPlatformWindowsDefault();
} }
} }
void SHEditor::InitLayout() noexcept
{
if(!std::filesystem::exists(io->IniFilename))
{
std::filesystem::copy_file("../../Assets/Editor/Layouts/Default.ini", io->IniFilename);
}
//eventually load preferred layout here
}
void SHEditor::InitFonts() noexcept void SHEditor::InitFonts() noexcept
{ {
ImGuiIO& io = ImGui::GetIO(); ImFont* mainFont = io->Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/Segoe UI.ttf", 20.f);//TODO: Change to config based assets path
ImFont* mainFont = io.Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/Segoe UI.ttf", 20.f);//TODO: Change to config based assets path
static const ImWchar icon_ranges[] = { ICON_MIN_MD, ICON_MAX_16_MD, 0 }; constexpr ImWchar icon_ranges[] = { ICON_MIN_MD, ICON_MAX_16_MD, 0 };
ImFontConfig icons_config{}; icons_config.MergeMode = true; icons_config.GlyphOffset.y = 5.f; ImFontConfig icons_config{}; icons_config.MergeMode = true; icons_config.GlyphOffset.y = 5.f;
ImFont* UIFont = io.Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/MaterialIcons-Regular.ttf", 20.f, &icons_config, icon_ranges); //TODO: Change to config based assets path ImFont* UIFont = io->Fonts->AddFontFromFileTTF("../../Assets/Editor/Fonts/MaterialIcons-Regular.ttf", 20.f, &icons_config, icon_ranges); //TODO: Change to config based assets path
io.Fonts->Build(); io->Fonts->Build();
} }
void SHEditor::Exit() void SHEditor::Exit()
{ {
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
{
window->Init();
}
ImGui_ImplVulkan_Shutdown(); ImGui_ImplVulkan_Shutdown();
ImGui_ImplSDL2_Shutdown(); ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext(); ImGui::DestroyContext();
@ -167,86 +190,86 @@ namespace SHADE
default: default:
case Style::SHADE: case Style::SHADE:
{ {
ImGuiStyle& imStyle = ImGui::GetStyle(); ImGuiStyle& imStyle = ImGui::GetStyle();
ImVec4* colors = imStyle.Colors; ImVec4* colors = imStyle.Colors;
colors[ImGuiCol_Text] = ImVec4(0.706f, 0.729f, 0.757f, 1.00f); colors[ImGuiCol_Text] = ImVec4(0.706f, 0.729f, 0.757f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.172f, 0.184f, 0.203f, 1.f); colors[ImGuiCol_WindowBg] = ImVec4(0.172f, 0.184f, 0.203f, 1.f);
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.19f, 0.19f, 0.19f, 0.92f); colors[ImGuiCol_PopupBg] = ImVec4(0.19f, 0.19f, 0.19f, 0.92f);
colors[ImGuiCol_Border] = ImVec4(0.19f, 0.19f, 0.19f, 0.29f); colors[ImGuiCol_Border] = ImVec4(0.19f, 0.19f, 0.19f, 0.29f);
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.24f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.24f);
colors[ImGuiCol_FrameBg] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f); colors[ImGuiCol_FrameBg] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.19f, 0.19f, 0.19f, 0.54f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.19f, 0.19f, 0.19f, 0.54f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f); colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f);
colors[ImGuiCol_TitleBg] = colors[ImGuiCol_WindowBg]; colors[ImGuiCol_TitleBg] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_TitleBgActive] = colors[ImGuiCol_WindowBg]; colors[ImGuiCol_TitleBgActive] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_TitleBgCollapsed] = colors[ImGuiCol_WindowBg]; colors[ImGuiCol_TitleBgCollapsed] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_MenuBarBg] = ImVec4(0.129f, 0.141f, 0.157f, 1.f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.129f, 0.141f, 0.157f, 1.f);
colors[ImGuiCol_ScrollbarBg] = colors[ImGuiCol_WindowBg]; colors[ImGuiCol_ScrollbarBg] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 0.54f); colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 0.54f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.40f, 0.54f); colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.40f, 0.54f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.56f, 0.56f, 0.56f, 0.54f); colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.56f, 0.56f, 0.56f, 0.54f);
colors[ImGuiCol_CheckMark] = ImVec4(0.627f, 0.239f, 0.761f, 1.00f); colors[ImGuiCol_CheckMark] = ImVec4(0.627f, 0.239f, 0.761f, 1.00f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.34f, 0.34f, 0.34f, 0.54f); colors[ImGuiCol_SliderGrab] = ImVec4(0.34f, 0.34f, 0.34f, 0.54f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.56f, 0.56f, 0.56f, 0.54f); colors[ImGuiCol_SliderGrabActive] = ImVec4(0.56f, 0.56f, 0.56f, 0.54f);
colors[ImGuiCol_Button] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f); colors[ImGuiCol_Button] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.15f, 0.15f, 0.15f, 0.54f); colors[ImGuiCol_ButtonHovered] = ImVec4(0.15f, 0.15f, 0.15f, 0.54f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f); colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f); colors[ImGuiCol_Header] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.00f, 0.00f, 0.00f, 0.36f); colors[ImGuiCol_HeaderHovered] = ImVec4(0.00f, 0.00f, 0.00f, 0.36f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.20f, 0.22f, 0.23f, 0.33f); colors[ImGuiCol_HeaderActive] = ImVec4(0.20f, 0.22f, 0.23f, 0.33f);
colors[ImGuiCol_Separator] = colors[ImGuiCol_MenuBarBg]; colors[ImGuiCol_Separator] = colors[ImGuiCol_MenuBarBg];
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.44f, 0.44f, 0.44f, 0.29f); colors[ImGuiCol_SeparatorHovered] = ImVec4(0.44f, 0.44f, 0.44f, 0.29f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.40f, 0.44f, 0.47f, 1.00f); colors[ImGuiCol_SeparatorActive] = ImVec4(0.40f, 0.44f, 0.47f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.28f, 0.28f, 0.28f, 0.29f); colors[ImGuiCol_ResizeGrip] = ImVec4(0.28f, 0.28f, 0.28f, 0.29f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.44f, 0.44f, 0.44f, 0.29f); colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.44f, 0.44f, 0.44f, 0.29f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.40f, 0.44f, 0.47f, 1.00f); colors[ImGuiCol_ResizeGripActive] = ImVec4(0.40f, 0.44f, 0.47f, 1.00f);
colors[ImGuiCol_Tab] = colors[ImGuiCol_WindowBg]; colors[ImGuiCol_Tab] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_TabHovered] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); colors[ImGuiCol_TabHovered] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
colors[ImGuiCol_TabActive] = ImVec4(0.14f, 0.14f, 0.14f, 0.8f); colors[ImGuiCol_TabActive] = ImVec4(0.14f, 0.14f, 0.14f, 0.8f);
colors[ImGuiCol_TabUnfocused] = colors[ImGuiCol_WindowBg]; colors[ImGuiCol_TabUnfocused] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_TabUnfocusedActive] = colors[ImGuiCol_WindowBg]; colors[ImGuiCol_TabUnfocusedActive] = colors[ImGuiCol_WindowBg];
colors[ImGuiCol_DockingPreview] = ImVec4(0.627f, 0.239f, 0.761f, 1.00f); colors[ImGuiCol_DockingPreview] = ImVec4(0.627f, 0.239f, 0.761f, 1.00f);
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.855f, 0.6f, 0.941f, 1.00f); colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.855f, 0.6f, 0.941f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f); colors[ImGuiCol_TableHeaderBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f); colors[ImGuiCol_TableBorderStrong] = ImVec4(0.00f, 0.00f, 0.00f, 0.52f);
colors[ImGuiCol_TableBorderLight] = ImVec4(0.28f, 0.28f, 0.28f, 0.29f); colors[ImGuiCol_TableBorderLight] = ImVec4(0.28f, 0.28f, 0.28f, 0.29f);
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f); colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f); colors[ImGuiCol_TextSelectedBg] = ImVec4(0.20f, 0.22f, 0.23f, 1.00f);
colors[ImGuiCol_DragDropTarget] = ImVec4(0.33f, 0.67f, 0.86f, 1.00f); colors[ImGuiCol_DragDropTarget] = ImVec4(0.33f, 0.67f, 0.86f, 1.00f);
colors[ImGuiCol_NavHighlight] = ImVec4(0.73f, 0.73f, 0.73f, 0.7f); colors[ImGuiCol_NavHighlight] = ImVec4(0.73f, 0.73f, 0.73f, 0.7f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.141f, 0.141f, 0.141f, 0.70f); colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.141f, 0.141f, 0.141f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = colors[ImGuiCol_NavHighlight]; colors[ImGuiCol_NavWindowingDimBg] = colors[ImGuiCol_NavHighlight];
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.2f, 0.2f, 0.2f, 0.65f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.2f, 0.2f, 0.2f, 0.65f);
imStyle.WindowPadding = ImVec2(8.00f, 8.00f); imStyle.WindowPadding = ImVec2(8.00f, 8.00f);
imStyle.FramePadding = ImVec2(5.00f, 2.00f); imStyle.FramePadding = ImVec2(5.00f, 2.00f);
imStyle.CellPadding = ImVec2(6.00f, 8.00f); imStyle.CellPadding = ImVec2(6.00f, 8.00f);
imStyle.ItemSpacing = ImVec2(6.00f, 6.00f); imStyle.ItemSpacing = ImVec2(6.00f, 6.00f);
imStyle.ItemInnerSpacing = ImVec2(6.00f, 6.00f); imStyle.ItemInnerSpacing = ImVec2(6.00f, 6.00f);
imStyle.TouchExtraPadding = ImVec2(0.00f, 0.00f); imStyle.TouchExtraPadding = ImVec2(0.00f, 0.00f);
imStyle.IndentSpacing = 25; imStyle.IndentSpacing = 25;
imStyle.ScrollbarSize = 15; imStyle.ScrollbarSize = 15;
imStyle.GrabMinSize = 10; imStyle.GrabMinSize = 10;
imStyle.WindowBorderSize = 0.6f; imStyle.WindowBorderSize = 0.6f;
imStyle.ChildBorderSize = 1; imStyle.ChildBorderSize = 1;
imStyle.PopupBorderSize = 1; imStyle.PopupBorderSize = 1;
imStyle.FrameBorderSize = 1; imStyle.FrameBorderSize = 1;
imStyle.TabBorderSize = 1; imStyle.TabBorderSize = 1;
imStyle.WindowRounding = 7; imStyle.WindowRounding = 7;
imStyle.ChildRounding = 4; imStyle.ChildRounding = 4;
imStyle.FrameRounding = 3; imStyle.FrameRounding = 3;
imStyle.PopupRounding = 4; imStyle.PopupRounding = 4;
imStyle.ScrollbarRounding = 9; imStyle.ScrollbarRounding = 9;
imStyle.GrabRounding = 3; imStyle.GrabRounding = 3;
imStyle.LogSliderDeadzone = 4; imStyle.LogSliderDeadzone = 4;
imStyle.TabRounding = 4; imStyle.TabRounding = 4;
imStyle.WindowMenuButtonPosition = ImGuiDir_None; imStyle.WindowMenuButtonPosition = ImGuiDir_None;
} }
break; break;
@ -281,10 +304,11 @@ namespace SHADE
imguiCommandPool = gfxSystem->GetDevice()->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true); imguiCommandPool = gfxSystem->GetDevice()->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true);
imguiCommandBuffer = imguiCommandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY); imguiCommandBuffer = imguiCommandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
auto const& renderers = gfxSystem->GetDefaultViewport()->GetRenderers(); //auto const& renderers = gfxSystem->GetDefaultViewport()->GetRenderers();
auto const& renderers = gfxSystem->GetEditorViewport()->GetRenderers();
SHASSERT(!renderers.empty(), "No Renderers available") SHASSERT(!renderers.empty(), "No Renderers available")
auto renderGraph = renderers[0]->GetRenderGraph(); auto renderGraph = renderers[SHGraphicsConstants::RenderGraphIndices::EDITOR]->GetRenderGraph();
auto renderPass = renderGraph->GetNode("ImGui Node")->GetRenderpass(); auto renderPass = renderGraph->GetNode("ImGui Node")->GetRenderpass();
if(ImGui_ImplVulkan_Init(&initInfo, renderPass->GetVkRenderpass()) == false) if(ImGui_ImplVulkan_Init(&initInfo, renderPass->GetVkRenderpass()) == false)
@ -309,6 +333,29 @@ namespace SHADE
}); });
} }
void SHEditor::PollPicking()
{
if (auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>())
{
auto viewportWindow = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>();
if (viewportWindow->isWindowHovered && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{
EntityID pickedEID = gfxSystem->GetMousePickSystem()->GetPickedEntity();
if(pickedEID == MAX_EID)
return;
if (!ImGui::IsKeyDown(ImGuiKey_LeftCtrl))
{
if (const auto hierarchyPanel = SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>())
{
hierarchyPanel->SetScrollTo(pickedEID);
}
selectedEntities.clear();
}
selectedEntities.push_back(pickedEID);
}
}
}
void SHEditor::NewFrame() void SHEditor::NewFrame()
{ {
SDL_Event event; SDL_Event event;

View File

@ -90,11 +90,11 @@ namespace SHADE
return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get()); return reinterpret_cast<T*>(editorWindows[GetEditorWindowID<T>()].get());
} }
static EditorWindowMap editorWindows;
private: private:
// Number of windows; used for Editor Window ID Generation // Number of windows; used for Editor Window ID Generation
static EditorWindowID windowCount; static EditorWindowID windowCount;
// Map of Editor Windows // Map of Editor Windows
static EditorWindowMap editorWindows;
friend class SHEditor; friend class SHEditor;
}; };
@ -110,10 +110,17 @@ namespace SHADE
class SH_API EditorRoutine final : public SHSystemRoutine class SH_API EditorRoutine final : public SHSystemRoutine
{ {
public: public:
EditorRoutine() = default; EditorRoutine():SHSystemRoutine("Editor routine", true) {};
void Execute(double dt) noexcept override final; void Execute(double dt) noexcept override final;
}; };
enum class State : uint8_t
{
PLAY,
PAUSE,
STOP
};
/** /**
* @brief Style options * @brief Style options
* *
@ -162,9 +169,13 @@ namespace SHADE
void SetSDLWindow(SDL_Window* inSDLWindow){sdlWindow = inSDLWindow;}; void SetSDLWindow(SDL_Window* inSDLWindow){sdlWindow = inSDLWindow;};
void PollPicking();
// List of selected entities // List of selected entities
std::vector<EntityID> selectedEntities; std::vector<EntityID> selectedEntities;
State editorState = State::STOP;
private: private:
/** /**
* @brief Start new frame for editor * @brief Start new frame for editor
@ -177,7 +188,7 @@ namespace SHADE
*/ */
void Render(); void Render();
void InitLayout() noexcept;
void InitFonts() noexcept; void InitFonts() noexcept;
@ -186,6 +197,8 @@ namespace SHADE
// Handle to command buffer used for ImGui Vulkan Backend // Handle to command buffer used for ImGui Vulkan Backend
Handle<SHVkCommandBuffer> imguiCommandBuffer; Handle<SHVkCommandBuffer> imguiCommandBuffer;
SDL_Window* sdlWindow; SDL_Window* sdlWindow {nullptr};
ImGuiIO* io{nullptr};
};//class SHEditor };//class SHEditor
}//namespace SHADE }//namespace SHADE

View File

@ -69,7 +69,15 @@ namespace SHADE
if (width == 0 || height == 0) if (width == 0 || height == 0)
return; return;
PrepareResize(resizeWidth, resizeHeight); #ifdef SHEDITOR
//PrepareResize(1, 1, SHVec2(0, 0));
#else
PrepareResize(resizeWidth, resizeHeight, SHVec2(0, 0));
#endif
}); });
window->RegisterWindowCloseCallback([&](void) window->RegisterWindowCloseCallback([&](void)
@ -130,7 +138,7 @@ namespace SHADE
worldCamera->SetPerspective(90.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 100.0f); worldCamera->SetPerspective(90.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 100.0f);
// Create Default Viewport // Create Default Viewport
defaultViewport = AddViewport(vk::Viewport(0.0f, 0.0f, static_cast<float>(window->GetWindowSize().first), static_cast<float>(window->GetWindowSize().second), 0.0f, 1.0f)); worldViewport = AddViewport(vk::Viewport(0.0f, 0.0f, static_cast<float>(window->GetWindowSize().first), static_cast<float>(window->GetWindowSize().second), 0.0f, 1.0f));
// Get render graph from default viewport world renderer // Get render graph from default viewport world renderer
worldRenderGraph = resourceManager.Create<SHRenderGraph>(); worldRenderGraph = resourceManager.Create<SHRenderGraph>();
@ -163,7 +171,7 @@ namespace SHADE
worldRenderGraph->Generate(); worldRenderGraph->Generate();
// Add world renderer to default viewport // Add world renderer to default viewport
worldRenderer = defaultViewport->AddRenderer(resourceManager, swapchain->GetNumImages(), renderContextCmdPools, descPool, SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS], worldRenderGraph); worldRenderer = worldViewport->AddRenderer(resourceManager, swapchain->GetNumImages(), renderContextCmdPools, descPool, SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS], worldRenderGraph);
worldRenderer->SetCamera(worldCamera); worldRenderer->SetCamera(worldCamera);
@ -589,7 +597,7 @@ namespace SHADE
/* System Routine Functions - BeginRoutine */ /* System Routine Functions - BeginRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::BeginRoutine::BeginRoutine() SHGraphicsSystem::BeginRoutine::BeginRoutine()
: SHSystemRoutine("Graphics System Frame Set Up", false) : SHSystemRoutine("Graphics System Frame Set Up", true)
{} {}
void SHGraphicsSystem::BeginRoutine::Execute(double) noexcept void SHGraphicsSystem::BeginRoutine::Execute(double) noexcept
@ -601,7 +609,7 @@ namespace SHADE
/* System Routine Functions - RenderRoutine */ /* System Routine Functions - RenderRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::RenderRoutine::RenderRoutine() SHGraphicsSystem::RenderRoutine::RenderRoutine()
: SHSystemRoutine("Graphics System Render", false) : SHSystemRoutine("Graphics System Render", true)
{} {}
void SHGraphicsSystem::RenderRoutine::Execute(double dt) noexcept void SHGraphicsSystem::RenderRoutine::Execute(double dt) noexcept
@ -613,7 +621,7 @@ namespace SHADE
/* System Routine Functions - EndRoutine */ /* System Routine Functions - EndRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::EndRoutine::EndRoutine() SHGraphicsSystem::EndRoutine::EndRoutine()
: SHSystemRoutine("Graphics System Frame Clean Up", false) : SHSystemRoutine("Graphics System Frame Clean Up", true)
{} {}
void SHGraphicsSystem::EndRoutine::Execute(double) noexcept void SHGraphicsSystem::EndRoutine::Execute(double) noexcept
@ -625,7 +633,7 @@ namespace SHADE
/* System Routine Functions - BatcherDispatcherRoutine */ /* System Routine Functions - BatcherDispatcherRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::BatcherDispatcherRoutine::BatcherDispatcherRoutine() SHGraphicsSystem::BatcherDispatcherRoutine::BatcherDispatcherRoutine()
: SHSystemRoutine("Graphics System Batcher Dispatcher", false) : SHSystemRoutine("Graphics System Batcher Dispatcher", true)
{} {}
void SHGraphicsSystem::BatcherDispatcherRoutine::Execute(double) noexcept void SHGraphicsSystem::BatcherDispatcherRoutine::Execute(double) noexcept
@ -691,8 +699,8 @@ namespace SHADE
mousePickSystem->HandleResize(); mousePickSystem->HandleResize();
postOffscreenRender->HandleResize(); postOffscreenRender->HandleResize();
defaultViewport->SetWidth(static_cast<float>(resizeWidth)); worldViewport->SetWidth(static_cast<float>(resizeWidth));
defaultViewport->SetHeight(static_cast<float>(resizeHeight)); worldViewport->SetHeight(static_cast<float>(resizeHeight));
worldCamera->SetPerspective(90.0f, static_cast<float>(resizeWidth), static_cast<float>(resizeHeight), 0.0f, 100.0f); worldCamera->SetPerspective(90.0f, static_cast<float>(resizeWidth), static_cast<float>(resizeHeight), 0.0f, 100.0f);

View File

@ -280,7 +280,7 @@ namespace SHADE
Handle<SHVkPhysicalDevice> GetPhysicalDevice() const { return physicalDevice; } Handle<SHVkPhysicalDevice> GetPhysicalDevice() const { return physicalDevice; }
Handle<SHVkQueue> GetQueue() const { return graphicsQueue; } Handle<SHVkQueue> GetQueue() const { return graphicsQueue; }
Handle<SHVkDescriptorPool> GetDescriptorPool() const { return descPool; } Handle<SHVkDescriptorPool> GetDescriptorPool() const { return descPool; }
Handle<SHViewport> GetDefaultViewport() const {return defaultViewport;} Handle<SHViewport> GetDefaultViewport() const {return worldViewport;}
#ifdef SHEDITOR #ifdef SHEDITOR
Handle<SHViewport> GetEditorViewport () const {return editorViewport;}; Handle<SHViewport> GetEditorViewport () const {return editorViewport;};
#endif #endif
@ -325,7 +325,7 @@ namespace SHADE
Handle<SHRenderGraph> editorRenderGraph; Handle<SHRenderGraph> editorRenderGraph;
#endif #endif
Handle<SHViewport> defaultViewport; // Whole screen Handle<SHViewport> worldViewport; // Whole screen
std::vector<Handle<SHViewport>> viewports; // Additional viewports std::vector<Handle<SHViewport>> viewports; // Additional viewports
// Debug Renderers // Debug Renderers

View File

@ -6,6 +6,7 @@
#include "Graphics/Synchronization/SHVkFence.h" #include "Graphics/Synchronization/SHVkFence.h"
#include "Graphics/Buffers/SHVkBuffer.h" #include "Graphics/Buffers/SHVkBuffer.h"
#include "Graphics/SHVkUtil.h" #include "Graphics/SHVkUtil.h"
#include "Graphics/MiddleEnd/Interface/SHViewport.h"
namespace SHADE namespace SHADE
{ {
@ -13,7 +14,7 @@ namespace SHADE
{ {
logicalDevice = device; logicalDevice = device;
pickedEID = 0; pickedEID = MAX_EID;
// Create command buffers // Create command buffers
for (auto& pool : cmdPools) for (auto& pool : cmdPools)
@ -30,7 +31,7 @@ namespace SHADE
void SHMousePickSystem::Run(Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept void SHMousePickSystem::Run(Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept
{ {
// if input detected // if input detected
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::LEFT_CTRL) && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB)) if (SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
{ {
afterCopyFence->Reset(); afterCopyFence->Reset();
@ -52,10 +53,8 @@ namespace SHADE
// wait for the copy to be done // wait for the copy to be done
afterCopyFence->Wait(true, std::numeric_limits<uint64_t>::max()); afterCopyFence->Wait(true, std::numeric_limits<uint64_t>::max());
int mouseX = 0, mouseY = 0; pickedEID = imageDataDstBuffer->GetDataFromMappedPointer<uint32_t>(static_cast<uint32_t>(viewportMousePos.y) * entityIDAttachment->GetWidth() + static_cast<uint32_t>(viewportMousePos.x));
SHInputManager::GetMouseWindowPosition(&mouseX, &mouseY);
pickedEID = imageDataDstBuffer->GetDataFromMappedPointer<uint32_t>(mouseY * entityIDAttachment->GetWidth() + mouseX);
} }
} }
@ -79,6 +78,11 @@ namespace SHADE
imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT); imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
} }
void SHMousePickSystem::SetViewportMousePos(SHVec2 vpMousePos) noexcept
{
viewportMousePos = vpMousePos;
}
EntityID SHMousePickSystem::GetPickedEntity(void) const noexcept EntityID SHMousePickSystem::GetPickedEntity(void) const noexcept
{ {
return pickedEID; return pickedEID;

View File

@ -13,6 +13,7 @@ namespace SHADE
class SHVkFence; class SHVkFence;
class SHVkQueue; class SHVkQueue;
class SHVkBuffer; class SHVkBuffer;
class SHViewport;
class SHMousePickSystem class SHMousePickSystem
{ {
@ -33,6 +34,10 @@ namespace SHADE
//! eid picked from screen //! eid picked from screen
EntityID pickedEID; EntityID pickedEID;
//! mouse position relative to the viewport window displaying the world
SHVec2 viewportMousePos;
public: public:
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* PUBLIC MEMBER FUNCTIONS */ /* PUBLIC MEMBER FUNCTIONS */
@ -44,6 +49,8 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SETTERS AND GETTERS */ /* SETTERS AND GETTERS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void SetViewportMousePos (SHVec2 vpMousePos) noexcept;
EntityID GetPickedEntity (void) const noexcept; EntityID GetPickedEntity (void) const noexcept;
}; };

View File

@ -85,4 +85,14 @@ namespace SHADE
} }
void SHViewport::SetX(float x) noexcept
{
viewport.x = x;
}
void SHViewport::SetY(float y) noexcept
{
viewport.y = y;
}
} }

View File

@ -67,6 +67,8 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
void SetWidth(float w) noexcept; void SetWidth(float w) noexcept;
void SetHeight (float h) noexcept; void SetHeight (float h) noexcept;
void SetX (float x) noexcept;
void SetY (float y) noexcept;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Getters */ /* Getters */

View File

@ -0,0 +1,102 @@
/************************************************************************************//*!
\file Input.cxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Oct 16, 2022
\brief Contains the definition of the managed Input static class.
Note: This file is written in C++17/CLI.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#include "SHpch.h"
#include "Input.hxx"
#include "Utility/Convert.hxx"
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Properties */
/*---------------------------------------------------------------------------------*/
Vector3 Input::MousePosition::get()
{
int x, y;
SHInputManager::GetMouseWindowPosition(&x, &y);
return Vector3(static_cast<float>(x), static_cast<float>(y), 0.0f);
}
int Input::MouseScrollDelta::get()
{
return SHInputManager::GetMouseWheelVerticalDelta();
}
/*---------------------------------------------------------------------------------*/
/* Usage Functions */
/*---------------------------------------------------------------------------------*/
bool Input::GetKey(KeyCode key)
{
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(key));
}
bool Input::GetKeyDown(KeyCode key)
{
return SHInputManager::GetKeyDown(static_cast<SHInputManager::SH_KEYCODE>(key));
}
bool Input::GetKeyUp(KeyCode key)
{
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(key));
}
bool Input::GetMouseButton(MouseCode mouseButton)
{
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
}
bool Input::GetMouseButtonDown(MouseCode mouseButton)
{
return SHInputManager::GetKeyDown(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
}
bool Input::GetMouseButtonUp(MouseCode mouseButton)
{
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
}
/*---------------------------------------------------------------------------------*/
/* Cursor Functions */
/*---------------------------------------------------------------------------------*/
void Input::SetMousePosition(Vector2 pos)
{
SHInputManager::SetMouseWindowPosition
(
static_cast<int>(pos.x),
static_cast<int>(pos.y)
);
}
/*---------------------------------------------------------------------------------*/
/* Time Functions */
/*---------------------------------------------------------------------------------*/
double Input::GetKeyHeldTime(KeyCode key)
{
return SHInputManager::GetKeyHeldTime(static_cast<SHInputManager::SH_KEYCODE>(key));
}
double Input::GetKeyReleasedTime(KeyCode key)
{
return SHInputManager::GetKeyReleasedTime(static_cast<SHInputManager::SH_KEYCODE>(key));
}
double Input::GetMouseHeldTime(MouseCode key)
{
return SHInputManager::GetKeyHeldTime(static_cast<SHInputManager::SH_KEYCODE>(key));
}
double Input::GetMouseReleasedTime(MouseCode key)
{
return SHInputManager::GetKeyReleasedTime(static_cast<SHInputManager::SH_KEYCODE>(key));
}
}

View File

@ -0,0 +1,325 @@
/************************************************************************************//*!
\file Input.hxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Oct 16, 2022
\brief Contains the definition of the managed Input static class.
Note: This file is written in C++17/CLI.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
#include "Input/SHInputManager.h"
#include "Math/Vector2.hxx"
#include "Math/Vector3.hxx"
namespace SHADE
{
/// <summary>
/// Static class responsible for providing access to Input-related functionality.
/// </summary>
public ref class Input abstract sealed
{
public:
/*-----------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Represents the available supported keycodes that can be passed into the
/// key-based Input functions.
/// </summary>
enum class KeyCode : int
{
Space = static_cast<int>(SHInputManager::SH_KEYCODE::SPACE),
//Apostrophe = static_cast<int>(SHInputManager::SH_KEYCODE::APOSTROPHE),
Comma = static_cast<int>(SHInputManager::SH_KEYCODE::OEM_COMMA),
Minus = static_cast<int>(SHInputManager::SH_KEYCODE::OEM_MINUS),
Period = static_cast<int>(SHInputManager::SH_KEYCODE::OEM_PERIOD),
//Slash = static_cast<int>(SHInputManager::SH_KEYCODE::SLASH),
Key0 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_0),
Key1 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_1),
Key2 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_2),
Key3 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_3),
Key4 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_4),
Key5 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_5),
Key6 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_6),
Key7 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_7),
Key8 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_8),
Key9 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_9),
//Semicolon = static_cast<int>(SHInputManager::SH_KEYCODE::SEMICOLON),
//Equal = static_cast<int>(SHInputManager::SH_KEYCODE::EQUAL),
A = static_cast<int>(SHInputManager::SH_KEYCODE::A),
B = static_cast<int>(SHInputManager::SH_KEYCODE::B),
C = static_cast<int>(SHInputManager::SH_KEYCODE::C),
D = static_cast<int>(SHInputManager::SH_KEYCODE::D),
E = static_cast<int>(SHInputManager::SH_KEYCODE::E),
F = static_cast<int>(SHInputManager::SH_KEYCODE::F),
G = static_cast<int>(SHInputManager::SH_KEYCODE::G),
H = static_cast<int>(SHInputManager::SH_KEYCODE::H),
I = static_cast<int>(SHInputManager::SH_KEYCODE::I),
J = static_cast<int>(SHInputManager::SH_KEYCODE::J),
K = static_cast<int>(SHInputManager::SH_KEYCODE::K),
L = static_cast<int>(SHInputManager::SH_KEYCODE::L),
M = static_cast<int>(SHInputManager::SH_KEYCODE::M),
N = static_cast<int>(SHInputManager::SH_KEYCODE::N),
O = static_cast<int>(SHInputManager::SH_KEYCODE::O),
P = static_cast<int>(SHInputManager::SH_KEYCODE::P),
Q = static_cast<int>(SHInputManager::SH_KEYCODE::Q),
R = static_cast<int>(SHInputManager::SH_KEYCODE::R),
S = static_cast<int>(SHInputManager::SH_KEYCODE::S),
T = static_cast<int>(SHInputManager::SH_KEYCODE::T),
U = static_cast<int>(SHInputManager::SH_KEYCODE::U),
V = static_cast<int>(SHInputManager::SH_KEYCODE::V),
W = static_cast<int>(SHInputManager::SH_KEYCODE::W),
X = static_cast<int>(SHInputManager::SH_KEYCODE::X),
Y = static_cast<int>(SHInputManager::SH_KEYCODE::Y),
Z = static_cast<int>(SHInputManager::SH_KEYCODE::Z),
//LeftBracket = static_cast<int>(SHInputManager::SH_KEYCODE::LEFTBRACKET),
//BackSlash = static_cast<int>(SHInputManager::SH_KEYCODE::BACKSLASH),
//RightBracket = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHTBRACKET),
//GraveAccent = static_cast<int>(SHInputManager::SH_KEYCODE::GRAVEACCENT),
//WORLD1 = static_cast<int>(SHInputManager::SH_KEYCODE::WORLD1),
//WORLD2 = static_cast<int>(SHInputManager::SH_KEYCODE::WORLD2),
/* Function keys */
Escape = static_cast<int>(SHInputManager::SH_KEYCODE::ESCAPE),
Enter = static_cast<int>(SHInputManager::SH_KEYCODE::ENTER),
Tab = static_cast<int>(SHInputManager::SH_KEYCODE::TAB),
Backspace = static_cast<int>(SHInputManager::SH_KEYCODE::BACKSPACE),
Insert = static_cast<int>(SHInputManager::SH_KEYCODE::INSERT),
Delete = static_cast<int>(SHInputManager::SH_KEYCODE::DEL),
Right = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_ARROW),
Left = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_ARROW),
Down = static_cast<int>(SHInputManager::SH_KEYCODE::DOWN_ARROW),
Up = static_cast<int>(SHInputManager::SH_KEYCODE::UP_ARROW),
PageUp = static_cast<int>(SHInputManager::SH_KEYCODE::PAGE_UP),
PageDown = static_cast<int>(SHInputManager::SH_KEYCODE::PAGE_DOWN),
Home = static_cast<int>(SHInputManager::SH_KEYCODE::HOME),
End = static_cast<int>(SHInputManager::SH_KEYCODE::END),
CapsLock = static_cast<int>(SHInputManager::SH_KEYCODE::CAPS_LOCK),
ScrollLock = static_cast<int>(SHInputManager::SH_KEYCODE::SCROLL_LOCK),
NumLock = static_cast<int>(SHInputManager::SH_KEYCODE::NUM_LOCK),
PrintScreen = static_cast<int>(SHInputManager::SH_KEYCODE::PRINT_SCREEN),
Pause = static_cast<int>(SHInputManager::SH_KEYCODE::PAUSE),
F1 = static_cast<int>(SHInputManager::SH_KEYCODE::F1),
F2 = static_cast<int>(SHInputManager::SH_KEYCODE::F2),
F3 = static_cast<int>(SHInputManager::SH_KEYCODE::F3),
F4 = static_cast<int>(SHInputManager::SH_KEYCODE::F4),
F5 = static_cast<int>(SHInputManager::SH_KEYCODE::F5),
F6 = static_cast<int>(SHInputManager::SH_KEYCODE::F6),
F7 = static_cast<int>(SHInputManager::SH_KEYCODE::F7),
F8 = static_cast<int>(SHInputManager::SH_KEYCODE::F8),
F9 = static_cast<int>(SHInputManager::SH_KEYCODE::F9),
F10 = static_cast<int>(SHInputManager::SH_KEYCODE::F10),
F11 = static_cast<int>(SHInputManager::SH_KEYCODE::F11),
F12 = static_cast<int>(SHInputManager::SH_KEYCODE::F12),
F13 = static_cast<int>(SHInputManager::SH_KEYCODE::F13),
F14 = static_cast<int>(SHInputManager::SH_KEYCODE::F14),
F15 = static_cast<int>(SHInputManager::SH_KEYCODE::F15),
F16 = static_cast<int>(SHInputManager::SH_KEYCODE::F16),
F17 = static_cast<int>(SHInputManager::SH_KEYCODE::F17),
F18 = static_cast<int>(SHInputManager::SH_KEYCODE::F18),
F19 = static_cast<int>(SHInputManager::SH_KEYCODE::F19),
F20 = static_cast<int>(SHInputManager::SH_KEYCODE::F20),
F21 = static_cast<int>(SHInputManager::SH_KEYCODE::F21),
F22 = static_cast<int>(SHInputManager::SH_KEYCODE::F22),
F23 = static_cast<int>(SHInputManager::SH_KEYCODE::F23),
F24 = static_cast<int>(SHInputManager::SH_KEYCODE::F24),
/* Keypad */
KeyPad0 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_0),
KeyPad1 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_1),
KeyPad2 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_2),
KeyPad3 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_3),
KeyPad4 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_4),
KeyPad5 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_5),
KeyPad6 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_6),
KeyPad7 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_7),
KeyPad8 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_8),
KeyPad9 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_9),
//KeyPadDecimal = static_cast<int>(SHInputManager::SH_KEYCODE::KPDECIMAL),
//KeyPadDivide = static_cast<int>(SHInputManager::SH_KEYCODE::KPDIVIDE),
//KeyPadMultiply = static_cast<int>(SHInputManager::SH_KEYCODE::KPMULTIPLY),
//KeyPadSubtract = static_cast<int>(SHInputManager::SH_KEYCODE::KPSUBTRACT),
//KeyPadAdd = static_cast<int>(SHInputManager::SH_KEYCODE::KPADD),
//KeyPadEnter = static_cast<int>(SHInputManager::SH_KEYCODE::KPENTER),
//KeyPadEqual = static_cast<int>(SHInputManager::SH_KEYCODE::KEYPAD),
Shift = static_cast<int>(SHInputManager::SH_KEYCODE::SHIFT),
LeftControl = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_CTRL),
LeftAlt = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_ALT),
LeftSuper = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_WINDOWS),
RightShift = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_SHIFT),
RightControl = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_CTRL),
RightAlt = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_ALT),
RightSuper = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_WINDOWS),
/* Gamepad */
JoystickA = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_A),
JoystickB = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_B),
JoystickX = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_X),
JoystickY = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_Y),
JoystickLeftBumper = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_LEFTSHOULDER),
JoystickRightBumper = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_RIGHTSHOULDER),
JoystickLeftTrigger = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_LEFTTRIGGER),
JoystickRightTrigger = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_RIGHTTRIGGER),
JoystickDPadUp = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_UP),
JoystickDPadDown = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_DOWN),
JoystickDPadLeft = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_LEFT),
JoystickDPadRight = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_RIGHT),
JoystickMenu = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_MENU),
JoystickView = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_VIEW),
JoystickLeftStick = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_LEFT_THUMBSTICK_BUTTON),
JoystickRightStick = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_RIGHT_THUMBSTICK_BUTTON),
/* Unity Gamepad Mappings */
JoystickButton0 = JoystickA,
JoystickButton1 = JoystickB,
JoystickButton2 = JoystickX,
JoystickButton3 = JoystickY,
JoystickButton4 = JoystickLeftBumper,
JoystickButton5 = JoystickRightBumper,
JoystickButton6 = JoystickView,
JoystickButton7 = JoystickMenu,
JoystickButton8 = JoystickLeftStick,
JoystickButton9 = JoystickRightStick
};
/// <summary>
/// Represents the available supported mouse keycodes that can be passed into the
/// mouse-button-based Input functions.
/// </summary>
enum class MouseCode : int
{
LeftButton = static_cast<int>(SHInputManager::SH_KEYCODE::LMB),
RightButton = static_cast<int>(SHInputManager::SH_KEYCODE::RMB),
MiddleButton = static_cast<int>(SHInputManager::SH_KEYCODE::MMB),
Button3 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB1),
Button4 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB2)
};
/*-----------------------------------------------------------------------------*/
/* Properites */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Mouse position in screen coordinates relative to the top left of the window.
/// This value is a Vector3 for compatibility with functions that have Vector3
/// arguments. The z component of the Vector3 is always 0
/// </summary>
static property Vector3 MousePosition
{
Vector3 get();
}
/// <summary>
/// Amnount of vertical mouse scroll in this frame.
/// </summary>
static property int MouseScrollDelta
{
int get();
}
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Checks if a specified key is being held down.
/// This will also be true if GetKeyDown() is true.
/// </summary>
/// <param name="key">KeyCode of the key to check.</param>
/// <returns>True while the user holds down the key specified.</returns>
static bool GetKey(KeyCode key);
/// <summary>
/// Checks if a specified key is pressed and was not pressed before.
/// </summary>
/// <param name="key">KeyCode of the key to check.</param>
/// <returns>
/// True during the frame the user starts pressing down the key specified.
/// </returns>
static bool GetKeyDown(KeyCode key);
/// <summary>
/// Checks if a specified key is no longer pressed pressed and was pressed
/// before.
/// </summary>
/// <param name="key">KeyCode of the key to check.</param>
/// <returns>
/// True during the frame the user releases the key identified by name.
/// </returns>
static bool GetKeyUp(KeyCode key);
/// <summary>
/// Checks if a specified mouse button is being held down.
/// This will also be true if GetMouseButtonDown() is true.
/// </summary>
/// <param name="mouseButton">MouseCode of the mouse button to check.</param>
/// <returns>True while the user holds down the mouse button specified.</returns>
static bool GetMouseButton(MouseCode mouseButton);
/// <summary>
/// Checks if a specified mouse button is pressed and was not pressed before.
/// </summary>
/// <param name="mouseButton">MouseCode of the mouse button to check.</param>
/// <returns>
/// True during the frame the user pressed the given mouse button.
/// </returns>
static bool GetMouseButtonDown(MouseCode mouseButton);
/// <summary>
/// Checks if a specified mouse button is no longer pressed and was pressed
/// before.
/// </summary>
/// <param name="mouseButton">MouseCode of the mouse button to check.</param>
/// <returns>
/// True during the frame the user releases the given mouse button.
/// </returns>
static bool GetMouseButtonUp(MouseCode mouseButton);
/*-----------------------------------------------------------------------------*/
/* Cursor Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Sets the position of the mouse cursor relative to the top left corner of the
/// window.
/// </summary>
/// <param name="pos">
/// Position of the mouse in window pixel coordinates to set.
/// </param>
static void SetMousePosition(Vector2 pos);
/*-----------------------------------------------------------------------------*/
/* Timing Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Retrieves the duration that the specified key has been held or was last held
/// for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetKeyHeldTime(KeyCode key);
/// <summary>
/// Retrieves the duration that the specified key has not been held or was last
/// not been held for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetKeyReleasedTime(KeyCode key);
/// <summary>
/// Retrieves the duration that the specified key has been held or was last held
/// for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetMouseHeldTime(MouseCode mouseButton);
/// <summary>
/// Retrieves the duration that the specified key has not been held or was last
/// not been held for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetMouseReleasedTime(MouseCode mouseButton);
};
}