- HitProxy 拾取:RG 管线渲染实体 id → host readback,点击帧 PickEntity 精确命中;拾取按视觉几何(Model 联合包围球射线求交), 与 Collider 解耦(UE/Unity 编辑器语义),命中打印实体名+碰撞体参数 - 选中描边(UE 语义):SelectionMask pass(R8Unorm 完整投影轮廓, 无深度测试透墙可见)→ Outline pass(边缘检测 + alpha 叠加, 必须注册在 Tonemap 后);edgeCut 贴视口边缘;widthPx=6 可调 - shader object 实证修复:VUID-08879 同程序 set layouts 超集一致、 VUID-10065 push block 4×float 平铺、新 pass 析构销毁 VkShaderEXT - RG:SideEffect() 保活"产出无 RG 内消费者"的 pass 链 - Editor:层次面板点击选中、Inspector 姿态编辑、Stats 面板拾取信息 - 相机 Update 改 const(姿态写入 Transform 引用,Camera 本身无状态变更)
88 lines
2.8 KiB
C++
88 lines
2.8 KiB
C++
//
|
|
// HierarchyPanel.cpp:实体列表实现。
|
|
//
|
|
|
|
#include "HierarchyPanel.h"
|
|
#include "Engine/ECS/Components.h"
|
|
#include "Engine/ECS/EntityHandle.h" // CreateEntity 返回完整 EntityHandle
|
|
|
|
#include <imgui.h>
|
|
|
|
using namespace Engine;
|
|
|
|
namespace {
|
|
struct ScopedID {
|
|
explicit ScopedID(const u64 uuid) {
|
|
ImGui::PushID(reinterpret_cast<const void*>(uuid));
|
|
}
|
|
~ScopedID() {ImGui::PopID(); }
|
|
};
|
|
}
|
|
|
|
void HierarchyPanel::Draw(const EditorContext& ctx, entt::entity& selected)
|
|
{
|
|
ImGui::Begin("Hierarchy");
|
|
|
|
// 工具栏:创建实体(在遍历之前,不修改遍历中的注册表结构)
|
|
if (ImGui::Button("+ Create Entity"))
|
|
{
|
|
const auto e = ctx.scene->CreateEntity("Entity");
|
|
selected = e;
|
|
}
|
|
ImGui::Separator();
|
|
|
|
auto& reg = ctx.scene->GetRegistry();
|
|
|
|
reg.view<Engine::ECS::NameComponent>().each(
|
|
[&](const entt::entity e, const Engine::ECS::NameComponent& name)
|
|
{
|
|
const bool isSelected = (selected == e);
|
|
|
|
u64 rowId = static_cast < uint64_t >( static_cast < uint32_t >(e));
|
|
if (const auto * id = reg.try_get<Engine::ECS::IdComponent>(e)) {
|
|
rowId = id->uuid.Value();
|
|
}
|
|
const ScopedID scope (rowId);
|
|
|
|
const std::string label = name.name.empty() ? "(unnamed)" : name.name;
|
|
if (ImGui::Selectable(label.c_str(), isSelected))
|
|
{
|
|
selected = e;
|
|
}
|
|
|
|
// 右键菜单:删除(延迟销毁,帧尾统一 flush)
|
|
if (ImGui::BeginPopupContextItem("entity_ctx"))
|
|
{
|
|
if (ImGui::MenuItem("Delete"))
|
|
{
|
|
ctx.scene->DestroyEntity(e);
|
|
if (selected == e)
|
|
{
|
|
selected = entt::null;
|
|
}
|
|
}
|
|
ImGui::EndPopup();
|
|
}
|
|
|
|
// 组件徽标 + 悬停清单
|
|
std::string badge;
|
|
if (reg.all_of<Engine::ECS::MeshRendererComponent>(e)) badge += "[M]";
|
|
if (reg.all_of<Engine::ECS::AnimationComponent>(e)) badge += "[A]";
|
|
if (reg.all_of<Engine::ECS::CameraComponent>(e)) badge += "[C]";
|
|
if (reg.all_of<Engine::ECS::LightComponent>(e)) badge += "[L]";
|
|
if (reg.all_of<Engine::ECS::RigidBodyComponent>(e)) badge += "[P]";
|
|
if (!badge.empty())
|
|
{
|
|
ImGui::SameLine();
|
|
ImGui::TextDisabled("%s", badge.c_str());
|
|
if (ImGui::IsItemHovered())
|
|
{
|
|
ImGui::SetTooltip(
|
|
"M=Mesh A=Animation C=Camera L=Light P=Physics");
|
|
}
|
|
}
|
|
});
|
|
|
|
ImGui::End();
|
|
}
|