display: give DisplayRegions a more recognisable name in PStats

This commit is contained in:
rdb 2018-11-19 21:01:43 +01:00
parent 8f73f95e79
commit e759a1b605
1 changed files with 18 additions and 1 deletions

View File

@ -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);