Tech ENABLE_RAYCAST_PICKING_DEBUG - Show number of active raycasters in debug imgui dialog and use ImGui tables to layout the dialog
This commit is contained in:
parent
d9552470a0
commit
7b812a120a
@ -5496,28 +5496,41 @@ void GLCanvas3D::_picking_pass()
|
|||||||
}
|
}
|
||||||
default: { break; }
|
default: { break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto add_strings_row_to_table = [&imgui](const std::string& col_1, const ImVec4& col_1_color, const std::string& col_2, const ImVec4& col_2_color) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableSetColumnIndex(0);
|
||||||
|
imgui.text_colored(col_1_color, col_1.c_str());
|
||||||
|
ImGui::TableSetColumnIndex(1);
|
||||||
|
imgui.text_colored(col_2_color, col_2.c_str());
|
||||||
|
};
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
if (hit.type != SceneRaycaster::EType::None) {
|
if (hit.type != SceneRaycaster::EType::None) {
|
||||||
sprintf(buf, "Object ID: %d", hit.raycaster_id);
|
if (ImGui::BeginTable("Hit", 2)) {
|
||||||
imgui.text(std::string(buf));
|
add_strings_row_to_table("Object ID", ImGuiWrapper::COL_ORANGE_LIGHT, std::to_string(hit.raycaster_id), ImGui::GetStyleColorVec4(ImGuiCol_Text));
|
||||||
sprintf(buf, "Type: %s", object_type.c_str());
|
add_strings_row_to_table("Type", ImGuiWrapper::COL_ORANGE_LIGHT, object_type, ImGui::GetStyleColorVec4(ImGuiCol_Text));
|
||||||
imgui.text(std::string(buf));
|
sprintf(buf, "%.3f, %.3f, %.3f", hit.position.x(), hit.position.y(), hit.position.z());
|
||||||
sprintf(buf, "Position: %.3f, %.3f, %.3f", hit.position.x(), hit.position.y(), hit.position.z());
|
add_strings_row_to_table("Position", ImGuiWrapper::COL_ORANGE_LIGHT, std::string(buf), ImGui::GetStyleColorVec4(ImGuiCol_Text));
|
||||||
imgui.text(std::string(buf));
|
sprintf(buf, "%.3f, %.3f, %.3f", hit.normal.x(), hit.normal.y(), hit.normal.z());
|
||||||
sprintf(buf, "Normal: %.3f, %.3f, %.3f", hit.normal.x(), hit.normal.y(), hit.normal.z());
|
add_strings_row_to_table("Normal", ImGuiWrapper::COL_ORANGE_LIGHT, std::string(buf), ImGui::GetStyleColorVec4(ImGuiCol_Text));
|
||||||
imgui.text(std::string(buf));
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
imgui.text("NO HIT");
|
imgui.text("NO HIT");
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
imgui.text("Registered for picking:");
|
imgui.text("Registered for picking:");
|
||||||
sprintf(buf, "Beds: %d", (int)m_scene_raycaster.beds_count());
|
if (ImGui::BeginTable("Raycasters", 2)) {
|
||||||
imgui.text(std::string(buf));
|
sprintf(buf, "%d (%d)", (int)m_scene_raycaster.beds_count(), (int)m_scene_raycaster.active_beds_count());
|
||||||
sprintf(buf, "Volumes: %d", (int)m_scene_raycaster.volumes_count());
|
add_strings_row_to_table("Beds", ImGuiWrapper::COL_ORANGE_LIGHT, std::string(buf), ImGui::GetStyleColorVec4(ImGuiCol_Text));
|
||||||
imgui.text(std::string(buf));
|
sprintf(buf, "%d (%d)", (int)m_scene_raycaster.volumes_count(), (int)m_scene_raycaster.active_volumes_count());
|
||||||
sprintf(buf, "Gizmo elements: %d", (int)m_scene_raycaster.gizmos_count());
|
add_strings_row_to_table("Volumes", ImGuiWrapper::COL_ORANGE_LIGHT, std::string(buf), ImGui::GetStyleColorVec4(ImGuiCol_Text));
|
||||||
imgui.text(std::string(buf));
|
sprintf(buf, "%d (%d)", (int)m_scene_raycaster.gizmos_count(), (int)m_scene_raycaster.active_gizmos_count());
|
||||||
|
add_strings_row_to_table("Gizmo elements", ImGuiWrapper::COL_ORANGE_LIGHT, std::string(buf), ImGui::GetStyleColorVec4(ImGuiCol_Text));
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
imgui.end();
|
imgui.end();
|
||||||
#endif // ENABLE_RAYCAST_PICKING_DEBUG
|
#endif // ENABLE_RAYCAST_PICKING_DEBUG
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,33 @@ int SceneRaycaster::base_id(EType type)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t SceneRaycaster::active_beds_count() const
|
||||||
|
{
|
||||||
|
size_t count = 0;
|
||||||
|
for (const auto& item : m_bed) {
|
||||||
|
if (item->is_active()) ++count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SceneRaycaster::active_volumes_count() const
|
||||||
|
{
|
||||||
|
size_t count = 0;
|
||||||
|
for (const auto& item : m_volumes) {
|
||||||
|
if (item->is_active()) ++count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t SceneRaycaster::active_gizmos_count() const
|
||||||
|
{
|
||||||
|
size_t count = 0;
|
||||||
|
for (const auto& item : m_gizmos) {
|
||||||
|
if (item->is_active()) ++count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
int SceneRaycaster::encode_id(EType type, int id) { return base_id(type) + id; }
|
int SceneRaycaster::encode_id(EType type, int id) { return base_id(type) + id; }
|
||||||
int SceneRaycaster::decode_id(EType type, int id) { return id - base_id(type); }
|
int SceneRaycaster::decode_id(EType type, int id) { return id - base_id(type); }
|
||||||
|
|
||||||
|
@ -100,6 +100,9 @@ public:
|
|||||||
size_t beds_count() const { return m_bed.size(); }
|
size_t beds_count() const { return m_bed.size(); }
|
||||||
size_t volumes_count() const { return m_volumes.size(); }
|
size_t volumes_count() const { return m_volumes.size(); }
|
||||||
size_t gizmos_count() const { return m_gizmos.size(); }
|
size_t gizmos_count() const { return m_gizmos.size(); }
|
||||||
|
size_t active_beds_count() const;
|
||||||
|
size_t active_volumes_count() const;
|
||||||
|
size_t active_gizmos_count() const;
|
||||||
#endif // ENABLE_RAYCAST_PICKING_DEBUG
|
#endif // ENABLE_RAYCAST_PICKING_DEBUG
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user