Quellcode durchsuchen

*** empty log message ***

David Rose vor 25 Jahren
Ursprung
Commit
bce5bf2905

+ 24 - 0
panda/src/linmath/lmatrix3_src.I

@@ -315,6 +315,30 @@ end() const {
   return begin() + get_num_components();
   return begin() + get_num_components();
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix3::Ordering Operator
+//       Access: Public
+//  Description: This performs a lexicographical comparison.  It's of
+//               questionable mathematical meaning, but sometimes has
+//               a practical purpose for sorting unique vectors,
+//               especially in an STL container.  Also see
+//               compare_to().
+////////////////////////////////////////////////////////////////////
+INLINE bool FLOATNAME(LMatrix3)::
+operator < (const FLOATNAME(LMatrix3) &other) const {
+  return compare_to(other) < 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix3::Equality Operator
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE bool FLOATNAME(LMatrix3)::
+operator == (const FLOATNAME(LMatrix3) &other) const {
+  return compare_to(other) == 0;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix3::Inequality Operator
 //     Function: LMatrix3::Inequality Operator
 //       Access: Public
 //       Access: Public

+ 6 - 21
panda/src/linmath/lmatrix3_src.cxx

@@ -17,7 +17,6 @@ FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::_ident_mat =
 //               fill_value.  This is of questionable value, but is
 //               fill_value.  This is of questionable value, but is
 //               sometimes useful when initializing to zero.
 //               sometimes useful when initializing to zero.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LMatrix3)::
 void FLOATNAME(LMatrix3)::
 fill(FLOATTYPE fill_value) {
 fill(FLOATTYPE fill_value) {
   set(fill_value, fill_value, fill_value,
   set(fill_value, fill_value, fill_value,
@@ -26,24 +25,14 @@ fill(FLOATTYPE fill_value) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: LMatrix3::Equality Operator
+//     Function: LMatrix3::compare_to
 //       Access: Public
 //       Access: Public
-//  Description: 
+//  Description: Sorts matrices lexicographically, componentwise.
+//               Returns a number less than 0 if this matrix sorts
+//               before the other one, greater than zero if it sorts
+//               after, 0 if they are equivalent (within the indicated
+//               tolerance).
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
-bool FLOATNAME(LMatrix3)::
-operator == (const FLOATNAME(LMatrix3) &other) const {
-  return ((*this)(0, 0) == other(0, 0) &&
-	  (*this)(0, 1) == other(0, 1) &&
-	  (*this)(0, 2) == other(0, 2) &&
-	  (*this)(1, 0) == other(1, 0) &&
-	  (*this)(1, 1) == other(1, 1) &&
-	  (*this)(1, 2) == other(1, 2) &&
-	  (*this)(2, 0) == other(2, 0) &&
-	  (*this)(2, 1) == other(2, 1) &&
-	  (*this)(2, 2) == other(2, 2));
-}
-
 int FLOATNAME(LMatrix3)::
 int FLOATNAME(LMatrix3)::
 compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
 compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
   for (int i = 0; i < 9; i++) {
   for (int i = 0; i < 9; i++) {
@@ -60,7 +49,6 @@ compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
 //  Description: Returns true if two matrices are memberwise equal
 //  Description: Returns true if two matrices are memberwise equal
 //               within a specified tolerance.
 //               within a specified tolerance.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 bool FLOATNAME(LMatrix3)::
 bool FLOATNAME(LMatrix3)::
 almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
 almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
   return (IS_THRESHOLD_EQUAL((*this)(0, 0), other(0, 0), threshold) &&
   return (IS_THRESHOLD_EQUAL((*this)(0, 0), other(0, 0), threshold) &&
@@ -79,7 +67,6 @@ almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const {
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LMatrix3)::
 void FLOATNAME(LMatrix3)::
 init_type() {
 init_type() {
   if (_type_handle == TypeHandle::none()) {
   if (_type_handle == TypeHandle::none()) {
@@ -95,7 +82,6 @@ init_type() {
 //     Function: LMatrix3::write_datagram
 //     Function: LMatrix3::write_datagram
 //  Description: Writes the matrix to the datagram
 //  Description: Writes the matrix to the datagram
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LMatrix3)::
 void FLOATNAME(LMatrix3)::
 write_datagram(Datagram &destination) const
 write_datagram(Datagram &destination) const
 {
 {
@@ -112,7 +98,6 @@ write_datagram(Datagram &destination) const
 //     Function: LMatrix3::read_datagram
 //     Function: LMatrix3::read_datagram
 //  Description: Reads itself out of the datagram
 //  Description: Reads itself out of the datagram
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LMatrix3)::
 void FLOATNAME(LMatrix3)::
 read_datagram(DatagramIterator &scan) 
 read_datagram(DatagramIterator &scan) 
 {
 {

+ 2 - 1
panda/src/linmath/lmatrix3_src.h

@@ -60,7 +60,8 @@ public:
   INLINE const_iterator end() const;
   INLINE const_iterator end() const;
 
 
 PUBLISHED:
 PUBLISHED:
-  bool operator == (const FLOATNAME(LMatrix3) &other) const;
+  INLINE bool operator < (const FLOATNAME(LMatrix3) &other) const;
+  INLINE bool operator == (const FLOATNAME(LMatrix3) &other) const;
   INLINE bool operator != (const FLOATNAME(LMatrix3) &other) const;
   INLINE bool operator != (const FLOATNAME(LMatrix3) &other) const;
 
 
   INLINE int compare_to(const FLOATNAME(LMatrix3) &other) const;
   INLINE int compare_to(const FLOATNAME(LMatrix3) &other) const;

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

@@ -419,6 +419,30 @@ end() const {
   return begin() + 16;
   return begin() + 16;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::Ordering Operator
+//       Access: Public
+//  Description: This performs a lexicographical comparison.  It's of
+//               questionable mathematical meaning, but sometimes has
+//               a practical purpose for sorting unique vectors,
+//               especially in an STL container.  Also see
+//               compare_to().
+////////////////////////////////////////////////////////////////////
+INLINE bool FLOATNAME(LMatrix4)::
+operator < (const FLOATNAME(LMatrix4) &other) const {
+  return compare_to(other) < 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::Equality Operator
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE bool FLOATNAME(LMatrix4)::
+operator == (const FLOATNAME(LMatrix4) &other) const {
+  return compare_to(other) == 0;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix4::Inequality Operator
 //     Function: LMatrix4::Inequality Operator
 //       Access: Public
 //       Access: Public

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

@@ -23,40 +23,12 @@ const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_z_to_y_up_mat =
 		      0.0, 1.0, 0.0, 0.0,
 		      0.0, 1.0, 0.0, 0.0,
 		      0.0, 0.0, 0.0, 1.0);
 		      0.0, 0.0, 0.0, 1.0);
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix4::Equality Operator
-//       Access: Public
-//  Description: 
-////////////////////////////////////////////////////////////////////
-
-bool FLOATNAME(LMatrix4)::
-operator == (const FLOATNAME(LMatrix4) &other) const {
-  return ((*this)(0, 0) == other(0, 0) &&
-	  (*this)(0, 1) == other(0, 1) &&
-	  (*this)(0, 2) == other(0, 2) &&
-	  (*this)(0, 3) == other(0, 3) &&
-	  (*this)(1, 0) == other(1, 0) &&
-	  (*this)(1, 1) == other(1, 1) &&
-	  (*this)(1, 2) == other(1, 2) &&
-	  (*this)(1, 3) == other(1, 3) &&
-	  (*this)(2, 0) == other(2, 0) &&
-	  (*this)(2, 1) == other(2, 1) &&
-	  (*this)(2, 2) == other(2, 2) &&
-	  (*this)(2, 3) == other(2, 3) &&
-	  (*this)(3, 0) == other(3, 0) &&
-	  (*this)(3, 1) == other(3, 1) &&
-	  (*this)(3, 2) == other(3, 2) &&
-	  (*this)(3, 3) == other(3, 3));
-}
-
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix::convert_mat
 //     Function: LMatrix::convert_mat
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: Returns a matrix that transforms from the indicated
 //  Description: Returns a matrix that transforms from the indicated
 //               coordinate system to the indicated coordinate system.
 //               coordinate system to the indicated coordinate system.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::
 FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::
 convert_mat(CoordinateSystem from, CoordinateSystem to) {
 convert_mat(CoordinateSystem from, CoordinateSystem to) {
   if (from == CS_default) {
   if (from == CS_default) {
@@ -121,7 +93,6 @@ convert_mat(CoordinateSystem from, CoordinateSystem to) {
 //  Description: Returns true if two matrices are memberwise equal
 //  Description: Returns true if two matrices are memberwise equal
 //               within a specified tolerance.
 //               within a specified tolerance.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 bool FLOATNAME(LMatrix4)::
 bool FLOATNAME(LMatrix4)::
 almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const {
 almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const {
   return (IS_THRESHOLD_EQUAL((*this)(0, 0), other(0, 0), threshold) &&
   return (IS_THRESHOLD_EQUAL((*this)(0, 0), other(0, 0), threshold) &&
@@ -148,7 +119,6 @@ almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const {
 //       Access: Private
 //       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 bool FLOATNAME(LMatrix4)::
 bool FLOATNAME(LMatrix4)::
 decompose_mat(int index[4]) {
 decompose_mat(int index[4]) {
   int i, j, k;
   int i, j, k;
@@ -222,7 +192,6 @@ decompose_mat(int index[4]) {
 //       Access: Private
 //       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 bool FLOATNAME(LMatrix4)::
 bool FLOATNAME(LMatrix4)::
 back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const {
 back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const {
   int ii = -1;
   int ii = -1;
@@ -258,7 +227,6 @@ back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const {
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LMatrix4)::
 void FLOATNAME(LMatrix4)::
 init_type() {
 init_type() {
   if (_type_handle == TypeHandle::none()) {
   if (_type_handle == TypeHandle::none()) {
@@ -274,7 +242,6 @@ init_type() {
 //     Function: LMatrix4::write_datagram
 //     Function: LMatrix4::write_datagram
 //  Description: Writes the matrix to the datagram
 //  Description: Writes the matrix to the datagram
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LMatrix4)::
 void FLOATNAME(LMatrix4)::
 write_datagram(Datagram &destination) const
 write_datagram(Datagram &destination) const
 {
 {
@@ -292,7 +259,6 @@ write_datagram(Datagram &destination) const
 //     Function: LMatrix4::read_datagram
 //     Function: LMatrix4::read_datagram
 //  Description: Reads itself out of the datagram
 //  Description: Reads itself out of the datagram
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LMatrix4)::
 void FLOATNAME(LMatrix4)::
 read_datagram(DatagramIterator &scan) 
 read_datagram(DatagramIterator &scan) 
 {
 {
@@ -314,7 +280,6 @@ read_datagram(DatagramIterator &scan)
 //               after, 0 if they are equivalent (within the indicated
 //               after, 0 if they are equivalent (within the indicated
 //               tolerance).
 //               tolerance).
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 int FLOATNAME(LMatrix4)::
 int FLOATNAME(LMatrix4)::
 compare_to(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const {
 compare_to(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const {
   for (int i = 0; i < 16; i++) {
   for (int i = 0; i < 16; i++) {

+ 2 - 1
panda/src/linmath/lmatrix4_src.h

@@ -67,7 +67,8 @@ PUBLISHED:
   INLINE const_iterator begin() const;
   INLINE const_iterator begin() const;
   INLINE const_iterator end() const;
   INLINE const_iterator end() const;
 
 
-  bool operator == (const FLOATNAME(LMatrix4) &other) const;
+  INLINE bool operator < (const FLOATNAME(LMatrix4) &other) const;
+  INLINE bool operator == (const FLOATNAME(LMatrix4) &other) const;
   INLINE bool operator != (const FLOATNAME(LMatrix4) &other) const;
   INLINE bool operator != (const FLOATNAME(LMatrix4) &other) const;
 
 
   INLINE int compare_to(const FLOATNAME(LMatrix4) &other) const;
   INLINE int compare_to(const FLOATNAME(LMatrix4) &other) const;

+ 0 - 1
panda/src/linmath/lvecBase3_src.cxx

@@ -19,7 +19,6 @@ const FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::_unit_z =
 //       Access: Public, Static
 //       Access: Public, Static
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
 void FLOATNAME(LVecBase3)::
 void FLOATNAME(LVecBase3)::
 init_type() {
 init_type() {
   if (_type_handle == TypeHandle::none()) {
   if (_type_handle == TypeHandle::none()) {