Browse Source

Added fast functions to construct all-zero and all-ones matrices

Josh Yelon 18 years ago
parent
commit
ec4e8cdab5

+ 20 - 0
panda/src/linmath/lmatrix4_src.I

@@ -29,6 +29,26 @@ ident_mat() {
   return _ident_mat;
   return _ident_mat;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::ones_mat
+//       Access: Public, Static
+//  Description: Returns an matrix filled with ones.
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4)::
+ones_mat() {
+  return _ones_mat;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::zeros_mat
+//       Access: Public, Static
+//  Description: Returns an matrix filled with zeros.
+////////////////////////////////////////////////////////////////////
+INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4)::
+zeros_mat() {
+  return _zeros_mat;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix4::Default Constructor
 //     Function: LMatrix4::Default Constructor
 //       Access: Public
 //       Access: Public

+ 12 - 0
panda/src/linmath/lmatrix4_src.cxx

@@ -24,6 +24,18 @@ const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ident_mat =
                       0.0f, 0.0f, 1.0f, 0.0f,
                       0.0f, 0.0f, 1.0f, 0.0f,
                       0.0f, 0.0f, 0.0f, 1.0f);
                       0.0f, 0.0f, 0.0f, 1.0f);
 
 
+const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ones_mat =
+  FLOATNAME(LMatrix4)(1.0f, 1.0f, 1.0f, 1.0f,
+                      1.0f, 1.0f, 1.0f, 1.0f,
+                      1.0f, 1.0f, 1.0f, 1.0f,
+                      1.0f, 1.0f, 1.0f, 1.0f);
+
+const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_zeros_mat =
+  FLOATNAME(LMatrix4)(0.0f, 0.0f, 0.0f, 0.0f,
+                      0.0f, 0.0f, 0.0f, 0.0f,
+                      0.0f, 0.0f, 0.0f, 0.0f,
+                      0.0f, 0.0f, 0.0f, 0.0f);
+
 const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_y_to_z_up_mat =
 const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_y_to_z_up_mat =
   FLOATNAME(LMatrix4)(1.0f, 0.0f, 0.0f, 0.0f,
   FLOATNAME(LMatrix4)(1.0f, 0.0f, 0.0f, 0.0f,
                       0.0f, 0.0f, 1.0f, 0.0f,
                       0.0f, 0.0f, 1.0f, 0.0f,

+ 4 - 0
panda/src/linmath/lmatrix4_src.h

@@ -134,6 +134,8 @@ PUBLISHED:
   INLINE_LINMATH bool invert_in_place();
   INLINE_LINMATH bool invert_in_place();
 
 
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &ident_mat();
   INLINE_LINMATH static const FLOATNAME(LMatrix4) &ident_mat();
+  INLINE_LINMATH static const FLOATNAME(LMatrix4) &ones_mat();
+  INLINE_LINMATH static const FLOATNAME(LMatrix4) &zeros_mat();
 
 
   INLINE_LINMATH void
   INLINE_LINMATH void
     set_translate_mat(const FLOATNAME(LVecBase3) &trans);
     set_translate_mat(const FLOATNAME(LVecBase3) &trans);
@@ -228,6 +230,8 @@ private:
   bool back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const;
   bool back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const;
 
 
   static const FLOATNAME(LMatrix4) _ident_mat;
   static const FLOATNAME(LMatrix4) _ident_mat;
+  static const FLOATNAME(LMatrix4) _ones_mat;
+  static const FLOATNAME(LMatrix4) _zeros_mat;
   static const FLOATNAME(LMatrix4) _y_to_z_up_mat;
   static const FLOATNAME(LMatrix4) _y_to_z_up_mat;
   static const FLOATNAME(LMatrix4) _z_to_y_up_mat;
   static const FLOATNAME(LMatrix4) _z_to_y_up_mat;
   static const FLOATNAME(LMatrix4) _flip_y_mat;
   static const FLOATNAME(LMatrix4) _flip_y_mat;