Added Collision Tag Matrix #296

Merged
srishamharan merged 5 commits from SP3-4-Editor into main 2022-12-27 13:59:49 +08:00
4 changed files with 84 additions and 1 deletions
Showing only changes of commit f119acdb65 - Show all commits

View File

@ -0,0 +1,62 @@
#include "SHpch.h"
#include "SHColliderTagPanel.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Physics/Collision/SHCollisionTagMatrix.h"
#include "Editor/SHEditorWidgets.hpp"
namespace SHADE
{
void SHColliderTagPanel::Update()
{
if (Begin())
{
ImGui::BeginTable("CollisionMtxTable", SHCollisionTag::NUM_LAYERS + 1, ImGuiTableRowFlags_Headers);
ImGui::TableNextRow();
for (int i = 0; i <= SHCollisionTag::NUM_LAYERS; ++i)
{
ImGui::TableNextColumn();
if(i == 0) continue;
std::string const& tagName = SHCollisionTagMatrix::GetTagName(i- 1);
auto tag = SHCollisionTagMatrix::GetTag(i - 1);
if (!tag)
continue;
//ImGui::Text(tagName.data());
SHEditorWidgets::InputText("##" + std::to_string(i), [i]{return SHCollisionTagMatrix::GetTagName(i- 1);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue);
}
for (int i = SHCollisionTag::NUM_LAYERS - 1; i >= 0; --i)
{
std::string tagName = SHCollisionTagMatrix::GetTagName(i);
auto tag = SHCollisionTagMatrix::GetTag(i);
if(!tag)
continue;
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text(tagName.data());
for (int j = 0; j < SHCollisionTag::NUM_LAYERS - i; ++j)
{
std::string tagName2 = SHCollisionTagMatrix::GetTagName(j);
auto tag2 = SHCollisionTagMatrix::GetTag(j);
if(!tag2)
continue;
if(tagName.empty())
tagName = std::to_string(i);
if(tagName2.empty())
tagName2 = std::to_string(j);
ImGui::TableNextColumn();
//if(i == j)
// continue;
std::string_view label = std::format("##{} vs {}", tagName, tagName2).data();
SHEditorWidgets::CheckBox(label, [tag, &j]{return tag->GetLayerState(j);}, [tag, i, j](bool const& value){tag->SetLayerState(j, value); SHCollisionTagMatrix::GetTag(j)->SetLayerState(i, value);}, label.substr(2));
}
}
ImGui::EndTable();
}
ImGui::End();
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "Editor/EditorWindow/SHEditorWindow.h"
#include <imgui.h>
namespace SHADE
{
class SH_API SHColliderTagPanel final : public SHEditorWindow
{
public:
SHColliderTagPanel():SHEditorWindow("Collider Tag Panel", ImGuiWindowFlags_MenuBar), isDirty(false){}
//void Init();
void Update() override;
//void Exit();
private:
bool isDirty;
};
}

View File

@ -5,4 +5,5 @@
#include "Profiling/SHEditorProfiler.h" //Profiler
#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport
#include "AssetBrowser/SHAssetBrowser.h" //Asset Browser
#include "MaterialInspector/SHMaterialInspector.h" //Material Inspector
#include "MaterialInspector/SHMaterialInspector.h" //Material Inspector
#include "ColliderTagPanel/SHColliderTagPanel.h" //Collider Tag Panel

View File

@ -101,6 +101,7 @@ namespace SHADE
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>();
SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>();
SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>();
SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();