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
This commit is contained in:
committed by
GitHub
parent
c751cda73d
commit
cf8a6761bf
@@ -1,14 +1,15 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
* 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>
|
||||
@@ -16,30 +17,44 @@
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
/**
|
||||
* Provide unique type alias for AZ::u64 for manipulator, bounds and manager.
|
||||
*/
|
||||
//! 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; }
|
||||
: 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;
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
@@ -51,10 +66,8 @@ namespace AzToolsFramework
|
||||
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.
|
||||
*/
|
||||
//! 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:
|
||||
@@ -63,25 +76,33 @@ namespace AzToolsFramework
|
||||
explicit BoundShapeInterface(const RegisteredBoundId boundId)
|
||||
: m_boundId(boundId)
|
||||
, m_valid(false)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~BoundShapeInterface() = default;
|
||||
|
||||
RegisteredBoundId GetBoundId() const { return m_boundId; }
|
||||
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;
|
||||
//! @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; }
|
||||
void SetValidity(bool valid)
|
||||
{
|
||||
m_valid = valid;
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
private:
|
||||
RegisteredBoundId m_boundId;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
* 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/EBus/EBus.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/Quaternion.h>
|
||||
#include <AzCore/Math/Spline.h>
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
@@ -27,9 +27,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Picking
|
||||
{
|
||||
/**
|
||||
* An interface concrete shape types can implement to create specific BoundShapeInterfaces.
|
||||
*/
|
||||
//! An interface concrete shape types can implement to create specific BoundShapeInterfaces.
|
||||
class BoundRequestShapeBase
|
||||
{
|
||||
public:
|
||||
@@ -114,11 +112,9 @@ namespace AzToolsFramework
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
/**
|
||||
* The quad shape consists of 4 points in 3D space. Please set them from \ref m_corner1 to \ref m_corner4
|
||||
* in either clock-wise winding or counter clock-wise winding. In another word, \ref m_corner1 and
|
||||
* \ref corner_2 cannot be diagonal corners.
|
||||
*/
|
||||
//! The quad shape consists of 4 points in 3D space. Please set them from \ref m_corner1 to \ref m_corner4
|
||||
//! in either clock-wise winding or counter clock-wise winding. In another word, \ref m_corner1 and
|
||||
//! \ref corner_2 cannot be diagonal corners.
|
||||
class BoundShapeQuad : public BoundRequestShapeBase
|
||||
{
|
||||
public:
|
||||
@@ -138,9 +134,7 @@ namespace AzToolsFramework
|
||||
AZ::Vector3 m_corner4;
|
||||
};
|
||||
|
||||
/**
|
||||
* The line segment consists of two points in 3D space defining a line the user can interact with.
|
||||
*/
|
||||
//! The line segment consists of two points in 3D space defining a line the user can interact with.
|
||||
class BoundShapeLineSegment : public BoundRequestShapeBase
|
||||
{
|
||||
public:
|
||||
@@ -159,10 +153,8 @@ namespace AzToolsFramework
|
||||
float m_width;
|
||||
};
|
||||
|
||||
/**
|
||||
* The torus shape is approximated by a cylinder whose radius is the sum of the torus's major radius
|
||||
* and minor radius and height is twice the torus's minor radius.
|
||||
*/
|
||||
//! The torus shape is approximated by a cylinder whose radius is the sum of the torus's major radius
|
||||
//! and minor radius and height is twice the torus's minor radius.
|
||||
class BoundShapeTorus : public BoundRequestShapeBase
|
||||
{
|
||||
public:
|
||||
@@ -182,10 +174,8 @@ namespace AzToolsFramework
|
||||
float m_minorRadius;
|
||||
};
|
||||
|
||||
/**
|
||||
* The spline is specified by a number of vertices. A piecewise approximation of the curve
|
||||
* is computed by using a number of linear steps (defined by the granularity of the curve).
|
||||
*/
|
||||
//! The spline is specified by a number of vertices. A piecewise approximation of the curve
|
||||
//! is computed by using a number of linear steps (defined by the granularity of the curve).
|
||||
class BoundShapeSpline : public BoundRequestShapeBase
|
||||
{
|
||||
public:
|
||||
@@ -204,16 +194,14 @@ namespace AzToolsFramework
|
||||
float m_width;
|
||||
};
|
||||
|
||||
/**
|
||||
* Ray query for intersection against bounds.
|
||||
*/
|
||||
//! Ray query for intersection against bounds.
|
||||
struct RaySelectInfo
|
||||
{
|
||||
AZ::Vector3 m_origin; ///< Start of ray.
|
||||
AZ::Vector3 m_direction; ///< Direction of ray - make sure m_direction is unit length.
|
||||
AZStd::vector<AZStd::pair<RegisteredBoundId, float>> m_boundIdsHit; ///< Store the id of the intersected bound
|
||||
///< and the parameter of the corresponding
|
||||
///< intersecting point.
|
||||
AZ::Vector3 m_origin; //!< Start of ray.
|
||||
AZ::Vector3 m_direction; //!< Direction of ray - make sure m_direction is unit length.
|
||||
AZStd::vector<AZStd::pair<RegisteredBoundId, float>> m_boundIdsHit; //!< Store the id of the intersected bound
|
||||
//!< and the parameter of the corresponding
|
||||
//!< intersecting point.
|
||||
};
|
||||
} // namespace Picking
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+18
-23
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ManipulatorBoundManager.h"
|
||||
|
||||
@@ -16,8 +16,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Picking
|
||||
{
|
||||
RegisteredBoundId ManipulatorBoundManager::UpdateOrRegisterBound(
|
||||
const BoundRequestShapeBase& shapeData, RegisteredBoundId boundId)
|
||||
RegisteredBoundId ManipulatorBoundManager::UpdateOrRegisterBound(const BoundRequestShapeBase& shapeData, RegisteredBoundId boundId)
|
||||
{
|
||||
if (boundId == InvalidBoundId)
|
||||
{
|
||||
@@ -25,8 +24,7 @@ namespace AzToolsFramework
|
||||
boundId = m_nextBoundId++;
|
||||
}
|
||||
|
||||
if (auto result = m_boundIdToShapeMap.find(boundId);
|
||||
result == m_boundIdToShapeMap.end())
|
||||
if (auto result = m_boundIdToShapeMap.find(boundId); result == m_boundIdToShapeMap.end())
|
||||
{
|
||||
if (AZStd::shared_ptr<BoundShapeInterface> createdShape = CreateShape(shapeData, boundId))
|
||||
{
|
||||
@@ -49,19 +47,16 @@ namespace AzToolsFramework
|
||||
|
||||
void ManipulatorBoundManager::UnregisterBound(const RegisteredBoundId boundId)
|
||||
{
|
||||
if (const auto findIter = m_boundIdToShapeMap.find(boundId);
|
||||
findIter != m_boundIdToShapeMap.end())
|
||||
if (const auto findIter = m_boundIdToShapeMap.find(boundId); findIter != m_boundIdToShapeMap.end())
|
||||
{
|
||||
DeleteShape(findIter->second.get());
|
||||
m_boundIdToShapeMap.erase(findIter);
|
||||
}
|
||||
}
|
||||
|
||||
void ManipulatorBoundManager::SetBoundValidity(
|
||||
const RegisteredBoundId boundId, const bool valid)
|
||||
void ManipulatorBoundManager::SetBoundValidity(const RegisteredBoundId boundId, const bool valid)
|
||||
{
|
||||
if (auto found = m_boundIdToShapeMap.find(boundId);
|
||||
found != m_boundIdToShapeMap.end())
|
||||
if (auto found = m_boundIdToShapeMap.find(boundId); found != m_boundIdToShapeMap.end())
|
||||
{
|
||||
found->second->SetValidity(valid);
|
||||
}
|
||||
@@ -104,9 +99,9 @@ namespace AzToolsFramework
|
||||
const auto hitItr = AZStd::lower_bound(
|
||||
rayHits.begin(), rayHits.end(), BoundIdHitDistance(0, t),
|
||||
[](const BoundIdHitDistance& lhs, const BoundIdHitDistance& rhs)
|
||||
{
|
||||
return lhs.second < rhs.second;
|
||||
});
|
||||
{
|
||||
return lhs.second < rhs.second;
|
||||
});
|
||||
|
||||
rayHits.insert(hitItr, AZStd::make_pair(bound->GetBoundId(), t));
|
||||
}
|
||||
|
||||
+17
-21
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
* 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
|
||||
|
||||
@@ -21,10 +21,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
class BoundShapeInterface;
|
||||
|
||||
/**
|
||||
* Handle creating, destroying and storing all active manipulator
|
||||
* bounds for performing raycasts/picking against.
|
||||
*/
|
||||
//! Handle creating, destroying and storing all active manipulator
|
||||
//! bounds for performing raycasts/picking against.
|
||||
class ManipulatorBoundManager
|
||||
{
|
||||
public:
|
||||
@@ -35,21 +33,19 @@ namespace AzToolsFramework
|
||||
ManipulatorBoundManager& operator=(const ManipulatorBoundManager&) = delete;
|
||||
~ManipulatorBoundManager() = default;
|
||||
|
||||
RegisteredBoundId UpdateOrRegisterBound(
|
||||
const BoundRequestShapeBase& shapeData, RegisteredBoundId id);
|
||||
RegisteredBoundId UpdateOrRegisterBound(const BoundRequestShapeBase& shapeData, RegisteredBoundId id);
|
||||
void UnregisterBound(RegisteredBoundId boundId);
|
||||
void SetBoundValidity(RegisteredBoundId boundId, bool valid);
|
||||
void RaySelect(RaySelectInfo &rayInfo);
|
||||
void RaySelect(RaySelectInfo& rayInfo);
|
||||
|
||||
private:
|
||||
AZStd::shared_ptr<BoundShapeInterface> CreateShape(
|
||||
const BoundRequestShapeBase& ptrShape, RegisteredBoundId id);
|
||||
AZStd::shared_ptr<BoundShapeInterface> CreateShape(const BoundRequestShapeBase& ptrShape, RegisteredBoundId id);
|
||||
void DeleteShape(const BoundShapeInterface* boundShape);
|
||||
|
||||
AZStd::unordered_map<RegisteredBoundId, AZStd::shared_ptr<BoundShapeInterface>> m_boundIdToShapeMap;
|
||||
AZStd::vector<AZStd::shared_ptr<BoundShapeInterface>> m_bounds; ///< All current manipulator bounds.
|
||||
AZStd::vector<AZStd::shared_ptr<BoundShapeInterface>> m_bounds; //!< All current manipulator bounds.
|
||||
|
||||
RegisteredBoundId m_nextBoundId = RegisteredBoundId(1); ///< Next bound id to use when a bound is registered.
|
||||
RegisteredBoundId m_nextBoundId = RegisteredBoundId(1); //!< Next bound id to use when a bound is registered.
|
||||
};
|
||||
} // namespace Picking
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+32
-32
@@ -1,17 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Math/IntersectSegment.h>
|
||||
#include <AzCore/Math/Spline.h>
|
||||
#include <AzCore/std/limits.h>
|
||||
#include <AzToolsFramework/Picking/ContextBoundAPI.h>
|
||||
#include <AzToolsFramework/Picking/Manipulators/ManipulatorBounds.h>
|
||||
|
||||
@@ -23,8 +24,7 @@ namespace AzToolsFramework
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection, float& rayIntersectionDistance)
|
||||
{
|
||||
float vecRayIntersectionDistance;
|
||||
if (AZ::Intersect::IntersectRaySphere(
|
||||
rayOrigin, rayDirection, m_center, m_radius, vecRayIntersectionDistance) > 0)
|
||||
if (AZ::Intersect::IntersectRaySphere(rayOrigin, rayDirection, m_center, m_radius, vecRayIntersectionDistance) > 0)
|
||||
{
|
||||
rayIntersectionDistance = vecRayIntersectionDistance;
|
||||
return true;
|
||||
@@ -45,8 +45,9 @@ namespace AzToolsFramework
|
||||
bool ManipulatorBoundBox::IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection, float& rayIntersectionDistance)
|
||||
{
|
||||
return AZ::Intersect::IntersectRayBox(rayOrigin, rayDirection, m_center, m_axis1, m_axis2, m_axis3,
|
||||
m_halfExtents.GetX(), m_halfExtents.GetY(), m_halfExtents.GetZ(), rayIntersectionDistance) > 0;
|
||||
return AZ::Intersect::IntersectRayBox(
|
||||
rayOrigin, rayDirection, m_center, m_axis1, m_axis2, m_axis3, m_halfExtents.GetX(), m_halfExtents.GetY(),
|
||||
m_halfExtents.GetZ(), rayIntersectionDistance) > 0;
|
||||
}
|
||||
|
||||
void ManipulatorBoundBox::SetShapeData(const BoundRequestShapeBase& shapeData)
|
||||
@@ -66,8 +67,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
float t1 = std::numeric_limits<float>::max();
|
||||
float t2 = std::numeric_limits<float>::max();
|
||||
if (AZ::Intersect::IntersectRayCappedCylinder(
|
||||
rayOrigin, rayDirection, m_base, m_axis, m_height, m_radius, t1, t2) > 0)
|
||||
if (AZ::Intersect::IntersectRayCappedCylinder(rayOrigin, rayDirection, m_base, m_axis, m_height, m_radius, t1, t2) > 0)
|
||||
{
|
||||
rayIntersectionDistance = AZStd::GetMin(t1, t2);
|
||||
return true;
|
||||
@@ -92,8 +92,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
float t1 = std::numeric_limits<float>::max();
|
||||
float t2 = std::numeric_limits<float>::max();
|
||||
if (AZ::Intersect::IntersectRayCone(
|
||||
rayOrigin, rayDirection, m_apexPosition, m_dir, m_height, m_radius, t1, t2) > 0)
|
||||
if (AZ::Intersect::IntersectRayCone(rayOrigin, rayDirection, m_apexPosition, m_dir, m_height, m_radius, t1, t2) > 0)
|
||||
{
|
||||
rayIntersectionDistance = AZStd::GetMin(t1, t2);
|
||||
return true;
|
||||
@@ -117,7 +116,7 @@ namespace AzToolsFramework
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection, float& rayIntersectionDistance)
|
||||
{
|
||||
return AZ::Intersect::IntersectRayQuad(
|
||||
rayOrigin, rayDirection, m_corner1, m_corner2, m_corner3, m_corner4, rayIntersectionDistance) > 0;
|
||||
rayOrigin, rayDirection, m_corner1, m_corner2, m_corner3, m_corner4, rayIntersectionDistance) > 0;
|
||||
}
|
||||
|
||||
void ManipulatorBoundQuad::SetShapeData(const BoundRequestShapeBase& shapeData)
|
||||
@@ -157,8 +156,7 @@ namespace AzToolsFramework
|
||||
float rayProportion, lineSegmentProportion;
|
||||
// note: here out param is proportion/percentage of line
|
||||
AZ::Intersect::ClosestSegmentSegment(
|
||||
rayOrigin, rayOrigin + rayDirection * rayLength,
|
||||
m_worldStart, m_worldEnd, rayProportion, lineSegmentProportion,
|
||||
rayOrigin, rayOrigin + rayDirection * rayLength, m_worldStart, m_worldEnd, rayProportion, lineSegmentProportion,
|
||||
closestPosRay, closestPosLineSegment);
|
||||
|
||||
float distanceFromLine = (closestPosRay - closestPosLineSegment).GetLength();
|
||||
@@ -188,8 +186,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
if (const AZStd::shared_ptr<const AZ::Spline> spline = m_spline.lock())
|
||||
{
|
||||
AZ::RaySplineQueryResult splineQueryResult =
|
||||
AZ::IntersectSpline(m_transform, rayOrigin, rayDirection, *spline);
|
||||
AZ::RaySplineQueryResult splineQueryResult = AZ::IntersectSpline(m_transform, rayOrigin, rayDirection, *spline);
|
||||
|
||||
if (splineQueryResult.m_distanceSq <= m_width * m_width)
|
||||
{
|
||||
@@ -214,22 +211,25 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
bool IntersectHollowCylinder(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection,
|
||||
const AZ::Vector3& center, const AZ::Vector3& axis,
|
||||
const float minorRadius, const float majorRadius,
|
||||
const AZ::Vector3& rayOrigin,
|
||||
const AZ::Vector3& rayDirection,
|
||||
const AZ::Vector3& center,
|
||||
const AZ::Vector3& axis,
|
||||
const float minorRadius,
|
||||
const float majorRadius,
|
||||
float& rayIntersectionDistance)
|
||||
{
|
||||
float t1 = std::numeric_limits<float>::max();
|
||||
float t2 = std::numeric_limits<float>::max();
|
||||
float t1 = AZStd::numeric_limits<float>::max();
|
||||
float t2 = AZStd::numeric_limits<float>::max();
|
||||
const AZ::Vector3 base = center - axis * minorRadius;
|
||||
|
||||
if (AZ::Intersect::IntersectRayCappedCylinder(
|
||||
rayOrigin, rayDirection, base, axis, minorRadius * 2.0f, majorRadius + minorRadius, t1, t2) > 0)
|
||||
rayOrigin, rayDirection, base, axis, minorRadius * 2.0f, majorRadius + minorRadius, t1, t2) > 0)
|
||||
{
|
||||
const float thresholdSq = powf(majorRadius - minorRadius, 2.0f);
|
||||
const float threshold = majorRadius - minorRadius;
|
||||
const float thresholdSq = threshold * threshold;
|
||||
// util lambda used for distance checks at both 't' values
|
||||
const auto validHolowCylinderHit =
|
||||
[&rayOrigin, &rayDirection, ¢er, thresholdSq](const float t)
|
||||
const auto validHolowCylinderHit = [&rayOrigin, &rayDirection, ¢er, thresholdSq](const float t)
|
||||
{
|
||||
// only return a valid intersection if the hit was
|
||||
// not in the 'hollow' part of the cylinder
|
||||
|
||||
+63
-62
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
* 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
|
||||
|
||||
@@ -27,36 +27,36 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Picking
|
||||
{
|
||||
class ManipulatorBoundSphere
|
||||
: public BoundShapeInterface
|
||||
class ManipulatorBoundSphere : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundSphere, "{64D1B863-F574-4B31-A4F2-C9744D8567B3}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundSphere, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundSphere(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
AZ::Vector3 m_center = AZ::Vector3::CreateZero();
|
||||
float m_radius = 0.0f;
|
||||
};
|
||||
|
||||
class ManipulatorBoundBox
|
||||
: public BoundShapeInterface
|
||||
class ManipulatorBoundBox : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundBox, "{3AD46067-933F-49B4-82E1-DBF12C7BC02E}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundBox, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundBox(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
AZ::Vector3 m_center = AZ::Vector3::CreateZero();
|
||||
@@ -66,38 +66,38 @@ namespace AzToolsFramework
|
||||
AZ::Vector3 m_halfExtents = AZ::Vector3::CreateZero();
|
||||
};
|
||||
|
||||
class ManipulatorBoundCylinder
|
||||
: public BoundShapeInterface
|
||||
class ManipulatorBoundCylinder : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundCylinder, "{D248F9E4-22E6-41A8-898D-704DF307B533}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundCylinder, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundCylinder(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
AZ::Vector3 m_base = AZ::Vector3::CreateZero(); ///< The center of the circle at the base of the cylinder.
|
||||
AZ::Vector3 m_base = AZ::Vector3::CreateZero(); //!< The center of the circle at the base of the cylinder.
|
||||
AZ::Vector3 m_axis = AZ::Vector3::CreateZero();
|
||||
float m_height = 0.0f;
|
||||
float m_radius = 0.0f;
|
||||
};
|
||||
|
||||
class ManipulatorBoundCone
|
||||
: public BoundShapeInterface
|
||||
class ManipulatorBoundCone : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundCone, "{9430440D-DFF2-4A60-9073-507C4E9DD65D}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundCone, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundCone(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
AZ::Vector3 m_apexPosition = AZ::Vector3::CreateZero();
|
||||
@@ -106,23 +106,21 @@ namespace AzToolsFramework
|
||||
float m_height = 0.0f;
|
||||
};
|
||||
|
||||
/**
|
||||
* The quad shape consists of 4 points in 3D space. Please set them from \ref m_corner1 to \ref m_corner4
|
||||
* in either clock-wise winding or counter clock-wise winding. In another word, \ref m_corner1 and
|
||||
* \ref corner_2 cannot be diagonal corners.
|
||||
*/
|
||||
class ManipulatorBoundQuad
|
||||
: public BoundShapeInterface
|
||||
//! The quad shape consists of 4 points in 3D space. Please set them from \ref m_corner1 to \ref m_corner4
|
||||
//! in either clock-wise winding or counter clock-wise winding. In another word, \ref m_corner1 and
|
||||
//! \ref corner_2 cannot be diagonal corners.
|
||||
class ManipulatorBoundQuad : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundQuad, "{3CDED61C-5786-4299-B5F2-5970DE4457AD}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundQuad, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundQuad(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
AZ::Vector3 m_corner1 = AZ::Vector3::CreateZero();
|
||||
@@ -131,18 +129,18 @@ namespace AzToolsFramework
|
||||
AZ::Vector3 m_corner4 = AZ::Vector3::CreateZero();
|
||||
};
|
||||
|
||||
class ManipulatorBoundTorus
|
||||
: public BoundShapeInterface
|
||||
class ManipulatorBoundTorus : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundTorus, "{46E4711C-178A-4F97-BC14-A048D096E7A1}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundTorus, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundTorus(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
// Approximate a torus as a thin cylinder. A ray intersects a torus when the ray and the torus'
|
||||
@@ -150,22 +148,22 @@ namespace AzToolsFramework
|
||||
// center of the torus.
|
||||
AZ::Vector3 m_center = AZ::Vector3::CreateZero();
|
||||
AZ::Vector3 m_axis = AZ::Vector3::CreateZero();
|
||||
float m_majorRadius = 0.0f; ///< Usually denoted as "R", the distance from the center of the tube to the center of the torus.
|
||||
float m_minorRadius = 0.0f; ///< Usually denoted as "r", the radius of the tube.
|
||||
float m_majorRadius = 0.0f; //!< Usually denoted as "R", the distance from the center of the tube to the center of the torus.
|
||||
float m_minorRadius = 0.0f; //!< Usually denoted as "r", the radius of the tube.
|
||||
};
|
||||
|
||||
class ManipulatorBoundLineSegment
|
||||
: public BoundShapeInterface
|
||||
class ManipulatorBoundLineSegment : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundLineSegment, "{66801554-1C1A-4E79-B1E7-342DFA779D53}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundLineSegment, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundLineSegment(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
AZ::Vector3 m_worldStart = AZ::Vector3::CreateZero();
|
||||
@@ -173,18 +171,18 @@ namespace AzToolsFramework
|
||||
float m_width = 0.0f;
|
||||
};
|
||||
|
||||
class ManipulatorBoundSpline
|
||||
: public BoundShapeInterface
|
||||
class ManipulatorBoundSpline : public BoundShapeInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ManipulatorBoundSpline, "{777760FF-8547-45AD-876F-16BA4D9D0584}", BoundShapeInterface);
|
||||
AZ_CLASS_ALLOCATOR(ManipulatorBoundSpline, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ManipulatorBoundSpline(RegisteredBoundId boundId)
|
||||
: BoundShapeInterface(boundId) {}
|
||||
: BoundShapeInterface(boundId)
|
||||
{
|
||||
}
|
||||
|
||||
bool IntersectRay(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
bool IntersectRay(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDir, float& rayIntersectionDistance) override;
|
||||
void SetShapeData(const BoundRequestShapeBase& shapeData) override;
|
||||
|
||||
AZStd::weak_ptr<const AZ::Spline> m_spline;
|
||||
@@ -192,11 +190,14 @@ namespace AzToolsFramework
|
||||
float m_width = 0.0f;
|
||||
};
|
||||
|
||||
/// Approximate intersection with a torus-like shape.
|
||||
//! Approximate intersection with a torus-like shape.
|
||||
bool IntersectHollowCylinder(
|
||||
const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection,
|
||||
const AZ::Vector3& center, const AZ::Vector3& axis,
|
||||
float minorRadius, float majorRadius,
|
||||
const AZ::Vector3& rayOrigin,
|
||||
const AZ::Vector3& rayDirection,
|
||||
const AZ::Vector3& center,
|
||||
const AZ::Vector3& axis,
|
||||
float minorRadius,
|
||||
float majorRadius,
|
||||
float& rayIntersectionDistance);
|
||||
|
||||
} // namespace Picking
|
||||
|
||||
Reference in New Issue
Block a user