| 404 | #endif |
| 405 | |
| 406 | void Camera::UpdateCache() |
| 407 | { |
| 408 | // Calculate view and projection matrices |
| 409 | Matrix view, projection; |
| 410 | GetMatrices(view, projection); |
| 411 | |
| 412 | // Update frustum and bounding box |
| 413 | _frustum.SetMatrix(view, projection); |
| 414 | _frustum.GetBox(_box); |
| 415 | BoundingSphere::FromBox(_box, _sphere); |
| 416 | |
| 417 | #if USE_EDITOR |
| 418 | |
| 419 | // Update editor preview model cache |
| 420 | Matrix rot, tmp, world; |
| 421 | GetLocalToWorldMatrix(tmp); |
| 422 | Matrix::RotationY(PI * -0.5f, rot); |
| 423 | Matrix::Multiply(rot, tmp, world); |
| 424 | |
| 425 | // Calculate snap box for preview model |
| 426 | if (_previewModel && _previewModel->IsLoaded()) |
| 427 | { |
| 428 | _previewModelBox = _previewModel->GetBox(world); |
| 429 | } |
| 430 | else |
| 431 | { |
| 432 | Vector3 min(-10.0f), max(10.0f); |
| 433 | min = Vector3::Transform(min, world); |
| 434 | max = Vector3::Transform(max, world); |
| 435 | _previewModelBox = BoundingBox(min, max); |
| 436 | } |
| 437 | |
| 438 | // Extend culling bounding box |
| 439 | BoundingBox::Merge(_box, _previewModelBox, _box); |
| 440 | BoundingSphere::FromBox(_box, _sphere); |
| 441 | |
| 442 | #endif |
| 443 | } |
| 444 | |
| 445 | void Camera::Serialize(SerializeStream& stream, const void* otherObj) |
| 446 | { |