fix gizmo drawing issue happens due to a null world object

This commit is contained in:
Mamadou Babaei
2023-04-25 09:04:02 +02:00
parent 9aebd23166
commit bce072931a
3 changed files with 8 additions and 9 deletions
@@ -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
@@ -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)));
@@ -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,