diff --git a/trunk/unmanaged/BulletSim/0001-Call-setWorldTransform-when-object-is-going-inactive.patch b/trunk/unmanaged/BulletSim/0001-Call-setWorldTransform-when-object-is-going-inactive.patch index 65cdcea4..57527dfe 100644 --- a/trunk/unmanaged/BulletSim/0001-Call-setWorldTransform-when-object-is-going-inactive.patch +++ b/trunk/unmanaged/BulletSim/0001-Call-setWorldTransform-when-object-is-going-inactive.patch @@ -1,28 +1,26 @@ -From 4dec1c667448dc2518a38212484c8a39dc203c65 Mon Sep 17 00:00:00 2001 -From: Robert Adams -Date: Tue, 4 Dec 2012 08:17:53 -0800 -Subject: [PATCH 1/2] Call setWorldTransform when object is going inactive. - Creates property update event when velocities are set - to zero. +From 9e8f6c61e1cd05bc211297c1edcadecfa20779c6 Mon Sep 17 00:00:00 2001 +From: Robert Adams +Date: Wed, 14 Dec 2022 04:23:51 +0000 +Subject: [PATCH] Add island sleeping transform event --- - .../Dynamics/btDiscreteDynamicsWorld.cpp | 3 +++ - 1 files changed, 3 insertions(+), 0 deletions(-) + src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp | 3 +++ + 1 file changed, 3 insertions(+) diff --git a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp -index 48ba8bd..be14294 100755 +index 9e99c154f..71af633b4 100644 --- a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +++ b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp -@@ -634,6 +634,9 @@ void btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep) +@@ -616,6 +616,9 @@ void btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep) { - body->setAngularVelocity(btVector3(0,0,0)); - body->setLinearVelocity(btVector3(0,0,0)); + body->setAngularVelocity(btVector3(0, 0, 0)); + body->setLinearVelocity(btVector3(0, 0, 0)); + // when sleeping, force the motion state to be called/updated + if (body->getMotionState()) + body->getMotionState()->setWorldTransform(body->getWorldTransform()); } - } + } -- -1.7.9 +2.25.1 diff --git a/trunk/unmanaged/BulletSim/0002-Disable-internal-profile-gathering.patch b/trunk/unmanaged/BulletSim/0002-Disable-internal-profile-gathering.patch deleted file mode 100644 index e1f8a6d4..00000000 --- a/trunk/unmanaged/BulletSim/0002-Disable-internal-profile-gathering.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 2a2bb8512bc0b7c804b30f5bf8eaf10ea721eb14 Mon Sep 17 00:00:00 2001 -From: Robert Adams -Date: Sun, 27 Jan 2013 21:07:13 -0800 -Subject: [PATCH 2/2] Disable internal profile gathering - ---- - src/LinearMath/btQuickprof.h | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - -diff --git a/src/LinearMath/btQuickprof.h b/src/LinearMath/btQuickprof.h -index 8691400..a688912 100755 ---- a/src/LinearMath/btQuickprof.h -+++ b/src/LinearMath/btQuickprof.h -@@ -16,7 +16,7 @@ - #define BT_QUICK_PROF_H - - //To disable built-in profiling, please comment out next line --//#define BT_NO_PROFILE 1 -+#define BT_NO_PROFILE 1 - #ifndef BT_NO_PROFILE - #include //@todo remove this, backwards compatibility - #include "btScalar.h" --- -1.7.9 - diff --git a/trunk/unmanaged/BulletSim/2.86-0001-Call-setWorldTransform-when-object-is-going-inactive.patch b/trunk/unmanaged/BulletSim/2.86-0001-Call-setWorldTransform-when-object-is-going-inactive.patch new file mode 100644 index 00000000..f8d3015d --- /dev/null +++ b/trunk/unmanaged/BulletSim/2.86-0001-Call-setWorldTransform-when-object-is-going-inactive.patch @@ -0,0 +1,28 @@ +From 4dec1c667448dc2518a38212484c8a39dc203c65 Mon Sep 17 00:00:00 2001 +From: Robert Adams +Date: Tue, 4 Dec 2012 08:17:53 -0800 +Subject: [PATCH 1/2] Call setWorldTransform when object is going inactive. + Creates property update event when velocities are set + to zero. + +--- + .../Dynamics/btDiscreteDynamicsWorld.cpp | 3 +++ + 1 files changed, 3 insertions(+), 0 deletions(-) + +diff --git a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +index 48ba8bd..be14294 100755 +--- a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp ++++ b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +@@ -642,6 +642,9 @@ void btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep) + { + body->setAngularVelocity(btVector3(0,0,0)); + body->setLinearVelocity(btVector3(0,0,0)); ++ // when sleeping, force the motion state to be called/updated ++ if (body->getMotionState()) ++ body->getMotionState()->setWorldTransform(body->getWorldTransform()); + } + + } +-- +1.7.9 + diff --git a/trunk/unmanaged/BulletSim/2.86-0002-mask-shuffle.patch b/trunk/unmanaged/BulletSim/2.86-0002-mask-shuffle.patch new file mode 100644 index 00000000..4891ba9b --- /dev/null +++ b/trunk/unmanaged/BulletSim/2.86-0002-mask-shuffle.patch @@ -0,0 +1,40 @@ +diff -crB bullet3-2.86.1/src/Bullet3Common/b3Vector3.h bullet3-2.86.1new/src/Bullet3Common/b3Vector3.h +*** bullet3-2.86.1/src/Bullet3Common/b3Vector3.h 2017-02-17 15:43:38.000000000 -0800 +--- bullet3-2.86.1new/src/Bullet3Common/b3Vector3.h 2022-12-04 21:49:54.000000000 -0800 +*************** +*** 39,45 **** + #endif + + +! #define B3_SHUFFLE(x,y,z,w) ((w)<<6 | (z)<<4 | (y)<<2 | (x)) + //#define b3_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) ) + #define b3_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) ) + #define b3_splat3_ps( _a, _i ) b3_pshufd_ps((_a), B3_SHUFFLE(_i,_i,_i, 3) ) +--- 39,45 ---- + #endif + + +! #define B3_SHUFFLE(x, y, z, w) (((w) << 6 | (z) << 4 | (y) << 2 | (x)) & 0xff) + //#define b3_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) ) + #define b3_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) ) + #define b3_splat3_ps( _a, _i ) b3_pshufd_ps((_a), B3_SHUFFLE(_i,_i,_i, 3) ) +diff -crB bullet3-2.86.1/src/LinearMath/btVector3.h bullet3-2.86.1new/src/LinearMath/btVector3.h +*** bullet3-2.86.1/src/LinearMath/btVector3.h 2017-02-17 15:43:38.000000000 -0800 +--- bullet3-2.86.1new/src/LinearMath/btVector3.h 2022-12-04 21:46:59.000000000 -0800 +*************** +*** 39,45 **** + #endif + + +! #define BT_SHUFFLE(x,y,z,w) ((w)<<6 | (z)<<4 | (y)<<2 | (x)) + //#define bt_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) ) + #define bt_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) ) + #define bt_splat3_ps( _a, _i ) bt_pshufd_ps((_a), BT_SHUFFLE(_i,_i,_i, 3) ) +--- 39,45 ---- + #endif + + +! #define BT_SHUFFLE(x, y, z, w) (((w) << 6 | (z) << 4 | (y) << 2 | (x)) & 0xff) + //#define bt_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) ) + #define bt_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) ) + #define bt_splat3_ps( _a, _i ) bt_pshufd_ps((_a), BT_SHUFFLE(_i,_i,_i, 3) ) diff --git a/trunk/unmanaged/BulletSim/API2.cpp b/trunk/unmanaged/BulletSim/API2.cpp index 2c13b5fa..61b42877 100755 --- a/trunk/unmanaged/BulletSim/API2.cpp +++ b/trunk/unmanaged/BulletSim/API2.cpp @@ -35,13 +35,14 @@ #include -#ifdef WIN32 - #define DLL_EXPORT __declspec( dllexport ) - #define DLL_IMPORT __declspec( dllimport ) +#if defined(_WIN32) || defined(_WIN64) + #define DLL_EXPORT __declspec( dllexport ) + #define DLL_IMPORT __declspec( dllimport ) #else - #define DLL_EXPORT - #define DLL_IMPORT + #define DLL_EXPORT + #define DLL_IMPORT #endif + #ifdef __cplusplus #define EXTERN_C extern "C" #else @@ -56,12 +57,12 @@ EXTERN_C DLL_EXPORT void DumpConstraint2(BulletSim* sim, btTypedConstraint* cons #define TERRAIN_MIN_THICKNESS (0.2) /** - * Returns a string that identifies the version of the BulletSim.dll - * @return static string of version information + * Returns a pointer to a string that identifies the version of the BulletSim.dll + * @return pointer to zero terminated static string of format BULLETENGINEVERSION,BULLETSIMVERSION ("3.25,1.3") */ -EXTERN_C DLL_EXPORT char* GetVersion2() +EXTERN_C DLL_EXPORT const char* GetVersion2() { - return &BulletSimVersionString[0]; + return BulletSimVersionString.c_str(); } // DEBUG DEBUG DEBUG ========================================================================================= diff --git a/trunk/unmanaged/BulletSim/ArchStuff.h b/trunk/unmanaged/BulletSim/ArchStuff.h index 260c44f0..f69708c1 100755 --- a/trunk/unmanaged/BulletSim/ArchStuff.h +++ b/trunk/unmanaged/BulletSim/ArchStuff.h @@ -29,7 +29,16 @@ #ifndef ARCH_STUFF_H #define ARCH_STUFF_H -// define types that are always 32bits (don't change on 64 bit systems) +// 20230107 RA: This file exists to create definitions for 32 vs 64 bit +// architectures. Since we're moving into the future, 32bit is old +// and is no longer a supported machine architecture. +// That said, C# floats are 32bits and, for reporting collisions and +// other interactions, item IDs are presumed to be the same size +// as a float. Therefore, IDTYPE must be 32bits. + +// Define types that are always 32bits (don't change on 64 bit systems) +// 20230107 RA: the symbol _MSC_VER is only defined for Win32 and thus will +// never be true. Test and code kept for historical reference. #ifdef _MSC_VER typedef signed __int32 int32_t; typedef unsigned __int32 uint32_t; @@ -37,15 +46,20 @@ #include #endif +// See above discussion about IDTYPE needing to be same size as a float. #define IDTYPE uint32_t -#ifdef __x86_64__ - // 64bit systems don't allow you to cast directly from a void* to an unsigned int - #define PACKLOCALID(xx) ((void*)((uint64_t)(xx))) - #define CONVLOCALID(xx) ((IDTYPE)((uint64_t)(xx))) -#else +#ifdef __x86_32__ #define PACKLOCALID(xx) ((void*)(xx)) #define CONVLOCALID(xx) ((IDTYPE)(xx)) +#else + // CONVLOCALID is usually called operating on a void* which will + // be 64bit on most modern systems. + // 64bit systems don't allow you to cast directly from a void* to an + // unsigned int thus we cast it to uint64_t before chopping it to a + // IDTYPE (uint32_t). + #define PACKLOCALID(xx) ((void*)((uint64_t)(xx))) + #define CONVLOCALID(xx) ((IDTYPE)((uint64_t)(xx))) #endif // key used for identifying meshes and hulls @@ -53,4 +67,4 @@ // key used to identify collisions based on the IDs of the colliding objects #define COLLIDERKEYTYPE unsigned long long -#endif // ARCH_STUFF_H \ No newline at end of file +#endif // ARCH_STUFF_H diff --git a/trunk/unmanaged/BulletSim/BUILD.TXT b/trunk/unmanaged/BulletSim/BUILD.TXT deleted file mode 100755 index 59b872c7..00000000 --- a/trunk/unmanaged/BulletSim/BUILD.TXT +++ /dev/null @@ -1,64 +0,0 @@ -The OpenSimulator BulletSPlugin expects to use a "BulletSim.dll" which provides the -linkage to the Bullet physics engine. - -BulletSim.dll is written in C++ and is statically linked with the Bullet engine. - -BulletSim.dll must be compiled separately as the OpenSimulator build -environment only builds the C# code. - -For Windows, the steps are: - -1) Fetch the latest version from GitHub: https://github.com/bulletphysics/bullet3. - cd trunk/unmanaged/BulletSim - git clone https://github.com/bulletphysics/bullet3 bullet-2 - - As of this writing (August 7, 2017), Bullet development is mostly doing - bug fixes on the v2 branch and new development is happening - on a new v3 branch. When Bullet advances to v3, BulletSim - will probably not build or link and will require rework. - In the mean time, any of the v2.8+ versions should work. - -2) Apply all the patches for bullet: - cd bullet-2 ; for file in ../*.patch ; do cat $file | patch -p1 ; done - -3) Build Bullet -3a) Windows: - The Bullet distribution has an instance of PreMake (https://premake.github.io/) - to build the Visual Studio project files. - The script buildBulletVS.bat will call premake and generate the project files. - As of August 2017, premake version 4 worked but would only generate for VS2010 (v100). - I build the BulletSim libraries with VS2012 (v110) for downward compatibility. - I let VS2012 upgrade the VS2010 project files for VS2012. - - Once the project files have been built, open - "bullet-2/build3/vs2010/0_Bullet3Solution.sln" with VS2012 - and do a batch compile for a Release version for 'Win32' and 'x64'. - -3b) Linux and IOS: - (http://bulletphysics.org/mediawiki-1.5.8/index.php/Installation). - The script "buildBulletCMake.sh" has the appropriate cmake and compilation - commands for Linux and IOS. - (for 64bit systems, you must also add the cmake flag -DCMAKE_CXX_FLAGS="-fPIC" ) - (for Mac OSX systems, you must also add the cmake flag - -DCMAKE_OSX_ARCHITECTURES=i386 as mono runs as a 32bit process on OSX) - The script builds bullet static libraries and copies them into local directories. - -4) Build BulletSim -4a) Windows: - Use VS2012 to open "BulletSim.sln". Build Release version for 'Win32' - and 'x64'. The resulting DLLs will be in "Release/BulletSim.dll" - and "x64/Release/BulletSim.dll". These files are copied to - "bin/lib32/BulletSim.dll" and "bin/lib64/BulletSim.dll" in the - OpenSimulator execution tree. - -4b) Linux and IOS: - Use the 'Makefile' to build BulletSim. A simple 'make' should build it. - - On Linux, copy "libBulletSim.so" into the OpenSimulator "bin/lib32" or "bin/lib64" - directories depending on the architecture of your system. - On Mac OSX, copy "libBulletSim.dylib" into the OpenSimulator "bin/lib32" directory - - -This was developed with Bullet v2.86. If you use a different version, you will -need to change the include and library directories for the BulletSim compilation. - diff --git a/trunk/unmanaged/BulletSim/BUILD.md b/trunk/unmanaged/BulletSim/BUILD.md new file mode 100755 index 00000000..392b9cf5 --- /dev/null +++ b/trunk/unmanaged/BulletSim/BUILD.md @@ -0,0 +1,127 @@ +# BUILDING THINGS + +The [Bullet physics engine](https://github.com/bulletphysics/bullet3) is +available for OpenSimulator using the BulletSim plugin. This functionality +is provided by several pre-built binary executables for various target +architectures. These executables include DLL's, SO's, and DYNLIB's. + +BulletSim consists of the C# code that is included in the OpenSimulator +sources, this C++ "glue" code which provides the interface between the C# code +and the Bullet physics engine, and the Bullet physics engine itself. + +The steps are to fetch the Bullet physics engine sources, build it, then +build the BulletSim C++ glue code and staticlly link it with the built +Bullet physics engine. + +Since Bullet is supplied as a binary, there are separate versions built +for different target operating systems and machine architectures. Thus +the built binary filename includes the version of Bullet used, the build +date, and the target machine architecture. Expect to see filenames like: + +- `libBulletSim-3.25-20230122-x86_64.so` (Intel arch, Linux) +- `libBulletSim-3.25-20230122-aarch64.so` (ARM 64 bit arch, Linux) +- `libBulletSim-3.25-20230122-universal.dynlib` (either x86 or ARM, IOS) +- `libBulletSim-3.25-20230122-x86.64.dll` (Intel arch, Windows) + +The selection of which binary to use must be configured in OpenSimulator. +This either requires copying the correct file to as default name or +editing a `.config` file. + +# NOTES + +- This builds with Bullet physics engine version 3+. Before 2023, + `BulletSim.dll` was built with Bullet version 2.86. The 3.25 version + of Bullet has been tested and does not seem to make any + difference to OpenSimulator operation as most of the Bullet changes + have to do with APIs and integration with Python (thus PyBullet). + Refer to some of the `.sh` files for the process of building the + BulletSim binary with the previous version of Bullet. + +- Only 64 bit architectures are supported. + +# BUILDING + +This "official" build scripts are called from `.github/workflows/build-dotnet6.yml` +which builds all the pieces using the Github action system. + +For Linux, the script `makeBullets.sh` has the following build steps captured +in one script. + +To build by hand, several scripts that are used in `build.yml` +are available. This builds the latest version of BulletSim with the latest +version of the Bullet physics engine. + +1) Fetch the latest version from GitHub: https://github.com/bulletphysics/bullet3. + +``` + cd trunk/unmanaged/BulletSim + git clone --depth 1 --single-branch https://github.com/bulletphysics/bullet3.git +``` + +2) Apply all the patches for bullet: + +``` + cd bullet3 ; for file in ../*.patch ; do cat $file | patch -p1 ; done +``` + +There are some small changes that are needed for the using Bullet for +distributed physics (physics simulation in both the serve and the client). + +There are separate patch files for Bullet version 2.86. These all start +with the string "2.86-". Refer to `makeBullets.sh` for an example of pulling +and patching the 2.86 version of Bullet. + +3) Build the Bullet physics engine + + a) Windows: + + Install CMake for Windows. + + `buildBulletCMake.ps1` builds the Bullet physics engine. Note that this + is a PowerShell script. + + If one can not install `CMake` but has Visual Studio, `buildBulletVS.bat` will + build `bullet3/build3/vs2010/0Bullet3Solution.sln` which can be used by + any modern Visual Studio to build the Bullet physics engine. + Note that after this step, the Bullet physics engine binaries will be in + the `lib` directory and the include files must be copied into `include/`. + + b) Linux and IOS: + + The script "buildBulletCMake.sh" has the appropriate cmake and compilation + commands for Linux and IOS. + The script builds bullet static libraries and copies them into local directories. + +``` + ./buildBulletCMake.sh +``` + +4) Build BulletSim + + a) Windows: + + Generate version file information: + +``` + bash buildVersionInfo.sh +``` + + Build BulletSim: + +``` + .\buildBulletSim.ps1 +``` + + b) Linux and IOS: + + Run BulletSim compile and link script: + +``` + ./buildBulletSim.sh +``` + + This builds a file with a name like: `libBulletSim-3.25-20230111-x86_64.so`. + Copy this file in to the OpenSimulator `bin/lib64` directory and edit + `OpenSim.Region.PhysicsModule.BulletS.dll.config` to point to this file for + the machine architecture you are running on. + diff --git a/trunk/unmanaged/BulletSim/BulletSim-vhacd-2012.sln b/trunk/unmanaged/BulletSim/BulletSim-vhacd-2012.sln deleted file mode 100755 index d2ae4adc..00000000 --- a/trunk/unmanaged/BulletSim/BulletSim-vhacd-2012.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BulletSim", "BulletSim-vhacd.vcxproj", "{C2C20743-0BB8-4BEC-A6D1-54C516BD9040}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Any CPU = Release|Any CPU - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Win32.ActiveCfg = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Win32.Build.0 = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|x64.ActiveCfg = Debug|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|x64.Build.0 = Debug|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Any CPU.ActiveCfg = Release|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Any CPU.Build.0 = Release|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Win32.ActiveCfg = Release|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Win32.Build.0 = Release|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|x64.ActiveCfg = Release|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/trunk/unmanaged/BulletSim/BulletSim-vhacd.vcxproj b/trunk/unmanaged/BulletSim/BulletSim-vhacd.vcxproj deleted file mode 100755 index 4cea160a..00000000 --- a/trunk/unmanaged/BulletSim/BulletSim-vhacd.vcxproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040} - BulletSim - ManagedCProj - - - - DynamicLibrary - Unicode - false - true - v110 - - - DynamicLibrary - Unicode - false - true - false - v110 - - - DynamicLibrary - Unicode - false - v110 - - - DynamicLibrary - Unicode - false - v110 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(PlatformName)\$(Configuration)\ - $(Configuration)\ - $(PlatformName)\$(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(PlatformName)\$(Configuration)\ - $(Configuration)\ - $(PlatformName)\$(Configuration)\ - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - false - - - - Disabled - .\bullet-2.82\src;.\vhacd;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_HAS_ITERATOR_DEBUGGING=0;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - BulletCollision_vs2010.lib;BulletDynamics_vs2010.lib;LinearMath_vs2010.lib;HACD_vs2010.lib;VHACD_Lib.lib - .\bullet-2.82\lib;.\vhacd\$(Configuration);%(AdditionalLibraryDirectories) - true - true - MachineX86 - - - - - Disabled - .\bullet-2.82\src;.\vhacd;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_HAS_ITERATOR_DEBUGGING=0;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - BulletCollision_vs2010_x64_release.lib;BulletDynamics_vs2010_x64_release.lib;LinearMath_vs2010_x64_release.lib;HACD_vs2010_x64_release.lib;VHACD_Lib_x64.lib - .\bullet-2.82\lib;.\vhacd\$(Configuration);%(AdditionalLibraryDirectories) - true - true - - - - - .\bullet-2.82\src;.\vhacd;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - BulletCollision_vs2010.lib;BulletDynamics_vs2010.lib;LinearMath_vs2010.lib;HACD_vs2010.lib;VHACD_Lib.lib - .\bullet-2.82\lib;.\vhacd\$(Configuration);%(AdditionalLibraryDirectories) - true - MachineX86 - $(OutDir)$(TargetName)$(TargetExt) - - - - - .\bullet-2.82\src;.\vhacd;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - false - - - BulletCollision_vs2010_x64_release.lib;BulletDynamics_vs2010_x64_release.lib;LinearMath_vs2010_x64_release.lib;HACD_vs2010_x64_release.lib;VHACD_Lib_x64.lib - .\bullet-2.82\lib;.\vhacd\$(Configuration);%(AdditionalLibraryDirectories) - true - $(OutDir)$(TargetName)$(TargetExt) - - - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/trunk/unmanaged/BulletSim/BulletSim.cpp b/trunk/unmanaged/BulletSim/BulletSim.cpp index 76852634..31f0f0c9 100755 --- a/trunk/unmanaged/BulletSim/BulletSim.cpp +++ b/trunk/unmanaged/BulletSim/BulletSim.cpp @@ -39,7 +39,7 @@ #if defined(__linux__) || defined(__APPLE__) #include "HACD/hacdHACD.h" #elif defined(_WIN32) || defined(_WIN64) -#include "../extras/HACD/hacdHACD.h" +#include "HACD/hacdHACD.h" #else #error "Platform type not understood." #endif @@ -170,8 +170,8 @@ void BulletSim::initPhysics2(ParamBlock* parms, { // Tell the world we're initializing and output size of types so we can // debug mis-alignments when changing architecture. - // m_worldData.BSLog("InitPhysics: sizeof(int)=%d, sizeof(long)=%d, sizeof(long long)=%d, sizeof(float)=%d", - // sizeof(int), sizeof(long), sizeof(long long), sizeof(float)); + m_worldData.BSLog("InitPhysics: sizeof(int)=%d, sizeof(long)=%d, sizeof(long long)=%d, sizeof(float)=%d", + sizeof(int), sizeof(long), sizeof(long long), sizeof(float)); // remember the pointers to pinned memory for returning collisions and property updates maxCollisionsPerFrame = maxCollisions; diff --git a/trunk/unmanaged/BulletSim/BulletSim.h b/trunk/unmanaged/BulletSim/BulletSim.h index 513a6c95..d69cad6d 100755 --- a/trunk/unmanaged/BulletSim/BulletSim.h +++ b/trunk/unmanaged/BulletSim/BulletSim.h @@ -56,8 +56,13 @@ // If defined, use the external VHACD library // #define USEVHACD 1 -// TODO: find a way to build this -static char BulletSimVersionString[] = "v0003"; +// Build version string of format BULLETSIMVERSION,BULLETENGINEVERSION ("1.3,3.25") +// This expects the version information to be passed in as defined variables (-D BULLETVERSION=...) +// If the version variables are not defined, the version string is just a comma. +// This uses the "#" pre-processor operator to stringify the variable and that adjacent strings are concatinated. +#define MACRO_AS_STRING1(X) #X +#define MACRO_AS_STRING(X) MACRO_AS_STRING1(X) +static std::string BulletSimVersionString = MACRO_AS_STRING(BULLETSIMVERSION) "," MACRO_AS_STRING(BULLETVERSION); // Helper method to determine if an object is phantom or not static bool IsPhantom(const btCollisionObject* obj) diff --git a/trunk/unmanaged/BulletSim/BulletSim.sln b/trunk/unmanaged/BulletSim/BulletSim.sln index a579b74e..e8a96787 100755 --- a/trunk/unmanaged/BulletSim/BulletSim.sln +++ b/trunk/unmanaged/BulletSim/BulletSim.sln @@ -1,36 +1,25 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BulletSim", "BulletSim.vcxproj", "{C2C20743-0BB8-4BEC-A6D1-54C516BD9040}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33122.133 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BulletSim", "BulletSim.vcxproj", "{896C2106-25E8-49E7-822A-6E02F04F6C0B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Win32.ActiveCfg = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|Win32.Build.0 = Debug|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|x64.ActiveCfg = Debug|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Debug|x64.Build.0 = Debug|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Any CPU.ActiveCfg = Release|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Mixed Platforms.Build.0 = Release|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Win32.ActiveCfg = Release|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|Win32.Build.0 = Release|Win32 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|x64.ActiveCfg = Release|x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040}.Release|x64.Build.0 = Release|x64 + {896C2106-25E8-49E7-822A-6E02F04F6C0B}.Debug|x64.ActiveCfg = Debug|x64 + {896C2106-25E8-49E7-822A-6E02F04F6C0B}.Debug|x64.Build.0 = Debug|x64 + {896C2106-25E8-49E7-822A-6E02F04F6C0B}.Release|x64.ActiveCfg = Release|x64 + {896C2106-25E8-49E7-822A-6E02F04F6C0B}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DDE25DAE-34CA-4768-A175-A587C8FFF265} + EndGlobalSection EndGlobal diff --git a/trunk/unmanaged/BulletSim/BulletSim.vcxproj b/trunk/unmanaged/BulletSim/BulletSim.vcxproj index a8d1bc0d..035bd069 100755 --- a/trunk/unmanaged/BulletSim/BulletSim.vcxproj +++ b/trunk/unmanaged/BulletSim/BulletSim.vcxproj @@ -1,191 +1,90 @@ - - + + - - Debug - Win32 - Debug x64 - - Release - Win32 - Release x64 - {C2C20743-0BB8-4BEC-A6D1-54C516BD9040} + 16.0 + Win32Proj + {896c2106-25e8-49e7-822a-6e02f04f6c0b} BulletSim - ManagedCProj + 10.0 - + DynamicLibrary + true + v143 Unicode - false - true - v110 DynamicLibrary - Unicode - false + false + v143 true - false - v110 - - - DynamicLibrary Unicode - false - v110 - - - DynamicLibrary - Unicode - false - v110 - + + + - - - - - - - + - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(PlatformName)\$(Configuration)\ - $(Configuration)\ - $(PlatformName)\$(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(PlatformName)\$(Configuration)\ - $(Configuration)\ - $(PlatformName)\$(Configuration)\ - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - false - - - - Disabled - .\bullet-2\src;.\bullet-2\Extras\ConvexDecomposition;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - BulletCollision_vs2010_debug.lib;BulletDynamics_vs2010_debug.lib;LinearMath_vs2010_debug.lib;HACD_vs2010_debug.lib - .\bullet-2\lib;%(AdditionalLibraryDirectories) - true - true - MachineX86 - - - Disabled - .\bullet-2\src;.\bullet-2\Extras\ConvexDecomposition;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - Level3 - ProgramDatabase - - - BulletCollision_vs2010_x64_debug.lib;BulletDynamics_vs2010_x64_debug.lib;LinearMath_vs2010_x64_debug.lib;HACD_vs2010_x64_debug.lib - .\bullet-2\lib;%(AdditionalLibraryDirectories) - true - true - - - - - .\bullet-2\src;.\bullet-2\Extras\ConvexDecomposition;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;%(PreprocessorDefinitions) + true + _DEBUG;BULLETSIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + NotUsing + ./include;%(AdditionalIncludeDirectories) MultiThreaded - - - Level3 - ProgramDatabase - BulletCollision_vs2010.lib;BulletDynamics_vs2010.lib;LinearMath_vs2010.lib;HACD_vs2010.lib - .\bullet-2\lib;%(AdditionalLibraryDirectories) + Windows + true + true true - MachineX86 - $(OutDir)$(TargetName)$(TargetExt) + false + .\lib;%(AdditionalLibraryDirectories) + lib/BulletDynamics.lib;lib/BulletCollision.lib;lib/LinearMath.lib;lib/HACD.lib;%(AdditionalDependencies) - .\bullet-2\src;.\bullet-2\Extras\ConvexDecomposition;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreaded - - Level3 - ProgramDatabase - false + true + true + true + NDEBUG;BULLETSIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + NotUsing + ./include + MultiThreaded - BulletCollision_vs2010_x64_release.lib;BulletDynamics_vs2010_x64_release.lib;LinearMath_vs2010_x64_release.lib;HACD_vs2010_x64_release.lib - .\bullet-2\lib;%(AdditionalLibraryDirectories) + Windows + true + true true - $(OutDir)$(TargetName)$(TargetExt) + false + .\lib + lib/BulletDynamics.lib;lib/BulletCollision.lib;lib/LinearMath.lib;lib/HACD.lib;%(AdditionalDependencies) - - - true - true - - - true - true - - - true - true - - - - - - @@ -193,6 +92,22 @@ + + + + + + + + + + + + + + + + diff --git a/trunk/unmanaged/BulletSim/Makefile b/trunk/unmanaged/BulletSim/Makefile deleted file mode 100644 index ce8ccd5c..00000000 --- a/trunk/unmanaged/BulletSim/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -# Build BulletSim - -# IDIR = /usr/local/include/bullet -# LDIR = /usr/local/lib -IDIR = ./include -LDIR = ./lib - -# the Bullet libraries are linked statically so we don't have to also distribute the shared binaries -BULLETLIBS = $(LDIR)/libBulletDynamics.a $(LDIR)/libBulletCollision.a $(LDIR)/libLinearMath.a $(LDIR)/libHACD.a - -#CC = gcc -CC = /usr/bin/g++ -LD = /usr/bin/g++ -UNAME := $(shell uname) -UNAMEPROCESSOR := $(shell uname -m) - -# Kludge for building libBulletSim.so with different library dependencies -# As of 20130424, 64bit Ubuntu needs to wrap memcpy so it doesn't pull in glibc 2.14. -# The wrap is not needed on Ubuntu 32bit and, in fact, causes crashes. -ifeq ($(UNAMEPROCESSOR), x86_64) -WRAPMEMCPY = -Wl,--wrap=memcpy -else -WRAPMEMCPY = -endif - -# Linux build. -ifeq ($(UNAME), Linux) -TARGET = libBulletSim-$(UNAMEPROCESSOR).so -CFLAGS = -I$(IDIR) -fPIC -g -fpermissive -LFLAGS = $(WRAPMEMCPY) -shared -Wl,-soname,$(TARGET) -o $(TARGET) -endif - -# OSX build. Builds 32bit dylib on 64bit system. (Need 32bit because Mono is 32bit only). -ifeq ($(UNAME), Darwin) -TARGET = libBulletSim.dylib -# CC = clang -# LD = clang -#CFLAGS = -m32 -I$(IDIR) -fPIC -g -#LFLAGS = -m32 -dynamiclib -Wl -o $(TARGET) -#CFLAGS = -m32 -arch i386 -stdlib=libstdc++ -mmacosx-version-min=10.6 -I$(IDIR) -g -#LFLAGS = -v -m32 -arch i386 -std=c++11 -stdlib=libstdc++ -mmacosx-version-min=10.6 -dynamic -o $(TARGET) -CFLAGS = -arch i386 -arch x86_64 -std=c++11 -O3 -I$(IDIR) -g -LFLAGS = -v -dynamiclib -arch i386 -arch x86_64 -o $(TARGET) -endif - -BASEFILES = API2.cpp BulletSim.cpp - -SRC = $(BASEFILES) -# SRC = $(wildcard *.cpp) - -BIN = $(patsubst %.cpp, %.o, $(SRC)) - - -all: $(TARGET) - -$(TARGET) : $(BIN) - $(LD) $(LFLAGS) $(BIN) $(BULLETLIBS) - -%.o: %.cpp - $(CC) $(CFLAGS) -c $? - -BulletSim.cpp : BulletSim.h Util.h - -BulletSim.h: ArchStuff.h APIData.h WorldData.h - -API2.cpp : BulletSim.h - -clean: - rm -f *.o $(TARGET) diff --git a/trunk/unmanaged/BulletSim/README.md b/trunk/unmanaged/BulletSim/README.md new file mode 100644 index 00000000..6d5d9656 --- /dev/null +++ b/trunk/unmanaged/BulletSim/README.md @@ -0,0 +1,37 @@ +# BulletSim Binary Build + +The BulletSim physics module for [OpenSimulator](http:opensimulator.org) +is distributed as a binary file. +The filenames are different for the various architectures and operating +system types. Names are usually: + +- `BulletSim*.dll` - Windows +- `libBulletSims*.so` - Linux +- `libBulletSim*.dynlib` - IOS + +The names could have architecture info in them like `x86_64`, `aarch64`, or +`universal` (with the `universal` possibly containing the images for multiple +Apple architectures). + +The binary file that is selected and run is specified in the OpenSimulator +file `bin/OpenSim.Region.PhysicsModule.BulletS.dll.config` which selects +the binary file to load based on the operating system. + +See the file in this directory named `BUILD.md` +for instructions on how to build the binary files. +The build steps include downloading and building the Bullet physics engine binaries +and then building and linking in the BulletSim wrapper. +There are many files in this directory related to building BulletSim using +Github actions. + +Development on BulletSim is also done in +[Misterblue's BulletSim repository](https://github.com/Misterblue/BulletSim) +which has Github actions to build BulletSim for the various target +architectures. + +Development for IOS has been done by +Cuga-rajal so refer to the +[opensim-apple-arm64](https://github.com/cuga-rajal/opensim_apple_arm64) repository +for that part of the world. +Cuga built and signed a BulletSim release for OpenSimulator which can +be found in the released `bin/lib64` directory of OpenSimulator. diff --git a/trunk/unmanaged/BulletSim/VERSION b/trunk/unmanaged/BulletSim/VERSION new file mode 100644 index 00000000..7e32cd56 --- /dev/null +++ b/trunk/unmanaged/BulletSim/VERSION @@ -0,0 +1 @@ +1.3 diff --git a/trunk/unmanaged/BulletSim/buildBulletCMake.ps1 b/trunk/unmanaged/BulletSim/buildBulletCMake.ps1 new file mode 100755 index 00000000..614e5ade --- /dev/null +++ b/trunk/unmanaged/BulletSim/buildBulletCMake.ps1 @@ -0,0 +1,55 @@ +# Script to build Bullet on a Windows system + +$MACH="x64" +$BULLETDIR="bullet3" + +$BUILDDIR="bullet-build" + +cd $BULLETDIR +New-Item -ItemType Directory -Path $BUILDDIR -Force +cd $BUILDDIR + +echo "=== Building Bullet in dir $BULLETDIR for arch $MACH into $BUILDDIR" + +cmake -G "Visual Studio 17 2022" -A $MACH -DDOTNET_SDK=ON -DBUILD_BULLET3=ON -DBUILD_EXTRAS=ON -DBUILD_INVERSE_DYNAMIC_EXTRA=OFF -DBUILD_BULLET_ROBOTICS_GUI_EXTRA=OFF -DBUILD_BULLET_ROBOTICS_EXTRA=OFF -DBUILD_OBJ2SDF_EXTRA=OFF -DBUILD_SERIALIZE_EXTRA=OFF -DBUILD_CONVEX_DECOMPOSITION_EXTRA=ON -DBUILD_HACD_EXTRA=ON -DBUILD_GIMPACTUTILS_EXTRA=OFF -DBUILD_CPU_DEMOS=OFF -DBUILD_BULLET2_DEMOS=OFF -DBUILD_ENET=OFF -DBUILD_PYBULLET=OFF -DBUILD_UNIT_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DINSTALL_EXTRA_LIBS=ON -DINSTALL_LIBS=ON -DCMAKE_BUILD_TYPE=Release .. + +msbuild -p:Configuration=Release BULLET_PHYSICS.sln + +# Copy the .lib files into the target lib directory +Set-Location ..\.. +New-Item -ItemType Directory -Path lib -Force +Write-Host "=== Copy .lib files into the lib dir" +Get-ChildItem -Path bullet3\bullet-build\* -Include *.lib -Recurse | ForEach-Object { + # echo "----- copying $_ to lib" + Copy-Item $_ -Destination lib -Force +} + +# Copy the .h and .inl files into the target include directory +Write-Host "=== Copy .h files into the include dir" +Get-ChildItem -Path bullet3\src\* -Include *.h,*.inl -Recurse | ForEach-Object { + $xxxx = $_.Fullname -replace ".*\\bullet3\\src\\","include\" + $xxxxDir = Split-Path -parent $xxxx + if ( -not (Test-Path "$xxxxDir" -PathType container)) { + echo "----- creating directory $xxxxDir" + New-Item -ItemType Directory -Path $xxxxDir -Force | Out-Null + } + echo "----- copying $_ to $xxxx" + Copy-Item $_ -Destination $xxxx -Force +} + +# Copy the .h files from Extras into the target include directory +Write-Host "=== Copy Extras .h files into the include dir" +Get-ChildItem -Path bullet3\Extras\* -Include *.h,*.inl -Recurse | ForEach-Object { + $xxxx = $_.Fullname -replace ".*\\bullet3\\Extras\\","include\" + $xxxxDir = Split-Path -parent $xxxx + if ( -not (Test-Path "$xxxxDir" -PathType container)) { + echo "----- creating Extras directory $xxxxDir" + New-Item -ItemType Directory -Path $xxxxDir -Force | Out-Null + } + echo "----- copying Extras $_ to $xxxx" + Copy-Item $_ -Destination $xxxx -Force +} + +# Copy Bullet's VERSION file into lib/ so BulletSim can reference it +Copy-Item -Path bullet3\VERSION -Destination lib + diff --git a/trunk/unmanaged/BulletSim/buildBulletCMake.sh b/trunk/unmanaged/BulletSim/buildBulletCMake.sh index 1b3e2794..a4f833cd 100755 --- a/trunk/unmanaged/BulletSim/buildBulletCMake.sh +++ b/trunk/unmanaged/BulletSim/buildBulletCMake.sh @@ -3,128 +3,206 @@ STARTDIR=$(pwd) -UNAME=$(uname) -MACH=$(uname -m) -BULLET=bullet-2 +# The UNAME is either "Darwin" or otherwise. Note that env variable overrides +UNAME=${BULLETUNAME:-$(uname)} +# The MACH is either 'x86_64', 'aarch64', or assumed generic. Note env variable overrides. +MACH=${BULLETMACH:-$(uname -m)} +# Note that this sets BULLETDIR unless there is an environment variable of the same name +BULLETDIR=${BULLETDIR:-bullet3} -cd $BULLET -mkdir -p bullet-build -cd bullet-build +BUILDDIR=bullet-build + +cd "${BULLETDIR}" +mkdir -p "${BUILDDIR}" +cd "${BUILDDIR}" + +echo "=== Building Bullet in dir ${BULLETDIR} for uname ${UNAME} and arch ${MACH} into ${BUILDDIR}" if [[ "$UNAME" == "Darwin" ]] ; then + echo "=== Running cmake for Darwin" cmake .. -G "Unix Makefiles" \ - -DBUILD_BULLET2_DEMOS=off \ - -DBUILD_BULLET3=on \ - -DBUILD_CLSOCKET=off \ - -DBUILD_CPU_DEMOS=off \ - -DBUILD_ENET=off \ - -DBUILD_EXTRAS=on \ - -DBUILD_DEMOS=off \ - -DBUILD_OPENGL_DEMOS=off \ - -DBUILD_PYBULLET=off \ - -DBUILD_SHARED_LIBS=off \ - -DBUILD_UNIT_TESTS=off \ - -DINSTALL_EXTRA_LIBS=on \ - -DINSTALL_LIBS=on \ - -DCMAKE_OSX_ARCHITECTURES="i386; x86_64" \ - -DCMAKE_CXX_FLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.11" \ - -DCMAKE_C_FLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.11" \ - -DCMAKE_EXE_LINKER_FLAGS="-arch i386 -arch x86_64 -mmacosx-version-min=10.11" \ - -DCMAKE_VERBOSE_MAKEFILE="on" \ + -DBUILD_BULLET3=ON \ + -DBUILD_EXTRAS=ON \ + -DBUILD_INVERSE_DYNAMIC_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_GUI_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_EXTRA=OFF \ + -DBUILD_OBJ2SDF_EXTRA=OFF \ + -DBUILD_SERIALIZE_EXTRA=OFF \ + -DBUILD_CONVEX_DECOMPOSITION_EXTRA=ON \ + -DBUILD_HACD_EXTRA=ON \ + -DBUILD_GIMPACTUTILS_EXTRA=OFF \ + -DBUILD_CPU_DEMOS=OFF \ + -DBUILD_BULLET2_DEMOS=OFF \ + -DBUILD_ENET=OFF \ + -DBUILD_PYBULLET=OFF \ + -DBUILD_UNIT_TESTS=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DINSTALL_EXTRA_LIBS=ON \ + -DINSTALL_LIBS=ON \ + -DCMAKE_OSX_ARCHITECTURES="arm64; x86_64" \ + -DCMAKE_CXX_FLAGS="-arch arm64 -arch x86_64" \ + -DCMAKE_C_FLAGS="-arch arm64 -arch x86_64 -fPIC -O2" \ + -DCMAKE_EXE_LINKER_FLAGS="-arch arm64 -arch x86_64" \ + -DCMAKE_VERBOSE_MAKEFILE="on" \ + -DCMAKE_BUILD_TYPE=Release +elif [[ "$UNAME" =~ "MINGW64*" ]] ; then + cmake .. -G "Visual Studio 17 2022" \ + -DBUILD_BULLET3=ON \ + -DBUILD_EXTRAS=ON \ + -DBUILD_INVERSE_DYNAMIC_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_GUI_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_EXTRA=OFF \ + -DBUILD_OBJ2SDF_EXTRA=OFF \ + -DBUILD_SERIALIZE_EXTRA=OFF \ + -DBUILD_CONVEX_DECOMPOSITION_EXTRA=ON \ + -DBUILD_HACD_EXTRA=ON \ + -DBUILD_GIMPACTUTILS_EXTRA=OFF \ + -DBUILD_CPU_DEMOS=OFF \ + -DBUILD_BULLET2_DEMOS=OFF \ + -DBUILD_ENET=OFF \ + -DBUILD_PYBULLET=OFF \ + -DBUILD_UNIT_TESTS=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DINSTALL_EXTRA_LIBS=ON \ + -DINSTALL_LIBS=ON \ + -DCMAKE_CXX_FLAGS="-fPIC" \ -DCMAKE_BUILD_TYPE=Release else if [[ "$MACH" == "x86_64" ]] then + echo "=== Running cmake for arch $MACH" cmake .. -G "Unix Makefiles" \ - -DBUILD_BULLET2_DEMOS=off \ - -DBUILD_BULLET3=on \ - -DBUILD_CLSOCKET=off \ - -DBUILD_CPU_DEMOS=off \ - -DBUILD_ENET=off \ - -DBUILD_EXTRAS=on \ - -DBUILD_DEMOS=off \ - -DBUILD_OPENGL_DEMOS=off \ - -DBUILD_PYBULLET=off \ - -DBUILD_SHARED_LIBS=off \ - -DBUILD_UNIT_TESTS=off \ - -DINSTALL_EXTRA_LIBS=on \ - -DINSTALL_LIBS=on \ + -DBUILD_BULLET3=ON \ + -DBUILD_EXTRAS=ON \ + -DBUILD_INVERSE_DYNAMIC_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_GUI_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_EXTRA=OFF \ + -DBUILD_OBJ2SDF_EXTRA=OFF \ + -DBUILD_SERIALIZE_EXTRA=OFF \ + -DBUILD_CONVEX_DECOMPOSITION_EXTRA=ON \ + -DBUILD_HACD_EXTRA=ON \ + -DBUILD_GIMPACTUTILS_EXTRA=OFF \ + -DBUILD_CPU_DEMOS=OFF \ + -DBUILD_BULLET2_DEMOS=OFF \ + -DBUILD_ENET=OFF \ + -DBUILD_PYBULLET=OFF \ + -DBUILD_UNIT_TESTS=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DINSTALL_EXTRA_LIBS=ON \ + -DINSTALL_LIBS=ON \ -DCMAKE_CXX_FLAGS="-fPIC" \ -DCMAKE_BUILD_TYPE=Release elif [[ "$MACH" == "aarch64" ]] then + echo "=== Running cmake for arch $MACH" cmake .. -G "Unix Makefiles" \ - -DBUILD_BULLET2_DEMOS=off \ - -DBUILD_BULLET3=on \ - -DBUILD_CLSOCKET=off \ - -DBUILD_CPU_DEMOS=off \ - -DBUILD_ENET=off \ - -DBUILD_EXTRAS=on \ - -DBUILD_BULLET_ROBOTICS_GUI_EXTRA=off \ - -DBUILD_BULLET_ROBOTICS_EXTRA=off \ - -DBUILD_DEMOS=off \ - -DBUILD_OPENGL_DEMOS=off \ - -DBUILD_PYBULLET=off \ - -DBUILD_SHARED_LIBS=off \ - -DBUILD_UNIT_TESTS=off \ - -DENABLE_VHACD=off \ - -DUSE_GRAPHICAL_BENCHMARK=off \ - -DBUILD_EGL=off \ - -DBUILD_OPENGL3_DEMOS=off \ - -DBUILD_BULLET2_DEMOS=off \ - -DINSTALL_EXTRA_LIBS=on \ - -DINSTALL_LIBS=on \ - -DCMAKE_CXX_FLAGS="-fPIC" \ + -DBUILD_BULLET3=ON \ + -DBUILD_EXTRAS=ON \ + -DBUILD_INVERSE_DYNAMIC_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_GUI_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_EXTRA=OFF \ + -DBUILD_OBJ2SDF_EXTRA=OFF \ + -DBUILD_SERIALIZE_EXTRA=OFF \ + -DBUILD_CONVEX_DECOMPOSITION_EXTRA=ON \ + -DBUILD_HACD_EXTRA=ON \ + -DBUILD_GIMPACTUTILS_EXTRA=OFF \ + -DBUILD_CPU_DEMOS=OFF \ + -DBUILD_BULLET2_DEMOS=OFF \ + -DBUILD_ENET=OFF \ + -DBUILD_PYBULLET=OFF \ + -DBUILD_UNIT_TESTS=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DINSTALL_EXTRA_LIBS=ON \ + -DINSTALL_LIBS=ON \ + -DCMAKE_OSX_ARCHITECTURES="arm64" \ + -DCMAKE_CXX_FLAGS="-arch arm64" \ + -DCMAKE_C_FLAGS="-arch arm64 -fPIC -O2" \ + -DCMAKE_EXE_LINKER_FLAGS="-arch arm64" \ -DCMAKE_BUILD_TYPE=Release else + echo "=== Running cmake for generic arch" cmake .. -G "Unix Makefiles" \ - -DBUILD_BULLET2_DEMOS=off \ - -DBUILD_BULLET3=on \ - -DBUILD_CLSOCKET=off \ - -DBUILD_CPU_DEMOS=off \ - -DBUILD_ENET=off \ - -DBUILD_EXTRAS=on \ - -DBUILD_DEMOS=off \ - -DBUILD_OPENGL_DEMOS=off \ - -DBUILD_PYBULLET=off \ - -DBUILD_SHARED_LIBS=off \ - -DBUILD_UNIT_TESTS=off \ - -DINSTALL_EXTRA_LIBS=on \ - -DINSTALL_LIBS=on \ + -DBUILD_BULLET3=ON \ + -DBUILD_EXTRAS=ON \ + -DBUILD_INVERSE_DYNAMIC_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_GUI_EXTRA=OFF \ + -DBUILD_BULLET_ROBOTICS_EXTRA=OFF \ + -DBUILD_OBJ2SDF_EXTRA=OFF \ + -DBUILD_SERIALIZE_EXTRA=OFF \ + -DBUILD_CONVEX_DECOMPOSITION_EXTRA=ON \ + -DBUILD_HACD_EXTRA=ON \ + -DBUILD_GIMPACTUTILS_EXTRA=OFF \ + -DBUILD_CPU_DEMOS=OFF \ + -DBUILD_BULLET2_DEMOS=OFF \ + -DBUILD_ENET=OFF \ + -DBUILD_PYBULLET=OFF \ + -DBUILD_UNIT_TESTS=OFF \ + -DBUILD_SHARED_LIBS=OFF \ + -DINSTALL_EXTRA_LIBS=ON \ + -DINSTALL_LIBS=ON \ + -DCMAKE_CXX_FLAGS="-fPIC" \ -DCMAKE_BUILD_TYPE=Release fi fi -make -j4 +# DEBUG DEBUG +echo "=== $(pwd)" +ls -l +echo "=== END" +# END DEBUG DEBUG + +if [[ -e Makefile ]] ; then + echo "=== Building Makefile" + make -j4 +fi +if [[ -e "BULLET_PHYSICS.sln" ]] ; then + echo "=== Building BULLET_PHYSICS.sln" + dotnet build -c Release BULLET_PHYSICS.sln +fi # make install # As an alternative to installation, move the .a files in to a local directory # Good as it doesn't require admin privilages +echo "=== Cleaning out any existing lib and include directories" +cd "$STARTDIR" +rm -rf lib +rm -rf include + +echo "=== Moving .a files into ../lib" cd "$STARTDIR" mkdir -p lib -cd "${BULLET}" -cp */*/*/*.a ../lib -#cp */*/*.a */*/*/*.a ../lib +for afile in $(find "${BULLETDIR}/${BUILDDIR}" -name *.a) ; do + cp "$afile" lib +done +echo "=== Moving .h files into ../include" cd "$STARTDIR" mkdir -p include -cd "${BULLET}/src" -cp *.h ../../include +cd "${BULLETDIR}/src" for file in $(find . -name \*.h) ; do - xxxx="../../include/$(dirname $file)" + xxxx="${STARTDIR}/include/$(dirname $file)" mkdir -p "$xxxx" cp "$file" "$xxxx" done -cd ../Extras +# Move Bullet's VERSION file into lib/ so BulletSim can reference it +echo "=== Moving Bullet's VERSION file into ../lib" +cd "$STARTDIR" +mkdir -p lib +cp "${BULLETDIR}/VERSION" lib/ + +echo "=== Moving .h files from Extras into ../include" +cd "$STARTDIR" +cd "${BULLETDIR}/Extras" for file in $(find . -name \*.h) ; do - xxxx="../../include/$(dirname $file)" + xxxx="${STARTDIR}/include/$(dirname $file)" mkdir -p "$xxxx" cp "$file" "$xxxx" done +echo "=== Moving .inl files from Extras into ../include" for file in $(find . -name \*.inl) ; do - xxxx="../../include/$(dirname $file)" + xxxx="${STARTDIR}/include/$(dirname $file)" mkdir -p "$xxxx" cp "$file" "$xxxx" done diff --git a/trunk/unmanaged/BulletSim/buildBulletSim.bat b/trunk/unmanaged/BulletSim/buildBulletSim.bat new file mode 100755 index 00000000..0ba767e5 --- /dev/null +++ b/trunk/unmanaged/BulletSim/buildBulletSim.bat @@ -0,0 +1,6 @@ + +set /p BULLETVERSION= BulletSimVersionInfo +echo "BulletSimVersion=$BulletSimVersion" >> BulletSimVersionInfo +echo "BulletSimGitVersion=$BulletSimGitVersion" >> BulletSimVersionInfo +echo "BulletSimGitVersionShort=$BulletSimGitVersionShort" >> BulletSimVersionInfo +echo "BulletVersion=$BulletVersion" >> BulletSimVersionInfo +echo "BulletGitVersion=$BulletGitVersion" >> BulletSimVersionInfo +echo "BulletGitVersionShort=$BulletGitVersionShort" >> BulletSimVersionInfo diff --git a/trunk/unmanaged/BulletSim/makeBullets.sh b/trunk/unmanaged/BulletSim/makeBullets.sh new file mode 100755 index 00000000..9f3d947e --- /dev/null +++ b/trunk/unmanaged/BulletSim/makeBullets.sh @@ -0,0 +1,97 @@ +#! /bin/bash +# Script to fetch the Bullet Physics Engine sources, build same +# using the 'buildBulletSMake.sh' script, and then build BulletSim +# .so's using 'buildBulletSim.sh'. +# This captures the steps needed and will be replaced by better scripts +# and Github actions. +# +# This can build two versions of Bullet: one of current version and another +# of Bullet version 2.86 which is the version of Bullet that was +# used in the BulletSim binaries distributed with OpenSimulator +# from 2015 to 2022. +# This also applies the BulletSim patches to the Bullet sources. + +# Set these values to 'yes' or 'no' to enable/disable fetching and building +FETCHBULLETSOURCES=${FETCHBULLETSOURCES:-no} +BUILDBULLET2=${BUILDBULLET2:-no} # usually don't need the old version +BUILDBULLET3=${BUILDBULLET3:-yes} + +# Note that Bullet3 sources are build in "bullet3/" and the +# these are copied into "bullet2/" and checkouted to the version 2 sources. + +BASE=$(pwd) + +if [[ "$FETCHBULLETSOURCES" == "yes" ]] ; then + cd "$BASE" + rm -rf bullet3 + + echo "=== Fetching Bullet Physics Engine sources into bullet3/" + git clone https://github.com/bulletphysics/bullet3.git + + if [[ "$BUILDBULLET2" == "yes" ]] ; then + cd "$BASE" + echo "=== Creating bullet2/ of Bullet version 2.86" + rm -rf bullet2 + cp -r bullet3 bullet2 + cd bullet2 + git checkout tags/2.86 -b tag-2.86 + fi + + echo "=== Applying BulletSim patches to bullet3" + cd "$BASE" + cd bullet3 + for file in ../000* ; do cat $file | patch -p1 ; done + + if [[ "$BUILDBULLET2" == "yes" ]] ; then + echo "=== Applying BulletSim patches to bullet2" + cd "$BASE" + cd bullet2 + for file in ../2.86-00* ; do cat $file | patch -p1 ; done + fi +fi + +cd "$BASE" + +echo "=== Setting environment variables" +export BuildDate=$(date +%Y%m%d) +export BulletSimVersion=$(cat VERSION) +export BulletSimGitVersion=$(git rev-parse HEAD) +export BulletSimGitVersionShort=$(git rev-parse --short HEAD) +cd bullet3 +export BulletVersion=$(cat VERSION) +export BulletGitVersion=$(git rev-parse HEAD) +export BulletGitVersionShort=$(git rev-parse --short HEAD) + +echo "=== Creating version information file" +cd "$BASE" +rm BulletSimVersionInfo +touch BulletSimVersionInfo +echo "BuildDate=$BuildDate" > BulletSimVersionInfo +echo "BulletSimVersion=$BulletSimVersion" >> BulletSimVersionInfo +echo "BulletSimGitVersion=$BulletSimGitVersion" >> BulletSimVersionInfo +echo "BulletSimGitVersionShort=$BulletSimGitVersionShort" >> BulletSimVersionInfo +echo "BulletVersion=$BulletVersion" >> BulletSimVersionInfo +echo "BulletGitVersion=$BulletGitVersion" >> BulletSimVersionInfo +echo "BulletGitVersionShort=$BulletGitVersionShort" >> BulletSimVersionInfo +cat BulletSimVersionInfo + +echo "=== removing libBulletSim-*" +rm libBulletSim-*.so + +if [[ "$BUILDBULLET2" == "yes" ]] ; then + echo "=== building bullet2" + cd "$BASE" + # Build the Bullet physics engine + BULLETDIR=bullet2 ./buildBulletCMake.sh + # Build the BulletSim glue/wrapper statically linked to Bullet + ./buildBulletSim.sh +fi + +if [[ "$BUILDBULLET3" == "yes" ]] ; then + echo "=== building bullet3" + cd "$BASE" + # Build the Bullet physics engine + BULLETDIR=bullet3 ./buildBulletCMake.sh + # Build the BulletSim glue/wrapper statically linked to Bullet + ./buildBulletSim.sh +fi