BsPixelVolume.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Volume of pixels used for referencing a part of
  7. * a texture.
  8. */
  9. struct BS_CORE_EXPORT PixelVolume
  10. {
  11. UINT32 left, top, right, bottom, front, back;
  12. PixelVolume()
  13. : left(0), top(0), right(1), bottom(1), front(0), back(1)
  14. { }
  15. PixelVolume(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom):
  16. left(left), top(top), right(right), bottom(bottom), front(0), back(1)
  17. {
  18. assert(right >= left && bottom >= top && back >= front);
  19. }
  20. PixelVolume(UINT32 left, UINT32 top, UINT32 front, UINT32 right, UINT32 bottom, UINT32 back):
  21. left(left), top(top), right(right), bottom(bottom), front(front), back(back)
  22. {
  23. assert(right >= left && bottom >= top && back >= front);
  24. }
  25. /**
  26. * @brief Return true if the other box is a part of this one.
  27. */
  28. bool contains(const PixelVolume &volume) const
  29. {
  30. return (volume.left >= left && volume.top >= top && volume.front >= front &&
  31. volume.right <= right && volume.bottom <= bottom && volume.back <= back);
  32. }
  33. UINT32 getWidth() const { return right-left; }
  34. UINT32 getHeight() const { return bottom-top; }
  35. UINT32 getDepth() const { return back-front; }
  36. };
  37. }