From ba701eb4d35a99a1c1c472e5de8dafcd7f8531ae Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 19 Sep 2024 17:04:31 +0200 Subject: [PATCH] Fix compilation warnings on large worlds --- Source/Engine/AI/BehaviorTreeNodes.cpp | 8 ++++---- Source/Engine/Core/Math/Quaternion.cpp | 4 +--- Source/Engine/Physics/Physics.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Source/Engine/AI/BehaviorTreeNodes.cpp b/Source/Engine/AI/BehaviorTreeNodes.cpp index e5b9d8d60..2833cf624 100644 --- a/Source/Engine/AI/BehaviorTreeNodes.cpp +++ b/Source/Engine/AI/BehaviorTreeNodes.cpp @@ -396,8 +396,8 @@ void BehaviorTreeMoveToNode::GetAgentSize(Actor* agent, float& outRadius, float& // Estimate actor bounds to extract capsule information const BoundingBox box = agent->GetBox(); const BoundingSphere sphere = agent->GetSphere(); - outRadius = sphere.Radius; - outHeight = box.GetSize().Y; + outRadius = (float)sphere.Radius; + outHeight = (float)box.GetSize().Y; } int32 BehaviorTreeMoveToNode::GetStateSize() const @@ -522,7 +522,7 @@ String BehaviorTreeMoveToNode::GetDebugInfo(const BehaviorUpdateContext& context goal = state->GoalLocation.ToString(); const Vector3 agentLocation = state->Agent->GetPosition(); const Vector3 agentLocationOnPath = agentLocation + state->AgentOffset; - float distanceLeft = state->Path.Count() > state->TargetPathIndex ? Vector3::Distance(state->Path[state->TargetPathIndex], agentLocationOnPath) : 0; + Real distanceLeft = state->Path.Count() > state->TargetPathIndex ? Vector3::Distance(state->Path[state->TargetPathIndex], agentLocationOnPath) : 0; for (int32 i = state->TargetPathIndex; i < state->Path.Count(); i++) distanceLeft += Vector3::Distance(state->Path[i - 1], state->Path[i]); return String::Format(TEXT("Agent: '{}'\nGoal: '{}'\nDistance: {}"), agent, goal, (int32)distanceLeft); @@ -559,7 +559,7 @@ void BehaviorTreeMoveToNode::State::OnUpdate() const float acceptableHeightPercentage = 1.05f; const float testHeight = agentHeight * acceptableHeightPercentage; const Vector3 toGoal = agentLocationOnPath - pathSegmentEnd; - const float toGoalHeightDiff = (toGoal * UpVector).SumValues(); + const Real toGoalHeightDiff = (toGoal * UpVector).SumValues(); if (toGoal.Length() <= testRadius && toGoalHeightDiff <= testHeight) { TargetPathIndex++; diff --git a/Source/Engine/Core/Math/Quaternion.cpp b/Source/Engine/Core/Math/Quaternion.cpp index 46240d4b8..14fbd6a2e 100644 --- a/Source/Engine/Core/Math/Quaternion.cpp +++ b/Source/Engine/Core/Math/Quaternion.cpp @@ -542,10 +542,8 @@ void Quaternion::RotationYawPitchRoll(float yaw, float pitch, float roll, Quater Quaternion Quaternion::GetRotationFromNormal(const Vector3& normal, const Transform& reference) { Float3 up = reference.GetUp(); - const float dot = Vector3::Dot(normal, up); + const Real dot = Vector3::Dot(normal, up); if (Math::NearEqual(Math::Abs(dot), 1)) - { up = reference.GetRight(); - } return Quaternion::LookRotation(normal, up); } diff --git a/Source/Engine/Physics/Physics.cpp b/Source/Engine/Physics/Physics.cpp index 42a80d440..66d5a76bf 100644 --- a/Source/Engine/Physics/Physics.cpp +++ b/Source/Engine/Physics/Physics.cpp @@ -494,28 +494,28 @@ void PhysicsScene::CollectResults() bool PhysicsScene::LineCast(const Vector3& start, const Vector3& end, uint32 layerMask, bool hitTriggers) { Vector3 directionToEnd = end - start; - const float distanceToEnd = directionToEnd.Length(); + const Real distanceToEnd = directionToEnd.Length(); if (distanceToEnd >= ZeroTolerance) directionToEnd /= distanceToEnd; - return PhysicsBackend::RayCast(_scene, start, directionToEnd, distanceToEnd, layerMask, hitTriggers); + return PhysicsBackend::RayCast(_scene, start, directionToEnd, (float)distanceToEnd, layerMask, hitTriggers); } bool PhysicsScene::LineCast(const Vector3& start, const Vector3& end, RayCastHit& hitInfo, uint32 layerMask, bool hitTriggers) { Vector3 directionToEnd = end - start; - const float distanceToEnd = directionToEnd.Length(); + const Real distanceToEnd = directionToEnd.Length(); if (distanceToEnd >= ZeroTolerance) directionToEnd /= distanceToEnd; - return PhysicsBackend::RayCast(_scene, start, directionToEnd, hitInfo, distanceToEnd, layerMask, hitTriggers); + return PhysicsBackend::RayCast(_scene, start, directionToEnd, hitInfo, (float)distanceToEnd, layerMask, hitTriggers); } bool PhysicsScene::LineCastAll(const Vector3& start, const Vector3& end, Array& results, uint32 layerMask, bool hitTriggers) { Vector3 directionToEnd = end - start; - const float distanceToEnd = directionToEnd.Length(); + const Real distanceToEnd = directionToEnd.Length(); if (distanceToEnd >= ZeroTolerance) directionToEnd /= distanceToEnd; - return PhysicsBackend::RayCastAll(_scene, start, directionToEnd, results, distanceToEnd, layerMask, hitTriggers); + return PhysicsBackend::RayCastAll(_scene, start, directionToEnd, results, (float)distanceToEnd, layerMask, hitTriggers); } bool PhysicsScene::RayCast(const Vector3& origin, const Vector3& direction, const float maxDistance, uint32 layerMask, bool hitTriggers)