remove some warnings
This commit is contained in:
@@ -276,8 +276,9 @@ void b3GpuGridBroadphase::calculateOverlappingPairs(int maxPairs)
|
||||
{
|
||||
b3AlignedObjectArray<b3Int4> pairsCpu;
|
||||
m_gpuPairs.copyToHost(pairsCpu);
|
||||
|
||||
printf("m_gpuPairs.size()=%d\n",m_gpuPairs.size());
|
||||
|
||||
int sz = m_gpuPairs.size();
|
||||
printf("m_gpuPairs.size()=%d\n",sz);
|
||||
for (int i=0;i<m_gpuPairs.size();i++)
|
||||
{
|
||||
printf("pair %d = %d,%d\n",i,pairsCpu[i].x,pairsCpu[i].y);
|
||||
|
||||
@@ -782,7 +782,8 @@ cl_program b3OpenCLUtils_compileCLProgramFromString(cl_context clContext, cl_dev
|
||||
binarySize = ftell( file );
|
||||
rewind( file );
|
||||
binary = (char*)malloc(sizeof(char)*binarySize);
|
||||
fread( binary, sizeof(char), binarySize, file );
|
||||
int bytesRead;
|
||||
bytesRead = fread( binary, sizeof(char), binarySize, file );
|
||||
fclose( file );
|
||||
|
||||
m_cpProgram = clCreateProgramWithBinary( clContext, 1,&device, &binarySize, (const unsigned char**)&binary, 0, &status );
|
||||
|
||||
@@ -74,13 +74,14 @@ bFile::bFile(const char *filename, const char headerString[7])
|
||||
fseek(fp, 0L, SEEK_SET);
|
||||
|
||||
mFileBuffer = (char*)malloc(mFileLen+1);
|
||||
fread(mFileBuffer, mFileLen, 1, fp);
|
||||
int bytesRead;
|
||||
bytesRead = fread(mFileBuffer, mFileLen, 1, fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
//
|
||||
parseHeader();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +102,9 @@ bFile::bFile( char *memoryBuffer, int len, const char headerString[7])
|
||||
}
|
||||
mFileBuffer = memoryBuffer;
|
||||
mFileLen = len;
|
||||
|
||||
|
||||
parseHeader();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -210,12 +211,12 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
// read the DNA1 block and extract SDNA
|
||||
if (getNextBlock(&dna, tempBuffer, mFlags) > 0)
|
||||
{
|
||||
if (strncmp((tempBuffer + ChunkUtils::getOffset(mFlags)), "SDNANAME", 8) ==0)
|
||||
if (strncmp((tempBuffer + ChunkUtils::getOffset(mFlags)), "SDNANAME", 8) ==0)
|
||||
dna.oldPtr = (tempBuffer + ChunkUtils::getOffset(mFlags));
|
||||
else dna.oldPtr = 0;
|
||||
}
|
||||
else dna.oldPtr = 0;
|
||||
}
|
||||
}
|
||||
// Some Bullet files are missing the DNA1 block
|
||||
// In Blender it's DNA1 + ChunkUtils::getOffset() + SDNA + NAME
|
||||
// In Bullet tests its SDNA + NAME
|
||||
@@ -224,7 +225,7 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
dna.oldPtr = blenderData + i;
|
||||
dna.len = mFileLen-i;
|
||||
|
||||
// Also no REND block, so exit now.
|
||||
// Also no REND block, so exit now.
|
||||
if (mVersion==276) break;
|
||||
}
|
||||
|
||||
@@ -240,11 +241,11 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
|
||||
|
||||
mFileDNA = new bDNA();
|
||||
|
||||
|
||||
|
||||
|
||||
///mFileDNA->init will convert part of DNA file endianness to current CPU endianness if necessary
|
||||
mFileDNA->init((char*)dna.oldPtr, dna.len, (mFlags & FD_ENDIAN_SWAP)!=0);
|
||||
|
||||
|
||||
|
||||
if (mVersion==276)
|
||||
{
|
||||
@@ -270,10 +271,10 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
mMemoryDNA = new bDNA();
|
||||
int littleEndian= 1;
|
||||
littleEndian= ((char*)&littleEndian)[0];
|
||||
|
||||
|
||||
mMemoryDNA->init(memDna,memDnaLength,littleEndian==0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///@todo we need a better version check, add version/sub version info from FileGlobal into memory DNA/header files
|
||||
@@ -289,16 +290,16 @@ void bFile::parseInternal(int verboseMode, char* memDna,int memDnaLength)
|
||||
//printf ("Warning, file DNA is newer than built in.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
mFileDNA->initCmpFlags(mMemoryDNA);
|
||||
|
||||
|
||||
parseData();
|
||||
|
||||
|
||||
resolvePointers(verboseMode);
|
||||
|
||||
|
||||
updateOldPointers();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -309,8 +310,8 @@ void bFile::swap(char *head, bChunkInd& dataChunk, bool ignoreEndianFlag)
|
||||
char *data = head;
|
||||
short *strc = mFileDNA->getStruct(dataChunk.dna_nr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const char s[] = "SoftBodyMaterialData";
|
||||
int szs = sizeof(s);
|
||||
if (strncmp((char*)&dataChunk.code,"ARAY",4)==0)
|
||||
@@ -322,7 +323,7 @@ void bFile::swap(char *head, bChunkInd& dataChunk, bool ignoreEndianFlag)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int len = mFileDNA->getLength(strc[0]);
|
||||
|
||||
@@ -410,11 +411,11 @@ void bFile::swapDNA(char* ptr)
|
||||
|
||||
|
||||
// Parse names
|
||||
if (swap)
|
||||
if (swap)
|
||||
dataLen = ChunkUtils::swapInt(*intPtr);
|
||||
else
|
||||
else
|
||||
dataLen = *intPtr;
|
||||
|
||||
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
intPtr++;
|
||||
|
||||
@@ -426,7 +427,7 @@ void bFile::swapDNA(char* ptr)
|
||||
cp++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
nr= (long)cp;
|
||||
//long mask=3;
|
||||
@@ -448,9 +449,9 @@ void bFile::swapDNA(char* ptr)
|
||||
intPtr = (int*)cp;
|
||||
assert(strncmp(cp, "TYPE", 4)==0); intPtr++;
|
||||
|
||||
if (swap)
|
||||
if (swap)
|
||||
dataLen = ChunkUtils::swapInt(*intPtr);
|
||||
else
|
||||
else
|
||||
dataLen = *intPtr;
|
||||
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
@@ -485,7 +486,7 @@ void bFile::swapDNA(char* ptr)
|
||||
intPtr = (int*)cp;
|
||||
assert(strncmp(cp, "TLEN", 4)==0); intPtr++;
|
||||
|
||||
|
||||
|
||||
shtPtr = (short*)intPtr;
|
||||
for ( i=0; i<dataLen; i++, shtPtr++)
|
||||
{
|
||||
@@ -493,7 +494,7 @@ void bFile::swapDNA(char* ptr)
|
||||
shtPtr[0] = ChunkUtils::swapShort(shtPtr[0]);
|
||||
}
|
||||
|
||||
if (dataLen & 1)
|
||||
if (dataLen & 1)
|
||||
shtPtr++;
|
||||
|
||||
/*
|
||||
@@ -509,12 +510,12 @@ void bFile::swapDNA(char* ptr)
|
||||
|
||||
intPtr = (int*)shtPtr;
|
||||
cp = (char*)intPtr;
|
||||
assert(strncmp(cp, "STRC", 4)==0);
|
||||
assert(strncmp(cp, "STRC", 4)==0);
|
||||
intPtr++;
|
||||
|
||||
if (swap)
|
||||
if (swap)
|
||||
dataLen = ChunkUtils::swapInt(*intPtr);
|
||||
else
|
||||
else
|
||||
dataLen = *intPtr;
|
||||
|
||||
*intPtr = ChunkUtils::swapInt(*intPtr);
|
||||
@@ -525,7 +526,7 @@ void bFile::swapDNA(char* ptr)
|
||||
shtPtr = (short*)intPtr;
|
||||
for ( i=0; i<dataLen; i++)
|
||||
{
|
||||
|
||||
|
||||
//if (swap)
|
||||
{
|
||||
int len = shtPtr[1];
|
||||
@@ -573,11 +574,11 @@ void bFile::preSwap()
|
||||
mFileBuffer[8]='V';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mDataStart = 12;
|
||||
|
||||
char *dataPtr = mFileBuffer+mDataStart;
|
||||
@@ -595,7 +596,7 @@ void bFile::preSwap()
|
||||
while (1)
|
||||
{
|
||||
// one behind
|
||||
if (dataChunk.code == B3_SDNA || dataChunk.code==B3_DNA1 || dataChunk.code == B3_TYPE || dataChunk.code == B3_TLEN || dataChunk.code==B3_STRC)
|
||||
if (dataChunk.code == B3_SDNA || dataChunk.code==B3_DNA1 || dataChunk.code == B3_TYPE || dataChunk.code == B3_TLEN || dataChunk.code==B3_STRC)
|
||||
{
|
||||
|
||||
swapDNA(dataPtr);
|
||||
@@ -604,7 +605,7 @@ void bFile::preSwap()
|
||||
{
|
||||
//if (dataChunk.code == DNA1) break;
|
||||
dataPtrHead = dataPtr+ChunkUtils::getOffset(mFlags);
|
||||
|
||||
|
||||
swapLen(dataPtr);
|
||||
if (dataChunk.dna_nr>=0)
|
||||
{
|
||||
@@ -632,7 +633,7 @@ void bFile::preSwap()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -644,7 +645,7 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
||||
if (mFlags & FD_ENDIAN_SWAP)
|
||||
swap(head, dataChunk, ignoreEndianFlag);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!mFileDNA->flagEqual(dataChunk.dna_nr))
|
||||
{
|
||||
@@ -656,7 +657,7 @@ char* bFile::readStruct(char *head, bChunkInd& dataChunk)
|
||||
|
||||
oldStruct = mFileDNA->getStruct(dataChunk.dna_nr);
|
||||
oldType = mFileDNA->getType(oldStruct[0]);
|
||||
|
||||
|
||||
oldLen = mFileDNA->getLength(oldStruct[0]);
|
||||
|
||||
if ((mFlags&FD_BROKEN_DNA)!=0)
|
||||
@@ -951,7 +952,7 @@ void bFile::safeSwapPtr(char *dst, const char *src)
|
||||
B3_SWITCH_LONGINT(longValue);
|
||||
*((int*)dst) = (int)(longValue>>3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (ptrMem==8 && ptrFile==4)
|
||||
{
|
||||
@@ -991,7 +992,7 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
||||
const char* type = mFileDNA->getType(dna_addr[0]);
|
||||
const char* name = mFileDNA->getName(dna_addr[1]);
|
||||
|
||||
|
||||
|
||||
|
||||
int eleLen = mFileDNA->getElementSize(dna_addr[0], dna_addr[1]);
|
||||
|
||||
@@ -1008,7 +1009,7 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
||||
//int arrayLenold = mFileDNA->getArraySize((char*)name.c_str());
|
||||
int arrayLen = mFileDNA->getArraySizeNew(dna_addr[1]);
|
||||
//assert(arrayLenold == arrayLen);
|
||||
|
||||
|
||||
if (name[0] == '*')
|
||||
{
|
||||
// cast pointers
|
||||
@@ -1022,11 +1023,11 @@ void bFile::getMatchingFileDNA(short* dna_addr, const char* lookupName, const c
|
||||
{
|
||||
//void **sarray = (void**)strcData;
|
||||
//void **darray = (void**)data;
|
||||
|
||||
|
||||
char *cpc, *cpo;
|
||||
cpc = (char*)strcData;
|
||||
cpo = (char*)data;
|
||||
|
||||
|
||||
for (int a=0; a<arrayLen; a++)
|
||||
{
|
||||
safeSwapPtr(cpc, cpo);
|
||||
@@ -1162,7 +1163,7 @@ void bFile::resolvePointersMismatch()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (i=0; i<m_pointerPtrFixupArray.size(); i++)
|
||||
{
|
||||
char* cur= m_pointerPtrFixupArray.at(i);
|
||||
@@ -1227,7 +1228,7 @@ void bFile::resolvePointersChunk(const bChunkInd& dataChunk, int verboseMode)
|
||||
|
||||
int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verboseMode,int recursion)
|
||||
{
|
||||
|
||||
|
||||
bParse::bDNA* fileDna = mFileDNA ? mFileDNA : mMemoryDNA;
|
||||
|
||||
char* memType;
|
||||
@@ -1238,7 +1239,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
char* elemPtr= strcPtr;
|
||||
|
||||
short int* oldStruct = fileDna->getStruct(dna_nr);
|
||||
|
||||
|
||||
int elementLength = oldStruct[1];
|
||||
oldStruct+=2;
|
||||
|
||||
@@ -1249,8 +1250,8 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
|
||||
memType = fileDna->getType(oldStruct[0]);
|
||||
memName = fileDna->getName(oldStruct[1]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int arrayLen = fileDna->getArraySizeNew(oldStruct[1]);
|
||||
if (memName[0] == '*')
|
||||
@@ -1268,7 +1269,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
}
|
||||
//skip the *
|
||||
printf("<%s type=\"pointer\"> ",&memName[1]);
|
||||
printf("%d ", array[a]);
|
||||
printf("%p ", array[a]);
|
||||
printf("</%s>\n",&memName[1]);
|
||||
}
|
||||
|
||||
@@ -1286,7 +1287,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
printf(" ");
|
||||
}
|
||||
printf("<%s type=\"pointer\"> ",&memName[1]);
|
||||
printf("%d ", ptr);
|
||||
printf("%p ", ptr);
|
||||
printf("</%s>\n",&memName[1]);
|
||||
}
|
||||
ptr = findLibPointer(ptr);
|
||||
@@ -1316,7 +1317,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
} else
|
||||
{
|
||||
int revType = fileDna->getReverseType(oldStruct[0]);
|
||||
if (oldStruct[0]>=firstStructType) //revType != -1 &&
|
||||
if (oldStruct[0]>=firstStructType) //revType != -1 &&
|
||||
{
|
||||
char cleanName[MAX_STRLEN];
|
||||
getCleanName(memName,cleanName);
|
||||
@@ -1421,7 +1422,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1429,7 +1430,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
|
||||
int size = fileDna->getElementSize(oldStruct[0], oldStruct[1]);
|
||||
totalSize += size;
|
||||
elemPtr+=size;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
@@ -1445,9 +1446,9 @@ void bFile::resolvePointers(int verboseMode)
|
||||
|
||||
if (1) //mFlags & (FD_BITS_VARIES | FD_VERSION_VARIES))
|
||||
{
|
||||
resolvePointersMismatch();
|
||||
resolvePointersMismatch();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
if (verboseMode & FD_VERBOSE_EXPORT_XML)
|
||||
@@ -1465,9 +1466,9 @@ void bFile::resolvePointers(int verboseMode)
|
||||
//dataChunk.len
|
||||
short int* oldStruct = fileDna->getStruct(dataChunk.dna_nr);
|
||||
char* oldType = fileDna->getType(oldStruct[0]);
|
||||
|
||||
|
||||
if (verboseMode & FD_VERBOSE_EXPORT_XML)
|
||||
printf(" <%s pointer=%d>\n",oldType,dataChunk.oldPtr);
|
||||
printf(" <%s pointer=%p>\n",oldType,dataChunk.oldPtr);
|
||||
|
||||
resolvePointersChunk(dataChunk, verboseMode);
|
||||
|
||||
@@ -1483,8 +1484,8 @@ void bFile::resolvePointers(int verboseMode)
|
||||
printf("</bullet_physics>\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1518,13 +1519,13 @@ void bFile::dumpChunks(bParse::bDNA* dna)
|
||||
bChunkInd& dataChunk = m_chunks[i];
|
||||
char* codeptr = (char*)&dataChunk.code;
|
||||
char codestr[5] = {codeptr[0],codeptr[1],codeptr[2],codeptr[3],0};
|
||||
|
||||
|
||||
short* newStruct = dna->getStruct(dataChunk.dna_nr);
|
||||
char* typeName = dna->getType(newStruct[0]);
|
||||
printf("%3d: %s ",i,typeName);
|
||||
|
||||
printf("code=%s ",codestr);
|
||||
|
||||
|
||||
printf("ptr=%p ",dataChunk.oldPtr);
|
||||
printf("len=%d ",dataChunk.len);
|
||||
printf("nr=%d ",dataChunk.nr);
|
||||
@@ -1534,8 +1535,8 @@ void bFile::dumpChunks(bParse::bDNA* dna)
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1544,7 +1545,7 @@ void bFile::dumpChunks(bParse::bDNA* dna)
|
||||
ifd.success = 0;
|
||||
ifd.IDname = NULL;
|
||||
ifd.just_print_it = 1;
|
||||
for (i=0; i<bf->m_blocks.size(); ++i)
|
||||
for (i=0; i<bf->m_blocks.size(); ++i)
|
||||
{
|
||||
BlendBlock* bb = bf->m_blocks[i];
|
||||
printf("tag='%s'\tptr=%p\ttype=%s\t[%4d]", bb->tag, bb,bf->types[bb->type_index].name,bb->m_array_entries_.size());
|
||||
@@ -1563,7 +1564,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
for (int i=0;i<m_chunks.size();i++)
|
||||
{
|
||||
bChunkInd& dataChunk = m_chunks.at(i);
|
||||
|
||||
|
||||
// Ouch! need to rebuild the struct
|
||||
short *oldStruct,*curStruct;
|
||||
char *oldType, *newType;
|
||||
@@ -1574,7 +1575,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
oldLen = fileDna->getLength(oldStruct[0]);
|
||||
///don't try to convert Link block data, just memcpy it. Other data can be converted.
|
||||
reverseOld = mMemoryDNA->getReverseType(oldType);
|
||||
|
||||
|
||||
|
||||
if ((reverseOld!=-1))
|
||||
{
|
||||
@@ -1586,7 +1587,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
// make sure it's the same
|
||||
assert((strcmp(oldType, newType)==0) && "internal error, struct mismatch!");
|
||||
|
||||
|
||||
|
||||
curLen = mMemoryDNA->getLength(curStruct[0]);
|
||||
dataChunk.dna_nr = reverseOld;
|
||||
if (strcmp("Link",oldType)!=0)
|
||||
@@ -1596,10 +1597,10 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
{
|
||||
// printf("keep length of link = %d\n",dataChunk.len);
|
||||
}
|
||||
|
||||
|
||||
//write the structure header
|
||||
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
|
||||
|
||||
|
||||
|
||||
|
||||
short int* curStruct1;
|
||||
@@ -1615,7 +1616,7 @@ void bFile::writeChunks(FILE* fp, bool fixupPointers)
|
||||
printf("serious error, struct mismatch: don't write\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1625,9 +1626,9 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
|
||||
bool swap = false;
|
||||
bool varies = false;
|
||||
|
||||
if (flags &FD_ENDIAN_SWAP)
|
||||
if (flags &FD_ENDIAN_SWAP)
|
||||
swap = true;
|
||||
if (flags &FD_BITS_VARIES)
|
||||
if (flags &FD_BITS_VARIES)
|
||||
varies = true;
|
||||
|
||||
if (VOID_IS_8)
|
||||
@@ -1697,11 +1698,11 @@ int bFile::getNextBlock(bChunkInd *dataChunk, const char *dataPtr, const int fl
|
||||
{
|
||||
b3Long64 oldPtr =0;
|
||||
memcpy(&oldPtr, &head.m_uniqueInts[0], 8);
|
||||
if (swap)
|
||||
if (swap)
|
||||
B3_SWITCH_LONGINT(oldPtr);
|
||||
chunk.m_uniqueInt = (int)(oldPtr >> 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
chunk.dna_nr = head.dna_nr;
|
||||
chunk.nr = head.nr;
|
||||
|
||||
@@ -1,117 +1,117 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
#define GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
|
||||
|
||||
#include "btVector3.h"
|
||||
#include "btAlignedObjectArray.h"
|
||||
|
||||
struct GrahamVector3 : public btVector3
|
||||
{
|
||||
GrahamVector3(const btVector3& org, int orgIndex)
|
||||
:btVector3(org),
|
||||
m_orgIndex(orgIndex)
|
||||
{
|
||||
}
|
||||
btScalar m_angle;
|
||||
int m_orgIndex;
|
||||
};
|
||||
|
||||
|
||||
struct btAngleCompareFunc {
|
||||
btVector3 m_anchor;
|
||||
btAngleCompareFunc(const btVector3& anchor)
|
||||
: m_anchor(anchor)
|
||||
{
|
||||
}
|
||||
bool operator()(const GrahamVector3& a, const GrahamVector3& b) const {
|
||||
if (a.m_angle != b.m_angle)
|
||||
return a.m_angle < b.m_angle;
|
||||
else
|
||||
{
|
||||
btScalar al = (a-m_anchor).length2();
|
||||
btScalar bl = (b-m_anchor).length2();
|
||||
if (al != bl)
|
||||
return al < bl;
|
||||
else
|
||||
{
|
||||
return a.m_orgIndex < b.m_orgIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void GrahamScanConvexHull2D(btAlignedObjectArray<GrahamVector3>& originalPoints, btAlignedObjectArray<GrahamVector3>& hull, const btVector3& normalAxis)
|
||||
{
|
||||
btVector3 axis0,axis1;
|
||||
btPlaneSpace1(normalAxis,axis0,axis1);
|
||||
|
||||
|
||||
if (originalPoints.size()<=1)
|
||||
{
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
hull.push_back(originalPoints[0]);
|
||||
return;
|
||||
}
|
||||
//step1 : find anchor point with smallest projection on axis0 and move it to first location
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
{
|
||||
// const btVector3& left = originalPoints[i];
|
||||
// const btVector3& right = originalPoints[0];
|
||||
btScalar projL = originalPoints[i].dot(axis0);
|
||||
btScalar projR = originalPoints[0].dot(axis0);
|
||||
if (projL < projR)
|
||||
{
|
||||
originalPoints.swap(0,i);
|
||||
}
|
||||
}
|
||||
|
||||
//also precompute angles
|
||||
originalPoints[0].m_angle = -1e30f;
|
||||
for (int i=1;i<originalPoints.size();i++)
|
||||
{
|
||||
btVector3 xvec = axis0;
|
||||
btVector3 ar = originalPoints[i]-originalPoints[0];
|
||||
originalPoints[i].m_angle = btCross(xvec, ar).dot(normalAxis) / ar.length();
|
||||
}
|
||||
|
||||
//step 2: sort all points, based on 'angle' with this anchor
|
||||
btAngleCompareFunc comp(originalPoints[0]);
|
||||
originalPoints.quickSortInternal(comp,1,originalPoints.size()-1);
|
||||
|
||||
int i;
|
||||
for (i = 0; i<2; i++)
|
||||
hull.push_back(originalPoints[i]);
|
||||
|
||||
//step 3: keep all 'convex' points and discard concave points (using back tracking)
|
||||
for (; i != originalPoints.size(); i++)
|
||||
{
|
||||
bool isConvex = false;
|
||||
while (!isConvex&& hull.size()>1) {
|
||||
btVector3& a = hull[hull.size()-2];
|
||||
btVector3& b = hull[hull.size()-1];
|
||||
isConvex = btCross(a-b,a-originalPoints[i]).dot(normalAxis)> 0;
|
||||
if (!isConvex)
|
||||
hull.pop_back();
|
||||
else
|
||||
hull.push_back(originalPoints[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
#define GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
|
||||
|
||||
#include "btVector3.h"
|
||||
#include "btAlignedObjectArray.h"
|
||||
|
||||
struct GrahamVector3 : public btVector3
|
||||
{
|
||||
GrahamVector3(const btVector3& org, int orgIndex)
|
||||
:btVector3(org),
|
||||
m_orgIndex(orgIndex)
|
||||
{
|
||||
}
|
||||
btScalar m_angle;
|
||||
int m_orgIndex;
|
||||
};
|
||||
|
||||
|
||||
struct btAngleCompareFunc {
|
||||
btVector3 m_anchor;
|
||||
btAngleCompareFunc(const btVector3& anchor)
|
||||
: m_anchor(anchor)
|
||||
{
|
||||
}
|
||||
bool operator()(const GrahamVector3& a, const GrahamVector3& b) const {
|
||||
if (a.m_angle != b.m_angle)
|
||||
return a.m_angle < b.m_angle;
|
||||
else
|
||||
{
|
||||
btScalar al = (a-m_anchor).length2();
|
||||
btScalar bl = (b-m_anchor).length2();
|
||||
if (al != bl)
|
||||
return al < bl;
|
||||
else
|
||||
{
|
||||
return a.m_orgIndex < b.m_orgIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void GrahamScanConvexHull2D(btAlignedObjectArray<GrahamVector3>& originalPoints, btAlignedObjectArray<GrahamVector3>& hull, const btVector3& normalAxis)
|
||||
{
|
||||
btVector3 axis0,axis1;
|
||||
btPlaneSpace1(normalAxis,axis0,axis1);
|
||||
|
||||
|
||||
if (originalPoints.size()<=1)
|
||||
{
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
hull.push_back(originalPoints[0]);
|
||||
return;
|
||||
}
|
||||
//step1 : find anchor point with smallest projection on axis0 and move it to first location
|
||||
for (int i=0;i<originalPoints.size();i++)
|
||||
{
|
||||
// const btVector3& left = originalPoints[i];
|
||||
// const btVector3& right = originalPoints[0];
|
||||
btScalar projL = originalPoints[i].dot(axis0);
|
||||
btScalar projR = originalPoints[0].dot(axis0);
|
||||
if (projL < projR)
|
||||
{
|
||||
originalPoints.swap(0,i);
|
||||
}
|
||||
}
|
||||
|
||||
//also precompute angles
|
||||
originalPoints[0].m_angle = -1e30f;
|
||||
for (int i=1;i<originalPoints.size();i++)
|
||||
{
|
||||
btVector3 xvec = axis0;
|
||||
btVector3 ar = originalPoints[i]-originalPoints[0];
|
||||
originalPoints[i].m_angle = btCross(xvec, ar).dot(normalAxis) / ar.length();
|
||||
}
|
||||
|
||||
//step 2: sort all points, based on 'angle' with this anchor
|
||||
btAngleCompareFunc comp(originalPoints[0]);
|
||||
originalPoints.quickSortInternal(comp,1,originalPoints.size()-1);
|
||||
|
||||
int i;
|
||||
for (i = 0; i<2; i++)
|
||||
hull.push_back(originalPoints[i]);
|
||||
|
||||
//step 3: keep all 'convex' points and discard concave points (using back tracking)
|
||||
for (; i != originalPoints.size(); i++)
|
||||
{
|
||||
bool isConvex = false;
|
||||
while (!isConvex&& hull.size()>1) {
|
||||
btVector3& a = hull[hull.size()-2];
|
||||
btVector3& b = hull[hull.size()-1];
|
||||
isConvex = btCross(a-b,a-originalPoints[i]).dot(normalAxis)> 0;
|
||||
if (!isConvex)
|
||||
hull.pop_back();
|
||||
else
|
||||
hull.push_back(originalPoints[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //GRAHAM_SCAN_2D_CONVEX_HULL_H
|
||||
|
||||
@@ -46,7 +46,8 @@ class btIDebugDraw
|
||||
DBG_DrawConstraints = (1 << 11),
|
||||
DBG_DrawConstraintLimits = (1 << 12),
|
||||
DBG_FastWireframe = (1<<13),
|
||||
DBG_DrawNormals = (1<<14),
|
||||
DBG_DrawNormals = (1<<14),
|
||||
DBG_DrawFrames = (1<<15),
|
||||
DBG_MAX_DEBUG_DRAW_MODE
|
||||
};
|
||||
|
||||
@@ -147,7 +148,7 @@ class btIDebugDraw
|
||||
const btVector3& vx = axis;
|
||||
btVector3 vy = normal.cross(axis);
|
||||
btScalar step = stepDegrees * SIMD_RADS_PER_DEG;
|
||||
int nSteps = (int)((maxAngle - minAngle) / step);
|
||||
int nSteps = (int)btFabs((maxAngle - minAngle) / step);
|
||||
if(!nSteps) nSteps = 1;
|
||||
btVector3 prev = center + radiusA * vx * btCos(minAngle) + radiusB * vy * btSin(minAngle);
|
||||
if(drawSect)
|
||||
@@ -438,11 +439,10 @@ class btIDebugDraw
|
||||
drawLine(transform*pt0,transform*pt1,color);
|
||||
drawLine(transform*pt2,transform*pt3,color);
|
||||
}
|
||||
|
||||
virtual void flushLines()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void flushLines()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
0
src/LinearMath/btPoolAllocator.h
Executable file → Normal file
0
src/LinearMath/btPoolAllocator.h
Executable file → Normal file
@@ -10,7 +10,7 @@
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
// Credits: The Clock class was inspired by the Timer classes in
|
||||
// Credits: The Clock class was inspired by the Timer classes in
|
||||
// Ogre (www.ogre3d.org).
|
||||
|
||||
#include "btQuickprof.h"
|
||||
@@ -27,8 +27,8 @@ static btClock gProfileClock;
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined (SUNOS) || defined (__SUNOS__)
|
||||
#include <stdio.h>
|
||||
#if defined (SUNOS) || defined (__SUNOS__)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
@@ -37,7 +37,7 @@ static btClock gProfileClock;
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOWINRES
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
#define NOIME
|
||||
|
||||
#ifdef _XBOX
|
||||
#include <Xtl.h>
|
||||
@@ -121,34 +121,34 @@ void btClock::reset()
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Returns the time in ms since the last call to reset or since
|
||||
/// Returns the time in ms since the last call to reset or since
|
||||
/// the btClock was created.
|
||||
unsigned long int btClock::getTimeMilliseconds()
|
||||
{
|
||||
#ifdef BT_USE_WINDOWS_TIMERS
|
||||
LARGE_INTEGER currentTime;
|
||||
QueryPerformanceCounter(¤tTime);
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
m_data->mStartTime.QuadPart;
|
||||
// Compute the number of millisecond ticks elapsed.
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// bridge, aka south bridge. See Microsoft KB274323.)
|
||||
unsigned long elapsedTicks = GetTickCount() - m_data->mStartTick;
|
||||
signed long msecOff = (signed long)(msecTicks - elapsedTicks);
|
||||
if (msecOff < -100 || msecOff > 100)
|
||||
{
|
||||
// Adjust the starting time forwards.
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
m_data->mPrevElapsedTime);
|
||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
||||
elapsedTime -= msecAdjustment;
|
||||
|
||||
// Recompute the number of millisecond ticks elapsed.
|
||||
msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
}
|
||||
|
||||
@@ -171,36 +171,36 @@ unsigned long int btClock::getTimeMilliseconds()
|
||||
|
||||
struct timeval currentTime;
|
||||
gettimeofday(¤tTime, 0);
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000 +
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000 +
|
||||
(currentTime.tv_usec - m_data->mStartTime.tv_usec) / 1000;
|
||||
#endif //__CELLOS_LV2__
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Returns the time in us since the last call to reset or since
|
||||
/// Returns the time in us since the last call to reset or since
|
||||
/// the Clock was created.
|
||||
unsigned long int btClock::getTimeMicroseconds()
|
||||
{
|
||||
#ifdef BT_USE_WINDOWS_TIMERS
|
||||
LARGE_INTEGER currentTime;
|
||||
QueryPerformanceCounter(¤tTime);
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
LONGLONG elapsedTime = currentTime.QuadPart -
|
||||
m_data->mStartTime.QuadPart;
|
||||
|
||||
// Compute the number of millisecond ticks elapsed.
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// Check for unexpected leaps in the Win32 performance counter.
|
||||
// (This is caused by unexpected data across the PCI to ISA
|
||||
// bridge, aka south bridge. See Microsoft KB274323.)
|
||||
unsigned long elapsedTicks = GetTickCount() - m_data->mStartTick;
|
||||
signed long msecOff = (signed long)(msecTicks - elapsedTicks);
|
||||
if (msecOff < -100 || msecOff > 100)
|
||||
{
|
||||
// Adjust the starting time forwards.
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
LONGLONG msecAdjustment = mymin(msecOff *
|
||||
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
|
||||
m_data->mPrevElapsedTime);
|
||||
m_data->mStartTime.QuadPart += msecAdjustment;
|
||||
elapsedTime -= msecAdjustment;
|
||||
@@ -210,7 +210,7 @@ unsigned long int btClock::getTimeMicroseconds()
|
||||
m_data->mPrevElapsedTime = elapsedTime;
|
||||
|
||||
// Convert to microseconds.
|
||||
unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime /
|
||||
unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime /
|
||||
m_data->mClockFrequency.QuadPart);
|
||||
|
||||
return usecTicks;
|
||||
@@ -229,10 +229,10 @@ unsigned long int btClock::getTimeMicroseconds()
|
||||
|
||||
struct timeval currentTime;
|
||||
gettimeofday(¤tTime, 0);
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000000 +
|
||||
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000000 +
|
||||
(currentTime.tv_usec - m_data->mStartTime.tv_usec);
|
||||
#endif//__CELLOS_LV2__
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
|
||||
}
|
||||
|
||||
// We didn't find it, so add it
|
||||
|
||||
|
||||
CProfileNode * node = new CProfileNode( name, this );
|
||||
node->Sibling = Child;
|
||||
Child = node;
|
||||
@@ -337,7 +337,7 @@ void CProfileNode::Reset( void )
|
||||
{
|
||||
TotalCalls = 0;
|
||||
TotalTime = 0.0f;
|
||||
|
||||
|
||||
|
||||
if ( Child ) {
|
||||
Child->Reset();
|
||||
@@ -359,7 +359,7 @@ void CProfileNode::Call( void )
|
||||
|
||||
bool CProfileNode::Return( void )
|
||||
{
|
||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||
unsigned long int time;
|
||||
Profile_Get_Ticks(&time);
|
||||
time-=StartTime;
|
||||
@@ -452,8 +452,8 @@ void CProfileManager::Start_Profile( const char * name )
|
||||
{
|
||||
if (name != CurrentNode->Get_Name()) {
|
||||
CurrentNode = CurrentNode->Get_Sub_Node( name );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CurrentNode->Call();
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ void CProfileManager::Stop_Profile( void )
|
||||
* This resets everything except for the tree structure. All of the timing data is reset. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Reset( void )
|
||||
{
|
||||
{
|
||||
gProfileClock.reset();
|
||||
Root.Reset();
|
||||
Root.Call();
|
||||
@@ -523,9 +523,9 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
||||
printf("Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time );
|
||||
float totalTime = 0.f;
|
||||
|
||||
|
||||
|
||||
int numChildren = 0;
|
||||
|
||||
|
||||
for (i = 0; !profileIterator->Is_Done(); i++,profileIterator->Next())
|
||||
{
|
||||
numChildren++;
|
||||
@@ -546,7 +546,7 @@ void CProfileManager::dumpRecursive(CProfileIterator* profileIterator, int spaci
|
||||
}
|
||||
for (i=0;i<spacing;i++) printf(".");
|
||||
printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
|
||||
|
||||
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
profileIterator->Enter_Child(i);
|
||||
|
||||
@@ -97,7 +97,7 @@ inline int btGetVersion()
|
||||
#ifdef BT_DEBUG
|
||||
#ifdef _MSC_VER
|
||||
#include <stdio.h>
|
||||
#define btAssert(x) { if(!(x)){printf("Assert " __FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
||||
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
||||
#else//_MSC_VER
|
||||
#include <assert.h>
|
||||
#define btAssert assert
|
||||
@@ -125,7 +125,7 @@ inline int btGetVersion()
|
||||
#ifdef __SPU__
|
||||
#include <spu_printf.h>
|
||||
#define printf spu_printf
|
||||
#define btAssert(x) {if(!(x)){printf("Assert " __FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}}
|
||||
#define btAssert(x) {if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);spu_hcmpeq(0,0);}}
|
||||
#else
|
||||
#define btAssert assert
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user