Browse Source

fix problem with hidden PGui items still being active

David Rose 20 years ago
parent
commit
76252c5316

+ 3 - 4
panda/src/pgraph/cullTraverser.cxx

@@ -199,18 +199,17 @@ traverse_below(CullTraverserData &data) {
   _nodes_pcollector.add_level(1);
   PandaNode *node = data.node();
 
-  bool visible = !(data._draw_mask & PandaNode::get_overall_bit()).is_zero() &&
-    !(data._draw_mask & _camera_mask).is_zero();
+  bool this_node_hidden = data.is_this_node_hidden(this);
 
   const RenderEffects *node_effects = node->get_effects();
-  bool has_decal = visible && node_effects->has_decal();
+  bool has_decal = !this_node_hidden && node_effects->has_decal();
   if (has_decal && !_depth_offset_decals) {
     // Start the three-pass decal rendering if we're not using
     // DepthOffsetAttribs to implement decals.
     start_decal(data);
     
   } else {
-    if (visible && node->is_geom_node()) {
+    if (!this_node_hidden && node->is_geom_node()) {
       _geom_nodes_pcollector.add_level(1);
       GeomNode *geom_node = DCAST(GeomNode, node);
 

+ 15 - 0
panda/src/pgraph/cullTraverserData.I

@@ -150,3 +150,18 @@ is_in_view(const DrawMask &camera_mask) {
   // Otherwise, compare the bounding volume to the frustum.
   return is_in_view_impl();
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: CullTraverserData::is_this_node_hidden
+//       Access: Public
+//  Description: Returns true if this particular node is hidden, even
+//               though we might be traversing past this node to find
+//               a child node that has had show_through() called for
+//               it.  If this returns true, the node should not be
+//               rendered.
+////////////////////////////////////////////////////////////////////
+INLINE bool CullTraverserData::
+is_this_node_hidden(const CullTraverser *trav) const {
+  return (_draw_mask & PandaNode::get_overall_bit()).is_zero() ||
+    (_draw_mask & trav->get_camera_mask()).is_zero();
+}

+ 2 - 1
panda/src/pgraph/cullTraverserData.h

@@ -27,9 +27,9 @@
 #include "geometricBoundingVolume.h"
 #include "pointerTo.h"
 #include "drawMask.h"
+#include "cullTraverser.h"
 
 class PandaNode;
-class CullTraverser;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : CullTraverserData
@@ -64,6 +64,7 @@ public:
   CPT(TransformState) get_net_transform(const CullTraverser *trav) const;
 
   INLINE bool is_in_view(const DrawMask &camera_mask);
+  INLINE bool is_this_node_hidden(const CullTraverser *trav) const;
 
   void apply_transform_and_state(CullTraverser *trav);
   void apply_transform_and_state(CullTraverser *trav, 

+ 2 - 1
panda/src/pgui/pgItem.cxx

@@ -184,7 +184,8 @@ has_cull_callback() const {
 ////////////////////////////////////////////////////////////////////
 bool PGItem::
 cull_callback(CullTraverser *trav, CullTraverserData &data) {
-  if (has_frame() && get_active()) {
+  bool this_node_hidden = data.is_this_node_hidden(trav);
+  if (!this_node_hidden && has_frame() && get_active()) {
     // The item has a frame, so we want to generate a region for it
     // and update the MouseWatcher.