| 159 | } |
| 160 | |
| 161 | static void xBoundOBBIsectRay(const xBox* b, const xMat4x3* m, const xRay3* r, xIsect* isect) |
| 162 | { |
| 163 | xRay3 xfr; |
| 164 | xBox sbox; |
| 165 | xVec3 scale; |
| 166 | xMat4x3 mnormal; |
| 167 | |
| 168 | { |
| 169 | F32 len2 = SQR(m->right.x) + SQR(m->right.y) + SQR(m->right.z); |
| 170 | |
| 171 | if ((F32)iabs(len2 - 1.0f) <= 0.00001f) |
| 172 | { |
| 173 | // non-matching: incorrect instruction + order |
| 174 | |
| 175 | scale.x = 1.0f; |
| 176 | |
| 177 | mnormal.right.x = SQR(m->right.x); |
| 178 | mnormal.right.y = SQR(m->right.y); |
| 179 | mnormal.right.z = SQR(m->right.z); |
| 180 | } |
| 181 | else if ((F32)iabs(len2) <= 0.00001f) |
| 182 | { |
| 183 | // non-matching: incorrect order |
| 184 | |
| 185 | scale.x = 0.0f; |
| 186 | |
| 187 | mnormal.right.x = 0.0f; |
| 188 | mnormal.right.y = 1.0f; |
| 189 | mnormal.right.z = 0.0f; |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | scale.x = xsqrt(len2); |
| 194 | |
| 195 | F32 len_inv = 1.0f / scale.x; |
| 196 | |
| 197 | mnormal.right.x = m->right.x * len_inv; |
| 198 | mnormal.right.y = m->right.y * len_inv; |
| 199 | mnormal.right.z = m->right.z * len_inv; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | { |
| 204 | F32 len2 = SQR(m->up.x) + SQR(m->up.y) + SQR(m->up.z); |
| 205 | |
| 206 | if ((F32)iabs(len2 - 1.0f) <= 0.00001f) |
| 207 | { |
| 208 | // non-matching: incorrect instruction + order |
| 209 | |
| 210 | scale.y = 1.0f; |
| 211 | |
| 212 | mnormal.up.x = SQR(m->up.x); |
| 213 | mnormal.up.y = SQR(m->up.y); |
| 214 | mnormal.up.z = SQR(m->up.z); |
| 215 | } |
| 216 | else if ((F32)iabs(len2) <= 0.00001f) |
| 217 | { |
| 218 | // non-matching: incorrect order |
no test coverage detected