diff options
author | erwincoumans <erwincoumans@google.com> | 2021-03-04 11:22:53 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-04 11:22:53 -0800 |
commit | db5be234dd2cc5471681663d04c9c3b247fc7e18 (patch) | |
tree | 39683f82f149cd6b9be56e0dd542500bbf61cfd1 | |
parent | 7b84fabb1ef336bf0c5d112365424183cd94b087 (diff) | |
parent | 5832166f53304473fb492cce2d1efcb708b34d00 (diff) | |
download | bullet3-db5be234dd2cc5471681663d04c9c3b247fc7e18.tar.gz |
Merge pull request #3296 from erwincoumans/master
add bullet_client.py options, fix memory leak in EGL/GUI mode with textures.
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Extras/BulletRobotics/CMakeLists.txt | 160 | ||||
-rw-r--r-- | Extras/BulletRoboticsGUI/CMakeLists.txt | 15 | ||||
-rw-r--r-- | examples/OpenGLWindow/GLInstancingRenderer.cpp | 9 | ||||
-rw-r--r-- | examples/pybullet/CMakeLists.txt | 14 | ||||
-rw-r--r-- | examples/pybullet/gym/pybullet_utils/bullet_client.py | 8 | ||||
-rw-r--r-- | src/BulletDynamics/Featherstone/btMultiBody.cpp | 2 | ||||
-rw-r--r-- | src/BulletDynamics/Featherstone/btMultiBody.h | 2 |
8 files changed, 124 insertions, 88 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eed80b1d..a695b7172 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,8 @@ OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF) OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" ON) OPTION(USE_OPENVR "Use OpenVR for virtual reality" OFF) +OPTION(ENABLE_VHACD "Use VHACD in BulletRobotics and pybullet" ON) + OPTION(BULLET2_MULTITHREADING "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF) IF (BULLET2_MULTITHREADING) OPTION(BULLET2_USE_OPEN_MP_MULTITHREADING "Build Bullet 2 with support for multi-threading with OpenMP (requires a compiler with OpenMP support)" OFF) diff --git a/Extras/BulletRobotics/CMakeLists.txt b/Extras/BulletRobotics/CMakeLists.txt index 19aaf8677..d2ab42334 100644 --- a/Extras/BulletRobotics/CMakeLists.txt +++ b/Extras/BulletRobotics/CMakeLists.txt @@ -7,6 +7,9 @@ INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src ) +ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN) + + SET(BulletRobotics_INCLUDES ../../examples/CommonInterfaces/Common2dCanvasInterface.h @@ -94,69 +97,102 @@ SET(BulletRobotics_INCLUDES ) SET(BulletRobotics_SRCS ${BulletRobotics_INCLUDES} - ../../examples/OpenGLWindow/SimpleCamera.cpp - - ../../examples/TinyRenderer/geometry.cpp - ../../examples/TinyRenderer/model.cpp - ../../examples/TinyRenderer/tgaimage.cpp - ../../examples/TinyRenderer/our_gl.cpp - ../../examples/TinyRenderer/TinyRenderer.cpp - - ../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp - ../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp - ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp - ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp - ../../examples/SharedMemory/IKTrajectoryHelper.cpp - ../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp - ../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp - ../../examples/SharedMemory/InProcessMemory.cpp - ../../examples/SharedMemory/PhysicsClient.cpp - ../../examples/SharedMemory/PhysicsServer.cpp - ../../examples/SharedMemory/PhysicsServerSharedMemory.cpp - ../../examples/SharedMemory/PhysicsDirect.cpp - ../../examples/SharedMemory/PhysicsDirectC_API.cpp - ../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp - ../../examples/SharedMemory/b3PluginManager.cpp - ../../examples/SharedMemory/PhysicsClientSharedMemory.cpp - ../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp - ../../examples/SharedMemory/PhysicsClientC_API.cpp - ../../examples/SharedMemory/Win32SharedMemory.cpp - ../../examples/SharedMemory/PosixSharedMemory.cpp - - ../../examples/Utils/b3ResourcePath.cpp - ../../examples/Utils/RobotLoggingUtil.cpp - ../../examples/Utils/b3Clock.cpp - ../../examples/Utils/b3ResourcePath.cpp - ../../examples/Utils/ChromeTraceUtil.cpp - - ../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp - ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp - ../../examples/ThirdPartyLibs/stb_image/stb_image.cpp - ../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp - ../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp - ../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp - ../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp - ../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp - ../../examples/ThirdPartyLibs/BussIK/Misc.cpp - ../../examples/ThirdPartyLibs/BussIK/Node.cpp - ../../examples/ThirdPartyLibs/BussIK/Tree.cpp - ../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp - - ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp - ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp - ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp - ../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp - ../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp - ../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp - ../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp - ../../examples/Importers/ImportURDFDemo/UrdfParser.cpp - ../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp - ../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp - - ../../examples/MultiThreading/b3PosixThreadSupport.cpp - ../../examples/MultiThreading/b3Win32ThreadSupport.cpp - ../../examples/MultiThreading/b3ThreadSupportInterface.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h + ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.h + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.h + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.h + ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h + ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.h + ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp + ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.h + + ../../examples/OpenGLWindow/SimpleCamera.cpp + + ../../examples/TinyRenderer/geometry.cpp + ../../examples/TinyRenderer/model.cpp + ../../examples/TinyRenderer/tgaimage.cpp + ../../examples/TinyRenderer/our_gl.cpp + ../../examples/TinyRenderer/TinyRenderer.cpp + + ../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp + ../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp + ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp + ../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp + ../../examples/SharedMemory/IKTrajectoryHelper.cpp + ../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp + ../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp + ../../examples/SharedMemory/InProcessMemory.cpp + ../../examples/SharedMemory/PhysicsClient.cpp + ../../examples/SharedMemory/PhysicsServer.cpp + ../../examples/SharedMemory/PhysicsServerSharedMemory.cpp + ../../examples/SharedMemory/PhysicsDirect.cpp + ../../examples/SharedMemory/PhysicsDirectC_API.cpp + ../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp + ../../examples/SharedMemory/b3PluginManager.cpp + ../../examples/SharedMemory/PhysicsClientSharedMemory.cpp + ../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp + ../../examples/SharedMemory/PhysicsClientC_API.cpp + ../../examples/SharedMemory/Win32SharedMemory.cpp + ../../examples/SharedMemory/PosixSharedMemory.cpp + + ../../examples/Utils/b3ResourcePath.cpp + ../../examples/Utils/RobotLoggingUtil.cpp + ../../examples/Utils/b3Clock.cpp + ../../examples/Utils/b3ResourcePath.cpp + ../../examples/Utils/ChromeTraceUtil.cpp + + ../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp + ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp + ../../examples/ThirdPartyLibs/stb_image/stb_image.cpp + ../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp + ../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp + ../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp + ../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp + ../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp + ../../examples/ThirdPartyLibs/BussIK/Misc.cpp + ../../examples/ThirdPartyLibs/BussIK/Node.cpp + ../../examples/ThirdPartyLibs/BussIK/Tree.cpp + ../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp + + ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp + ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp + ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp + ../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp + ../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp + ../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp + ../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp + ../../examples/Importers/ImportURDFDemo/UrdfParser.cpp + ../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp + ../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp + + ../../examples/MultiThreading/b3PosixThreadSupport.cpp + ../../examples/MultiThreading/b3Win32ThreadSupport.cpp + ../../examples/MultiThreading/b3ThreadSupportInterface.cpp + + +) + +IF(ENABLE_VHACD) +ADD_DEFINITIONS(-DBT_ENABLE_VHACD) +SET(BulletRobotics_SRCS ${BulletRobotics_SRCS} + ../../Extras/VHACD/test/src/main_vhacd.cpp + ../../Extras/VHACD/src/VHACD.cpp + ../../Extras/VHACD/src/vhacdICHull.cpp + ../../Extras/VHACD/src/vhacdManifoldMesh.cpp + ../../Extras/VHACD/src/vhacdMesh.cpp + ../../Extras/VHACD/src/vhacdVolume.cpp +) +INCLUDE_DIRECTORIES( + ../../Extras/VHACD/inc + ../../Extras/VHACD/public ) +ENDIF(ENABLE_VHACD) IF(BUILD_CLSOCKET) ADD_DEFINITIONS(-DBT_ENABLE_CLSOCKET) diff --git a/Extras/BulletRoboticsGUI/CMakeLists.txt b/Extras/BulletRoboticsGUI/CMakeLists.txt index 29786e2c3..57ab97f24 100644 --- a/Extras/BulletRoboticsGUI/CMakeLists.txt +++ b/Extras/BulletRoboticsGUI/CMakeLists.txt @@ -94,21 +94,6 @@ SET(BulletRoboticsGUI_INCLUDES ) SET(BulletRoboticsGUI_SRCS ${BulletRoboticsGUI_INCLUDES} - - ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h - ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/Shape.h - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.h - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.h - ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h - ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.h - ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp - ../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.h ../../examples/ExampleBrowser/InProcessExampleBrowser.cpp ../../examples/SharedMemory/GraphicsServerExample.cpp ../../examples/SharedMemory/GraphicsClientExample.cpp diff --git a/examples/OpenGLWindow/GLInstancingRenderer.cpp b/examples/OpenGLWindow/GLInstancingRenderer.cpp index 3754c4a9e..81f9ec8c6 100644 --- a/examples/OpenGLWindow/GLInstancingRenderer.cpp +++ b/examples/OpenGLWindow/GLInstancingRenderer.cpp @@ -397,6 +397,15 @@ void GLInstancingRenderer::removeAllInstances() m_graphicsInstances.clear(); m_data->m_publicGraphicsInstances.exitHandles(); m_data->m_publicGraphicsInstances.initHandles(); + + for (int i=0;i<m_data->m_textureHandles.size();i++) + { + InternalTextureHandle& h = m_data->m_textureHandles[i]; + glDeleteTextures(1, &h.m_glTexture); + } + + m_data->m_textureHandles.clear(); + } GLInstancingRenderer::~GLInstancingRenderer() diff --git a/examples/pybullet/CMakeLists.txt b/examples/pybullet/CMakeLists.txt index 1a7f0d5f2..5ee71645e 100644 --- a/examples/pybullet/CMakeLists.txt +++ b/examples/pybullet/CMakeLists.txt @@ -13,15 +13,19 @@ IF(BUILD_PYBULLET_NUMPY) ) ENDIF() -ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN) +ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN ) -SET(pybullet3_SRCS - pybullet.c - ) +IF(ENABLE_VHACD) +ADD_DEFINITIONS(-DBT_ENABLE_VHACD) + +INCLUDE_DIRECTORIES( + ../../Extras/VHACD/inc + ../../Extras/VHACD/public +) +ENDIF(ENABLE_VHACD) SET(pybullet_SRCS pybullet.c - ) IF(BUILD_CLSOCKET) diff --git a/examples/pybullet/gym/pybullet_utils/bullet_client.py b/examples/pybullet/gym/pybullet_utils/bullet_client.py index f4995d3b5..6543313d0 100644 --- a/examples/pybullet/gym/pybullet_utils/bullet_client.py +++ b/examples/pybullet/gym/pybullet_utils/bullet_client.py @@ -9,7 +9,7 @@ import pybullet class BulletClient(object): """A wrapper for pybullet to manage different clients.""" - def __init__(self, connection_mode=None, hostName=None): + def __init__(self, connection_mode=None, hostName=None, options=''): """Creates a Bullet client and connects to a simulation. Args: @@ -22,15 +22,15 @@ class BulletClient(object): """ self._shapes = {} if connection_mode is None: - self._client = pybullet.connect(pybullet.SHARED_MEMORY) + self._client = pybullet.connect(pybullet.SHARED_MEMORY, options=options) if self._client >= 0: return else: connection_mode = pybullet.DIRECT if hostName is None: - self._client = pybullet.connect(connection_mode) + self._client = pybullet.connect(connection_mode, options=options) else: - self._client = pybullet.connect(connection_mode, hostName=hostName) + self._client = pybullet.connect(connection_mode, hostName=hostName, options=options) def __del__(self): """Clean up connection if not already done.""" diff --git a/src/BulletDynamics/Featherstone/btMultiBody.cpp b/src/BulletDynamics/Featherstone/btMultiBody.cpp index 7cb92fa3b..dfc4f92a3 100644 --- a/src/BulletDynamics/Featherstone/btMultiBody.cpp +++ b/src/BulletDynamics/Featherstone/btMultiBody.cpp @@ -1411,7 +1411,7 @@ void btMultiBody::solveImatrix(const btSpatialForceVector &rhs, btSpatialMotionV } } -void btMultiBody::mulMatrix(btScalar *pA, btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const +void btMultiBody::mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const { for (int row = 0; row < rowsA; row++) { diff --git a/src/BulletDynamics/Featherstone/btMultiBody.h b/src/BulletDynamics/Featherstone/btMultiBody.h index 5a3efc941..9cf1ceb5a 100644 --- a/src/BulletDynamics/Featherstone/btMultiBody.h +++ b/src/BulletDynamics/Featherstone/btMultiBody.h @@ -745,7 +745,7 @@ private: } } - void mulMatrix(btScalar * pA, btScalar * pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const; + void mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const; private: btMultiBodyLinkCollider *m_baseCollider; //can be NULL |