Merge pull request #1985 from erwincoumans/master

fix setuptools 'monkey-patch' hang and 2 potential data race conditions.
This commit is contained in:
erwincoumans
2018-11-09 08:48:59 -08:00
committed by GitHub
3 changed files with 21 additions and 16 deletions

View File

@@ -1,6 +1,9 @@
#include <stdio.h> #include <stdio.h>
#include "LinearMath/btTransform.h" #include "LinearMath/btTransform.h"
#include "LinearMath/btThreads.h"
#include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h" #include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h"
#include "BulletCollision/CollisionShapes/btCompoundShape.h" #include "BulletCollision/CollisionShapes/btCompoundShape.h"
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
@@ -28,10 +31,13 @@ static btVector4 colors[4] =
static btVector4 selectColor2() static btVector4 selectColor2()
{ {
static btSpinMutex sMutex;
sMutex.lock();
static int curColor = 0; static int curColor = 0;
btVector4 color = colors[curColor]; btVector4 color = colors[curColor];
curColor++; curColor++;
curColor &= 3; curColor &= 3;
sMutex.unlock();
return color; return color;
} }

View File

@@ -23,7 +23,8 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N
except KeyError: return except KeyError: return
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
# convert to list, imap is evaluated on-demand # convert to list, imap is evaluated on-demand
list(multiprocessing.pool.ThreadPool(N).imap(_single_compile,objects)) pool = multiprocessing.pool.ThreadPool(N)
list(pool.imap(_single_compile,objects))
return objects return objects
import distutils.ccompiler import distutils.ccompiler
distutils.ccompiler.CCompiler.compile=parallelCCompile distutils.ccompiler.CCompiler.compile=parallelCCompile
@@ -583,7 +584,7 @@ if 'BT_USE_EGL' in EGL_CXX_FLAGS:
setup( setup(
name = 'pybullet', name = 'pybullet',
version='2.3.6', version='2.3.7',
description='Official Python Interface for the Bullet Physics SDK specialized for Robotics Simulation and Reinforcement Learning', description='Official Python Interface for the Bullet Physics SDK specialized for Robotics Simulation and Reinforcement Learning',
long_description='pybullet is an easy to use Python module for physics simulation, robotics and deep reinforcement learning based on the Bullet Physics SDK. With pybullet you can load articulated bodies from URDF, SDF and other file formats. pybullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics and collision detection and ray intersection queries. Aside from physics simulation, pybullet supports to rendering, with a CPU renderer and OpenGL visualization and support for virtual reality headsets.', long_description='pybullet is an easy to use Python module for physics simulation, robotics and deep reinforcement learning based on the Bullet Physics SDK. With pybullet you can load articulated bodies from URDF, SDF and other file formats. pybullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics and collision detection and ray intersection queries. Aside from physics simulation, pybullet supports to rendering, with a CPU renderer and OpenGL visualization and support for virtual reality headsets.',
url='https://github.com/bulletphysics/bullet3', url='https://github.com/bulletphysics/bullet3',

View File

@@ -37,21 +37,8 @@ btShapeHull::~btShapeHull()
bool btShapeHull::buildHull(btScalar /*margin*/, int highres) bool btShapeHull::buildHull(btScalar /*margin*/, int highres)
{ {
int numSampleDirections = highres ? NUM_UNITSPHERE_POINTS_HIGHRES : NUM_UNITSPHERE_POINTS;
{
int numPDA = m_shape->getNumPreferredPenetrationDirections();
if (numPDA)
{
for (int i = 0; i < numPDA; i++)
{
btVector3 norm;
m_shape->getPreferredPenetrationDirection(i, norm);
getUnitSpherePoints(highres)[numSampleDirections] = norm;
numSampleDirections++;
}
}
}
int numSampleDirections = highres ? NUM_UNITSPHERE_POINTS_HIGHRES : NUM_UNITSPHERE_POINTS;
btVector3 supportPoints[NUM_UNITSPHERE_POINTS_HIGHRES + MAX_PREFERRED_PENETRATION_DIRECTIONS * 2]; btVector3 supportPoints[NUM_UNITSPHERE_POINTS_HIGHRES + MAX_PREFERRED_PENETRATION_DIRECTIONS * 2];
int i; int i;
for (i = 0; i < numSampleDirections; i++) for (i = 0; i < numSampleDirections; i++)
@@ -59,6 +46,17 @@ bool btShapeHull::buildHull(btScalar /*margin*/, int highres)
supportPoints[i] = m_shape->localGetSupportingVertex(getUnitSpherePoints(highres)[i]); supportPoints[i] = m_shape->localGetSupportingVertex(getUnitSpherePoints(highres)[i]);
} }
int numPDA = m_shape->getNumPreferredPenetrationDirections();
if (numPDA)
{
for (int s = 0; s < numPDA; s++)
{
btVector3 norm;
m_shape->getPreferredPenetrationDirection(s, norm);
supportPoints[i++] = m_shape->localGetSupportingVertex(norm);
numSampleDirections++;
}
}
HullDesc hd; HullDesc hd;
hd.mFlags = QF_TRIANGLES; hd.mFlags = QF_TRIANGLES;
hd.mVcount = static_cast<unsigned int>(numSampleDirections); hd.mVcount = static_cast<unsigned int>(numSampleDirections);