- 资产浏览器可视化与配色:面板重构(网格/列表/缩略图)、AssetKind 分类、 EditorColors 统一配色、AssetItemView 抽出条目绘制;HierarchyPanel/ MaterialEditorPanel 同步调整 - 材质缩略图改走 GPU 回读烘焙:MaterialPreviewPass 新增 bake pass (SDR atlas → host staging copyImageToBuffer)、Renderer 提供 Request/PollMaterialPreviewBake(无 waitIdle,依赖 per-slot fence), Editor 每帧排空后注入 ThumbnailCache——脱离预览 tile 池,消除"滚出视野 即失效/池耗尽"两问题 - 缩略图失效:BakedIdentity(serial, editVersion) 与当前材质身份比对, 换贴图槽(重载新 serial)/调参数(editVersion++)不符即 Invalidate 重烘, 修"修改材质后资产浏览器缩略图不更新" - 材质加载闸门:每帧至多 1 个 + 按实测耗时冷却,替代固定 2/帧 - 纹理上传批式化:VulkanAssetUploader 新增路径纹理缓存(跨材质去重, 同一贴图只解码/上传一次)+ 同批新纹理合并为单 cmd/单 submit/单 fence; Texture 抽出 RecordPixelsUpload/CreateDeferred/ReleasePendingStaging, 析构兜底释放 staging;MaterialAsset 纹理所有权移交 uploader 缓存—— 修大材质目录首次打开卡顿
64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
//
|
||
// 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";
|
||
|
||
// 纹理资产拖拽 payload(Content Browser 拖 .png/.jpg/... → 材质纹理槽)
|
||
inline constexpr const char* kTextureDragPayload = "TEXTURE_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
|