From e759a1b6052be122eb9f9985e099f76f1ff6573a Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 21:01:43 +0100 Subject: [PATCH] display: give DisplayRegions a more recognisable name in PStats --- panda/src/display/displayRegion.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index e1765861e1..6946ce6832 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -679,7 +679,24 @@ void DisplayRegion:: set_active_index(int index) { #ifdef DO_PSTATS std::ostringstream strm; - strm << "dr_" << index; + + // To make a more useful name for PStats and debug output, we add the scene + // graph name and camera name. + NodePath camera = get_camera(); + if (!camera.is_empty()) { + Camera *camera_node = DCAST(Camera, camera.node()); + if (camera_node != nullptr) { + NodePath scene_root = camera_node->get_scene(); + if (scene_root.is_empty()) { + scene_root = camera.get_top(); + } + strm << scene_root.get_name(); + } + } + + // And add the index in case we have two scene graphs with the same name. + strm << "#" << index; + string name = strm.str(); _cull_region_pcollector = PStatCollector(_window->get_cull_window_pcollector(), name);