From 5e0b298d505d7ff8160d77fa78cbba0c24d872a7 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 e8ebf472dcc..a209abc437b 100644 --- a/scene/3d/room_manager.cpp +++ b/scene/3d/room_manager.cpp @@ -330,11 +330,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) { @@ -617,6 +617,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; @@ -1234,7 +1235,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; } @@ -1275,7 +1276,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); @@ -1296,6 +1297,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 @@ -1311,7 +1317,7 @@ void RoomManager::_process_static(Room *p_room, Spatial *p_node, Vector if (p_add_to_portal_renderer) { Vector dummy_pts; VisualServer::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()); } } @@ -1348,7 +1354,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)"; } @@ -1385,7 +1391,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)"; } @@ -1415,7 +1421,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 7fd5d41a64b..145b4c446ac 100644 --- a/scene/3d/room_manager.h +++ b/scene/3d/room_manager.h @@ -154,7 +154,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);