diff --git a/python/generate-python-stubs.sh b/python/generate-python-stubs.sh new file mode 100755 index 0000000000..07e4efd0b1 --- /dev/null +++ b/python/generate-python-stubs.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Usage: ./generate-python-stubs.sh +# To be run *after* building pymrpt. + + +# Generate stub .pyi files: +echo "Generating stub pyi files..." +export PYTHONPATH=$(realpath $(pwd)/../build-Release/) +if compgen -G "$PYTHONPATH/mrpt/pymrpt*.so" > /dev/null; then + echo "Using mrpt module found under: $PYTHONPATH" +else + echo "$PYTHONPATH does not seem to contain a compiled pymrpt module!" + exit 1 +fi +stubgen -p mrpt -p mrpt.pymrpt -o stubs-out + +# applying manual patches to stubs: +echo "Applying manual patches to stubs..." +find . -name "patch-stubs*.diff" | xargs -I FIL bash -c "echo FIL && git apply FIL" diff --git a/python/generate-python.sh b/python/generate-python.sh index 2281664882..1759f09a22 100755 --- a/python/generate-python.sh +++ b/python/generate-python.sh @@ -93,8 +93,6 @@ find $WRAP_OUT_DIR -name "*.cpp" | xargs -I FIL \ sed -i -e 's/(long)/(int64_t)/g' FIL # applying manual patches: -echo "Applying manual patches..." -find . -name "*.diff" | xargs -I FIL bash -c "git apply FIL" +echo "Applying manual patches to pybind11 code..." +find . -name "patch-0*.diff" | xargs -I FIL bash -c "echo FIL && git apply FIL" -# Generate stub .pyi files: -stubgen -p mrpt -p mrpt.pymrpt -o stubs-out diff --git a/python/patch-009.diff b/python/patch-stubs-001.diff similarity index 100% rename from python/patch-009.diff rename to python/patch-stubs-001.diff diff --git a/python/src/mrpt/opengl/DefaultShaders.cpp b/python/src/mrpt/opengl/DefaultShaders.cpp index 29f71a4b6d..40e71d1c66 100644 --- a/python/src/mrpt/opengl/DefaultShaders.cpp +++ b/python/src/mrpt/opengl/DefaultShaders.cpp @@ -68,7 +68,7 @@ void bind_mrpt_opengl_DefaultShaders(std::function< pybind11::module &(std::stri pybind11::class_> cl(M("mrpt::opengl"), "DefaultShaderID", ""); cl.def( pybind11::init( [](){ return new mrpt::opengl::DefaultShaderID(); } ) ); } - { // mrpt::opengl::TRenderMatrices file:mrpt/opengl/TRenderMatrices.h line:28 + { // mrpt::opengl::TRenderMatrices file:mrpt/opengl/TRenderMatrices.h line:29 pybind11::class_> cl(M("mrpt::opengl"), "TRenderMatrices", "Rendering state related to the projection and model-view matrices.\n Used to store matrices that will be sent to shaders.\n\n The homogeneous coordinates of a rendered point comes from the product\n (from right to left) of MODEL, VIEW and PROJECTION matrices:\n\n p = p_matrix * v_matrix * m_matrix * [x y z 1.0]'\n\n \n\n "); cl.def( pybind11::init( [](){ return new mrpt::opengl::TRenderMatrices(); } ) ); cl.def( pybind11::init( [](mrpt::opengl::TRenderMatrices const &o){ return new mrpt::opengl::TRenderMatrices(o); } ) ); @@ -88,7 +88,6 @@ void bind_mrpt_opengl_DefaultShaders(std::function< pybind11::module &(std::stri cl.def_readwrite("azimuth", &mrpt::opengl::TRenderMatrices::azimuth); cl.def_readwrite("elev", &mrpt::opengl::TRenderMatrices::elev); cl.def_readwrite("eyeDistance", &mrpt::opengl::TRenderMatrices::eyeDistance); - cl.def_readwrite("eyeDistance2lightShadowExtension", &mrpt::opengl::TRenderMatrices::eyeDistance2lightShadowExtension); cl.def_readwrite("viewport_width", &mrpt::opengl::TRenderMatrices::viewport_width); cl.def_readwrite("viewport_height", &mrpt::opengl::TRenderMatrices::viewport_height); cl.def_readwrite("initialized", &mrpt::opengl::TRenderMatrices::initialized); @@ -98,7 +97,7 @@ void bind_mrpt_opengl_DefaultShaders(std::function< pybind11::module &(std::stri cl.def_readwrite("up", &mrpt::opengl::TRenderMatrices::up); cl.def("matricesSetIdentity", (void (mrpt::opengl::TRenderMatrices::*)()) &mrpt::opengl::TRenderMatrices::matricesSetIdentity, "C++: mrpt::opengl::TRenderMatrices::matricesSetIdentity() --> void"); cl.def("computeProjectionMatrix", (void (mrpt::opengl::TRenderMatrices::*)(float, float)) &mrpt::opengl::TRenderMatrices::computeProjectionMatrix, "Uses is_projective , vw,vh, etc. and computes p_matrix from either:\n - pinhole_model if set, or\n - FOV, otherwise.\n Replacement for obsolete: gluPerspective() and glOrtho() \n\nC++: mrpt::opengl::TRenderMatrices::computeProjectionMatrix(float, float) --> void", pybind11::arg("zmin"), pybind11::arg("zmax")); - cl.def("computeLightProjectionMatrix", (void (mrpt::opengl::TRenderMatrices::*)(float, float, const struct mrpt::math::TPoint3D_ &)) &mrpt::opengl::TRenderMatrices::computeLightProjectionMatrix, "Updates light_pv \n\nC++: mrpt::opengl::TRenderMatrices::computeLightProjectionMatrix(float, float, const struct mrpt::math::TPoint3D_ &) --> void", pybind11::arg("zmin"), pybind11::arg("zmax"), pybind11::arg("direction")); + cl.def("computeLightProjectionMatrix", (void (mrpt::opengl::TRenderMatrices::*)(float, float, const struct mrpt::opengl::TLightParameters &)) &mrpt::opengl::TRenderMatrices::computeLightProjectionMatrix, "Updates light_pv \n\nC++: mrpt::opengl::TRenderMatrices::computeLightProjectionMatrix(float, float, const struct mrpt::opengl::TLightParameters &) --> void", pybind11::arg("zmin"), pybind11::arg("zmax"), pybind11::arg("lp")); cl.def("computeOrthoProjectionMatrix", (void (mrpt::opengl::TRenderMatrices::*)(float, float, float, float, float, float)) &mrpt::opengl::TRenderMatrices::computeOrthoProjectionMatrix, "Especial case for custom parameters of Orthographic projection.\n Equivalent to `p_matrix = ortho(...);`.\n\n Replacement for obsolete: glOrtho()\n\nC++: mrpt::opengl::TRenderMatrices::computeOrthoProjectionMatrix(float, float, float, float, float, float) --> void", pybind11::arg("left"), pybind11::arg("right"), pybind11::arg("bottom"), pybind11::arg("top"), pybind11::arg("znear"), pybind11::arg("zfar")); cl.def_static("OrthoProjectionMatrix", (class mrpt::math::CMatrixFixed (*)(float, float, float, float, float, float)) &mrpt::opengl::TRenderMatrices::OrthoProjectionMatrix, "Computes and returns an orthographic projection matrix.\n Equivalent to obsolete glOrtho() or glm::ortho().\n\nC++: mrpt::opengl::TRenderMatrices::OrthoProjectionMatrix(float, float, float, float, float, float) --> class mrpt::math::CMatrixFixed", pybind11::arg("left"), pybind11::arg("right"), pybind11::arg("bottom"), pybind11::arg("top"), pybind11::arg("znear"), pybind11::arg("zfar")); cl.def("computeNoProjectionMatrix", (void (mrpt::opengl::TRenderMatrices::*)(float, float)) &mrpt::opengl::TRenderMatrices::computeNoProjectionMatrix, "Especial case: no projection, opengl coordinates are pixels from (0,0)\n bottom-left corner.\n\nC++: mrpt::opengl::TRenderMatrices::computeNoProjectionMatrix(float, float) --> void", pybind11::arg("znear"), pybind11::arg("zfar")); @@ -142,6 +141,7 @@ void bind_mrpt_opengl_DefaultShaders(std::function< pybind11::module &(std::stri cl.def_readwrite("shadow_bias", &mrpt::opengl::TLightParameters::shadow_bias); cl.def_readwrite("shadow_bias_cam2frag", &mrpt::opengl::TLightParameters::shadow_bias_cam2frag); cl.def_readwrite("shadow_bias_normal", &mrpt::opengl::TLightParameters::shadow_bias_normal); + cl.def_readwrite("eyeDistance2lightShadowExtension", &mrpt::opengl::TLightParameters::eyeDistance2lightShadowExtension); cl.def("writeToStream", (void (mrpt::opengl::TLightParameters::*)(class mrpt::serialization::CArchive &) const) &mrpt::opengl::TLightParameters::writeToStream, "C++: mrpt::opengl::TLightParameters::writeToStream(class mrpt::serialization::CArchive &) const --> void", pybind11::arg("out")); cl.def("readFromStream", (void (mrpt::opengl::TLightParameters::*)(class mrpt::serialization::CArchive &)) &mrpt::opengl::TLightParameters::readFromStream, "C++: mrpt::opengl::TLightParameters::readFromStream(class mrpt::serialization::CArchive &) --> void", pybind11::arg("in")); cl.def("assign", (struct mrpt::opengl::TLightParameters & (mrpt::opengl::TLightParameters::*)(const struct mrpt::opengl::TLightParameters &)) &mrpt::opengl::TLightParameters::operator=, "C++: mrpt::opengl::TLightParameters::operator=(const struct mrpt::opengl::TLightParameters &) --> struct mrpt::opengl::TLightParameters &", pybind11::return_value_policy::automatic, pybind11::arg("")); diff --git a/python/stubs-out/mrpt/pymrpt/mrpt/opengl/__init__.pyi b/python/stubs-out/mrpt/pymrpt/mrpt/opengl/__init__.pyi index 237845e70f..dbd2f10ab9 100644 --- a/python/stubs-out/mrpt/pymrpt/mrpt/opengl/__init__.pyi +++ b/python/stubs-out/mrpt/pymrpt/mrpt/opengl/__init__.pyi @@ -3605,6 +3605,7 @@ class TLightParameters: color: mrpt.pymrpt.mrpt.img.TColorf diffuse: float direction: Any + eyeDistance2lightShadowExtension: float shadow_bias: float shadow_bias_cam2frag: float shadow_bias_normal: float @@ -3660,7 +3661,6 @@ class TRenderMatrices: elev: float eye: Any eyeDistance: float - eyeDistance2lightShadowExtension: float initialized: bool is1stShadowMapPass: bool is_projective: bool @@ -3686,7 +3686,7 @@ class TRenderMatrices: def LookAt(self, *args, **kwargs) -> Any: ... def OrthoProjectionMatrix(self, *args, **kwargs) -> Any: ... def assign(self) -> TRenderMatrices: ... - def computeLightProjectionMatrix(self, zmin: float, zmax: float, direction) -> None: ... + def computeLightProjectionMatrix(self, zmin: float, zmax: float, lp) -> None: ... def computeNoProjectionMatrix(self, znear: float, zfar: float) -> None: ... def computeOrthoProjectionMatrix(self, *args, **kwargs) -> Any: ... def computeProjectionMatrix(self, *args, **kwargs) -> Any: ... diff --git a/python/stubs-out/mrpt/pymrpt/std/chrono.pyi b/python/stubs-out/mrpt/pymrpt/std/chrono.pyi index 6ab9717938..dbc88f81c0 100644 --- a/python/stubs-out/mrpt/pymrpt/std/chrono.pyi +++ b/python/stubs-out/mrpt/pymrpt/std/chrono.pyi @@ -37,6 +37,6 @@ class time_point_mrpt_Clock_std_chrono_duration_long_std_ratio_1_10000000_t: def max(self, *args, **kwargs) -> Any: ... def min(self, *args, **kwargs) -> Any: ... def time_since_epoch(self) -> duration_long_std_ratio_1_10000000_t: ... - def to_double()(self, *args, **kwargs) -> Any: ... + def to_double(self) -> float: ... def __iadd__(self, __dur: duration_long_std_ratio_1_10000000_t) -> time_point_mrpt_Clock_std_chrono_duration_long_std_ratio_1_10000000_t: ... def __isub__(self, __dur: duration_long_std_ratio_1_10000000_t) -> time_point_mrpt_Clock_std_chrono_duration_long_std_ratio_1_10000000_t: ...