Disallow the operator= for btAlignedObjectArray, together with some fixes in the code (to avoid accidental deep copy)
Enable #define BT_ALLOW_ARRAY_COPY_OPERATOR in Bullet/LinearMath/btAlignedObjectArray.h to re-enable it Fixes Issue 564, thanks to Tissen Peter for the report/fix
This commit is contained in:
@@ -251,7 +251,7 @@ bool ConvexBuilder::combineHulls(void)
|
|||||||
if ( combine )
|
if ( combine )
|
||||||
{
|
{
|
||||||
mChulls.clear();
|
mChulls.clear();
|
||||||
mChulls = output;
|
mChulls.copyFromArray(output);
|
||||||
output.clear();
|
output.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void btOptimizedBvh::build(btStridingMeshInterface* triangles, bool useQuantized
|
|||||||
|
|
||||||
NodeTriangleCallback& operator=(NodeTriangleCallback& other)
|
NodeTriangleCallback& operator=(NodeTriangleCallback& other)
|
||||||
{
|
{
|
||||||
m_triangleNodes = other.m_triangleNodes;
|
m_triangleNodes.copyFromArray(other.m_triangleNodes);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ void btOptimizedBvh::build(btStridingMeshInterface* triangles, bool useQuantized
|
|||||||
|
|
||||||
QuantizedNodeTriangleCallback& operator=(QuantizedNodeTriangleCallback& other)
|
QuantizedNodeTriangleCallback& operator=(QuantizedNodeTriangleCallback& other)
|
||||||
{
|
{
|
||||||
m_triangleNodes = other.m_triangleNodes;
|
m_triangleNodes.copyFromArray(other.m_triangleNodes);
|
||||||
m_optimizedTree = other.m_optimizedTree;
|
m_optimizedTree = other.m_optimizedTree;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#define BT_USE_PLACEMENT_NEW 1
|
#define BT_USE_PLACEMENT_NEW 1
|
||||||
//#define BT_USE_MEMCPY 1 //disable, because it is cumbersome to find out for each platform where memcpy is defined. It can be in <memory.h> or <string.h> or otherwise...
|
//#define BT_USE_MEMCPY 1 //disable, because it is cumbersome to find out for each platform where memcpy is defined. It can be in <memory.h> or <string.h> or otherwise...
|
||||||
|
//#define BT_ALLOW_ARRAY_COPY_OPERATOR // enabling this can accidently perform deep copies of data if you are not careful
|
||||||
|
|
||||||
#ifdef BT_USE_MEMCPY
|
#ifdef BT_USE_MEMCPY
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
@@ -53,7 +54,19 @@ class btAlignedObjectArray
|
|||||||
//PCK: added this line
|
//PCK: added this line
|
||||||
bool m_ownsMemory;
|
bool m_ownsMemory;
|
||||||
|
|
||||||
protected:
|
#ifdef BT_ALLOW_ARRAY_COPY_OPERATOR
|
||||||
|
public:
|
||||||
|
SIMD_FORCE_INLINE btAlignedObjectArray<T>& operator=(btAlignedObjectArray<T> &other)
|
||||||
|
{
|
||||||
|
copyFromArray(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#else//BT_ALLOW_ARRAY_COPY_OPERATOR
|
||||||
|
private:
|
||||||
|
SIMD_FORCE_INLINE btAlignedObjectArray<T>& operator=(btAlignedObjectArray<T> &other);
|
||||||
|
#endif//BT_ALLOW_ARRAY_COPY_OPERATOR
|
||||||
|
|
||||||
|
protected:
|
||||||
SIMD_FORCE_INLINE int allocSize(int size)
|
SIMD_FORCE_INLINE int allocSize(int size)
|
||||||
{
|
{
|
||||||
return (size ? size*2 : 1);
|
return (size ? size*2 : 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user