Files
HelloVulkan/App/editor/MaterialEditorPanel.h
T
atdunbg cc837bc605 Add animation controller system, material assets and skeleton visualization
- .animctrl state machine asset (params/transitions/blend trees, 1D+2D
  directional blending) with Unity Animator-style editor panel: state
  list, transitions, params, directional pad preview driving live
  CrossFade on the selected entity
- Split animation evaluation out of SceneRenderer into
  AnimationSystem/AnimationEvaluator; skin palettes with rest-pose
  fallback and blend-weight epsilon filtering
- MaterialAsset (.material) with reload-safe preview tile pool
  (DropMaterial clears dirty refs before instance destruction)
- EditorGizmoPass skeleton wires + viewport joint overlay; camera
  projection rework (baked Vulkan Y-flip, ortho support)
- Editor/game build split via HELLOVULKAN_EDITOR option
2026-10-07 01:50:04 +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