Browse Source

add RenderAttrib::always_reissue()

David Rose 21 years ago
parent
commit
4cbaf55032

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

@@ -92,3 +92,18 @@ compare_to(const RenderAttrib &other) const {
   // We only call compare_to_impl() if they have the same type.
   // We only call compare_to_impl() if they have the same type.
   return compare_to_impl(&other);
   return compare_to_impl(&other);
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: RenderAttrib::always_reissue
+//       Access: Public
+//  Description: Returns true if the RenderAttrib should be reissued
+//               to the GSG with every state change, even if it is the
+//               same pointer as it was before; or false for the
+//               normal case, to reissue only when the RenderAttrib
+//               pointer changes.
+////////////////////////////////////////////////////////////////////
+INLINE bool RenderAttrib::
+always_reissue() const {
+  return _always_reissue;
+}
+

+ 49 - 6
panda/src/pgraph/renderAttrib.cxx

@@ -39,6 +39,8 @@ RenderAttrib() {
     _attribs = new Attribs;
     _attribs = new Attribs;
   }
   }
   _saved_entry = _attribs->end();
   _saved_entry = _attribs->end();
+
+  _always_reissue = false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -112,12 +114,6 @@ output(ostream &out) const {
   out << get_type();
   out << get_type();
 }
 }
 
 
-void RenderAttrib::
-output_comparefunc(ostream &out,PandaCompareFunc fn) const {
-   static char *FuncStrs[M_always+1] = {"none","never","less","equal", "less or equal","greater","not equal","greater or equal","always"};
-   out << FuncStrs[fn];
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: RenderAttrib::write
 //     Function: RenderAttrib::write
 //       Access: Published, Virtual
 //       Access: Published, Virtual
@@ -223,6 +219,53 @@ invert_compose_impl(const RenderAttrib *other) const {
   return other;
   return other;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: RenderAttrib::output_comparefunc
+//       Access: Protected
+//  Description: Outputs a string representation of the given
+//               PandaCompareFunc object.
+////////////////////////////////////////////////////////////////////
+void RenderAttrib::
+output_comparefunc(ostream &out, PandaCompareFunc fn) const {
+  switch (fn) {
+  case M_none:
+    out << "none";
+    break;
+
+  case M_never:
+    out << "never";
+    break;
+
+  case M_less:
+    out << "less";
+    break;
+
+  case M_equal:
+    out << "equal";
+    break;
+
+  case M_less_equal:
+    out << "less_equal";
+    break;
+
+  case M_greater:
+    out << "greater";
+    break;
+
+  case M_not_equal:
+    out << "not_equal";
+    break;
+
+  case M_greater_equal:
+    out << "greater_equal";
+    break;
+
+  case M_always:
+    out << "always";
+    break;
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: RenderAttrib::make_default_impl
 //     Function: RenderAttrib::make_default_impl
 //       Access: Protected, Virtual
 //       Access: Protected, Virtual

+ 6 - 1
panda/src/pgraph/renderAttrib.h

@@ -71,6 +71,8 @@ public:
   INLINE int compare_to(const RenderAttrib &other) const;
   INLINE int compare_to(const RenderAttrib &other) const;
   virtual void issue(GraphicsStateGuardianBase *gsg) const;
   virtual void issue(GraphicsStateGuardianBase *gsg) const;
 
 
+  INLINE bool always_reissue() const;
+
 PUBLISHED:
 PUBLISHED:
   virtual void output(ostream &out) const;
   virtual void output(ostream &out) const;
   virtual void write(ostream &out, int indent_level) const;
   virtual void write(ostream &out, int indent_level) const;
@@ -93,7 +95,10 @@ protected:
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual RenderAttrib *make_default_impl() const=0;
   virtual RenderAttrib *make_default_impl() const=0;
-  void output_comparefunc(ostream &out,PandaCompareFunc fn) const;
+  void output_comparefunc(ostream &out, PandaCompareFunc fn) const;
+
+protected:
+  bool _always_reissue;
 
 
 private:
 private:
   typedef pset<const RenderAttrib *, IndirectCompareTo<RenderAttrib> > Attribs;
   typedef pset<const RenderAttrib *, IndirectCompareTo<RenderAttrib> > Attribs;

+ 5 - 1
panda/src/pgraph/renderState.cxx

@@ -842,7 +842,11 @@ issue_delta_modify(const RenderState *other,
       if ((*ai)._attrib != (*bi)._attrib) {
       if ((*ai)._attrib != (*bi)._attrib) {
         any_changed = true;
         any_changed = true;
         (*bi)._attrib->issue(gsg);
         (*bi)._attrib->issue(gsg);
+
+      } else if ((*bi)._attrib->always_reissue()) {
+        (*bi)._attrib->issue(gsg);
       }
       }
+        
       *result = *bi;
       *result = *bi;
       ++ai;
       ++ai;
       ++bi;
       ++bi;
@@ -910,7 +914,7 @@ issue_delta_set(const RenderState *other,
     } else {
     } else {
       // Here is an attribute we have in both.  Issue the new one if
       // Here is an attribute we have in both.  Issue the new one if
       // it's different.
       // it's different.
-      if ((*ai)._attrib != (*bi)._attrib) {
+      if ((*ai)._attrib != (*bi)._attrib || (*bi)._attrib->always_reissue()) {
         (*bi)._attrib->issue(gsg);
         (*bi)._attrib->issue(gsg);
       }
       }
       ++ai;
       ++ai;