ソースを参照

linmath: fix mat4.get_col3() and mat4.get_row3() when using Eigen

rdb 6 年 前
コミット
cc4d5259cc
2 ファイル変更36 行追加8 行削除
  1. 0 8
      panda/src/linmath/lmatrix4_src.I
  2. 36 0
      tests/linmath/test_lmatrix4.py

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

@@ -484,13 +484,9 @@ get_col(int col) const {
  */
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4)::
 get_row3(int row) const {
-#ifdef HAVE_EIGEN
-  return FLOATNAME(LVecBase3)(_m.block<1, 3>(row, 0));
-#else
   return FLOATNAME(LVecBase3)((*this)(row, 0),
                               (*this)(row, 1),
                               (*this)(row, 2));
-#endif  // HAVE_EIGEN
 }
 
 /**
@@ -514,13 +510,9 @@ get_row3(FLOATNAME(LVecBase3) &result_vec,int row) const {
  */
 INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4)::
 get_col3(int col) const {
-#ifdef HAVE_EIGEN
-  return FLOATNAME(LVecBase3)(_m.block<1, 3>(0, col));
-#else
   return FLOATNAME(LVecBase3)((*this)(0, col),
                               (*this)(1, col),
                               (*this)(2, col));
-#endif  // HAVE_EIGEN
 }
 
 /**

+ 36 - 0
tests/linmath/test_lmatrix4.py

@@ -87,3 +87,39 @@ def test_mat4_invert_correct(type):
 
     assert (mat * inv).is_identity()
     assert (inv * mat).is_identity()
+
+
[email protected]("type", (core.LMatrix4d, core.LMatrix4f))
+def test_mat4_rows(type):
+    mat = type((1, 2, 3, 4,
+                5, 6, 7, 8,
+                9, 10, 11, 12,
+                13, 14, 15, 16))
+
+    assert mat.rows[0] == (1, 2, 3, 4)
+    assert mat.rows[1] == (5, 6, 7, 8)
+    assert mat.rows[2] == (9, 10, 11, 12)
+    assert mat.rows[3] == (13, 14, 15, 16)
+
+    assert mat.get_row3(0) == (1, 2, 3)
+    assert mat.get_row3(1) == (5, 6, 7)
+    assert mat.get_row3(2) == (9, 10, 11)
+    assert mat.get_row3(3) == (13, 14, 15)
+
+
[email protected]("type", (core.LMatrix4d, core.LMatrix4f))
+def test_mat4_cols(type):
+    mat = type((1, 5, 9, 13,
+                2, 6, 10, 14,
+                3, 7, 11, 15,
+                4, 8, 12, 16))
+
+    assert mat.cols[0] == (1, 2, 3, 4)
+    assert mat.cols[1] == (5, 6, 7, 8)
+    assert mat.cols[2] == (9, 10, 11, 12)
+    assert mat.cols[3] == (13, 14, 15, 16)
+
+    assert mat.get_col3(0) == (1, 2, 3)
+    assert mat.get_col3(1) == (5, 6, 7)
+    assert mat.get_col3(2) == (9, 10, 11)
+    assert mat.get_col3(3) == (13, 14, 15)