From 1d123b6ceb963716913cc9a515a24d97ba64bfd0 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 30 Sep 2019 09:09:26 -0700 Subject: [PATCH 1/5] bump up PyBullet version to 2.5.6 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 88d3e47c1..56cc7887f 100644 --- a/setup.py +++ b/setup.py @@ -490,7 +490,7 @@ if 'BT_USE_EGL' in EGL_CXX_FLAGS: setup( name='pybullet', - version='2.5.5', + version='2.5.6', description= 'Official Python Interface for the Bullet Physics SDK specialized for Robotics Simulation and Reinforcement Learning', long_description= From b6e5609f906abeaa4c8dab98ee0df30e509552d7 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 30 Sep 2019 14:08:22 -0700 Subject: [PATCH 2/5] fix mac osx compilation --- examples/ThirdPartyLibs/glad/glad/gl.h | 4 ++++ setup.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/ThirdPartyLibs/glad/glad/gl.h b/examples/ThirdPartyLibs/glad/glad/gl.h index 3d08b2d45..0dfb4d9c8 100644 --- a/examples/ThirdPartyLibs/glad/glad/gl.h +++ b/examples/ThirdPartyLibs/glad/glad/gl.h @@ -2007,12 +2007,16 @@ typedef khronos_ssize_t GLsizeiptr; #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) typedef long GLintptrARB; #else +#ifndef __gltypes_h_ typedef ptrdiff_t GLintptrARB; #endif +#endif #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060) typedef long GLsizeiptrARB; #else +#ifndef __gltypes_h_ typedef ptrdiff_t GLsizeiptrARB; +#endif #endif typedef int64_t GLint64EXT; typedef uint64_t GLuint64EXT; diff --git a/setup.py b/setup.py index 56cc7887f..82fd4059c 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ def parallelCCompile(self, newcc_args = cc_args if _platform == "darwin": if src.endswith('.cpp'): - newcc_args = cc_args + ["-stdlib=libc++"] + newcc_args = cc_args + ["-mmacosx-version-min=10.7", "-stdlib=libc++"] self._compile(obj, src, ext, newcc_args, extra_postargs, pp_opts) # convert to list, imap is evaluated on-demand @@ -417,7 +417,7 @@ elif _platform == "win32": +["examples/ThirdPartyLibs/glad/gl.c"] elif _platform == "darwin": print("darwin!") - os.environ['LDFLAGS'] = '-framework Cocoa -stdlib=libc++ -framework OpenGL' + os.environ['LDFLAGS'] = '-framework Cocoa -mmacosx-version-min=10.7 -stdlib=libc++ -framework OpenGL' CXX_FLAGS += '-DB3_NO_PYTHON_FRAMEWORK ' CXX_FLAGS += '-DHAS_SOCKLEN_T ' CXX_FLAGS += '-D_DARWIN ' From 2caf4505f0e750a649202dd07e2715b6a6e54ac9 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 3 Oct 2019 09:25:54 -0700 Subject: [PATCH 3/5] pybullet: suppress debug printf (obj texture coordinate out-of-range) --- .../ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp b/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp index 08fa521ae..f44030f21 100644 --- a/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp +++ b/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp @@ -111,7 +111,7 @@ GLInstanceGraphicsShape* btgCreateGraphicsShapeFromWavefrontObj(const tinyobj::a } else { - b3Warning("obj texture coordinate out-of-range!"); + //b3Warning("obj texture coordinate out-of-range!"); vtx2.uv[0] = 0; vtx2.uv[1] = 0; } From 3a4159c7934e22f214a2bbd9ab94047464d1b389 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 8 Oct 2019 19:31:58 -0700 Subject: [PATCH 4/5] fix slow full btMatrixX operator* (was not used) --- src/LinearMath/btMatrixX.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/LinearMath/btMatrixX.h b/src/LinearMath/btMatrixX.h index 388c57c2d..961c94dc6 100644 --- a/src/LinearMath/btMatrixX.h +++ b/src/LinearMath/btMatrixX.h @@ -338,24 +338,23 @@ struct btMatrixX btMatrixX res(rows(), other.cols()); res.setZero(); // BT_PROFILE("btMatrixX mul"); - for (int j = 0; j < res.cols(); ++j) + for (int i = 0; i < rows(); ++i) { { - for (int i = 0; i < res.rows(); ++i) + for (int j = 0; j < other.cols(); ++j) { T dotProd = 0; - // T dotProd2=0; - //int waste=0,waste2=0; - { - // bool useOtherCol = true; { - for (int v = 0; v < rows(); v++) + int r = rows(); + int c = cols(); + + for (int k = 0; k < cols(); k++) { - T w = (*this)(i, v); - if (other(v, j) != 0.f) + T w = (*this)(i, k); + if (other(k, j) != 0.f) { - dotProd += w * other(v, j); + dotProd += w * other(k, j); } } } From 31e778c913c6bd8478f32c3e50ac5b6d90928526 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 9 Oct 2019 22:26:20 -0400 Subject: [PATCH 5/5] avoid crashes in TinyRenderer --- examples/TinyRenderer/TinyRenderer.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/TinyRenderer/TinyRenderer.cpp b/examples/TinyRenderer/TinyRenderer.cpp index f98362d96..2880eb254 100644 --- a/examples/TinyRenderer/TinyRenderer.cpp +++ b/examples/TinyRenderer/TinyRenderer.cpp @@ -156,8 +156,11 @@ struct Shader : public IShader float index_x = b3Max(float(0.0), b3Min(float(m_width - 1), p[0])); float index_y = b3Max(float(0.0), b3Min(float(m_height - 1), p[1])); int idx = int(index_x) + int(index_y) * m_width; // index in the shadowbuffer array - float shadow = 0.8 + 0.2 * (m_shadowBuffer->at(idx) < -depth + 0.05); // magic coeff to avoid z-fighting - + float shadow = 1.0; + if (m_shadowBuffer && idx >=0 && idx size()) + { + shadow = 0.8 + 0.2 * (m_shadowBuffer->at(idx) < -depth + 0.05); // magic coeff to avoid z-fighting + } Vec3f bn = (varying_nrm * bar).normalize(); Vec2f uv = varying_uv * bar; @@ -174,7 +177,13 @@ struct Shader : public IShader for (int i = 0; i < 3; ++i) { - color[i] = b3Min(int(m_ambient_coefficient * color[i] + shadow * (m_diffuse_coefficient * diffuse + m_specular_coefficient * specular) * color[i] * m_light_color[i]), 255); + int orgColor = 0; + float floatColor = (m_ambient_coefficient * color[i] + shadow * (m_diffuse_coefficient * diffuse + m_specular_coefficient * specular) * color[i] * m_light_color[i]); + if (floatColor==floatColor) + { + orgColor=int(floatColor); + } + color[i] = b3Min(orgColor, 255); } return false;