Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp	(revision 2908)
@@ -20,4 +20,5 @@
 #include "btAxisSweep3.h"
 
+#include <assert.h>
 
 btAxisSweep3::btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator)
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h	(revision 2908)
@@ -43,5 +43,4 @@
 public:
 	
- BT_DECLARE_ALIGNED_ALLOCATOR();
 
 	class Edge
@@ -140,5 +139,5 @@
 	SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {return m_pHandles + index;}
 
-	virtual void resetPool(btDispatcher* dispatcher);
+	void resetPool();
 
 	void	processAllOverlappingPairs(btOverlapCallback* callback);
@@ -222,5 +221,5 @@
 
 	if (checkCardinality)
-		btAssert(numEdges == m_numHandles*2+1);
+		assert(numEdges == m_numHandles*2+1);
 }
 #endif //DEBUG_BROADPHASE
@@ -348,5 +347,5 @@
 	}
 
-	//btAssert(bounds.HasVolume());
+	//assert(bounds.HasVolume());
 
 	// init bounds
@@ -454,5 +453,5 @@
 BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle()
 {
-	btAssert(m_firstFreeHandle);
+	assert(m_firstFreeHandle);
 
 	BP_FP_INT_TYPE handle = m_firstFreeHandle;
@@ -466,5 +465,5 @@
 void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle)
 {
-	btAssert(handle > 0 && handle < m_maxHandles);
+	assert(handle > 0 && handle < m_maxHandles);
 
 	getHandle(handle)->SetNextFree(m_firstFreeHandle);
@@ -589,5 +588,5 @@
 
 template <typename BP_FP_INT_TYPE>
-void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool(btDispatcher* dispatcher)
+void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool()
 {
 	if (m_numHandles == 0)
@@ -643,5 +642,4 @@
 			if (!isDuplicate)
 			{
-				///important to use an AABB test that is consistent with the broadphase
 				bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
 
@@ -689,4 +687,8 @@
 	}
 
+
+
+	
+
 }
 
@@ -729,6 +731,6 @@
 void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher)
 {
-//	btAssert(bounds.IsFinite());
-	//btAssert(bounds.HasVolume());
+//	assert(bounds.IsFinite());
+	//assert(bounds.HasVolume());
 
 	Handle* pHandle = getHandle(handle);
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h	(revision 2908)
@@ -65,7 +65,4 @@
 	virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const =0;
 
-	///reset broadphase internal structures, to ensure determinism/reproducability
-	virtual void resetPool(btDispatcher* dispatcher) {};
-
 	virtual void	printStats() = 0;
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h	(revision 2908)
@@ -70,6 +70,5 @@
 
 	SOFTBODY_SHAPE_PROXYTYPE,
-	HFFLUID_SHAPE_PROXYTYPE,
-	HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE,
+
 	INVALID_SHAPE_PROXYTYPE,
 
@@ -189,5 +188,5 @@
 
 		//keep them sorted, so the std::set operations work
-		if (proxy0.m_uniqueId < proxy1.m_uniqueId)
+		if (&proxy0 < &proxy1)
         { 
             m_pProxy0 = &proxy0; 
@@ -230,11 +229,6 @@
 		bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
 		{
-			const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
-			const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
-			const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
-			const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
-
-			 return uidA0 > uidB0 || 
-				(a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
+			 return a.m_pProxy0 > b.m_pProxy0 || 
+				(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 > b.m_pProxy1) ||
 				(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm); 
 		}
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp	(revision 2908)
@@ -394,5 +394,5 @@
 }
 
-#if 0
+//
 static DBVT_INLINE btDbvtNode*	walkup(btDbvtNode* n,int count)
 {
@@ -400,5 +400,4 @@
 	return(n);
 }
-#endif
 
 //
@@ -425,12 +424,7 @@
 void			btDbvt::clear()
 {
-	if(m_root)	
-		recursedeletenode(this,m_root);
+	if(m_root)	recursedeletenode(this,m_root);
 	btAlignedFree(m_free);
 	m_free=0;
-	m_lkhd		=	-1;
-	m_stkStack.clear();
-	m_opath		=	0;
-	
 }
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h	(revision 2908)
@@ -58,5 +58,5 @@
 
 //SSE gives errors on a MSVC 7.1
-#ifdef BT_USE_SSE
+#if (defined (WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))
 #define DBVT_SELECT_IMPL		DBVT_IMPL_SSE
 #define DBVT_MERGE_IMPL			DBVT_IMPL_SSE
@@ -83,5 +83,5 @@
 #define DBVT_PREFIX					template <typename T>
 #define DBVT_IPOLICY				T& policy
-#define DBVT_CHECKTYPE				static const ICollide&	typechecker=*(T*)1;(void)typechecker;
+#define DBVT_CHECKTYPE				static const ICollide&	typechecker=*(T*)0;
 #else
 #define	DBVT_VIRTUAL_DTOR(a)		virtual ~a() {}
@@ -147,5 +147,7 @@
 	DBVT_INLINE friend bool			Intersect(	const btDbvtAabbMm& a,
 		const btDbvtAabbMm& b);
-	
+	DBVT_INLINE friend bool			Intersect(	const btDbvtAabbMm& a,
+		const btDbvtAabbMm& b,
+		const btTransform& xform);
 	DBVT_INLINE friend bool			Intersect(	const btDbvtAabbMm& a,
 		const btVector3& b);
@@ -303,5 +305,5 @@
 		  const btDbvtNode* root1,
 		  DBVT_IPOLICY);
-#if 0
+
 	DBVT_PREFIX
 		void		collideTT(	const btDbvtNode* root0,
@@ -315,6 +317,4 @@
 		const btTransform& xform1,
 		DBVT_IPOLICY);
-#endif
-
 	DBVT_PREFIX
 		void		collideTV(	const btDbvtNode* root,
@@ -531,5 +531,19 @@
 }
 
-
+//
+DBVT_INLINE bool		Intersect(	const btDbvtAabbMm& a,
+								  const btDbvtAabbMm& b,
+								  const btTransform& xform)
+{
+	const btVector3		d0=xform*b.Center()-a.Center();
+	const btVector3		d1=d0*xform.getBasis();
+	btScalar			s0[2]={0,0};
+	btScalar			s1[2]={dot(xform.getOrigin(),d0),s1[0]};
+	a.AddSpan(d0,s0[0],s0[1]);
+	b.AddSpan(d1,s1[0],s1[1]);
+	if(s0[0]>(s1[1])) return(false);
+	if(s0[1]<(s1[0])) return(false);
+	return(true);
+}
 
 //
@@ -835,5 +849,5 @@
 }
 
-#if 0
+
 //
 DBVT_PREFIX
@@ -891,4 +905,5 @@
 		}
 }
+
 //
 DBVT_PREFIX
@@ -902,5 +917,4 @@
 	collideTT(root0,root1,xform,policy);
 }
-#endif 
 
 //
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp	(revision 2908)
@@ -101,6 +101,5 @@
 			btDbvtProxy*	pb=(btDbvtProxy*)nb->data;
 #if DBVT_BP_SORTPAIRS
-			if(pa->m_uniqueId>pb->m_uniqueId) 
-				btSwap(pa,pb);
+			if(pa>pb) btSwap(pa,pb);
 #endif
 			pbp->m_paircache->addOverlappingPair(pa,pb);
@@ -134,5 +133,7 @@
 	m_updates_done		=	0;
 	m_updates_ratio		=	0;
-	m_paircache			=	paircache? paircache	: new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
+	m_paircache			=	paircache?
+paircache	:
+	new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
 	m_gid				=	0;
 	m_pid				=	0;
@@ -210,20 +211,21 @@
 }
 
-struct	BroadphaseRayTester : btDbvt::ICollide
-{
-	btBroadphaseRayCallback& m_rayCallback;
-	BroadphaseRayTester(btBroadphaseRayCallback& orgCallback)
-		:m_rayCallback(orgCallback)
-	{
-	}
-	void					Process(const btDbvtNode* leaf)
-	{
-		btDbvtProxy*	proxy=(btDbvtProxy*)leaf->data;
-		m_rayCallback.process(proxy);
-	}
-};	
-
 void	btDbvtBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin,const btVector3& aabbMax)
 {
+
+	struct	BroadphaseRayTester : btDbvt::ICollide
+	{
+		btBroadphaseRayCallback& m_rayCallback;
+		BroadphaseRayTester(btBroadphaseRayCallback& orgCallback)
+			:m_rayCallback(orgCallback)
+		{
+		}
+		void					Process(const btDbvtNode* leaf)
+		{
+			btDbvtProxy*	proxy=(btDbvtProxy*)leaf->data;
+			m_rayCallback.process(proxy);
+		}
+	};	
+
 	BroadphaseRayTester callback(rayCallback);
 
@@ -340,79 +342,4 @@
 	}
 #endif
-
-	performDeferredRemoval(dispatcher);
-
-}
-
-void btDbvtBroadphase::performDeferredRemoval(btDispatcher* dispatcher)
-{
-
-	if (m_paircache->hasDeferredRemoval())
-	{
-
-		btBroadphasePairArray&	overlappingPairArray = m_paircache->getOverlappingPairArray();
-
-		//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
-		overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
-
-		int invalidPair = 0;
-
-		
-		int i;
-
-		btBroadphasePair previousPair;
-		previousPair.m_pProxy0 = 0;
-		previousPair.m_pProxy1 = 0;
-		previousPair.m_algorithm = 0;
-		
-		
-		for (i=0;i<overlappingPairArray.size();i++)
-		{
-		
-			btBroadphasePair& pair = overlappingPairArray[i];
-
-			bool isDuplicate = (pair == previousPair);
-
-			previousPair = pair;
-
-			bool needsRemoval = false;
-
-			if (!isDuplicate)
-			{
-				//important to perform AABB check that is consistent with the broadphase
-				btDbvtProxy*		pa=(btDbvtProxy*)pair.m_pProxy0;
-				btDbvtProxy*		pb=(btDbvtProxy*)pair.m_pProxy1;
-				bool hasOverlap = Intersect(pa->leaf->volume,pb->leaf->volume);
-
-				if (hasOverlap)
-				{
-					needsRemoval = false;
-				} else
-				{
-					needsRemoval = true;
-				}
-			} else
-			{
-				//remove duplicate
-				needsRemoval = true;
-				//should have no algorithm
-				btAssert(!pair.m_algorithm);
-			}
-			
-			if (needsRemoval)
-			{
-				m_paircache->cleanOverlappingPair(pair,dispatcher);
-
-				pair.m_pProxy0 = 0;
-				pair.m_pProxy1 = 0;
-				invalidPair++;
-			} 
-			
-		}
-
-		//perform a sort, to sort 'invalid' pairs to the end
-		overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
-		overlappingPairArray.resize(overlappingPairArray.size() - invalidPair);
-	}
 }
 
@@ -420,21 +347,4 @@
 void							btDbvtBroadphase::collide(btDispatcher* dispatcher)
 {
-	/*printf("---------------------------------------------------------\n");
-	printf("m_sets[0].m_leaves=%d\n",m_sets[0].m_leaves);
-	printf("m_sets[1].m_leaves=%d\n",m_sets[1].m_leaves);
-	printf("numPairs = %d\n",getOverlappingPairCache()->getNumOverlappingPairs());
-	{
-		int i;
-		for (i=0;i<getOverlappingPairCache()->getNumOverlappingPairs();i++)
-		{
-			printf("pair[%d]=(%d,%d),",i,getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy0->getUid(),
-				getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy1->getUid());
-		}
-		printf("\n");
-	}
-*/
-
-
-
 	SPC(m_profiling.m_total);
 	/* optimize				*/ 
@@ -492,9 +402,9 @@
 		if(pairs.size()>0)
 		{
-
-			int			ni=btMin(pairs.size(),btMax<int>(m_newpairs,(pairs.size()*m_cupdates)/100));
+			const int	ci=pairs.size();
+			int			ni=btMin(ci,btMax<int>(m_newpairs,(ci*m_cupdates)/100));
 			for(int i=0;i<ni;++i)
 			{
-				btBroadphasePair&	p=pairs[(m_cid+i)%pairs.size()];
+				btBroadphasePair&	p=pairs[(m_cid+i)%ci];
 				btDbvtProxy*		pa=(btDbvtProxy*)p.m_pProxy0;
 				btDbvtProxy*		pb=(btDbvtProxy*)p.m_pProxy1;
@@ -502,6 +412,5 @@
 				{
 #if DBVT_BP_SORTPAIRS
-					if(pa->m_uniqueId>pb->m_uniqueId) 
-						btSwap(pa,pb);
+					if(pa>pb) btSwap(pa,pb);
 #endif
 					m_paircache->removeOverlappingPair(pa,pb,dispatcher);
@@ -558,37 +467,4 @@
 	aabbMin=bounds.Mins();
 	aabbMax=bounds.Maxs();
-}
-
-void btDbvtBroadphase::resetPool(btDispatcher* dispatcher)
-{
-	
-	int totalObjects = m_sets[0].m_leaves + m_sets[1].m_leaves;
-	if (!totalObjects)
-	{
-		//reset internal dynamic tree data structures
-		m_sets[0].clear();
-		m_sets[1].clear();
-		
-		m_deferedcollide	=	false;
-		m_needcleanup		=	true;
-		m_prediction		=	1/(btScalar)2;
-		m_stageCurrent		=	0;
-		m_fixedleft			=	0;
-		m_fupdates			=	1;
-		m_dupdates			=	0;
-		m_cupdates			=	10;
-		m_newpairs			=	1;
-		m_updates_call		=	0;
-		m_updates_done		=	0;
-		m_updates_ratio		=	0;
-		
-		m_gid				=	0;
-		m_pid				=	0;
-		m_cid				=	0;
-		for(int i=0;i<=STAGECOUNT;++i)
-		{
-			m_stageRoots[i]=0;
-		}
-	}
 }
 
@@ -725,3 +601,2 @@
 #undef	SPC
 #endif
-
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h	(revision 2908)
@@ -25,5 +25,5 @@
 
 #define	DBVT_BP_PROFILE					0
-//#define DBVT_BP_SORTPAIRS				1
+#define DBVT_BP_SORTPAIRS				1
 #define DBVT_BP_PREVENTFALSEUPDATE		0
 #define DBVT_BP_ACCURATESLEEPING		0
@@ -115,11 +115,4 @@
 	void							printStats();
 	static void						benchmark(btBroadphaseInterface*);
-
-
-	void	performDeferredRemoval(btDispatcher* dispatcher);
-
-	///reset broadphase internal structures, to ensure determinism/reproducability
-	virtual void resetPool(btDispatcher* dispatcher);
-
 };
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp	(revision 2908)
@@ -483,7 +483,2 @@
 
 }
-
-void btMultiSapBroadphase::resetPool(btDispatcher* dispatcher)
-{
-	// not yet
-}
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h	(revision 2908)
@@ -144,7 +144,4 @@
 	void quicksort (btBroadphasePairArray& a, int lo, int hi);
 
-	///reset broadphase internal structures, to ensure determinism/reproducability
-	virtual void resetPool(btDispatcher* dispatcher);
-
 };
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp	(revision 2908)
@@ -20,5 +20,4 @@
 #include "btDispatcher.h"
 #include "btCollisionAlgorithm.h"
-#include "LinearMath/btAabbUtil2.h"
 
 #include <stdio.h>
@@ -137,6 +136,5 @@
 {
 	gFindPairs++;
-	if(proxy0->m_uniqueId>proxy1->m_uniqueId) 
-		btSwap(proxy0,proxy1);
+	if(proxy0>proxy1) btSwap(proxy0,proxy1);
 	int proxyId1 = proxy0->getUid();
 	int proxyId2 = proxy1->getUid();
@@ -214,6 +212,5 @@
 btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
 {
-	if(proxy0->m_uniqueId>proxy1->m_uniqueId) 
-		btSwap(proxy0,proxy1);
+	if(proxy0>proxy1) btSwap(proxy0,proxy1);
 	int proxyId1 = proxy0->getUid();
 	int proxyId2 = proxy1->getUid();
@@ -274,6 +271,5 @@
 {
 	gRemovePairs++;
-	if(proxy0->m_uniqueId>proxy1->m_uniqueId) 
-		btSwap(proxy0,proxy1);
+	if(proxy0>proxy1) btSwap(proxy0,proxy1);
 	int proxyId1 = proxy0->getUid();
 	int proxyId2 = proxy1->getUid();
@@ -397,33 +393,4 @@
 }
 
-void	btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
-{
-	///need to keep hashmap in sync with pair address, so rebuild all
-	btBroadphasePairArray tmpPairs;
-	int i;
-	for (i=0;i<m_overlappingPairArray.size();i++)
-	{
-		tmpPairs.push_back(m_overlappingPairArray[i]);
-	}
-
-	for (i=0;i<tmpPairs.size();i++)
-	{
-		removeOverlappingPair(tmpPairs[i].m_pProxy0,tmpPairs[i].m_pProxy1,dispatcher);
-	}
-	
-	for (i = 0; i < m_next.size(); i++)
-	{
-		m_next[i] = BT_NULL_PAIR;
-	}
-
-	tmpPairs.quickSort(btBroadphasePairSortPredicate());
-
-	for (i=0;i<tmpPairs.size();i++)
-	{
-		addOverlappingPair(tmpPairs[i].m_pProxy0,tmpPairs[i].m_pProxy1);
-	}
-
-	
-}
 
 
@@ -463,5 +430,5 @@
 {
 	//don't add overlap with own
-	btAssert(proxy0 != proxy1);
+	assert(proxy0 != proxy1);
 
 	if (!needsBroadphaseCollision(proxy0,proxy1))
@@ -494,5 +461,5 @@
 	if (findIndex < m_overlappingPairArray.size())
 	{
-		//btAssert(it != m_overlappingPairSet.end());
+		//assert(it != m_overlappingPairSet.end());
 		 btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
 		return pair;
@@ -524,7 +491,6 @@
 		{
 			cleanOverlappingPair(*pair,dispatcher);
-			pair->m_pProxy0 = 0;
-			pair->m_pProxy1 = 0;
-			m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
+
+			m_overlappingPairArray.swap(i,m_overlappingPairArray.capacity()-1);
 			m_overlappingPairArray.pop_back();
 			gOverlappingPairs--;
@@ -626,8 +592,2 @@
 	processAllOverlappingPairs(&removeCallback,dispatcher);
 }
-
-void	btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
-{
-	//should already be sorted
-}
-
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h	(revision 2908)
@@ -84,7 +84,4 @@
 
 	virtual	void	setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)=0;
-
-	virtual void	sortOverlappingPairs(btDispatcher* dispatcher) = 0;
-
 
 };
@@ -263,8 +260,5 @@
 	}
 
-	virtual void	sortOverlappingPairs(btDispatcher* dispatcher);
-	
-
-protected:
+public:
 	
 	btAlignedObjectArray<int>	m_hashTable;
@@ -376,6 +370,4 @@
 		}
 
-		virtual void	sortOverlappingPairs(btDispatcher* dispatcher);
-		
 
 };
@@ -456,7 +448,4 @@
 	}
 	
-	virtual void	sortOverlappingPairs(btDispatcher* dispatcher)
-	{
-	}
 
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp	(revision 2908)
@@ -470,4 +470,5 @@
 
 #ifdef RAYAABB2
+	btVector3 rayFrom = raySource;
 	btVector3 rayDir = (rayTarget-raySource);
 	rayDir.normalize ();
@@ -558,4 +559,5 @@
 
 #ifdef RAYAABB2
+	btVector3 rayFrom = raySource;
 	btVector3 rayDirection = (rayTarget-raySource);
 	rayDirection.normalize ();
@@ -816,5 +818,4 @@
 #include <new>
 
-#if 0
 //PCK: consts
 static const unsigned BVH_ALIGNMENT = 16;
@@ -822,5 +823,5 @@
 
 static const unsigned BVH_ALIGNMENT_BLOCKS = 2;
-#endif
+
 
 
@@ -1146,3 +1147,2 @@
 
 
-
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp	(revision 2908)
@@ -325,6 +325,4 @@
 }
 
-void	btSimpleBroadphase::resetPool(btDispatcher* dispatcher)
-{
-	//not yet
-}
+
+
Index: code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h	(revision 2908)
@@ -109,7 +109,4 @@
 	}
 
-	///reset broadphase internal structures, to ensure determinism/reproducability
-	virtual void resetPool(btDispatcher* dispatcher);
-
 
 	void	validate();
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp	(revision 2908)
@@ -53,5 +53,5 @@
 		{
 			m_doubleDispatch[i][j] = m_collisionConfiguration->getCollisionAlgorithmCreateFunc(i,j);
-			btAssert(m_doubleDispatch[i][j]);
+			assert(m_doubleDispatch[i][j]);
 		}
 	}
@@ -80,10 +80,6 @@
 	btCollisionObject* body1 = (btCollisionObject*)b1;
 
-	//test for Bullet 2.74: use a relative contact breaking threshold without clamping against 'gContactBreakingThreshold'
-	//btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
-	btScalar contactBreakingThreshold = btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold());
-
-	btScalar contactProcessingThreshold = btMin(body0->getContactProcessingThreshold(),body1->getContactProcessingThreshold());
-		
+	btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
+	
 	void* mem = 0;
 	
@@ -96,5 +92,5 @@
 
 	}
-	btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold,contactProcessingThreshold);
+	btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold);
 	manifold->m_index1a = m_manifoldsPtr.size();
 	m_manifoldsPtr.push_back(manifold);
@@ -147,4 +143,5 @@
 	return algo;
 }
+
 
 
@@ -164,6 +161,6 @@
 bool	btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1)
 {
-	btAssert(body0);
-	btAssert(body1);
+	assert(body0);
+	assert(body1);
 
 	bool needsCollision = true;
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp	(revision 2908)
@@ -18,8 +18,5 @@
 
 btCollisionObject::btCollisionObject()
-	:	m_anisotropicFriction(1.f,1.f,1.f),
-	m_hasAnisotropicFriction(false),
-	m_contactProcessingThreshold(1e30f),
-		m_broadphaseHandle(0),
+	:	m_broadphaseHandle(0),
 		m_collisionShape(0),
 		m_rootCollisionShape(0),
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h	(revision 2908)
@@ -53,9 +53,4 @@
 	btVector3	m_interpolationLinearVelocity;
 	btVector3	m_interpolationAngularVelocity;
-	
-	btVector3		m_anisotropicFriction;
-	bool				m_hasAnisotropicFriction;
-	btScalar		m_contactProcessingThreshold;	
-
 	btBroadphaseProxy*		m_broadphaseHandle;
 	btCollisionShape*		m_collisionShape;
@@ -120,9 +115,8 @@
 		CO_COLLISION_OBJECT =1,
 		CO_RIGID_BODY,
+		CO_SOFT_BODY,
 		///CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter
 		///It is useful for collision sensors, explosion objects, character controller etc.
-		CO_GHOST_OBJECT,
-		CO_SOFT_BODY,
-		CO_HF_FLUID
+		CO_GHOST_OBJECT
 	};
 
@@ -133,28 +127,4 @@
 	}
 
-	const btVector3& getAnisotropicFriction() const
-	{
-		return m_anisotropicFriction;
-	}
-	void	setAnisotropicFriction(const btVector3& anisotropicFriction)
-	{
-		m_anisotropicFriction = anisotropicFriction;
-		m_hasAnisotropicFriction = (anisotropicFriction[0]!=1.f) || (anisotropicFriction[1]!=1.f) || (anisotropicFriction[2]!=1.f);
-	}
-	bool	hasAnisotropicFriction() const
-	{
-		return m_hasAnisotropicFriction;
-	}
-
-	///the constraint solver can discard solving contacts, if the distance is above this threshold. 0 by default.
-	///Note that using contacts with positive distance can improve stability. It increases, however, the chance of colliding with degerate contacts, such as 'interior' triangle edges
-	void	setContactProcessingThreshold( btScalar contactProcessingThreshold)
-	{
-		m_contactProcessingThreshold = contactProcessingThreshold;
-	}
-	btScalar	getContactProcessingThreshold() const
-	{
-		return m_contactProcessingThreshold;
-	}
 
 	SIMD_FORCE_INLINE bool		isStaticObject() const {
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp	(revision 2908)
@@ -70,5 +70,4 @@
 			getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
 			getBroadphase()->destroyProxy(bp,m_dispatcher1);
-			collisionObject->setBroadphaseHandle(0);
 		}
 	}
@@ -120,37 +119,4 @@
 
 
-void	btCollisionWorld::updateSingleAabb(btCollisionObject* colObj)
-{
-	btVector3 minAabb,maxAabb;
-	colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
-	//need to increase the aabb for contact thresholds
-	btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
-	minAabb -= contactThreshold;
-	maxAabb += contactThreshold;
-
-	btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
-
-	//moving objects should be moderately sized, probably something wrong if not
-	if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
-	{
-		bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
-	} else
-	{
-		//something went wrong, investigate
-		//this assert is unwanted in 3D modelers (danger of loosing work)
-		colObj->setActivationState(DISABLE_SIMULATION);
-
-		static bool reportMe = true;
-		if (reportMe && m_debugDrawer)
-		{
-			reportMe = false;
-			m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
-			m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
-			m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
-			m_debugDrawer->reportErrorWarning("Thanks.\n");
-		}
-	}
-}
-
 void	btCollisionWorld::updateAabbs()
 {
@@ -165,7 +131,36 @@
 		if (colObj->isActive())
 		{
-			updateSingleAabb(colObj);
-		}
-	}
+			btVector3 minAabb,maxAabb;
+			colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
+			//need to increase the aabb for contact thresholds
+			btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
+			minAabb -= contactThreshold;
+			maxAabb += contactThreshold;
+
+			btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
+
+			//moving objects should be moderately sized, probably something wrong if not
+			if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
+			{
+				bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
+			} else
+			{
+				//something went wrong, investigate
+				//this assert is unwanted in 3D modelers (danger of loosing work)
+				colObj->setActivationState(DISABLE_SIMULATION);
+
+				static bool reportMe = true;
+				if (reportMe && m_debugDrawer)
+				{
+					reportMe = false;
+					m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
+					m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
+					m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
+					m_debugDrawer->reportErrorWarning("Thanks.\n");
+				}
+			}
+		}
+	}
+
 }
 
@@ -299,6 +294,5 @@
 					BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
 						btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*	triangleMesh):
-                  //@BP Mod
-						btTriangleRaycastCallback(from,to, resultCallback->m_flags),
+						btTriangleRaycastCallback(from,to),
 							m_resultCallback(resultCallback),
 							m_collisionObject(collisionObject),
@@ -349,6 +343,5 @@
 					BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
 						btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape*	triangleMesh):
-                  //@BP Mod
-                  btTriangleRaycastCallback(from,to, resultCallback->m_flags),
+						btTriangleRaycastCallback(from,to),
 							m_resultCallback(resultCallback),
 							m_collisionObject(collisionObject),
@@ -671,5 +664,5 @@
 			//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
 			//btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
-#if 0
+			
 #ifdef RECALCULATE_AABB
 			btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
@@ -679,5 +672,4 @@
 			const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin;
 			const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax;
-#endif
 #endif
 			//btScalar hitLambda = m_resultCallback.m_closestHitFraction;
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h	(revision 2908)
@@ -59,6 +59,4 @@
  * 
  */
-
-
  
  
@@ -82,10 +80,8 @@
 {
 
-
 	
 protected:
 
 	btAlignedObjectArray<btCollisionObject*>	m_collisionObjects;
-
 	
 	btDispatcher*	m_dispatcher1;
@@ -99,5 +95,4 @@
 	btIDebugDraw*	m_debugDrawer;
 
-
 	
 public:
@@ -138,6 +133,4 @@
 		return m_dispatcher1;
 	}
-
-	void	updateSingleAabb(btCollisionObject* colObj);
 
 	virtual void	updateAabbs();
@@ -161,5 +154,4 @@
 		int	m_shapePart;
 		int	m_triangleIndex;
-
 		
 		//const btCollisionShape*	m_shapeTemp;
@@ -194,6 +186,4 @@
 		short int	m_collisionFilterGroup;
 		short int	m_collisionFilterMask;
-      //@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback
-      unsigned int m_flags;
 
 		virtual ~RayResultCallback()
@@ -209,7 +199,5 @@
 			m_collisionObject(0),
 			m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
-			m_collisionFilterMask(btBroadphaseProxy::AllFilter),
-         //@BP Mod
-         m_flags(0)
+			m_collisionFilterMask(btBroadphaseProxy::AllFilter)
 		{
 		}
@@ -239,5 +227,4 @@
 		btVector3	m_hitNormalWorld;
 		btVector3	m_hitPointWorld;
-
 			
 		virtual	btScalar	addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace)
@@ -245,5 +232,4 @@
 			//caller already does the filter on the m_closestHitFraction
 			btAssert(rayResult.m_hitFraction <= m_closestHitFraction);
-
 			
 			m_closestHitFraction = rayResult.m_hitFraction;
@@ -292,5 +278,4 @@
 		short int	m_collisionFilterGroup;
 		short int	m_collisionFilterMask;
-
 		
 		ConvexResultCallback()
@@ -304,5 +289,4 @@
 		{
 		}
-
 		
 		bool	hasHit() const
@@ -310,5 +294,4 @@
 			return (m_closestHitFraction < btScalar(1.));
 		}
-
 
 		
@@ -339,5 +322,4 @@
 		btVector3	m_hitPointWorld;
 		btCollisionObject*	m_hitCollisionObject;
-
 		
 		virtual	btScalar	addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace)
@@ -345,5 +327,4 @@
 //caller already does the filter on the m_closestHitFraction
 			btAssert(convexResult.m_hitFraction <= m_closestHitFraction);
-
 						
 			m_closestHitFraction = convexResult.m_hitFraction;
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp	(revision 2908)
@@ -20,5 +20,4 @@
 #include "LinearMath/btIDebugDraw.h"
 #include "LinearMath/btAabbUtil2.h"
-#include "btManifoldResult.h"
 
 btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
@@ -30,20 +29,8 @@
 
 	btCollisionObject* colObj = m_isSwapped? body1 : body0;
-	btAssert (colObj->getCollisionShape()->isCompound());
+	btCollisionObject* otherObj = m_isSwapped? body0 : body1;
+	assert (colObj->getCollisionShape()->isCompound());
 	
 	btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
-	m_compoundShapeRevision = compoundShape->getUpdateRevision();
-	
-	preallocateChildAlgorithms(body0,body1);
-}
-
-void	btCompoundCollisionAlgorithm::preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1)
-{
-	btCollisionObject* colObj = m_isSwapped? body1 : body0;
-	btCollisionObject* otherObj = m_isSwapped? body0 : body1;
-	btAssert (colObj->getCollisionShape()->isCompound());
-	
-	btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
-
 	int numChildren = compoundShape->getNumChildShapes();
 	int i;
@@ -60,5 +47,5 @@
 			btCollisionShape* childShape = compoundShape->getChildShape(i);
 			colObj->internalSetTemporaryCollisionShape( childShape );
-			m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(colObj,otherObj,m_sharedManifold);
+			m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj,m_sharedManifold);
 			colObj->internalSetTemporaryCollisionShape( tmpShape );
 		}
@@ -66,5 +53,6 @@
 }
 
-void	btCompoundCollisionAlgorithm::removeChildAlgorithms()
+
+btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
 {
 	int numChildren = m_childCollisionAlgorithms.size();
@@ -78,9 +66,4 @@
 		}
 	}
-}
-
-btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
-{
-	removeChildAlgorithms();
 }
 
@@ -185,19 +168,6 @@
 	btCollisionObject* otherObj = m_isSwapped? body0 : body1;
 
-	
-
-	btAssert (colObj->getCollisionShape()->isCompound());
+	assert (colObj->getCollisionShape()->isCompound());
 	btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
-
-	///btCompoundShape might have changed:
-	////make sure the internal child collision algorithm caches are still valid
-	if (compoundShape->getUpdateRevision() != m_compoundShapeRevision)
-	{
-		///clear and update all
-		removeChildAlgorithms();
-		
-		preallocateChildAlgorithms(body0,body1);
-	}
-
 
 	btDbvt* tree = compoundShape->getDynamicAabbTree();
@@ -205,28 +175,4 @@
 	btCompoundLeafCallback  callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold);
 
-	///we need to refresh all contact manifolds
-	///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep
-	///so we should add a 'refreshManifolds' in the btCollisionAlgorithm
-	{
-		int i;
-		btManifoldArray manifoldArray;
-		for (i=0;i<m_childCollisionAlgorithms.size();i++)
-		{
-			if (m_childCollisionAlgorithms[i])
-			{
-				m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);
-				for (int m=0;m<manifoldArray.size();m++)
-				{
-					if (manifoldArray[m]->getNumContacts())
-					{
-						resultOut->setPersistentManifold(manifoldArray[m]);
-						resultOut->refreshContactPoints();
-						resultOut->setPersistentManifold(0);//??necessary?
-					}
-				}
-				manifoldArray.clear();
-			}
-		}
-	}
 
 	if (tree)
@@ -297,5 +243,5 @@
 	btCollisionObject* otherObj = m_isSwapped? body0 : body1;
 
-	btAssert (colObj->getCollisionShape()->isCompound());
+	assert (colObj->getCollisionShape()->isCompound());
 	
 	btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
@@ -340,3 +286,2 @@
 
 
-
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h	(revision 2908)
@@ -27,5 +27,4 @@
 #include "LinearMath/btAlignedObjectArray.h"
 class btDispatcher;
-class btCollisionObject;
 
 /// btCompoundCollisionAlgorithm  supports collision between CompoundCollisionShapes and other collision shapes
@@ -37,11 +36,5 @@
 	class btPersistentManifold*	m_sharedManifold;
 	bool					m_ownsManifold;
-
-	int	m_compoundShapeRevision;//to keep track of changes, so that childAlgorithm array can be updated
 	
-	void	removeChildAlgorithms();
-	
-	void	preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1);
-
 public:
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp	(revision 2908)
@@ -52,6 +52,4 @@
 btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface*			simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
 {
-	m_numPerturbationIterations = 0;
-	m_minimumPointsPerturbationThreshold = 3;
 	m_simplexSolver = simplexSolver;
 	m_pdSolver = pdSolver;
@@ -62,5 +60,5 @@
 }
 
-btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
+btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
 : btActivatingCollisionAlgorithm(ci,body0,body1),
 m_simplexSolver(simplexSolver),
@@ -68,11 +66,9 @@
 m_ownManifold (false),
 m_manifoldPtr(mf),
-m_lowLevelOfDetail(false),
+m_lowLevelOfDetail(false)
 #ifdef USE_SEPDISTANCE_UTIL2
 ,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
-			  (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
+			  (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc())
 #endif
-m_numPerturbationIterations(numPerturbationIterations),
-m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
 {
 	(void)body0;
@@ -98,61 +94,6 @@
 
 
-struct btPerturbedContactResult : public btManifoldResult
-{
-	btManifoldResult* m_originalManifoldResult;
-	btTransform m_transformA;
-	btTransform m_transformB;
-	btTransform	m_unPerturbedTransform;
-	bool	m_perturbA;
-	btIDebugDraw*	m_debugDrawer;
-
-
-	btPerturbedContactResult(btManifoldResult* originalResult,const btTransform& transformA,const btTransform& transformB,const btTransform& unPerturbedTransform,bool perturbA,btIDebugDraw* debugDrawer)
-		:m_originalManifoldResult(originalResult),
-		m_transformA(transformA),
-		m_transformB(transformB),
-		m_perturbA(perturbA),
-		m_unPerturbedTransform(unPerturbedTransform),
-		m_debugDrawer(debugDrawer)
-	{
-	}
-	virtual ~ btPerturbedContactResult()
-	{
-	}
-
-	virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar orgDepth)
-	{
-		btVector3 endPt,startPt;
-		btScalar newDepth;
-		btVector3 newNormal;
-
-		if (m_perturbA)
-		{
-			btVector3 endPtOrg = pointInWorld + normalOnBInWorld*orgDepth;
-			endPt = (m_unPerturbedTransform*m_transformA.inverse())(endPtOrg);
-			newDepth = (endPt -  pointInWorld).dot(normalOnBInWorld);
-			startPt = endPt+normalOnBInWorld*newDepth;
-		} else
-		{
-			endPt = pointInWorld + normalOnBInWorld*orgDepth;
-			startPt = (m_unPerturbedTransform*m_transformB.inverse())(pointInWorld);
-			newDepth = (endPt -  startPt).dot(normalOnBInWorld);
-			
-		}
-
-//#define DEBUG_CONTACTS 1
-#ifdef DEBUG_CONTACTS
-		m_debugDrawer->drawLine(startPt,endPt,btVector3(1,0,0));
-		m_debugDrawer->drawSphere(startPt,0.05,btVector3(0,1,0));
-		m_debugDrawer->drawSphere(endPt,0.05,btVector3(0,0,1));
-#endif //DEBUG_CONTACTS
-
-		
-		m_originalManifoldResult->addContactPoint(normalOnBInWorld,startPt,newDepth);
-	}
-
-};
-
-extern btScalar gContactBreakingThreshold;
+
+
 
 //
@@ -170,6 +111,4 @@
 	resultOut->setPersistentManifold(m_manifoldPtr);
 
-	//comment-out next line to test multi-contact generation
-	//resultOut->getPersistentManifold()->clearManifold();
 	
 
@@ -208,75 +147,6 @@
 
 	gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
+
 	btScalar sepDist = gjkPairDetector.getCachedSeparatingDistance()+dispatchInfo.m_convexConservativeDistanceThreshold;
-
-	//now perturbe directions to get multiple contact points
-	btVector3 v0,v1;
-	btVector3 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized();
-	btPlaneSpace1(sepNormalWorldSpace,v0,v1);
-	//now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
-	
-	//perform perturbation when more then 'm_minimumPointsPerturbationThreshold' points
-	if (resultOut->getPersistentManifold()->getNumContacts() < m_minimumPointsPerturbationThreshold)
-	{
-		
-		int i;
-
-		bool perturbeA = true;
-		const btScalar angleLimit = 0.125f * SIMD_PI;
-		btScalar perturbeAngle;
-		btScalar radiusA = min0->getAngularMotionDisc();
-		btScalar radiusB = min1->getAngularMotionDisc();
-		if (radiusA < radiusB)
-		{
-			perturbeAngle = gContactBreakingThreshold /radiusA;
-			perturbeA = true;
-		} else
-		{
-			perturbeAngle = gContactBreakingThreshold / radiusB;
-			perturbeA = false;
-		}
-		if ( perturbeAngle > angleLimit ) 
-				perturbeAngle = angleLimit;
-
-		btTransform unPerturbedTransform;
-		if (perturbeA)
-		{
-			unPerturbedTransform = input.m_transformA;
-		} else
-		{
-			unPerturbedTransform = input.m_transformB;
-		}
-		
-		for ( i=0;i<m_numPerturbationIterations;i++)
-		{
-			btQuaternion perturbeRot(v0,perturbeAngle);
-			btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
-			btQuaternion rotq(sepNormalWorldSpace,iterationAngle);
-			
-			
-			if (perturbeA)
-			{
-				input.m_transformA.setBasis(  btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body0->getWorldTransform().getBasis());
-				input.m_transformB = body1->getWorldTransform();
-#ifdef DEBUG_CONTACTS
-				dispatchInfo.m_debugDraw->drawTransform(input.m_transformA,10.0);
-#endif //DEBUG_CONTACTS
-			} else
-			{
-				input.m_transformA = body0->getWorldTransform();
-				input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body1->getWorldTransform().getBasis());
-#ifdef DEBUG_CONTACTS
-				dispatchInfo.m_debugDraw->drawTransform(input.m_transformB,10.0);
-#endif
-			}
-			
-			btPerturbedContactResult perturbedResultOut(resultOut,input.m_transformA,input.m_transformB,unPerturbedTransform,perturbeA,dispatchInfo.m_debugDraw);
-			gjkPairDetector.getClosestPoints(input,perturbedResultOut,dispatchInfo.m_debugDraw);
-			
-			
-		}
-	}
-
-	
 
 #ifdef USE_SEPDISTANCE_UTIL2
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h	(revision 2908)
@@ -34,7 +34,5 @@
 ///#define USE_SEPDISTANCE_UTIL2 1
 
-///The convexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations between two convex objects.
-///Multiple contact points are calculated by perturbing the orientation of the smallest object orthogonal to the separating normal.
-///This idea was described by Gino van den Bergen in this forum topic http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=4&t=288&p=888#p888
+///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
 class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm
 {
@@ -50,8 +48,4 @@
 	bool			m_lowLevelOfDetail;
 	
-	int m_numPerturbationIterations;
-	int m_minimumPointsPerturbationThreshold;
-
-
 	///cache separating vector to speedup collision detection
 	
@@ -59,6 +53,5 @@
 public:
 
-	btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
-
+	btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
 
 	virtual ~btConvexConvexAlgorithm();
@@ -86,10 +79,7 @@
 	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
 	{
-
 		btConvexPenetrationDepthSolver*		m_pdSolver;
 		btSimplexSolverInterface*			m_simplexSolver;
-		int m_numPerturbationIterations;
-		int m_minimumPointsPerturbationThreshold;
-
+		
 		CreateFunc(btSimplexSolverInterface*			simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
 		
@@ -99,5 +89,5 @@
 		{
 			void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm));
-			return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
+			return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver);
 		}
 	};
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp	(revision 2908)
@@ -5,6 +5,6 @@
 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,
+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:
 
@@ -23,15 +23,13 @@
 //#include <stdio.h>
 
-btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold)
+btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
 : btCollisionAlgorithm(ci),
 m_ownManifold(false),
 m_manifoldPtr(mf),
-m_isSwapped(isSwapped),
-m_numPerturbationIterations(numPerturbationIterations),
-m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
+m_isSwapped(isSwapped)
 {
 	btCollisionObject* convexObj = m_isSwapped? col1 : col0;
 	btCollisionObject* planeObj = m_isSwapped? col0 : col1;
-
+	
 	if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj))
 	{
@@ -51,7 +49,14 @@
 }
 
-void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+
+
+void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
 {
-    btCollisionObject* convexObj = m_isSwapped? body1 : body0;
+	(void)dispatchInfo;
+	(void)resultOut;
+	if (!m_manifoldPtr)
+		return;
+
+	btCollisionObject* convexObj = m_isSwapped? body1 : body0;
 	btCollisionObject* planeObj = m_isSwapped? body0: body1;
 
@@ -59,18 +64,13 @@
 	btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
 
-    bool hasCollision = false;
+	bool hasCollision = false;
 	const btVector3& planeNormal = planeShape->getPlaneNormal();
 	const btScalar& planeConstant = planeShape->getPlaneConstant();
-	
-	btTransform convexWorldTransform = convexObj->getWorldTransform();
+	btTransform planeInConvex;
+	planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
 	btTransform convexInPlaneTrans;
-	convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexWorldTransform;
-	//now perturbe the convex-world transform
-	convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot);
-	btTransform planeInConvex;
-	planeInConvex= convexWorldTransform.inverse() * planeObj->getWorldTransform();
-	
+	convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();
+
 	btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
-
 	btVector3 vtxInPlane = convexInPlaneTrans(vtx);
 	btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
@@ -88,51 +88,4 @@
 		resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
 	}
-}
-
-
-void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
-{
-	(void)dispatchInfo;
-	if (!m_manifoldPtr)
-		return;
-
-    btCollisionObject* convexObj = m_isSwapped? body1 : body0;
-	btCollisionObject* planeObj = m_isSwapped? body0: body1;
-
-	btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
-	btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
-
-    bool hasCollision = false;
-	const btVector3& planeNormal = planeShape->getPlaneNormal();
-	const btScalar& planeConstant = planeShape->getPlaneConstant();
-
-	//first perform a collision query with the non-perturbated collision objects
-	{
-		btQuaternion rotq(0,0,0,1);
-		collideSingleContact(rotq,body0,body1,dispatchInfo,resultOut);
-	}
-
-	if (resultOut->getPersistentManifold()->getNumContacts()<m_minimumPointsPerturbationThreshold)
-	{
-		btVector3 v0,v1;
-		btPlaneSpace1(planeNormal,v0,v1);
-		//now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
-
-		const btScalar angleLimit = 0.125f * SIMD_PI;
-		btScalar perturbeAngle;
-		btScalar radius = convexShape->getAngularMotionDisc();
-		perturbeAngle = gContactBreakingThreshold / radius;
-		if ( perturbeAngle > angleLimit ) 
-				perturbeAngle = angleLimit;
-
-		btQuaternion perturbeRot(v0,perturbeAngle);
-		for (int i=0;i<m_numPerturbationIterations;i++)
-		{
-			btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
-			btQuaternion rotq(planeNormal,iterationAngle);
-			collideSingleContact(rotq.inverse()*perturbeRot*rotq,body0,body1,dispatchInfo,resultOut);
-		}
-	}
-
 	if (m_ownManifold)
 	{
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h	(revision 2908)
@@ -5,6 +5,6 @@
 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,
+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:
 
@@ -29,19 +29,15 @@
 class btConvexPlaneCollisionAlgorithm : public btCollisionAlgorithm
 {
-	bool		m_ownManifold;
+	bool	m_ownManifold;
 	btPersistentManifold*	m_manifoldPtr;
-	bool		m_isSwapped;
-	int			m_numPerturbationIterations;
-	int			m_minimumPointsPerturbationThreshold;
-
+	bool	m_isSwapped;
+	
 public:
 
-	btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold);
+	btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
 
 	virtual ~btConvexPlaneCollisionAlgorithm();
 
 	virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
-
-	void collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
 
 	virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
@@ -57,13 +53,4 @@
 	struct CreateFunc :public 	btCollisionAlgorithmCreateFunc
 	{
-		int	m_numPerturbationIterations;
-		int m_minimumPointsPerturbationThreshold;
-			
-		CreateFunc() 
-			: m_numPerturbationIterations(3),
-			m_minimumPointsPerturbationThreshold(3)
-		{
-		}
-		
 		virtual	btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
 		{
@@ -71,8 +58,8 @@
 			if (!m_swapped)
 			{
-				return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
+				return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false);
 			} else
 			{
-				return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
+				return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true);
 			}
 		}
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp	(revision 2908)
@@ -289,9 +289,2 @@
 	return m_emptyCreateFunc;
 }
-
-void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
-{
-	btConvexConvexAlgorithm::CreateFunc* convexConvex = (btConvexConvexAlgorithm::CreateFunc*) m_convexConvexCreateFunc;
-	convexConvex->m_numPerturbationIterations = numPerturbationIterations;
-	convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
-}
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h	(revision 2908)
@@ -112,12 +112,4 @@
 	virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
 
-	///Use this method to allow to generate multiple contact points between at once, between two objects using the generic convex-convex algorithm.
-	///By default, this feature is disabled for best performance.
-	///@param numPerturbationIterations controls the number of collision queries. Set it to zero to disable the feature.
-	///@param minimumPointsPerturbationThreshold is the minimum number of points in the contact cache, above which the feature is disabled
-	///3 is a good value for both params, if you want to enable the feature. This is because the default contact cache contains a maximum of 4 points, and one collision query at the unperturbed orientation is performed first.
-	///See Bullet/Demos/CollisionDemo for an example how this feature gathers multiple points.
-	///@todo we could add a per-object setting of those parameters, for level-of-detail collision detection.
-	void	setConvexConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold = 3);
 
 };
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btGhostObject.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btGhostObject.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btGhostObject.cpp	(revision 2908)
@@ -64,5 +64,4 @@
 btPairCachingGhostObject::~btPairCachingGhostObject()
 {
-	m_hashPairCache->~btHashedOverlappingPairCache();
 	btAlignedFree( m_hashPairCache );
 }
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp	(revision 2908)
@@ -56,5 +56,5 @@
 void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
 {
-	btAssert(m_manifoldPtr);
+	assert(m_manifoldPtr);
 	//order in manifold needs to match
 	
@@ -93,5 +93,5 @@
    newPt.m_index0  = m_index0;
    newPt.m_index1  = m_index1;
-	//printf("depth=%f\n",depth);
+	
 	///@todo, check this for any side effects
 	if (insertIndex >= 0)
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h	(revision 2908)
@@ -46,6 +46,4 @@
 	int m_index0;
 	int m_index1;
-	
-
 public:
 
@@ -80,5 +78,4 @@
 	}
 
-
 	virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp	(revision 2908)
@@ -25,6 +25,5 @@
 #include "LinearMath/btQuickprof.h"
 
-btSimulationIslandManager::btSimulationIslandManager():
-m_splitIslands(true)
+btSimulationIslandManager::btSimulationIslandManager()
 {
 }
@@ -45,8 +44,8 @@
 	
 	{
-		
+		btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
+
 		for (int i=0;i<colWorld->getPairCache()->getNumOverlappingPairs();i++)
 		{
-			btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
 			const btBroadphasePair& collisionPair = pairPtr[i];
 			btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
@@ -187,5 +186,5 @@
 			}
 
-			btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+			assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
 			if (colObj0->getIslandTag() == islandId)
 			{
@@ -214,5 +213,5 @@
 				}
 
-				btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+				assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
 
 				if (colObj0->getIslandTag() == islandId)
@@ -235,5 +234,5 @@
 				}
 
-				btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
+				assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
 
 				if (colObj0->getIslandTag() == islandId)
@@ -253,9 +252,9 @@
 	int maxNumManifolds = dispatcher->getNumManifolds();
 
-//#define SPLIT_ISLANDS 1
-//#ifdef SPLIT_ISLANDS
-
-	
-//#endif //SPLIT_ISLANDS
+#define SPLIT_ISLANDS 1
+#ifdef SPLIT_ISLANDS
+
+	
+#endif //SPLIT_ISLANDS
 
 	
@@ -281,10 +280,9 @@
 				colObj0->activate();
 			}
-			if(m_splitIslands)
-			{ 
-				//filtering for response
-				if (dispatcher->needsResponse(colObj0,colObj1))
-					m_islandmanifold.push_back(manifold);
-			}
+#ifdef SPLIT_ISLANDS
+	//		//filtering for response
+			if (dispatcher->needsResponse(colObj0,colObj1))
+				m_islandmanifold.push_back(manifold);
+#endif //SPLIT_ISLANDS
 		}
 	}
@@ -306,85 +304,83 @@
 	BT_PROFILE("processIslands");
 
-	if(!m_splitIslands)
-	{
-		btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
-		int maxNumManifolds = dispatcher->getNumManifolds();
-		callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
-	}
-	else
-	{
-		// Sort manifolds, based on islands
-		// Sort the vector using predicate and std::sort
-		//std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);
-
-		int numManifolds = int (m_islandmanifold.size());
-
-		//we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
-		m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());
-
-		//now process all active islands (sets of manifolds for now)
-
-		int startManifoldIndex = 0;
-		int endManifoldIndex = 1;
-
-		//int islandId;
-
-		
-
-	//	printf("Start Islands\n");
-
-		//traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
-		for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
-		{
-			int islandId = getUnionFind().getElement(startIslandIndex).m_id;
-
-
-			   bool islandSleeping = false;
-	                
-					for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
-					{
-							int i = getUnionFind().getElement(endIslandIndex).m_sz;
-							btCollisionObject* colObj0 = collisionObjects[i];
-							m_islandBodies.push_back(colObj0);
-							if (!colObj0->isActive())
-									islandSleeping = true;
-					}
-	                
-
-			//find the accompanying contact manifold for this islandId
-			int numIslandManifolds = 0;
-			btPersistentManifold** startManifold = 0;
-
-			if (startManifoldIndex<numManifolds)
-			{
-				int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
-				if (curIslandId == islandId)
-				{
-					startManifold = &m_islandmanifold[startManifoldIndex];
-				
-					for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
-					{
-
-					}
-					/// Process the actual simulation, only if not sleeping/deactivated
-					numIslandManifolds = endManifoldIndex-startManifoldIndex;
-				}
-
-			}
-
-			if (!islandSleeping)
-			{
-				callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
-	//			printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
-			}
+#ifndef SPLIT_ISLANDS
+	btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
+	
+	callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
+#else
+	// Sort manifolds, based on islands
+	// Sort the vector using predicate and std::sort
+	//std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);
+
+	int numManifolds = int (m_islandmanifold.size());
+
+	//we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
+	m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());
+
+	//now process all active islands (sets of manifolds for now)
+
+	int startManifoldIndex = 0;
+	int endManifoldIndex = 1;
+
+	//int islandId;
+
+	
+
+//	printf("Start Islands\n");
+
+	//traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
+	for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
+	{
+		int islandId = getUnionFind().getElement(startIslandIndex).m_id;
+
+
+	       bool islandSleeping = false;
+                
+                for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
+                {
+                        int i = getUnionFind().getElement(endIslandIndex).m_sz;
+                        btCollisionObject* colObj0 = collisionObjects[i];
+						m_islandBodies.push_back(colObj0);
+                        if (!colObj0->isActive())
+                                islandSleeping = true;
+                }
+                
+
+		//find the accompanying contact manifold for this islandId
+		int numIslandManifolds = 0;
+		btPersistentManifold** startManifold = 0;
+
+		if (startManifoldIndex<numManifolds)
+		{
+			int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
+			if (curIslandId == islandId)
+			{
+				startManifold = &m_islandmanifold[startManifoldIndex];
 			
-			if (numIslandManifolds)
-			{
-				startManifoldIndex = endManifoldIndex;
-			}
-
-			m_islandBodies.resize(0);
-		}
-	} // else if(!splitIslands) 
-
-}
+				for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
+				{
+
+				}
+				/// Process the actual simulation, only if not sleeping/deactivated
+				numIslandManifolds = endManifoldIndex-startManifoldIndex;
+			}
+
+		}
+
+		if (!islandSleeping)
+		{
+			callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
+//			printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
+		}
+		
+		if (numIslandManifolds)
+		{
+			startManifoldIndex = endManifoldIndex;
+		}
+
+		m_islandBodies.resize(0);
+	}
+#endif //SPLIT_ISLANDS
+
+
+}
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h	(revision 2908)
@@ -36,5 +36,4 @@
 	btAlignedObjectArray<btCollisionObject* >  m_islandBodies;
 	
-	bool m_splitIslands;
 	
 public:
@@ -67,13 +66,4 @@
 	void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld);
 
-	bool getSplitIslands()
-	{
-		return m_splitIslands;
-	}
-	void setSplitIslands(bool doSplitIslands)
-	{
-		m_splitIslands = doSplitIslands;
-	}
-
 };
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp	(revision 2908)
@@ -79,5 +79,5 @@
 
 	///point on A (worldspace)
-	///btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
+	btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
 	///point on B (worldspace)
 	btVector3 pos1 = col1->getWorldTransform().getOrigin() + radius1* normalOnSurfaceB;
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp	(revision 2908)
@@ -15,4 +15,6 @@
 
 #include "btUnionFind.h"
+#include <assert.h>
+
 
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h	(revision 2908)
@@ -99,6 +99,6 @@
 		int find(int x)
 		{ 
-			//btAssert(x < m_N);
-			//btAssert(x >= 0);
+			//assert(x < m_N);
+			//assert(x >= 0);
 
 			while (x != m_elements[x].m_id) 
@@ -111,6 +111,6 @@
 		#endif //
 				x = m_elements[x].m_id;
-				//btAssert(x < m_N);
-				//btAssert(x >= 0);
+				//assert(x < m_N);
+				//assert(x >= 0);
 
 			}
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h	(revision 2908)
@@ -162,23 +162,29 @@
 		{
 		case 0:
-			plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x());
+			plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
+			plane[3] = -halfExtents.x();
 			break;
 		case 1:
-			plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x());
+			plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
+			plane[3] = -halfExtents.x();
 			break;
 		case 2:
-			plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y());
+			plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
+			plane[3] = -halfExtents.y();
 			break;
 		case 3:
-			plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y());
+			plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
+			plane[3] = -halfExtents.y();
 			break;
 		case 4:
-			plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z());
+			plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
+			plane[3] = -halfExtents.z();
 			break;
 		case 5:
-			plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z());
+			plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
+			plane[3] = -halfExtents.z();
 			break;
 		default:
-			btAssert(0);
+			assert(0);
 		}
 	}
@@ -307,5 +313,5 @@
 			break;
 		default:
-			btAssert(0);
+			assert(0);
 		}
 	}
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp	(revision 2908)
@@ -15,7 +15,4 @@
 
 #include "BulletCollision/CollisionShapes/btCollisionShape.h"
-
-
-btScalar gContactThresholdFactor=btScalar(0.02);
 
 
@@ -48,5 +45,6 @@
 btScalar	btCollisionShape::getContactBreakingThreshold() const
 {
-	return getAngularMotionDisc() * gContactThresholdFactor;
+	///@todo make this 0.1 configurable
+	return getAngularMotionDisc() * btScalar(0.1);
 }
 btScalar	btCollisionShape::getAngularMotionDisc() const
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp	(revision 2908)
@@ -23,6 +23,5 @@
 m_collisionMargin(btScalar(0.)),
 m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
-m_dynamicAabbTree(0),
-m_updateRevision(1)
+m_dynamicAabbTree(0)
 {
 	m_shapeType = COMPOUND_SHAPE_PROXYTYPE;
@@ -48,5 +47,4 @@
 void	btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape)
 {
-	m_updateRevision++;
 	//m_childTransforms.push_back(localTransform);
 	//m_childShapes.push_back(shape);
@@ -57,5 +55,6 @@
 	child.m_childMargin = shape->getMargin();
 
-	
+	m_children.push_back(child);
+
 	//extend the local aabbMin/aabbMax
 	btVector3 localAabbMin,localAabbMax;
@@ -76,9 +75,7 @@
 	{
 		const btDbvtVolume	bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
-		int index = m_children.size();
+		int index = m_children.size()-1;
 		child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index);
 	}
-
-	m_children.push_back(child);
 
 }
@@ -103,5 +100,4 @@
 void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
 {
-	m_updateRevision++;
 	btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size());
 	if (m_dynamicAabbTree)
@@ -118,5 +114,4 @@
 void btCompoundShape::removeChildShape(btCollisionShape* shape)
 {
-	m_updateRevision++;
 	// Find the children containing the shape specified, and remove those children.
 	//note: there might be multiple children using the same shape!
@@ -145,5 +140,4 @@
 	// Recalculate the local aabb
 	// Brute force, it iterates over all the shapes left.
-
 	m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
 	m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
@@ -168,14 +162,6 @@
 {
 	btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
+	localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
 	btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
-	
-	//avoid an illegal AABB when there are no children
-	if (!m_children.size())
-	{
-		localHalfExtents.setValue(0,0,0);
-		localCenter.setValue(0,0,0);
-	}
-	localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
-		
 
 	btMatrix3x3 abs_b = trans.getBasis().absolute();  
@@ -188,5 +174,5 @@
 	aabbMin = center-extent;
 	aabbMax = center+extent;
-	
+
 }
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h	(revision 2908)
@@ -59,7 +59,4 @@
 
 	btDbvt*							m_dynamicAabbTree;
-
-	///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated
-	int								m_updateRevision;
 
 public:
@@ -156,8 +153,4 @@
 	void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const;
 
-	int	getUpdateRevision() const
-	{
-		return m_updateRevision;
-	}
 
 private:
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp	(revision 2908)
@@ -61,5 +61,5 @@
 		break;
 	default:
-		btAssert(0);
+		assert(0);
 	};
 }
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp	(revision 2908)
@@ -182,5 +182,5 @@
 bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
 {
-	btAssert(0);
+	assert(0);
 	return false;
 }
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp	(revision 2908)
@@ -151,5 +151,5 @@
 bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const
 {
-	btAssert(0);
+	assert(0);
 	return false;
 }
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp	(revision 2908)
@@ -155,4 +155,5 @@
 
 		btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
+		btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions();
 		btScalar halfHeight = capsuleShape->getHalfHeight();
 		int capsuleUpAxis = capsuleShape->getUpAxis();
@@ -301,6 +302,6 @@
 	{
 		btSphereShape* sphereShape = (btSphereShape*)this;
-		btScalar radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
-		btScalar margin = radius + sphereShape->getMarginNonVirtual();
+		float radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
+		float margin = radius + sphereShape->getMarginNonVirtual();
 		const btVector3& center = t.getOrigin();
 		btVector3 extent(margin,margin,margin);
@@ -314,5 +315,5 @@
 	{
 		btBoxShape* convexShape = (btBoxShape*)this;
-		btScalar margin=convexShape->getMarginNonVirtual();
+		float margin=convexShape->getMarginNonVirtual();
 		btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
 		halfExtents += btVector3(margin,margin,margin);
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp	(revision 2908)
@@ -145,10 +145,5 @@
 }
 
-
-/// This returns the "raw" (user's initial) height, not the actual height.
-/// The actual height needs to be adjusted to be relative to the center
-///   of the heightfield's AABB.
-btScalar
-btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const
+btScalar	btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const
 {
 	btScalar val = 0.f;
@@ -187,7 +182,8 @@
 
 
-/// this returns the vertex in bullet-local coordinates
+
 void	btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
 {
+
 	btAssert(x>=0);
 	btAssert(y>=0);
@@ -195,5 +191,6 @@
 	btAssert(y<m_heightStickLength);
 
-	btScalar	height = getRawHeightFieldValue(x,y);
+
+	btScalar	height = getHeightFieldValue(x,y);
 
 	switch (m_upAxis)
@@ -202,5 +199,5 @@
 		{
 		vertex.setValue(
-			height - m_localOrigin.getX(),
+			height,
 			(-m_width/btScalar(2.0)) + x,
 			(-m_length/btScalar(2.0) ) + y
@@ -212,5 +209,5 @@
 			vertex.setValue(
 			(-m_width/btScalar(2.0)) + x,
-			height - m_localOrigin.getY(),
+			height,
 			(-m_length/btScalar(2.0)) + y
 			);
@@ -222,5 +219,5 @@
 			(-m_width/btScalar(2.0)) + x,
 			(-m_length/btScalar(2.0)) + y,
-			height - m_localOrigin.getZ()
+			height
 			);
 			break;
@@ -234,4 +231,5 @@
 
 	vertex*=m_localScaling;
+	
 }
 
@@ -241,5 +239,5 @@
 getQuantized
 (
-btScalar x
+float x
 )
 {
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h	(revision 2908)
@@ -30,15 +30,4 @@
   center (as determined by width and length and height, with each
   axis multiplied by the localScaling).
-
-  \b NOTE: be careful with coordinates.  If you have a heightfield with a local
-  min height of -100m, and a max height of +500m, you may be tempted to place it
-  at the origin (0,0) and expect the heights in world coordinates to be
-  -100 to +500 meters.
-  Actually, the heights will be -300 to +300m, because bullet will re-center
-  the heightfield based on its AABB (which is determined by the min/max
-  heights).  So keep in mind that once you create a btHeightfieldTerrainShape
-  object, the heights will be adjusted relative to the center of the AABB.  This
-  is different to the behavior of many rendering engines, but is useful for
-  physics engines.
 
   Most (but not all) rendering and heightfield libraries assume upAxis = 1
@@ -100,5 +89,5 @@
 	btVector3	m_localScaling;
 
-	virtual btScalar	getRawHeightFieldValue(int x,int y) const;
+	virtual btScalar	getHeightFieldValue(int x,int y) const;
 	void		quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
 	void		getVertex(int x,int y,btVector3& vertex) const;
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp	(revision 2908)
@@ -29,6 +29,6 @@
 btVector3 btMinkowskiSumShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
 {
-	btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(vec*m_transA.getBasis()));
-	btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(-vec*m_transB.getBasis()));
+	btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(-vec*m_transA.getBasis()));
+	btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(vec*m_transB.getBasis()));
 	return  supVertexA - supVertexB;
 }
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h	(revision 2908)
@@ -32,10 +32,8 @@
 	BT_DECLARE_ALIGNED_ALLOCATOR();
 
-    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
+    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {}
     btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
         btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
         {
-            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
-
             btVector3 m_triangle[3];
             const unsigned char *vertexbase;
@@ -70,6 +68,4 @@
         btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
         {
-            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
-
             btVector3 m_triangle[3];
             const unsigned char *vertexbase;
@@ -112,4 +108,9 @@
 */
     }
+	virtual int	getShapeType() const
+	{
+		return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
+	}
+	
 	//debugging
 	virtual const char*	getName()const {return "MULTIMATERIALTRIANGLEMESH";}
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h	(revision 2908)
@@ -48,10 +48,4 @@
 	btScalar	getRadius() const { return m_implicitShapeDimensions.getX() * m_localScaling.getX();}
 
-	void	setUnscaledRadius(btScalar	radius)
-	{
-		m_implicitShapeDimensions.setX(radius);
-		btConvexInternalShape::setMargin(radius);
-	}
-
 	//debugging
 	virtual const char*	getName()const {return "SPHERE";}
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp	(revision 2908)
@@ -83,6 +83,5 @@
 }
 
-
-void	btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
+void	btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax )
 {
 	m_aabbMin = aabbMin;
@@ -97,3 +96,2 @@
 }
 
-
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h	(revision 2908)
@@ -53,7 +53,7 @@
 	IndexedMeshArray	m_indexedMeshes;
 	int m_pad[2];
-	mutable int m_hasAabb; // using int instead of bool to maintain alignment
-	mutable btVector3 m_aabbMin;
-	mutable btVector3 m_aabbMax;
+	int m_hasAabb; // using int instead of bool to maintain alignment
+	btVector3 m_aabbMin;
+	btVector3 m_aabbMax;
 
 public:
@@ -107,5 +107,5 @@
 
 	virtual bool	hasPremadeAabb() const;
-	virtual void	setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const;
+	virtual void	setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax );
 	virtual void	getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const;
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp	(revision 2908)
@@ -1,3 +1,2 @@
-
 /*
 Bullet Continuous Collision Detection and Physics Library
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp	(revision 2908)
@@ -36,5 +36,5 @@
 	{
 		m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
-		m_indexedMeshes[0].m_triangleIndexBase = 0;
+		m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
 		m_indexedMeshes[0].m_indexType = PHY_INTEGER;
 		m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
@@ -42,5 +42,5 @@
 	{
 		m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
-		m_indexedMeshes[0].m_triangleIndexBase = 0;
+		m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
 		m_indexedMeshes[0].m_indexType = PHY_SHORT;
 		m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
@@ -50,10 +50,10 @@
 	{
 		m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
-		m_indexedMeshes[0].m_vertexBase = 0;
+		m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
 		m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
 	} else
 	{
 		m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
-		m_indexedMeshes[0].m_vertexBase = 0;
+		m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
 		m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
 	}
@@ -112,7 +112,7 @@
 			}
 	}
-		m_3componentVertices.push_back((float)vertex.getX());
-		m_3componentVertices.push_back((float)vertex.getY());
-		m_3componentVertices.push_back((float)vertex.getZ());
+		m_3componentVertices.push_back(vertex.getX());
+		m_3componentVertices.push_back(vertex.getY());
+		m_3componentVertices.push_back(vertex.getZ());
 		m_indexedMeshes[0].m_numVertices++;
 		m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
Index: code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h	(revision 2908)
@@ -41,5 +41,5 @@
 	virtual btVector3	localGetSupportingVertexWithoutMargin(const btVector3& vec)const
 	{
-		btAssert(0);
+		assert(0);
 		return localGetSupportingVertex(vec);
 	}
Index: code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactBvh.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactBvh.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactBvh.cpp	(revision 2908)
@@ -151,5 +151,6 @@
 	}
 
-	btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex))));
+	bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
+	btAssert(!unbal);
 
 	return splitIndex;
Index: code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp	(revision 2908)
@@ -172,5 +172,6 @@
 	}
 
-	btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex))));
+	bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
+	btAssert(!unbal);
 
 	return splitIndex;
Index: code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactShape.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactShape.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactShape.h	(revision 2908)
@@ -882,6 +882,4 @@
 class btGImpactMeshShape : public btGImpactShapeInterface
 {
-	btStridingMeshInterface* m_meshInterface;
-
 protected:
 	btAlignedObjectArray<btGImpactMeshShapePart*> m_mesh_parts;
@@ -910,5 +908,4 @@
 	btGImpactMeshShape(btStridingMeshInterface * meshInterface)
 	{
-		m_meshInterface = meshInterface;
 		buildMeshParts(meshInterface);
 	}
@@ -926,13 +923,4 @@
 
 
-	btStridingMeshInterface* getMeshInterface()
-	{
-		return m_meshInterface;
-	}
-
-	const btStridingMeshInterface* getMeshInterface() const
-	{
-		return m_meshInterface;
-	}
 
 	int getMeshPartCount() const
@@ -1046,10 +1034,10 @@
 
 	//! call when reading child shapes
-	virtual void lockChildShapes() const
-	{
-		btAssert(0);
-	}
-
-	virtual void unlockChildShapes() const
+	virtual void lockChildShapes()
+	{
+		btAssert(0);
+	}
+
+	virtual void unlockChildShapes()
 	{
 		btAssert(0);
Index: code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_box_set.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_box_set.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_box_set.cpp	(revision 2908)
@@ -111,5 +111,6 @@
 	}
 
-	btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex))));
+	bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
+	btAssert(!unbal);
 
 	return splitIndex;
@@ -180,3 +181,2 @@
 }
 
-
Index: code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_math.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_math.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_math.h	(revision 2908)
@@ -108,5 +108,5 @@
 #define GIM_CLAMP(number,minval,maxval) (number<minval?minval:(number>maxval?maxval:number))
 
-#define GIM_GREATER(x, y)	btFabs(x) > (y)
+#define GIM_GREATER(x, y)	fabsf(x) > (y)
 
 ///Swap numbers
Index: code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_tri_collision.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_tri_collision.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_tri_collision.h	(revision 2908)
@@ -276,5 +276,5 @@
 		else
 		{
-			btScalar sumuv;
+			float sumuv;
 			sumuv = u+v;
 			if(sumuv<-G_EPSILON)
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp	(revision 2908)
@@ -136,7 +136,4 @@
 			//btScalar clippedDist  = dist;
 			
-			//don't report time of impact for motion away from the contact normal (or causes minor penetration)
-			if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=SIMD_EPSILON)
-				return false;
 			
 			dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
@@ -200,8 +197,9 @@
 
 		}
-	
+
+		//don't report time of impact for motion away from the contact normal (or causes minor penetration)
 		if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=result.m_allowedPenetration)//SIMD_EPSILON)
 			return false;
-			
+
 		result.m_fraction = lambda;
 		result.m_normal = n;
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp	(revision 2908)
@@ -151,6 +151,5 @@
 			if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) 
 			{
-				checkSimplex=true;
-				//checkPenetration = false;
+				checkPenetration = false;
 				break;
 			}
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h	(revision 2908)
@@ -113,10 +113,4 @@
 			}
 			
-			///this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver
-			btScalar	getAppliedImpulse() const
-			{
-				return m_appliedImpulse;
-			}
-
 			
 
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp	(revision 2908)
@@ -184,7 +184,4 @@
 		
 	}
-	if (insertIndex<0)
-		insertIndex=0;
-
 	btAssert(m_pointCache[insertIndex].m_userPersistentData==0);
 	m_pointCache[insertIndex] = newPoint;
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h	(revision 2908)
@@ -56,5 +56,4 @@
 
 	btScalar	m_contactBreakingThreshold;
-	btScalar	m_contactProcessingThreshold;
 
 	
@@ -72,8 +71,7 @@
 	btPersistentManifold();
 
-	btPersistentManifold(void* body0,void* body1,int , btScalar contactBreakingThreshold,btScalar contactProcessingThreshold)
+	btPersistentManifold(void* body0,void* body1,int , btScalar contactBreakingThreshold)
 		: m_body0(body0),m_body1(body1),m_cachedPoints(0),
-		m_contactBreakingThreshold(contactBreakingThreshold),
-		m_contactProcessingThreshold(contactProcessingThreshold)
+		m_contactBreakingThreshold(contactBreakingThreshold)
 	{
 		
@@ -114,9 +112,4 @@
 	///@todo: get this margin from the current physics / collision environment
 	btScalar	getContactBreakingThreshold() const;
-
-	btScalar	getContactProcessingThreshold() const
-	{
-		return m_contactProcessingThreshold;
-	}
 	
 	int getCacheEntry(const btManifoldPoint& newPoint) const;
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp	(revision 2908)
@@ -24,10 +24,8 @@
 #include "btRaycastCallback.h"
 
-btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to, unsigned int flags)
+btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to)
 	:
 	m_from(from),
 	m_to(to),
-   //@BP Mod
-   m_flags(flags),
 	m_hitFraction(btScalar(1.))
 {
@@ -58,10 +56,4 @@
 		return ; // same sign
 	}
-   //@BP Mod - Backface filtering
-   if (((m_flags & kF_FilterBackfaces) != 0) && (dist_a > btScalar(0.0)))
-   {
-      // Backface, skip check
-      return;
-   }
 	
 	const btScalar proj_length=dist_a-dist_b;
@@ -98,16 +90,12 @@
 					if ( (btScalar)(cp2.dot(triangleNormal)) >=edge_tolerance) 
 					{
-                  //@BP Mod
-                  // Triangle normal isn't normalized
-				      triangleNormal.normalize();
 
-                  //@BP Mod - Allow for unflipped normal when raycasting against backfaces
-                  if (((m_flags & kF_KeepUnflippedNormal) != 0) || (dist_a <= btScalar(0.0)))
+						if ( dist_a > 0 )
 						{
-							m_hitFraction = reportHit(-triangleNormal,distance,partId,triangleIndex);
+							m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex);
 						}
 						else
 						{
-                     m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex);
+							m_hitFraction = reportHit(-triangleNormal,distance,partId,triangleIndex);
 						}
 					}
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h	(revision 2908)
@@ -30,18 +30,7 @@
 	btVector3 m_to;
 
-   //@BP Mod - allow backface filtering and unflipped normals
-   enum EFlags
-   {
-      kF_None                 = 0,
-      kF_FilterBackfaces      = 1 << 0,
-      kF_KeepUnflippedNormal  = 1 << 1,   // Prevents returned face normal getting flipped when a ray hits a back-facing triangle
-
-      kF_Terminator        = 0xFFFFFFFF
-   };
-   unsigned int m_flags;
-
 	btScalar	m_hitFraction;
 
-	btTriangleRaycastCallback(const btVector3& from,const btVector3& to, unsigned int flags=0);
+	btTriangleRaycastCallback(const btVector3& from,const btVector3& to);
 	
 	virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
Index: code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp
===================================================================
--- code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp	(revision 2907)
+++ code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp	(revision 2908)
@@ -26,4 +26,6 @@
 
 #include "btVoronoiSimplexSolver.h"
+#include <assert.h>
+//#include <stdio.h>
 
 #define VERTA  0
@@ -36,5 +38,5 @@
 {
 	
-	btAssert(m_numVertices>0);
+	assert(m_numVertices>0);
 	m_numVertices--;
 	m_simplexVectorW[index] = m_simplexVectorW[m_numVertices];
