OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 var v0 = (t00 * x - | 518 var v0 = (t00 * x - |
519 (m10 * m22 - m12 * m20) * y + | 519 (m10 * m22 - m12 * m20) * y + |
520 (m10 * m21 - m11 * m20) * z) / d; | 520 (m10 * m21 - m11 * m20) * z) / d; |
521 var v1 = (-t10 * x + | 521 var v1 = (-t10 * x + |
522 (m00 * m22 - m02 * m20) * y - | 522 (m00 * m22 - m02 * m20) * y - |
523 (m00 * m21 - m01 * m20) * z) / d; | 523 (m00 * m21 - m01 * m20) * z) / d; |
524 var v2 = (t20 * x - | 524 var v2 = (t20 * x - |
525 (m00 * m12 - m02 * m10) * y + | 525 (m00 * m12 - m02 * m10) * y + |
526 (m00 * m11 - m01 * m10) * z) / d; | 526 (m00 * m11 - m01 * m10) * z) / d; |
527 | 527 |
528 if (v0 > 0 && v1 > 0 && v2 > 0) { | 528 if (v0 >= 0 && v1 >= 0 && v2 >= 0 && (v0 + v1 + v2 > 0)) { |
529 // Rescale by the one-norm to find the intersection of the transformed. | 529 // Rescale by the one-norm to find the intersection of the transformed. |
530 // ray with the unit triangle. | 530 // ray with the unit triangle. |
531 var one_norm = v0 + v1 + v2; | 531 var one_norm = v0 + v1 + v2; |
532 v0 /= one_norm; | 532 v0 /= one_norm; |
533 v1 /= one_norm; | 533 v1 /= one_norm; |
534 v2 /= one_norm; | 534 v2 /= one_norm; |
535 // Multiply m to get back to the original triangle. | 535 // Multiply m to get back to the original triangle. |
536 var px = m00 * v0 + m10 * v1 + m20 * v2; | 536 var px = m00 * v0 + m10 * v1 + m20 * v2; |
537 var py = m01 * v0 + m11 * v1 + m21 * v2; | 537 var py = m01 * v0 + m11 * v1 + m21 * v2; |
538 var pz = m02 * v0 + m12 * v1 + m22 * v2; | 538 var pz = m02 * v0 + m12 * v1 + m22 * v2; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 } | 581 } |
582 points.push(p); | 582 points.push(p); |
583 } | 583 } |
584 | 584 |
585 o3d.BoundingBox.fitBoxToPoints_(points, this.boundingBox); | 585 o3d.BoundingBox.fitBoxToPoints_(points, this.boundingBox); |
586 return this.boundingBox; | 586 return this.boundingBox; |
587 }; | 587 }; |
588 | 588 |
589 | 589 |
590 | 590 |
OLD | NEW |