Portals - Allow more logging to be disabled

Some logging messages were still being issued when portals/debug/logging was false. This could be annoying in games that stream in parts of levels and repeatedly call `rooms_convert()`.

This PR allows all but essential logging to be disabled.
This commit is contained in:
lawnjelly 2022-07-24 13:44:59 +01:00 committed by Relintai
parent 50d5be10f8
commit 8726cccd56
4 changed files with 34 additions and 28 deletions

View File

@ -463,15 +463,11 @@ bool RoomManager::get_merge_meshes() const {
return _settings_merge_meshes; return _settings_merge_meshes;
} }
void RoomManager::show_warning(const String &p_string, const String &p_extra_string, bool p_alert) { void RoomManager::show_warning(const String &p_string, bool p_skippable, bool p_alert) {
if (p_extra_string != "") { if (p_skippable && !Engine::get_singleton()->is_editor_hint() && !_show_debug) {
WARN_PRINT(p_string + " " + p_extra_string); return;
#ifdef TOOLS_ENABLED
if (p_alert && Engine::get_singleton()->is_editor_hint()) {
EditorNode::get_singleton()->show_warning(TTRGET(p_string) + "\n" + TTRGET(p_extra_string));
} }
#endif
} else {
WARN_PRINT(p_string); WARN_PRINT(p_string);
// OS::get_singleton()->alert(p_string, p_title); // OS::get_singleton()->alert(p_string, p_title);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
@ -479,7 +475,6 @@ void RoomManager::show_warning(const String &p_string, const String &p_extra_str
EditorNode::get_singleton()->show_warning(TTRGET(p_string)); EditorNode::get_singleton()->show_warning(TTRGET(p_string));
} }
#endif #endif
}
} }
void RoomManager::debug_print_line(String p_string, int p_priority) { void RoomManager::debug_print_line(String p_string, int p_priority) {
@ -657,15 +652,15 @@ void RoomManager::rooms_convert() {
} }
if (_warning_portal_link_room_not_found) { if (_warning_portal_link_room_not_found) {
show_warning(TTR("Portal link room not found, check output log for details.")); show_warning(TTR("Portal link room not found, check output log for details."), true);
} }
if (_warning_portal_autolink_failed) { if (_warning_portal_autolink_failed) {
show_warning(TTR("Portal autolink failed, check output log for details.\nCheck the portal is facing outwards from the source room.")); show_warning(TTR("Portal autolink failed, check output log for details.\nCheck the portal is facing outwards from the source room."), true);
} }
if (_warning_room_overlap_detected) { if (_warning_room_overlap_detected) {
show_warning(TTR("Room overlap detected, cameras may work incorrectly in overlapping area.\nCheck output log for details.")); show_warning(TTR("Room overlap detected, cameras may work incorrectly in overlapping area.\nCheck output log for details."), true);
} }
} }
@ -1026,7 +1021,9 @@ void RoomManager::_autolink_portals(Spatial *p_roomlist, LocalVector<Portal *> &
// error condition // error condition
if (!autolink_found) { if (!autolink_found) {
if (_show_debug) {
WARN_PRINT("Portal AUTOLINK failed for " + portal->get_name() + " from " + source_room->get_name()); WARN_PRINT("Portal AUTOLINK failed for " + portal->get_name() + " from " + source_room->get_name());
}
_warning_portal_autolink_failed = true; _warning_portal_autolink_failed = true;
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED

View File

@ -207,10 +207,10 @@ private:
// only prints when user has set 'debug' in the room manager inspector // only prints when user has set 'debug' in the room manager inspector
// also does not show in non editor builds // also does not show in non editor builds
void debug_print_line(String p_string, int p_priority = 0); void debug_print_line(String p_string, int p_priority = 0);
void show_warning(const String &p_string, bool p_skippable = false, bool p_alert = true);
public: public:
static String _find_name_before(Node *p_node, String p_postfix, bool p_allow_no_postfix = false); static String _find_name_before(Node *p_node, String p_postfix, bool p_allow_no_postfix = false);
static void show_warning(const String &p_string, const String &p_extra_string = "", bool p_alert = true);
static real_t _get_default_portal_margin() { return _default_portal_margin; } static real_t _get_default_portal_margin() { return _default_portal_margin; }
private: private:

View File

@ -152,6 +152,7 @@ void PortalRenderer::_debug_print_global_list() {
} }
void PortalRenderer::_log(String p_string, int p_priority) { void PortalRenderer::_log(String p_string, int p_priority) {
if (_show_debug) {
// change this for more debug output .. // change this for more debug output ..
// not selectable at runtime yet. // not selectable at runtime yet.
if (p_priority >= 1) { if (p_priority >= 1) {
@ -159,6 +160,7 @@ void PortalRenderer::_log(String p_string, int p_priority) {
} else { } else {
print_verbose(p_string); print_verbose(p_string);
} }
}
} }
void PortalRenderer::instance_moving_destroy(OcclusionHandle p_handle) { void PortalRenderer::instance_moving_destroy(OcclusionHandle p_handle) {
@ -861,7 +863,7 @@ void PortalRenderer::rooms_finalize(bool p_generate_pvs, bool p_cull_using_pvs,
// as this will worst case give wrong result for a frame // as this will worst case give wrong result for a frame
Engine::get_singleton()->set_portals_active(true); Engine::get_singleton()->set_portals_active(true);
print_line("Room conversion complete. " + itos(_room_pool_ids.size()) + " rooms, " + itos(_portal_pool_ids.size()) + " portals."); _log("Room conversion complete. " + itos(_room_pool_ids.size()) + " rooms, " + itos(_portal_pool_ids.size()) + " portals.", 1);
} }
bool PortalRenderer::sprawl_static_geometry(int p_static_id, const VSStatic &p_static, int p_room_id, const Vector<Vector3> &p_object_pts) { bool PortalRenderer::sprawl_static_geometry(int p_static_id, const VSStatic &p_static, int p_room_id, const Vector<Vector3> &p_object_pts) {
@ -1198,3 +1200,7 @@ String PortalRenderer::_rid_to_string(RID p_rid) {
String PortalRenderer::_addr_to_string(const void *p_addr) { String PortalRenderer::_addr_to_string(const void *p_addr) {
return String::num_uint64((uint64_t)p_addr, 16); return String::num_uint64((uint64_t)p_addr, 16);
} }
PortalRenderer::PortalRenderer() {
_show_debug = GLOBAL_GET("rendering/portals/debug/logging");
}

View File

@ -328,6 +328,7 @@ private:
bool _active = true; bool _active = true;
bool _loaded = false; bool _loaded = false;
bool _debug_sprawl = false; bool _debug_sprawl = false;
bool _show_debug = true;
// if the pvs is generated, we can either cull using dynamic portals or PVS // if the pvs is generated, we can either cull using dynamic portals or PVS
bool _cull_using_pvs = false; bool _cull_using_pvs = false;
@ -356,6 +357,8 @@ public:
void occluder_ensure_up_to_date_sphere(const PortalResources &p_resources, VSOccluder_Instance &r_occluder); void occluder_ensure_up_to_date_sphere(const PortalResources &p_resources, VSOccluder_Instance &r_occluder);
void occluder_ensure_up_to_date_polys(const PortalResources &p_resources, VSOccluder_Instance &r_occluder); void occluder_ensure_up_to_date_polys(const PortalResources &p_resources, VSOccluder_Instance &r_occluder);
void occluder_refresh_room_within(uint32_t p_occluder_pool_id); void occluder_refresh_room_within(uint32_t p_occluder_pool_id);
PortalRenderer();
}; };
inline void PortalRenderer::occluder_ensure_up_to_date_sphere(const PortalResources &p_resources, VSOccluder_Instance &r_occluder) { inline void PortalRenderer::occluder_ensure_up_to_date_sphere(const PortalResources &p_resources, VSOccluder_Instance &r_occluder) {