mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
linmath: fix mat4.get_col3() and mat4.get_row3() when using Eigen
This commit is contained in:
parent
6d9b217c2c
commit
cc4d5259cc
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,3 +87,39 @@ def test_mat4_invert_correct(type):
|
||||
|
||||
assert (mat * inv).is_identity()
|
||||
assert (inv * mat).is_identity()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("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)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user