Skip to content

Commit 4810773

Browse files
authored
Add pybind11 V2i64/V3i64/V4i64, and split into separate files (AcademySoftwareFoundation#494)
The single PyBindImathVec.cpp file got too big for gcc on mingw32. Signed-off-by: Cary Phillips <cary@ilm.com>
1 parent c4273e1 commit 4810773

9 files changed

Lines changed: 622 additions & 493 deletions

src/pybind11/PyBindImath/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ message(STATUS "Configuring pybindimath module and ${PYBINDIMATH_LIBRARY} librar
1818
set(PYBINDIMATH_SOURCES
1919
PyBindImathFun.cpp
2020
PyBindImathBox.cpp
21-
PyBindImathVec.cpp
21+
PyBindImathVec2.cpp
22+
PyBindImathVec3.cpp
23+
PyBindImathVec4.cpp
2224
PyBindImathMatrix.cpp
2325
PyBindImathPlane.cpp
2426
PyBindImathLine.cpp

src/pybind11/PyBindImath/PyBindImath.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ namespace PyBindImath {
1919

2020
PYBINDIMATH_EXPORT void register_imath_fun(pybind11::module& m);
2121

22-
PYBINDIMATH_EXPORT void register_imath_vec(pybind11::module& m);
22+
PYBINDIMATH_EXPORT void register_imath_vec2(pybind11::module& m);
23+
PYBINDIMATH_EXPORT void register_imath_vec3(pybind11::module& m);
24+
PYBINDIMATH_EXPORT void register_imath_vec4(pybind11::module& m);
2325
PYBINDIMATH_EXPORT void register_imath_matrix(pybind11::module& m);
2426
PYBINDIMATH_EXPORT void register_imath_box(pybind11::module& m);
2527
PYBINDIMATH_EXPORT void register_imath_plane(pybind11::module& m);

src/pybind11/PyBindImath/PyBindImathMatrix.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace {
1515

1616
template <class Matrix>
1717
std::string
18-
repr(const char* name, const Matrix& m)
18+
reprMatrix(const char* name, const Matrix& m)
1919
{
2020
typedef typename Matrix::BaseType T;
2121

@@ -43,7 +43,7 @@ repr(const char* name, const Matrix& m)
4343

4444
template <class Matrix>
4545
static bool
46-
lessThan(const Matrix& mat1, const Matrix& mat2)
46+
lessThanMatrix(const Matrix& mat1, const Matrix& mat2)
4747
{
4848
const int n = static_cast<int>(mat1.dimensions());
4949
for (int x=0; x<n; x++)
@@ -81,7 +81,7 @@ register_matrix(py::class_<M<T>>& m, const char* name)
8181

8282
auto ri = py::return_value_policy::reference_internal;
8383

84-
return m.def("__repr__", [name](const Matrix& self) { return repr(name, self); })
84+
return m.def("__repr__", [name](const Matrix& self) { return reprMatrix(name, self); })
8585
.def(py::init([](){return Matrix();}))
8686
.def(py::init<T>())
8787
.def(py::init<const Matrix&>())
@@ -96,10 +96,10 @@ register_matrix(py::class_<M<T>>& m, const char* name)
9696

9797
.def(py::self == py::self)
9898
.def(py::self != py::self)
99-
.def("__lt__", &lessThan<Matrix>)
100-
.def("__le__", [](const Matrix& a, const Matrix& b) { return !lessThan(b, a); })
101-
.def("__gt__", [](const Matrix& a, const Matrix& b) { return lessThan(b, a); })
102-
.def("__ge__", [](const Matrix& a, const Matrix& b) { return !lessThan(a, b); })
99+
.def("__lt__", &lessThanMatrix<Matrix>)
100+
.def("__le__", [](const Matrix& a, const Matrix& b) { return !lessThanMatrix(b, a); })
101+
.def("__gt__", [](const Matrix& a, const Matrix& b) { return lessThanMatrix(b, a); })
102+
.def("__ge__", [](const Matrix& a, const Matrix& b) { return !lessThanMatrix(a, b); })
103103
.def("equalWithAbsError", [](Matrix& self, const Matrix& other, double e) {
104104
return self.equalWithAbsError(other, typename Matrix::BaseType(e));
105105
})

0 commit comments

Comments
 (0)