refactor the debug gizmo draw method
This commit is contained in:
@@ -117,11 +117,11 @@ USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& Obj
|
||||
bOverridePluginWristTrackingDebugSettings = false;
|
||||
bDrawWristTrackerDebugGizmo = false;
|
||||
WristTrackerDebugGizmoSettings = FSGDebugGizmoSettings(
|
||||
4.0f, 1.0f,
|
||||
FColor(1.0f, 0.0f, 0.0f, 1.0f),
|
||||
FColor(0.0f, 1.0f, 0.0f, 1.0f),
|
||||
FColor(0.0f, 0.0f, 1.0f, 1.0f),
|
||||
false, 1.1f, 0
|
||||
4.0f, 1.0f,
|
||||
FColor(1.0f, 0.0f, 0.0f, 1.0f),
|
||||
FColor(0.0f, 1.0f, 0.0f, 1.0f),
|
||||
FColor(0.0f, 0.0f, 1.0f, 1.0f),
|
||||
false, 1.1f, 0
|
||||
);
|
||||
bDrawWristTrackerDebugGizmo = false;
|
||||
|
||||
@@ -539,11 +539,7 @@ void USGWristTrackerComponent::FImpl::DrawDebugGizmo()
|
||||
const FRotator& Rotation{Owner->GetComponentRotation()};
|
||||
const FSGDebugGizmoSettings& DebugGizmoSettings{Owner->GetWristTrackerDebugGizmoSettings()};
|
||||
|
||||
FSGDebugGizmo::Draw(
|
||||
World, Location, Rotation,
|
||||
DebugGizmoSettings.Length, DebugGizmoSettings.Thickness,
|
||||
DebugGizmoSettings.XAxisColor, DebugGizmoSettings.YAxisColor, DebugGizmoSettings.ZAxisColor,
|
||||
DebugGizmoSettings.bPersistentLines, DebugGizmoSettings.LifeTimeModifier, DebugGizmoSettings.DepthPriority);
|
||||
FSGDebugGizmo::Draw(World, Location, Rotation, DebugGizmoSettings);
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::FImplDeleter::operator()(const FImpl* P) const
|
||||
|
||||
@@ -41,23 +41,20 @@
|
||||
#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)
|
||||
void FSGDebugGizmo::Draw(const UWorld* World, const FVector& Location, const FRotator& Rotation,
|
||||
const FSGDebugGizmoSettings& Settings)
|
||||
{
|
||||
const float LifeTime = UGameplayStatics::GetWorldDeltaSeconds(World) * LifeTimeModifier;
|
||||
const float LifeTime = UGameplayStatics::GetWorldDeltaSeconds(World) * Settings.LifeTimeModifier;
|
||||
|
||||
const FVector XAxisLineEnd(Location + Rotation.RotateVector(FVector(Length, 0.0f, 0.0f)));
|
||||
DrawDebugLine(World, Location, XAxisLineEnd, XAxisColor, bPersistentLines, LifeTime, DepthPriority, Thickness);
|
||||
const FVector XAxisLineEnd(Location + Rotation.RotateVector(FVector(Settings.Length, 0.0f, 0.0f)));
|
||||
DrawDebugLine(World, Location, XAxisLineEnd,
|
||||
Settings.XAxisColor, Settings.bPersistentLines, LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
|
||||
const FVector YAxisLineEnd(Location + Rotation.RotateVector(FVector{0.0f, Length, 0.0f}));
|
||||
DrawDebugLine(World, Location, YAxisLineEnd, YAxisColor, bPersistentLines, LifeTime, DepthPriority, Thickness);
|
||||
const FVector YAxisLineEnd(Location + Rotation.RotateVector(FVector{0.0f, Settings.Length, 0.0f}));
|
||||
DrawDebugLine(World, Location, YAxisLineEnd,
|
||||
Settings.YAxisColor, Settings.bPersistentLines, LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
|
||||
const FVector ZAxisLineEnd{Location + Rotation.RotateVector(FVector{0.0f, 0.0f, Length})};
|
||||
DrawDebugLine(World, Location, ZAxisLineEnd, ZAxisColor, bPersistentLines, LifeTime, DepthPriority, Thickness);
|
||||
const FVector ZAxisLineEnd{Location + Rotation.RotateVector(FVector{0.0f, 0.0f, Settings.Length})};
|
||||
DrawDebugLine(World, Location, ZAxisLineEnd,
|
||||
Settings.ZAxisColor, Settings.bPersistentLines, LifeTime, Settings.DepthPriority, Settings.Thickness);
|
||||
}
|
||||
@@ -35,20 +35,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SGSettings/SGDebugGizmoSettings.h"
|
||||
|
||||
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,
|
||||
const FColor& XAxisColor = FColor(1.0f, 0.0f, 0.0f, 1.0f),
|
||||
const FColor& YAxisColor = FColor(0.0f, 1.0f, 0.0f, 1.0f),
|
||||
const FColor& ZAxisColor = FColor(0.0f, 0.0f, 1.0f, 1.0f),
|
||||
bool bPersistentLines = false,
|
||||
float LifeTimeModifier = 1.1f,
|
||||
uint8 DepthPriority = 0);
|
||||
const FSGDebugGizmoSettings& Settings);
|
||||
|
||||
public:
|
||||
FSGDebugGizmo() = delete;
|
||||
|
||||
@@ -55,6 +55,7 @@ public class SenseGloveDebug : ModuleRules
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"SenseGloveLog",
|
||||
"SenseGloveSettings",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user