| 108 | } |
| 109 | |
| 110 | static bool IntersectBBox(Vector3* isect, const Vector3 tMinMax[2], const Vector3 wMinMax[2], const Matrix4& withToThis) |
| 111 | { |
| 112 | #if 1 |
| 113 | // calculate bbox of transformed bbox |
| 114 | Vector3 wtMin(+1e10, +1e10, +1e10), wtMax(-1e10, -1e10, -1e10); // in this coordinates |
| 115 | |
| 116 | Vector3 wCorners[2][2][2]; |
| 117 | for (int lr = 0; lr < 2; lr++) |
| 118 | { |
| 119 | for (int ud = 0; ud < 2; ud++) |
| 120 | { |
| 121 | for (int fb = 0; fb < 2; fb++) |
| 122 | { |
| 123 | Vector3 wCorner = MinMaxCorner(wMinMax, lr, ud, fb); |
| 124 | Vector3 wtCorner; |
| 125 | wtCorner.SetFastTransform(withToThis, wCorner); |
| 126 | wCorners[lr][ud][fb] = wtCorner; |
| 127 | CheckMinMax(wtMin, wtMax, wtCorner); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | // clip wtMinMax against tMinMax |
| 133 | |
| 134 | if (wtMin[0] >= tMinMax[1][0]) |
| 135 | { |
| 136 | return false; |
| 137 | } |
| 138 | if (wtMin[1] >= tMinMax[1][1]) |
| 139 | { |
| 140 | return false; |
| 141 | } |
| 142 | if (wtMin[2] >= tMinMax[1][2]) |
| 143 | { |
| 144 | return false; |
| 145 | } |
| 146 | if (wtMax[0] <= tMinMax[0][0]) |
| 147 | { |
| 148 | return false; |
| 149 | } |
| 150 | if (wtMax[1] <= tMinMax[0][1]) |
| 151 | { |
| 152 | return false; |
| 153 | } |
| 154 | if (wtMax[2] <= tMinMax[0][2]) |
| 155 | { |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | if (isect) |
| 160 | { |
| 161 | // the caller requires intersection result |
| 162 | isect[0] = VectorMax(wtMin, tMinMax[0]); |
| 163 | isect[1] = VectorMin(wtMax, tMinMax[1]); |
| 164 | } |
| 165 | |
| 166 | #else |
| 167 |
no test coverage detected