| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "col.h"
- #include "matrix3.h"
- #include "vector3.h"
- BoxClass::BoxClass(Box box)
- {
- Center.X = box.center[0];
- Center.Y = box.center[1];
- Center.Z = box.center[2];
- Extent.X = box.extent[0];
- Extent.Y = box.extent[1];
- Extent.Z = box.extent[2];
- Velocity.X = box.velocity[0];
- Velocity.Y = box.velocity[1];
- Velocity.Z = box.velocity[2];
- Basis[0][0] = box.basis[0][0];
- Basis[0][1] = box.basis[0][1];
- Basis[0][2] = box.basis[0][2];
- Basis[1][0] = box.basis[1][0];
- Basis[1][1] = box.basis[1][1];
- Basis[1][2] = box.basis[1][2];
- Basis[2][0] = box.basis[2][0];
- Basis[2][1] = box.basis[2][1];
- Basis[2][2] = box.basis[2][2];
- }
- //---------------------------------------------------------------------------
- IntersectType Boxes_Intersect(const BoxClass & box0, const BoxClass & box1,float dt)
- {
- // memoized values for Dot_Product(box0.Basis[i],box1.Basis[j]),
- Matrix3 AB;
- // calculate difference of centers
- Vector3 C = box1.Center - box0.Center;
- Vector3 V = box1.Velocity - box0.Velocity;
- float ra, rb, rsum, u0, u1;
- /////////////////////////////////////////////////////////////////////////
- // L = A0
- //
- // Projecting the two boxes onto Box0's X axis. If their intervals
- // on this line do not intersect, the boxes are not intersecting!
- // Each of the tests in this function work in a similar way.
- /////////////////////////////////////////////////////////////////////////
- AB[0][0] = Dot_Product(box0.Basis[0],box1.Basis[0]);
- AB[0][1] = Dot_Product(box0.Basis[0],box1.Basis[1]);
- AB[0][2] = Dot_Product(box0.Basis[0],box1.Basis[2]);
-
- ra = FABS(box0.Extent[0]);
- rb = FABS(box1.Extent[0]*AB[0][0])+FABS(box1.Extent[1]*AB[0][1])+FABS(box1.Extent[2]*AB[0][2]);
- rsum = ra+rb;
- // u0 = projected distance between the box centers at t0
- // u1 = projected distance between the box centers at t1
- u0 = Dot_Product(C,box0.Basis[0]);
- u1 = u0+dt*Dot_Product(V,box0.Basis[0]);
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA0;
- /////////////////////////////////////////////////////////////////////////
- // L = A1
- // Separating Axis is Box0's Y axis
- /////////////////////////////////////////////////////////////////////////
- AB[1][0] = Dot_Product(box0.Basis[1],box1.Basis[0]);
- AB[1][1] = Dot_Product(box0.Basis[1],box1.Basis[1]);
- AB[1][2] = Dot_Product(box0.Basis[1],box1.Basis[2]);
- ra = FABS(box0.Extent[1]);
- rb = FABS(box1.Extent[0]*AB[1][0])+FABS(box1.Extent[1]*AB[1][1])+FABS(box1.Extent[2]*AB[1][2]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box0.Basis[1]);
- u1 = u0+dt*Dot_Product(V,box0.Basis[1]);
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA1;
-
- /////////////////////////////////////////////////////////////////////////
- // L = A2
- // Separating Axis is Box0's Y axis
- /////////////////////////////////////////////////////////////////////////
- AB[2][0] = Dot_Product(box0.Basis[2],box1.Basis[0]);
- AB[2][1] = Dot_Product(box0.Basis[2],box1.Basis[1]);
- AB[2][2] = Dot_Product(box0.Basis[2],box1.Basis[2]);
- ra = FABS(box0.Extent[2]);
- rb = FABS(box1.Extent[0]*AB[2][0])+FABS(box1.Extent[1]*AB[2][1])+FABS(box1.Extent[2]*AB[2][2]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box0.Basis[2]);
- u1 = u0+dt*Dot_Product(V,box0.Basis[2]);
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA2;
- /////////////////////////////////////////////////////////////////////////
- // L = B0
- // Separating Axis is Box1's X axis
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*AB[0][0])+FABS(box0.Extent[1]*AB[1][0])+FABS(box0.Extent[2]*AB[2][0]);
- rb = FABS(box1.Extent[0]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box1.Basis[0]);
- u1 = u0+dt*Dot_Product(V,box1.Basis[0]);
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itB0;
- /////////////////////////////////////////////////////////////////////////
- // L = B1
- // Separating Axis is Box1's Y axis
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*AB[0][1])+FABS(box0.Extent[1]*AB[1][1])+FABS(box0.Extent[2]*AB[2][1]);
- rb = FABS(box1.Extent[1]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box1.Basis[1]);
- u1 = u0+dt*Dot_Product(V,box1.Basis[1]);
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itB1;
-
- /////////////////////////////////////////////////////////////////////////
- // L = B2
- // Separating Axis is Box1's Z axis
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*AB[0][2])+FABS(box0.Extent[1]*AB[1][2])+FABS(box0.Extent[2]*AB[2][2]);
- rb = FABS(box1.Extent[2]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box1.Basis[2]);
- u1 = u0+dt*Dot_Product(V,box1.Basis[2]);
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itB2;
- /////////////////////////////////////////////////////////////////////////
- // None of the aligned axes turned out to be separating axes. Now
- // we check all combinations of cross products of the two boxes axes.
- /////////////////////////////////////////////////////////////////////////
- Matrix3 Ainv = box0.Basis.Transpose();
- Matrix3 coeff = AB.Transpose();
- // difference of centers in box0's-basis
- Vector3 d0, d1, product;
- d0 = Ainv * C;
- d1 = Ainv * V;
- product = dt*d1;
- d1 = d0 + product;
- /////////////////////////////////////////////////////////////////////////
- // L = A0xB0
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[1]*coeff[0][2])+FABS(box0.Extent[2]*coeff[0][1]);
- rb = FABS(box1.Extent[1]*coeff[2][0])+FABS(box1.Extent[2]*coeff[1][0]);
- rsum = ra+rb;
- u0 = d0[2]*coeff[1][0]-d0[1]*coeff[2][0];
- u1 = d1[2]*coeff[1][0]-d1[1]*coeff[2][0];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA0B0;
- /////////////////////////////////////////////////////////////////////////
- // L = A0xB1
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[1]*coeff[1][2])+FABS(box0.Extent[2]*coeff[1][1]);
- rb = FABS(box1.Extent[0]*coeff[2][0])+FABS(box1.Extent[2]*coeff[0][0]);
- rsum = ra+rb;
- u0 = d0[2]*coeff[1][1]-d0[1]*coeff[1][2];
- u1 = d1[2]*coeff[1][1]-d1[1]*coeff[1][2];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA0B1;
- /////////////////////////////////////////////////////////////////////////
- // L = A0xB2
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[1]*coeff[2][2])+FABS(box0.Extent[2]*coeff[2][1]);
- rb = FABS(box1.Extent[0]*coeff[1][0])+FABS(box1.Extent[1]*coeff[0][0]);
- rsum = ra+rb;
- u0 = d0[2]*coeff[2][1]-d0[1]*coeff[2][2];
- u1 = d1[2]*coeff[2][1]-d1[1]*coeff[2][2];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA0B2;
- /////////////////////////////////////////////////////////////////////////
- // L = A1xB0
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[0][2])+FABS(box0.Extent[2]*coeff[0][0]);
- rb = FABS(box1.Extent[1]*coeff[2][1])+FABS(box1.Extent[2]*coeff[1][1]);
- rsum = ra+rb;
- u0 = d0[0]*coeff[0][2]-d0[2]*coeff[0][0];
- u1 = d1[0]*coeff[0][2]-d1[2]*coeff[0][0];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA1B0;
- /////////////////////////////////////////////////////////////////////////
- // L = A1xB1
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[1][2])+FABS(box0.Extent[2]*coeff[1][0]);
- rb = FABS(box1.Extent[0]*coeff[2][1])+FABS(box1.Extent[2]*coeff[0][1]);
- rsum = ra+rb;
- u0 = d0[0]*coeff[1][2]-d0[2]*coeff[1][0];
- u1 = d1[0]*coeff[1][2]-d1[2]*coeff[1][0];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA1B1;
- /////////////////////////////////////////////////////////////////////////
- // L = A1xB2
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[2][2])+FABS(box0.Extent[2]*coeff[2][0]);
- rb = FABS(box1.Extent[0]*coeff[1][1])+FABS(box1.Extent[1]*coeff[0][1]);
- rsum = ra+rb;
- u0 = d0[0]*coeff[2][2]-d0[2]*coeff[2][0];
- u1 = d1[0]*coeff[2][2]-d1[2]*coeff[2][0];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA1B2;
- /////////////////////////////////////////////////////////////////////////
- // L = A2xB0
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[0][1])+FABS(box0.Extent[1]*coeff[0][0]);
- rb = FABS(box1.Extent[1]*coeff[2][2])+FABS(box1.Extent[2]*coeff[1][2]);
- rsum = ra+rb;
- u0 = d0[1]*coeff[0][0]-d0[0]*coeff[0][1];
- u1 = d1[1]*coeff[0][0]-d1[0]*coeff[0][1];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA2B0;
- /////////////////////////////////////////////////////////////////////////
- // L = A2xB1
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[1][1])+FABS(box0.Extent[1]*coeff[1][0]);
- rb = FABS(box1.Extent[0]*coeff[2][2])+FABS(box1.Extent[2]*coeff[0][2]);
- rsum = ra+rb;
- u0 = d0[1]*coeff[1][0]-d0[0]*coeff[1][1];
- u1 = d1[1]*coeff[1][0]-d1[0]*coeff[1][1];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA2B1;
- /////////////////////////////////////////////////////////////////////////
- // L = A2xB2
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[2][1])+FABS(box0.Extent[1]*coeff[2][0]);
- rb = FABS(box1.Extent[0]*coeff[1][2])+FABS(box1.Extent[1]*coeff[0][2]);
- rsum = ra+rb;
- u0 = d0[1]*coeff[2][0]-d0[0]*coeff[2][1];
- u1 = d1[1]*coeff[2][0]-d1[0]*coeff[2][1];
- if ((u0 > rsum && u1 > rsum) || (u0 < -rsum && u1 < -rsum) )
- return itA2B2;
- return itIntersects;
- }
- //---------------------------------------------------------------------------
- IntersectType Boxes_Intersect(const BoxClass & box0, const BoxClass & box1)
- {
- // memoized values for Dot_Product(box0.Basis[i],box1.Basis[j]),
- Matrix3 AB;
- // calculate difference of centers
- Vector3 C = box1.Center - box0.Center;
- float ra, rb, rsum, u0;
- /////////////////////////////////////////////////////////////////////////
- // L = A0
- //
- // Projecting the two boxes onto Box0's X axis. If their intervals
- // on this line do not intersect, the boxes are not intersecting!
- // Each of the tests in this function work in a similar way.
- /////////////////////////////////////////////////////////////////////////
- AB[0][0] = Dot_Product(box0.Basis[0],box1.Basis[0]);
- AB[0][1] = Dot_Product(box0.Basis[0],box1.Basis[1]);
- AB[0][2] = Dot_Product(box0.Basis[0],box1.Basis[2]);
-
- ra = FABS(box0.Extent[0]);
- rb = FABS(box1.Extent[0]*AB[0][0])+FABS(box1.Extent[1]*AB[0][1])+FABS(box1.Extent[2]*AB[0][2]);
- rsum = ra+rb;
- // u0 = projected distance between the box centers at t0
- // u1 = projected distance between the box centers at t1
- u0 = Dot_Product(C,box0.Basis[0]);
- if ((u0 > rsum) || (u0 < -rsum))
- return itA0;
- /////////////////////////////////////////////////////////////////////////
- // L = A1
- // Separating Axis is Box0's Y axis
- /////////////////////////////////////////////////////////////////////////
- AB[1][0] = Dot_Product(box0.Basis[1],box1.Basis[0]);
- AB[1][1] = Dot_Product(box0.Basis[1],box1.Basis[1]);
- AB[1][2] = Dot_Product(box0.Basis[1],box1.Basis[2]);
- ra = FABS(box0.Extent[1]);
- rb = FABS(box1.Extent[0]*AB[1][0])+FABS(box1.Extent[1]*AB[1][1])+FABS(box1.Extent[2]*AB[1][2]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box0.Basis[1]);
- if ((u0 > rsum) || (u0 < -rsum))
- return itA1;
-
- /////////////////////////////////////////////////////////////////////////
- // L = A2
- // Separating Axis is Box0's Y axis
- /////////////////////////////////////////////////////////////////////////
- AB[2][0] = Dot_Product(box0.Basis[2],box1.Basis[0]);
- AB[2][1] = Dot_Product(box0.Basis[2],box1.Basis[1]);
- AB[2][2] = Dot_Product(box0.Basis[2],box1.Basis[2]);
- ra = FABS(box0.Extent[2]);
- rb = FABS(box1.Extent[0]*AB[2][0])+FABS(box1.Extent[1]*AB[2][1])+FABS(box1.Extent[2]*AB[2][2]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box0.Basis[2]);
- if ((u0 > rsum) || (u0 < -rsum))
- return itA2;
- /////////////////////////////////////////////////////////////////////////
- // L = B0
- // Separating Axis is Box1's X axis
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*AB[0][0])+FABS(box0.Extent[1]*AB[1][0])+FABS(box0.Extent[2]*AB[2][0]);
- rb = FABS(box1.Extent[0]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box1.Basis[0]);
- if ((u0 > rsum) || (u0 < -rsum))
- return itB0;
- /////////////////////////////////////////////////////////////////////////
- // L = B1
- // Separating Axis is Box1's Y axis
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*AB[0][1])+FABS(box0.Extent[1]*AB[1][1])+FABS(box0.Extent[2]*AB[2][1]);
- rb = FABS(box1.Extent[1]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box1.Basis[1]);
- if ((u0 > rsum) || (u0 < -rsum))
- return itB1;
-
- /////////////////////////////////////////////////////////////////////////
- // L = B2
- // Separating Axis is Box1's Z axis
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*AB[0][2])+FABS(box0.Extent[1]*AB[1][2])+FABS(box0.Extent[2]*AB[2][2]);
- rb = FABS(box1.Extent[2]);
- rsum = ra+rb;
- u0 = Dot_Product(C,box1.Basis[2]);
- if ((u0 > rsum) || (u0 < -rsum))
- return itB2;
- /////////////////////////////////////////////////////////////////////////
- // None of the aligned axes turned out to be separating axes. Now
- // we check all combinations of cross products of the two boxes axes.
- /////////////////////////////////////////////////////////////////////////
- Matrix3 Ainv = box0.Basis.Transpose();
- Matrix3 coeff = AB.Transpose();
- // difference of centers in box0's-basis
- Vector3 d0, d1, product;
- d0 = Ainv * C;
- /////////////////////////////////////////////////////////////////////////
- // L = A0xB0
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[1]*coeff[0][2])+FABS(box0.Extent[2]*coeff[0][1]);
- rb = FABS(box1.Extent[1]*coeff[2][0])+FABS(box1.Extent[2]*coeff[1][0]);
- rsum = ra+rb;
- u0 = d0[2]*coeff[1][0]-d0[1]*coeff[2][0];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA0B0;
- /////////////////////////////////////////////////////////////////////////
- // L = A0xB1
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[1]*coeff[1][2])+FABS(box0.Extent[2]*coeff[1][1]);
- rb = FABS(box1.Extent[0]*coeff[2][0])+FABS(box1.Extent[2]*coeff[0][0]);
- rsum = ra+rb;
- u0 = d0[2]*coeff[1][1]-d0[1]*coeff[1][2];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA0B1;
- /////////////////////////////////////////////////////////////////////////
- // L = A0xB2
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[1]*coeff[2][2])+FABS(box0.Extent[2]*coeff[2][1]);
- rb = FABS(box1.Extent[0]*coeff[1][0])+FABS(box1.Extent[1]*coeff[0][0]);
- rsum = ra+rb;
- u0 = d0[2]*coeff[2][1]-d0[1]*coeff[2][2];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA0B2;
- /////////////////////////////////////////////////////////////////////////
- // L = A1xB0
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[0][2])+FABS(box0.Extent[2]*coeff[0][0]);
- rb = FABS(box1.Extent[1]*coeff[2][1])+FABS(box1.Extent[2]*coeff[1][1]);
- rsum = ra+rb;
- u0 = d0[0]*coeff[0][2]-d0[2]*coeff[0][0];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA1B0;
- /////////////////////////////////////////////////////////////////////////
- // L = A1xB1
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[1][2])+FABS(box0.Extent[2]*coeff[1][0]);
- rb = FABS(box1.Extent[0]*coeff[2][1])+FABS(box1.Extent[2]*coeff[0][1]);
- rsum = ra+rb;
- u0 = d0[0]*coeff[1][2]-d0[2]*coeff[1][0];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA1B1;
- /////////////////////////////////////////////////////////////////////////
- // L = A1xB2
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[2][2])+FABS(box0.Extent[2]*coeff[2][0]);
- rb = FABS(box1.Extent[0]*coeff[1][1])+FABS(box1.Extent[1]*coeff[0][1]);
- rsum = ra+rb;
- u0 = d0[0]*coeff[2][2]-d0[2]*coeff[2][0];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA1B2;
- /////////////////////////////////////////////////////////////////////////
- // L = A2xB0
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[0][1])+FABS(box0.Extent[1]*coeff[0][0]);
- rb = FABS(box1.Extent[1]*coeff[2][2])+FABS(box1.Extent[2]*coeff[1][2]);
- rsum = ra+rb;
- u0 = d0[1]*coeff[0][0]-d0[0]*coeff[0][1];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA2B0;
- /////////////////////////////////////////////////////////////////////////
- // L = A2xB1
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[1][1])+FABS(box0.Extent[1]*coeff[1][0]);
- rb = FABS(box1.Extent[0]*coeff[2][2])+FABS(box1.Extent[2]*coeff[0][2]);
- rsum = ra+rb;
- u0 = d0[1]*coeff[1][0]-d0[0]*coeff[1][1];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA2B1;
- /////////////////////////////////////////////////////////////////////////
- // L = A2xB2
- /////////////////////////////////////////////////////////////////////////
- ra = FABS(box0.Extent[0]*coeff[2][1])+FABS(box0.Extent[1]*coeff[2][0]);
- rb = FABS(box1.Extent[0]*coeff[1][2])+FABS(box1.Extent[1]*coeff[0][2]);
- rsum = ra+rb;
- u0 = d0[1]*coeff[2][0]-d0[0]*coeff[2][1];
- if ((u0 > rsum) || (u0 < -rsum))
- return itA2B2;
- return itIntersects;
- }
|