diff --git a/engine/build.xml b/engine/build.xml index 3352105f7..80acc7e65 100644 --- a/engine/build.xml +++ b/engine/build.xml @@ -201,6 +201,7 @@ + diff --git a/engine/lib/bullet/android/armeabi-v7a/libbulletjme.so b/engine/lib/bullet/android/armeabi-v7a/libbulletjme.so new file mode 100644 index 000000000..9091c258a Binary files /dev/null and b/engine/lib/bullet/android/armeabi-v7a/libbulletjme.so differ diff --git a/engine/lib/bullet/android/armeabi/libbulletjme.so b/engine/lib/bullet/android/armeabi/libbulletjme.so new file mode 100644 index 000000000..0cc514a54 Binary files /dev/null and b/engine/lib/bullet/android/armeabi/libbulletjme.so differ diff --git a/engine/lib/bullet/android/x86/libbulletjme.so b/engine/lib/bullet/android/x86/libbulletjme.so new file mode 100644 index 000000000..5ea0d8b49 Binary files /dev/null and b/engine/lib/bullet/android/x86/libbulletjme.so differ diff --git a/engine/lib/bullet/jME3-bullet-android-natives.jar b/engine/lib/bullet/jME3-bullet-android-natives.jar new file mode 100644 index 000000000..33432d1fc Binary files /dev/null and b/engine/lib/bullet/jME3-bullet-android-natives.jar differ diff --git a/engine/lib/bullet/jME3-bullet-natives.jar b/engine/lib/bullet/jME3-bullet-natives.jar index b8da64c89..7d4765b74 100644 Binary files a/engine/lib/bullet/jME3-bullet-natives.jar and b/engine/lib/bullet/jME3-bullet-natives.jar differ diff --git a/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib b/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib index 24536fc4c..7e34029d3 100755 Binary files a/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib and b/engine/lib/bullet/jarcontent/native/macosx/libbulletjme.jnilib differ diff --git a/engine/src/bullet/native/android/Android.mk b/engine/src/bullet/native/android/Android.mk new file mode 100644 index 000000000..3db035184 --- /dev/null +++ b/engine/src/bullet/native/android/Android.mk @@ -0,0 +1,259 @@ +# /* +# Bullet Continuous Collision Detection and Physics Library for Android NDK +# Copyright (c) 2006-2009 Noritsuna Imamura http://www.siprop.org/ +# +# This software is provided 'as-is', without any express or implied warranty. +# In no event will the authors be held liable for any damages arising from the use of this software. +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it freely, +# subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +# 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +# 3. This notice may not be removed or altered from any source distribution. +# */ +LOCAL_PATH:= $(call my-dir) +JME3_PATH:= +BULLET_PATH:= + +include $(CLEAR_VARS) + +LOCAL_MODULE := bulletjme +LOCAL_C_INCLUDES := $(BULLET_PATH)/\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch\ + $(BULLET_PATH)/BulletCollision/CollisionShapes\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver\ + $(BULLET_PATH)/BulletDynamics/Dynamics\ + $(BULLET_PATH)/BulletDynamics/Vehicle\ + $(BULLET_PATH)/LinearMath\ + $(BULLET_PATH)/BulletCollision\ + $(BULLET_PATH)/BulletDynamics\ + $(BULLET_PATH)/BulletMultiThreaded\ + $(BULLET_PATH)/BulletSoftBody\ + $(BULLET_PATH)/ibmsdk\ + $(BULLET_PATH)/LinearMath\ + $(BULLET_PATH)/MiniCL\ + $(BULLET_PATH)/vectormath\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch\ + $(BULLET_PATH)/BulletCollision/CollisionShapes\ + $(BULLET_PATH)/BulletCollision/Gimpact\ + $(BULLET_PATH)/BulletCollision/ibmsdk\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision\ + $(BULLET_PATH)/BulletDynamics/Character\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver\ + $(BULLET_PATH)/BulletDynamics/Dynamics\ + $(BULLET_PATH)/BulletDynamics/ibmsdk\ + $(BULLET_PATH)/BulletDynamics/Vehicle\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers\ + $(BULLET_PATH)/BulletMultiThreaded/out\ + $(BULLET_PATH)/BulletMultiThreaded/SpuNarrowPhaseCollisionTask\ + $(BULLET_PATH)/BulletMultiThreaded/SpuSampleTask\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/CPU\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/DX11\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/DX11/HLSL\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/AMD\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Apple\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/NVidia\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10\ + $(BULLET_PATH)/LinearMath/ibmsdk\ + $(BULLET_PATH)/MiniCL/MiniCLTask\ + $(BULLET_PATH)/vectormath/scalar\ + $(BULLET_PATH)/vectormath/sse + +LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) +LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl -lm -llog + +LOCAL_SRC_FILES := $(JME3_PATH)/com_jme3_bullet_collision_PhysicsCollisionEvent.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_PhysicsCollisionObject.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_BoxCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_CapsuleCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_CollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_CompoundCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_ConeCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_CylinderCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_GImpactCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_HeightfieldCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_HullCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_MeshCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_PlaneCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_SimplexCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_collision_shapes_SphereCollisionShape.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_ConeJoint.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_HingeJoint.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_motors_RotationalLimitMotor.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_motors_TranslationalLimitMotor.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_PhysicsJoint.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_Point2PointJoint.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_SixDofJoint.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_SixDofSpringJoint.cpp\ + $(JME3_PATH)/com_jme3_bullet_joints_SliderJoint.cpp\ + $(JME3_PATH)/com_jme3_bullet_objects_infos_RigidBodyMotionState.cpp\ + $(JME3_PATH)/com_jme3_bullet_objects_PhysicsCharacter.cpp\ + $(JME3_PATH)/com_jme3_bullet_objects_PhysicsGhostObject.cpp\ + $(JME3_PATH)/com_jme3_bullet_objects_PhysicsRigidBody.cpp\ + $(JME3_PATH)/com_jme3_bullet_objects_PhysicsVehicle.cpp\ + $(JME3_PATH)/com_jme3_bullet_objects_VehicleWheel.cpp\ + $(JME3_PATH)/com_jme3_bullet_PhysicsSpace.cpp\ + $(JME3_PATH)/com_jme3_bullet_util_DebugShapeFactory.cpp\ + $(JME3_PATH)/com_jme3_bullet_util_NativeMeshUtil.cpp\ + $(JME3_PATH)/jmeBulletUtil.cpp\ + $(JME3_PATH)/jmeClasses.cpp\ + $(JME3_PATH)/jmeMotionState.cpp\ + $(JME3_PATH)/jmePhysicsSpace.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btDbvt.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btDispatcher.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp\ + $(BULLET_PATH)/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btCollisionObject.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btCollisionWorld.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btGhostObject.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btManifoldResult.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/btUnionFind.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btBox2dShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btBoxShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btCapsuleShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btCollisionShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btCompoundShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConcaveShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConeShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConvex2dShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConvexHullShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConvexInternalShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConvexPolyhedron.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConvexShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btCylinderShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btEmptyShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btMultiSphereShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btOptimizedBvh.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btShapeHull.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btSphereShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btTetrahedronShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btTriangleBuffer.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btTriangleCallback.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btTriangleMesh.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp\ + $(BULLET_PATH)/BulletCollision/CollisionShapes/btUniformScalingShape.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/btContactProcessing.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/btGenericPoolAllocator.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/btGImpactBvh.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/btGImpactShape.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/btTriangleShapeEx.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/gim_box_set.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/gim_contact.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/gim_memory.cpp\ + $(BULLET_PATH)/BulletCollision/Gimpact/gim_tri_collision.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp\ + $(BULLET_PATH)/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp\ + $(BULLET_PATH)/BulletDynamics/Character/btKinematicCharacterController.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btContactConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp\ + $(BULLET_PATH)/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp\ + $(BULLET_PATH)/BulletDynamics/Dynamics/btRigidBody.cpp\ + $(BULLET_PATH)/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp\ + $(BULLET_PATH)/BulletDynamics/Dynamics/Bullet-C-API.cpp\ + $(BULLET_PATH)/BulletDynamics/Vehicle/btRaycastVehicle.cpp\ + $(BULLET_PATH)/BulletDynamics/Vehicle/btWheelInfo.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/btGpu3DGridBroadphase.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/btParallelConstraintSolver.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/btThreadSupportInterface.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/PosixThreadSupport.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SequentialThreadSupport.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuCollisionObjectWrapper.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuCollisionTaskProcess.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuContactManifoldCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuFakeDma.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuGatheringCollisionDispatcher.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuLibspe2Support.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuSampleTaskProcess.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/Win32ThreadSupport.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/CPU/btSoftBodySolver_CPU.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL/MiniCLTaskWrap.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuMinkowskiPenetrationDepthSolver.cpp\ + $(BULLET_PATH)/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp\ + $(BULLET_PATH)/BulletSoftBody/btDefaultSoftBodySolver.cpp\ + $(BULLET_PATH)/BulletSoftBody/btSoftBody.cpp\ + $(BULLET_PATH)/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletSoftBody/btSoftBodyHelpers.cpp\ + $(BULLET_PATH)/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp\ + $(BULLET_PATH)/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp\ + $(BULLET_PATH)/BulletSoftBody/btSoftRigidDynamicsWorld.cpp\ + $(BULLET_PATH)/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp\ + $(BULLET_PATH)/LinearMath/btAlignedAllocator.cpp\ + $(BULLET_PATH)/LinearMath/btConvexHull.cpp\ + $(BULLET_PATH)/LinearMath/btConvexHullComputer.cpp\ + $(BULLET_PATH)/LinearMath/btGeometryUtil.cpp\ + $(BULLET_PATH)/LinearMath/btQuickprof.cpp\ + $(BULLET_PATH)/LinearMath/btSerializer.cpp\ + $(BULLET_PATH)/MiniCL/MiniCL.cpp\ + $(BULLET_PATH)/MiniCL/MiniCLTaskScheduler.cpp\ + $(BULLET_PATH)/MiniCL/MiniCLTask/MiniCLTask.cpp + +include $(BUILD_SHARED_LIBRARY) diff --git a/engine/src/bullet/native/android/Application.mk b/engine/src/bullet/native/android/Application.mk new file mode 100644 index 000000000..9e8be3571 --- /dev/null +++ b/engine/src/bullet/native/android/Application.mk @@ -0,0 +1,2 @@ +APP_MODULES := bulletjme +APP_ABI := all \ No newline at end of file diff --git a/engine/src/bullet/native/android/jmePhysicsSpace.cpp b/engine/src/bullet/native/android/jmePhysicsSpace.cpp new file mode 100644 index 000000000..efed1b612 --- /dev/null +++ b/engine/src/bullet/native/android/jmePhysicsSpace.cpp @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "jmePhysicsSpace.h" +#include "jmeBulletUtil.h" +#include + +/** + * Author: Normen Hansen + */ +jmePhysicsSpace::jmePhysicsSpace(JNIEnv* env, jobject javaSpace) { + //TODO: global ref? maybe not -> cleaning, rather callback class? + this->javaPhysicsSpace = env->NewWeakGlobalRef(javaSpace); + this->env = env; + env->GetJavaVM(&vm); + if (env->ExceptionCheck()) { + env->Throw(env->ExceptionOccurred()); + return; + } +} + +void jmePhysicsSpace::attachThread() { +#ifdef JNI_VERSION_1_2 + vm->AttachCurrentThread((JNIEnv**) &env, NULL); +#else + vm->AttachCurrentThread(&env, NULL); +#endif +} + +JNIEnv* jmePhysicsSpace::getEnv() { + attachThread(); + return this->env; +} + +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); + + btVector3 min = btVector3(minX, minY, minZ); + btVector3 max = btVector3(maxX, maxY, maxZ); + + btBroadphaseInterface* broadphase; + + switch (broadphaseId) { + case 0: + broadphase = new btSimpleBroadphase(); + break; + case 1: + broadphase = new btAxisSweep3(min, max); + break; + case 2: + //TODO: 32bit! + broadphase = new btAxisSweep3(min, max); + break; + 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); + } + + // 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; + } + + //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 { + // return true when pairs need collision + + virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy * proxy1) const { + // bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0; + // collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); + bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0; + collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); + if (collides) { + btCollisionObject* co0 = (btCollisionObject*) proxy0->m_clientObject; + btCollisionObject* co1 = (btCollisionObject*) proxy1->m_clientObject; + jmeUserPointer *up0 = (jmeUserPointer*) co0 -> getUserPointer(); + jmeUserPointer *up1 = (jmeUserPointer*) co1 -> getUserPointer(); + if (up0 != NULL && up1 != NULL) { + collides = (up0->group & up1->groups) != 0; + collides = collides && (up1->group & up0->groups); + + //add some additional logic here that modified 'collides' + return collides; + } + return false; + } + return collides; + } + }; + dynamicsWorld->getPairCache()->setOverlapFilterCallback(new jmeFilterCallback()); + dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::preTickCallback, static_cast (this), true); + dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::postTickCallback, static_cast (this)); + if (gContactProcessedCallback == NULL) { + gContactProcessedCallback = &jmePhysicsSpace::contactProcessedCallback; + } +} + +void jmePhysicsSpace::preTickCallback(btDynamicsWorld *world, btScalar timeStep) { + jmePhysicsSpace* dynamicsWorld = (jmePhysicsSpace*) world->getWorldUserInfo(); + JNIEnv* env = dynamicsWorld->getEnv(); + jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace()); + if (javaPhysicsSpace != NULL) { + env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_preTick, timeStep); + env->DeleteLocalRef(javaPhysicsSpace); + if (env->ExceptionCheck()) { + env->Throw(env->ExceptionOccurred()); + return; + } + } +} + +void jmePhysicsSpace::postTickCallback(btDynamicsWorld *world, btScalar timeStep) { + jmePhysicsSpace* dynamicsWorld = (jmePhysicsSpace*) world->getWorldUserInfo(); + JNIEnv* env = dynamicsWorld->getEnv(); + jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace()); + if (javaPhysicsSpace != NULL) { + env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_postTick, timeStep); + env->DeleteLocalRef(javaPhysicsSpace); + if (env->ExceptionCheck()) { + env->Throw(env->ExceptionOccurred()); + return; + } + } +} + +bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, void *body1) { + // printf("contactProcessedCallback %d %dn", body0, body1); + btCollisionObject* co0 = (btCollisionObject*) body0; + jmeUserPointer *up0 = (jmeUserPointer*) co0 -> getUserPointer(); + btCollisionObject* co1 = (btCollisionObject*) body1; + jmeUserPointer *up1 = (jmeUserPointer*) co1 -> getUserPointer(); + if (up0 != NULL) { + jmePhysicsSpace *dynamicsWorld = (jmePhysicsSpace *)up0->space; + if (dynamicsWorld != NULL) { + JNIEnv* env = dynamicsWorld->getEnv(); + jobject javaPhysicsSpace = env->NewLocalRef(dynamicsWorld->getJavaPhysicsSpace()); + if (javaPhysicsSpace != NULL) { + jobject javaCollisionObject0 = env->NewLocalRef(up0->javaCollisionObject); + jobject javaCollisionObject1 = env->NewLocalRef(up1->javaCollisionObject); + env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_addCollisionEvent, javaCollisionObject0, javaCollisionObject1, (jlong) & cp); + env->DeleteLocalRef(javaPhysicsSpace); + env->DeleteLocalRef(javaCollisionObject0); + env->DeleteLocalRef(javaCollisionObject1); + if (env->ExceptionCheck()) { + env->Throw(env->ExceptionOccurred()); + return true; + } + } + } + } + return true; +} + +btDynamicsWorld* jmePhysicsSpace::getDynamicsWorld() { + return dynamicsWorld; +} + +jobject jmePhysicsSpace::getJavaPhysicsSpace() { + return javaPhysicsSpace; +} + +jmePhysicsSpace::~jmePhysicsSpace() { + delete(dynamicsWorld); +} \ No newline at end of file diff --git a/engine/src/bullet/native/build.xml b/engine/src/bullet/native/build.xml index 1658bda11..1c1264201 100644 --- a/engine/src/bullet/native/build.xml +++ b/engine/src/bullet/native/build.xml @@ -35,6 +35,10 @@ + + + + @@ -47,10 +51,12 @@ - + + + @@ -245,4 +251,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/engine/src/bullet/native/bullet.properties b/engine/src/bullet/native/bullet.properties index a81d1aa19..0e6a0309a 100644 --- a/engine/src/bullet/native/bullet.properties +++ b/engine/src/bullet/native/bullet.properties @@ -12,7 +12,7 @@ bullet.compile.debug=false # native library compilation options bullet.osx.compiler=g++ -bullet.osx.syslibroot=/Developer/SDKs/MacOSX10.5u.sdk +bullet.osx.syslibroot=/Developer/SDKs/MacOSX10.6.sdk # change this to msvc for MS Visual Studio compiler bullet.windows.compiler=g++ bullet.linux.compiler=g++ @@ -22,6 +22,9 @@ bullet.java.include=${java.home}/../include # OSX has no JRE, only JDK bullet.osx.java.include=/System/Library/Frameworks/JavaVM.framework/Headers +# location of Android NDK +ndk.dir=/opt/android-ndk-r7 + # dont change these.. bullet.bullet.include=${bullet.folder}/src bullet.build.dir=build/bullet/