Browse Source

display: give DisplayRegions a more recognisable name in PStats

rdb 7 years ago
parent
commit
e759a1b605
1 changed files with 18 additions and 1 deletions
  1. 18 1
      panda/src/display/displayRegion.cxx

+ 18 - 1
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);