| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsCorePrerequisites.h" |
| 6 | |
| 7 | namespace bs |
| 8 | { |
| 9 | /** @addtogroup Utility-Core |
| 10 | * @{ |
| 11 | */ |
| 12 | |
| 13 | /** Represents a 3D region of pixels used for referencing pixel data. */ |
| 14 | struct BS_CORE_EXPORT BS_SCRIPT_EXPORT(pl:true,n:PixelVolume) PixelVolume |
| 15 | { |
| 16 | UINT32 left = 0; |
| 17 | UINT32 top = 0; |
| 18 | UINT32 right = 1; |
| 19 | UINT32 bottom = 1; |
| 20 | UINT32 front = 0; |
| 21 | UINT32 back = 1; |
| 22 | |
| 23 | PixelVolume() = default; |
| 24 | |
| 25 | PixelVolume(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom): |
| 26 | left(left), top(top), right(right), bottom(bottom), front(0), back(1) |
| 27 | { |
| 28 | assert(right >= left && bottom >= top && back >= front); |
| 29 | } |
| 30 | |
| 31 | PixelVolume(UINT32 left, UINT32 top, UINT32 front, UINT32 right, UINT32 bottom, UINT32 back): |
| 32 | left(left), top(top), right(right), bottom(bottom), front(front), back(back) |
| 33 | { |
| 34 | assert(right >= left && bottom >= top && back >= front); |
| 35 | } |
| 36 | |
| 37 | /** Return true if the other box is a part of this one. */ |
| 38 | bool contains(const PixelVolume &volume) const |
| 39 | { |
| 40 | return (volume.left >= left && volume.top >= top && volume.front >= front && |
| 41 | volume.right <= right && volume.bottom <= bottom && volume.back <= back); |
| 42 | } |
| 43 | |
| 44 | UINT32 getWidth() const { return right-left; } |
| 45 | UINT32 getHeight() const { return bottom-top; } |
| 46 | UINT32 getDepth() const { return back-front; } |
| 47 | }; |
| 48 | |
| 49 | /** @} */ |
| 50 | } |