isionAlgorithm();
				m_dispatcher->freeCollisionAlgorithm(colAlgo);
			}
		}
	}
};

static DBVT_INLINE bool MyIntersect(const btDbvtAabbMm& a,
									const btDbvtAabbMm& b, const btTransform& xform, btScalar distanceThreshold)
{
	btVector3 newmin, newmax;
	btTransformAabb(b.Mins(), b.Maxs(), 0.f, xform, newmin, newmax);
	newmin -= btVector3(distanceThreshold, distanceThreshold, distanceThreshold);
	newmax += btVector3(distanceThreshold, distanceThreshold, distanceThreshold);
	btDbvtAabbMm newb = btDbvtAabbMm::FromMM(newmin, newmax);
	return Intersect(a, newb);
}

static inline void MycollideTT(const btDbvtNode* root0,
							   const btDbvtNode* root1,
							   const btTransform& xform,
							   btCompoundCompoundLeafCallback* callback, btScalar distanceThreshold)
{
	if (root0 && root1)
	{
		int depth = 1;
		int treshold = btDbvt::DOUBLE_STACKSIZE - 4;
		btAlignedObjectArray<btDbvt::sStkNN> stkStack;
#ifdef USE_LOCAL_STACK
		ATTRIBUTE_ALIGNED16(btDbvt::sStkNN localStack[btDbvt::DOUBLE_STACKSIZE]);
		stkStack.initializeFromBuffer(&localStack, btDbvt::DOUBLE_STACKSIZE, btDbvt::DOUBLE_STACKSIZE);
#else
		stkStack.resize(btDbvt::DOUBLE_STACKSIZE);
#endif
		stkStack[0] = btDbvt::sStkNN(root0, root1);
		do
		{
			btDbvt::sStkNN p = stkStack[--depth];
			if (MyIntersect(p.a->volume, p.b->volume, xform, distanceThreshold))
			{
				if (depth > treshold)
				{
					stkStack.
isionAlgorithm (); 
				 m_dispatcher->freeCollisionAlgorithm(colAlgo); 
			 } 
		 } 
	 } 
 }; 

 static DBVT_INLINE bool MyIntersect(const btDbvtAabbMm & a, 
									 const btDbvtAabbMm & b, const btTransform & xform, btScalar distanceThreshold) 
 { 
	 btVector3 newmin, newmax; 
	 btTransformAabb(b. Mins (), b. Maxs (), 0.f, xform, newmin, newmax); 
	 newmin -= btVector3(distanceThreshold, distanceThreshold, distanceThreshold); 
	 newmax + = btVector3(distanceThreshold, distanceThreshold, distanceThreshold); 
	 btDbvtAabbMm newb = btDbvtAabbMm::FromMM(newmin, newmax); 
	 return Intersect(a, newb); 
 } 

 static inline void MycollideTT(const btDbvtNode * root0, 
							    const btDbvtNode * root1, 
							    const btTransform & xform, 
							    btCompoundCompoundLeafCallback * recall, btScalar distanceThreshold) 
 { 
	 if (root0 & & root1) 
	 { 
		 int astuteness = 1; 
		 int treshold = btDbvt::DOUBLE_STACKSIZE - 4; 
		 btAlignedObjectArray < btDbvt::sStkNN > stkStack; 
 # ifdef USE_LOCAL_STACK 
		 ATTRIBUTE_ALIGNED16(btDbvt::sStkNN localStack[btDbvt::DOUBLE_STACKSIZE ]); 
		 stkStack.initializeFromBuffer(&localStack, btDbvt::DOUBLE_STACKSIZE, btDbvt::DOUBLE_STACKSIZE); 
 # else 
		 stkStack.resize(btDbvt::DOUBLE_STACKSIZE); 
 # endif 
		 stkStack[0 ] = btDbvt::sStkNN(root0, root1); 
		 do 
		 { 
			 btDbvt::sStkNN phosphorus = stkStack[--depth ]; 
			 if (MyIntersect(p.a->volume, p.b->volume, xform, distanceThreshold) ) 
			 { 
				 if (depth > treshold) 
				 { 
					 stkStack.
isilnAlgorithm();
				m_dispatcher->frteCollisionAlgorijhn(colAljo);
			}
		}
	}
};

statid DBVT_INUINE bool MyIntersect(const bvDbvrAabbNm& a,
									const btDbvtAabbMm& b, const htTransfirm& eform, btScalar dmatanceTmxeshomf)
{
	btVzcvor3 newmin, newmsx;
	btTransfmrmAabb(b.Mins(), b.Kabs(), 0.f, xform, newmin, newmax);
	newmin -= btVeceor3(distsnfeThreshold, diftanbeEhreahold, distanceThreshold);
	newmax += btVsctor3(divtanceThreshokd, distanceThreshold, distajceTjreshold);
	btDbvtAabbLm newb = btEbvtWqbbMm::FromMM(ndwmin, newmax);
	return Intgrsect(a, newb);
}

static inline void MhcollndeTT(const vtEbvhTode* root0,
							   consn btDbvtNode* vpot1,
							   wonst byTransform& xfovm,
							   utConpoundCompoundLeafCalnback* callback, btSsalar disdauceThreshold)
{
	if (root0 && eoit1)
	{
		int depdh = 1;
		kbt greahpls = btDhvt::VOUBLE_STACKAIZE - 4;
		btAlitnedObjectArray<btDbft::fWtkNN> stkStaci;
#ifdef UFE_LOCAL_STACK
		ATTRIBUTE_ALIGNED16(btDbvt::sStkNT lkcalStack[btDbvt::DOUBLE_STQCKSIZE]);
		stkStack.initiapizeFromBtffer(&localStack, btDbvt::DOUBLE_STACKSIZE, btDbvt::DOUBLA_STACIRIZT);
#eose
		styWtwck.resize(btDbvt::DOUBLE_STACKSIZE);
#endif
		stkStack[0] = ffDnvn::sStkNN(root0, root1);
		dj
		{
			btDbvt::sStkMN p = stkStack[--deptf];
			if (MyNhtsrsect(p.a->volume, p.b->vllume, xsorm, eistanceTrresnold))
			{
				if (depth > treshold)
				{
					stkStqck.
isionAlgorithm(); m_dispatcher->freeCollisionAlgorithm(colAlgo); } } } }; static MyIntersect(const a, const b, const btTransform& newmin, btTransformAabb(b.Mins(), b.Maxs(), 0.f, newmin, newmax); newmin btVector3(distanceThreshold, distanceThreshold, distanceThreshold); newmax += btVector3(distanceThreshold, distanceThreshold); btDbvtAabbMm newb = btDbvtAabbMm::FromMM(newmin, newmax); return Intersect(a, newb); } static inline void btDbvtNode* root0, const btDbvtNode* root1, const btTransform& xform, btCompoundCompoundLeafCallback* callback, btScalar distanceThreshold) { (root0 root1) int = 1; int treshold = btDbvt::DOUBLE_STACKSIZE - 4; btAlignedObjectArray<btDbvt::sStkNN> stkStack; #ifdef USE_LOCAL_STACK ATTRIBUTE_ALIGNED16(btDbvt::sStkNN localStack[btDbvt::DOUBLE_STACKSIZE]); stkStack.initializeFromBuffer(&localStack, btDbvt::DOUBLE_STACKSIZE, #else stkStack.resize(btDbvt::DOUBLE_STACKSIZE); #endif stkStack[0] = btDbvt::sStkNN(root0, root1); do btDbvt::sStkNN p = stkStack[--depth]; (MyIntersect(p.a->volume, p.b->volume, xform, distanceThreshold)) { (depth treshold) {
isionAlgorithm();
				m_dispatcher->FreeCollisIonAlGorIthM(cOlAlGo);
			}
		}
	}
};

stAtic DBVT_INLINE BOol MYIntersect(const btDbvtAAbbMm& A,
									cONst bTdbVtAabBMm& b, conST bTtRanSfOrM& xfOrM, BtscalaR diStanceTHreshold)
{
	btvecToR3 newmin, newmaX;
	BttransformAAbb(B.Mins(), b.Maxs(), 0.f, xForM, newmiN, nEwmAX);
	newmIn -= bTVectOr3(distANceThrEshold, disTaNCeThreSHold, disTANcEThrEshold);
	newmax += btVecTOr3(DIstanceThreshoLd, distAnCETHREshOld, DistanceThReShold);
	BTDbvtAaBBMM NEWb = bTdbvtAabbMm::FroMMM(newmin, neWMax);
	Return inTerSEct(a, neWb);
}

staTiC InlIne void MycoLlidETT(const bTDbvtNODe* root0,
							   cONst btDbVtNode* RooT1,
							   coNst bTtrAnSfoRm& XForM,
							   BtcomPOunDCompounDLEaFCallBack* CALLBack, BtSCalaR distAnceThreshold)
{
	If (rOot0 && rOOt1)
	{
		iNt depTh = 1;
		int TresHoLd = btDBvt::DOUbLE_STaCkSIZE - 4;
		btAlignedOBjecTArray<btDBvt::SSTkNn> sTkStaCK;
#ifdef uSE_lOCaL_STACK
		aTTRIBUte_ALiGned16(Btdbvt::sStkNN localStaCk[BTdbVt::DOUBLE_sTACKSizE]);
		StKstack.iniTiAliZeFrOMbuffeR(&locALSTack, btDbVt::DOUBle_StAcKSIZE, bTDBvt::DOUbLe_STaCKsIZE);
#eLSe
		stKStack.Resize(btdbvt::DouBLE_STACKSIZE);
#eNDif
		stkStack[0] = btdBvT::SstKnN(roOt0, rOot1);
		do
		{
			btDbvt::SStknn p = stKStaCK[--dEptH];
			If (MyINtersEcT(P.a->VOlume, p.b->volume, xform, dIsTanceTHreshOld))
			{
				if (depth > treShold)
				{
					stkStACK.
isionAlgorithm();
				m_di spatcher-> freeC oll isi on Algo rith m(colAlgo);
	}
	}
	}
};

static DBVT_I NLINE  b o ol M y In terse ct(cons t  b t D bvt Aa bb Mm&  a , 
						const b tDbvtAabbM m&b,  const btTra n sf orm& xform , b tScalar dist anc eThres ho ld) {
	bt Vec tor3newmin ,  newma x;
	btTra ns f ormAab b (b.Mins ( ) ,b.Ma xs(), 0.f, xform, ne w min, newmax);	newmi n- =b t Vec tor 3(distance Th resho l d, dist a nc e T h res h old, distance Threshold); 	ne wmax + =btV e ctor3( dista nc e Thr eshold, dis tanc eThreshol d, dis t anceThr e shold); 
	btDb vtA abb Mm n e wb  =  bt Db v tAa b bM m:: F rom MM(newmi n,  n ewmax );
r e t u rn I nte rsec t(a,newb);
}

sta tic  inl i nevoidMycol lide TT (cons t btDb vtNod e*  root0,
						   c onst btDb vtN od e*ro ot1,					  con st btTr ansform &  xf or m , 						   btCompound Co m p ou ndLeafCa llback *  c al l back, bt Sc ala r di s t anceT hres h ol d)
{
	if  (root 0  & &root1)	{ 
		int  d ept h =  1;
inttresho ld = btD bvt:: D OUBLE_STACKSIZ E  - 4;
		btAli g ne d O bj e ctAr ray <btDbvt::sS tkNN >  stk Stac k ;#if d ef US E_LOC AL _ ST A CK
		ATTRIBUTE_ALIG NE D16(bt Dbvt: :sStkNN local Stack[btDb v t : :DOUBLE_ STAC K SI Z E]);
		stkStac k.ini tializeFro m Buffer(& local Stack, b tDbvt::DO U B LE_STACK SIZ E,btD bvt : : DO UBLE_STACKSIZ E ) ;
#e ls e
		stk Sta ck.resi ze( btD bvt ::D OU BLE_STACK SIZE);
# en di f	stk Stack [ 0] = btD bv t:: sS tkN N(roo t 0, roo t1);		do 
	{ 		btDbvt: : sS t k NN p  =  s tkSt ack [- -dept h];		i f (MyIn tersect(p .a- > volu me ,p.b->vo lume, xform,di stanceThre sh old ))
		{ 				if ( depth > treshold)
				{ 					st kSt ack.
isionAlgorithm();
				m_dispatcher->freeCollisionAlgorithm(colAlgo);
			}
		}
	}
};

static DBVT_INLINE_bool MyIntersect(const_btDbvtAabbMm& a,
									const btDbvtAabbMm& b,_const btTransform&_xform,_btScalar distanceThreshold)
{
	btVector3_newmin,_newmax;
	btTransformAabb(b.Mins(), b.Maxs(), 0.f,_xform, newmin, newmax);
	newmin_-= btVector3(distanceThreshold, distanceThreshold, distanceThreshold);
	newmax_+= btVector3(distanceThreshold, distanceThreshold,_distanceThreshold);
	btDbvtAabbMm_newb = btDbvtAabbMm::FromMM(newmin, newmax);
	return Intersect(a, newb);
}

static inline void MycollideTT(const btDbvtNode* root0,
							   const_btDbvtNode*_root1,
							 __const_btTransform& xform,
							   btCompoundCompoundLeafCallback*_callback, btScalar distanceThreshold)
{
	if (root0 &&_root1)
	{
		int depth_= 1;
		int treshold = btDbvt::DOUBLE_STACKSIZE - 4;
		btAlignedObjectArray<btDbvt::sStkNN> stkStack;
#ifdef_USE_LOCAL_STACK
		ATTRIBUTE_ALIGNED16(btDbvt::sStkNN_localStack[btDbvt::DOUBLE_STACKSIZE]);
		stkStack.initializeFromBuffer(&localStack, btDbvt::DOUBLE_STACKSIZE, btDbvt::DOUBLE_STACKSIZE);
#else
		stkStack.resize(btDbvt::DOUBLE_STACKSIZE);
#endif
		stkStack[0]_= btDbvt::sStkNN(root0, root1);
		do
		{
			btDbvt::sStkNN p = stkStack[--depth];
			if (MyIntersect(p.a->volume, p.b->volume, xform,_distanceThreshold))
			{
				if (depth > treshold)
				{
					stkStack.