lots of asset manager changes. using meta to manage asset, add twoside material flag for grid

This commit is contained in:
2026-02-15 16:17:23 +08:00
parent 896d3c7f97
commit 2bbe332532
45 changed files with 2114 additions and 1333 deletions

View File

@ -11,11 +11,11 @@
#include "Prism/Core/Input.h"
#include "Prism/Core/Math/Math.h"
#include "Prism/Editor/AssetEditorPanel.h"
#include "Prism/Editor/PhysicsSettingsWindow.h"
#include "Prism/Physics/Physics3D.h"
#include "Prism/Renderer/Renderer2D.h"
#include "Prism/Script/ScriptEngine.h"
#include "Prism/Utilities/DragDropData.h"
namespace Prism
{
@ -178,12 +178,13 @@ namespace Prism
// OpenScene("assets/scenes/FPSDemo.scene");
NewScene();
FileSystemWatcher::StartWatching();
AssetEditorPanel::RegisterDefaultEditors();
FileSystem::StartWatching();
}
void EditorLayer::OnDetach()
{
FileSystemWatcher::StopWatching();
FileSystem::StopWatching();
m_EditorScene->OnShutdown();
}
@ -404,10 +405,6 @@ namespace Prism
ImGui::EndMenuBar();
}
m_SceneHierarchyPanel->OnImGuiRender();
PhysicsSettingsWindow::OnImGuiRender(m_ShowPhysicsSettings);
SceneRenderer::OnImGuiRender();
// m_EditorCamera.OnImGuiRender();
ImGui::Begin("Materials");
@ -616,7 +613,6 @@ namespace Prism
ScriptEngine::OnImGuiRender();
ImGui::End();
@ -661,6 +657,12 @@ namespace Prism
if (m_UIShowBoundingBoxes && Property("On Top", m_UIShowBoundingBoxesOnTop))
ShowBoundingBoxes(m_UIShowBoundingBoxes, m_UIShowBoundingBoxesOnTop);
m_SceneHierarchyPanel->OnImGuiRender();
PhysicsSettingsWindow::OnImGuiRender(m_ShowPhysicsSettings);
SceneRenderer::OnImGuiRender();
AssetEditorPanel::OnImGuiRender();
ScriptEngine::OnImGuiRender();
m_AssetManagerPanel->OnImGuiRender();
m_ObjectsPanel->OnImGuiRender();
@ -772,7 +774,7 @@ namespace Prism
m_EditorScene->SetViewportSize((uint32_t)viewportSize.x, (uint32_t)viewportSize.y);
if (m_RuntimeScene)
m_RuntimeScene->SetViewportSize((uint32_t)viewportSize.x, (uint32_t)viewportSize.y);
m_EditorCamera.SetProjectionMatrix(glm::perspectiveFov(glm::radians(45.0f), viewportSize.x, viewportSize.y, 0.1f, 1000.0f));
m_EditorCamera.SetProjectionMatrix(glm::perspectiveFov(glm::radians(45.0f), viewportSize.x, viewportSize.y, 0.1f, 10000.0f));
m_EditorCamera.SetViewportSize((uint32_t)viewportSize.x, (uint32_t)viewportSize.y);
ImGui::Image((ImTextureRef)SceneRenderer::GetFinalColorBufferRendererID(), viewportSize, { 0, 1 }, { 1, 0 });
@ -847,37 +849,28 @@ namespace Prism
if (ImGui::BeginDragDropTarget())
{
auto payload = ImGui::AcceptDragDropPayload("scene_entity_objectP");
auto payload = ImGui::AcceptDragDropPayload("asset_payload");
if (payload)
{
const auto data = (DragDropData*)payload->Data;
if (std::string_view(data->Type) == "Mesh")
{
auto entity = m_EditorScene->CreateEntity(data->Name);
entity.AddComponent<MeshComponent>(Ref<Mesh>::Create(data->SourcePath));
}
}
ImGui::EndDragDropTarget();
}
int count = payload->DataSize / sizeof(AssetHandle);
/* Payload Implementation For Getting Assets In The Viewport From Asset Manager */
if (ImGui::BeginDragDropTarget())
{
auto payload = ImGui::AcceptDragDropPayload("scene_entity_assetsP");
if (payload)
{
UUID assetId = *(UUID*)payload->Data;
Asset& asset = AssetsManager::GetAssetFromId(assetId);
if (asset.Type == AssetType::Scene)
for (int i = 0; i < count; i++)
{
OpenScene(asset.FilePath);
}
AssetHandle assetHandle = *(((AssetHandle*)payload->Data) + i);
Ref<Asset> asset = AssetsManager::GetAsset<Asset>(assetHandle);
if (asset.Type == AssetType::Mesh)
{
Entity entity = m_EditorScene->CreateEntity(asset.FileName);
entity.AddComponent<MeshComponent>(AssetsManager::InstantiateAsset<Mesh>(assetId));
// We can't really support dragging and dropping scenes when we're dropping multiple assets
if (count == 1 && asset->Type == AssetType::Scene)
{
OpenScene(asset->FilePath);
}
if (asset->Type == AssetType::Mesh)
{
Entity entity = m_EditorScene->CreateEntity(asset->FileName);
entity.AddComponent<MeshComponent>(Ref<Mesh>(asset));
SelectEntity(entity);
}
}
}
ImGui::EndDragDropTarget();

View File

@ -118,7 +118,7 @@ namespace Prism
struct RoughnessInput
{
float Value = 0.5f;
float Value = 1.0f;
Ref<Texture2D> TextureMap;
bool UseTexture = false;
};