From cad57533279572e9d0a30ec351970e20c63f9cba Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Tue, 25 Apr 2023 09:04:02 +0200 Subject: [PATCH] fix gizmo drawing issue happens due to a null world object --- .../SenseGlove/Components/SGWristTrackerComponent.cpp | 6 ++++-- .../SenseGloveDebug/Private/SGDebug/SGDebugGizmo.cpp | 10 +++------- Source/SenseGloveDebug/Public/SGDebug/SGDebugGizmo.h | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp index 43b6149a..8844460c 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp @@ -746,6 +746,7 @@ void USGWristTrackerComponent::FImpl::UpdateWristTrackingData() const void USGWristTrackerComponent::FImpl::DrawDebugGizmo() { + const UWorld* World{Owner->GetWorld()}; const FVector& Location{Owner->GetComponentLocation()}; const FRotator& Rotation{Owner->GetComponentRotation()}; const float Length = Owner->GetDebugWristTrackerGizmoLength(); @@ -757,8 +758,9 @@ void USGWristTrackerComponent::FImpl::DrawDebugGizmo() const FColor& YAxisColor{Owner->GetDebugWristTrackerGizmoYAxisColor()}; const FColor& ZAxisColor{Owner->GetDebugWristTrackerGizmoZAxisColor()}; - FSGDebugGizmo::Draw(Location, Rotation, Length, Thickness, XAxisColor, YAxisColor, ZAxisColor, - bPersistentLines, LifeTimeModifier, DepthPriority); + FSGDebugGizmo::Draw(World, Location, Rotation, Length, Thickness, + XAxisColor, YAxisColor, ZAxisColor, + bPersistentLines, LifeTimeModifier, DepthPriority); } void USGWristTrackerComponent::FImplDeleter::operator()(const FImpl* P) const diff --git a/Source/SenseGloveDebug/Private/SGDebug/SGDebugGizmo.cpp b/Source/SenseGloveDebug/Private/SGDebug/SGDebugGizmo.cpp index 46a15e00..a718006e 100644 --- a/Source/SenseGloveDebug/Private/SGDebug/SGDebugGizmo.cpp +++ b/Source/SenseGloveDebug/Private/SGDebug/SGDebugGizmo.cpp @@ -36,24 +36,20 @@ #include "SGDebug/SGDebugGizmo.h" #include "DrawDebugHelpers.h" -#include "Engine/Engine.h" #include "Kismet/GameplayStatics.h" #include "Math/Color.h" #include "Math/Rotator.h" #include "Math/Vector.h" +#include "SGLog/SGLog.h" + void FSGDebugGizmo::Draw( + const UWorld* World, const FVector& Location, const FRotator& Rotation, const float Length, const float Thickness, const FColor& XAxisColor, const FColor& YAxisColor, const FColor& ZAxisColor, const bool bPersistentLines, const float LifeTimeModifier, const uint8 DepthPriority) { - if (!GEngine) - { - return; - } - - const UWorld* World{GEngine->GetWorld()}; const float LifeTime = UGameplayStatics::GetWorldDeltaSeconds(World) * LifeTimeModifier; const FVector XAxisLineEnd(Location + Rotation.RotateVector(FVector(Length, 0.0f, 0.0f))); diff --git a/Source/SenseGloveDebug/Public/SGDebug/SGDebugGizmo.h b/Source/SenseGloveDebug/Public/SGDebug/SGDebugGizmo.h index e0f2eeec..1343c17f 100644 --- a/Source/SenseGloveDebug/Public/SGDebug/SGDebugGizmo.h +++ b/Source/SenseGloveDebug/Public/SGDebug/SGDebugGizmo.h @@ -39,6 +39,7 @@ class SENSEGLOVEDEBUG_API FSGDebugGizmo final { public: static void Draw( + const UWorld* World, const FVector& Location, const FRotator& Rotation, float Length = 1.0f, float Thickness = 1.0f,