public static bool Intersects(ref PartFromPrefab partA, ref MatrixI transformA, ref MatrixI invTransformA, ref PartFromPrefab partB, ref MatrixI transformB, ref MatrixI invTransformB, bool testOptional, bool testQuick = false) { var cheapResult = IntersectsInternalCheap(ref partA, ref transformA, ref invTransformA, ref partB, ref transformB, ref invTransformB, testOptional); switch (cheapResult) { case CheapIntersection.Yes: return(true); case CheapIntersection.No: return(false); case CheapIntersection.Maybe: default: break; } if (testQuick) { return(true); } MatrixI abTransform; MatrixI.Multiply(ref transformA, ref invTransformB, out abTransform); var key = new IntersectKey(partA, partB, abTransform, testOptional); bool result; // ReSharper disable once ConvertIfStatementToReturnStatement // TODO when threading cause a wait when another thread is preparing this cache value? if (IntersectionCache.TryGet(key, out result)) { return(result); } return(IntersectionCache.Store(key, IntersectsInternalExpensive(ref partA, ref transformA, ref invTransformA, ref partB, ref transformB, ref invTransformB, testOptional))); }
public bool Equals(IntersectKey other) { return(m_testOptional == other.m_testOptional && m_partA == other.m_partA && m_partB == other.m_partB && m_transformAB.Equals(other.m_transformAB)); }