Skip to content

Commit

Permalink
Update from upstream 3999e29c0aaadec3c32ca9c526d2c5b5a1bf5e8b
Browse files Browse the repository at this point in the history
  • Loading branch information
ElementW committed Oct 1, 2017
1 parent 537b241 commit 1800c26
Show file tree
Hide file tree
Showing 30 changed files with 15,132 additions and 8,377 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
project(VHACD_LIB CXX C)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

if (NOT NO_OPENCL)
find_package(OpenCL REQUIRED)
Expand Down
525 changes: 525 additions & 0 deletions inc/FloatMath.h

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion inc/btAlignedAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ subject to the following restrictions:
///that is better portable and more predictable

#include "btScalar.h"
//#define BT_DEBUG_MEMORY_ALLOCATIONS 1


///BT_DEBUG_MEMORY_ALLOCATIONS preprocessor can be set in build system
///for regression tests to detect memory leaks
///#define BT_DEBUG_MEMORY_ALLOCATIONS 1
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS

int btDumpMemoryLeaks();

#define btAlignedAlloc(a,b) \
btAlignedAllocInternal(a,b,__LINE__,__FILE__)

Expand Down
45 changes: 32 additions & 13 deletions inc/btAlignedObjectArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ subject to the following restrictions:
#include <new> //for placement new
#endif //BT_USE_PLACEMENT_NEW

// The register keyword is deprecated in C++11 so don't use it.
#if __cplusplus > 199711L
#define BT_REGISTER
#else
#define BT_REGISTER register
#endif

///The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods
///It is developed to replace stl::vector to avoid portability issues, including STL alignment issues to add SIMD/SSE data
Expand Down Expand Up @@ -197,11 +203,21 @@ class btAlignedObjectArray
m_data[m_size].~T();
}


///resize changes the number of elements in the array. If the new size is larger, the new elements will be constructed using the optional second argument.
///when the new number of elements is smaller, the destructor will be called, but memory will not be freed, to reduce performance overhead of run-time memory (de)allocations.
SIMD_FORCE_INLINE void resizeNoInitialize(int newsize)
{
if (newsize > size())
{
reserve(newsize);
}
m_size = newsize;
}

SIMD_FORCE_INLINE void resize(int newsize, const T& fillData=T())
{
int curSize = size();
const BT_REGISTER int curSize = size();

if (newsize < curSize)
{
Expand All @@ -211,7 +227,7 @@ class btAlignedObjectArray
}
} else
{
if (newsize > size())
if (newsize > curSize)
{
reserve(newsize);
}
Expand All @@ -226,10 +242,9 @@ class btAlignedObjectArray

m_size = newsize;
}

SIMD_FORCE_INLINE T& expandNonInitializing( )
{
int sz = size();
const BT_REGISTER int sz = size();
if( sz == capacity() )
{
reserve( allocSize(size()) );
Expand All @@ -242,7 +257,7 @@ class btAlignedObjectArray

SIMD_FORCE_INLINE T& expand( const T& fillValue=T())
{
int sz = size();
const BT_REGISTER int sz = size();
if( sz == capacity() )
{
reserve( allocSize(size()) );
Expand All @@ -258,7 +273,7 @@ class btAlignedObjectArray

SIMD_FORCE_INLINE void push_back(const T& _Val)
{
int sz = size();
const BT_REGISTER int sz = size();
if( sz == capacity() )
{
reserve( allocSize(size()) );
Expand Down Expand Up @@ -307,12 +322,13 @@ class btAlignedObjectArray
{
public:

bool operator() ( const T& a, const T& b )
bool operator() ( const T& a, const T& b ) const
{
return ( a < b );
}
};


template <typename L>
void quickSortInternal(const L& CompareFunc,int lo, int hi)
{
Expand Down Expand Up @@ -460,15 +476,18 @@ class btAlignedObjectArray
return index;
}

void removeAtIndex(int index)
{
if (index<size())
{
swap( index,size()-1);
pop_back();
}
}
void remove(const T& key)
{

int findIndex = findLinearSearch(key);
if (findIndex<size())
{
swap( findIndex,size()-1);
pop_back();
}
removeAtIndex(findIndex);
}

//PCK: whole function
Expand Down
128 changes: 61 additions & 67 deletions inc/btConvexHullComputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,62 @@ subject to the following restrictions:
#ifndef BT_CONVEX_HULL_COMPUTER_H
#define BT_CONVEX_HULL_COMPUTER_H

#include "btVector3.h"
#include "btAlignedObjectArray.h"
#include "btVector3.h"

/// Convex hull implementation based on Preparata and Hong
/// See http://code.google.com/p/bullet/issues/detail?id=275
/// Ole Kniemeyer, MAXON Computer GmbH
class btConvexHullComputer
{
private:
btScalar compute(const void* coords, bool doubleCoords, int stride, int count, btScalar shrink, btScalar shrinkClamp);

public:

class Edge
{
private:
int next;
int reverse;
int targetVertex;

friend class btConvexHullComputer;

public:
int getSourceVertex() const
{
return (this + reverse)->targetVertex;
}

int getTargetVertex() const
{
return targetVertex;
}

const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex
{
return this + next;
}

const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face
{
return (this + reverse)->getNextEdgeOfVertex();
}

const Edge* getReverseEdge() const
{
return this + reverse;
}
};


// Vertices of the output hull
btAlignedObjectArray<btVector3> vertices;

// Edges of the output hull
btAlignedObjectArray<Edge> edges;

// Faces of the convex hull. Each entry is an index into the "edges" array pointing to an edge of the face. Faces are planar n-gons
btAlignedObjectArray<int> faces;

/*
class btConvexHullComputer {
private:
btScalar compute(const void* coords, bool doubleCoords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp);

public:
class Edge {
private:
int32_t next;
int32_t reverse;
int32_t targetVertex;

friend class btConvexHullComputer;

public:
int32_t getSourceVertex() const
{
return (this + reverse)->targetVertex;
}

int32_t getTargetVertex() const
{
return targetVertex;
}

const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex
{
return this + next;
}

const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face
{
return (this + reverse)->getNextEdgeOfVertex();
}

const Edge* getReverseEdge() const
{
return this + reverse;
}
};

// Vertices of the output hull
btAlignedObjectArray<btVector3> vertices;

// Edges of the output hull
btAlignedObjectArray<Edge> edges;

// Faces of the convex hull. Each entry is an index into the "edges" array pointing to an edge of the face. Faces are planar n-gons
btAlignedObjectArray<int32_t> faces;

/*
Compute convex hull of "count" vertices stored in "coords". "stride" is the difference in bytes
between the addresses of consecutive vertices. If "shrink" is positive, the convex hull is shrunken
by that amount (each face is moved by "shrink" length units towards the center along its normal).
Expand All @@ -86,18 +82,16 @@ class btConvexHullComputer
The output convex hull can be found in the member variables "vertices", "edges", "faces".
*/
btScalar compute(const float* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
{
return compute(coords, false, stride, count, shrink, shrinkClamp);
}

// same as above, but double precision
btScalar compute(const double* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp)
{
return compute(coords, true, stride, count, shrink, shrinkClamp);
}
btScalar compute(const float* coords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp)
{
return compute(coords, false, stride, count, shrink, shrinkClamp);
}

// same as above, but double precision
btScalar compute(const double* coords, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp)
{
return compute(coords, true, stride, count, shrink, shrinkClamp);
}
};


#endif //BT_CONVEX_HULL_COMPUTER_H

Loading

0 comments on commit 1800c26

Please sign in to comment.