From 70fe4e8a25f5cc65b3667210d67dd0f144e7408f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 19 Oct 2019 23:46:00 +0200 Subject: [PATCH] python: add more getters to trade.MeshDataXD. Was not sure if properties or methods, but this thing is scheduled for a rewrite anyway. --- src/python/magnum/test/test_primitives.py | 6 ++++++ src/python/magnum/trade.cpp | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/python/magnum/test/test_primitives.py b/src/python/magnum/test/test_primitives.py index 5079ac6..28ec4c7 100644 --- a/src/python/magnum/test/test_primitives.py +++ b/src/python/magnum/test/test_primitives.py @@ -49,6 +49,12 @@ class Square(unittest.TestCase): a = primitives.square_solid(primitives.SquareTextureCoords.GENERATE) self.assertEqual(a.primitive, MeshPrimitive.TRIANGLE_STRIP) self.assertFalse(a.is_indexed()) + self.assertTrue(a.has_texture_coords2d()) + + b = primitives.square_solid() + self.assertEqual(b.primitive, MeshPrimitive.TRIANGLE_STRIP) + self.assertFalse(b.is_indexed()) + self.assertFalse(b.has_texture_coords2d()) def test_wireframe(self): a = primitives.square_wireframe() diff --git a/src/python/magnum/trade.cpp b/src/python/magnum/trade.cpp index e4790c1..c0df8b2 100644 --- a/src/python/magnum/trade.cpp +++ b/src/python/magnum/trade.cpp @@ -140,7 +140,9 @@ template void imageData(py::class_ void meshData(py::class_& c) { c .def_property_readonly("primitive", &T::primitive, "Primitive") - .def("is_indexed", &T::isIndexed, "Whether the mesh is indexed"); + .def("is_indexed", &T::isIndexed, "Whether the mesh is indexed") + .def("has_texture_coords2d", &T::hasTextureCoords2D, "Whether the data contain any 2D texture coordinates") + .def("has_colors", &T::hasColors, "Whether the data contain any vertex colors"); } /* For some reason having ...Args as the second (and not last) template @@ -209,6 +211,7 @@ void trade(py::module& m) { py::class_ meshData3D{m, "MeshData3D", "Three-dimensional mesh data"}; meshData(meshData2D); meshData(meshData3D); + meshData3D.def("has_normals", &Trade::MeshData3D::hasNormals, "Whether the data contain any normals"); py::class_ imageData1D{m, "ImageData1D", "One-dimensional image data"}; py::class_ imageData2D{m, "ImageData2D", "Two-dimensional image data"};