private void GetClosestPointCandidatesImpl(Vector3 scale, Pose pose, ISupportClosestPointQueries<T> otherPartition, Vector3 otherScale, Pose otherPose, Func<T, T, float> callback)
    {
      // Test leaf nodes against other partition.

      // Use a wrapper for the callback to reduce the parameters from Func<T, T, float> to 
      // Func<T, float>.
      ClosestPointCallbackWrapper<T> callbackWrapper = ClosestPointCallbackWrapper<T>.Create();
      callbackWrapper.OriginalCallback = callback;

      // Prepare transformation to transform leaf AABBs into local space of other partition.
      Pose toOther = otherPose.Inverse * pose;
      Vector3 otherScaleInverse = Vector3.One / otherScale;

      float closestPointDistanceSquared = float.PositiveInfinity;
      foreach (var leaf in _leaves.Values)
      {
        callbackWrapper.Item = leaf.Item;

        // Transform AABB into local space of other partition.
        Aabb aabb = leaf.Aabb.GetAabb(scale, toOther);
        aabb.Scale(otherScaleInverse);

        closestPointDistanceSquared = otherPartition.GetClosestPointCandidates(aabb, closestPointDistanceSquared, callbackWrapper.Callback);
        if (closestPointDistanceSquared < 0)
        {
          // closestPointDistanceSquared == -1 indicates early exit.
          break;
        }
      }

      callbackWrapper.Recycle();
    }
        private void GetClosestPointCandidatesImpl(Vector3F scale, Pose pose, ISupportClosestPointQueries<int> otherPartition, Vector3F otherScale, Pose otherPose, Func<int, int, float> callback)
        {
            // Test leaf nodes against other partition.

              // Use a wrapper for the callback to reduce the parameters from Func<T, T, float> to
              // Func<T, float>.
              ClosestPointCallbackWrapper<int> callbackWrapper = ClosestPointCallbackWrapper<int>.Create();
              callbackWrapper.OriginalCallback = callback;

              // Prepare transformation to transform leaf AABBs into local space of other partition.
              Pose toOther = otherPose.Inverse * pose;
              Vector3F otherScaleInverse = Vector3F.One / otherScale;

              float closestPointDistanceSquared = float.PositiveInfinity;
              foreach (Node node in _nodes)
              {
            if (node.IsLeaf)
            {
              callbackWrapper.Item = node.Item;

              // Transform AABB into local space of other partition.
              Aabb aabb = GetAabb(node).GetAabb(scale, toOther);
              aabb.Scale(otherScaleInverse);

              closestPointDistanceSquared = otherPartition.GetClosestPointCandidates(aabb, closestPointDistanceSquared, callbackWrapper.Callback);
              if (closestPointDistanceSquared < 0)
              {
            // closestPointDistanceSquared == -1 indicates early exit.
            break;
              }
            }
              }

              callbackWrapper.Recycle();
        }