From b1f1014a5e72e0d4e5ef10fa809d3ca9b9b00fe9 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Wed, 22 Mar 2023 15:24:11 +0100 Subject: [PATCH] fix multiple issues with the virtual hand component and the plugin settings --- .../Components/SGVirtualHandComponent.cpp | 5 +- .../Components/SGVirtualHandComponent.h | 2 - .../SGVirtualHandComponentKismetLibrary.h | 30 +++---- .../SenseGloveKismet.Build.cs | 2 +- .../Private/SGSettings/SGSettings.cpp | 84 ++++++++++++------- .../Public/SGSettings/SGSettings.h | 18 ++-- 6 files changed, 79 insertions(+), 62 deletions(-) diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp index 39e37a14..30c29512 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp @@ -326,7 +326,6 @@ void USGVirtualHandComponent::EditorTick( (void) Pimpl->CheckGlove(); } - bool USGVirtualHandComponent::IsGloveConnected() const { return Pimpl->CheckGlove(); @@ -445,7 +444,7 @@ FString USGVirtualHandComponent::FImpl::GetDefaultMeshPath() const { FString SkeletalMeshPath; - if (Owner->bRight) + if (Owner->IsRight()) { SkeletalMeshPath = GetDefaultRightHandMeshPath(); } @@ -630,7 +629,7 @@ bool USGVirtualHandComponent::FImpl::CheckGlove() const if (!bFoundGlove && bGloveWasPresent) { SGLOG_ERROR(FString::Printf(TEXT("Could not find a %s glove!"), - (Owner->bRight ? TEXT("right-handed") : TEXT("left-handed")))); + (Owner->IsRight() ? TEXT("right-handed") : TEXT("left-handed")))); } const bool bIsEditor = IsEditor(); diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h index 1a3cc741..6ccb82ed 100644 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h +++ b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h @@ -48,8 +48,6 @@ #include "SGVirtualHandComponent.generated.h" class USkeletalMesh; -class USkeleton; -class USceneComponent; class USGHandPose; class USGHapticGlove; diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h index 8d989f27..5fcc495d 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h @@ -59,52 +59,52 @@ class SENSEGLOVEKISMET_API UVirtualHandComponentKismetLibrary final : public USG GENERATED_BODY() public: - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") static TArray GetLeftHandFingerBoneNames(); - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") static TArray GetRightHandFingerBoneNames(); - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") static const FName& GetLeftHandFingerBoneName(int32 Finger, int32 Joint); - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") static const FName& GetRightHandFingerBoneName(int32 Finger, int32 Joint); - UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") static bool IsLeft(const USGVirtualHandComponent* VirtualHandComponent); - UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") static bool IsRight(const USGVirtualHandComponent* VirtualHandComponent); - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") static void SetRight(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent, bool bInRight); - UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") static bool IsHiddenInGameIfNoGloveDetected(const USGVirtualHandComponent* VirtualHandComponent); - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") static void SetHiddenIfNoGloveDetected(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent, bool bInHiddenIfNoGloveDetected); - UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") bool IsGloveConnected(const USGVirtualHandComponent* VirtualHandComponent) const; - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") USGHandPose* GetHandPose(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent); - UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") const FName& GetFingerBoneName(const USGVirtualHandComponent* VirtualHandComponent, int32 Finger, int32 Joint) const; - UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") const FTransform& GetFingerBoneRefTransform(const USGVirtualHandComponent* VirtualHandComponent, int32 Finger, int32 Joint) const; - UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") FRotator GetFingerBoneRefRotation(const USGVirtualHandComponent* VirtualHandComponent, int32 Finger, int32 Joint) const; - UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Mesh Component") + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") TMap GetFingersBonesRotations(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent); }; \ No newline at end of file diff --git a/Source/SenseGloveKismet/SenseGloveKismet.Build.cs b/Source/SenseGloveKismet/SenseGloveKismet.Build.cs index e1507235..3c9118b5 100644 --- a/Source/SenseGloveKismet/SenseGloveKismet.Build.cs +++ b/Source/SenseGloveKismet/SenseGloveKismet.Build.cs @@ -63,4 +63,4 @@ public class SenseGloveKismet : ModuleRules } ); } -} +} \ No newline at end of file diff --git a/Source/SenseGloveSettings/Private/SGSettings/SGSettings.cpp b/Source/SenseGloveSettings/Private/SGSettings/SGSettings.cpp index ee9eefa2..86f4d877 100644 --- a/Source/SenseGloveSettings/Private/SGSettings/SGSettings.cpp +++ b/Source/SenseGloveSettings/Private/SGSettings/SGSettings.cpp @@ -86,6 +86,13 @@ USGSettings::USGSettings() Pimpl->ResetHardwareOffsetValuesToZero(); + bDrawDebugWristTrackerGizmo = false; + HardwareOffset = ESGPositionalTrackingHardware::None; + HardwareLocationOffsetLeftHand = FVector::ZeroVector; + HardwareLocationOffsetRightHand = FVector::ZeroVector; + HardwareRotationOffsetLeftHand = FRotator::ZeroRotator; + HardwareRotationOffsetRightHand = FRotator::ZeroRotator; + bDrawDebugWristTrackerGizmo = false; DebugWristTrackerGizmoLength = 1.0f; DebugWristTrackerGizmoXAxisColor = FColor::Red; @@ -164,128 +171,141 @@ void USGSettings::SetHardwareRotationOffsetRightHand(const FRotator& InHardwareR float USGSettings::GetDebugWristTrackerGizmoLength() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting DebugWristTrackerGizmoLength is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting DebugWristTrackerGizmoLength is only permitted when bDrawDebugWristTrackerGizmo is enabled!")); return DebugWristTrackerGizmoLength; } void USGSettings::SetDebugWristTrackerGizmoLength(const float InDebugWristTrackerGizmoLength) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting DebugWristTrackerGizmoLength is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting DebugWristTrackerGizmoLength is only permitted when bDrawDebugWristTrackerGizmo is enabled!")); DebugWristTrackerGizmoLength = InDebugWristTrackerGizmoLength; } const FLinearColor& USGSettings::GetDebugWristTrackerGizmoXAxisColor() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting DebugWristTrackerGizmoXAxisColor is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting DebugWristTrackerGizmoXAxisColor is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); return DebugWristTrackerGizmoXAxisColor; } void USGSettings::SetDebugWristTrackerGizmoXAxisColor(const FLinearColor& InDebugWristTrackerGizmoXAxisColor) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting DebugWristTrackerGizmoXAxisColor is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting DebugWristTrackerGizmoXAxisColor is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); DebugWristTrackerGizmoXAxisColor = InDebugWristTrackerGizmoXAxisColor; } const FLinearColor& USGSettings::GetDebugWristTrackerGizmoYAxisColor() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting DebugWristTrackerGizmoYAxisColor is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting DebugWristTrackerGizmoYAxisColor is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); return DebugWristTrackerGizmoXAxisColor; } void USGSettings::SetDebugWristTrackerGizmoYAxisColor(const FLinearColor& InDebugWristTrackerGizmoYAxisColor) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting DebugWristTrackerGizmoYAxisColor is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting DebugWristTrackerGizmoYAxisColor is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); DebugWristTrackerGizmoYAxisColor = InDebugWristTrackerGizmoYAxisColor; } const FLinearColor& USGSettings::GetDebugWristTrackerGizmoZAxisColor() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting DebugWristTrackerGizmoZAxisColor is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting DebugWristTrackerGizmoZAxisColor is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); return DebugWristTrackerGizmoZAxisColor; } void USGSettings::SetDebugWristTrackerGizmoZAxisColor(const FLinearColor& InDebugWristTrackerGizmoZAxisColor) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting DebugWristTrackerGizmoZAxisColor is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting DebugWristTrackerGizmoZAxisColor is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); DebugWristTrackerGizmoZAxisColor = InDebugWristTrackerGizmoZAxisColor; } bool USGSettings::GetDebugWristTrackerGizmoPersistentLines() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting bDebugWristTrackerGizmoPersistentLines is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting bDebugWristTrackerGizmoPersistentLines is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); return !!bDebugWristTrackerGizmoPersistentLines; } void USGSettings::SetDebugWristTrackerGizmoPersistentLines(const bool bInDebugWristTrackerGizmoPersistentLines) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting bDebugWristTrackerGizmoPersistentLines is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting bDebugWristTrackerGizmoPersistentLines is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); bDebugWristTrackerGizmoPersistentLines = bInDebugWristTrackerGizmoPersistentLines; } float USGSettings::GetDebugWristTrackerGizmoLifeTimeModifier() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting DebugWristTrackerGizmoLifeTimeModifier is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting DebugWristTrackerGizmoLifeTimeModifier is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); return DebugWristTrackerGizmoLifeTimeModifier; } void USGSettings::SetDebugWristTrackerGizmoLifeTimeModifier(const float InDebugWristTrackerGizmoLifeTimeModifier) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting DebugWristTrackerGizmoLifeTimeModifier is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting DebugWristTrackerGizmoLifeTimeModifier is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); DebugWristTrackerGizmoLifeTimeModifier = InDebugWristTrackerGizmoLifeTimeModifier; } uint8 USGSettings::GetDebugWristTrackerGizmoDepthPriority() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting DebugWristTrackerGizmoDepthPriority is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting DebugWristTrackerGizmoDepthPriority is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); return DebugWristTrackerGizmoDepthPriority; } void USGSettings::SetDebugWristTrackerGizmoDepthPriority(const uint8 InDebugWristTrackerGizmoDepthPriority) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting is only permitted when bDrawDebugWristTrackerGizmo is enabled!")); DebugWristTrackerGizmoDepthPriority = InDebugWristTrackerGizmoDepthPriority; } float USGSettings::GetDebugWristTrackerGizmoThickness() const { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Getting DebugWristTrackerGizmoThickness is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Getting DebugWristTrackerGizmoThickness is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); return DebugWristTrackerGizmoThickness; } void USGSettings::SetDebugWristTrackerGizmoThickness(const float InDebugWristTrackerGizmoThickness) { ensureAlwaysMsgf( - bDrawDebugWristTrackerGizmo, - TEXT("Setting DebugWristTrackerGizmoThickness is only permitted when HardwareOffset is set to Custom!")); + GetDrawDebugWristTrackerGizmo(), + TEXT("Setting DebugWristTrackerGizmoThickness is only permitted when bDrawDebugWristTrackerGizmo is" + " enabled!")); DebugWristTrackerGizmoThickness = InDebugWristTrackerGizmoThickness; } diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h index 2defc4ed..ae2dc748 100644 --- a/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h +++ b/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h @@ -97,7 +97,7 @@ private: * Valid only if HardwareOffset is set to Custom. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking", - meta=(editcondition="hardwareoffset == esgpositionaltrackinghardware::custom", editconditionhides)) + meta=(EditCondition="hardwareoffset == esgpositionaltrackinghardware::custom", EditConditionHides)) FRotator HardwareRotationOffsetRightHand; /** @@ -110,56 +110,56 @@ private: * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) float DebugWristTrackerGizmoLength; /** * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) FLinearColor DebugWristTrackerGizmoXAxisColor; /** * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) FLinearColor DebugWristTrackerGizmoYAxisColor; /** * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) FLinearColor DebugWristTrackerGizmoZAxisColor; /** * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) uint8 bDebugWristTrackerGizmoPersistentLines : 1; /** * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) float DebugWristTrackerGizmoLifeTimeModifier; /** * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) uint8 DebugWristTrackerGizmoDepthPriority; /** * Valid only if bDrawDebugWristTrackerGizmo is enabled. */ UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking Debug", - meta=(editcondition="bDrawDebugWristTrackerGizmo", editconditionhides)) + meta=(EditCondition="bDrawDebugWristTrackerGizmo", EditConditionHides)) float DebugWristTrackerGizmoThickness; public: