Check if we're moving to a smaller mip, and if so, shrink the rectangle pointed at by sub in half.
| 273 | // Check if we're moving to a smaller mip, and if so, shrink the rectangle pointed at by |
| 274 | // sub in half. |
| 275 | void AdvanceMip( Tr2TextureSubresource& sub, const Tr2BitmapDimensions& bd, uint32_t mip ) |
| 276 | { |
| 277 | if( bd.GetMipWidth( sub.m_startMipLevel + mip + 1 ) < bd.GetMipWidth( sub.m_startMipLevel + mip ) ) |
| 278 | { |
| 279 | sub.m_box.left /= 2; |
| 280 | sub.m_box.right /= 2; |
| 281 | |
| 282 | if( bd.IsCompressed() && sub.GetWidth() < 4 ) |
| 283 | { |
| 284 | sub.m_box.right = sub.m_box.left + 4; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | if( bd.GetMipHeight( sub.m_startMipLevel + mip + 1 ) < bd.GetMipHeight( sub.m_startMipLevel + mip ) ) |
| 289 | { |
| 290 | sub.m_box.top /= 2; |
| 291 | sub.m_box.bottom /= 2; |
| 292 | |
| 293 | if( bd.IsCompressed() && sub.GetHeight() < 4 ) |
| 294 | { |
| 295 | sub.m_box.bottom = sub.m_box.top + 4; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | if( bd.GetMipDepth( sub.m_startMipLevel + mip + 1 ) < bd.GetMipDepth( sub.m_startMipLevel + mip ) ) |
| 300 | { |
| 301 | sub.m_box.front /= 2; |
| 302 | sub.m_box.back /= 2; |
| 303 | |
| 304 | if( bd.IsCompressed() && sub.GetDepth() < 4 ) |
| 305 | { |
| 306 | sub.m_box.bottom = sub.m_box.top + 4; |
| 307 | } |
| 308 | } |
| 309 | } |