Browse Source

pgraph: add version of RenderState::get_attrib(_def) taking a CPT

rdb 7 years ago
parent
commit
19e1b1d877
2 changed files with 17 additions and 2 deletions
  1. 13 2
      panda/src/pgraph/renderState.I
  2. 4 0
      panda/src/pgraph/renderState.h

+ 13 - 2
panda/src/pgraph/renderState.I

@@ -483,7 +483,7 @@ flush_level() {
 
 #ifndef CPPPARSER
 /**
- * Handy templated version of get_attrib that costs to the right type.
+ * Handy templated version of get_attrib that casts to the right type.
  * Returns true if the attribute was present, false otherwise.
  */
 template<class AttribType>
@@ -492,15 +492,26 @@ get_attrib(const AttribType *&attrib) const {
   attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot());
   return (attrib != nullptr);
 }
+template<class AttribType>
+INLINE bool RenderState::
+get_attrib(CPT(AttribType) &attrib) const {
+  attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot());
+  return (attrib != nullptr);
+}
 
 /**
- * Handy templated version of get_attrib_def that costs to the right type.
+ * Handy templated version of get_attrib_def that casts to the right type.
  */
 template<class AttribType>
 INLINE void RenderState::
 get_attrib_def(const AttribType *&attrib) const {
   attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot());
 }
+template<class AttribType>
+INLINE void RenderState::
+get_attrib_def(CPT(AttribType) &attrib) const {
+  attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot());
+}
 #endif  // CPPPARSER
 
 /**

+ 4 - 0
panda/src/pgraph/renderState.h

@@ -162,7 +162,11 @@ public:
   template<class AttribType>
   INLINE bool get_attrib(const AttribType *&attrib) const;
   template<class AttribType>
+  INLINE bool get_attrib(CPT(AttribType) &attrib) const;
+  template<class AttribType>
   INLINE void get_attrib_def(const AttribType *&attrib) const;
+  template<class AttribType>
+  INLINE void get_attrib_def(CPT(AttribType) &attrib) const;
 #endif  // CPPPARSER
 
 private: