per-mesh 引用:MeshRendererComponent.meshIndex(-1=整模型)贯穿渲染收集/物理 Mesh 碰撞(自动跟随)/场景序列化(缺省键向前兼容)/Inspector mesh 下拉
This commit is contained in:
@@ -739,6 +739,40 @@ void InspectorPanel::Draw(const EditorContext& ctx, entt::entity selected)
|
||||
if (const Engine::Model* model = ctx.assets->GetModel(mr->model);
|
||||
model != nullptr)
|
||||
{
|
||||
// 单 mesh 子引用下拉(-1 = 整模型全部):名字用
|
||||
// GetMeshMaterialInfos(材质名优先,空回退 Slot N)
|
||||
{
|
||||
const auto& infos = model->GetMeshMaterialInfos();
|
||||
const int sel = mr->meshIndex + 1; // 0 = All
|
||||
std::string preview = "All meshes";
|
||||
if (sel > 0 &&
|
||||
static_cast<size_t>(sel - 1) < infos.size()) {
|
||||
preview = infos[static_cast<size_t>(sel) - 1]
|
||||
.name.empty()
|
||||
? "Slot " + std::to_string(sel - 1)
|
||||
: infos[static_cast<size_t>(sel) - 1].name;
|
||||
}
|
||||
if (ImGui::BeginCombo("mesh", preview.c_str()))
|
||||
{
|
||||
if (ImGui::Selectable("All meshes", sel <= 0)) {
|
||||
mr->meshIndex = -1;
|
||||
}
|
||||
for (size_t i = 0; i < infos.size(); ++i)
|
||||
{
|
||||
const std::string label =
|
||||
(infos[i].name.empty()
|
||||
? "Slot " + std::to_string(i)
|
||||
: infos[i].name) +
|
||||
"##" + std::to_string(i);
|
||||
const bool cur =
|
||||
mr->meshIndex == static_cast<int>(i);
|
||||
if (ImGui::Selectable(label.c_str(), cur)) {
|
||||
mr->meshIndex = static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
const auto& clips = model->GetClips();
|
||||
if (model->GetMeshes().empty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user