| 893 | |
| 894 | #if WIVRN_CLIENT_DEBUG_MENU |
| 895 | void scenes::lobby::gui_debug_node_hierarchy(entt::entity root) |
| 896 | { |
| 897 | for (auto && [entity, node]: world.view<components::node>().each()) |
| 898 | { |
| 899 | if (node.parent != root) |
| 900 | continue; |
| 901 | |
| 902 | std::string id = "entity-" + std::to_string((int)entity); |
| 903 | const std::string & name = node.name == "" ? id : node.name; |
| 904 | |
| 905 | // See ImGui::StyleColorsDark |
| 906 | if (node.global_visible) |
| 907 | ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.00f, 1.00f, 1.00f, 1.00f)); |
| 908 | else |
| 909 | ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.50f, 0.50f, 0.50f, 1.00f)); |
| 910 | |
| 911 | ImGui::TableNextRow(); |
| 912 | ImGui::TableNextColumn(); |
| 913 | if (ImGui::TreeNodeEx(id.c_str(), ImGuiTreeNodeFlags_None, "%s", name.c_str())) |
| 914 | { |
| 915 | glm::vec3 scale{ |
| 916 | glm::length(glm::column(node.transform_to_root, 0)), |
| 917 | glm::length(glm::column(node.transform_to_root, 1)), |
| 918 | glm::length(glm::column(node.transform_to_root, 2)), |
| 919 | }; |
| 920 | |
| 921 | gui_debug_node_hierarchy(entity); |
| 922 | |
| 923 | if (node.mesh) |
| 924 | for (auto [index, primitive]: utils::enumerate(node.mesh->primitives)) |
| 925 | { |
| 926 | ImGui::TableNextRow(); |
| 927 | ImGui::TableNextColumn(); |
| 928 | std::string name = "Primitive " + std::to_string(index + 1); |
| 929 | |
| 930 | ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf; |
| 931 | if (debug_primitive_to_highlight == std::pair{entity, index}) |
| 932 | flags |= ImGuiTreeNodeFlags_Selected; |
| 933 | |
| 934 | if (ImGui::TreeNodeEx(name.c_str(), flags)) |
| 935 | { |
| 936 | if (ImGui::IsItemClicked()) |
| 937 | debug_primitive_to_highlight = {entity, index}; |
| 938 | |
| 939 | if (ImGui::IsItemHovered()) |
| 940 | { |
| 941 | std::string tooltip = fmt::format( |
| 942 | "Name: {}\n" |
| 943 | "Topology: {}\n" |
| 944 | "Vertices: {}\n" |
| 945 | "Material: {}\n" |
| 946 | "vertex shader: {}\n" |
| 947 | "Fragment shader: {}\n", |
| 948 | name, |
| 949 | vk::to_string(primitive.topology), |
| 950 | primitive.vertex_count, |
| 951 | primitive.material_->name, |
| 952 | primitive.vertex_shader, |