Skip to content

Commit 0120869

Browse files
author
Adrien GIVRY
committed
Fixing wrong ScreenDirection when very close to an actor
1 parent f046a1f commit 0120869

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Sources/Overload/OvEditor/src/OvEditor/Core/GizmoBehaviour.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ OvMaths::FVector3 OvEditor::Core::GizmoBehaviour::GetRealDirection(bool p_relati
6363

6464
OvMaths::FVector2 OvEditor::Core::GizmoBehaviour::GetScreenDirection(const OvMaths::FMatrix4& p_viewMatrix, const OvMaths::FMatrix4& p_projectionMatrix, const OvMaths::FVector2& p_viewSize) const
6565
{
66-
auto start = m_target->transform.GetWorldPosition();
67-
auto end = m_target->transform.GetWorldPosition() + GetRealDirection(true);
66+
auto start = m_originalTransform.GetWorldPosition();
67+
auto end = m_originalTransform.GetWorldPosition() + GetRealDirection(true) * 0.01f;
6868

6969
auto start2D = OvMaths::FVector2();
7070
{
7171
auto clipSpacePos = p_projectionMatrix * (p_viewMatrix * OvMaths::FVector4{ start.x, start.y, start.z, 1.0f });
7272
auto ndcSpacePos = OvMaths::FVector3{ clipSpacePos.x, clipSpacePos.y, clipSpacePos.z } / clipSpacePos.w;
73-
auto windowSpacePos = ((OvMaths::FVector2{ ndcSpacePos.x, ndcSpacePos.y } +1.0) / 2.0);
73+
auto windowSpacePos = ((OvMaths::FVector2{ ndcSpacePos.x, ndcSpacePos.y } + 1.0f) / 2.0f);
7474
windowSpacePos.x *= p_viewSize.x;
7575
windowSpacePos.y *= p_viewSize.y;
7676
start2D = windowSpacePos;
@@ -80,7 +80,7 @@ OvMaths::FVector2 OvEditor::Core::GizmoBehaviour::GetScreenDirection(const OvMat
8080
{
8181
auto clipSpacePos = p_projectionMatrix * (p_viewMatrix * OvMaths::FVector4{ end.x, end.y, end.z, 1.0f });
8282
auto ndcSpacePos = OvMaths::FVector3{ clipSpacePos.x, clipSpacePos.y, clipSpacePos.z } / clipSpacePos.w;
83-
auto windowSpacePos = ((OvMaths::FVector2{ ndcSpacePos.x, ndcSpacePos.y } +1.0) / 2.0);
83+
auto windowSpacePos = ((OvMaths::FVector2{ ndcSpacePos.x, ndcSpacePos.y } + 1.0f) / 2.0f);
8484
windowSpacePos.x *= p_viewSize.x;
8585
windowSpacePos.y *= p_viewSize.y;
8686
end2D = windowSpacePos;

0 commit comments

Comments
 (0)