From e5747c2faaa53cc606795830ed89200ba7da144a Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Wed, 13 Jul 2016 17:16:28 +0200 Subject: [PATCH 1/5] Update bullet to 2.83.7 --- .gitignore | 1 + gradle.properties | 6 +++--- jme3-bullet-native/build.gradle | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index be1334611..c3a69f041 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ /jme3-*/build/ /jme3-bullet-native/bullet.zip /jme3-bullet-native/bullet-2.82-r2704/ +/jme3-bullet-native/bullet3-2.83.7/ /jme3-android-native/openal-soft/ /jme3-android-native/OpenALSoft.zip /jme3-android-native/src/native/jme_decode/STBI/ diff --git a/gradle.properties b/gradle.properties index e5903cec9..168ac64fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ jmeVersionTagID = 0 buildJavaDoc = true # specify if SDK and Native libraries get built -buildNativeProjects = false +buildNativeProjects = true buildAndroidExamples = false # Path to android NDK for building native libraries @@ -19,8 +19,8 @@ buildAndroidExamples = false ndkPath = /opt/android-ndk-r10c # Path for downloading native Bullet -bulletUrl = http://bullet.googlecode.com/files/bullet-2.82-r2704.zip -bulletFolder = bullet-2.82-r2704 +bulletUrl = https://github.com/bulletphysics/bullet3/archive/2.83.7.zip +bulletFolder = bullet3-2.83.7 bulletZipFile = bullet.zip # Path for downloading NetBeans Base diff --git a/jme3-bullet-native/build.gradle b/jme3-bullet-native/build.gradle index f1875647c..ebddec36d 100644 --- a/jme3-bullet-native/build.gradle +++ b/jme3-bullet-native/build.gradle @@ -27,12 +27,13 @@ model { source { srcDir 'src/native/cpp' srcDir bulletSrcPath - exclude 'BulletMultiThreaded/GpuSoftBodySolvers/**' + exclude 'Bullet3OpenCL/**' include '**/*.cpp' } exportedHeaders { srcDir 'src/native/cpp' srcDir bulletSrcPath + exclude 'Bullet3OpenCL/**' include '**/*.h' } } @@ -88,6 +89,7 @@ model { cppCompiler.args "-fvisibility=hidden" cppCompiler.args '-I', "$javaHome/include/linux" cppCompiler.args "-fPIC" + cppCompiler.args "-fpermissive" linker.args "-fvisibility=hidden" } else if (os == "windows") { From 7f87a92c72e3c5730dc3cacdceb5ee5cc7a07270 Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Wed, 13 Jul 2016 17:16:51 +0200 Subject: [PATCH 2/5] Bullet: Remove multithread support that is not available anymore. And was never used by the engine in the first place. --- .../src/native/cpp/jmePhysicsSpace.cpp | 102 +++++++++--------- .../src/native/cpp/jmePhysicsSpace.h | 22 ++-- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp index 6a9e248de..51b5798bb 100644 --- a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp +++ b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp @@ -66,41 +66,41 @@ void jmePhysicsSpace::stepSimulation(jfloat tpf, jint maxSteps, jfloat accuracy) dynamicsWorld->stepSimulation(tpf, maxSteps, accuracy); } -btThreadSupportInterface* jmePhysicsSpace::createSolverThreadSupport(int maxNumThreads) { -#ifdef _WIN32 - Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", SolverThreadFunc, SolverlsMemoryFunc, maxNumThreads); - Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); - threadSupport->startSPU(); -#elif defined (USE_PTHREADS) - PosixThreadSupport::ThreadConstructionInfo constructionInfo("collision", SolverThreadFunc, - SolverlsMemoryFunc, maxNumThreads); - PosixThreadSupport* threadSupport = new PosixThreadSupport(constructionInfo); - threadSupport->startSPU(); -#else - SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", SolverThreadFunc, SolverlsMemoryFunc); - SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); - threadSupport->startSPU(); -#endif - return threadSupport; -} +// btThreadSupportInterface* jmePhysicsSpace::createSolverThreadSupport(int maxNumThreads) { +// #ifdef _WIN32 +// Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", SolverThreadFunc, SolverlsMemoryFunc, maxNumThreads); +// Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); +// threadSupport->startSPU(); +// #elif defined (USE_PTHREADS) +// PosixThreadSupport::ThreadConstructionInfo constructionInfo("collision", SolverThreadFunc, +// SolverlsMemoryFunc, maxNumThreads); +// PosixThreadSupport* threadSupport = new PosixThreadSupport(constructionInfo); +// threadSupport->startSPU(); +// #else +// SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", SolverThreadFunc, SolverlsMemoryFunc); +// SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); +// threadSupport->startSPU(); +// #endif +// return threadSupport; +// } -btThreadSupportInterface* jmePhysicsSpace::createDispatchThreadSupport(int maxNumThreads) { -#ifdef _WIN32 - Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", processCollisionTask, createCollisionLocalStoreMemory, maxNumThreads); - Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); - threadSupport->startSPU(); -#elif defined (USE_PTHREADS) - PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", processCollisionTask, - createCollisionLocalStoreMemory, maxNumThreads); - PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo); - threadSupport->startSPU(); -#else - SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", processCollisionTask, createCollisionLocalStoreMemory); - SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); - threadSupport->startSPU(); -#endif - return threadSupport; -} +// btThreadSupportInterface* jmePhysicsSpace::createDispatchThreadSupport(int maxNumThreads) { +// #ifdef _WIN32 +// Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", processCollisionTask, createCollisionLocalStoreMemory, maxNumThreads); +// Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); +// threadSupport->startSPU(); +// #elif defined (USE_PTHREADS) +// PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", processCollisionTask, +// createCollisionLocalStoreMemory, maxNumThreads); +// PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo); +// threadSupport->startSPU(); +// #else +// SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", processCollisionTask, createCollisionLocalStoreMemory); +// SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); +// threadSupport->startSPU(); +// #endif +// return threadSupport; +// } void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphaseId, jboolean threading) { // collision configuration contains default setup for memory, collision setup @@ -140,23 +140,23 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, btCollisionDispatcher* dispatcher; btConstraintSolver* solver; // use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) - if (threading) { - btThreadSupportInterface* dispatchThreads = createDispatchThreadSupport(4); - dispatcher = new SpuGatheringCollisionDispatcher(dispatchThreads, 4, collisionConfiguration); - dispatcher->setDispatcherFlags(btCollisionDispatcher::CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION); - } else { + // if (threading) { + // btThreadSupportInterface* dispatchThreads = createDispatchThreadSupport(4); + // dispatcher = new SpuGatheringCollisionDispatcher(dispatchThreads, 4, collisionConfiguration); + // dispatcher->setDispatcherFlags(btCollisionDispatcher::CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION); + // } else { dispatcher = new btCollisionDispatcher(collisionConfiguration); - } + // } btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher); // the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) - if (threading) { - btThreadSupportInterface* solverThreads = createSolverThreadSupport(4); - solver = new btParallelConstraintSolver(solverThreads); - } else { + // if (threading) { + // btThreadSupportInterface* solverThreads = createSolverThreadSupport(4); + // solver = new btParallelConstraintSolver(solverThreads); + // } else { solver = new btSequentialImpulseConstraintSolver; - } + // } //create dynamics world btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); @@ -164,12 +164,12 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, dynamicsWorld->setWorldUserInfo(this); //parallel solver requires the contacts to be in a contiguous pool, so avoid dynamic allocation - if (threading) { - world->getSimulationIslandManager()->setSplitIslands(false); - world->getSolverInfo().m_numIterations = 4; - world->getSolverInfo().m_solverMode = SOLVER_SIMD + SOLVER_USE_WARMSTARTING; //+SOLVER_RANDMIZE_ORDER; - world->getDispatchInfo().m_enableSPU = true; - } + // if (threading) { + // world->getSimulationIslandManager()->setSplitIslands(false); + // world->getSolverInfo().m_numIterations = 4; + // world->getSolverInfo().m_solverMode = SOLVER_SIMD + SOLVER_USE_WARMSTARTING; //+SOLVER_RANDMIZE_ORDER; + // world->getDispatchInfo().m_enableSPU = true; + // } broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback()); diff --git a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h index f3e3e2503..2c0c09113 100644 --- a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h +++ b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h @@ -36,15 +36,15 @@ #include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "BulletCollision/CollisionDispatch/btGhostObject.h" #include "BulletDynamics/Character/btKinematicCharacterController.h" -#ifdef _WIN32 -#include "BulletMultiThreaded/Win32ThreadSupport.h" -#else -#include "BulletMultiThreaded/PosixThreadSupport.h" -#endif -#include "BulletMultiThreaded/btParallelConstraintSolver.h" -#include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h" -#include "BulletMultiThreaded/SpuCollisionTaskProcess.h" -#include "BulletMultiThreaded/SequentialThreadSupport.h" +// #ifdef _WIN32 +// #include "BulletMultiThreaded/Win32ThreadSupport.h" +// #else +// #include "BulletMultiThreaded/PosixThreadSupport.h" +// #endif +// #include "BulletMultiThreaded/btParallelConstraintSolver.h" +// #include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h" +// #include "BulletMultiThreaded/SpuCollisionTaskProcess.h" +// #include "BulletMultiThreaded/SequentialThreadSupport.h" #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" #include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h" #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" @@ -59,8 +59,8 @@ private: JavaVM* vm; btDynamicsWorld* dynamicsWorld; jobject javaPhysicsSpace; - btThreadSupportInterface* createSolverThreadSupport(int); - btThreadSupportInterface* createDispatchThreadSupport(int); + // btThreadSupportInterface* createSolverThreadSupport(int); + // btThreadSupportInterface* createDispatchThreadSupport(int); void attachThread(); public: jmePhysicsSpace(){}; From 2958fc53d7c4732c45e08c60a26132eed78a1dbc Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Wed, 13 Jul 2016 17:22:49 +0200 Subject: [PATCH 3/5] Disable buildNativeProjects --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 168ac64fd..dc9c10058 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ jmeVersionTagID = 0 buildJavaDoc = true # specify if SDK and Native libraries get built -buildNativeProjects = true +buildNativeProjects = false buildAndroidExamples = false # Path to android NDK for building native libraries From 6b1656f33703ef4ba8c5d90004657c5bc094faae Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Fri, 22 Jul 2016 00:27:38 +0200 Subject: [PATCH 4/5] Compile with Ofast and disable _FORTIFY_SOURCE --- jme3-bullet-native/build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jme3-bullet-native/build.gradle b/jme3-bullet-native/build.gradle index ebddec36d..cf42e17f6 100644 --- a/jme3-bullet-native/build.gradle +++ b/jme3-bullet-native/build.gradle @@ -85,11 +85,14 @@ model { if (os == "osx") { cppCompiler.args '-I', "$javaHome/include/darwin" + cppCompiler.args "-Ofast" + cppCompiler.args "-U_FORTIFY_SOURCE" } else if (os == "linux") { cppCompiler.args "-fvisibility=hidden" cppCompiler.args '-I', "$javaHome/include/linux" cppCompiler.args "-fPIC" - + cppCompiler.args "-Ofast" + cppCompiler.args "-U_FORTIFY_SOURCE" cppCompiler.args "-fpermissive" linker.args "-fvisibility=hidden" } else if (os == "windows") { @@ -101,6 +104,8 @@ model { } cppCompiler.args "-fpermissive" cppCompiler.args "-static" + cppCompiler.args "-Ofast" + cppCompiler.args "-U_FORTIFY_SOURCE" linker.args "-static" linker.args "-Wl,--exclude-all-symbols" } From e602ed651a77203cd1e304181d2b36f2ed6baa1a Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Tue, 26 Jul 2016 15:12:13 +0200 Subject: [PATCH 5/5] Remove commented/unused code. --- .../src/native/cpp/jmePhysicsSpace.cpp | 81 +------------------ .../src/native/cpp/jmePhysicsSpace.h | 11 --- 2 files changed, 4 insertions(+), 88 deletions(-) diff --git a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp index 51b5798bb..27fde5bfe 100644 --- a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp +++ b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp @@ -31,7 +31,6 @@ */ #include "jmePhysicsSpace.h" #include "jmeBulletUtil.h" -#include /** * Author: Normen Hansen @@ -66,49 +65,8 @@ void jmePhysicsSpace::stepSimulation(jfloat tpf, jint maxSteps, jfloat accuracy) dynamicsWorld->stepSimulation(tpf, maxSteps, accuracy); } -// btThreadSupportInterface* jmePhysicsSpace::createSolverThreadSupport(int maxNumThreads) { -// #ifdef _WIN32 -// Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", SolverThreadFunc, SolverlsMemoryFunc, maxNumThreads); -// Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); -// threadSupport->startSPU(); -// #elif defined (USE_PTHREADS) -// PosixThreadSupport::ThreadConstructionInfo constructionInfo("collision", SolverThreadFunc, -// SolverlsMemoryFunc, maxNumThreads); -// PosixThreadSupport* threadSupport = new PosixThreadSupport(constructionInfo); -// threadSupport->startSPU(); -// #else -// SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", SolverThreadFunc, SolverlsMemoryFunc); -// SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); -// threadSupport->startSPU(); -// #endif -// return threadSupport; -// } - -// btThreadSupportInterface* jmePhysicsSpace::createDispatchThreadSupport(int maxNumThreads) { -// #ifdef _WIN32 -// Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads", processCollisionTask, createCollisionLocalStoreMemory, maxNumThreads); -// Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); -// threadSupport->startSPU(); -// #elif defined (USE_PTHREADS) -// PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", processCollisionTask, -// createCollisionLocalStoreMemory, maxNumThreads); -// PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo); -// threadSupport->startSPU(); -// #else -// SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads", processCollisionTask, createCollisionLocalStoreMemory); -// SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); -// threadSupport->startSPU(); -// #endif -// return threadSupport; -// } - -void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphaseId, jboolean threading) { - // collision configuration contains default setup for memory, collision setup - btDefaultCollisionConstructionInfo cci; - // if(threading){ - // cci.m_defaultMaxPersistentManifoldPoolSize = 32768; - // } - btCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(cci); +void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphaseId, jboolean threading /*unused*/) { + btCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); btVector3 min = btVector3(minX, minY, minZ); btVector3 max = btVector3(maxX, maxY, maxZ); @@ -129,50 +87,19 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, case 3: broadphase = new btDbvtBroadphase(); break; - case 4: - // broadphase = new btGpu3DGridBroadphase( - // min, max, - // 20, 20, 20, - // 10000, 1000, 25); - break; } - btCollisionDispatcher* dispatcher; - btConstraintSolver* solver; - // use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) - // if (threading) { - // btThreadSupportInterface* dispatchThreads = createDispatchThreadSupport(4); - // dispatcher = new SpuGatheringCollisionDispatcher(dispatchThreads, 4, collisionConfiguration); - // dispatcher->setDispatcherFlags(btCollisionDispatcher::CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION); - // } else { - dispatcher = new btCollisionDispatcher(collisionConfiguration); - // } + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration); btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher); - - // the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) - // if (threading) { - // btThreadSupportInterface* solverThreads = createSolverThreadSupport(4); - // solver = new btParallelConstraintSolver(solverThreads); - // } else { - solver = new btSequentialImpulseConstraintSolver; - // } + btConstraintSolver* solver = new btSequentialImpulseConstraintSolver(); //create dynamics world btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); dynamicsWorld = world; dynamicsWorld->setWorldUserInfo(this); - //parallel solver requires the contacts to be in a contiguous pool, so avoid dynamic allocation - // if (threading) { - // world->getSimulationIslandManager()->setSplitIslands(false); - // world->getSolverInfo().m_numIterations = 4; - // world->getSolverInfo().m_solverMode = SOLVER_SIMD + SOLVER_USE_WARMSTARTING; //+SOLVER_RANDMIZE_ORDER; - // world->getDispatchInfo().m_enableSPU = true; - // } - broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback()); - dynamicsWorld->setGravity(btVector3(0, -9.81f, 0)); struct jmeFilterCallback : public btOverlapFilterCallback { diff --git a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h index 2c0c09113..7a61e4e1f 100644 --- a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h +++ b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h @@ -36,15 +36,6 @@ #include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "BulletCollision/CollisionDispatch/btGhostObject.h" #include "BulletDynamics/Character/btKinematicCharacterController.h" -// #ifdef _WIN32 -// #include "BulletMultiThreaded/Win32ThreadSupport.h" -// #else -// #include "BulletMultiThreaded/PosixThreadSupport.h" -// #endif -// #include "BulletMultiThreaded/btParallelConstraintSolver.h" -// #include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h" -// #include "BulletMultiThreaded/SpuCollisionTaskProcess.h" -// #include "BulletMultiThreaded/SequentialThreadSupport.h" #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" #include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h" #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" @@ -59,8 +50,6 @@ private: JavaVM* vm; btDynamicsWorld* dynamicsWorld; jobject javaPhysicsSpace; - // btThreadSupportInterface* createSolverThreadSupport(int); - // btThreadSupportInterface* createDispatchThreadSupport(int); void attachThread(); public: jmePhysicsSpace(){};