1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #pragma once19 20 #include "../MathGeoLibFwd.h"21 #include "../Math/float3.h"22 23 [MATH_BEGIN_NAMESPACE]24 25 template<typename A, typename B>26 bool [SATIntersect](const A &a, const B &b)27 {28 vec normals[16];29 int n = a.UniqueFaceNormals(normals);30 [assert](n <= 16); 31 for(int i = 0; i < n; ++i)32 {33 float amin, amax, bmin, bmax;34 a.ProjectToAxis(normals[i], amin, amax);35 b.ProjectToAxis(normals[i], bmin, bmax);36 if (amax < bmin || bmax < amin)37 return false;38 }39 n = b.UniqueFaceNormals(normals);40 [assert](n <= 16); 41 for(int i = 0; i < n; ++i)42 {43 float amin, amax, bmin, bmax;44 a.ProjectToAxis(normals[i], amin, amax);45 b.ProjectToAxis(normals[i], bmin, bmax);46 if (amax < bmin || bmax < amin)47 return false;48 }49 vec normals2[16];50 n = a.UniqueEdgeDirections(normals);51 int m = b.UniqueEdgeDirections(normals2);52 for(int i = 0; i < n; ++i)53 for(int j = 0; j < m; ++j)54 {55 float amin, amax, bmin, bmax;56 vec normal = [Cross](normals[i], normals2[j]);57 a.ProjectToAxis(normal, amin, amax);58 b.ProjectToAxis(normal, bmin, bmax);59 if (amax < bmin || bmax < amin)60 return false;61 }62 return true;63 }64 65 [MATH_END_NAMESPACE] Go back to previous page