+ bool expanded = false;
+
+ if(debug_gui) {
+ if(parent_expanded) {
+ ImGui::PushID(this);
+ ImGui::AlignTextToFramePadding();
+
+ int flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
+ if(children.empty()) flags |= ImGuiTreeNodeFlags_Leaf;
+ if(dbg_sel_node == this) flags |= ImGuiTreeNodeFlags_Selected;
+ expanded = ImGui::TreeNodeEx(name ? name : "<nameless node>", flags);
+ if(ImGui::IsItemClicked()) {
+ dbg_sel_node = this;
+ }
+
+ ImGui::NextColumn();
+ ImGui::Checkbox("##vis", &visible);
+ ImGui::SameLine();
+ if(ImGui::Button("xform")) {
+ ImGui::OpenPopup("xform_popup");
+ }
+ ImGui::SameLine();
+ if(ImGui::Button("bbox")) {
+ ImGui::OpenPopup("bbox_popup");
+ }
+ if(ImGui::BeginPopup("xform_popup")) {
+ ImGui::Text("Local transform");
+ Vec3 p = get_node_position();
+ ImGui::BulletText("P: %g %g %g", p.x, p.y, p.z);
+ Quat q = get_node_rotation();
+ ImGui::BulletText("R: %g %g %g %g", q.x, q.y, q.z, q.w);
+ Vec3 s = get_node_scaling();
+ ImGui::BulletText("S: %g %g %g", s.x, s.y, s.z);
+
+ ImGui::Separator();
+ ImGui::Text("Global transform");
+ p = get_position();
+ ImGui::BulletText("P: %g %g %g", p.x, p.y, p.z);
+ q = get_rotation();
+ ImGui::BulletText("R: %g %g %g %g", q.x, q.y, q.z, q.w);
+ s = get_scaling();
+ ImGui::BulletText("S: %g %g %g", s.x, s.y, s.z);
+
+ const Mat4 &mat = get_matrix();
+ ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[0][0], mat[0][1], mat[0][2], mat[0][3]);
+ ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[1][0], mat[1][1], mat[1][2], mat[1][3]);
+ ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[2][0], mat[2][1], mat[2][2], mat[2][3]);
+ ImGui::BulletText("| %3.3f %3.3f %3.3f %3.3f |", mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
+
+ ImGui::EndPopup();
+ }
+ if(ImGui::BeginPopup("bbox_popup")) {
+ AABox bloc = get_local_bounds();
+ ImGui::Text("Local bounds:");
+ if(bloc.max.x < bloc.min.x || bloc.max.y < bloc.min.y || bloc.max.z < bloc.min.z) {
+ ImGui::BulletText("invalid");
+ } else {
+ ImGui::BulletText("X: %f - %f", bloc.min.x, bloc.max.x);
+ ImGui::BulletText("Y: %f - %f", bloc.min.y, bloc.max.y);
+ ImGui::BulletText("Z: %f - %f", bloc.min.z, bloc.max.z);
+ }
+ ImGui::Separator();
+ AABox bbox = get_bounds();
+ ImGui::Text("Global bounds:");
+ if(bbox.max.x < bbox.min.x || bbox.max.y < bbox.min.y || bbox.max.z < bbox.min.z) {
+ ImGui::BulletText("invalid");
+ } else {
+ ImGui::BulletText("X: %f - %f", bbox.min.x, bbox.max.x);
+ ImGui::BulletText("Y: %f - %f", bbox.min.y, bbox.max.y);
+ ImGui::BulletText("Z: %f - %f", bbox.min.z, bbox.max.z);
+ }
+ ImGui::EndPopup();
+ }
+ ImGui::NextColumn();
+ ImGui::PopID();
+ }
+ }
+