Commit 531b1588 by Rémi Verschelde

vhacd: Recommit unmodified upstream code without style changes

Godot-specific changes will then be redone without touching upstream formatting. Also documented current state in thirdparty/README.md and added LICENSE. Add vhacd to COPYRIGHT.txt.
parent 7f2ad8bd
......@@ -385,6 +385,12 @@ Copyright: 2014-2018, Syoyo Fujita
2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC
License: BSD-3-clause
Files: ./thirdparty/vhacd/
Comment: V-HACD
Copyright: 2011, Khaled Mamou
2003-2009, Erwin Coumans
License: BSD-3-clause
Files: ./thirdparty/zlib/
Comment: zlib
Copyright: 1995-2017, Jean-loup Gailly and Mark Adler
......
# Third party libraries
## assimp
- Upstream: http://github.com/assimp/assimp
......@@ -294,8 +295,12 @@ Godot build configurations, check them out when updating.
File extracted from upstream release tarball `mbedtls-2.16.0-apache.tgz`:
- All `*.h` from `include/mbedtls/` to `thirdparty/mbedtls/include/mbedtls/`
- All `*.c` from `library/` to `thirdparty/mbedtls/library/`
- Applied the patch in `thirdparty/mbedtls/1453.diff` (PR 1453). Soon to be merged upstream. Check it out at next update.
- Applied the patch in `thirdparty/mbedtls/padlock.diff`. This disables VIA padlock support which defines a symbol `unsupported` which clashses with a symbol in libwebsockets.
- Applied the patch in `thirdparty/mbedtls/1453.diff` (PR 1453).
Soon to be merged upstream. Check it out at next update.
- Applied the patch in `thirdparty/mbedtls/padlock.diff`. This disables VIA
padlock support which defines a symbol `unsupported` which clashes with
a symbol in libwebsockets.
## miniupnpc
......@@ -523,6 +528,18 @@ Files extracted from upstream source:
- `tinyexr.{cc,h}`
## vhacd
- Upstream: https://github.com/kmammou/v-hacd
- Version: git (2297aa1, 2018)
- License: BSD-3-Clause
Files extracted from upstream source:
- From `src/VHACD_Lib/`: `inc`, `public` and `src`
- `LICENSE`
## zlib
- Upstream: http://www.zlib.net
......
BSD 3-Clause License
Copyright (c) 2011, Khaled Mamou (kmamou at gmail dot com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
......@@ -21,27 +21,22 @@ subject to the following restrictions:
///that is better portable and more predictable
#include "btScalar.h"
//GODOT ADDITION
namespace VHACD {
//
//#define BT_DEBUG_MEMORY_ALLOCATIONS 1
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
#define btAlignedAlloc(a, b) \
btAlignedAllocInternal(a, b, __LINE__, __FILE__)
btAlignedAllocInternal(a, b, __LINE__, __FILE__)
#define btAlignedFree(ptr) \
btAlignedFreeInternal(ptr, __LINE__, __FILE__)
btAlignedFreeInternal(ptr, __LINE__, __FILE__)
void *btAlignedAllocInternal(size_t size, int32_t alignment, int32_t line, char *filename);
void* btAlignedAllocInternal(size_t size, int32_t alignment, int32_t line, char* filename);
void btAlignedFreeInternal(void *ptr, int32_t line, char *filename);
void btAlignedFreeInternal(void* ptr, int32_t line, char* filename);
#else
void *btAlignedAllocInternal(size_t size, int32_t alignment);
void btAlignedFreeInternal(void *ptr);
void* btAlignedAllocInternal(size_t size, int32_t alignment);
void btAlignedFreeInternal(void* ptr);
#define btAlignedAlloc(size, alignment) btAlignedAllocInternal(size, alignment)
#define btAlignedFree(ptr) btAlignedFreeInternal(ptr)
......@@ -49,63 +44,61 @@ void btAlignedFreeInternal(void *ptr);
#endif
typedef int32_t size_type;
typedef void *(btAlignedAllocFunc)(size_t size, int32_t alignment);
typedef void(btAlignedFreeFunc)(void *memblock);
typedef void *(btAllocFunc)(size_t size);
typedef void(btFreeFunc)(void *memblock);
typedef void*(btAlignedAllocFunc)(size_t size, int32_t alignment);
typedef void(btAlignedFreeFunc)(void* memblock);
typedef void*(btAllocFunc)(size_t size);
typedef void(btFreeFunc)(void* memblock);
///The developer can let all Bullet memory allocations go through a custom memory allocator, using btAlignedAllocSetCustom
void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc);
void btAlignedAllocSetCustom(btAllocFunc* allocFunc, btFreeFunc* freeFunc);
///If the developer has already an custom aligned allocator, then btAlignedAllocSetCustomAligned can be used. The default aligned allocator pre-allocates extra memory using the non-aligned allocator, and instruments it.
void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc);
void btAlignedAllocSetCustomAligned(btAlignedAllocFunc* allocFunc, btAlignedFreeFunc* freeFunc);
///The btAlignedAllocator is a portable class for aligned memory allocations.
///Default implementations for unaligned and aligned allocations can be overridden by a custom allocator using btAlignedAllocSetCustom and btAlignedAllocSetCustomAligned.
template <typename T, unsigned Alignment>
class btAlignedAllocator {
typedef btAlignedAllocator<T, Alignment> self_type;
typedef btAlignedAllocator<T, Alignment> self_type;
public:
//just going down a list:
btAlignedAllocator() {}
/*
//just going down a list:
btAlignedAllocator() {}
/*
btAlignedAllocator( const self_type & ) {}
*/
template <typename Other>
btAlignedAllocator(const btAlignedAllocator<Other, Alignment> &) {}
typedef const T *const_pointer;
typedef const T &const_reference;
typedef T *pointer;
typedef T &reference;
typedef T value_type;
pointer address(reference ref) const { return &ref; }
const_pointer address(const_reference ref) const { return &ref; }
pointer allocate(size_type n, const_pointer *hint = 0) {
(void)hint;
return reinterpret_cast<pointer>(btAlignedAlloc(sizeof(value_type) * n, Alignment));
}
void construct(pointer ptr, const value_type &value) { new (ptr) value_type(value); }
void deallocate(pointer ptr) {
btAlignedFree(reinterpret_cast<void *>(ptr));
}
void destroy(pointer ptr) { ptr->~value_type(); }
template <typename O>
struct rebind {
typedef btAlignedAllocator<O, Alignment> other;
};
template <typename O>
self_type &operator=(const btAlignedAllocator<O, Alignment> &) { return *this; }
friend bool operator==(const self_type &, const self_type &) { return true; }
template <typename Other>
btAlignedAllocator(const btAlignedAllocator<Other, Alignment>&) {}
typedef const T* const_pointer;
typedef const T& const_reference;
typedef T* pointer;
typedef T& reference;
typedef T value_type;
pointer address(reference ref) const { return &ref; }
const_pointer address(const_reference ref) const { return &ref; }
pointer allocate(size_type n, const_pointer* hint = 0)
{
(void)hint;
return reinterpret_cast<pointer>(btAlignedAlloc(sizeof(value_type) * n, Alignment));
}
void construct(pointer ptr, const value_type& value) { new (ptr) value_type(value); }
void deallocate(pointer ptr)
{
btAlignedFree(reinterpret_cast<void*>(ptr));
}
void destroy(pointer ptr) { ptr->~value_type(); }
template <typename O>
struct rebind {
typedef btAlignedAllocator<O, Alignment> other;
};
template <typename O>
self_type& operator=(const btAlignedAllocator<O, Alignment>&) { return *this; }
friend bool operator==(const self_type&, const self_type&) { return true; }
};
//GODOT ADDITION
}; // namespace VHACD
//
#endif //BT_ALIGNED_ALLOCATOR
......@@ -18,60 +18,59 @@ subject to the following restrictions:
#include "btAlignedObjectArray.h"
#include "btVector3.h"
//GODOT ADDITION
namespace VHACD {
//
/// 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, int32_t stride, int32_t count, btScalar shrink, btScalar shrinkClamp);
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;
/*
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).
......@@ -83,18 +82,16 @@ public:
The output convex hull can be found in the member variables "vertices", "edges", "faces".
*/
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);
}
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);
}
};
//GODOT ADDITION
}; // namespace VHACD
//
#endif //BT_CONVEX_HULL_COMPUTER_H
......@@ -17,50 +17,49 @@ subject to the following restrictions:
#include "btScalar.h"
//GODOT ADDITION
namespace VHACD {
//
template <class T>
SIMD_FORCE_INLINE const T &btMin(const T &a, const T &b) {
return a < b ? a : b;
SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b)
{
return a < b ? a : b;
}
template <class T>
SIMD_FORCE_INLINE const T &btMax(const T &a, const T &b) {
return a > b ? a : b;
SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b)
{
return a > b ? a : b;
}
template <class T>
SIMD_FORCE_INLINE const T &btClamped(const T &a, const T &lb, const T &ub) {
return a < lb ? lb : (ub < a ? ub : a);
SIMD_FORCE_INLINE const T& btClamped(const T& a, const T& lb, const T& ub)
{
return a < lb ? lb : (ub < a ? ub : a);
}
template <class T>
SIMD_FORCE_INLINE void btSetMin(T &a, const T &b) {
if (b < a) {
a = b;
}
SIMD_FORCE_INLINE void btSetMin(T& a, const T& b)
{
if (b < a) {
a = b;
}
}
template <class T>
SIMD_FORCE_INLINE void btSetMax(T &a, const T &b) {
if (a < b) {
a = b;
}
SIMD_FORCE_INLINE void btSetMax(T& a, const T& b)
{
if (a < b) {
a = b;
}
}
template <class T>
SIMD_FORCE_INLINE void btClamp(T &a, const T &lb, const T &ub) {
if (a < lb) {
a = lb;
} else if (ub < a) {
a = ub;
}
SIMD_FORCE_INLINE void btClamp(T& a, const T& lb, const T& ub)
{
if (a < lb) {
a = lb;
}
else if (ub < a) {
a = ub;
}
}
//GODOT ADDITION
}; // namespace VHACD
//
#endif //BT_GEN_MINMAX_H
......@@ -15,157 +15,166 @@ subject to the following restrictions:
#include "btAlignedAllocator.h"
//GODOT ADDITION
namespace VHACD {
//
#ifdef _MSC_VER
#pragma warning(disable : 4311 4302)
#pragma warning(disable:4311 4302)
#endif
int32_t gNumAlignedAllocs = 0;
int32_t gNumAlignedFree = 0;
int32_t gTotalBytesAlignedAllocs = 0; //detect memory leaks
static void *btAllocDefault(size_t size) {
return malloc(size);
static void* btAllocDefault(size_t size)
{
return malloc(size);
}
static void btFreeDefault(void *ptr) {
free(ptr);
static void btFreeDefault(void* ptr)
{
free(ptr);
}
static btAllocFunc *sAllocFunc = btAllocDefault;
static btFreeFunc *sFreeFunc = btFreeDefault;
static btAllocFunc* sAllocFunc = btAllocDefault;
static btFreeFunc* sFreeFunc = btFreeDefault;
#if defined(BT_HAS_ALIGNED_ALLOCATOR)
#include <malloc.h>
static void *btAlignedAllocDefault(size_t size, int32_t alignment) {
return _aligned_malloc(size, (size_t)alignment);
static void* btAlignedAllocDefault(size_t size, int32_t alignment)
{
return _aligned_malloc(size, (size_t)alignment);
}
static void btAlignedFreeDefault(void *ptr) {
_aligned_free(ptr);
static void btAlignedFreeDefault(void* ptr)
{
_aligned_free(ptr);
}
#elif defined(__CELLOS_LV2__)
#include <stdlib.h>
static inline void *btAlignedAllocDefault(size_t size, int32_t alignment) {
return memalign(alignment, size);
static inline void* btAlignedAllocDefault(size_t size, int32_t alignment)
{
return memalign(alignment, size);
}
static inline void btAlignedFreeDefault(void *ptr) {
free(ptr);
static inline void btAlignedFreeDefault(void* ptr)
{
free(ptr);
}
#else
static inline void *btAlignedAllocDefault(size_t size, int32_t alignment) {
void *ret;
char *real;
unsigned long offset;
real = (char *)sAllocFunc(size + sizeof(void *) + (alignment - 1));
if (real) {
offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment - 1);
ret = (void *)((real + sizeof(void *)) + offset);
*((void **)(ret)-1) = (void *)(real);
} else {
ret = (void *)(real);
}
return (ret);
static inline void* btAlignedAllocDefault(size_t size, int32_t alignment)
{
void* ret;
char* real;
unsigned long offset;
real = (char*)sAllocFunc(size + sizeof(void*) + (alignment - 1));
if (real) {
offset = (alignment - (unsigned long)(real + sizeof(void*))) & (alignment - 1);
ret = (void*)((real + sizeof(void*)) + offset);
*((void**)(ret)-1) = (void*)(real);
}
else {
ret = (void*)(real);
}
return (ret);
}
static inline void btAlignedFreeDefault(void *ptr) {
void *real;
static inline void btAlignedFreeDefault(void* ptr)
{
void* real;
if (ptr) {
real = *((void **)(ptr)-1);
sFreeFunc(real);
}
if (ptr) {
real = *((void**)(ptr)-1);
sFreeFunc(real);
}
}
#endif
static btAlignedAllocFunc *sAlignedAllocFunc = btAlignedAllocDefault;
static btAlignedFreeFunc *sAlignedFreeFunc = btAlignedFreeDefault;
static btAlignedAllocFunc* sAlignedAllocFunc = btAlignedAllocDefault;
static btAlignedFreeFunc* sAlignedFreeFunc = btAlignedFreeDefault;
void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc) {
sAlignedAllocFunc = allocFunc ? allocFunc : btAlignedAllocDefault;
sAlignedFreeFunc = freeFunc ? freeFunc : btAlignedFreeDefault;
void btAlignedAllocSetCustomAligned(btAlignedAllocFunc* allocFunc, btAlignedFreeFunc* freeFunc)
{
sAlignedAllocFunc = allocFunc ? allocFunc : btAlignedAllocDefault;
sAlignedFreeFunc = freeFunc ? freeFunc : btAlignedFreeDefault;
}
void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc) {
sAllocFunc = allocFunc ? allocFunc : btAllocDefault;
sFreeFunc = freeFunc ? freeFunc : btFreeDefault;
void btAlignedAllocSetCustom(btAllocFunc* allocFunc, btFreeFunc* freeFunc)
{
sAllocFunc = allocFunc ? allocFunc : btAllocDefault;
sFreeFunc = freeFunc ? freeFunc : btFreeDefault;
}
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
//this generic allocator provides the total allocated number of bytes
#include <stdio.h>
void *btAlignedAllocInternal(size_t size, int32_t alignment, int32_t line, char *filename) {
void *ret;
char *real;
unsigned long offset;
gTotalBytesAlignedAllocs += size;
gNumAlignedAllocs++;
real = (char *)sAllocFunc(size + 2 * sizeof(void *) + (alignment - 1));
if (real) {
offset = (alignment - (unsigned long)(real + 2 * sizeof(void *))) & (alignment - 1);
ret = (void *)((real + 2 * sizeof(void *)) + offset);
*((void **)(ret)-1) = (void *)(real);
*((int32_t *)(ret)-2) = size;
} else {
ret = (void *)(real); //??
}
printf("allocation#%d at address %x, from %s,line %d, size %d\n", gNumAlignedAllocs, real, filename, line, size);
int32_t *ptr = (int32_t *)ret;
*ptr = 12;
return (ret);
void* btAlignedAllocInternal(size_t size, int32_t alignment, int32_t line, char* filename)
{
void* ret;
char* real;
unsigned long offset;
gTotalBytesAlignedAllocs += size;
gNumAlignedAllocs++;
real = (char*)sAllocFunc(size + 2 * sizeof(void*) + (alignment - 1));
if (real) {
offset = (alignment - (unsigned long)(real + 2 * sizeof(void*))) & (alignment - 1);
ret = (void*)((real + 2 * sizeof(void*)) + offset);
*((void**)(ret)-1) = (void*)(real);
*((int32_t*)(ret)-2) = size;
}
else {
ret = (void*)(real); //??
}
printf("allocation#%d at address %x, from %s,line %d, size %d\n", gNumAlignedAllocs, real, filename, line, size);
int32_t* ptr = (int32_t*)ret;
*ptr = 12;
return (ret);
}
void btAlignedFreeInternal(void *ptr, int32_t line, char *filename) {
void btAlignedFreeInternal(void* ptr, int32_t line, char* filename)
{
void *real;
gNumAlignedFree++;
void* real;
gNumAlignedFree++;
if (ptr) {
real = *((void **)(ptr)-1);
int32_t size = *((int32_t *)(ptr)-2);
gTotalBytesAlignedAllocs -= size;
if (ptr) {
real = *((void**)(ptr)-1);
int32_t size = *((int32_t*)(ptr)-2);
gTotalBytesAlignedAllocs -= size;
printf("free #%d at address %x, from %s,line %d, size %d\n", gNumAlignedFree, real, filename, line, size);
printf("free #%d at address %x, from %s,line %d, size %d\n", gNumAlignedFree, real, filename, line, size);
sFreeFunc(real);
} else {
printf("NULL ptr\n");
}
sFreeFunc(real);
}
else {
printf("NULL ptr\n");
}
}
#else //BT_DEBUG_MEMORY_ALLOCATIONS
void *btAlignedAllocInternal(size_t size, int32_t alignment) {
gNumAlignedAllocs++;
void *ptr;
ptr = sAlignedAllocFunc(size, alignment);
// printf("btAlignedAllocInternal %d, %x\n",size,ptr);
return ptr;
void* btAlignedAllocInternal(size_t size, int32_t alignment)
{
gNumAlignedAllocs++;
void* ptr;
ptr = sAlignedAllocFunc(size, alignment);
// printf("btAlignedAllocInternal %d, %x\n",size,ptr);
return ptr;
}
void btAlignedFreeInternal(void *ptr) {
if (!ptr) {
return;
}
void btAlignedFreeInternal(void* ptr)
{
if (!ptr) {
return;
}
gNumAlignedFree++;
// printf("btAlignedFreeInternal %x\n",ptr);
sAlignedFreeFunc(ptr);
gNumAlignedFree++;
// printf("btAlignedFreeInternal %x\n",ptr);
sAlignedFreeFunc(ptr);
}
//GODOT ADDITION
};
//
#endif //BT_DEBUG_MEMORY_ALLOCATIONS
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment