3
0

Interval.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/RHI.Reflect/Interval.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. namespace AZ::RHI
  11. {
  12. void Interval::Reflect(AZ::ReflectContext* context)
  13. {
  14. if (SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context))
  15. {
  16. serializeContext->Class<Interval>()
  17. ->Version(1)
  18. ->Field("m_min", &Interval::m_min)
  19. ->Field("m_max", &Interval::m_max);
  20. }
  21. }
  22. Interval::Interval(uint32_t min, uint32_t max)
  23. : m_min{min}
  24. , m_max{max}
  25. {}
  26. bool Interval::operator == (const Interval& rhs) const
  27. {
  28. return m_min == rhs.m_min && m_max == rhs.m_max;
  29. }
  30. bool Interval::operator != (const Interval& rhs) const
  31. {
  32. return m_min != rhs.m_min || m_max != rhs.m_max;
  33. }
  34. bool Interval::Overlaps(const Interval& rhs) const
  35. {
  36. return m_min <= rhs.m_max && rhs.m_min <= m_max;
  37. }
  38. }