Explorar o código

Addressing PR

Signed-off-by: Olex Lozitskiy <[email protected]>
Olex Lozitskiy %!s(int64=3) %!d(string=hai) anos
pai
achega
b10294e7de

+ 2 - 1
Gems/RecastNavigation/Code/Source/Components/DetourNavigationComponent.cpp

@@ -73,7 +73,8 @@ namespace RecastNavigation
         }
 
         AZStd::vector<AZ::Vector3> pathPoints;
-        RecastVector3 startRecast{ fromWorldPosition }, endRecast{ toWorldPosition };
+        RecastVector3 startRecast = RecastVector3::CreateFromVector3SwapYZ(fromWorldPosition);
+        RecastVector3 endRecast = RecastVector3::CreateFromVector3SwapYZ(toWorldPosition);
         const float halfExtents[3] = { m_nearestDistance, m_nearestDistance, m_nearestDistance };
 
         dtPolyRef startPoly = 0, endPoly = 0;

+ 13 - 11
Gems/RecastNavigation/Code/Source/Misc/RecastHelpers.h

@@ -7,12 +7,10 @@
  */
 
 #pragma once
-#include <DetourAlloc.h>
-#include <Recast.h>
 #include <AzCore/Math/Aabb.h>
 #include <AzCore/Math/Vector3.h>
-#include <AzCore/std/smart_ptr/shared_ptr.h>
 #include <AzCore/std/function/function_template.h>
+#include <AzCore/std/smart_ptr/shared_ptr.h>
 
 namespace RecastNavigation
 {
@@ -24,19 +22,23 @@ namespace RecastNavigation
         RecastVector3() = default;
 
         //! A constructor from O3DE coordinate values.
-        explicit RecastVector3(const AZ::Vector3& in)
+        static RecastVector3 CreateFromVector3SwapYZ(const AZ::Vector3& in)
         {
-            m_xyz[0] = in.GetX();
-            m_xyz[1] = in.GetZ(); // swapping y and z
-            m_xyz[2] = in.GetY();
+            RecastVector3 out;
+            out.m_xyz[0] = in.GetX(),
+            out.m_xyz[1] = in.GetZ(),
+            out.m_xyz[2] = in.GetY();
+            return out;
         }
 
         //! A constructor from Recast coordinate values.
-        explicit RecastVector3(const float* data)
+        static RecastVector3 CreateFromFloatSwapYZ(const float* data)
         {
-            m_xyz[0] = data[0];
-            m_xyz[1] = data[1];
-            m_xyz[2] = data[2];
+            RecastVector3 out;
+            out.m_xyz[0] = data[0];
+            out.m_xyz[1] = data[1];
+            out.m_xyz[2] = data[2];
+            return out;
         }
 
         //! @returns raw data without any conversion between coordinate systems. Useful when working with Recast library API.

+ 1 - 1
Gems/RecastNavigation/Code/Source/Misc/RecastNavigationDebugDraw.cpp

@@ -110,7 +110,7 @@ namespace RecastNavigation
     void RecastNavigationDebugDraw::AddVertex(float x, float y, float z, unsigned color)
     {
         const float temp[3] = { x, y, z };
-        const RecastVector3 v(temp);
+        const RecastVector3 v = RecastVector3::CreateFromFloatSwapYZ(temp);
         m_verticesToDraw.emplace_back(v.AsVector3WithZup(), color);
     }
 } // namespace RecastNavigation

+ 3 - 3
Gems/RecastNavigation/Code/Source/Misc/RecastNavigationMeshCommon.cpp

@@ -65,8 +65,8 @@ namespace RecastNavigation
         // Here the bounds of the input mesh are used, but the
         // area could be specified by an user defined box, etc.
 
-        const RecastVector3 worldMin(geom->m_worldBounds.GetMin());
-        const RecastVector3 worldMax(geom->m_worldBounds.GetMax());
+        const RecastVector3 worldMin = RecastVector3::CreateFromVector3SwapYZ(geom->m_worldBounds.GetMin());
+        const RecastVector3 worldMax = RecastVector3::CreateFromVector3SwapYZ(geom->m_worldBounds.GetMax());
 
         rcVcopy(config.bmin, worldMin.m_xyz);
         rcVcopy(config.bmax, worldMax.m_xyz);
@@ -307,7 +307,7 @@ namespace RecastNavigation
         dtNavMeshParams params = {};
         RecastNavigationProviderRequestBus::EventResult(worldVolume, meshEntityId, &RecastNavigationProviderRequests::GetWorldBounds);
 
-        const RecastVector3 worldCenter(worldVolume.GetMin());
+        const RecastVector3 worldCenter = RecastVector3::CreateFromVector3SwapYZ(worldVolume.GetMin());
         rcVcopy(params.orig, worldCenter.m_xyz);
 
         RecastNavigationProviderRequestBus::EventResult(params.maxTiles, meshEntityId, &RecastNavigationProviderRequests::GetNumberOfTiles, tileSize);

+ 2 - 2
Gems/RecastNavigation/Code/Source/Misc/RecastNavigationPhysXProviderCommon.cpp

@@ -110,7 +110,7 @@ namespace RecastNavigation
                     for (const AZ::Vector3& vertex : vertices)
                     {
                         const AZ::Vector3 translated = t.TransformPoint(vertex);
-                        geometry.m_vertices.push_back(RecastVector3(translated));
+                        geometry.m_vertices.push_back(RecastVector3::CreateFromVector3SwapYZ(translated));
 
                         if (cl_navmesh_showInputData || debugDrawInputData)
                         {
@@ -141,7 +141,7 @@ namespace RecastNavigation
                     for (const AZ::Vector3& vertex : vertices)
                     {
                         const AZ::Vector3 translated = t.TransformPoint(vertex);
-                        geometry.m_vertices.push_back(RecastVector3(translated));
+                        geometry.m_vertices.push_back(RecastVector3::CreateFromVector3SwapYZ(translated));
 
                         if (cl_navmesh_showInputData || debugDrawInputData)
                         {