Files
o3de/Code/Framework/AzToolsFramework/AzToolsFramework/Picking/BoundInterface.h
T
Tom Hulton-Harrop cf8a6761bf Formatting-only change - Update Manipulator and Viewport AzToolsFramework files (#1143)
* formatting changes to AzToolsFramework viewport related types + API comment style updates

* minor format change - include ordering

* improve formatting by moving comment

* fix compile error and switch to use AZ_Printf

* small polish changes after review feedback
2021-06-07 14:50:49 +01:00

113 lines
3.2 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Math/Vector3.h>
#include <AzCore/RTTI/RTTI.h>
namespace AzToolsFramework
{
//! Provide unique type alias for AZ::u64 for manipulator, bounds and manager.
template<typename T>
class IdType
{
public:
explicit IdType(AZ::u64 id = 0)
: m_id(id)
{
}
operator AZ::u64() const
{
return m_id;
}
bool operator==(IdType other) const
{
return m_id == other.m_id;
}
bool operator!=(IdType other) const
{
return m_id != other.m_id;
}
IdType& operator++() // pre-increment
{
++m_id;
return *this;
}
IdType operator++(int) // post-increment
{
IdType temp = *this;
++*this;
return temp;
}
private:
AZ::u64 m_id;
};
namespace Picking
{
class BoundRequestShapeBase;
using RegisteredBoundId = IdType<struct RegisteredBoundType>;
static const RegisteredBoundId InvalidBoundId = RegisteredBoundId(0);
//! This class serves as the base class for the actual bound shapes that various DefaultContextBoundManager-derived
//! classes return from the function CreateShape.
class BoundShapeInterface
{
public:
AZ_RTTI(BoundShapeInterface, "{C639CB8E-1957-4E4F-B889-3BE1DFBC358D}");
explicit BoundShapeInterface(const RegisteredBoundId boundId)
: m_boundId(boundId)
, m_valid(false)
{
}
virtual ~BoundShapeInterface() = default;
RegisteredBoundId GetBoundId() const
{
return m_boundId;
}
//! @param rayOrigin The origin of the ray to test with.
//! @param rayDir The direction of the ray to test with.
//! @param[out] rayIntersectionDistance The distance of the intersecting point closest to the ray origin.
//! @return Boolean indicating whether there is a least one intersecting point between this bound shape and the ray.
virtual bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) = 0;
virtual void SetShapeData(const BoundRequestShapeBase& shapeData) = 0;
void SetValidity(bool valid)
{
m_valid = valid;
}
bool IsValid() const
{
return m_valid;
}
private:
RegisteredBoundId m_boundId;
bool m_valid;
};
} // namespace Picking
} // namespace AzToolsFramework