diff --git a/CHANGELOG.md b/CHANGELOG.md index 638f46f7..0e65f13f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,6 @@ This is a minor release focusing mainly on bringing OpenXR-compatible hand track - Added USGVirtualHandComponent::OnHandVisibilityChanged() event in order to notify other components/actors whenever the virtual hand mesh appears or disappears (for example, this could happen when a glove is connected/disconnected). - Added USGWristTrackerComponent::GetMotionControllerData(). - Added USGWristTrackerComponent::OnWristDeviceVisualTypeChanged event in order to be able to notify other components/actors whenever the wrist-tracking device switches between hand tracking or motion controllers. -- Added SGWristTrackerVisualizationComponent which is replacing UXRDeviceVisualizationComponent usage inside SGPawn. - Added the SenseGloveDebugKismet module in order to allow drawing of debugging gizmos and virtual hands from Blueprint. - Added a new static Draw() method overload to DebugGizmo which allows passing an FQuat instead of a FRotator. - Added SGEngineUtils. diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerVisualizationComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerVisualizationComponent.cpp deleted file mode 100644 index b84a0b6a..00000000 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerVisualizationComponent.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @file - * - * @author Mamadou Babaei - * - * @section LICENSE - * - * (The MIT License) - * - * Copyright (c) 2020 - 2024 SenseGlove - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @section DESCRIPTION - * - * - */ - - -#include "SenseGlove/Components/SGWristTrackerVisualizationComponent.h" - -#include "SenseGlove/Components/SGWristTrackerComponent.h" -#include "SGLog/SGLog.h" - -struct USGWristTrackerVisualizationComponent::FImpl -{ - /************************ - * Static methods - ************************/ - - /************************ - * Owner object - ************************/ - - USGWristTrackerVisualizationComponent* Owner; - - /************************ - * Constructor / Destructor - ************************/ - - explicit FImpl(USGWristTrackerVisualizationComponent* InOwner); - ~FImpl(); - - /************************ - * Default copy constructor & copy assignment operator - ************************/ - - FImpl(const FImpl& Rhs) = default; - FImpl& operator=(const FImpl& Rhs) = default; - - /************************ - * Methods - ************************/ - - bool IsEditor() const; - - void UpdateLocationAndRotation() const; -}; - -USGWristTrackerVisualizationComponent::USGWristTrackerVisualizationComponent(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer), - Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) -{ - PrimaryComponentTick.bTickEvenWhenPaused = false; - PrimaryComponentTick.bCanEverTick = true; - PrimaryComponentTick.bStartWithTickEnabled = true; - bTickInEditor = true; - bNeverNeedsRenderUpdate = true; - bAllowConcurrentTick = true; - - SetCastShadow(false); - SetCastHiddenShadow(false); - bCastDynamicShadow = false; - SetOnlyOwnerSee(false); - SetReceivesDecals(false); - SetCanEverAffectNavigation(false); -} - -void USGWristTrackerVisualizationComponent::InitializeComponent() -{ - Super::InitializeComponent(); - - Pimpl->UpdateLocationAndRotation(); -} - -void USGWristTrackerVisualizationComponent::BeginPlay() -{ - Super::BeginPlay(); - - Pimpl->UpdateLocationAndRotation(); -} - -void USGWristTrackerVisualizationComponent::TickComponent( - const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) -{ -#if WITH_EDITOR - if (Pimpl->IsEditor()) - { - EditorTick(DeltaTime, TickType, ThisTickFunction); - return; - } -#endif /* WITH_EDITOR */ - - Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - - Pimpl->UpdateLocationAndRotation(); -} - - -void USGWristTrackerVisualizationComponent::EditorTick( - const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) -{ - Pimpl->UpdateLocationAndRotation(); -} - -USGWristTrackerVisualizationComponent::FImpl::FImpl(USGWristTrackerVisualizationComponent* InOwner) - : Owner(InOwner) -{ -} - -USGWristTrackerVisualizationComponent::FImpl::~FImpl() = default; - -bool USGWristTrackerVisualizationComponent::FImpl::IsEditor() const -{ - const UWorld* World{Owner->GetWorld()}; - if (World && (World->WorldType == EWorldType::Editor || World->WorldType == EWorldType::EditorPreview)) - { - return true; - } - - return false; -} - -void USGWristTrackerVisualizationComponent::FImpl::UpdateLocationAndRotation() const -{ - USGWristTrackerComponent* ParentComponent{Cast(Owner->GetAttachParent())}; - if (!ensureAlwaysMsgf(IsValid(ParentComponent), - TEXT("This component should be attached to a SGWristTackerComponent!"))) - { - return; - } - - SGLOG(ParentComponent->GetWristRotation(), ParentComponent->GetWristLocation()) - - //Owner->MotionSource = FName("Left"); - // Owner->SetWorldLocation(ParentComponent->GetWristLocation()); - // Owner->SetWorldRotation(ParentComponent->GetWristRotation()); -} - -void USGWristTrackerVisualizationComponent::FImplDeleter::operator()(const FImpl* P) const -{ - delete P; -} \ No newline at end of file diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp index e9c0cdd5..d37053d4 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp @@ -40,12 +40,12 @@ #include "Components/SphereComponent.h" #include "Kismet/KismetMathLibrary.h" #include "UObject/UObjectGlobals.h" +#include "XRDeviceVisualizationComponent.h" #include "SenseGlove/Components/SGGrabComponent.h" #include "SenseGlove/Components/SGTouchComponent.h" #include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/Components/SGWristTrackerComponent.h" -#include "SenseGlove/Components/SGWristTrackerVisualizationComponent.h" #include "SGLog/SGLog.h" static constexpr float SG_HAND_MESH_YAW_CORRECTION_OFFSET = -90.0f; @@ -190,7 +190,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) WristTrackerLeft->SetupAttachment(GetRootComponent()); WristTrackerLeft->SetRight(false); - ControllerVisualizerLeft = ObjectInitializer.CreateDefaultSubobject( + ControllerVisualizerLeft = ObjectInitializer.CreateDefaultSubobject( this, TEXT("ControllerVisualizerLeft")); ControllerVisualizerLeft->SetupAttachment(WristTrackerLeft); ControllerVisualizerLeft->SetDisplayModelSource(FName("OpenXR")); @@ -349,7 +349,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) WristTrackerRight->SetupAttachment(GetRootComponent()); WristTrackerRight->SetRight(true); - ControllerVisualizerRight = ObjectInitializer.CreateDefaultSubobject( + ControllerVisualizerRight = ObjectInitializer.CreateDefaultSubobject( this, TEXT("ControllerVisualizerRight")); ControllerVisualizerRight->SetupAttachment(WristTrackerRight); ControllerVisualizerRight->SetDisplayModelSource(FName("OpenXR")); @@ -1687,7 +1687,7 @@ void ASGPawn::FImpl::UpdateWristTrackerVisualization(const bool bRight, const EX const bool bIsVisualizationActive = VisualType == EXRVisualType::Controller || !!Settings.bHandTrackingVisualizationAllowed; - USGWristTrackerVisualizationComponent* ControllerVisualizer{ + UXRDeviceVisualizationComponent* ControllerVisualizer{ bRight ? Owner->ControllerVisualizerLeft : Owner->ControllerVisualizerRight }; diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerVisualizationComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerVisualizationComponent.h deleted file mode 100644 index 6d2b4b6f..00000000 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerVisualizationComponent.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file - * - * @author Mamadou Babaei - * - * @section LICENSE - * - * (The MIT License) - * - * Copyright (c) 2020 - 2024 SenseGlove - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @section DESCRIPTION - * - * - */ - - -#pragma once - -#include "GameFramework/Actor.h" -#include "HeadMountedDisplayTypes.h" -#include "Math/Rotator.h" -#include "Math/Vector.h" -#include "XRDeviceVisualizationComponent.h" -#include "Templates/UniquePtr.h" - -#include "SGWristTrackerVisualizationComponent.generated.h" - -UCLASS(Blueprintable, ClassGroup = MotionController, meta = (BlueprintSpawnableComponent)) -class SENSEGLOVE_API USGWristTrackerVisualizationComponent : public UXRDeviceVisualizationComponent -{ - GENERATED_UCLASS_BODY() - -private: - struct FImpl; - - struct FImplDeleter - { - void operator()(const FImpl* P) const; - }; - - TUniquePtr Pimpl; - FImplDeleter PimplDeleter; - -public: - virtual void InitializeComponent() override; - - virtual void BeginPlay() override; - - virtual void TickComponent(float DeltaTime, - enum ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; - -protected: - virtual void EditorTick(float DeltaTime, - enum ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction); -}; \ No newline at end of file diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h index c8af2178..e812d410 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h @@ -48,10 +48,10 @@ class UCameraComponent; class UPrimitiveComponent; class USphereComponent; +class UXRDeviceVisualizationComponent; class USGVirtualHandComponent; class USGWristTrackerComponent; -class USGWristTrackerVisualizationComponent; UCLASS(Config=Game, BlueprintType, Blueprintable) class SENSEGLOVE_API ASGPawn : public APawn @@ -131,7 +131,7 @@ private: USGWristTrackerComponent* WristTrackerLeft; UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) - USGWristTrackerVisualizationComponent* ControllerVisualizerLeft; + UXRDeviceVisualizationComponent* ControllerVisualizerLeft; UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGVirtualHandComponent* HandLeft; @@ -167,7 +167,7 @@ private: USGWristTrackerComponent* WristTrackerRight; UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) - USGWristTrackerVisualizationComponent* ControllerVisualizerRight; + UXRDeviceVisualizationComponent* ControllerVisualizerRight; UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGVirtualHandComponent* HandRight; @@ -251,7 +251,7 @@ public: return WristTrackerLeft; } - FORCEINLINE USGWristTrackerVisualizationComponent* GetControllerVisualizerLeft() const + FORCEINLINE UXRDeviceVisualizationComponent* GetControllerVisualizerLeft() const { return ControllerVisualizerLeft; } @@ -311,7 +311,7 @@ public: return WristTrackerRight; } - FORCEINLINE USGWristTrackerVisualizationComponent* GetControllerVisualizerRight() const + FORCEINLINE UXRDeviceVisualizationComponent* GetControllerVisualizerRight() const { return ControllerVisualizerLeft; } diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp index e3be1f63..7ef95140 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp @@ -35,13 +35,13 @@ #include "SGKismet/SGPawnKismetLibrary.h" -#include "Runtime/Launch/Resources/Version.h" #include "Camera/CameraComponent.h" #include "Components/SphereComponent.h" +#include "Runtime/Launch/Resources/Version.h" +#include "XRDeviceVisualizationComponent.h" #include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/Components/SGWristTrackerComponent.h" -#include "SenseGlove/Components/SGWristTrackerVisualizationComponent.h" #include "SenseGlove/GameFramework/SGPawn.h" UCameraComponent* UPawnKismetLibrary::GetCamera(const ASGPawn* Pawn) @@ -54,7 +54,7 @@ USGWristTrackerComponent* UPawnKismetLibrary::GetWristTrackerLeft(const ASGPawn* return Pawn->GetWristTrackerLeft(); } -USGWristTrackerVisualizationComponent* UPawnKismetLibrary::GetControllerVisualizerLeft(const ASGPawn* Pawn) +UXRDeviceVisualizationComponent* UPawnKismetLibrary::GetControllerVisualizerLeft(const ASGPawn* Pawn) { return Pawn->GetControllerVisualizerLeft(); } @@ -114,7 +114,7 @@ USGWristTrackerComponent* UPawnKismetLibrary::GetWristTrackerRight(const ASGPawn return Pawn->GetWristTrackerRight(); } -USGWristTrackerVisualizationComponent* UPawnKismetLibrary::GetControllerVisualizerRight(const ASGPawn* Pawn) +UXRDeviceVisualizationComponent* UPawnKismetLibrary::GetControllerVisualizerRight(const ASGPawn* Pawn) { return Pawn->GetControllerVisualizerRight(); } diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h index 0df38e1f..3a4a0ab0 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h @@ -43,17 +43,16 @@ #include "UObject/NameTypes.h" #include "SGKismet/SGBlueprintFunctionLibrary.h" -#include "SGTypes/SGNameArray.h" #include "SGPawnKismetLibrary.generated.h" class UCameraComponent; class USphereComponent; +class UXRDeviceVisualizationComponent; class ASGPawn; class USGVirtualHandComponent; class USGWristTrackerComponent; -class USGWristTrackerVisualizationComponent; UCLASS(meta=(ScriptName = "SesneGlovePawnKismetLibrary")) class SENSEGLOVEKISMET_API UPawnKismetLibrary final : public USGBlueprintFunctionLibrary @@ -68,7 +67,7 @@ public: static USGWristTrackerComponent* GetWristTrackerLeft(const ASGPawn* Pawn); UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") - static USGWristTrackerVisualizationComponent* GetControllerVisualizerLeft(const ASGPawn* Pawn); + static UXRDeviceVisualizationComponent* GetControllerVisualizerLeft(const ASGPawn* Pawn); UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGVirtualHandComponent* GetHandLeft(const ASGPawn* Pawn); @@ -104,7 +103,7 @@ public: static USGWristTrackerComponent* GetWristTrackerRight(const ASGPawn* Pawn); UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") - static USGWristTrackerVisualizationComponent* GetControllerVisualizerRight(const ASGPawn* Pawn); + static UXRDeviceVisualizationComponent* GetControllerVisualizerRight(const ASGPawn* Pawn); UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGVirtualHandComponent* GetHandRight(const ASGPawn* Pawn);