Browse Source

python: added Vector4 from Vector3 and Vector3 from Vector2 constructors.

Not sure why I missed those.
pull/11/head
Vladimír Vondruš 5 years ago
parent
commit
aadc437b25
  1. 2
      doc/python/pages/changelog.rst
  2. 2
      src/python/magnum/math.vector.h

2
doc/python/pages/changelog.rst

@ -35,6 +35,8 @@ Changelog
`Changes since 2020.06`_
========================
- Exposed missing :ref:`Vector4` constructor from a :ref:`Vector3` and a
W component and :ref:`Vector3` from :ref:`Vector2` and a Z component
- Renamed :py:`Matrix3.from()` / :py:`Matrix4.from()` to :ref:`Matrix3.from_()`
/ :ref:`Matrix4.from_()` because :py:`from` is a Python keyword and it
would be silly to have to write :py:`getattr(Matrix4, 'from')` just to use

2
src/python/magnum/math.vector.h

@ -380,6 +380,7 @@ template<class T> void vector3(py::class_<Math::Vector3<T>>& c) {
c
/* Constructors */
.def(py::init<T, T, T>(), "Constructor")
.def(py::init<Math::Vector2<T>, T>(), "Constructor")
.def(py::init([](const std::tuple<T, T, T>& value) {
return Math::Vector3<T>{std::get<0>(value), std::get<1>(value), std::get<2>(value)};
}), "Construct from a tuple")
@ -437,6 +438,7 @@ template<class T> void vector4(py::class_<Math::Vector4<T>>& c) {
c
/* Constructors */
.def(py::init<T, T, T, T>(), "Constructor")
.def(py::init<Math::Vector3<T>, T>(), "Constructor")
.def(py::init([](const std::tuple<T, T, T, T>& value) {
return Math::Vector4<T>{std::get<0>(value), std::get<1>(value), std::get<2>(value), std::get<3>(value)};
}), "Construct from a tuple")

Loading…
Cancel
Save