Browse Source

python: ugh, once again hit the "let's interpret an int as enum" bug.

next
Vladimír Vondruš 3 years ago
parent
commit
2b09a43f99
  1. 20
      src/python/magnum/trade.cpp

20
src/python/magnum/trade.cpp

@ -957,11 +957,6 @@ void trade(py::module_& m) {
/* Has to be a function instead of a property because there's an /* Has to be a function instead of a property because there's an
overload taking a morph target ID and an overload taking a name */ overload taking a morph target ID and an overload taking a name */
.def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)() const>(&Trade::MeshData::attributeCount), "Attribute array count") .def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)() const>(&Trade::MeshData::attributeCount), "Attribute array count")
.def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)(Int) const>(&Trade::MeshData::attributeCount), "Attribute array count for given morph target",
#if PYBIND11_VERSION_MAJOR*100 + PYBIND11_VERSION_MINOR >= 206
py::kw_only{}, /* new in pybind11 2.6 */
#endif
py::arg("morph_target_id"))
/** @todo direct access to MeshAttributeData, once making custom /** @todo direct access to MeshAttributeData, once making custom
MeshData is desired */ MeshData is desired */
.def("has_attribute", &Trade::MeshData::hasAttribute, "Whether the mesh has given attribute", py::arg("name"), .def("has_attribute", &Trade::MeshData::hasAttribute, "Whether the mesh has given attribute", py::arg("name"),
@ -969,17 +964,22 @@ void trade(py::module_& m) {
py::kw_only{}, /* new in pybind11 2.6 */ py::kw_only{}, /* new in pybind11 2.6 */
#endif #endif
py::arg("morph_target_id") = -1) py::arg("morph_target_id") = -1)
.def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)(Trade::MeshAttribute, Int) const>(&Trade::MeshData::attributeCount), "Count of given named attribute", py::arg("name"),
#if PYBIND11_VERSION_MAJOR*100 + PYBIND11_VERSION_MINOR >= 206
py::kw_only{}, /* new in pybind11 2.6 */
#endif
py::arg("morph_target_id") = -1)
/* IMPORTANT: due to pybind11 behavioral differences on (already EOL'd) /* IMPORTANT: due to pybind11 behavioral differences on (already EOL'd)
Python 3.7 the following overloads need to have the MeshAttribute Python 3.7 the following overloads need to have the MeshAttribute
overload *before* the UnsignedInt overload, otherwise the integer overload *before* the UnsignedInt overload, otherwise the integer
overload gets picked even if an enum is passed from Python, causing overload gets picked even if an enum is passed from Python, causing
massive suffering */ massive suffering */
.def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)(Trade::MeshAttribute, Int) const>(&Trade::MeshData::attributeCount), "Count of given named attribute", py::arg("name"),
#if PYBIND11_VERSION_MAJOR*100 + PYBIND11_VERSION_MINOR >= 206
py::kw_only{}, /* new in pybind11 2.6 */
#endif
py::arg("morph_target_id") = -1)
.def("attribute_count", static_cast<UnsignedInt(Trade::MeshData::*)(Int) const>(&Trade::MeshData::attributeCount), "Attribute array count for given morph target",
#if PYBIND11_VERSION_MAJOR*100 + PYBIND11_VERSION_MINOR >= 206
py::kw_only{}, /* new in pybind11 2.6 */
#endif
py::arg("morph_target_id"))
.def("attribute_name", [](Trade::MeshData& self, UnsignedInt id) { .def("attribute_name", [](Trade::MeshData& self, UnsignedInt id) {
if(id >= self.attributeCount()) { if(id >= self.attributeCount()) {
PyErr_SetNone(PyExc_IndexError); PyErr_SetNone(PyExc_IndexError);

Loading…
Cancel
Save