From a842fc2c11e30d189a41be930cf9db55eaddddfa Mon Sep 17 00:00:00 2001 From: Nathan Jeffords Date: Sun, 30 Dec 2012 22:02:55 -0800 Subject: [PATCH] added hack to fix an alignment issue in MSVC 2010 The default allocator in Visual Studio 2010 does not respect the alignment requirements of classes it is allocating memory for. This results in a potential crash when using OEngine::Physics::PhysicActor that has been allocated on the heap if it is built against a version of Bullet that has SSE intrinsics enabled. --- libs/openengine/bullet/physic.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index f320d009d..76bdb491d 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -122,8 +122,13 @@ namespace Physic */ void runPmove(); - - +//HACK: in Visual Studio 2010 and presumably above, this structures alignment +// must be 16, but the built in operator new & delete don't properly +// perform this alignment. +#if _MSC_VER >= 1600 + void * operator new (size_t Size) { return _aligned_malloc (Size, 16); } + void operator delete (void * Data) { _aligned_free (Data); } +#endif private: