Merge pull request #1016 from erwincoumans/master

Apply temporary stack-memory optimization, thanks to Jim Tilander
This commit is contained in:
erwincoumans 2017-03-13 23:18:25 -07:00 committed by GitHub
commit 25b1293ead

View File

@ -942,7 +942,13 @@ inline void btDbvt::collideTV( const btDbvtNode* root,
ATTRIBUTE_ALIGNED16(btDbvtVolume) volume(vol);
btAlignedObjectArray<const btDbvtNode*> stack;
stack.resize(0);
#ifndef BT_DISABLE_STACK_TEMP_MEMORY
char tempmemory[SIMPLE_STACKSIZE*sizeof(const btDbvtNode*)];
stack.initializeFromBuffer(tempmemory, 0, SIMPLE_STACKSIZE);
#else
stack.reserve(SIMPLE_STACKSIZE);
#endif //BT_DISABLE_STACK_TEMP_MEMORY
stack.push_back(root);
do {
const btDbvtNode* n=stack[stack.size()-1];
@ -1078,7 +1084,12 @@ inline void btDbvt::rayTest( const btDbvtNode* root,
int depth=1;
int treshold=DOUBLE_STACKSIZE-2;
char tempmemory[DOUBLE_STACKSIZE * sizeof(const btDbvtNode*)];
#ifndef BT_DISABLE_STACK_TEMP_MEMORY
stack.initializeFromBuffer(tempmemory, DOUBLE_STACKSIZE, DOUBLE_STACKSIZE);
#else//BT_DISABLE_STACK_TEMP_MEMORY
stack.resize(DOUBLE_STACKSIZE);
#endif //BT_DISABLE_STACK_TEMP_MEMORY
stack[0]=root;
btVector3 bounds[2];
do {