| 209 | } |
| 210 | |
| 211 | void BoundingBoxTransform( Vector3& min, Vector3& max, const Matrix& tf ) |
| 212 | { |
| 213 | Vector3 corners[8]; |
| 214 | |
| 215 | corners[0] = min; |
| 216 | |
| 217 | corners[1].x = min.x; |
| 218 | corners[1].y = min.y; |
| 219 | corners[1].z = max.z; |
| 220 | |
| 221 | corners[2].x = max.x; |
| 222 | corners[2].y = min.y; |
| 223 | corners[2].z = min.z; |
| 224 | |
| 225 | corners[3].x = max.x; |
| 226 | corners[3].y = min.y; |
| 227 | corners[3].z = max.z; |
| 228 | |
| 229 | corners[4] = max; |
| 230 | |
| 231 | corners[5].x = max.x; |
| 232 | corners[5].y = max.y; |
| 233 | corners[5].z = min.z; |
| 234 | |
| 235 | corners[6].x = min.x; |
| 236 | corners[6].y = max.y; |
| 237 | corners[6].z = max.z; |
| 238 | |
| 239 | corners[7].x = min.x; |
| 240 | corners[7].y = max.y; |
| 241 | corners[7].z = min.z; |
| 242 | |
| 243 | TransformCoords( corners, tf ); |
| 244 | |
| 245 | min = corners[0]; |
| 246 | max = corners[0]; |
| 247 | float* pMin = (float*)&min; |
| 248 | float* pMax = (float*)&max; |
| 249 | |
| 250 | for( int i = 1; i < 8; ++i ) |
| 251 | { |
| 252 | float* pCorner = (float*)&corners[i]; |
| 253 | |
| 254 | for( int component = 0; component < 3; ++component ) |
| 255 | { |
| 256 | if( pCorner[component] < pMin[component] ) |
| 257 | { |
| 258 | pMin[component] = pCorner[component]; |
| 259 | } |
| 260 | if( pCorner[component] > pMax[component] ) |
| 261 | { |
| 262 | pMax[component] = pCorner[component]; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | void BoundingBoxProject( Vector3& min, Vector3& max, const Matrix& view, const Matrix& proj, const TriViewport& vp ) |
no outgoing calls
no test coverage detected