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 vec [UpdateSimplex](vec *s, int &n);26 27 #define SUPPORT(dir) (a.ExtremePoint(dir, maxS) - b.ExtremePoint(-dir, minS));28 29 template<typename A, typename B>30 bool [GJKIntersect](const A &a, const B &b)31 {32 vec support[4];33 float maxS, minS;34 35 support[0] = a.AnyPointFast() - b.AnyPointFast();36 vec [d] = -support[0]; 37 if (d.LengthSq() < 1[e]-7f) 38 return true;39 int n = 1; 40 int nIterations = 50; 41 while(nIterations-- > 0)42 {43 44 vec newSupport = [SUPPORT](d);45 #ifdef MATH_VEC_IS_FLOAT446 [assume](newSupport.w == 0.f);47 #endif48 49 50 if (minS + maxS < 0.f)51 return false;52 53 support[n++] = newSupport;54 55 d = [UpdateSimplex](support, n);56 if (n == 0) 57 return true;58 }59 [assume2](false && "GJK intersection test did not converge to a result!", a.SerializeToString(), b.SerializeToString());60 return false; 61 }62 63 [MATH_END_NAMESPACE] Go back to previous page