b3VoronoiSimplexSolver.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. Elsevier CDROM license agreements grants nonexclusive license to use the software
  13. for any purpose, commercial or non-commercial as long as the following credit is included
  14. identifying the original source of the software:
  15. Parts of the source are "from the book Real-Time Collision Detection by
  16. Christer Ericson, published by Morgan Kaufmann Publishers,
  17. (c) 2005 Elsevier Inc."
  18. */
  19. #include "b3VoronoiSimplexSolver.h"
  20. #define VERTA 0
  21. #define VERTB 1
  22. #define VERTC 2
  23. #define VERTD 3
  24. #define B3_CATCH_DEGENERATE_TETRAHEDRON 1
  25. void b3VoronoiSimplexSolver::removeVertex(int index)
  26. {
  27. b3Assert(m_numVertices > 0);
  28. m_numVertices--;
  29. m_simplexVectorW[index] = m_simplexVectorW[m_numVertices];
  30. m_simplexPointsP[index] = m_simplexPointsP[m_numVertices];
  31. m_simplexPointsQ[index] = m_simplexPointsQ[m_numVertices];
  32. }
  33. void b3VoronoiSimplexSolver::reduceVertices(const b3UsageBitfield& usedVerts)
  34. {
  35. if ((numVertices() >= 4) && (!usedVerts.usedVertexD))
  36. removeVertex(3);
  37. if ((numVertices() >= 3) && (!usedVerts.usedVertexC))
  38. removeVertex(2);
  39. if ((numVertices() >= 2) && (!usedVerts.usedVertexB))
  40. removeVertex(1);
  41. if ((numVertices() >= 1) && (!usedVerts.usedVertexA))
  42. removeVertex(0);
  43. }
  44. //clear the simplex, remove all the vertices
  45. void b3VoronoiSimplexSolver::reset()
  46. {
  47. m_cachedValidClosest = false;
  48. m_numVertices = 0;
  49. m_needsUpdate = true;
  50. m_lastW = b3MakeVector3(b3Scalar(B3_LARGE_FLOAT), b3Scalar(B3_LARGE_FLOAT), b3Scalar(B3_LARGE_FLOAT));
  51. m_cachedBC.reset();
  52. }
  53. //add a vertex
  54. void b3VoronoiSimplexSolver::addVertex(const b3Vector3& w, const b3Vector3& p, const b3Vector3& q)
  55. {
  56. m_lastW = w;
  57. m_needsUpdate = true;
  58. m_simplexVectorW[m_numVertices] = w;
  59. m_simplexPointsP[m_numVertices] = p;
  60. m_simplexPointsQ[m_numVertices] = q;
  61. m_numVertices++;
  62. }
  63. bool b3VoronoiSimplexSolver::updateClosestVectorAndPoints()
  64. {
  65. if (m_needsUpdate)
  66. {
  67. m_cachedBC.reset();
  68. m_needsUpdate = false;
  69. switch (numVertices())
  70. {
  71. case 0:
  72. m_cachedValidClosest = false;
  73. break;
  74. case 1:
  75. {
  76. m_cachedP1 = m_simplexPointsP[0];
  77. m_cachedP2 = m_simplexPointsQ[0];
  78. m_cachedV = m_cachedP1 - m_cachedP2; //== m_simplexVectorW[0]
  79. m_cachedBC.reset();
  80. m_cachedBC.setBarycentricCoordinates(b3Scalar(1.), b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
  81. m_cachedValidClosest = m_cachedBC.isValid();
  82. break;
  83. };
  84. case 2:
  85. {
  86. //closest point origin from line segment
  87. const b3Vector3& from = m_simplexVectorW[0];
  88. const b3Vector3& to = m_simplexVectorW[1];
  89. b3Vector3 nearest;
  90. b3Vector3 p = b3MakeVector3(b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
  91. b3Vector3 diff = p - from;
  92. b3Vector3 v = to - from;
  93. b3Scalar t = v.dot(diff);
  94. if (t > 0)
  95. {
  96. b3Scalar dotVV = v.dot(v);
  97. if (t < dotVV)
  98. {
  99. t /= dotVV;
  100. diff -= t * v;
  101. m_cachedBC.m_usedVertices.usedVertexA = true;
  102. m_cachedBC.m_usedVertices.usedVertexB = true;
  103. }
  104. else
  105. {
  106. t = 1;
  107. diff -= v;
  108. //reduce to 1 point
  109. m_cachedBC.m_usedVertices.usedVertexB = true;
  110. }
  111. }
  112. else
  113. {
  114. t = 0;
  115. //reduce to 1 point
  116. m_cachedBC.m_usedVertices.usedVertexA = true;
  117. }
  118. m_cachedBC.setBarycentricCoordinates(1 - t, t);
  119. nearest = from + t * v;
  120. m_cachedP1 = m_simplexPointsP[0] + t * (m_simplexPointsP[1] - m_simplexPointsP[0]);
  121. m_cachedP2 = m_simplexPointsQ[0] + t * (m_simplexPointsQ[1] - m_simplexPointsQ[0]);
  122. m_cachedV = m_cachedP1 - m_cachedP2;
  123. reduceVertices(m_cachedBC.m_usedVertices);
  124. m_cachedValidClosest = m_cachedBC.isValid();
  125. break;
  126. }
  127. case 3:
  128. {
  129. //closest point origin from triangle
  130. b3Vector3 p = b3MakeVector3(b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
  131. const b3Vector3& a = m_simplexVectorW[0];
  132. const b3Vector3& b = m_simplexVectorW[1];
  133. const b3Vector3& c = m_simplexVectorW[2];
  134. closestPtPointTriangle(p, a, b, c, m_cachedBC);
  135. m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] +
  136. m_simplexPointsP[1] * m_cachedBC.m_barycentricCoords[1] +
  137. m_simplexPointsP[2] * m_cachedBC.m_barycentricCoords[2];
  138. m_cachedP2 = m_simplexPointsQ[0] * m_cachedBC.m_barycentricCoords[0] +
  139. m_simplexPointsQ[1] * m_cachedBC.m_barycentricCoords[1] +
  140. m_simplexPointsQ[2] * m_cachedBC.m_barycentricCoords[2];
  141. m_cachedV = m_cachedP1 - m_cachedP2;
  142. reduceVertices(m_cachedBC.m_usedVertices);
  143. m_cachedValidClosest = m_cachedBC.isValid();
  144. break;
  145. }
  146. case 4:
  147. {
  148. b3Vector3 p = b3MakeVector3(b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
  149. const b3Vector3& a = m_simplexVectorW[0];
  150. const b3Vector3& b = m_simplexVectorW[1];
  151. const b3Vector3& c = m_simplexVectorW[2];
  152. const b3Vector3& d = m_simplexVectorW[3];
  153. bool hasSeparation = closestPtPointTetrahedron(p, a, b, c, d, m_cachedBC);
  154. if (hasSeparation)
  155. {
  156. m_cachedP1 = m_simplexPointsP[0] * m_cachedBC.m_barycentricCoords[0] +
  157. m_simplexPointsP[1] * m_cachedBC.m_barycentricCoords[1] +
  158. m_simplexPointsP[2] * m_cachedBC.m_barycentricCoords[2] +
  159. m_simplexPointsP[3] * m_cachedBC.m_barycentricCoords[3];
  160. m_cachedP2 = m_simplexPointsQ[0] * m_cachedBC.m_barycentricCoords[0] +
  161. m_simplexPointsQ[1] * m_cachedBC.m_barycentricCoords[1] +
  162. m_simplexPointsQ[2] * m_cachedBC.m_barycentricCoords[2] +
  163. m_simplexPointsQ[3] * m_cachedBC.m_barycentricCoords[3];
  164. m_cachedV = m_cachedP1 - m_cachedP2;
  165. reduceVertices(m_cachedBC.m_usedVertices);
  166. }
  167. else
  168. {
  169. // printf("sub distance got penetration\n");
  170. if (m_cachedBC.m_degenerate)
  171. {
  172. m_cachedValidClosest = false;
  173. }
  174. else
  175. {
  176. m_cachedValidClosest = true;
  177. //degenerate case == false, penetration = true + zero
  178. m_cachedV.setValue(b3Scalar(0.), b3Scalar(0.), b3Scalar(0.));
  179. }
  180. break;
  181. }
  182. m_cachedValidClosest = m_cachedBC.isValid();
  183. //closest point origin from tetrahedron
  184. break;
  185. }
  186. default:
  187. {
  188. m_cachedValidClosest = false;
  189. }
  190. };
  191. }
  192. return m_cachedValidClosest;
  193. }
  194. //return/calculate the closest vertex
  195. bool b3VoronoiSimplexSolver::closest(b3Vector3& v)
  196. {
  197. bool succes = updateClosestVectorAndPoints();
  198. v = m_cachedV;
  199. return succes;
  200. }
  201. b3Scalar b3VoronoiSimplexSolver::maxVertex()
  202. {
  203. int i, numverts = numVertices();
  204. b3Scalar maxV = b3Scalar(0.);
  205. for (i = 0; i < numverts; i++)
  206. {
  207. b3Scalar curLen2 = m_simplexVectorW[i].length2();
  208. if (maxV < curLen2)
  209. maxV = curLen2;
  210. }
  211. return maxV;
  212. }
  213. //return the current simplex
  214. int b3VoronoiSimplexSolver::getSimplex(b3Vector3* pBuf, b3Vector3* qBuf, b3Vector3* yBuf) const
  215. {
  216. int i;
  217. for (i = 0; i < numVertices(); i++)
  218. {
  219. yBuf[i] = m_simplexVectorW[i];
  220. pBuf[i] = m_simplexPointsP[i];
  221. qBuf[i] = m_simplexPointsQ[i];
  222. }
  223. return numVertices();
  224. }
  225. bool b3VoronoiSimplexSolver::inSimplex(const b3Vector3& w)
  226. {
  227. bool found = false;
  228. int i, numverts = numVertices();
  229. //b3Scalar maxV = b3Scalar(0.);
  230. //w is in the current (reduced) simplex
  231. for (i = 0; i < numverts; i++)
  232. {
  233. #ifdef BT_USE_EQUAL_VERTEX_THRESHOLD
  234. if (m_simplexVectorW[i].distance2(w) <= m_equalVertexThreshold)
  235. #else
  236. if (m_simplexVectorW[i] == w)
  237. #endif
  238. found = true;
  239. }
  240. //check in case lastW is already removed
  241. if (w == m_lastW)
  242. return true;
  243. return found;
  244. }
  245. void b3VoronoiSimplexSolver::backup_closest(b3Vector3& v)
  246. {
  247. v = m_cachedV;
  248. }
  249. bool b3VoronoiSimplexSolver::emptySimplex() const
  250. {
  251. return (numVertices() == 0);
  252. }
  253. void b3VoronoiSimplexSolver::compute_points(b3Vector3& p1, b3Vector3& p2)
  254. {
  255. updateClosestVectorAndPoints();
  256. p1 = m_cachedP1;
  257. p2 = m_cachedP2;
  258. }
  259. bool b3VoronoiSimplexSolver::closestPtPointTriangle(const b3Vector3& p, const b3Vector3& a, const b3Vector3& b, const b3Vector3& c, b3SubSimplexClosestResult& result)
  260. {
  261. result.m_usedVertices.reset();
  262. // Check if P in vertex region outside A
  263. b3Vector3 ab = b - a;
  264. b3Vector3 ac = c - a;
  265. b3Vector3 ap = p - a;
  266. b3Scalar d1 = ab.dot(ap);
  267. b3Scalar d2 = ac.dot(ap);
  268. if (d1 <= b3Scalar(0.0) && d2 <= b3Scalar(0.0))
  269. {
  270. result.m_closestPointOnSimplex = a;
  271. result.m_usedVertices.usedVertexA = true;
  272. result.setBarycentricCoordinates(1, 0, 0);
  273. return true; // a; // barycentric coordinates (1,0,0)
  274. }
  275. // Check if P in vertex region outside B
  276. b3Vector3 bp = p - b;
  277. b3Scalar d3 = ab.dot(bp);
  278. b3Scalar d4 = ac.dot(bp);
  279. if (d3 >= b3Scalar(0.0) && d4 <= d3)
  280. {
  281. result.m_closestPointOnSimplex = b;
  282. result.m_usedVertices.usedVertexB = true;
  283. result.setBarycentricCoordinates(0, 1, 0);
  284. return true; // b; // barycentric coordinates (0,1,0)
  285. }
  286. // Check if P in edge region of AB, if so return projection of P onto AB
  287. b3Scalar vc = d1 * d4 - d3 * d2;
  288. if (vc <= b3Scalar(0.0) && d1 >= b3Scalar(0.0) && d3 <= b3Scalar(0.0))
  289. {
  290. b3Scalar v = d1 / (d1 - d3);
  291. result.m_closestPointOnSimplex = a + v * ab;
  292. result.m_usedVertices.usedVertexA = true;
  293. result.m_usedVertices.usedVertexB = true;
  294. result.setBarycentricCoordinates(1 - v, v, 0);
  295. return true;
  296. //return a + v * ab; // barycentric coordinates (1-v,v,0)
  297. }
  298. // Check if P in vertex region outside C
  299. b3Vector3 cp = p - c;
  300. b3Scalar d5 = ab.dot(cp);
  301. b3Scalar d6 = ac.dot(cp);
  302. if (d6 >= b3Scalar(0.0) && d5 <= d6)
  303. {
  304. result.m_closestPointOnSimplex = c;
  305. result.m_usedVertices.usedVertexC = true;
  306. result.setBarycentricCoordinates(0, 0, 1);
  307. return true; //c; // barycentric coordinates (0,0,1)
  308. }
  309. // Check if P in edge region of AC, if so return projection of P onto AC
  310. b3Scalar vb = d5 * d2 - d1 * d6;
  311. if (vb <= b3Scalar(0.0) && d2 >= b3Scalar(0.0) && d6 <= b3Scalar(0.0))
  312. {
  313. b3Scalar w = d2 / (d2 - d6);
  314. result.m_closestPointOnSimplex = a + w * ac;
  315. result.m_usedVertices.usedVertexA = true;
  316. result.m_usedVertices.usedVertexC = true;
  317. result.setBarycentricCoordinates(1 - w, 0, w);
  318. return true;
  319. //return a + w * ac; // barycentric coordinates (1-w,0,w)
  320. }
  321. // Check if P in edge region of BC, if so return projection of P onto BC
  322. b3Scalar va = d3 * d6 - d5 * d4;
  323. if (va <= b3Scalar(0.0) && (d4 - d3) >= b3Scalar(0.0) && (d5 - d6) >= b3Scalar(0.0))
  324. {
  325. b3Scalar w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
  326. result.m_closestPointOnSimplex = b + w * (c - b);
  327. result.m_usedVertices.usedVertexB = true;
  328. result.m_usedVertices.usedVertexC = true;
  329. result.setBarycentricCoordinates(0, 1 - w, w);
  330. return true;
  331. // return b + w * (c - b); // barycentric coordinates (0,1-w,w)
  332. }
  333. // P inside face region. Compute Q through its barycentric coordinates (u,v,w)
  334. b3Scalar denom = b3Scalar(1.0) / (va + vb + vc);
  335. b3Scalar v = vb * denom;
  336. b3Scalar w = vc * denom;
  337. result.m_closestPointOnSimplex = a + ab * v + ac * w;
  338. result.m_usedVertices.usedVertexA = true;
  339. result.m_usedVertices.usedVertexB = true;
  340. result.m_usedVertices.usedVertexC = true;
  341. result.setBarycentricCoordinates(1 - v - w, v, w);
  342. return true;
  343. // return a + ab * v + ac * w; // = u*a + v*b + w*c, u = va * denom = b3Scalar(1.0) - v - w
  344. }
  345. /// Test if point p and d lie on opposite sides of plane through abc
  346. int b3VoronoiSimplexSolver::pointOutsideOfPlane(const b3Vector3& p, const b3Vector3& a, const b3Vector3& b, const b3Vector3& c, const b3Vector3& d)
  347. {
  348. b3Vector3 normal = (b - a).cross(c - a);
  349. b3Scalar signp = (p - a).dot(normal); // [AP AB AC]
  350. b3Scalar signd = (d - a).dot(normal); // [AD AB AC]
  351. #ifdef B3_CATCH_DEGENERATE_TETRAHEDRON
  352. #ifdef BT_USE_DOUBLE_PRECISION
  353. if (signd * signd < (b3Scalar(1e-8) * b3Scalar(1e-8)))
  354. {
  355. return -1;
  356. }
  357. #else
  358. if (signd * signd < (b3Scalar(1e-4) * b3Scalar(1e-4)))
  359. {
  360. // printf("affine dependent/degenerate\n");//
  361. return -1;
  362. }
  363. #endif
  364. #endif
  365. // Points on opposite sides if expression signs are opposite
  366. return signp * signd < b3Scalar(0.);
  367. }
  368. bool b3VoronoiSimplexSolver::closestPtPointTetrahedron(const b3Vector3& p, const b3Vector3& a, const b3Vector3& b, const b3Vector3& c, const b3Vector3& d, b3SubSimplexClosestResult& finalResult)
  369. {
  370. b3SubSimplexClosestResult tempResult;
  371. // Start out assuming point inside all halfspaces, so closest to itself
  372. finalResult.m_closestPointOnSimplex = p;
  373. finalResult.m_usedVertices.reset();
  374. finalResult.m_usedVertices.usedVertexA = true;
  375. finalResult.m_usedVertices.usedVertexB = true;
  376. finalResult.m_usedVertices.usedVertexC = true;
  377. finalResult.m_usedVertices.usedVertexD = true;
  378. int pointOutsideABC = pointOutsideOfPlane(p, a, b, c, d);
  379. int pointOutsideACD = pointOutsideOfPlane(p, a, c, d, b);
  380. int pointOutsideADB = pointOutsideOfPlane(p, a, d, b, c);
  381. int pointOutsideBDC = pointOutsideOfPlane(p, b, d, c, a);
  382. if (pointOutsideABC < 0 || pointOutsideACD < 0 || pointOutsideADB < 0 || pointOutsideBDC < 0)
  383. {
  384. finalResult.m_degenerate = true;
  385. return false;
  386. }
  387. if (!pointOutsideABC && !pointOutsideACD && !pointOutsideADB && !pointOutsideBDC)
  388. {
  389. return false;
  390. }
  391. b3Scalar bestSqDist = FLT_MAX;
  392. // If point outside face abc then compute closest point on abc
  393. if (pointOutsideABC)
  394. {
  395. closestPtPointTriangle(p, a, b, c, tempResult);
  396. b3Vector3 q = tempResult.m_closestPointOnSimplex;
  397. b3Scalar sqDist = (q - p).dot(q - p);
  398. // Update best closest point if (squared) distance is less than current best
  399. if (sqDist < bestSqDist)
  400. {
  401. bestSqDist = sqDist;
  402. finalResult.m_closestPointOnSimplex = q;
  403. //convert result bitmask!
  404. finalResult.m_usedVertices.reset();
  405. finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA;
  406. finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexB;
  407. finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexC;
  408. finalResult.setBarycentricCoordinates(
  409. tempResult.m_barycentricCoords[VERTA],
  410. tempResult.m_barycentricCoords[VERTB],
  411. tempResult.m_barycentricCoords[VERTC],
  412. 0);
  413. }
  414. }
  415. // Repeat test for face acd
  416. if (pointOutsideACD)
  417. {
  418. closestPtPointTriangle(p, a, c, d, tempResult);
  419. b3Vector3 q = tempResult.m_closestPointOnSimplex;
  420. //convert result bitmask!
  421. b3Scalar sqDist = (q - p).dot(q - p);
  422. if (sqDist < bestSqDist)
  423. {
  424. bestSqDist = sqDist;
  425. finalResult.m_closestPointOnSimplex = q;
  426. finalResult.m_usedVertices.reset();
  427. finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA;
  428. finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexB;
  429. finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexC;
  430. finalResult.setBarycentricCoordinates(
  431. tempResult.m_barycentricCoords[VERTA],
  432. 0,
  433. tempResult.m_barycentricCoords[VERTB],
  434. tempResult.m_barycentricCoords[VERTC]);
  435. }
  436. }
  437. // Repeat test for face adb
  438. if (pointOutsideADB)
  439. {
  440. closestPtPointTriangle(p, a, d, b, tempResult);
  441. b3Vector3 q = tempResult.m_closestPointOnSimplex;
  442. //convert result bitmask!
  443. b3Scalar sqDist = (q - p).dot(q - p);
  444. if (sqDist < bestSqDist)
  445. {
  446. bestSqDist = sqDist;
  447. finalResult.m_closestPointOnSimplex = q;
  448. finalResult.m_usedVertices.reset();
  449. finalResult.m_usedVertices.usedVertexA = tempResult.m_usedVertices.usedVertexA;
  450. finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexC;
  451. finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexB;
  452. finalResult.setBarycentricCoordinates(
  453. tempResult.m_barycentricCoords[VERTA],
  454. tempResult.m_barycentricCoords[VERTC],
  455. 0,
  456. tempResult.m_barycentricCoords[VERTB]);
  457. }
  458. }
  459. // Repeat test for face bdc
  460. if (pointOutsideBDC)
  461. {
  462. closestPtPointTriangle(p, b, d, c, tempResult);
  463. b3Vector3 q = tempResult.m_closestPointOnSimplex;
  464. //convert result bitmask!
  465. b3Scalar sqDist = (q - p).dot(q - p);
  466. if (sqDist < bestSqDist)
  467. {
  468. bestSqDist = sqDist;
  469. finalResult.m_closestPointOnSimplex = q;
  470. finalResult.m_usedVertices.reset();
  471. //
  472. finalResult.m_usedVertices.usedVertexB = tempResult.m_usedVertices.usedVertexA;
  473. finalResult.m_usedVertices.usedVertexC = tempResult.m_usedVertices.usedVertexC;
  474. finalResult.m_usedVertices.usedVertexD = tempResult.m_usedVertices.usedVertexB;
  475. finalResult.setBarycentricCoordinates(
  476. 0,
  477. tempResult.m_barycentricCoords[VERTA],
  478. tempResult.m_barycentricCoords[VERTC],
  479. tempResult.m_barycentricCoords[VERTB]);
  480. }
  481. }
  482. //help! we ended up full !
  483. if (finalResult.m_usedVertices.usedVertexA &&
  484. finalResult.m_usedVertices.usedVertexB &&
  485. finalResult.m_usedVertices.usedVertexC &&
  486. finalResult.m_usedVertices.usedVertexD)
  487. {
  488. return true;
  489. }
  490. return true;
  491. }