From 61645f36f3555a4334b9e67243df969a059f22d6 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Mon, 29 Jan 2024 13:43:43 +0000 Subject: [PATCH] Portals - Improve conversion logging Logging is now allowed in any TOOLS build (rather than just in the editor), but still prevented in final exports. Logging can be switched off via project settings. Autoplacement is now logged. --- scene/3d/room_manager.cpp | 28 +++++++++++++++++----------- scene/3d/room_manager.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/scene/3d/room_manager.cpp b/scene/3d/room_manager.cpp index 7c3aff7fe..c127b82af 100644 --- a/scene/3d/room_manager.cpp +++ b/scene/3d/room_manager.cpp @@ -335,11 +335,11 @@ void RoomManager::_refresh_from_project_settings() { _show_debug = GLOBAL_GET("rendering/portals/debug/logging"); Portal::_portal_plane_convention = GLOBAL_GET("rendering/portals/advanced/flip_imported_portals"); - // force not to show logs when not in editor - if (!Engine::get_singleton()->is_editor_hint()) { - _show_debug = false; - _settings_log_pvs_generation = false; - } + // Disallow logs on final exports. +#ifndef TOOLS_ENABLED + _show_debug = false; + _settings_log_pvs_generation = false; +#endif } void RoomManager::set_roomlist_path(const NodePath &p_path) { @@ -622,6 +622,7 @@ void RoomManager::rooms_convert() { // now we run autoplace to place any statics that have not been explicitly placed in rooms. // These will by definition not affect the room bounds, but is convenient for users to edit // levels in a more freeform manner + convert_log(""); _autoplace_recursive(_roomlist); bool generate_pvs = false; @@ -1239,7 +1240,7 @@ bool RoomManager::_autoplace_object(VisualInstance *p_vi) { Vector room_pts; // we can reuse this function - _process_static(best_room, p_vi, room_pts, true); + _process_static(best_room, p_vi, room_pts, true, true); return true; } @@ -1280,7 +1281,7 @@ void RoomManager::_autoplace_recursive(Spatial *p_node) { } } -void RoomManager::_process_static(Room *p_room, Spatial *p_node, Vector &r_room_pts, bool p_add_to_portal_renderer) { +void RoomManager::_process_static(Room *p_room, Spatial *p_node, Vector &r_room_pts, bool p_add_to_portal_renderer, bool p_autoplaced) { bool ignore = false; VisualInstance *vi = Object::cast_to(p_node); @@ -1301,6 +1302,11 @@ void RoomManager::_process_static(Room *p_room, Spatial *p_node, Vector } if (!ignore) { + String prefix = "\t\t\t"; + if (p_autoplaced) { + prefix = "AUTOPLACED in " + p_room->get_name() + "\t"; + } + // We'll have a done flag. This isn't strictly speaking necessary // because the types should be mutually exclusive, but this would // break if something changes the inheritance hierarchy of the nodes @@ -1316,7 +1322,7 @@ void RoomManager::_process_static(Room *p_room, Spatial *p_node, Vector if (p_add_to_portal_renderer) { Vector dummy_pts; RenderingServer::get_singleton()->room_add_instance(p_room->_room_rid, light->get_instance(), light->get_transformed_aabb(), dummy_pts); - convert_log("\t\t\tLIGT\t" + light->get_name()); + convert_log(prefix + "LIGHT\t" + light->get_name()); } } @@ -1353,7 +1359,7 @@ void RoomManager::_process_static(Room *p_room, Spatial *p_node, Vector } // if bound found points if (p_add_to_portal_renderer) { - String msg = "\t\t\tMESH\t" + mi->get_name(); + String msg = prefix + "MESH\t" + mi->get_name(); if (!added) { msg += "\t(unrecognized)"; } @@ -1390,7 +1396,7 @@ void RoomManager::_process_static(Room *p_room, Spatial *p_node, Vector } // if bound found points if (p_add_to_portal_renderer) { - String msg = "\t\t\tGEOM\t" + gi->get_name(); + String msg = prefix + "GEOM\t" + gi->get_name(); if (!added) { msg += "\t(unrecognized)"; } @@ -1420,7 +1426,7 @@ void RoomManager::_find_statics_recursive(Room *p_room, Spatial *p_node, Vector< return; } - _process_static(p_room, p_node, r_room_pts, p_add_to_portal_renderer); + _process_static(p_room, p_node, r_room_pts, p_add_to_portal_renderer, false); for (int n = 0; n < p_node->get_child_count(); n++) { Spatial *child = Object::cast_to(p_node->get_child(n)); diff --git a/scene/3d/room_manager.h b/scene/3d/room_manager.h index a8dae7e6a..183d7dcb2 100644 --- a/scene/3d/room_manager.h +++ b/scene/3d/room_manager.h @@ -155,7 +155,7 @@ private: bool _convert_manual_bound(Room *p_room, Spatial *p_node, const LocalVector &p_portals); void _check_portal_for_warnings(Portal *p_portal, const AABB &p_room_aabb_without_portals); - void _process_static(Room *p_room, Spatial *p_node, Vector &r_room_pts, bool p_add_to_portal_renderer); + void _process_static(Room *p_room, Spatial *p_node, Vector &r_room_pts, bool p_add_to_portal_renderer, bool p_autoplaced); void _find_statics_recursive(Room *p_room, Spatial *p_node, Vector &r_room_pts, bool p_add_to_portal_renderer); bool _convert_room_hull_preliminary(Room *p_room, const Vector &p_room_pts, const LocalVector &p_portals);