Files
HelloVulkan/App/editor/panels/MaterialEditorPanel.h
T
atdunbg f73e52926f Reorganize directory layout: editor panels/, grouped shaders, drop stale header
- App/editor: move 7 panels into panels/ (Editor core stays at root)
- shaders/: group into pbr/ post/ debug/ env/ (runtime load paths updated)
- Delete outdated duplicate Engine/src/Renderer/VulkanAssetUploader.h
2026-10-07 09:52:17 +08:00

61 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// MaterialEditorPanel:独立材质编辑器窗口(UE Material Editor 语义)。
//
// 与 Details 面板职责分离:Details 材质槽行只做"指派"(换绑/还原/拖拽
// 覆盖资产),双击槽位预览球或 Content Browser 的 .material 条目 →
// 本面板打开做"编辑"(参数全平铺 + 纹理槽)。
//
// 两种模式:
// - 资产模式(可编辑):编辑 .material 资产。参数走
// EditParams 直写 UBO(松手落盘),纹理槽变化走 ReloadMaterialAsset
// (waitIdle 全停重建,低频路径)——与原 Inspector 内嵌编辑完全
// 同一套语义,此处原样搬运
// - 内建模式(只读):Model 内建材质无 CPU 参数副本(直写 GPU UBO),
// 只读展示 MeshMaterialInfo 快照 + 站内一键 Create Override(生成
// 资产后自动切换到资产模式编辑)
//
// 打开目标每帧重解析(实体可销毁 / 模型可卸载 / 资产可 Reload 换实例),
// 面板不跨帧持有任何指针。
//
#ifndef HELLOVULKAN_MATERIALEDITORPANEL_H
#define HELLOVULKAN_MATERIALEDITORPANEL_H
#include "EditorContext.h"
#include <Engine/Core/Types.h>
#include <entt/entt.hpp>
#include <string>
// 材质资产拖拽 payload(Content Browser 拖 .material → Details 槽位)
inline constexpr const char* kMaterialDragPayload = "MAT_PATH";
class MaterialEditorPanel {
public:
// 打开 .material 资产(可编辑模式)
void OpenAsset(const std::string& path);
// 打开内建材质(只读模式):owner 实体 + mesh 槽位每帧重解析
void OpenBuiltin(entt::entity owner, Engine::u32 meshIdx,
const std::string& displayName);
void Draw(const EditorContext& ctx);
private:
void DrawPreview(const EditorContext& ctx, Engine::Material* mat);
void DrawAssetMode(const EditorContext& ctx);
void DrawBuiltinMode(const EditorContext& ctx);
bool m_Open = false;
bool m_AssetMode = false;
// 资产模式目标
std::string m_Path;
bool m_LoadTried = false; // 未加载时自动 Load 一次(防每帧重试)
// 内建模式目标
entt::entity m_Owner{entt::null};
Engine::u32 m_MeshIdx = 0;
std::string m_DisplayName;
};
#endif //HELLOVULKAN_MATERIALEDITORPANEL_H