private bool _CapsuleTraceBrush(CollisioinTreeNode pNode, CapsuleTraceBrushInfo pInfo) { if (null == pNode || null == pInfo) { return(false); } if (!BoundsExtansions.AABBAABBOverlap(pNode.AABB, pInfo.Bound)) { return(false); } bool bCollide = false; bool bStartSolid = false; CDBrush HitObject = null; CollidePoints HitPoints = new CollidePoints(); Vector3 normal = Vector3.zero; float fFraction = 100.0f; if (pNode.IsLeaf()) { int i; for (i = 0; i < (int)pNode.LstCDBrush.Count; ++i) { CDBrush pBrush = pNode.LstCDBrush[i]; if (pBrush.CapsuleTraceBrush(pInfo) && (pInfo.Fraction < fFraction)) { //update the saving info bStartSolid = pInfo.StartSolid; fFraction = pInfo.Fraction; HitObject = pInfo.HitObject; HitPoints = pInfo.HitPoints; normal = pInfo.Normal; bCollide = true; //if (pInfo.Fraction == 0.0f) //{ // break; //} } } } else { for (int j = 0; j < 8; j++) { if (_CapsuleTraceBrush(pNode.Children[j], pInfo) && pInfo.Fraction < fFraction) { bStartSolid = pInfo.StartSolid; fFraction = pInfo.Fraction; HitObject = pInfo.HitObject; HitPoints = pInfo.HitPoints; normal = pInfo.Normal; bCollide = true; //if (pInfo.Fraction == 0.0f) //{ // break; //} } } } if (bCollide) { //set back pInfo.StartSolid = bStartSolid; pInfo.Fraction = fFraction; pInfo.HitObject = HitObject; pInfo.HitPoints = HitPoints; pInfo.Normal = normal; } return(bCollide); }