mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-04 11:35:06 +03:00
Better UI and some optimizations
This commit is contained in:
@@ -141,7 +141,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
|
||||
Nuake::RenderCommand::DrawLines(0, 6);
|
||||
}
|
||||
|
||||
glLineWidth(2.0f);
|
||||
glLineWidth(1.0f);
|
||||
auto boxColliderView = scene->m_Registry.view<TransformComponent, BoxColliderComponent>();
|
||||
for (auto e : boxColliderView)
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Nuake {
|
||||
framebuffer->QueueResize(viewportPanelSize);
|
||||
|
||||
Ref<Texture> texture = framebuffer->GetTexture();
|
||||
ImVec2 imagePos = ImGui::GetCursorPos();
|
||||
ImVec2 imagePos = ImGui::GetWindowPos() + ImGui::GetCursorPos();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
m_ViewportPos = { imagePos.x, imagePos.y };
|
||||
@@ -173,7 +173,7 @@ namespace Nuake {
|
||||
|
||||
ImGuizmo::SetDrawlist();
|
||||
ImGuizmo::AllowAxisFlip(true);
|
||||
ImGuizmo::SetRect(imagePos.x + 8.0, imagePos.y + 30.0, viewportPanelSize.x, viewportPanelSize.y);
|
||||
ImGuizmo::SetRect(imagePos.x, imagePos.y + 0.0f, viewportPanelSize.x, viewportPanelSize.y);
|
||||
|
||||
if (m_DrawGrid && !Engine::IsPlayMode())
|
||||
{
|
||||
@@ -298,23 +298,7 @@ namespace Nuake {
|
||||
if (Selection.Type == EditorSelectionType::Entity && Selection.Entity == e)
|
||||
base_flags |= ImGuiTreeNodeFlags_Selected;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
bool& isVisible = e.GetComponent<VisibilityComponent>().Visible;
|
||||
char* visibilityIcon = isVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH;
|
||||
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||
if (ImGui::Button(visibilityIcon, { 40, 40 }))
|
||||
{
|
||||
isVisible = !isVisible;
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
@@ -428,6 +412,23 @@ namespace Nuake {
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{ 0.0f, 0.0f });
|
||||
{
|
||||
bool& isVisible = e.GetComponent<VisibilityComponent>().Visible;
|
||||
char* visibilityIcon = isVisible ? ICON_FA_EYE : ICON_FA_EYE_SLASH;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||
if (ImGui::Button(visibilityIcon, { 40, 40 }))
|
||||
{
|
||||
isVisible = !isVisible;
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (open)
|
||||
{
|
||||
// Caching list to prevent deletion while iterating.
|
||||
@@ -1041,9 +1042,9 @@ namespace Nuake {
|
||||
{
|
||||
if (ImGui::BeginTable("entity_table", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_SizingStretchProp))
|
||||
{
|
||||
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentEnable);
|
||||
std::string icon = ICON_FA_EYE;
|
||||
ImGui::TableSetupColumn((" " + icon).c_str(), ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed, 32);
|
||||
ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentEnable);
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Nuake
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
|
||||
{
|
||||
ImGui::OpenPopup(hoverMenuId.c_str());
|
||||
m_hasClickedOnFile = true;
|
||||
m_HasClickedOnFile = true;
|
||||
}
|
||||
|
||||
const std::string renameId = "Rename" + std::string("##") + hoverMenuId;
|
||||
@@ -252,7 +252,7 @@ namespace Nuake
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
|
||||
{
|
||||
ImGui::OpenPopup(hoverMenuId.c_str());
|
||||
m_hasClickedOnFile = true;
|
||||
m_HasClickedOnFile = true;
|
||||
}
|
||||
|
||||
const std::string openSceneId = "Open Scene" + std::string("##") + hoverMenuId;
|
||||
@@ -414,7 +414,7 @@ namespace Nuake
|
||||
|
||||
void FileSystemUI::DrawContextMenu()
|
||||
{
|
||||
if (!m_hasClickedOnFile && ImGui::IsMouseReleased(1) && ImGui::IsWindowHovered())
|
||||
if (!m_HasClickedOnFile && ImGui::IsMouseReleased(1) && ImGui::IsWindowHovered())
|
||||
{
|
||||
ImGui::OpenPopup("window_hover_menu");
|
||||
}
|
||||
@@ -634,10 +634,10 @@ namespace Nuake
|
||||
ImGui::BeginChild("searchBar", ImVec2(ImGui::GetContentRegionAvail().x - (numButtonAfterPathBrowser * buttonWidth), 24));
|
||||
char buffer[256];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
std::strncpy(buffer, m_searchKeyWord.c_str(), sizeof(buffer));
|
||||
std::strncpy(buffer, m_SearchKeyword.c_str(), sizeof(buffer));
|
||||
if (ImGui::InputTextEx("##Search", "Asset search & filter ..", buffer, sizeof(buffer), ImVec2(ImGui::GetContentRegionAvail().x, 24), ImGuiInputTextFlags_EscapeClearsAll))
|
||||
{
|
||||
m_searchKeyWord = std::string(buffer);
|
||||
m_SearchKeyword = std::string(buffer);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -692,7 +692,7 @@ namespace Nuake
|
||||
{
|
||||
for (Ref<Directory>& d : m_CurrentDirectory->Directories)
|
||||
{
|
||||
if(String::Sanitize(d->name).find(String::Sanitize(m_searchKeyWord)) != std::string::npos)
|
||||
if(String::Sanitize(d->name).find(String::Sanitize(m_SearchKeyword)) != std::string::npos)
|
||||
{
|
||||
if (i + 1 % amount != 0)
|
||||
ImGui::TableNextColumn();
|
||||
@@ -707,14 +707,18 @@ namespace Nuake
|
||||
|
||||
if (m_CurrentDirectory && m_CurrentDirectory->Files.size() > 0)
|
||||
{
|
||||
for (auto f : m_CurrentDirectory->Files)
|
||||
for (auto& f : m_CurrentDirectory->Files)
|
||||
{
|
||||
if(String::Sanitize(f->GetName()).find(String::Sanitize(m_searchKeyWord)) != std::string::npos)
|
||||
if(m_SearchKeyword.empty() || f->GetName().find(String::Sanitize(m_SearchKeyword)) != std::string::npos)
|
||||
{
|
||||
if (i - 1 % amount != 0 || i == 1)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
}
|
||||
|
||||
DrawFile(f, i);
|
||||
i++;
|
||||
@@ -723,7 +727,7 @@ namespace Nuake
|
||||
}
|
||||
|
||||
DrawContextMenu();
|
||||
m_hasClickedOnFile = false;
|
||||
m_HasClickedOnFile = false;
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Nuake {
|
||||
|
||||
public:
|
||||
static Ref<Directory> m_CurrentDirectory;
|
||||
bool m_hasClickedOnFile;
|
||||
std::string m_searchKeyWord;
|
||||
bool m_HasClickedOnFile;
|
||||
std::string m_SearchKeyword;
|
||||
|
||||
FileSystemUI(EditorInterface* editor)
|
||||
{
|
||||
m_CurrentDirectory = FileSystem::RootDirectory;
|
||||
m_hasClickedOnFile = false;
|
||||
m_HasClickedOnFile = false;
|
||||
Editor = editor;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,19 @@ namespace Nuake
|
||||
public:
|
||||
RenderList()
|
||||
{
|
||||
this->m_RenderList = std::map<Ref<Material>, std::vector<RenderMesh>>();
|
||||
this->m_RenderList = std::unordered_map<Ref<Material>, std::vector<RenderMesh>>();
|
||||
}
|
||||
|
||||
void AddToRenderList(Ref<Mesh> mesh, Matrix4 transform, const int32_t entityId = -1)
|
||||
void AddToRenderList(Ref<Mesh> mesh, const Matrix4& transform, const int32_t entityId = -1)
|
||||
{
|
||||
Ref<Material> material = mesh->GetMaterial();
|
||||
|
||||
if (m_RenderList.find(material) == m_RenderList.end())
|
||||
{
|
||||
m_RenderList[material] = std::vector<RenderMesh>();
|
||||
}
|
||||
|
||||
m_RenderList[material].push_back({mesh, transform, entityId});
|
||||
m_RenderList[material].push_back({std::move(mesh), std::move(transform), entityId});
|
||||
}
|
||||
|
||||
void Flush(Shader* shader, bool depthOnly = false)
|
||||
@@ -57,6 +59,6 @@ namespace Nuake
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<Ref<Material>, std::vector<RenderMesh>> m_RenderList;
|
||||
std::unordered_map<Ref<Material>, std::vector<RenderMesh>> m_RenderList;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -91,10 +91,12 @@ namespace Nuake
|
||||
|
||||
void Material::Bind(Shader* shader)
|
||||
{
|
||||
//if (MaterialManager::Get()->CurrentlyBoundedMaterial == m_Name)
|
||||
// return;
|
||||
if (MaterialManager::Get()->CurrentlyBoundedMaterial == ID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MaterialManager::Get()->CurrentlyBoundedMaterial = m_Name;
|
||||
MaterialManager::Get()->CurrentlyBoundedMaterial = ID;
|
||||
|
||||
|
||||
// Albedo
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#pragma once
|
||||
#include "src/Core/Core.h"
|
||||
#include "src/Resource/UUID.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "src/Core/Core.h"
|
||||
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
class Material;
|
||||
|
||||
// TODO: Should probably be static.
|
||||
class MaterialManager
|
||||
{
|
||||
private:
|
||||
@@ -23,7 +25,7 @@ namespace Nuake
|
||||
|
||||
public:
|
||||
const std::string DEFAULT_MATERIAL = "resources/Textures/default/Default.png";
|
||||
std::string CurrentlyBoundedMaterial = "";
|
||||
UUID CurrentlyBoundedMaterial;
|
||||
MaterialManager();
|
||||
|
||||
void LoadMaterials();
|
||||
|
||||
@@ -103,18 +103,18 @@ namespace Nuake
|
||||
for (auto& e : camView)
|
||||
{
|
||||
auto [transform, camera] = camView.get<TransformComponent, CameraComponent>(e);
|
||||
Matrix4 cameraTransform = camera.CameraInstance->GetTransformRotation();
|
||||
const Matrix4& cameraTransform = camera.CameraInstance->GetTransformRotation();
|
||||
|
||||
camera.CameraInstance->Translation = transform.GlobalTranslation;
|
||||
|
||||
auto globalRotation = transform.GetGlobalRotation();
|
||||
auto& translationMatrix = glm::translate(Matrix4(1.0f), transform.GetGlobalPosition());
|
||||
const Quat& globalRotation = transform.GetGlobalRotation();
|
||||
const Matrix4& translationMatrix = glm::translate(Matrix4(1.0f), transform.GetGlobalPosition());
|
||||
const Matrix4& rotationMatrix = glm::mat4_cast(globalRotation);
|
||||
Vector4 forward = Vector4(0, 0, -1, 1);
|
||||
const auto globalForward = rotationMatrix * forward;
|
||||
const Vector4& forward = Vector4(0, 0, -1, 1);
|
||||
const Vector4& globalForward = rotationMatrix * forward;
|
||||
|
||||
Vector4 right = Vector4(1, 0, 0, 1);
|
||||
const auto globalRight = rotationMatrix * right;
|
||||
const Vector4& right = Vector4(1, 0, 0, 1);
|
||||
const Vector4& globalRight = rotationMatrix * right;
|
||||
camera.CameraInstance->Direction = globalForward;
|
||||
camera.CameraInstance->Right = globalRight;
|
||||
; camera.CameraInstance->SetTransform(glm::inverse(translationMatrix * rotationMatrix));
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace ImGuizmo
|
||||
static const float RAD2DEG = (180.f / ZPI);
|
||||
static const float DEG2RAD = (ZPI / 180.f);
|
||||
static float gGizmoSizeClipSpace = 0.1f;
|
||||
const float screenRotateSize = 0.06f;
|
||||
const float screenRotateSize = 0.04f;
|
||||
|
||||
static OPERATION operator&(OPERATION lhs, OPERATION rhs)
|
||||
{
|
||||
@@ -729,10 +729,10 @@ namespace ImGuizmo
|
||||
static Context gContext;
|
||||
|
||||
static const vec_t directionUnary[3] = { makeVect(1.f, 0.f, 0.f), makeVect(0.f, 1.f, 0.f), makeVect(0.f, 0.f, 1.f) };
|
||||
static const ImU32 directionColor[3] = { 0xFF0000AA, 0xFF00AA00, 0xFFAA0000 };
|
||||
static const ImU32 directionColor[3] = { 0xFF3333AA, 0xFF33AA33, 0xFFAA3333 };
|
||||
|
||||
// Alpha: 100%: FF, 87%: DE, 70%: B3, 54%: 8A, 50%: 80, 38%: 61, 12%: 1F
|
||||
static const ImU32 planeColor[3] = { 0x610000AA, 0x6100AA00, 0x61AA0000 };
|
||||
static const ImU32 planeColor[3] = { 0xFF3333AA, 0xFF33AA33, 0xFFAA3333 };
|
||||
static const ImU32 selectionColor = 0x8A1080FF;
|
||||
static const ImU32 inactiveColor = 0x99999999;
|
||||
static const ImU32 translationLineColor = 0xAAAAAAAA;
|
||||
@@ -1156,7 +1156,7 @@ namespace ImGuizmo
|
||||
vec_t perpendicularVector;
|
||||
perpendicularVector.Cross(gContext.mRotationVectorSource, gContext.mTranslationPlan);
|
||||
perpendicularVector.Normalize();
|
||||
float acosAngle = Clamp(Dot(localPos, gContext.mRotationVectorSource), -1.f, 1.f);
|
||||
float acosAngle = Clamp(Dot(localPos, gContext.mRotationVectorSource), -0.9999999f, 0.999999f);
|
||||
float angle = acosf(acosAngle);
|
||||
angle *= (Dot(localPos, perpendicularVector) < 0.f) ? 1.f : -1.f;
|
||||
return angle;
|
||||
@@ -1200,7 +1200,7 @@ namespace ImGuizmo
|
||||
}
|
||||
ImVec2* circlePos = (ImVec2*) alloca(sizeof(ImVec2) * (circleMul * halfCircleSegmentCount + 1));
|
||||
|
||||
float angleStart = atan2f(cameraToModelNormalized[(4 - axis) % 3], cameraToModelNormalized[(3 - axis) % 3]) + ZPI * 0.5f;
|
||||
float angleStart = atan2f(cameraToModelNormalized[(4 - axis) % 3], cameraToModelNormalized[(3 - axis) % 3]) + ZPI * 0.5f + 0.25f;
|
||||
|
||||
for (unsigned int i = 0; i < circleMul * halfCircleSegmentCount + 1; i++)
|
||||
{
|
||||
@@ -1216,11 +1216,11 @@ namespace ImGuizmo
|
||||
gContext.mRadiusSquareCenter = radiusAxis;
|
||||
}
|
||||
|
||||
drawList->AddPolyline(circlePos, circleMul * halfCircleSegmentCount + 1, colors[3 - axis], false, 2);
|
||||
drawList->AddPolyline(circlePos, circleMul * halfCircleSegmentCount + 1, colors[3 - axis], false, 4);
|
||||
}
|
||||
if(hasRSC)
|
||||
{
|
||||
drawList->AddCircle(worldToPos(gContext.mModel.v.position, gContext.mViewProjection), gContext.mRadiusSquareCenter, colors[0], 64, 3.f);
|
||||
drawList->AddCircle(worldToPos(gContext.mModel.v.position, gContext.mViewProjection), gContext.mRadiusSquareCenter * 1.1f, colors[0], 64, 3.f);
|
||||
}
|
||||
|
||||
if (gContext.mbUsing && (gContext.mActualID == -1 || gContext.mActualID == gContext.mEditingID) && IsRotateType(type))
|
||||
@@ -1382,17 +1382,17 @@ namespace ImGuizmo
|
||||
|
||||
float d = sqrtf(ImLengthSqr(dir));
|
||||
dir /= d; // Normalize
|
||||
dir *= 6.0f;
|
||||
dir *= 10.0f;
|
||||
|
||||
ImVec2 ortogonalDir(dir.y, -dir.x); // Perpendicular vector
|
||||
ImVec2 a(worldDirSSpace + dir);
|
||||
drawList->AddTriangleFilled(worldDirSSpace - dir, a + ortogonalDir, a - ortogonalDir, colors[i + 1]);
|
||||
// Arrow head end
|
||||
|
||||
if (gContext.mAxisFactor[i] < 0.f)
|
||||
{
|
||||
DrawHatchedAxis(dirAxis);
|
||||
}
|
||||
//if (gContext.mAxisFactor[i] < 0.f)
|
||||
//{
|
||||
// DrawHatchedAxis(dirAxis);
|
||||
//}
|
||||
}
|
||||
|
||||
// draw plane
|
||||
|
||||
Reference in New Issue
Block a user