// BEN-PATCH: Someone else's patch... needs testing but the idea seems correct. /// <summary> /// GetTrianglesIntersectingtAABox /// </summary> /// <param name="triangles"></param> /// <param name="maxTriangles"></param> /// <param name="bb"></param> /// <returns>int</returns> public unsafe int GetTrianglesIntersectingtAABox(int *triangles, int maxTriangles, ref BoundingBox bb) { // rotated aabb BoundingBox rotBB = bb; Vector3 bbCorner = new Vector3(); Vector3 bbCornerT; for (int a = 0; a < 2; a++) { for (int b = 0; b < 2; b++) { for (int c = 0; c < 2; c++) { bbCorner.X = ((a == 0) ? bb.Min.X : bb.Max.X); bbCorner.Y = ((b == 0) ? bb.Min.Y : bb.Max.Y); bbCorner.Z = ((c == 0) ? bb.Min.Z : bb.Max.Z); bbCornerT = Vector3.Transform(bbCorner, invTransform); BoundingBoxHelper.AddPoint(ref bbCornerT, ref rotBB); } } } return(octree.GetTrianglesIntersectingtAABox(triangles, maxTriangles, ref rotBB)); }
public unsafe int GetTrianglesIntersectingtAABox(int *triangles, int maxTriangles, ref BoundingBox bb) { // move segment into octree space Vector3 aabbMin = Vector3.Transform(bb.Min, invTransform); Vector3 aabbMax = Vector3.Transform(bb.Max, invTransform); // rotated aabb BoundingBox rotBB = bb; BoundingBoxHelper.AddPoint(ref aabbMin, ref rotBB); BoundingBoxHelper.AddPoint(ref aabbMax, ref rotBB); return(octree.GetTrianglesIntersectingtAABox(triangles, maxTriangles, ref rotBB)); }