浏览代码

return status from recompute_if_stale()

David Rose 14 年之前
父节点
当前提交
8f68dd373b
共有 2 个文件被更改,包括 14 次插入8 次删除
  1. 12 6
      panda/src/distort/projectionScreen.cxx
  2. 2 2
      panda/src/distort/projectionScreen.h

+ 12 - 6
panda/src/distort/projectionScreen.cxx

@@ -345,12 +345,13 @@ recompute() {
 //  Description: Calls recompute() only if the relative transform
 //  Description: Calls recompute() only if the relative transform
 //               between the ProjectionScreen and the projector has
 //               between the ProjectionScreen and the projector has
 //               changed, or if any other relevant property has
 //               changed, or if any other relevant property has
-//               changed.
+//               changed.  Returns true if recomputed, false
+//               otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ProjectionScreen::
+bool ProjectionScreen::
 recompute_if_stale() {
 recompute_if_stale() {
   NodePath this_np(NodePath::any_path(this));
   NodePath this_np(NodePath::any_path(this));
-  recompute_if_stale(this_np);
+  return recompute_if_stale(this_np);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -359,17 +360,19 @@ recompute_if_stale() {
 //  Description: Calls recompute() only if the relative transform
 //  Description: Calls recompute() only if the relative transform
 //               between the ProjectionScreen and the projector has
 //               between the ProjectionScreen and the projector has
 //               changed, or if any other relevant property has
 //               changed, or if any other relevant property has
-//               changed.
+//               changed.  Returns true if recomputed, false
+//               otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void ProjectionScreen::
+bool ProjectionScreen::
 recompute_if_stale(const NodePath &this_np) {
 recompute_if_stale(const NodePath &this_np) {
-  nassertv(!this_np.is_empty() && this_np.node() == this);
+  nassertr(!this_np.is_empty() && this_np.node() == this, false);
 
 
   if (_projector_node != (LensNode *)NULL && 
   if (_projector_node != (LensNode *)NULL && 
       _projector_node->get_lens() != (Lens *)NULL) {
       _projector_node->get_lens() != (Lens *)NULL) {
     UpdateSeq lens_change = _projector_node->get_lens()->get_last_change();
     UpdateSeq lens_change = _projector_node->get_lens()->get_last_change();
     if (_stale || lens_change != _projector_lens_change) {
     if (_stale || lens_change != _projector_lens_change) {
       recompute();
       recompute();
+      return true;
 
 
     } else {
     } else {
       // Get the relative transform to ensure it hasn't changed.
       // Get the relative transform to ensure it hasn't changed.
@@ -379,9 +382,12 @@ recompute_if_stale(const NodePath &this_np) {
         _rel_top_mat = top_mat;
         _rel_top_mat = top_mat;
         _computed_rel_top_mat = true;
         _computed_rel_top_mat = true;
         do_recompute(this_np);
         do_recompute(this_np);
+        return true;
       }
       }
     }
     }
   }
   }
+
+  return false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 2 - 2
panda/src/distort/projectionScreen.h

@@ -95,8 +95,8 @@ PUBLISHED:
 
 
   void recompute();
   void recompute();
   INLINE const UpdateSeq &get_last_screen() const;
   INLINE const UpdateSeq &get_last_screen() const;
-  void recompute_if_stale();
-  void recompute_if_stale(const NodePath &this_np);
+  bool recompute_if_stale();
+  bool recompute_if_stale(const NodePath &this_np);
 
 
 private:
 private:
   void do_recompute(const NodePath &this_np);
   void do_recompute(const NodePath &this_np);