From 202cf1899574f72a70967914f665ff01ee15bb66 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 11 Dec 2019 13:07:53 -0800 Subject: [PATCH] allow to compile using clang-cl on visual studio (disable SSE) --- examples/ExampleBrowser/premake4.lua | 1 - examples/SharedMemory/premake4.lua | 4 ++-- examples/pybullet/premake4.lua | 4 ---- src/Bullet3Common/b3Logging.h | 17 +++++++++++++++-- src/Bullet3Common/b3Scalar.h | 26 +++++++++++++------------- src/LinearMath/btScalar.h | 8 +++++++- test/SharedMemory/premake4.lua | 2 -- 7 files changed, 37 insertions(+), 25 deletions(-) diff --git a/examples/ExampleBrowser/premake4.lua b/examples/ExampleBrowser/premake4.lua index 5ffba4a9a..c82a549e0 100644 --- a/examples/ExampleBrowser/premake4.lua +++ b/examples/ExampleBrowser/premake4.lua @@ -199,7 +199,6 @@ project "App_BulletExampleBrowser" "../RigidBody/RigidBodySoftContact.cpp", "../ThirdPartyLibs/stb_image/stb_image.cpp", "../ThirdPartyLibs/Wavefront/tiny_obj_loader.*", - "../ThirdPartyLibs/BussIK/*", "../GyroscopicDemo/GyroscopicSetup.cpp", "../GyroscopicDemo/GyroscopicSetup.h", "../ThirdPartyLibs/tinyxml2/tinyxml2.cpp", diff --git a/examples/SharedMemory/premake4.lua b/examples/SharedMemory/premake4.lua index 1be7f957f..980f14063 100644 --- a/examples/SharedMemory/premake4.lua +++ b/examples/SharedMemory/premake4.lua @@ -72,8 +72,6 @@ myfiles = "plugins/collisionFilterPlugin/collisionFilterPlugin.cpp", "plugins/pdControlPlugin/pdControlPlugin.cpp", "plugins/pdControlPlugin/pdControlPlugin.h", - "../OpenGLWindow/SimpleCamera.cpp", - "../OpenGLWindow/SimpleCamera.h", "../Importers/ImportURDFDemo/ConvertRigidBodies2MultiBody.h", "../Importers/ImportURDFDemo/MultiBodyCreationInterface.h", "../Importers/ImportURDFDemo/MyMultiBodyCreator.cpp", @@ -115,6 +113,8 @@ myfiles = files { myfiles, + "../OpenGLWindow/SimpleCamera.cpp", + "../OpenGLWindow/SimpleCamera.h", "main.cpp", } diff --git a/examples/pybullet/premake4.lua b/examples/pybullet/premake4.lua index 34d829579..8d63393d2 100644 --- a/examples/pybullet/premake4.lua +++ b/examples/pybullet/premake4.lua @@ -109,8 +109,6 @@ if not _OPTIONS["no-enet"] then "../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.h", "../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp", "../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.h", - "../../examples/OpenGLWindow/SimpleCamera.cpp", - "../../examples/OpenGLWindow/SimpleCamera.h", "../../examples/TinyRenderer/geometry.cpp", "../../examples/TinyRenderer/model.cpp", "../../examples/TinyRenderer/tgaimage.cpp", @@ -157,8 +155,6 @@ if not _OPTIONS["no-enet"] then "../../examples/SharedMemory/PosixSharedMemory.h", "../../examples/SharedMemory/SharedMemoryCommands.h", "../../examples/SharedMemory/SharedMemoryPublic.h", - "../../examples/Utils/b3ResourcePath.cpp", - "../../examples/Utils/b3ResourcePath.h", "../../examples/Utils/RobotLoggingUtil.cpp", "../../examples/Utils/RobotLoggingUtil.h", "../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp", diff --git a/src/Bullet3Common/b3Logging.h b/src/Bullet3Common/b3Logging.h index 9c92b12eb..3542718d6 100644 --- a/src/Bullet3Common/b3Logging.h +++ b/src/Bullet3Common/b3Logging.h @@ -14,7 +14,20 @@ extern "C" //#define b3Printf b3OutputPrintfVarArgsInternal //#define b3Printf(...) printf(__VA_ARGS__) //#define b3Printf(...) - +#ifdef __clang__ +#define b3Warning(...) \ + do \ + { \ + b3OutputWarningMessageVarArgsInternal("b3Warning[%s,%d]:\n", __FILE_NAME__, __LINE__); \ + b3OutputWarningMessageVarArgsInternal(__VA_ARGS__); \ + } while (0) +#define b3Error(...) \ + do \ + { \ + b3OutputErrorMessageVarArgsInternal("b3Error[%s,%d]:\n", __FILE_NAME__, __LINE__); \ + b3OutputErrorMessageVarArgsInternal(__VA_ARGS__); \ + } while (0) +#else//__clang__ #define b3Warning(...) \ do \ { \ @@ -27,7 +40,7 @@ extern "C" b3OutputErrorMessageVarArgsInternal("b3Error[%s,%d]:\n", __FILE__, __LINE__); \ b3OutputErrorMessageVarArgsInternal(__VA_ARGS__); \ } while (0) - +#endif //__clang__ #ifndef B3_NO_PROFILE void b3EnterProfileZone(const char* name); diff --git a/src/Bullet3Common/b3Scalar.h b/src/Bullet3Common/b3Scalar.h index c843c1dd2..eeb70ed63 100644 --- a/src/Bullet3Common/b3Scalar.h +++ b/src/Bullet3Common/b3Scalar.h @@ -71,7 +71,17 @@ inline int b3GetVersion() #if (defined(_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined(B3_USE_DOUBLE_PRECISION)) #if (defined(_M_IX86) || defined(_M_X64)) + + +#ifdef __clang__ +//#define B3_NO_SIMD_OPERATOR_OVERLOADS +#define B3_DISABLE_SSE +#endif //__clang__ + +#ifndef B3_DISABLE_SSE #define B3_USE_SSE +#endif //B3_DISABLE_SSE + #ifdef B3_USE_SSE //B3_USE_SSE_IN_API is disabled under Windows by default, because //it makes it harder to integrate Bullet into your application under Windows @@ -92,17 +102,7 @@ inline int b3GetVersion() #ifdef B3_DEBUG #ifdef _MSC_VER #include -#define b3Assert(x) \ - { \ - if (!(x)) \ - { \ - b3Error( \ - "Assert "__FILE__ \ - ":%u (" #x ")\n", \ - __LINE__); \ - __debugbreak(); \ - } \ - } +#define b3Assert(x) { if(!(x)){b3Error("Assert " __FILE__ ":%u (%s)\n", __LINE__, #x);__debugbreak(); }} #else //_MSC_VER #include #define b3Assert assert @@ -297,7 +297,7 @@ static int b3NanMask = 0x7F800001; static int b3InfinityMask = 0x7F800000; #define B3_INFINITY_MASK (*(float *)&b3InfinityMask) #endif - +#ifndef B3_NO_SIMD_OPERATOR_OVERLOADS inline __m128 operator+(const __m128 A, const __m128 B) { return _mm_add_ps(A, B); @@ -312,7 +312,7 @@ inline __m128 operator*(const __m128 A, const __m128 B) { return _mm_mul_ps(A, B); } - +#endif //B3_NO_SIMD_OPERATOR_OVERLOADS #define b3CastfTo128i(a) (_mm_castps_si128(a)) #define b3CastfTo128d(a) (_mm_castps_pd(a)) #define b3CastiTo128f(a) (_mm_castsi128_ps(a)) diff --git a/src/LinearMath/btScalar.h b/src/LinearMath/btScalar.h index 0fa46df09..9b5ea9585 100644 --- a/src/LinearMath/btScalar.h +++ b/src/LinearMath/btScalar.h @@ -110,11 +110,16 @@ inline int btIsDoublePrecision() #if defined (_M_ARM) //Do not turn SSE on for ARM (may want to turn on BT_USE_NEON however) #elif (defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION)) + +#ifdef __clang__ +#define __BT_DISABLE_SSE__ +#endif +#ifndef __BT_DISABLE_SSE__ #if _MSC_VER>1400 #define BT_USE_SIMD_VECTOR3 #endif - #define BT_USE_SSE +#endif//__BT_DISABLE_SSE__ #ifdef BT_USE_SSE #if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default) @@ -210,6 +215,7 @@ inline int btIsDoublePrecision() #if (defined (__APPLE__) && (!defined (BT_USE_DOUBLE_PRECISION))) #if defined (__i386__) || defined (__x86_64__) +#error bla #define BT_USE_SIMD_VECTOR3 #define BT_USE_SSE //BT_USE_SSE_IN_API is enabled on Mac OSX by default, because memory is automatically aligned on 16-byte boundaries diff --git a/test/SharedMemory/premake4.lua b/test/SharedMemory/premake4.lua index 7933e900e..69a66d32c 100644 --- a/test/SharedMemory/premake4.lua +++ b/test/SharedMemory/premake4.lua @@ -413,8 +413,6 @@ project ("Test_PhysicsServerInProcessExampleBrowser") "../../examples/TinyRenderer/tgaimage.cpp", "../../examples/TinyRenderer/our_gl.cpp", "../../examples/TinyRenderer/TinyRenderer.cpp", - "../../examples/Utils/b3ResourcePath.cpp", - "../../examples/Utils/b3ResourcePath.h", "../../examples/Utils/RobotLoggingUtil.cpp", "../../examples/Utils/RobotLoggingUtil.h", "../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp",