Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class Vector, class UVector>
- struct Rect2KImpl {
- using Scalar = typename Vector::value_type;
- using UScalar = typename UVector::value_type;
- Vector TopLeft;
- Vector BottomRight;
- static Rect2KImpl FromCorners(Vector tl, Vector br);
- static Rect2KImpl FromHalfDim(Vector center, UScalar halfDimension);
- static Rect2KImpl FromDim(Vector topLeft, UVector dimensions);
- static Rect2KImpl FromScalars(Scalar x, Scalar y, UScalar width, UScalar height);
- __declspec(property(get = GetCenter)) Vector Center;
- Vector GetCenter() const;
- __declspec(property(get = GetTopRight, put = SetTopRight)) Vector TopRight;
- Vector GetTopRight() const;
- void SetTopRight(Vector topRight);
- __declspec(property(get = GetBottomLeft, put = SetBottomLeft)) Vector BottomLeft;
- Vector GetBottomLeft() const;
- void SetBottomLeft(Vector bottomLeft);
- __declspec(property(get = GetX, put = SetX)) Scalar X;
- Scalar GetX() const;
- void SetX(Scalar x);
- __declspec(property(get = GetY, put = SetY)) Scalar Y;
- Scalar GetY() const;
- void SetY(Scalar y);
- __declspec(property(get = GetWidth, put = SetWidth)) UScalar Width;
- UScalar GetWidth() const;
- void SetWidth(UScalar width);
- __declspec(property(get = GetHeight, put = SetHeight)) UScalar Height;
- UScalar GetHeight() const;
- void SetHeight(UScalar height);
- __declspec(property(get = GetDimensions, put = SetDimensions)) UVector Dimensions;
- UVector GetDimensions() const;
- void SetDimensions(UVector dimensions);
- __declspec(property(get = GetHalfDimensions, put = SetHalfDimensions)) UVector HalfDimensions;
- UVector GetHalfDimensions() const;
- void SetHalfDimensions(UVector halfDimensions);
- bool HasPoint(Vector pt) const;
- bool IntersectsWith(const Rect2KImpl<Vector, UVector>& rect) const;
- template <typename = std::enable_if_t<std::is_same_v<UScalar, Diligent::Uint32>>>
- Diligent::Box ToDiligentBox() const;
- };
- using Rect2i = Rect2KImpl<glm::ivec2, glm::uvec2>;
- using Rect2 = Rect2KImpl<glm::vec2, glm::vec2>;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement