Browse Source

issue warning for singular transforms over camera

David Rose 19 years ago
parent
commit
dbb25d478c
2 changed files with 32 additions and 0 deletions
  1. 28 0
      panda/src/display/graphicsEngine.cxx
  2. 4 0
      panda/src/display/graphicsEngine.h

+ 28 - 0
panda/src/display/graphicsEngine.cxx

@@ -123,6 +123,9 @@ GraphicsEngine(Pipeline *pipeline) :
   _auto_flip = auto_flip;
   _auto_flip = auto_flip;
   _portal_enabled = false;
   _portal_enabled = false;
   _flip_state = FS_flip;
   _flip_state = FS_flip;
+
+  _singular_warning_last_frame = false;
+  _singular_warning_this_frame = false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1058,6 +1061,9 @@ void GraphicsEngine::
 cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
 cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
   PStatTimer timer(_cull_pcollector, current_thread);
   PStatTimer timer(_cull_pcollector, current_thread);
 
 
+  _singular_warning_last_frame = _singular_warning_this_frame;
+  _singular_warning_this_frame = false;
+
   // Keep track of the cameras we have already used in this thread to
   // Keep track of the cameras we have already used in this thread to
   // render DisplayRegions.
   // render DisplayRegions.
   typedef pmap<NodePath, DisplayRegion *> AlreadyCulled;
   typedef pmap<NodePath, DisplayRegion *> AlreadyCulled;
@@ -1404,6 +1410,28 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) {
   CPT(TransformState) camera_transform = camera.get_transform(scene_parent, current_thread);
   CPT(TransformState) camera_transform = camera.get_transform(scene_parent, current_thread);
   CPT(TransformState) world_transform = scene_parent.get_transform(camera, current_thread);
   CPT(TransformState) world_transform = scene_parent.get_transform(camera, current_thread);
 
 
+  if (camera_transform->is_invalid()) {
+    // There must be a singular transform over the scene.
+    if (!_singular_warning_last_frame) {
+      display_cat.warning()
+        << "Scene " << scene_root << " has net scale (" 
+        << scene_root.get_scale(NodePath()) << "); cannot render.\n";
+      _singular_warning_this_frame = true;
+    }
+    return NULL;
+  }
+
+  if (world_transform->is_invalid()) {
+    // There must be a singular transform over the camera.
+    if (!_singular_warning_last_frame) {
+      display_cat.warning()
+        << "Camera " << camera << " has net scale (" 
+        << camera.get_scale(NodePath()) << "); cannot render.\n";
+    }
+    _singular_warning_this_frame = true;
+    return NULL;
+  }
+
   CPT(RenderState) initial_state = camera_node->get_initial_state();
   CPT(RenderState) initial_state = camera_node->get_initial_state();
 
 
   if (window->get_inverted()) {
   if (window->get_inverted()) {

+ 4 - 0
panda/src/display/graphicsEngine.h

@@ -330,6 +330,10 @@ private:
     FS_flip,  // All windows are done drawing and have flipped.
     FS_flip,  // All windows are done drawing and have flipped.
   };
   };
   FlipState _flip_state;
   FlipState _flip_state;
+
+  bool _singular_warning_last_frame;
+  bool _singular_warning_this_frame;
+
   ReMutex _lock;
   ReMutex _lock;
 
 
   static PStatCollector _wait_pcollector;
   static PStatCollector _wait_pcollector;