From ad7cbcd4ec447d4423e05b0e0b813327bd722bf3 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 27 Oct 2021 11:20:19 +0200 Subject: [PATCH 1/7] bullet: Fix memory leak getting persistent manifolds from Python These classes ought to be returned by value. Cleaner fix will be in master. Fixes #1193 --- panda/src/bullet/bulletPersistentManifold.cxx | 17 +++++++++++++++++ panda/src/bullet/bulletPersistentManifold.h | 5 +++-- panda/src/bullet/bulletWorld.cxx | 13 +++++++++++++ panda/src/bullet/bulletWorld.h | 5 +++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index 9876ff35ee..f5e96d0464 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -49,6 +49,8 @@ get_contact_processing_threshold() const { */ void BulletPersistentManifold:: clear_manifold() { + nassertv_always(_manifold != nullptr); + LightMutexHolder holder(BulletWorld::get_global_lock()); _manifold->clearManifold(); @@ -59,6 +61,8 @@ clear_manifold() { */ PandaNode *BulletPersistentManifold:: get_node0() { + nassertr_always(_manifold != nullptr, nullptr); + LightMutexHolder holder(BulletWorld::get_global_lock()); #if BT_BULLET_VERSION >= 281 @@ -75,6 +79,8 @@ get_node0() { */ PandaNode *BulletPersistentManifold:: get_node1() { + nassertr_always(_manifold != nullptr, nullptr); + LightMutexHolder holder(BulletWorld::get_global_lock()); #if BT_BULLET_VERSION >= 281 @@ -91,6 +97,8 @@ get_node1() { */ int BulletPersistentManifold:: get_num_manifold_points() const { + nassertr_always(_manifold != nullptr, 0); + LightMutexHolder holder(BulletWorld::get_global_lock()); return _manifold->getNumContacts(); @@ -107,3 +115,12 @@ get_manifold_point(int idx) const { return new BulletManifoldPoint(_manifold->getContactPoint(idx)); } + +/** + * + */ +BulletManifoldPoint BulletPersistentManifold:: +__get_manifold_point(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + return BulletManifoldPoint(_manifold->getContactPoint(idx)); +} diff --git a/panda/src/bullet/bulletPersistentManifold.h b/panda/src/bullet/bulletPersistentManifold.h index 25feb57493..e97192f81e 100644 --- a/panda/src/bullet/bulletPersistentManifold.h +++ b/panda/src/bullet/bulletPersistentManifold.h @@ -35,7 +35,8 @@ PUBLISHED: int get_num_manifold_points() const; BulletManifoldPoint *get_manifold_point(int idx) const; - MAKE_SEQ(get_manifold_points, get_num_manifold_points, get_manifold_point); + BulletManifoldPoint __get_manifold_point(int idx) const; + MAKE_SEQ(get_manifold_points, get_num_manifold_points, __get_manifold_point); PN_stdfloat get_contact_breaking_threshold() const; PN_stdfloat get_contact_processing_threshold() const; @@ -44,7 +45,7 @@ PUBLISHED: MAKE_PROPERTY(node0, get_node0); MAKE_PROPERTY(node1, get_node1); - MAKE_SEQ_PROPERTY(manifold_points, get_num_manifold_points, get_manifold_point); + MAKE_SEQ_PROPERTY(manifold_points, get_num_manifold_points, __get_manifold_point); MAKE_PROPERTY(contact_breaking_threshold, get_contact_breaking_threshold); MAKE_PROPERTY(contact_processing_threshold, get_contact_processing_threshold); diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 9884b45bd7..5590f6aee6 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -1070,6 +1070,19 @@ get_manifold(int idx) const { return (ptr) ? new BulletPersistentManifold(ptr) : nullptr; } +/** + * + */ +BulletPersistentManifold BulletWorld:: +__get_manifold(int idx) const { + LightMutexHolder holder(get_global_lock()); + + nassertr(idx < _dispatcher->getNumManifolds(), BulletPersistentManifold(nullptr)); + + btPersistentManifold *ptr = _dispatcher->getManifoldByIndexInternal(idx); + return BulletPersistentManifold(ptr); +} + /** * */ diff --git a/panda/src/bullet/bulletWorld.h b/panda/src/bullet/bulletWorld.h index 67607923dd..a910e5f503 100644 --- a/panda/src/bullet/bulletWorld.h +++ b/panda/src/bullet/bulletWorld.h @@ -128,7 +128,8 @@ PUBLISHED: // Manifolds int get_num_manifolds() const; BulletPersistentManifold *get_manifold(int idx) const; - MAKE_SEQ(get_manifolds, get_num_manifolds, get_manifold); + BulletPersistentManifold __get_manifold(int idx) const; + MAKE_SEQ(get_manifolds, get_num_manifolds, __get_manifold); // Collision filtering void set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable); @@ -168,7 +169,7 @@ PUBLISHED: MAKE_SEQ_PROPERTY(characters, get_num_characters, get_character); MAKE_SEQ_PROPERTY(vehicles, get_num_vehicles, get_vehicle); MAKE_SEQ_PROPERTY(constraints, get_num_constraints, get_constraint); - MAKE_SEQ_PROPERTY(manifolds, get_num_manifolds, get_manifold); + MAKE_SEQ_PROPERTY(manifolds, get_num_manifolds, __get_manifold); MAKE_PROPERTY(force_update_all_aabbs, get_force_update_all_aabbs, set_force_update_all_aabbs); From c1bb28b6d8007ff3424097a3f8dc9d568c3419cd Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 2 Nov 2021 14:08:27 +0100 Subject: [PATCH 2/7] workflow: Update Ubuntu builder to 18.04 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a06b563405..ecca594aa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,12 +6,12 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: - os: [ubuntu-16.04, windows-2016, macOS-latest] + os: [ubuntu-18.04, windows-2016, macOS-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v1 - name: Install dependencies (Ubuntu) - if: matrix.os == 'ubuntu-16.04' + if: matrix.os == 'ubuntu-18.04' run: | sudo apt-get update sudo apt-get install build-essential bison flex libfreetype6-dev libgl1-mesa-dev libjpeg-dev libode-dev libopenal-dev libpng-dev libssl-dev libvorbis-dev libx11-dev libxcursor-dev libxrandr-dev nvidia-cg-toolkit zlib1g-dev From e87a2a1f0f9524bcd208ad8bc3031ab0ed49244b Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 2 Nov 2021 15:01:18 +0100 Subject: [PATCH 3/7] showbase: Fix typo in API reference --- direct/src/showbase/ShowBase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 72197ffabf..5efe908ecd 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -728,7 +728,7 @@ class ShowBase(DirectObject.DirectObject): of :meth:`~panda3d.core.GraphicsWindow.setUnexposedDraw()`. :param callbackWindowDict: If not None, a - :class:`~panda3d.core.CallbackGraphicWindow` + :class:`~panda3d.core.CallbackGraphicsWindow` is created instead, which allows the caller to create the actual window with its own OpenGL context, and direct Panda's rendering From c1888ba43709123323f38eda266b3744e59d7c46 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 2 Nov 2021 15:01:42 +0100 Subject: [PATCH 4/7] makepackage: Add Python 3.11 to installer.nsi --- makepanda/installer.nsi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 0600d8c449..6696a0cf0b 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -424,6 +424,7 @@ SectionGroup "Python modules" SecGroupPython !insertmacro PyBindingSection 3.8-32 .cp38-win32.pyd !insertmacro PyBindingSection 3.9-32 .cp39-win32.pyd !insertmacro PyBindingSection 3.10-32 .cp310-win32.pyd + !insertmacro PyBindingSection 3.11-32 .cp311-win32.pyd !else !insertmacro PyBindingSection 3.5 .cp35-win_amd64.pyd !insertmacro PyBindingSection 3.6 .cp36-win_amd64.pyd @@ -431,6 +432,7 @@ SectionGroup "Python modules" SecGroupPython !insertmacro PyBindingSection 3.8 .cp38-win_amd64.pyd !insertmacro PyBindingSection 3.9 .cp39-win_amd64.pyd !insertmacro PyBindingSection 3.10 .cp310-win_amd64.pyd + !insertmacro PyBindingSection 3.11 .cp311-win_amd64.pyd !endif SectionGroupEnd @@ -540,6 +542,7 @@ Function .onInit ${If} ${AtLeastWin8} !insertmacro MaybeEnablePyBindingSection 3.9-32 !insertmacro MaybeEnablePyBindingSection 3.10-32 + !insertmacro MaybeEnablePyBindingSection 3.11-32 ${EndIf} !else !insertmacro MaybeEnablePyBindingSection 3.5 @@ -549,6 +552,7 @@ Function .onInit ${If} ${AtLeastWin8} !insertmacro MaybeEnablePyBindingSection 3.9 !insertmacro MaybeEnablePyBindingSection 3.10 + !insertmacro MaybeEnablePyBindingSection 3.11 ${EndIf} !endif @@ -562,6 +566,10 @@ Function .onInit SectionSetFlags ${SecPyBindings3.10} ${SF_RO} SectionSetInstTypes ${SecPyBindings3.10} 0 !endif + !ifdef SecPyBindings3.11 + SectionSetFlags ${SecPyBindings3.11} ${SF_RO} + SectionSetInstTypes ${SecPyBindings3.11} 0 + !endif ${EndUnless} FunctionEnd @@ -873,6 +881,7 @@ Section Uninstall !insertmacro RemovePythonPath 3.8-32 !insertmacro RemovePythonPath 3.9-32 !insertmacro RemovePythonPath 3.10-32 + !insertmacro RemovePythonPath 3.11-32 !else !insertmacro RemovePythonPath 3.5 !insertmacro RemovePythonPath 3.6 @@ -880,6 +889,7 @@ Section Uninstall !insertmacro RemovePythonPath 3.8 !insertmacro RemovePythonPath 3.9 !insertmacro RemovePythonPath 3.10 + !insertmacro RemovePythonPath 3.11 !endif SetDetailsPrint both @@ -955,6 +965,7 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.8-32} $(DESC_SecPyBindings3.8-32) !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.9-32} $(DESC_SecPyBindings3.9-32) !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.10-32} $(DESC_SecPyBindings3.10-32) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.11-32} $(DESC_SecPyBindings3.11-32) !else !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.5} $(DESC_SecPyBindings3.5) !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.6} $(DESC_SecPyBindings3.6) @@ -962,6 +973,7 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.8} $(DESC_SecPyBindings3.8) !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.9} $(DESC_SecPyBindings3.9) !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.10} $(DESC_SecPyBindings3.10) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.11} $(DESC_SecPyBindings3.11) !endif !ifdef INCLUDE_PYVER !insertmacro MUI_DESCRIPTION_TEXT ${SecPython} $(DESC_SecPython) From 9587965c5dcedd958dc2aa3454b77ccf36db90c0 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 2 Nov 2021 15:02:14 +0100 Subject: [PATCH 5/7] bullet: Add some API documentation strings for BulletDebugNode --- panda/src/bullet/bulletDebugNode.I | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/panda/src/bullet/bulletDebugNode.I b/panda/src/bullet/bulletDebugNode.I index eae681aba5..e29863669f 100644 --- a/panda/src/bullet/bulletDebugNode.I +++ b/panda/src/bullet/bulletDebugNode.I @@ -20,7 +20,7 @@ INLINE BulletDebugNode:: } /** - * + * If true, displays collision shapes in wireframe mode. */ INLINE void BulletDebugNode:: show_wireframe(bool show) { @@ -39,7 +39,8 @@ get_show_wireframe() const { } /** - * + * If true, display limits defined for constraints, e.g. a pivot axis or maximum + * amplitude. */ INLINE void BulletDebugNode:: show_constraints(bool show) { @@ -58,7 +59,7 @@ get_show_constraints() const { } /** - * + * If true, displays axis aligned bounding boxes for objects. */ INLINE void BulletDebugNode:: show_bounding_boxes(bool show) { @@ -77,7 +78,7 @@ get_show_bounding_boxes() const { } /** - * + * If true, displays normal vectors for triangle mesh and heightfield faces. */ INLINE void BulletDebugNode:: show_normals(bool show) { @@ -92,4 +93,4 @@ INLINE bool BulletDebugNode:: get_show_normals() const { return _drawer._normals; -} \ No newline at end of file +} From 04c6636744ce583ed6104b7fed20e3d8310562d4 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 2 Nov 2021 15:02:40 +0100 Subject: [PATCH 6/7] pgraph: Add some missing properties to PlaneNode --- panda/src/pgraph/planeNode.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/panda/src/pgraph/planeNode.h b/panda/src/pgraph/planeNode.h index 2b58225abd..6debd7a217 100644 --- a/panda/src/pgraph/planeNode.h +++ b/panda/src/pgraph/planeNode.h @@ -65,6 +65,11 @@ PUBLISHED: INLINE void set_clip_effect(int clip_effect); INLINE int get_clip_effect() const; + MAKE_PROPERTY(plane, get_plane, set_plane); + MAKE_PROPERTY(viz_scale, get_viz_scale, set_viz_scale); + MAKE_PROPERTY(priority, get_priority, set_priority); + MAKE_PROPERTY(clip_effect, get_clip_effect, set_clip_effect); + public: INLINE static UpdateSeq get_sort_seq(); From 29294cb9749a6497fd5babb60bcfaf0ba6aeb0d9 Mon Sep 17 00:00:00 2001 From: Epihaius Date: Mon, 1 Nov 2021 15:48:04 +0100 Subject: [PATCH 7/7] interval: Redefine some properties in MetaInterval class The `play_rate` property invokes the underlying C++ `set_play_rate` method, which leads to a bug (#1202). The property is now redefined to make it invoke the overriding `MetaInterval.set_play_rate` method instead. Fixes #1202 Closes #1204 --- direct/src/interval/MetaInterval.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/direct/src/interval/MetaInterval.py b/direct/src/interval/MetaInterval.py index 4f31c9839d..8c2e26908f 100644 --- a/direct/src/interval/MetaInterval.py +++ b/direct/src/interval/MetaInterval.py @@ -348,10 +348,14 @@ class MetaInterval(CMetaInterval): def getManager(self): return self.__manager + manager = property(getManager, setManager) + def setT(self, t): self.__updateIvals() CMetaInterval.setT(self, t) + t = property(CMetaInterval.getT, setT) + def start(self, startT = 0.0, endT = -1.0, playRate = 1.0): self.__updateIvals() self.setupPlay(startT, endT, playRate, 0) @@ -475,6 +479,8 @@ class MetaInterval(CMetaInterval): else: CMetaInterval.setPlayRate(self, playRate) + play_rate = property(CMetaInterval.getPlayRate, setPlayRate) + def __doPythonCallbacks(self): # This function invokes any Python-level Intervals that need # to be invoked at this point in time. It must be called @@ -549,6 +555,8 @@ class MetaInterval(CMetaInterval): self.__updateIvals() return CMetaInterval.getDuration(self) + duration = property(getDuration) + def __repr__(self, *args, **kw): # This function overrides from the parent level to force it to # update the interval list first, if necessary.