From a76678c5ba1f7bbb8cc4e566ed0b16610df9b4f6 Mon Sep 17 00:00:00 2001 From: Simeon Wallrath Date: Fri, 30 Aug 2024 15:41:10 +0200 Subject: [PATCH] Fixed Checkbox and Images showing on Buttons --- .../Content/MainMenu/BP_MainMenu.uasset | 4 +- .../Widget3DPassThrough_NoDepth.uasset | 2 +- .../Widget3DPassThrough_NoDepth_Inst.uasset | 4 +- ...dget3DPassThrough_NoDepth_Inst_Alöt.uasset | 3 + .../Content/MainMenu/WB_Button.uasset | 4 +- .../Content/MainMenu/WB_SettingsMain.uasset | 4 +- .../VRE/ExampleMap/MotionControllerMap.umap | 4 +- .../SoundComponentTestStruct.uasset | 4 +- .../Misc/Examples/Gestures/GestureWand.uasset | 4 +- .../OpenXRExpansionPlugin.uplugin | 6 +- .../OpenXRExpansionPlugin.Build.cs | 4 +- .../Private/OpenXRHandPoseComponent.cpp | 15 +- .../Plugins/VRExpansionPlugin/README.md | 2 +- .../Private/VRGlobalSettingsDetails.cpp | 54 - .../Public/VRGlobalSettingsDetails.h | 2 - .../Private/CharacterMovementCompTypes.cpp | 2 +- .../Private/GripMotionControllerComponent.cpp | 395 ++---- .../Private/GripScripts/GS_Melee.cpp | 6 - .../Private/Grippables/GrippableActor.cpp | 101 +- .../Grippables/GrippableBoxComponent.cpp | 93 +- .../Grippables/GrippableCapsuleComponent.cpp | 93 +- .../GrippablePhysicsReplication.cpp | 1087 ++++------------- .../Grippables/GrippableSkeletalMeshActor.cpp | 112 +- .../GrippableSkeletalMeshComponent.cpp | 92 +- .../Grippables/GrippableSphereComponent.cpp | 95 +- .../Grippables/GrippableStaticMeshActor.cpp | 99 +- .../GrippableStaticMeshComponent.cpp | 92 +- .../Grippables/HandSocketComponent.cpp | 67 +- .../Interactibles/VRButtonComponent.cpp | 43 +- .../Private/Interactibles/VRDialComponent.cpp | 53 +- .../Interactibles/VRLeverComponent.cpp | 54 +- .../Interactibles/VRMountComponent.cpp | 51 +- .../Interactibles/VRSliderComponent.cpp | 60 +- .../Private/Misc/CollisionIgnoreSubsystem.cpp | 11 - .../Misc/OptionalRepSkeletalMeshActor.cpp | 34 +- .../Private/Misc/VRAIPerceptionOverrides.cpp | 55 +- .../Misc/VREPhysicalAnimationComponent.cpp | 35 +- .../Private/Misc/VRFullScreenUserWidget.cpp | 2 +- .../Private/Misc/VRLogComponent.cpp | 3 - .../Private/Misc/VRPlayerStart.cpp | 2 - .../Private/Misc/VRRenderTargetManager.cpp | 21 +- .../Private/Mover/VRMoverComponent.cpp | 207 ---- .../ParentRelativeAttachmentComponent.cpp | 1 - .../Private/ReplicatedVRCameraComponent.cpp | 58 +- .../Private/VRAIController.cpp | 2 - .../Private/VRBPDatatypes.cpp | 71 -- .../Private/VRBaseCharacter.cpp | 49 +- .../VRBaseCharacterMovementComponent.cpp | 40 +- .../VRExpansionPlugin/Private/VRCharacter.cpp | 1 - .../Private/VRCharacterMovementComponent.cpp | 94 +- .../Private/VRGestureComponent.cpp | 2 - .../Private/VRPathFollowingComponent.cpp | 33 +- .../Private/VRPlayerController.cpp | 18 + .../Private/VRRootComponent.cpp | 53 +- .../Private/VRStereoWidgetComponent.cpp | 22 +- .../Public/GripMotionControllerComponent.h | 61 +- .../Public/GripScripts/GS_Melee.h | 7 +- .../Public/Grippables/GrippableActor.h | 41 +- .../Public/Grippables/GrippableBoxComponent.h | 23 - .../Grippables/GrippableCapsuleComponent.h | 25 - .../Grippables/GrippablePhysicsReplication.h | 33 +- .../Grippables/GrippableSkeletalMeshActor.h | 41 +- .../GrippableSkeletalMeshComponent.h | 23 - .../Grippables/GrippableSphereComponent.h | 22 - .../Grippables/GrippableStaticMeshActor.h | 35 - .../Grippables/GrippableStaticMeshComponent.h | 25 - .../Public/Grippables/HandSocketComponent.h | 19 +- .../Public/Interactibles/VRButtonComponent.h | 14 - .../Public/Interactibles/VRDialComponent.h | 18 +- .../Public/Interactibles/VRLeverComponent.h | 16 +- .../Public/Interactibles/VRMountComponent.h | 18 +- .../Public/Interactibles/VRSliderComponent.h | 21 +- .../Public/Misc/CollisionIgnoreSubsystem.h | 10 +- .../Misc/OptionalRepSkeletalMeshActor.h | 11 +- .../Public/Misc/VRAIPerceptionOverrides.h | 2 - .../Misc/VREPhysicalAnimationComponent.h | 12 +- .../Public/Misc/VRLogComponent.h | 1 - .../Public/Misc/VRRenderTargetManager.h | 16 +- .../Public/Mover/VRMoverComponent.h | 154 --- .../Public/ReplicatedVRCameraComponent.h | 24 +- .../VRExpansionPlugin/Public/VRBPDatatypes.h | 58 +- .../Public/VRBaseCharacter.h | 8 +- .../Public/VRGestureComponent.h | 3 +- .../Public/VRRootComponent.h | 3 - .../Public/VRStereoWidgetComponent.h | 11 +- .../VRExpansionPlugin.Build.cs | 26 +- .../VRExpansionPlugin.uplugin | 12 +- 87 files changed, 800 insertions(+), 3518 deletions(-) create mode 100644 VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst_Alöt.uasset delete mode 100644 VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Mover/VRMoverComponent.cpp delete mode 100644 VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Mover/VRMoverComponent.h diff --git a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/BP_MainMenu.uasset b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/BP_MainMenu.uasset index 9ea65be..b8ec588 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/BP_MainMenu.uasset +++ b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/BP_MainMenu.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e88f675a3f11f0372af6ce8c04c2294a60b5d8ccef321e29bc0fe950a08ad5d4 -size 734014 +oid sha256:a3af49e9c968b405e4d213da616677edfb27416faf36b43b30380d842519d20d +size 733182 diff --git a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth.uasset b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth.uasset index 43fdc74..3b7267c 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth.uasset +++ b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b33897777f3621ddba5eecf92a2b4515be266ae2b255a60b8fcd10fcb3a03eb9 +oid sha256:ec3d100b07f3efc100615cc2b085f9171f80c90e04bba2bf7d6a03d0bcf8d410 size 16104 diff --git a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst.uasset b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst.uasset index eb68967..3ef52aa 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst.uasset +++ b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b98e2b022eb3d3480e718836ee419c9b7fbfa709c75dd75de6028d693311a94a -size 7871 +oid sha256:af1c43a9632d7cb25d7c61a5ee4fce941958ad3bc98712d4cdd50d05a697deaf +size 9066 diff --git a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst_Alöt.uasset b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst_Alöt.uasset new file mode 100644 index 0000000..eb21d54 --- /dev/null +++ b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/UI_Materials/Widget3DPassThrough_NoDepth_Inst_Alöt.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f02873297c9c96cf7463b062d803990a998dc32f3e87c1fbdef8a66f2253d242 +size 10627 diff --git a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_Button.uasset b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_Button.uasset index a8c97bd..41e9d56 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_Button.uasset +++ b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_Button.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cf7adf5d00c7e64e019ac68b9eb1cb8673886d70ad27d2925323094ef10f0605 -size 199628 +oid sha256:8f19f6bade9172653b0b19980f96392200e8ab5eed567674f0ad6a6dddf2e700 +size 214920 diff --git a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_SettingsMain.uasset b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_SettingsMain.uasset index e1a7346..f89cd7d 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_SettingsMain.uasset +++ b/VIRTUOS_ExpansionPluginTests/Content/MainMenu/WB_SettingsMain.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0de6d3ab9f2d9e3ab3f5eea797537dd3b47ae3e4a2cca666f24c55ad81328049 -size 38887 +oid sha256:e293e68ecb9fb33acc808283eeadab6bd6fefae71a693ebab9fd504e4639fa76 +size 39346 diff --git a/VIRTUOS_ExpansionPluginTests/Content/VRE/ExampleMap/MotionControllerMap.umap b/VIRTUOS_ExpansionPluginTests/Content/VRE/ExampleMap/MotionControllerMap.umap index a11aced..f1a7c47 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/VRE/ExampleMap/MotionControllerMap.umap +++ b/VIRTUOS_ExpansionPluginTests/Content/VRE/ExampleMap/MotionControllerMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:93ab2584efd46c01499d33b8a5e6a0575ba45a4466bc43923629f9fc23a7035e -size 887504 +oid sha256:d5b38d7d6fa209928a614050bdcb0915845de525e41c3bfa2ea6f3f22b719505 +size 887586 diff --git a/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/DrawerBase/FileCabinet/SoundComponentTestStruct.uasset b/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/DrawerBase/FileCabinet/SoundComponentTestStruct.uasset index 619203d..7a9253a 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/DrawerBase/FileCabinet/SoundComponentTestStruct.uasset +++ b/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/DrawerBase/FileCabinet/SoundComponentTestStruct.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2d1935abd2d51a1a2f5eb9757182a067f90bc6cd8cb25fcb552c549d8d9a6c3c -size 396548 +oid sha256:c8b6261813f731eeb9af0e5b3885137f15a87f55794d5f52855909613444eb10 +size 383859 diff --git a/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/Gestures/GestureWand.uasset b/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/Gestures/GestureWand.uasset index f8b847b..2cad221 100644 --- a/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/Gestures/GestureWand.uasset +++ b/VIRTUOS_ExpansionPluginTests/Content/VRE/Grippables/Misc/Examples/Gestures/GestureWand.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f39b3b35bf1867075c1861faf5c36fc09e53209693f48e985f25d6441bf088ba -size 187040 +oid sha256:3f4943ec359bccc4d0492e4c9dba3a4f9de910a0c96dbbda8784006e69ea3b02 +size 186968 diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/OpenXRExpansionPlugin.uplugin b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/OpenXRExpansionPlugin.uplugin index 6422043..02a46d5 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/OpenXRExpansionPlugin.uplugin +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/OpenXRExpansionPlugin.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 5.4, - "VersionName": "5.4", + "Version": 5.3, + "VersionName": "5.3", "FriendlyName": "OpenXRExpansionPlugin", "Description": "An set of utility functions for OpenXR", "Category": "Virtual Reality", @@ -31,7 +31,7 @@ { "Name": "OpenXRExpansionEditor", "Type": "UnCookedOnly", - "LoadingPhase": "PreDefault" + "LoadingPhase": "PostEngineInit" } ], "Plugins": [ diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/OpenXRExpansionPlugin.Build.cs b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/OpenXRExpansionPlugin.Build.cs index 6670404..5e4b5d1 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/OpenXRExpansionPlugin.Build.cs +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/OpenXRExpansionPlugin.Build.cs @@ -10,9 +10,7 @@ namespace UnrealBuildTool.Rules public OpenXRExpansionPlugin(ReadOnlyTargetRules Target) : base(Target) { - SetupIrisSupport(Target); - - PublicDependencyModuleNames.AddRange( + PublicDependencyModuleNames.AddRange( new string[] { //"InputDevice", diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/Private/OpenXRHandPoseComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/Private/OpenXRHandPoseComponent.cpp index cd6b6f9..0912c8d 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/Private/OpenXRHandPoseComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/OpenXRExpansionPlugin/Source/OpenXRExpansionPlugin/Private/OpenXRHandPoseComponent.cpp @@ -6,7 +6,6 @@ #include "MotionControllerComponent.h" #include "OpenXRExpansionFunctionLibrary.h" #include "Engine/NetSerialization.h" -#include "Net/Core/PushModel/PushModel.h" #include "XRMotionControllerBase.h" // for GetHandEnumForSourceName() //#include "EngineMinimal.h" @@ -30,13 +29,9 @@ void UOpenXRHandPoseComponent::GetLifetimeReplicatedProps(TArray< class FLifetim { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - FDoRepLifetimeParams SkipOwnerParams; - SkipOwnerParams.Condition = COND_SkipOwner; - SkipOwnerParams.bIsPushBased = true; - // Skipping the owner with this as the owner will use the controllers location directly - DOREPLIFETIME_WITH_PARAMS_FAST(UOpenXRHandPoseComponent, LeftHandRep, SkipOwnerParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UOpenXRHandPoseComponent, RightHandRep, SkipOwnerParams); + DOREPLIFETIME_CONDITION(UOpenXRHandPoseComponent, LeftHandRep, COND_SkipOwner); + DOREPLIFETIME_CONDITION(UOpenXRHandPoseComponent, RightHandRep, COND_SkipOwner); } void UOpenXRHandPoseComponent::Server_SendSkeletalTransforms_Implementation(const FBPXRSkeletalRepContainer& SkeletalInfo) @@ -54,9 +49,6 @@ void UOpenXRHandPoseComponent::Server_SendSkeletalTransforms_Implementation(cons FBPXRSkeletalRepContainer::CopyReplicatedTo(SkeletalInfo, HandSkeletalActions[i]); LeftHandRep = SkeletalInfo; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UOpenXRHandPoseComponent, LeftHandRep, this); -#endif if (bSmoothReplicatedSkeletalData) { @@ -72,9 +64,6 @@ void UOpenXRHandPoseComponent::Server_SendSkeletalTransforms_Implementation(cons FBPXRSkeletalRepContainer::CopyReplicatedTo(SkeletalInfo, HandSkeletalActions[i]); RightHandRep = SkeletalInfo; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UOpenXRHandPoseComponent, RightHandRep, this); -#endif if (bSmoothReplicatedSkeletalData) { diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/README.md b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/README.md index fa9c46f..875fec0 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/README.md +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/README.md @@ -1,4 +1,4 @@ -UE Forums Thread +UE4 Forums Thread https://forums.unrealengine.com/development-discussion/vr-ar-development/89050-vr-openvr-expansion-plugin Example Template Project diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Private/VRGlobalSettingsDetails.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Private/VRGlobalSettingsDetails.cpp index b774672..0c6ad90 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Private/VRGlobalSettingsDetails.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Private/VRGlobalSettingsDetails.cpp @@ -31,8 +31,6 @@ #include "AssetRegistry/AssetRegistryModule.h" #include "AssetRegistry/ARFilter.h" -#include "FileHelpers.h" -#include "Engine/Engine.h" #include "Editor/UnrealEdEngine.h" #include "UnrealEdGlobals.h" @@ -78,60 +76,8 @@ void FVRGlobalSettingsDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuil .Text(LOCTEXT("FixInvalidAnimationAssetsButton", "Fix Animation Assets")) ] ]; - - /*DetailBuilder.EditCategory("Utilities") - .AddCustomRow(LOCTEXT("Fix 5.4.0 Shadow Shader", "Fix Broken 5.4.0 Shadow Shader")) - .NameContent() - [ - SNew(STextBlock) - .Font(IDetailLayoutBuilder::GetDetailFont()) - .Text(LOCTEXT("Fix54ShadowShader", "Fix Broken 5.4.0 Shadow Shader")) - ] - .ValueContent() - .MaxDesiredWidth(125.f) - .MinDesiredWidth(125.f) - [ - SNew(SButton) - .ContentPadding(2) - .VAlign(VAlign_Center) - .HAlign(HAlign_Center) - .OnClicked(this, &FVRGlobalSettingsDetails::OnFixShadowShader) - [ - SNew(STextBlock) - .Font(IDetailLayoutBuilder::GetDetailFont()) - .Text(LOCTEXT("Fix54ShadowShaderButton", "Fix Broken 5.4.0 Shadow Shader")) - ] - ];*/ } -/*FReply FVRGlobalSettingsDetails::OnFixShadowShader() -{ -#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION == 4 - FString EnginePath = FPaths::EngineDir(); - EnginePath += "/Shaders/Private/ShadowProjectionPixelShader.usf"; - - if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*EnginePath)) - { - FString FileStr = ""; - if (FFileHelper::LoadFileToString(FileStr, *EnginePath)) - { - // Don't need to do anything complicated, the shader only contains one line with this define in it - FileStr = FileStr.Replace(TEXT("#if MOBILE_MULTI_VIEW || INSTANCED_STEREO"),TEXT("#if ((MOBILE_MULTI_VIEW || INSTANCED_STEREO) && SHADING_PATH_MOBILE)")); - - FFileHelper::SaveStringToFile(FileStr, *EnginePath); - - GEngine->Exec(GEngine->GetWorld(), TEXT("recompileshaders changed")); - UE_LOG(LogPath, Log, TEXT("ShadowProjectionPixelShader.usf resaved and recompiled!")); - return FReply::Handled(); - } - } - -#endif - - UE_LOG(LogPath, Error, TEXT("ShadowProjectionPixelShader.usf could not be found, edited, or the engine version is incorrect!")); - return FReply::Handled(); -}*/ - FReply FVRGlobalSettingsDetails::OnCorrectInvalidAnimationAssets() { diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Public/VRGlobalSettingsDetails.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Public/VRGlobalSettingsDetails.h index 3266b3a..6e5ee1e 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Public/VRGlobalSettingsDetails.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionEditor/Public/VRGlobalSettingsDetails.h @@ -20,8 +20,6 @@ public: virtual void CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) override; FReply OnCorrectInvalidAnimationAssets(); - - FReply OnFixShadowShader(); void OnLockedStateUpdated(IDetailLayoutBuilder* LayoutBuilder); diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/CharacterMovementCompTypes.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/CharacterMovementCompTypes.cpp index 300790d..3ae2705 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/CharacterMovementCompTypes.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/CharacterMovementCompTypes.cpp @@ -118,7 +118,7 @@ void FSavedMove_VRBaseCharacter::SetInitialPosition(ACharacter* C) // Instead, re-purpose it to be the capsule half height if (AVRBaseCharacter* BaseChar = Cast(C)) { - if (BaseChar->GetVRReplicateCapsuleHeight()) + if (BaseChar->VRReplicateCapsuleHeight) CapsuleHeight = BaseChar->GetCapsuleComponent()->GetUnscaledCapsuleHalfHeight(); else CapsuleHeight = 0.0f; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripMotionControllerComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripMotionControllerComponent.cpp index 5bcf7aa..dd581c4 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripMotionControllerComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripMotionControllerComponent.cpp @@ -57,10 +57,6 @@ #include "Features/IModularFeatures.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - DEFINE_LOG_CATEGORY(LogVRMotionController); //For UE4 Profiler ~ Stat DECLARE_CYCLE_STAT(TEXT("TickGrip ~ TickingGrip"), STAT_TickGrip, STATGROUP_TickGrip); @@ -670,25 +666,17 @@ void UGripMotionControllerComponent::GetLifetimeReplicatedProps(TArray< class FL DISABLE_REPLICATED_PRIVATE_PROPERTY(USceneComponent, RelativeRotation); DISABLE_REPLICATED_PRIVATE_PROPERTY(USceneComponent, RelativeScale3D); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - DOREPLIFETIME_WITH_PARAMS_FAST(UGripMotionControllerComponent, GrippedObjects, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGripMotionControllerComponent, ControllerNetUpdateRate, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGripMotionControllerComponent, bSmoothReplicatedMotion, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGripMotionControllerComponent, bReplicateWithoutTracking, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_SkipOwner, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - // Skipping the owner with this as the owner will use the controllers location directly - DOREPLIFETIME_WITH_PARAMS_FAST(UGripMotionControllerComponent, ReplicatedControllerTransform, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGripMotionControllerComponent, LocallyGrippedObjects, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(UGripMotionControllerComponent, ReplicatedControllerTransform, COND_SkipOwner); + DOREPLIFETIME(UGripMotionControllerComponent, GrippedObjects); + DOREPLIFETIME(UGripMotionControllerComponent, ControllerNetUpdateRate); + DOREPLIFETIME(UGripMotionControllerComponent, bSmoothReplicatedMotion); + DOREPLIFETIME(UGripMotionControllerComponent, bReplicateWithoutTracking); + - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithConditionOwnerOnly{ COND_OwnerOnly, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGripMotionControllerComponent, LocalTransactionBuffer, PushModelParamsWithConditionOwnerOnly); + DOREPLIFETIME_CONDITION(UGripMotionControllerComponent, LocallyGrippedObjects, COND_SkipOwner); + DOREPLIFETIME_CONDITION(UGripMotionControllerComponent, LocalTransactionBuffer, COND_OwnerOnly); // DOREPLIFETIME(UGripMotionControllerComponent, bReplicateControllerTransform); } @@ -706,9 +694,6 @@ void UGripMotionControllerComponent::Server_SendControllerTransform_Implementati { // Store new transform and trigger OnRep_Function ReplicatedControllerTransform = NewTransform; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, ReplicatedControllerTransform, this); -#endif // Server should no longer call this RPC itself, but if is using non tracked then it will so keeping auth check if(!bHasAuthority) @@ -747,14 +732,6 @@ void UGripMotionControllerComponent::GetPhysicsVelocities(const FBPActorGripInfo return; } - // TMP #TODO: Fix when 5.4 bug is fixed - if (!primComp->IsSimulatingPhysics()) - { - CurLinearVelocity = Grip.LinVel; - CurAngularVelocity = Grip.RotVel; - return; - } - CurAngularVelocity = primComp->GetPhysicsAngularVelocityInDegrees(); CurLinearVelocity = primComp->GetPhysicsLinearVelocity(); } @@ -1054,7 +1031,6 @@ void UGripMotionControllerComponent::SetGripCollisionType(const FBPActorGripInfo { GrippedObjects[fIndex].GripCollisionType = NewGripCollisionType; ReCreateGrip(GrippedObjects[fIndex]); - DIRTY_GRIPPED_OBJECTS(); Result = EBPVRResultSwitch::OnSucceeded; return; } @@ -1073,7 +1049,6 @@ void UGripMotionControllerComponent::SetGripCollisionType(const FBPActorGripInfo } ReCreateGrip(LocallyGrippedObjects[fIndex]); - DIRTY_LOCALLY_GRIPPED_OBJECTS(); Result = EBPVRResultSwitch::OnSucceeded; return; @@ -1090,7 +1065,6 @@ void UGripMotionControllerComponent::SetGripLateUpdateSetting(const FBPActorGrip if (fIndex != INDEX_NONE) { GrippedObjects[fIndex].GripLateUpdateSetting = NewGripLateUpdateSetting; - DIRTY_GRIPPED_OBJECTS(); Result = EBPVRResultSwitch::OnSucceeded; return; } @@ -1108,7 +1082,6 @@ void UGripMotionControllerComponent::SetGripLateUpdateSetting(const FBPActorGrip Server_NotifyLocalGripAddedOrChanged(GripInfo); } - DIRTY_LOCALLY_GRIPPED_OBJECTS(); Result = EBPVRResultSwitch::OnSucceeded; return; } @@ -1134,8 +1107,6 @@ void UGripMotionControllerComponent::SetGripRelativeTransform( NotifyGripTransformChanged(Grip); } - DIRTY_GRIPPED_OBJECTS(); - Result = EBPVRResultSwitch::OnSucceeded; return; } @@ -1158,8 +1129,6 @@ void UGripMotionControllerComponent::SetGripRelativeTransform( Server_NotifyLocalGripAddedOrChanged(GripInfo); } - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - Result = EBPVRResultSwitch::OnSucceeded; return; } @@ -1179,7 +1148,6 @@ void UGripMotionControllerComponent::SetGripAdditionTransform( if (fIndex != INDEX_NONE) { GrippedObjects[fIndex].AdditionTransform = CreateGripRelativeAdditionTransform(Grip, NewAdditionTransform, bMakeGripRelative); - DIRTY_GRIPPED_OBJECTS(); Result = EBPVRResultSwitch::OnSucceeded; return; @@ -1191,7 +1159,6 @@ void UGripMotionControllerComponent::SetGripAdditionTransform( if (fIndex != INDEX_NONE) { LocallyGrippedObjects[fIndex].AdditionTransform = CreateGripRelativeAdditionTransform(Grip, NewAdditionTransform, bMakeGripRelative); - DIRTY_LOCALLY_GRIPPED_OBJECTS(); Result = EBPVRResultSwitch::OnSucceeded; return; @@ -1220,8 +1187,6 @@ void UGripMotionControllerComponent::SetGripStiffnessAndDamping( GrippedObjects[fIndex].AdvancedGripSettings.PhysicsSettings.AngularDamping = OptionalAngularDamping; } - DIRTY_GRIPPED_OBJECTS(); - Result = EBPVRResultSwitch::OnSucceeded; SetGripConstraintStiffnessAndDamping(&GrippedObjects[fIndex]); //return; @@ -1247,8 +1212,6 @@ void UGripMotionControllerComponent::SetGripStiffnessAndDamping( Server_NotifyLocalGripAddedOrChanged(GripInfo); } - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - Result = EBPVRResultSwitch::OnSucceeded; SetGripConstraintStiffnessAndDamping(&LocallyGrippedObjects[fIndex]); // return; @@ -1747,8 +1710,6 @@ bool UGripMotionControllerComponent::GripActor( if (!bIsLocalGrip) { int32 Index = GrippedObjects.Add(newActorGrip); - DIRTY_GRIPPED_OBJECTS(); - if (Index != INDEX_NONE) NotifyGrip(GrippedObjects[Index]); //NotifyGrip(newActorGrip); @@ -1758,13 +1719,9 @@ bool UGripMotionControllerComponent::GripActor( if (!IsLocallyControlled()) { LocalTransactionBuffer.Add(newActorGrip); -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, LocalTransactionBuffer, this); -#endif } int32 Index = LocallyGrippedObjects.Add(newActorGrip); - DIRTY_LOCALLY_GRIPPED_OBJECTS(); if (Index != INDEX_NONE) { @@ -2009,8 +1966,6 @@ bool UGripMotionControllerComponent::GripComponent( if (!bIsLocalGrip) { int32 Index = GrippedObjects.Add(newComponentGrip); - DIRTY_GRIPPED_OBJECTS(); - if (Index != INDEX_NONE) NotifyGrip(GrippedObjects[Index]); @@ -2021,13 +1976,9 @@ bool UGripMotionControllerComponent::GripComponent( if (!IsLocallyControlled()) { LocalTransactionBuffer.Add(newComponentGrip); -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, LocalTransactionBuffer, this); -#endif } int32 Index = LocallyGrippedObjects.Add(newComponentGrip); - DIRTY_LOCALLY_GRIPPED_OBJECTS(); if (Index != INDEX_NONE) { @@ -2132,9 +2083,6 @@ bool UGripMotionControllerComponent::DropGrip_Implementation(const FBPActorGripI if (LocalTransactionBuffer[i].GripID == Grip.GripID) LocalTransactionBuffer.RemoveAt(i); } -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, LocalTransactionBuffer, this); -#endif } UPrimitiveComponent * PrimComp = nullptr; @@ -2751,8 +2699,6 @@ void UGripMotionControllerComponent::DropAndSocket_Implementation(const FBPActor int fIndex = 0; if (LocallyGrippedObjects.Find(NewDrop, fIndex)) { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - if (HasGripAuthority(NewDrop) || IsServer()) { LocallyGrippedObjects.RemoveAt(fIndex); @@ -2768,7 +2714,6 @@ void UGripMotionControllerComponent::DropAndSocket_Implementation(const FBPActor fIndex = 0; if (GrippedObjects.Find(NewDrop, fIndex)) { - DIRTY_GRIPPED_OBJECTS(); if (HasGripAuthority(NewDrop) || IsServer()) { GrippedObjects.RemoveAt(fIndex); @@ -3124,7 +3069,7 @@ bool UGripMotionControllerComponent::NotifyGrip(FBPActorGripInformation &NewGrip case EGripCollisionType::AttachmentGrip: { - if (IsValid(root)) + if (root) root->SetSimulatePhysics(false); // Move it to the correct location automatically @@ -3151,7 +3096,7 @@ bool UGripMotionControllerComponent::NotifyGrip(FBPActorGripInformation &NewGrip default: { - if (IsValid(root)) + if (root) { if (root->IsSimulatingPhysics()) { @@ -3184,13 +3129,6 @@ bool UGripMotionControllerComponent::NotifyGrip(FBPActorGripInformation &NewGrip if (!bIsReInit) { - // TMP #TODO: Remove when 5.4 velocity bug is fixed - if (IsValid(root)) - { - // Set initial world transform for velocity - NewGrip.LastVelWorldTrans = root->GetComponentTransform(); - } - // Broadcast a new grip OnGrippedObject.Broadcast(NewGrip); if (!LocallyGrippedObjects.Contains(NewGrip.GripID) && !GrippedObjects.Contains(NewGrip.GripID)) @@ -3786,14 +3724,15 @@ void UGripMotionControllerComponent::Drop_Implementation(const FBPActorGripInfor }; + + + // Copy over the information instead of working with a reference for the OnDroppedBroadcast FBPActorGripInformation DropBroadcastData = NewDrop; int fIndex = 0; if (LocallyGrippedObjects.Find(NewDrop, fIndex)) { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - if (HasGripAuthority(NewDrop) || IsServer()) { LocallyGrippedObjects.RemoveAt(fIndex); @@ -3809,7 +3748,6 @@ void UGripMotionControllerComponent::Drop_Implementation(const FBPActorGripInfor fIndex = 0; if (GrippedObjects.Find(NewDrop, fIndex)) { - DIRTY_GRIPPED_OBJECTS(); if (HasGripAuthority(NewDrop) || IsServer()) { GrippedObjects.RemoveAt(fIndex); @@ -4086,15 +4024,6 @@ bool UGripMotionControllerComponent::AddSecondaryAttachmentToGrip(const FBPActor Server_NotifySecondaryAttachmentChanged(GripToUse->GripID, GripToUse->SecondaryGripInfo); } - if (bWasLocal) - { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - } - else - { - DIRTY_GRIPPED_OBJECTS(); - } - OnSecondaryGripAdded.Broadcast(*GripToUse); GripToUse = nullptr; @@ -4285,15 +4214,6 @@ bool UGripMotionControllerComponent::RemoveSecondaryAttachmentFromGrip(const FBP } - if (bWasLocal) - { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - } - else - { - DIRTY_GRIPPED_OBJECTS(); - } - SecondaryGripIDs.Remove(GripToUse->GripID); OnSecondaryGripRemoved.Broadcast(*GripToUse); GripToUse = nullptr; @@ -4612,10 +4532,6 @@ bool UGripMotionControllerComponent::TeleportMoveGrip_Impl(FBPActorGripInformati } } - // TMP #TODO: Remove with 5.4 bug with velocity is fixed - // Reset our last world transform velocity as typically we don't want to accumulate teleport speeds into it. - Grip.LastVelWorldTrans = PrimComp->GetComponentTransform(); - return true; } @@ -4811,10 +4727,6 @@ void UGripMotionControllerComponent::UpdateTracking(float DeltaTime) ReplicatedControllerTransform.Position = RelLoc; ReplicatedControllerTransform.Rotation = RelRot; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, ReplicatedControllerTransform, this); -#endif - // I would keep the torn off check here, except this can be checked on tick if they // Set 100 htz updates, and in the TornOff case, it actually can't hurt any besides some small // Perf difference. @@ -5091,22 +5003,6 @@ FVector UGripMotionControllerComponent::GetComponentVelocity() const return Super::GetComponentVelocity(); } -// TEMP: #TODO: Remove -void UGripMotionControllerComponent::CalculateGripVelocity(FBPActorGripInformation& GripToFill, UPrimitiveComponent* ComponentToSample, float DeltaTime) -{ - if (!bHasAuthority && !IsServer()) - { - return; - } - - FTransform CurTrans = ComponentToSample->GetComponentTransform(); - - GripToFill.LinVel = (CurTrans.GetLocation() - GripToFill.LastVelWorldTrans.GetLocation()) / DeltaTime; - GripToFill.RotVel = FVector::RadiansToDegrees(((CurTrans.GetRotation().ToRotationVector() - GripToFill.LastVelWorldTrans.GetRotation().ToRotationVector()))) / DeltaTime; - - GripToFill.LastVelWorldTrans = CurTrans; -} - void UGripMotionControllerComponent::HandleGripArray(TArray &GrippedObjectsArray, const FTransform & ParentTransform, float DeltaTime, bool bReplicatedArray) { if (GrippedObjectsArray.Num()) @@ -5194,8 +5090,6 @@ void UGripMotionControllerComponent::HandleGripArray(TArray ActorHandles; - HandleInfo->KinActorData2->GetGameThreadAPI().SetGeometry(MakeImplicitObjectPtr>(TVector(0.f), 1000.f)); + HandleInfo->KinActorData2->GetGameThreadAPI().SetGeometry(TUniquePtr(new TSphere(TVector(0.f), 1000.f))); HandleInfo->KinActorData2->GetGameThreadAPI().SetObjectState(EObjectStateType::Kinematic); FPhysicsInterface::AddActorToSolver(HandleInfo->KinActorData2, ActorParams.Scene->GetSolver()); //ActorHandles.Add(HandleInfo->KinActorData2); @@ -6645,7 +6536,7 @@ bool UGripMotionControllerComponent::SetUpPhysicsHandle(const FBPActorGripInform NewLinDrive.Stiffness = Stiffness; NewLinDrive.MaxForce = MaxForce; - //HandleInfo->LinConstraint.bEnablePositionDrive = true; + HandleInfo->LinConstraint.bEnablePositionDrive = true; HandleInfo->LinConstraint.XDrive = NewLinDrive; HandleInfo->LinConstraint.YDrive = NewLinDrive; HandleInfo->LinConstraint.ZDrive = NewLinDrive; @@ -6717,11 +6608,7 @@ bool UGripMotionControllerComponent::SetUpPhysicsHandle(const FBPActorGripInform NewAngDrive.MaxForce = AngularMaxForce; //NewAngDrive.MaxForce = MAX_FLT; - //HandleInfo->LinConstraint.bEnablePositionDrive = true; - HandleInfo->LinConstraint.XDrive.bEnablePositionDrive = true; - HandleInfo->LinConstraint.YDrive.bEnablePositionDrive = true; - HandleInfo->LinConstraint.ZDrive.bEnablePositionDrive = true; - + HandleInfo->LinConstraint.bEnablePositionDrive = true; HandleInfo->LinConstraint.XDrive = NewLinDrive; HandleInfo->LinConstraint.YDrive = NewLinDrive; HandleInfo->LinConstraint.ZDrive = NewLinDrive; @@ -7315,9 +7202,81 @@ bool UGripMotionControllerComponent::GripPollControllerState_GameThread(FVector& bPolledHMD_GameThread = false; } + //GripUEMotionController::FScopeLockOptional LockOptional; + TArray MotionControllers; + MotionControllers = IModularFeatures::Get().GetModularFeatureImplementations(IMotionController::GetModularFeatureName()); + for (auto MotionController : MotionControllers) + { + if (MotionController == nullptr) + { + continue; + } + + if (bIsInGameThread) + { + EControllerHand HandType; + GetHandType(HandType); + FName GripSource = (HandType == EControllerHand::Left) ? FName("LeftGrip") : FName("RightGrip"); + CurrentTrackingStatus = MotionController->GetControllerTrackingStatus(PlayerIndex, GripSource); + if (!bIgnoreTrackingStatus && CurrentTrackingStatus == ETrackingStatus::NotTracked) + continue; + } + + if (MotionController->GetControllerOrientationAndPosition(PlayerIndex, MotionSource, Orientation, Position, OutbProvidedLinearVelocity, OutLinearVelocity, OutbProvidedAngularVelocity, OutAngularVelocityAsAxisAndLength, OutbProvidedLinearAcceleration, OutLinearAcceleration, WorldToMetersScale)) + { + /*#if PLATFORM_PS4 + // Moving this in here to work around a PSVR module bug + if (bIsInGameThread) + { + CurrentTrackingStatus = MotionController->GetControllerTrackingStatus(PlayerIndex, MotionSource); + if (CurrentTrackingStatus == ETrackingStatus::NotTracked) + continue; + } + #endif*/ + + if (HasTrackingParameters()) + { + ApplyTrackingParameters(Position, bIsInGameThread); + } + + if (bOffsetByControllerProfile) + { + FTransform FinalControllerTransform(Orientation,Position); + if (bIsInGameThread) + { + FinalControllerTransform = CurrentControllerProfileTransform * FinalControllerTransform; + } + else + { + FinalControllerTransform = LateUpdateParams.GripRenderThreadProfileTransform * FinalControllerTransform; + } + + Orientation = FinalControllerTransform.Rotator(); + Position = FinalControllerTransform.GetTranslation(); + } + + InUseMotionController = MotionController; + OnMotionControllerUpdated(); + InUseMotionController = nullptr; + + { + FScopeLock Lock(&PolledMotionControllerMutex); + PolledMotionController_GameThread = MotionController; // We only want a render thread update from the motion controller we polled on the game thread. + } + return true; + } + + /*#if PLATFORM_PS4 + else if (bIsInGameThread) + { + CurrentTrackingStatus = MotionController->GetControllerTrackingStatus(PlayerIndex, MotionSource); + } + #endif*/ + } + // #NOTE: This was adding in 4.20, I presume to allow for HMDs as tracking sources for mixed reality. // Skipping all of my special logic here for now - if (MotionSource == IMotionController::HMDSourceId || MotionSource == IMotionController::HeadSourceId) + if (MotionSource == IMotionController::HMDSourceId) { IXRTrackingSystem* TrackingSys = GEngine->XRSystem.Get(); if (TrackingSys) @@ -7334,81 +7293,6 @@ bool UGripMotionControllerComponent::GripPollControllerState_GameThread(FVector& } } } - else - { - //GripUEMotionController::FScopeLockOptional LockOptional; - TArray MotionControllers; - MotionControllers = IModularFeatures::Get().GetModularFeatureImplementations(IMotionController::GetModularFeatureName()); - for (auto MotionController : MotionControllers) - { - if (MotionController == nullptr) - { - continue; - } - - if (bIsInGameThread) - { - EControllerHand HandType; - GetHandType(HandType); - FName GripSource = (HandType == EControllerHand::Left) ? FName("LeftGrip") : FName("RightGrip"); - - CurrentTrackingStatus = MotionController->GetControllerTrackingStatus(PlayerIndex, MotionSource); - if (!bIgnoreTrackingStatus && CurrentTrackingStatus == ETrackingStatus::NotTracked) - continue; - } - - if (MotionController->GetControllerOrientationAndPosition(PlayerIndex, MotionSource, Orientation, Position, OutbProvidedLinearVelocity, OutLinearVelocity, OutbProvidedAngularVelocity, OutAngularVelocityAsAxisAndLength, OutbProvidedLinearAcceleration, OutLinearAcceleration, WorldToMetersScale)) - { - /*#if PLATFORM_PS4 - // Moving this in here to work around a PSVR module bug - if (bIsInGameThread) - { - CurrentTrackingStatus = MotionController->GetControllerTrackingStatus(PlayerIndex, MotionSource); - if (CurrentTrackingStatus == ETrackingStatus::NotTracked) - continue; - } - #endif*/ - - if (HasTrackingParameters()) - { - ApplyTrackingParameters(Position, bIsInGameThread); - } - - if (bOffsetByControllerProfile) - { - FTransform FinalControllerTransform(Orientation, Position); - if (bIsInGameThread) - { - FinalControllerTransform = CurrentControllerProfileTransform * FinalControllerTransform; - } - else - { - FinalControllerTransform = LateUpdateParams.GripRenderThreadProfileTransform * FinalControllerTransform; - } - - Orientation = FinalControllerTransform.Rotator(); - Position = FinalControllerTransform.GetTranslation(); - } - - InUseMotionController = MotionController; - OnMotionControllerUpdated(); - InUseMotionController = nullptr; - - { - FScopeLock Lock(&PolledMotionControllerMutex); - PolledMotionController_GameThread = MotionController; // We only want a render thread update from the motion controller we polled on the game thread. - } - return true; - } - - /*#if PLATFORM_PS4 - else if (bIsInGameThread) - { - CurrentTrackingStatus = MotionController->GetControllerTrackingStatus(PlayerIndex, MotionSource); - } - #endif*/ - } - } } return false; } @@ -7423,7 +7307,6 @@ bool UGripMotionControllerComponent::GripPollControllerState_RenderThread(FVecto EControllerHand HandType; GetHandType(HandType); FName GripSource = (HandType == EControllerHand::Left) ? FName("LeftGrip") : FName("RightGrip"); - CurrentTrackingStatus = PolledMotionController_RenderThread->GetControllerTrackingStatus(PlayerIndex, GripSource); if (PolledMotionController_RenderThread->GetControllerOrientationAndPosition(PlayerIndex, MotionSource, Orientation, Position, WorldToMetersScale)) { @@ -7759,10 +7642,6 @@ void UGripMotionControllerComponent::Server_NotifyHandledTransaction_Implementat if(LocalTransactionBuffer[i].GripID == GripID) LocalTransactionBuffer.RemoveAt(i); } - -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, LocalTransactionBuffer, this); -#endif } bool UGripMotionControllerComponent::Server_NotifyLocalGripAddedOrChanged_Validate(const FBPActorGripInformation & newGrip) @@ -7772,8 +7651,6 @@ bool UGripMotionControllerComponent::Server_NotifyLocalGripAddedOrChanged_Valida void UGripMotionControllerComponent::Server_NotifyLocalGripAddedOrChanged_Implementation(const FBPActorGripInformation & newGrip) { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - if (!newGrip.GrippedObject || newGrip.GripMovementReplicationSetting != EGripMovementReplicationSettings::ClientSide_Authoritive) { Client_NotifyInvalidLocalGrip(newGrip.GrippedObject, newGrip.GripID); @@ -7894,7 +7771,6 @@ void UGripMotionControllerComponent::Server_NotifyLocalGripAddedOrChanged_Implem } int32 NewIndex = LocallyGrippedObjects.Add(newGrip); - DIRTY_LOCALLY_GRIPPED_OBJECTS(); if (NewIndex != INDEX_NONE && LocallyGrippedObjects.Num() > 0) { @@ -7938,8 +7814,6 @@ bool UGripMotionControllerComponent::Server_NotifyLocalGripRemoved_Validate(uint void UGripMotionControllerComponent::Server_NotifyLocalGripRemoved_Implementation(uint8 GripID, const FTransform_NetQuantize &TransformAtDrop, FVector_NetQuantize100 OptAngularVelocity, FVector_NetQuantize100 OptLinearVelocity) { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - FBPActorGripInformation FoundGrip; EBPVRResultSwitch Result; GetGripByID(FoundGrip, GripID, Result); @@ -7993,7 +7867,6 @@ void UGripMotionControllerComponent::Server_NotifySecondaryAttachmentChanged_Imp uint8 GripID, const FBPSecondaryGripInfo& SecondaryGripInfo) { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); FBPActorGripInformation * GripInfo = LocallyGrippedObjects.FindByKey(GripID); if (GripInfo != nullptr) @@ -8020,7 +7893,6 @@ void UGripMotionControllerComponent::Server_NotifySecondaryAttachmentChanged_Ret uint8 GripID, const FBPSecondaryGripInfo& SecondaryGripInfo, const FTransform_NetQuantize & NewRelativeTransform) { - DIRTY_LOCALLY_GRIPPED_OBJECTS(); FBPActorGripInformation * GripInfo = LocallyGrippedObjects.FindByKey(GripID); if (GripInfo != nullptr) @@ -8121,10 +7993,9 @@ void FExpandedLateUpdateManager::Setup(const FTransform& ParentToWorld, UGripMot //void FExpandedLateUpdateManager::Apply_RenderThread(FSceneInterface* Scene, const int32 FrameNumber, const FTransform& OldRelativeTransform, const FTransform& NewRelativeTransform) void FExpandedLateUpdateManager::Apply_RenderThread(FSceneInterface* Scene, const FTransform& OldRelativeTransform, const FTransform& NewRelativeTransform) { - FRHICommandListBase& RHICmdList = FRHICommandListImmediate::Get(); - check(IsInRenderingThread()); + if (!UpdateStates[LateUpdateRenderReadIndex].Primitives.Num() || UpdateStates[LateUpdateRenderReadIndex].bSkip) { return; @@ -8160,7 +8031,7 @@ void FExpandedLateUpdateManager::Apply_RenderThread(FSceneInterface* Scene, cons } else if (CachedSceneInfo->Proxy) { - CachedSceneInfo->Proxy->ApplyLateUpdateTransform(RHICmdList, LateUpdateTransform); + CachedSceneInfo->Proxy->ApplyLateUpdateTransform(LateUpdateTransform); PrimitivePair.Value = -1; // Set the cached index to -1 to indicate that this primitive was already processed /*if (FrameNumber >= 0) { @@ -8180,7 +8051,7 @@ void FExpandedLateUpdateManager::Apply_RenderThread(FSceneInterface* Scene, cons if (RetrievedSceneInfo->Proxy && PrimitiveIndex != nullptr && *PrimitiveIndex >= 0)*/ if (RetrievedSceneInfo->Proxy && UpdateStates[LateUpdateRenderReadIndex].Primitives.Contains(RetrievedSceneInfo) && UpdateStates[LateUpdateRenderReadIndex].Primitives[RetrievedSceneInfo] >= 0) { - RetrievedSceneInfo->Proxy->ApplyLateUpdateTransform(RHICmdList, LateUpdateTransform); + RetrievedSceneInfo->Proxy->ApplyLateUpdateTransform(LateUpdateTransform); /*if (FrameNumber >= 0) { RetrievedSceneInfo->Proxy->SetPatchingFrameNumber(FrameNumber); @@ -8399,7 +8270,7 @@ bool UGripMotionControllerComponent::GetIsComponentHeld(const UPrimitiveComponen return (GrippedObjects.FindByKey(ComponentToCheck) || LocallyGrippedObjects.FindByKey(ComponentToCheck)); - //return false; + return false; } bool UGripMotionControllerComponent::GetIsSecondaryAttachment(const USceneComponent * ComponentToCheck, FBPActorGripInformation & Grip) @@ -8513,81 +8384,3 @@ bool UGripMotionControllerComponent::HasAuthority() const return bHasAuthority; } -void UGripMotionControllerComponent::CheckTransactionBuffer() -{ - if (LocalTransactionBuffer.Num()) - { - for (int i = LocalTransactionBuffer.Num() - 1; i >= 0; --i) - { - if (LocalTransactionBuffer[i].ValueCache.bWasInitiallyRepped && LocalTransactionBuffer[i].GripID != LocalTransactionBuffer[i].ValueCache.CachedGripID) - { - // There appears to be a bug with TArray replication where if you replace an index with another value of that - // Index, it doesn't fully re-init the object, this is a workaround to re-zero non replicated variables - // when that happens. - LocalTransactionBuffer[i].ClearNonReppingItems(); - } - - if (!LocalTransactionBuffer[i].ValueCache.bWasInitiallyRepped && LocalTransactionBuffer[i].GrippedObject->IsValidLowLevelFast()) - { - LocalTransactionBuffer[i].ValueCache.bWasInitiallyRepped = true; - LocalTransactionBuffer[i].ValueCache.CachedGripID = LocalTransactionBuffer[i].GripID; - - int32 Index = LocallyGrippedObjects.Add(LocalTransactionBuffer[i]); - DIRTY_LOCALLY_GRIPPED_OBJECTS(); - - if (Index != INDEX_NONE) - { - NotifyGrip(LocallyGrippedObjects[Index]); - } - - Server_NotifyHandledTransaction(LocalTransactionBuffer[i].GripID); - } - } - } -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void UGripMotionControllerComponent::SetSmoothReplicatedMotion(bool bNewSmoothReplicatedMotion) -{ - bSmoothReplicatedMotion = bNewSmoothReplicatedMotion; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, bSmoothReplicatedMotion, this); -#endif -} - -void UGripMotionControllerComponent::SetReplicateWithoutTracking(bool bNewReplicateWithoutTracking) -{ - bReplicateWithoutTracking = bNewReplicateWithoutTracking; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, bReplicateWithoutTracking, this); -#endif -} - -void UGripMotionControllerComponent::SetControllerNetUpdateRate(float NewControllerNetUpdateRate) -{ - ControllerNetUpdateRate = NewControllerNetUpdateRate; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, ControllerNetUpdateRate, this); -#endif -} - -void UGripMotionControllerComponent::DIRTY_GRIPPED_OBJECTS() -{ -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, GrippedObjects, this); -#endif -} - -void UGripMotionControllerComponent::DIRTY_LOCALLY_GRIPPED_OBJECTS() -{ -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGripMotionControllerComponent, LocallyGrippedObjects, this); -#endif -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripScripts/GS_Melee.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripScripts/GS_Melee.cpp index 312f6f4..3c1555f 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripScripts/GS_Melee.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/GripScripts/GS_Melee.cpp @@ -46,12 +46,6 @@ UGS_Melee::UGS_Melee(const FObjectInitializer& ObjectInitializer) : bOnlyPenetrateWithTwoHands = false; } -void UGS_Melee::SetIsLodged(bool IsLodged, UPrimitiveComponent* LodgeComponent) -{ - bIsLodged = IsLodged; - LodgedComponent = LodgeComponent; -} - void UGS_Melee::UpdateDualHandInfo() { TArray HoldingControllers; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableActor.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableActor.cpp index 57d69df..0b8b17b 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableActor.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableActor.cpp @@ -19,6 +19,7 @@ #include "Net/Core/PushModel/PushModel.h" #endif + //============================================================================= AGrippableActor::AGrippableActor(const FObjectInitializer& ObjectInitializer) : Super() @@ -61,20 +62,13 @@ void AGrippableActor::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableActor, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableActor, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableActor, bAllowIgnoringAttachOnOwner, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableActor, ClientAuthReplicationData, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableActor, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableActor, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableActor, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(AGrippableActor, GripLogicScripts, COND_Custom); + DOREPLIFETIME(AGrippableActor, bReplicateGripScripts); + DOREPLIFETIME(AGrippableActor, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(AGrippableActor, bAllowIgnoringAttachOnOwner); + DOREPLIFETIME(AGrippableActor, ClientAuthReplicationData); + DOREPLIFETIME_CONDITION(AGrippableActor, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(AGrippableActor, GameplayTags, COND_Custom); DISABLE_REPLICATED_PRIVATE_PROPERTY(AActor, AttachmentReplication); @@ -84,6 +78,7 @@ void AGrippableActor::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty void AGrippableActor::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) { + // Don't replicate if set to not do it DOREPLIFETIME_ACTIVE_OVERRIDE_FAST(AGrippableActor, VRGripInterfaceSettings, bRepGripSettingsAndGameplayTags); DOREPLIFETIME_ACTIVE_OVERRIDE_FAST(AGrippableActor, GameplayTags, bRepGripSettingsAndGameplayTags); @@ -851,80 +846,4 @@ void AGrippableActor::GetSubobjectsWithStableNamesForNetworking(TArray } } } -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void AGrippableActor::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableActor, bReplicateGripScripts, this); -#endif -} - -TArray>& AGrippableActor::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableActor, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void AGrippableActor::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableActor, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void AGrippableActor::SetAllowIgnoringAttachOnOwner(bool bNewAllowIgnoringAttachOnOwner) -{ - bAllowIgnoringAttachOnOwner = bNewAllowIgnoringAttachOnOwner; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableActor, bAllowIgnoringAttachOnOwner, this); -#endif -} - -FVRClientAuthReplicationData& AGrippableActor::GetClientAuthReplicationData(FVRClientAuthReplicationData& ClientAuthData) -{ -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableActor, ClientAuthReplicationData, this); -#endif - return ClientAuthReplicationData; -} - -FBPInterfaceProperties& AGrippableActor::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableActor, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& AGrippableActor::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableActor, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableBoxComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableBoxComponent.cpp index ec8f05d..235959a 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableBoxComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableBoxComponent.cpp @@ -8,10 +8,6 @@ #include "GripScripts/VRGripScriptBase.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - //============================================================================= UGrippableBoxComponent::~UGrippableBoxComponent() { @@ -51,19 +47,12 @@ void UGrippableBoxComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeP { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableBoxComponent, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableBoxComponent, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableBoxComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableBoxComponent, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableBoxComponent, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableBoxComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(UGrippableBoxComponent, GripLogicScripts, COND_Custom); + DOREPLIFETIME(UGrippableBoxComponent, bReplicateGripScripts); + DOREPLIFETIME(UGrippableBoxComponent, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(UGrippableBoxComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UGrippableBoxComponent, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(UGrippableBoxComponent, GameplayTags, COND_Custom); } void UGrippableBoxComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -331,72 +320,4 @@ void UGrippableBoxComponent::OnComponentDestroyed(bool bDestroyingHierarchy) } GripLogicScripts.Empty(); -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void UGrippableBoxComponent::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableBoxComponent, bReplicateGripScripts, this); -#endif -} - -TArray>& UGrippableBoxComponent::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableBoxComponent, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void UGrippableBoxComponent::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableBoxComponent, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void UGrippableBoxComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableBoxComponent, bReplicateMovement, this); -#endif -} - -FBPInterfaceProperties& UGrippableBoxComponent::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableBoxComponent, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& UGrippableBoxComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableBoxComponent, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableCapsuleComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableCapsuleComponent.cpp index 9178cb5..bbb8853 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableCapsuleComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableCapsuleComponent.cpp @@ -8,10 +8,6 @@ #include "GripScripts/VRGripScriptBase.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - //============================================================================= UGrippableCapsuleComponent::UGrippableCapsuleComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -47,19 +43,12 @@ void UGrippableCapsuleComponent::GetLifetimeReplicatedProps(TArray< class FLifet { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableCapsuleComponent, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableCapsuleComponent, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableCapsuleComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableCapsuleComponent, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableCapsuleComponent, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableCapsuleComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(UGrippableCapsuleComponent, GripLogicScripts, COND_Custom); + DOREPLIFETIME(UGrippableCapsuleComponent, bReplicateGripScripts); + DOREPLIFETIME(UGrippableCapsuleComponent, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(UGrippableCapsuleComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UGrippableCapsuleComponent, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(UGrippableCapsuleComponent, GameplayTags, COND_Custom); } void UGrippableCapsuleComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -331,72 +320,4 @@ void UGrippableCapsuleComponent::OnComponentDestroyed(bool bDestroyingHierarchy) } GripLogicScripts.Empty(); -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void UGrippableCapsuleComponent::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableCapsuleComponent, bReplicateGripScripts, this); -#endif -} - -TArray>& UGrippableCapsuleComponent::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableCapsuleComponent, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void UGrippableCapsuleComponent::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableCapsuleComponent, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void UGrippableCapsuleComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableCapsuleComponent, bReplicateMovement, this); -#endif -} - -FBPInterfaceProperties& UGrippableCapsuleComponent::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableCapsuleComponent, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& UGrippableCapsuleComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableCapsuleComponent, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippablePhysicsReplication.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippablePhysicsReplication.cpp index d727289..284a52a 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippablePhysicsReplication.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippablePhysicsReplication.cpp @@ -1,31 +1,21 @@ - -/*============================================================================= - PhysicsReplication.cpp: Code for keeping replicated physics objects in sync with the server based on replicated server state data. - Copy / override of this class for VR client authority -=============================================================================*/ - +// Fill out your copyright notice in the Description page of Project Settings. #include "Grippables/GrippablePhysicsReplication.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(GrippablePhysicsReplication) -#include "CoreMinimal.h" -#include "PhysicsEngine\BodyInstance.h" -#include "Components/PrimitiveComponent.h" -#include "Components/SkeletalMeshComponent.h" #include "UObject/ObjectMacros.h" #include "UObject/Interface.h" #include "DrawDebugHelpers.h" #include "Chaos/ChaosMarshallingManager.h" #include "PhysicsProxy/SingleParticlePhysicsProxy.h" #include "Chaos/PhysicsObjectInternalInterface.h" - +#include "Chaos/PhysicsObject.h" #include "PBDRigidsSolver.h" #include "Chaos/PBDRigidsEvolutionGBF.h" #include "VRGlobalSettings.h" #include "PhysicsEngine/PhysicsSettings.h" #include "Physics/Experimental/PhysScene_Chaos.h" #include "Chaos/DebugDrawQueue.h" -#include "Chaos/Particles.h" //#include "Components/SkeletalMeshComponent.h" #include "Misc/ScopeRWLock.h" @@ -41,71 +31,6 @@ namespace VRPhysicsReplicationStatics static bool bHasVRPhysicsReplication = false; } -// Hacky work around for them not exporting these.... -#if WITH_EDITOR -namespace PhysicsReplicationCVars -{ - int32 SkipSkeletalRepOptimization = 1; -#if !UE_BUILD_SHIPPING - //int32 LogPhysicsReplicationHardSnaps = 0; -#endif - - int32 EnableDefaultReplication = 0; - - namespace ResimulationCVars - { - bool bRuntimeCorrectionEnabled = true; - bool bRuntimeVelocityCorrection = false; - bool bRuntimeCorrectConnectedBodies = true; - float PosStabilityMultiplier = 0.5f; - float RotStabilityMultiplier = 1.0f; - float VelStabilityMultiplier = 0.5f; - float AngVelStabilityMultiplier = 0.5f; - bool bDrawDebug = false; - } - - namespace PredictiveInterpolationCVars - { - float PosCorrectionTimeBase = 0.0f; - float PosCorrectionTimeMin = 0.1f; - float PosCorrectionTimeMultiplier = 1.0f; - float RotCorrectionTimeBase = 0.0f; - float RotCorrectionTimeMin = 0.1f; - float RotCorrectionTimeMultiplier = 1.0f; - float PosInterpolationTimeMultiplier = 1.1f; - float RotInterpolationTimeMultiplier = 1.25f; - float AverageReceiveIntervalSmoothing = 3.0f; - float ExtrapolationTimeMultiplier = 3.0f; - float ExtrapolationMinTime = 0.75f; - float MinExpectedDistanceCovered = 0.5f; - float ErrorAccumulationDecreaseMultiplier = 0.5f; - float ErrorAccumulationSeconds = 3.0f; - bool bDisableErrorVelocityLimits = false; - float ErrorAccLinVelMaxLimit = 50.0f; - float ErrorAccAngVelMaxLimit = 1.5f; - float SoftSnapPosStrength = 0.5f; - float SoftSnapRotStrength = 0.5f; - bool bSoftSnapToSource = false; - float EarlyOutDistanceSqr = 1.0f; - float EarlyOutAngle = 1.5f; - bool bEarlyOutWithVelocity = true; - bool bSkipVelocityRepOnPosEarlyOut = true; - bool bPostResimWaitForUpdate = false; - bool bVelocityBased = true; - bool bPosCorrectionAsVelocity = false; - bool bDisableSoftSnap = false; - bool bAlwaysHardSnap = false; - bool bSkipReplication = false; - bool bDontClearTarget = false; - bool bDrawDebugTargets = false; - bool bDrawDebugVectors = false; - float SleepSecondsClearTarget = 15.0f; - int32 TargetTickAlignmentClampMultiplier = 1; - } - -} -#endif - /*struct FAsyncPhysicsRepCallbackDataVR : public Chaos::FSimCallbackInput { TArray Buffer; @@ -281,7 +206,7 @@ bool FPhysicsReplicationVR::ApplyRigidBodyState(float DeltaSeconds, FBodyInstanc return ApplyRigidBodyState(DeltaSeconds, BI, PhysicsTarget, ErrorCorrection, InPingSecondsOneWay); } -/*void FPhysicsReplicationVR::SetReplicatedTarget(UPrimitiveComponent* Component, FName BoneName, const FRigidBodyState& ReplicatedTarget, int32 ServerFrame) +void FPhysicsReplicationVR::SetReplicatedTarget(UPrimitiveComponent* Component, FName BoneName, const FRigidBodyState& ReplicatedTarget, int32 ServerFrame) { // Skip all of the custom logic if we aren't the server @@ -297,30 +222,25 @@ bool FPhysicsReplicationVR::ApplyRigidBodyState(float DeltaSeconds, FBodyInstanc // If networked physics prediction is enabled, enforce the new physics replication flow via SetReplicatedTarget() using PhysicsObject instead of BodyInstance from BoneName. AActor* Owner = Component->GetOwner(); - - if (Owner && (CVarEnableDefaultReplication->GetBool() || Owner->GetPhysicsReplicationMode() != EPhysicsReplicationMode::Default)) // For now, only opt in to the PhysicsObject flow if not using Default replication or if default is allowed via CVar. + if (UPhysicsSettings::Get()->PhysicsPrediction.bEnablePhysicsPrediction && Owner && + (CVarEnableDefaultReplication->GetInt() || Owner->GetPhysicsReplicationMode() != EPhysicsReplicationMode::Default)) // For now, only opt in to the PhysicsObject flow if not using Default replication or if default is allowed via CVar. { const ENetRole OwnerRole = Owner->GetLocalRole(); const bool bIsSimulated = OwnerRole == ROLE_SimulatedProxy; const bool bIsReplicatedAutonomous = OwnerRole == ROLE_AutonomousProxy && Component->bReplicatePhysicsToAutonomousProxy; if (bIsSimulated || bIsReplicatedAutonomous) { - Chaos::FConstPhysicsObjectHandle PhysicsObject = Component->GetPhysicsObjectByName(BoneName); + Chaos::FPhysicsObjectHandle PhysicsObject = Component->GetPhysicsObjectByName(BoneName); SetReplicatedTargetVR(PhysicsObject, ReplicatedTarget, ServerFrame, Owner->GetPhysicsReplicationMode()); return; } } return FPhysicsReplication::SetReplicatedTarget(Component, BoneName, ReplicatedTarget, ServerFrame); -}*/ +} -void FPhysicsReplicationVR::SetReplicatedTargetVR(Chaos::FConstPhysicsObjectHandle PhysicsObject, const FRigidBodyState& ReplicatedTarget, int32 ServerFrame, EPhysicsReplicationMode ReplicationMode) +void FPhysicsReplicationVR::SetReplicatedTargetVR(Chaos::FPhysicsObject* PhysicsObject, const FRigidBodyState& ReplicatedTarget, int32 ServerFrame, EPhysicsReplicationMode ReplicationMode) { - if (!PhysicsObject) - { - return; - } - UWorld* OwningWorld = GetOwningWorld(); if (OwningWorld == nullptr) { @@ -329,8 +249,8 @@ void FPhysicsReplicationVR::SetReplicatedTargetVR(Chaos::FConstPhysicsObjectHand // TODO, Check if owning actor is ROLE_SimulatedProxy or ROLE_AutonomousProxy ? - FReplicatedPhysicsTarget Target(PhysicsObject); - + FReplicatedPhysicsTarget Target; + Target.PhysicsObject = PhysicsObject; Target.ReplicationMode = ReplicationMode; Target.ServerFrame = ServerFrame; Target.TargetState = ReplicatedTarget; @@ -341,35 +261,6 @@ void FPhysicsReplicationVR::SetReplicatedTargetVR(Chaos::FConstPhysicsObjectHand ReplicatedTargetsQueueVR.Add(Target); } -void FPhysicsReplicationVR::RemoveReplicatedTarget(UPrimitiveComponent* Component) -{ - - // Skip all of the custom logic if we aren't the server - if (const UWorld* World = GetOwningWorld()) - { - if (World->GetNetMode() == ENetMode::NM_Client) - { - return FPhysicsReplication::RemoveReplicatedTarget(Component); - } - } - - if (Component == nullptr) - { - return; - } - - // Call super version to ensure its removed from the inaccessible deprecated targets list - FPhysicsReplication::RemoveReplicatedTarget(Component); - - // Remove from legacy flow - //ComponentToTargets_DEPRECATED.Remove(Component); - - // Remove from FPhysicsObject flow - Chaos::FConstPhysicsObjectHandle PhysicsObject = Component->GetPhysicsObjectByName(NAME_None); - FReplicatedPhysicsTarget Target(PhysicsObject); // This creates a new but empty target and when it tries to update the current target in the async flow it will remove it from replication since it's empty. - ReplicatedTargetsQueueVR.Add(Target); -} - bool FPhysicsReplicationVR::ApplyRigidBodyState(float DeltaSeconds, FBodyInstance* BI, FReplicatedPhysicsTarget& PhysicsTarget, const FRigidBodyErrorCorrection& ErrorCorrection, const float PingSecondsOneWay, bool* bDidHardSnap) { // Skip all of the custom logic if we aren't the server @@ -630,11 +521,12 @@ bool FPhysicsReplicationVR::ApplyRigidBodyState(float DeltaSeconds, FBodyInstanc else { //If async is used, enqueue for callback - FPhysicsRepAsyncInputData AsyncInputData(nullptr); + FPhysicsRepAsyncInputData AsyncInputData; AsyncInputData.TargetState = NewState; AsyncInputData.TargetState.Position = IdealWorldTM.GetLocation(); AsyncInputData.TargetState.Quaternion = IdealWorldTM.GetRotation(); AsyncInputData.Proxy = static_cast(BI->GetPhysicsActorHandle()); + AsyncInputData.PhysicsObject = nullptr; AsyncInputData.ErrorCorrection = { ErrorCorrection.LinearVelocityCoefficient, ErrorCorrection.AngularVelocityCoefficient, ErrorCorrection.PositionLerp, ErrorCorrection.AngleLerp }; AsyncInputData.LatencyOneWay = PingSeconds; @@ -722,7 +614,7 @@ void FPhysicsReplicationVR::OnTick(float DeltaSeconds, TMapGetFirstPlayerController()) { - LocalFrameOffset = PlayerController->GetNetworkPhysicsTickOffset(); + LocalFrameOffset = PlayerController->GetServerToLocalAsyncPhysicsTickOffset(); } } } @@ -739,29 +631,33 @@ void FPhysicsReplicationVR::OnTick(float DeltaSeconds, TMapGetAttachParent() == nullptr) + { + if (FBodyInstance* BI = PrimComp->GetBodyInstance(Itr.Value().BoneName)) { - if (FBodyInstance* BI = PrimComp->GetBodyInstance(Itr.Value().BoneName)) + FReplicatedPhysicsTarget& PhysicsTarget = Itr.Value(); + FRigidBodyState& UpdatedState = PhysicsTarget.TargetState; + bool bUpdated = false; + if (AActor* OwningActor = PrimComp->GetOwner()) { - FReplicatedPhysicsTarget& PhysicsTarget = Itr.Value(); - FRigidBodyState& UpdatedState = PhysicsTarget.TargetState; - bool bUpdated = false; - if (AActor* OwningActor = PrimComp->GetOwner()) + // Remove if there is no owner + if (!OwningActor->GetNetOwningPlayer()) + { + bRemoveItr = true; + } + else { // Removed as this is server sided - /* - const ENetRole OwnerRole = OwningActor->GetLocalRole(); + /*const ENetRole OwnerRole = OwningActor->GetLocalRole(); const bool bIsSimulated = OwnerRole == ROLE_SimulatedProxy; const bool bIsReplicatedAutonomous = OwnerRole == ROLE_AutonomousProxy && PrimComp->bReplicatePhysicsToAutonomousProxy; if (bIsSimulated || bIsReplicatedAutonomous)*/ + // Deleted everything here, we will always be the server, I already filtered out clients to default logic { - // Get the ping of this thing's owner. If nobody owns it, - // then it's server authoritative. /*const*/ float OwnerPing = 0.0f;// GetOwnerPing(OwningActor, PhysicsTarget); /*if (UPlayer* OwningPlayer = OwningActor->GetNetOwningPlayer()) @@ -780,10 +676,12 @@ void FPhysicsReplicationVR::OnTick(float DeltaSeconds, TMapSyncComponentToRBPhysics(); } - if (bRestoredState) + + // Added a sleeping check from the input state as well, we always want to cease activity on sleep + if (bRestoredState /* || ((UpdatedState.Flags & ERigidBodyFlags::Sleeping) != 0)*/) { bRemoveItr = true; } @@ -800,31 +700,34 @@ void FPhysicsReplicationVR::OnTick(float DeltaSeconds, TMapInputData.Add(AsyncInputData); + AsyncInputVR->InputData.Add(AsyncInputData); + } } ReplicatedTargetsQueueVR.Reset(); @@ -914,48 +817,8 @@ bool FRepMovementVR::GatherActorsMovement(AActor* OwningActor) return true; } - -#pragma region FPhysicsReplicationAsync - -void FPhysicsReplicationAsyncVR::OnPhysicsObjectUnregistered_Internal(Chaos::FConstPhysicsObjectHandle PhysicsObject) -{ - ObjectToTarget.Remove(PhysicsObject); - ObjectToSettings.Remove(PhysicsObject); -} - -void FPhysicsReplicationAsyncVR::RegisterSettings(Chaos::FConstPhysicsObjectHandle PhysicsObject, FNetworkPhysicsSettingsAsync InSettings) -{ - if (PhysicsObject != nullptr) - { - FNetworkPhysicsSettingsAsync& Settings = ObjectToSettings.FindOrAdd(PhysicsObject); - Settings = InSettings; - } -} - -void FPhysicsReplicationAsyncVR::FetchObjectSettings(Chaos::FConstPhysicsObjectHandle PhysicsObject) -{ - FNetworkPhysicsSettingsAsync* CustomSettings = ObjectToSettings.Find(PhysicsObject); - SettingsCurrent = (CustomSettings != nullptr) ? *CustomSettings : SettingsDefault; -} - -void FPhysicsReplicationAsyncVR::OnPostInitialize_Internal() -{ - Chaos::FPBDRigidsSolver* RigidsSolver = static_cast(GetSolver()); - - if (ensure(RigidsSolver)) - { - // This doesn't even do anything currently, nothing gets it #TODO: CHECK BACK ON THIS - //RigidsSolver->SetPhysicsReplication(this); - } -} - void FPhysicsReplicationAsyncVR::OnPreSimulate_Internal() { - if (FPhysicsReplication::ShouldSkipPhysicsReplication()) - { - return; - } - if (const FPhysicsReplicationAsyncInput* AsyncInput = GetConsumerInput_Internal()) { Chaos::FPBDRigidsSolver* RigidsSolver = static_cast(GetSolver()); @@ -963,12 +826,11 @@ void FPhysicsReplicationAsyncVR::OnPreSimulate_Internal() // Early out if this is a resim frame Chaos::FRewindData* RewindData = RigidsSolver->GetRewindData(); - const bool bRewindDataExist = RewindData != nullptr; - if (bRewindDataExist && RewindData->IsResim()) + if (RewindData && RewindData->IsResim()) { - // TODO, Handle the transition from post-resim to interpolation better (disabled by default, resim vs replication interaction is handled via FPhysicsReplicationAsync::CacheResimInteractions) + // TODO, Handle the transition from post-resim to interpolation better. static const auto CVarPostResimWaitForUpdate = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.PostResimWaitForUpdate")); - if (CVarPostResimWaitForUpdate->GetBool() && RewindData->IsFinalResim()) + if (CVarPostResimWaitForUpdate->GetBool() && RewindData->IsFinalResim()) { for (auto Itr = ObjectToTarget.CreateIterator(); Itr; ++Itr) { @@ -977,7 +839,8 @@ void FPhysicsReplicationAsyncVR::OnPreSimulate_Internal() // If final resim frame, mark interpolated targets as waiting for up to date data from the server. if (Target.RepMode == EPhysicsReplicationMode::PredictiveInterpolation) { - Target.SetWaiting(RigidsSolver->GetCurrentFrame() + Target.FrameOffset, Target.RepModeOverride); + Target.bWaiting = true; + Target.ServerFrame = RigidsSolver->GetCurrentFrame() + Target.FrameOffset; } } } @@ -988,30 +851,8 @@ void FPhysicsReplicationAsyncVR::OnPreSimulate_Internal() // Update async targets with target input for (const FPhysicsRepAsyncInputData& Input : AsyncInput->InputData) { - if (Input.TargetState.Flags == ERigidBodyFlags::None) - { - // Remove replication target - ObjectToTarget.Remove(Input.PhysicsObject); - continue; - } - - if (!bRewindDataExist && Input.RepMode == EPhysicsReplicationMode::Resimulation) - { - // We don't have rewind data but an actor is set to replicate using resimulation; we need to enable rewind capture. - if (ensure(Chaos::FPBDRigidsSolver::IsNetworkPhysicsPredictionEnabled())) - { - const int32 NumFrames = FMath::Max(1, Chaos::FPBDRigidsSolver::GetPhysicsHistoryCount()); - RigidsSolver->EnableRewindCapture(NumFrames, true); - } - } - UpdateRewindDataTarget(Input); - UpdateAsyncTarget(Input, RigidsSolver); - } - - if (Chaos::FPBDRigidsSolver::IsNetworkPhysicsPredictionEnabled()) - { - CacheResimInteractions(); + UpdateAsyncTarget(Input); } ApplyTargetStatesAsync(GetDeltaTime_Internal(), AsyncInput->ErrorCorrection, AsyncInput->InputData); @@ -1038,7 +879,9 @@ void FPhysicsReplicationAsyncVR::UpdateRewindDataTarget(const FPhysicsRepAsyncIn } Chaos::FReadPhysicsObjectInterface_Internal Interface = Chaos::FPhysicsObjectInternalInterface::GetRead(); - if (Chaos::FGeometryParticleHandle* Handle = Interface.GetParticle(Input.PhysicsObject)) + Chaos::FPBDRigidParticleHandle* Handle = Interface.GetRigidParticle(Input.PhysicsObject); + + if (Handle != nullptr) { // Cache all target states inside RewindData const int32 LocalFrame = Input.ServerFrame - Input.FrameOffset; @@ -1048,7 +891,7 @@ void FPhysicsReplicationAsyncVR::UpdateRewindDataTarget(const FPhysicsRepAsyncIn } } -void FPhysicsReplicationAsyncVR::UpdateAsyncTarget(const FPhysicsRepAsyncInputData& Input, Chaos::FPBDRigidsSolver* RigidsSolver) +void FPhysicsReplicationAsyncVR::UpdateAsyncTarget(const FPhysicsRepAsyncInputData& Input) { if (Input.PhysicsObject == nullptr) { @@ -1056,142 +899,34 @@ void FPhysicsReplicationAsyncVR::UpdateAsyncTarget(const FPhysicsRepAsyncInputDa } FReplicatedPhysicsTargetAsync* Target = ObjectToTarget.Find(Input.PhysicsObject); - bool bFirstTarget = Target == nullptr; - if (bFirstTarget) + if (Target == nullptr) { - // First time we add a target, set previous state to current input - Target = &ObjectToTarget.Add(Input.PhysicsObject, FReplicatedPhysicsTargetAsync()); + // First time we add a target, set it's previous and correction + // positions to the target position to avoid math with uninitialized + // memory. + Target = &ObjectToTarget.Add(Input.PhysicsObject); Target->PrevPos = Input.TargetState.Position; Target->PrevPosTarget = Input.TargetState.Position; Target->PrevRotTarget = Input.TargetState.Quaternion; Target->PrevLinVel = Input.TargetState.LinVel; - Target->RepModeOverride = Input.RepMode; } - /** Target Update Description - * @param Input = incoming state target for replication. - * - * Input comes mainly from the server but can be a faked state produced by the client for example if the client object wakes up from sleeping. - * Fake inputs should have a ServerFrame of -1 (bool bIsFake = Input.ServerFrame == -1) - * Server inputs can have ServerFrame values of either 0 or an incrementing integer value. - * If the ServerFrame is 0 it should always be 0. If it's incrementing it will always increment. - * - * @local Target = The current state target used for replication, to be updated with data from Input. - * Read about the different target properties in FReplicatedPhysicsTargetAsync - * - * IMPORTANT: - * Target.ServerFrame can be -1 if the target is newly created or if it has data from a fake input. - * - * SendInterval is calculated by taking Input.ServerFrame - Target.ServerFrame - * Note, can only be calculated if the server is sending incrementing SendIntervals and if we have received a valid input previously so we have the previous ServerFrame cached in Target. - * - * ReceiveInterval is calculated by taking RigidsSolver->GetCurrentFrame() - Target.ReceiveFrame - * Note that ReceiveInterval is only used if SendInterval is 0 - * - * Target.TickCount starts at 0 and is incremented each tick that the target is used for, TickCount is reset back to 0 each time Target is updated with new Input. - * - * NOTE: With perfect network conditions SendInterval, ReceiveInterval and Target.TickCount will be the same value. - */ - - if ((bFirstTarget || Input.ServerFrame == 0 || Input.ServerFrame > Target->ServerFrame)) + if (Input.ServerFrame > Target->ServerFrame) { - // Get the current physics frame - const int32 CurrentFrame = RigidsSolver->GetCurrentFrame(); - - // Cache TickCount before updating it, force to 0 if ServerFrame is -1 - const int32 PrevTickCount = (Target->ServerFrame < 0) ? 0 : Target->TickCount; - - // Cache SendInterval, only calculate if we have a valid Target->ServerFrame, else leave at 0. - const int32 SendInterval = (Target->ServerFrame <= 0) ? 0 : Input.ServerFrame - Target->ServerFrame; - - // Cache if this target was previously allowed to be altered, before this update - const bool bPrevAllowTargetAltering = Target->bAllowTargetAltering; - - // Set if the target is allowed to be altered after this update - Target->bAllowTargetAltering = !(Target->TargetState.Flags & ERigidBodyFlags::Sleeping) && !(Input.TargetState.Flags & ERigidBodyFlags::Sleeping); - - // Set Target->ReceiveInterval from either SendInterval or the number of physics ticks between receiving input states - if (SendInterval > 0) - { - Target->ReceiveInterval = SendInterval; - } - else - { - const int32 PrevReceiveFrame = Target->ReceiveFrame < 0 ? (CurrentFrame - 1) : Target->ReceiveFrame; - Target->ReceiveInterval = (CurrentFrame - PrevReceiveFrame); - } - - // Update target from input and reset properties - PRAGMA_DISABLE_DEPRECATION_WARNINGS - Target->PrevServerFrame = Target->bWaiting ? Input.ServerFrame : Target->ServerFrame; // DEPRECATED UE5.4 - Target->PrevReceiveFrame = (Target->ReceiveFrame == INDEX_NONE) ? (RigidsSolver->GetCurrentFrame() - 1) : Target->ReceiveFrame; // DEPRECATED UE5.4 - PRAGMA_ENABLE_DEPRECATION_WARNINGS - Target->ServerFrame = Input.ServerFrame; - Target->ReceiveFrame = CurrentFrame; + Target->PhysicsObject = Input.PhysicsObject; + Target->PrevServerFrame = Target->ServerFrame; + Target->ServerFrame = Input.ServerFrame; Target->TargetState = Input.TargetState; Target->RepMode = Input.RepMode; Target->FrameOffset = Input.FrameOffset; Target->TickCount = 0; - Target->AccumulatedSleepSeconds = 0.0f; - - // Update waiting state - Target->UpdateWaiting(Input.ServerFrame); + Target->bWaiting = false; if (Input.RepMode == EPhysicsReplicationMode::PredictiveInterpolation) { - -#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) - static const auto CVarDrawDebugTargets = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.DrawDebugTargets")); - if (CVarDrawDebugTargets->GetBool()) - { - const FVector Offset = FVector(0.0f, 0.0f, 50.0f); - - static const auto CVarNetCorrectionLifetime = IConsoleManager::Get().FindConsoleVariable(TEXT("p.NetCorrectionLifetime")); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugBox(Input.TargetState.Position + Offset, FVector(15.0f, 15.0f, 15.0f), Input.TargetState.Quaternion, FColor::MakeRandomSeededColor(Input.ServerFrame), false, CVarNetCorrectionLifetime->GetFloat(), 0, 1.0f); - } -#endif - // Cache the position we received this target at, Predictive Interpolation will alter the target state but use this as the source position for reconciliation. Target->PrevPosTarget = Input.TargetState.Position; Target->PrevRotTarget = Input.TargetState.Quaternion; - - { - /** Target Alignment Feature - * With variable network conditions state inputs from the server can arrive both later or earlier than expected. - * Target Alignment can adjust for this to make replication act on a target in the timeline that the client is currently replicating in. - * - * If SendInterval is 4 we expect TickCount to be 4. TickCount - SendInterval = 0, meaning the client and server has ticked physics the same amount between the target states. - * - * If SendInterval is 4 and TickCount is 2 we have only simulated physics for 2 ticks with the previous target while the server had simulated physics 4 ticks between previous target and new target - * TickCount - SendInterval = -2 - * To align this we need to adjust the new target by predicting backwards by 2 ticks, else the replication will start replicating towards a state that is 2 ticks further ahead than expected, making replication speed up. - * - * Same goes for vice-versa: - * If SendInterval is 4 and TickCount is 6 we have simulated physics for 6 ticks with the previous target while the server had simulated physics 4 ticks between previous target and new target - * TickCount - SendInterval = 2 - * To align this we need to adjust the new target by predicting forwards by 2 ticks, else the replication will start replicating towards a state that is 2 ticks behind than expected, making replication slow down. - * - * Note that state inputs from the server can arrive fluctuating between above examples, but over time the alignment is evened out to 0. - * If the clients latency is raised or lowered since replication started there might be a consistent offset in the TickCount which is handled by TimeDilation of client physics through APlayerController::UpdateServerAsyncPhysicsTickOffset() - */ - - // Run target alignment if we have been allowed to alter the target during the last two target updates - if (!bFirstTarget && bPrevAllowTargetAltering && Target->bAllowTargetAltering) - { - static const auto CVarTargetTickAlignmentClampMultiplier = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.TargetTickAlignmentClampMultiplier")); - const int32 AdjustedAverageReceiveInterval = FMath::CeilToInt(Target->AverageReceiveInterval) * CVarTargetTickAlignmentClampMultiplier->GetInt(); - - // Set the TickCount to the physics tick offset value from where we expected this target to arrive. - // If the client has ticked 2 times ahead from the last target and this target is 3 ticks in front of the previous target then the TickOffset should be -1 - Target->TickCount = FMath::Clamp(PrevTickCount - Target->ReceiveInterval, -AdjustedAverageReceiveInterval, AdjustedAverageReceiveInterval); - - // Apply target alignment if we aren't waiting for a newer state from the server - if (!Target->IsWaiting()) - { - FPhysicsReplicationAsyncVR::ExtrapolateTarget(*Target, Target->TickCount, GetDeltaTime_Internal()); - } - } - } } } @@ -1199,47 +934,11 @@ void FPhysicsReplicationAsyncVR::UpdateAsyncTarget(const FPhysicsRepAsyncInputDa LatencyOneWay = Input.LatencyOneWay; } - -void FPhysicsReplicationAsyncVR::CacheResimInteractions() -{ - static const auto CVarResimDisableReplicationOnInteraction = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.Resim.DisableReplicationOnInteraction")); - if (!CVarResimDisableReplicationOnInteraction->GetBool()) - { - return; - } - - Chaos::FPBDRigidsSolver* RigidsSolver = static_cast(GetSolver()); - if (RigidsSolver == nullptr) - { - return; - } - - ParticlesInResimIslands.Empty(FMath::CeilToInt(static_cast(ParticlesInResimIslands.Num()) * 0.9f)); - Chaos::Private::FPBDIslandManager& IslandManager = RigidsSolver->GetEvolution()->GetIslandManager(); - Chaos::FWritePhysicsObjectInterface_Internal Interface = Chaos::FPhysicsObjectInternalInterface::GetWrite(); - for (auto Itr = ObjectToTarget.CreateIterator(); Itr; ++Itr) - { - FReplicatedPhysicsTargetAsync& Target = Itr.Value(); - if (Target.RepMode == EPhysicsReplicationMode::Resimulation) - { - Chaos::FConstPhysicsObjectHandle& POHandle = Itr.Key(); - if (Chaos::FGeometryParticleHandle* Handle = Interface.GetParticle(POHandle)) - { - // Get a list of particles from the same island as a resim particle is in, i.e. particles interacting with a resim particle - for (const Chaos::FGeometryParticleHandle* InteractParticle : IslandManager.FindParticlesInIslands(IslandManager.FindParticleIslands(Handle))) - { - ParticlesInResimIslands.Add(InteractParticle->GetHandleIdx()); - } - } - } - } -} - void FPhysicsReplicationAsyncVR::ApplyTargetStatesAsync(const float DeltaSeconds, const FPhysicsRepErrorCorrectionData& ErrorCorrection, const TArray& InputData) { using namespace Chaos; - // Deprecated, legacy BodyInstance flow + // Deprecated, BodyInstance flow for (const FPhysicsRepAsyncInputData& Input : InputData) { if (Input.Proxy != nullptr) @@ -1253,38 +952,40 @@ void FPhysicsReplicationAsyncVR::ApplyTargetStatesAsync(const float DeltaSeconds } // PhysicsObject flow - Chaos::FWritePhysicsObjectInterface_Internal Interface = Chaos::FPhysicsObjectInternalInterface::GetWrite(); for (auto Itr = ObjectToTarget.CreateIterator(); Itr; ++Itr) { bool bRemoveItr = true; // Remove current cached replication target unless replication logic tells us to store it for next tick - Chaos::FConstPhysicsObjectHandle& POHandle = Itr.Key(); - if (FGeometryParticleHandle* Handle = Interface.GetParticle(POHandle)) + FReplicatedPhysicsTargetAsync& Target = Itr.Value(); + + if (Target.PhysicsObject != nullptr) { - FReplicatedPhysicsTargetAsync& Target = Itr.Value(); + Chaos::FWritePhysicsObjectInterface_Internal Interface = Chaos::FPhysicsObjectInternalInterface::GetWrite(); + FPBDRigidParticleHandle* Handle = Interface.GetRigidParticle(Target.PhysicsObject); - - if (FPBDRigidParticleHandle* RigidHandle = Handle->CastToRigidParticle()) + if (Handle != nullptr) { - // Cache custom settings for this object if there are any - FetchObjectSettings(POHandle); + // TODO, Remove the resim option from project settings, we only need the physics prediction one now + EPhysicsReplicationMode RepMode = Target.RepMode; + if (!Chaos::FPBDRigidsSolver::IsPhysicsResimulationEnabled() && RepMode == EPhysicsReplicationMode::Resimulation) + { + RepMode = EPhysicsReplicationMode::Default; + } - const EPhysicsReplicationMode RepMode = Target.IsWaiting() ? Target.RepModeOverride : Target.RepMode; switch (RepMode) { case EPhysicsReplicationMode::Default: - bRemoveItr = DefaultReplication(RigidHandle, Target, DeltaSeconds); + bRemoveItr = DefaultReplication(Handle, Target, DeltaSeconds); break; case EPhysicsReplicationMode::PredictiveInterpolation: - bRemoveItr = PredictiveInterpolation(RigidHandle, Target, DeltaSeconds); + bRemoveItr = PredictiveInterpolation(Handle, Target, DeltaSeconds); break; case EPhysicsReplicationMode::Resimulation: - bRemoveItr = ResimulationReplication(RigidHandle, Target, DeltaSeconds); + bRemoveItr = ResimulationReplication(Handle, Target, DeltaSeconds); break; } - Target.TickCount++; } } @@ -1358,12 +1059,6 @@ bool FPhysicsReplicationAsyncVR::DefaultReplication(Chaos::FPBDRigidParticleHand return true; } - static const auto CVarResimDisableReplicationOnInteraction = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.Resim.DisableReplicationOnInteraction")); - if (CVarResimDisableReplicationOnInteraction->GetBool() && ParticlesInResimIslands.Contains(Handle->GetHandleIdx())) - { - return false; - } - // // NOTES: // @@ -1402,7 +1097,7 @@ bool FPhysicsReplicationAsyncVR::DefaultReplication(Chaos::FPBDRigidParticleHand const FString ObjectName #if CHAOS_DEBUG_NAME - = Handle && Handle->DebugName() ? *Handle->DebugName() : FString(TEXT("")); + = Handle->DebugName() ? *Handle->DebugName() : FString(TEXT("")); #else = FString(TEXT("")); #endif @@ -1467,10 +1162,10 @@ bool FPhysicsReplicationAsyncVR::DefaultReplication(Chaos::FPBDRigidParticleHand // Get Current state FRigidBodyState CurrentState; - CurrentState.Position = Handle->GetX(); - CurrentState.Quaternion = Handle->GetR(); - CurrentState.AngVel = Handle->GetW(); - CurrentState.LinVel = Handle->GetV(); + CurrentState.Position = Handle->X(); + CurrentState.Quaternion = Handle->R(); + CurrentState.AngVel = Handle->W(); + CurrentState.LinVel = Handle->V(); // Starting from the last known authoritative position, and @@ -1622,13 +1317,7 @@ bool FPhysicsReplicationAsyncVR::DefaultReplication(Chaos::FPBDRigidParticleHand */ bool FPhysicsReplicationAsyncVR::PredictiveInterpolation(Chaos::FPBDRigidParticleHandle* Handle, FReplicatedPhysicsTargetAsync& Target, const float DeltaSeconds) { - static const auto CVarSkipReplication = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.SkipReplication")); - if (CVarSkipReplication->GetBool()) - { - return true; - } - - if (Target.IsWaiting()) + if (Target.bWaiting) { return false; } @@ -1639,341 +1328,171 @@ bool FPhysicsReplicationAsyncVR::PredictiveInterpolation(Chaos::FPBDRigidParticl return true; } - static const auto CVarResimDisableReplicationOnInteraction = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.Resim.DisableReplicationOnInteraction")); - if (CVarResimDisableReplicationOnInteraction->GetBool() && ParticlesInResimIslands.Contains(Handle->GetHandleIdx())) - { - // If particle is in an island with a resim object, don't run replication and wait for an up to date target (after leaving the island) - Target.SetWaiting(RigidsSolver->GetCurrentFrame() + Target.FrameOffset, EPhysicsReplicationMode::Resimulation); - return false; - } + static const auto CVarErrorAccumulationSeconds = IConsoleManager::Get().FindConsoleVariable(TEXT("p.ErrorAccumulationSeconds")); + const float ErrorAccumulationSeconds = CVarErrorAccumulationSeconds->GetFloat() >= 0.0f ? CVarErrorAccumulationSeconds->GetFloat() : ErrorCorrectionDefault.ErrorAccumulationSeconds; + + static const auto CVarMaxRestoredStateError = IConsoleManager::Get().FindConsoleVariable(TEXT("p.MaxRestoredStateError")); + const float MaxRestoredStateErrorSqr = CVarMaxRestoredStateError->GetFloat() >= 0.0f ? + (CVarMaxRestoredStateError->GetFloat() * CVarMaxRestoredStateError->GetFloat()) : + (ErrorCorrectionDefault.MaxRestoredStateError * ErrorCorrectionDefault.MaxRestoredStateError); -#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) - static const auto CVarDrawDebugTargets = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.DrawDebugTargets")); - if (CVarDrawDebugTargets->GetBool()) - { - const FVector Offset = FVector(0.0f, 0.0f, 50.0f); - const FVector StartPos = Target.TargetState.Position + Offset; - const int32 SizeMultiplier = FMath::Clamp(Target.TickCount, -4, 30); - static const auto CVarNetCorrectionLifetime = IConsoleManager::Get().FindConsoleVariable(TEXT("p.NetCorrectionLifetime")); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugBox(StartPos, FVector(5.0f + SizeMultiplier * 0.75f, 5.0f + SizeMultiplier * 0.75f, 5.0f + SizeMultiplier * 0.75f), Target.TargetState.Quaternion, FColor::MakeRandomSeededColor(Target.ServerFrame), false, CVarNetCorrectionLifetime->GetFloat(), 0, 1.0f); - } -#endif + const bool bShouldSleep = (Target.TargetState.Flags & ERigidBodyFlags::Sleeping) != 0; + const int32 LocalFrame = Target.ServerFrame - Target.FrameOffset; + const int32 NumPredictedFrames = RigidsSolver->GetCurrentFrame() - LocalFrame - Target.TickCount; + const float PredictedTime = DeltaSeconds * NumPredictedFrames; + const float SendRate = (Target.ServerFrame - Target.PrevServerFrame) * DeltaSeconds; - const bool bIsSleeping = Handle->IsSleeping(); - const bool bCanSimulate = Handle->IsDynamic() || bIsSleeping; + static const auto CVarPosCorrectionTimeMultiplier = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.PosCorrectionTimeMultiplier")); + const float PosCorrectionTime = PredictedTime * CVarPosCorrectionTimeMultiplier->GetFloat(); - // Accumulate sleep time or reset back to 0s if not sleeping - Target.AccumulatedSleepSeconds = bIsSleeping ? (Target.AccumulatedSleepSeconds + DeltaSeconds) : 0.0f; - - // Helper for sleep and target clearing at replication end - auto EndReplicationHelper = [RigidsSolver, Handle, bCanSimulate, bIsSleeping, DeltaSeconds](FReplicatedPhysicsTargetAsync& Target, bool bOkToClear) -> bool - { - const bool bShouldSleep = (Target.TargetState.Flags & ERigidBodyFlags::Sleeping) != 0; - const bool bReplicatingPhysics = (Target.TargetState.Flags & ERigidBodyFlags::RepPhysics) != 0; - - // --- Set Sleep State --- - if (bOkToClear && bShouldSleep && bCanSimulate) - { - RigidsSolver->GetEvolution()->SetParticleObjectState(Handle, Chaos::EObjectStateType::Sleeping); - } - - static const auto CVarSleepSecondsClearTarget = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.SleepSecondsClearTarget")); - static const auto CVarDontClearTarget = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.DontClearTarget")); - // --- Should replication stop? --- - const bool bClearTarget = - (!bCanSimulate - || (bOkToClear && bShouldSleep && Target.AccumulatedSleepSeconds >= CVarSleepSecondsClearTarget->GetFloat()) // Don't clear the target due to sleeping until the object both should sleep and is sleeping for n seconds - || (bOkToClear && !bReplicatingPhysics)) - && !CVarDontClearTarget->GetBool(); - - // --- Target Prediction --- - if (!bClearTarget && Target.bAllowTargetAltering) - { - static const auto CVarExtrapolationTimeMultiplier = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.ExtrapolationTimeMultiplier")); - static const auto CVarExtrapolationMinTime = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.ExtrapolationMinTime")); - const int32 ExtrapolationTickLimit = FMath::Max( - FMath::CeilToInt(Target.AverageReceiveInterval * CVarExtrapolationTimeMultiplier->GetFloat()), // Extrapolate time based on receive interval * multiplier - FMath::CeilToInt(CVarExtrapolationMinTime->GetFloat() / DeltaSeconds)); // At least extrapolate for N seconds - if (Target.TickCount <= ExtrapolationTickLimit) - { - FPhysicsReplicationAsyncVR::ExtrapolateTarget(Target, 1, DeltaSeconds); - } - } - - return bClearTarget; - }; - - - static const auto CVarEarlyOutWithVelocity = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.EarlyOutWithVelocity")); - static const auto CVarEarlyOutDistanceSqr = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.EarlyOutDistanceSqr")); - // If target velocity is low enough, check the distance from the current position to the source position of our target to see if it's low enough to early out of replication - const bool bXCanEarlyOut = (CVarEarlyOutWithVelocity->GetBool() || Target.TargetState.LinVel.SizeSquared() < UE_KINDA_SMALL_NUMBER) && - (Target.PrevPosTarget - Handle->GetX()).SizeSquared() < CVarEarlyOutDistanceSqr->GetFloat(); - - // Early out if we are within range of target, also apply target sleep state - if (bXCanEarlyOut) - { - // Get the rotational offset between the blended rotation target and the current rotation - const FQuat TargetRotDelta = Target.TargetState.Quaternion * Handle->GetR().Inverse(); - - // Convert to angle axis - float Angle; - FVector Axis; - TargetRotDelta.ToAxisAndAngle(Axis, Angle); - Angle = FMath::Abs(FMath::UnwindRadians(Angle)); - - static const auto CVarEarlyOutAngle = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.EarlyOutAngle")); - if (Angle < FMath::DegreesToRadians(CVarEarlyOutAngle->GetFloat())) - { - // Early Out - return EndReplicationHelper(Target, true); - } - } - - // Wake up if sleeping - if (bIsSleeping) - { - RigidsSolver->GetEvolution()->SetParticleObjectState(Handle, Chaos::EObjectStateType::Dynamic); - } - - static const auto CVarAverageReceiveIntervalSmoothing = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.AverageReceiveIntervalSmoothing")); - // Update the AverageReceiveInterval if Target.ReceiveInterval has a valid value to update from - Target.AverageReceiveInterval = Target.ReceiveInterval == 0 ? Target.AverageReceiveInterval : FMath::Lerp(Target.AverageReceiveInterval, Target.ReceiveInterval, FMath::Clamp((1.0f / (Target.ReceiveInterval * CVarAverageReceiveIntervalSmoothing->GetFloat())), 0.0f, 1.0f)); + static const auto CVarInterpolationTimeMultiplier = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.InterpolationTimeMultiplier")); + const float InterpolationTime = SendRate * CVarInterpolationTimeMultiplier->GetFloat(); // CurrentState FRigidBodyState CurrentState; - CurrentState.Position = Handle->GetX(); - CurrentState.Quaternion = Handle->GetR(); - CurrentState.LinVel = Handle->GetV(); - CurrentState.AngVel = Handle->GetW(); // Note: Current angular velocity is in Radians + CurrentState.Position = Handle->X(); + CurrentState.Quaternion = Handle->R(); + CurrentState.LinVel = Handle->V(); + CurrentState.AngVel = Handle->W(); // NewState - const FVector TargetPos = FVector(Target.TargetState.Position); + const FVector TargetPos = Target.TargetState.Position; const FQuat TargetRot = Target.TargetState.Quaternion; - const FVector TargetLinVel = FVector(Target.TargetState.LinVel); - const FVector TargetAngVel = FVector(Target.TargetState.AngVel); // Note: Target angular velocity is in Degrees + const FVector TargetLinVel = Target.TargetState.LinVel; + const FVector TargetAngVel = Target.TargetState.AngVel; + /** --- Reconciliation --- - * If target velocities are low enough, check the traveled direction and distance from previous frame and compare with replicated linear velocity. - * If the object isn't moving enough along the replicated velocity it's considered stuck and needs reconciliation. - * SoftSnap is performed each tick while there is a registered error, if enough time pass HardSnap forces the object into the correct state. */ - static const auto CVarVelocityBased = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.VelocityBased")); - bool bSoftSnap = !CVarVelocityBased->GetBool(); + * Get the traveled direction and distance from previous frame and compare with replicated linear velocity. + * If the object isn't moving enough along the replicated velocity it's considered stuck and needs a hard reconciliation. + */ + const FVector PrevDiff = CurrentState.Position - Target.PrevPos; + const float ExpectedDistance = (Target.PrevLinVel * DeltaSeconds).Size(); + const float CoveredDistance = FVector::DotProduct(PrevDiff, Target.PrevLinVel.GetSafeNormal()); - static const auto CVarDisableErrorVelocityLimits = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.DisableErrorVelocityLimits")); - static const auto CVarErrorAccLinVelMaxLimit = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.ErrorAccLinVelMaxLimit")); - static const auto CVarErrorAccAngVelMaxLimit = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.ErrorAccAngVelMaxLimit")); - if (CVarDisableErrorVelocityLimits->GetBool() || - (TargetLinVel.Size() < CVarErrorAccLinVelMaxLimit->GetFloat() && TargetAngVel.Size() < CVarErrorAccAngVelMaxLimit->GetFloat())) + // If the object is moving less than X% of the expected distance, accumulate error seconds + static const auto CVarMinExpectedDistanceCovered = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.MinExpectedDistanceCovered")); + if (CoveredDistance / ExpectedDistance < CVarMinExpectedDistanceCovered->GetFloat()) { - const FVector PrevDiff = CurrentState.Position - Target.PrevPos; - const float ExpectedDistance = (Target.PrevLinVel * DeltaSeconds).Size(); - const float CoveredDistance = FVector::DotProduct(PrevDiff, Target.PrevLinVel.GetSafeNormal()); - const float CoveredAplha = FMath::Clamp(CoveredDistance / ExpectedDistance, 0.0f, 1.0f); + Target.AccumulatedErrorSeconds += DeltaSeconds; + } + else + { + Target.AccumulatedErrorSeconds = FMath::Max(Target.AccumulatedErrorSeconds - DeltaSeconds, 0.0f); + } - // If the object is moving less than X% of the expected distance, accumulate error seconds - static const auto CVarMinExpectedDistanceCovered = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.MinExpectedDistanceCovered")); - if (CoveredAplha < CVarMinExpectedDistanceCovered->GetFloat()) + static const auto CVarbPredictiveInterpolationAlwaysHardSnap = IConsoleManager::Get().FindConsoleVariable(TEXT("p.PredictiveInterpolation.AlwaysHardSnap")); + const bool bHardSnap = Target.AccumulatedErrorSeconds > ErrorAccumulationSeconds || CVarbPredictiveInterpolationAlwaysHardSnap->GetBool(); + bool bClearTarget = bHardSnap; + if (bHardSnap) + { + // Too much error so just snap state here and be done with it + Target.AccumulatedErrorSeconds = 0.0f; + Handle->SetX(Target.PrevPosTarget); + Handle->SetP(Target.PrevPosTarget); + Handle->SetR(Target.PrevRotTarget); + Handle->SetQ(Target.PrevRotTarget); + Handle->SetV(Target.TargetState.LinVel); + Handle->SetW(Target.TargetState.AngVel); + } + else // Velocity-based Replication + { + const Chaos::EObjectStateType ObjectState = Handle->ObjectState(); + if (ObjectState != Chaos::EObjectStateType::Dynamic) { - Target.AccumulatedErrorSeconds += DeltaSeconds; - bSoftSnap = true; + RigidsSolver->GetEvolution()->SetParticleObjectState(Handle, Chaos::EObjectStateType::Dynamic); } - else if (Target.AccumulatedErrorSeconds > 0.f) + + + // --- Velocity Replication --- + // Get PosDiff + const FVector PosDiff = TargetPos - CurrentState.Position; + + // Convert PosDiff to a velocity + const FVector PosDiffVelocity = PosDiff / PosCorrectionTime; + + // Get LinVelDiff by adding inverted CurrentState.LinVel to TargetLinVel + const FVector LinVelDiff = -CurrentState.LinVel + TargetLinVel; + + // Add PosDiffVelocity to LinVelDiff to get BlendedTargetVelocity + const FVector BlendedTargetVelocity = LinVelDiff + PosDiffVelocity; + + // Multiply BlendedTargetVelocity with(deltaTime / interpolationTime), clamp to 1 and add to CurrentState.LinVel to get BlendedTargetVelocityInterpolated + const float BlendStepAmount = FMath::Clamp(DeltaSeconds / InterpolationTime, 0.f, 1.f); + const FVector RepLinVel = CurrentState.LinVel + (BlendedTargetVelocity * BlendStepAmount); + + + // --- Angular Velocity Replication --- + // Extrapolate current rotation along current angular velocity to see where we would end up + float CurAngVelSize; + FVector CurAngVelAxis; + CurrentState.AngVel.FVector::ToDirectionAndLength(CurAngVelAxis, CurAngVelSize); + CurAngVelSize = FMath::DegreesToRadians(CurAngVelSize); + const FQuat CurRotExtrapDelta = FQuat(CurAngVelAxis, CurAngVelSize * DeltaSeconds); + const FQuat CurRotExtrap = CurRotExtrapDelta * CurrentState.Quaternion; + + // Slerp from the extrapolated current rotation towards the target rotation + // This takes current angular velocity into account + const FQuat TargetRotBlended = FQuat::Slerp(CurRotExtrap, TargetRot, BlendStepAmount); + + // Get the rotational offset between the blended rotation target and the current rotation + const FQuat TargetRotDelta = TargetRotBlended * CurrentState.Quaternion.Inverse(); + + // Convert the rotational delta to angular velocity with a magnitude that will make it arrive at the rotation after DeltaTime has passed + float WAngle; + FVector WAxis; + TargetRotDelta.ToAxisAndAngle(WAxis, WAngle); + + const FVector RepAngVel = WAxis * (WAngle / DeltaSeconds); + + + // Apply velocity + Handle->SetV(RepLinVel); + Handle->SetW(RepAngVel); + + + // Cache data for reconciliation + Target.PrevPos = FVector(CurrentState.Position); + Target.PrevLinVel = FVector(RepLinVel); + } + + + if (bShouldSleep) + { + // --- Sleep --- + // Get the distance from the current position to the source position of our target state + const float SourceDistanceSqr = (Target.PrevPosTarget - CurrentState.Position).SizeSquared(); + + // Don't allow kinematic to sleeping transition + static const auto CVarMaxDistanceToSleepSqr = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.MaxDistanceToSleepSqr")); + if (SourceDistanceSqr < CVarMaxDistanceToSleepSqr->GetFloat() && !Handle->IsKinematic()) { - static const auto CVarErrorAccumulationDecreaseMultiplier = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.ErrorAccumulationDecreaseMultiplier")); - const float DecreaseTime = DeltaSeconds * CVarErrorAccumulationDecreaseMultiplier->GetFloat(); - Target.AccumulatedErrorSeconds = FMath::Max(Target.AccumulatedErrorSeconds - DecreaseTime, 0.0f); - bSoftSnap = true; + RigidsSolver->GetEvolution()->SetParticleObjectState(Handle, Chaos::EObjectStateType::Sleeping); + bClearTarget = true; } } else { - Target.AccumulatedErrorSeconds = 0; - } - - static const auto CVarVelocityBasedSetting = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.VelocityBased")); - if (SettingsCurrent.PredictiveInterpolationSettings.GetDisableSoftSnap() && CVarVelocityBasedSetting->GetBool()) - { - bSoftSnap = false; - } - - static const auto CVarErrorAccumulationSeconds = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.ErrorAccumulationSeconds")); - static const auto CVarAlwaysHardSnap = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.AlwaysHardSnap")); - const bool bHardSnap = !bCanSimulate || - Target.AccumulatedErrorSeconds > CVarErrorAccumulationSeconds->GetFloat() || - CVarAlwaysHardSnap->GetBool(); - - if (bHardSnap) - { - Target.AccumulatedErrorSeconds = 0.0f; - - if (Handle->IsKinematic()) + // --- Target Extrapolation --- + static const auto CVarExtrapolationTimeMultiplier = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.ExtrapolationTimeMultiplier")); + if ((Target.TickCount * DeltaSeconds) < SendRate * CVarExtrapolationTimeMultiplier->GetFloat()) { - // Set a FKinematicTarget to hard snap kinematic object - const Chaos::FKinematicTarget KinTarget = Chaos::FKinematicTarget::MakePositionTarget(Target.PrevPosTarget, Target.PrevRotTarget); // Uses EKinematicTargetMode::Position - RigidsSolver->GetEvolution()->SetParticleKinematicTarget(Handle, KinTarget); - } - else - { - // Set XPRQVW to hard snap dynamic object - Handle->SetX(Target.PrevPosTarget); - Handle->SetP(Target.PrevPosTarget); - Handle->SetR(Target.PrevRotTarget); - Handle->SetQ(Target.PrevRotTarget); - Handle->SetV(Target.TargetState.LinVel); - Handle->SetW(FMath::DegreesToRadians(Target.TargetState.AngVel)); - } + // Extrapolate target position + Target.TargetState.Position = Target.TargetState.Position + Target.TargetState.LinVel * DeltaSeconds; - // Cache data for next replication - Target.PrevLinVel = FVector(Target.TargetState.LinVel); - - // End replication and go to sleep if that's requested - return EndReplicationHelper(Target, true); - } - else // Velocity-based Replication - { - // Calculate interpolation time based on current average receive rate - const float AverageReceiveIntervalSeconds = Target.AverageReceiveInterval * DeltaSeconds; - const float InterpolationTime = AverageReceiveIntervalSeconds * SettingsCurrent.PredictiveInterpolationSettings.GetPosInterpolationTimeMultiplier(); - - // Calculate position correction time based on current Round Trip Time - const float RTT = LatencyOneWay * 2.f; - const float PosCorrectionTime = FMath::Max(SettingsCurrent.PredictiveInterpolationSettings.GetPosCorrectionTimeBase() + AverageReceiveIntervalSeconds + RTT * SettingsCurrent.PredictiveInterpolationSettings.GetPosCorrectionTimeMultiplier(), - DeltaSeconds + SettingsCurrent.PredictiveInterpolationSettings.GetPosCorrectionTimeMin()); - const float RotCorrectionTime = FMath::Max(SettingsCurrent.PredictiveInterpolationSettings.GetRotCorrectionTimeBase() + AverageReceiveIntervalSeconds + RTT * SettingsCurrent.PredictiveInterpolationSettings.GetRotCorrectionTimeMultiplier(), - DeltaSeconds + SettingsCurrent.PredictiveInterpolationSettings.GetRotCorrectionTimeMin()); - - if ((bXCanEarlyOut && SettingsCurrent.PredictiveInterpolationSettings.GetSkipVelocityRepOnPosEarlyOut()) == false) - { // --- Velocity Replication --- - - // Get PosDiff - const FVector PosDiff = TargetPos - CurrentState.Position; - - // Get LinVelDiff by adding inverted CurrentState.LinVel to TargetLinVel - const FVector LinVelDiff = -CurrentState.LinVel + TargetLinVel; - - // Calculate velocity blend amount for this tick as an alpha value - const float Alpha = FMath::Clamp(DeltaSeconds / InterpolationTime, 0.0f, 1.0f); - - FVector RepLinVel; - static const auto CVarPosCorrectionAsVelocity = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.PosCorrectionAsVelocity")); - if (CVarPosCorrectionAsVelocity->GetBool()) - { - // Convert PosDiff to a velocity - const FVector PosDiffVelocity = PosDiff / PosCorrectionTime; - - // Add PosDiffVelocity to LinVelDiff to get BlendedTargetVelocity - const FVector BlendedTargetVelocity = LinVelDiff + PosDiffVelocity; - - // Add BlendedTargetVelocity onto current velocity - - RepLinVel = CurrentState.LinVel + (BlendedTargetVelocity * Alpha); - } - else // Positional correction as position shift - { - // Calculate the PosDiff amount to correct this tick - const FVector PosDiffVelocityDelta = PosDiff * (DeltaSeconds / PosCorrectionTime); // Same as (PosDiff / PosCorrectionTime) * DeltaSeconds - - // Add velocity diff onto current velocity - RepLinVel = CurrentState.LinVel + (LinVelDiff * Alpha); - - - // Apply positional correction - Handle->SetX(Handle->GetX() + PosDiffVelocityDelta); - } - - // Apply velocity replication - - Handle->SetV(RepLinVel); - -#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) - static const auto CVarDrawDebugVectors = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.PredictiveInterpolation.DrawDebugVectors")); - if (CVarDrawDebugVectors->GetBool()) - { - const FVector Offset = FVector(0.0f, 0.0f, 50.0f); - const FVector OffsetAdd = FVector(0.0f, 0.0f, 10.0f); - const FVector StartPos = TargetPos + Offset; - FVector Direction = TargetLinVel; - Direction.Normalize(); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow((StartPos + OffsetAdd * 0), (StartPos + OffsetAdd * 0) + TargetLinVel * 0.5f, 5.0f, FColor::Green, false, -1.0f, 0, 2.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow((StartPos + OffsetAdd * 1), (StartPos + OffsetAdd * 1) + CurrentState.LinVel * 0.5f, 5.0f, FColor::Blue, false, -1.0f, 0, 2.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow((StartPos + OffsetAdd * 2), (StartPos + OffsetAdd * 2) + (Target.PrevLinVel - CurrentState.LinVel) * 0.5f, 5.0f, FColor::Red, false, -1.0f, 0, 2.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow((StartPos + OffsetAdd * 3), (StartPos + OffsetAdd * 3) + RepLinVel * 0.5f, 5.0f, FColor::Magenta, false, -1.0f, 0, 2.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow((StartPos + OffsetAdd * 4), (StartPos + OffsetAdd * 4) + (Target.PrevLinVel - RepLinVel) * 0.5f, 5.0f, FColor::Orange, false, -1.0f, 0, 2.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow((StartPos + OffsetAdd * 5), (StartPos + OffsetAdd * 5) + Direction * RTT, 5.0f, FColor::White, false, -1.0f, 0, 2.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow((StartPos + OffsetAdd * 6), (StartPos + OffsetAdd * 6) + Direction * InterpolationTime, 5.0f, FColor::Yellow, false, -1.0f, 0, 2.0f); - } -#endif - // Cache data for next replication - Target.PrevLinVel = FVector(RepLinVel); - } - - { // --- Angular Velocity Replication --- - /* Todo, Implement InterpolationTime */ - - // Extrapolate current rotation along current angular velocity to see where we would end up - float CurAngVelSize; - FVector CurAngVelAxis; - CurrentState.AngVel.FVector::ToDirectionAndLength(CurAngVelAxis, CurAngVelSize); - const FQuat CurRotExtrapDelta = FQuat(CurAngVelAxis, CurAngVelSize * DeltaSeconds); - const FQuat CurRotExtrap = CurRotExtrapDelta * CurrentState.Quaternion; - - // Slerp from the extrapolated current rotation towards the target rotation - // This takes current angular velocity into account - const float RotCorrectionAmount = FMath::Clamp(DeltaSeconds / RotCorrectionTime, 0.0f, 1.0f); - const FQuat TargetRotBlended = FQuat::Slerp(CurRotExtrap, TargetRot, RotCorrectionAmount); - - // Get the rotational offset between the blended rotation target and the current rotation - const FQuat TargetRotDelta = TargetRotBlended * CurrentState.Quaternion.Inverse(); - - // Convert the rotational delta to angular velocity - float WAngle; - FVector WAxis; - TargetRotDelta.ToAxisAndAngle(WAxis, WAngle); - const FVector TargetRotDeltaBlend = FVector(WAxis * (WAngle / (DeltaSeconds * SettingsCurrent.PredictiveInterpolationSettings.GetRotInterpolationTimeMultiplier()))); - const FVector RepAngVel = FMath::DegreesToRadians(TargetAngVel) + TargetRotDeltaBlend; - - Handle->SetW(RepAngVel); - } - - // Cache data for next replication - Target.PrevPos = FVector(CurrentState.Position); - - if (bSoftSnap) - { - const FVector SoftSnapPos = FMath::Lerp(FVector(CurrentState.Position), - SettingsCurrent.PredictiveInterpolationSettings.GetSoftSnapToSource() ? Target.PrevPosTarget : Target.TargetState.Position, - FMath::Clamp(SettingsCurrent.PredictiveInterpolationSettings.GetSoftSnapPosStrength(), 0.0f, 1.0f)); - - const FQuat SoftSnapRot = FQuat::Slerp(CurrentState.Quaternion, - SettingsCurrent.PredictiveInterpolationSettings.GetSoftSnapToSource() ? Target.PrevRotTarget : Target.TargetState.Quaternion, - FMath::Clamp(SettingsCurrent.PredictiveInterpolationSettings.GetSoftSnapRotStrength(), 0.0f, 1.0f)); - - Handle->SetX(SoftSnapPos); - Handle->SetP(SoftSnapPos); - Handle->SetR(SoftSnapRot); - Handle->SetQ(SoftSnapRot); + // Extrapolate target rotation + float TargetAngVelSize; + FVector TargetAngVelAxis; + Target.TargetState.AngVel.FVector::ToDirectionAndLength(TargetAngVelAxis, TargetAngVelSize); + TargetAngVelSize = FMath::DegreesToRadians(TargetAngVelSize); + const FQuat TargetRotExtrapDelta = FQuat(TargetAngVelAxis, TargetAngVelSize * DeltaSeconds); + Target.TargetState.Quaternion = TargetRotExtrapDelta * Target.TargetState.Quaternion; } } - return EndReplicationHelper(Target, false); -} + Target.TickCount++; -/** Static function to extrapolate a target for N ticks using X DeltaSeconds */ -void FPhysicsReplicationAsyncVR::ExtrapolateTarget(FReplicatedPhysicsTargetAsync& Target, const int32 ExtrapolateFrames, const float DeltaSeconds) -{ - const float ExtrapolationTime = DeltaSeconds * static_cast(ExtrapolateFrames); - - // Extrapolate target position - Target.TargetState.Position = Target.TargetState.Position + Target.TargetState.LinVel * ExtrapolationTime; - - // Extrapolate target rotation - float TargetAngVelSize; - FVector TargetAngVelAxis; - Target.TargetState.AngVel.FVector::ToDirectionAndLength(TargetAngVelAxis, TargetAngVelSize); - TargetAngVelSize = FMath::DegreesToRadians(TargetAngVelSize); - const FQuat TargetRotExtrapDelta = FQuat(TargetAngVelAxis, TargetAngVelSize * ExtrapolationTime); - Target.TargetState.Quaternion = TargetRotExtrapDelta * Target.TargetState.Quaternion; + return bClearTarget;; } /** Compare states and trigger resimulation if needed */ @@ -1993,131 +1512,67 @@ bool FPhysicsReplicationAsyncVR::ResimulationReplication(Chaos::FPBDRigidParticl const int32 LocalFrame = Target.ServerFrame - Target.FrameOffset; - if (LocalFrame >= RewindData->CurrentFrame() || LocalFrame < RewindData->GetEarliestFrame_Internal()) + if (LocalFrame <= RewindData->CurrentFrame() && LocalFrame >= RewindData->GetEarliestFrame_Internal()) { - if (LocalFrame > 0 && (RewindData->CurrentFrame() - RewindData->GetEarliestFrame_Internal()) == RewindData->Capacity()) - { - UE_LOG(LogPhysics, Warning, TEXT("FPhysicsReplication::ResimulationReplication target frame (%d) out of rewind data bounds (%d,%d)"), - LocalFrame, RewindData->GetEarliestFrame_Internal(), RewindData->CurrentFrame()); - } - return true; - } + static constexpr Chaos::FFrameAndPhase::EParticleHistoryPhase RewindPhase = Chaos::FFrameAndPhase::EParticleHistoryPhase::PostPushData; - bool bClearTarget = true; + FAsyncPhysicsTimestamp TimeStamp; + TimeStamp.LocalFrame = RewindData->CurrentFrame(); + const float ResimErrorThreshold = Chaos::FPhysicsSolverBase::ResimulationErrorThreshold(); - static constexpr Chaos::FFrameAndPhase::EParticleHistoryPhase RewindPhase = Chaos::FFrameAndPhase::EParticleHistoryPhase::PostPushData; - - const float ResimErrorThreshold = SettingsCurrent.ResimulationSettings.GetResimulationErrorThreshold(Chaos::FPhysicsSolverBase::ResimulationErrorThreshold()); - const Chaos::FGeometryParticleState PastState = RewindData->GetPastStateAtFrame(*Handle, LocalFrame, RewindPhase); - - const FVector ErrorOffset = (Target.TargetState.Position - PastState.GetX()); - const float ErrorDistance = ErrorOffset.Size(); - const bool ShouldTriggerResim = ErrorDistance >= ResimErrorThreshold; + auto PastState = RewindData->GetPastStateAtFrame(*Handle, LocalFrame, RewindPhase); + const FVector ErrorOffset = (PastState.X() - Target.TargetState.Position); + const float ErrorDistance = ErrorOffset.Size(); + const bool ShouldTriggerResim = ErrorDistance >= ResimErrorThreshold; + float ColorLerp = ShouldTriggerResim ? 1.0f : 0.0f; #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) - if (Chaos::FPhysicsSolverBase::CanDebugNetworkPhysicsPrediction()) - { - UE_LOG(LogTemp, Log, TEXT("Apply Rigid body state at local frame %d with offset = %d"), LocalFrame, Target.FrameOffset); - UE_LOG(LogTemp, Log, TEXT("Particle Position Error = %f | Should Trigger Resim = %s | Server Frame = %d | Client Frame = %d"), ErrorDistance, (ShouldTriggerResim ? TEXT("True") : TEXT("False")), Target.ServerFrame, LocalFrame); - UE_LOG(LogTemp, Log, TEXT("Particle Target Position = %s | Current Position = %s"), *Target.TargetState.Position.ToString(), *PastState.GetX().ToString()); - UE_LOG(LogTemp, Log, TEXT("Particle Target Velocity = %s | Current Velocity = %s"), *Target.TargetState.LinVel.ToString(), *PastState.GetV().ToString()); - UE_LOG(LogTemp, Log, TEXT("Particle Target Quaternion = %s | Current Quaternion = %s"), *Target.TargetState.Quaternion.ToString(), *PastState.GetR().ToString()); - UE_LOG(LogTemp, Log, TEXT("Particle Target Omega = %s | Current Omega= %s"), *Target.TargetState.AngVel.ToString(), *PastState.GetW().ToString()); - } + if (Chaos::FPhysicsSolverBase::CanDebugNetworkPhysicsPrediction()) + { + UE_LOG(LogTemp, Log, TEXT("Apply Rigid body state at local frame %d with offset = %d"), LocalFrame, Target.FrameOffset); + UE_LOG(LogTemp, Log, TEXT("Particle Position Error = %f | Should Trigger Resim = %s | Server Frame = %d | Client Frame = %d"), ErrorDistance, (ShouldTriggerResim ? TEXT("True") : TEXT("False")), Target.ServerFrame, LocalFrame); + UE_LOG(LogTemp, Log, TEXT("Particle Target Position = %s | Current Position = %s"), *Target.TargetState.Position.ToString(), *PastState.X().ToString()); + UE_LOG(LogTemp, Log, TEXT("Particle Target Velocity = %s | Current Velocity = %s"), *Target.TargetState.LinVel.ToString(), *PastState.V().ToString()); + UE_LOG(LogTemp, Log, TEXT("Particle Target Quaternion = %s | Current Quaternion = %s"), *Target.TargetState.Quaternion.ToString(), *PastState.R().ToString()); + UE_LOG(LogTemp, Log, TEXT("Particle Target Omega = %s | Current Omega= %s"), *Target.TargetState.AngVel.ToString(), *PastState.W().ToString()); - static const auto CVarResimDrawDebug = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.Resim.DrawDebug")); - if (CVarResimDrawDebug->GetBool()) - { - static constexpr float BoxSize = 5.0f; - const float ColorLerp = ShouldTriggerResim ? 1.0f : 0.0f; - const FColor DebugColor = FLinearColor::LerpUsingHSV(FLinearColor::Green, FLinearColor::Red, ColorLerp).ToFColor(false); + { // DrawDebug + static constexpr float BoxSize = 5.0f; + const FColor DebugColor = FLinearColor::LerpUsingHSV(FLinearColor::Green, FLinearColor::Red, ColorLerp).ToFColor(false); - static const auto CVarNetCorrectionLifetime = IConsoleManager::Get().FindConsoleVariable(TEXT("p.NetCorrectionLifetime")); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugBox(Target.TargetState.Position, FVector(BoxSize, BoxSize, BoxSize), Target.TargetState.Quaternion, FColor::Orange, true, CVarNetCorrectionLifetime->GetFloat(), 0, 1.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugBox(PastState.GetX(), FVector(6, 6, 6), PastState.GetR(), DebugColor, true, CVarNetCorrectionLifetime->GetFloat(), 0, 1.0f); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow(PastState.GetX(), Target.TargetState.Position, 5.0f, FColor::MakeRandomSeededColor(LocalFrame), true, CVarNetCorrectionLifetime->GetFloat(), 0, 0.5f); - } + static const auto CVarNetCorrectionLifetime = IConsoleManager::Get().FindConsoleVariable(TEXT("p.NetCorrectionLifetime")); + + Chaos::FDebugDrawQueue::GetInstance().DrawDebugBox(Target.TargetState.Position, FVector(BoxSize, BoxSize, BoxSize), Target.TargetState.Quaternion, FColor::Orange, true, CVarNetCorrectionLifetime->GetFloat(), 0, 1.0f); + Chaos::FDebugDrawQueue::GetInstance().DrawDebugBox(PastState.X(), FVector(6, 6, 6), PastState.R(), DebugColor, true, CVarNetCorrectionLifetime->GetFloat(), 0, 1.0f); + + Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow(PastState.X(), Target.TargetState.Position, 5.0f, FColor::Green, true, CVarNetCorrectionLifetime->GetFloat(), 0, 0.5f); + } + } #endif - if (LocalFrame > RewindData->GetBlockedResimFrame()) - { - if (ShouldTriggerResim && Target.TickCount == 0) + if (ShouldTriggerResim) { - // Trigger resimulation RigidsSolver->GetEvolution()->GetIslandManager().SetParticleResimFrame(Handle, LocalFrame); int32 ResimFrame = RewindData->GetResimFrame(); ResimFrame = (ResimFrame == INDEX_NONE) ? LocalFrame : FMath::Min(ResimFrame, LocalFrame); RewindData->SetResimFrame(ResimFrame); } - else if (SettingsCurrent.ResimulationSettings.GetRuntimeCorrectionEnabled()) - - { - const int32 NumPredictedFrames = RigidsSolver->GetCurrentFrame() - LocalFrame - Target.TickCount; - - - - if (Target.TickCount <= NumPredictedFrames && NumPredictedFrames > 0) - { - // Positional Correction - const float CorrectionAmountX = SettingsCurrent.ResimulationSettings.GetPosStabilityMultiplier() / NumPredictedFrames; - const FVector PosDiffCorrection = ErrorOffset * CorrectionAmountX; // Same result as (ErrorOffset / NumPredictedFrames) * PosStabilityMultiplier - const FVector CorrectedX = Handle->GetX() + PosDiffCorrection; - - - // Rotational Correction - const float CorrectionAmountR = SettingsCurrent.ResimulationSettings.GetRotStabilityMultiplier() / NumPredictedFrames; - - const FQuat DeltaQuat = PastState.GetR().Inverse() * Target.TargetState.Quaternion; - const FQuat TargetCorrectionR = Handle->GetR() * DeltaQuat; - const FQuat CorrectedR = FQuat::Slerp(Handle->GetR(), TargetCorrectionR, CorrectionAmountR); - - if (SettingsCurrent.ResimulationSettings.GetRuntimeVelocityCorrectionEnabled()) - { - // Linear Velocity Correction - const FVector LinVelDiff = Target.TargetState.LinVel - PastState.GetV(); // Velocity vector that the server covers but the client doesn't - const float CorrectionAmountV = SettingsCurrent.ResimulationSettings.GetVelStabilityMultiplier() / NumPredictedFrames; - const FVector VelCorrection = LinVelDiff * CorrectionAmountV; // Same result as (LinVelDiff / NumPredictedFrames) * VelStabilityMultiplier - const FVector CorrectedV = Handle->GetV() + VelCorrection; - - // Angular Velocity Correction - const FVector AngVelDiff = Target.TargetState.AngVel - PastState.GetW(); // Angular velocity vector that the server covers but the client doesn't - const float CorrectionAmountW = SettingsCurrent.ResimulationSettings.GetAngVelStabilityMultiplier() / NumPredictedFrames; - const FVector AngVelCorrection = AngVelDiff * CorrectionAmountW; // Same result as (AngVelDiff / NumPredictedFrames) * VelStabilityMultiplier - const FVector CorrectedW = Handle->GetW() + AngVelCorrection; - - // Apply correction to velocities - Handle->SetV(CorrectedV); - Handle->SetW(CorrectedW); - } - - -#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) - if (CVarResimDrawDebug->GetBool()) - { - static const auto CVarNetCorrectionLifetime = IConsoleManager::Get().FindConsoleVariable(TEXT("p.NetCorrectionLifetime")); - Chaos::FDebugDrawQueue::GetInstance().DrawDebugDirectionalArrow(Handle->GetX(), CorrectedX, 5.0f, FColor::MakeRandomSeededColor(LocalFrame), true, CVarNetCorrectionLifetime->GetFloat(), 0, 0.5f); - } -#endif - // Apply correction to position and rotation - static const auto CVarResimRuntimeCorrectConnectedBodies = IConsoleManager::Get().FindConsoleVariable(TEXT("np2.Resim.RuntimeCorrectConnectedBodies")); - RigidsSolver->GetEvolution()->ApplyParticleTransformCorrection(Handle, CorrectedX, CorrectedR, CVarResimRuntimeCorrectConnectedBodies->GetBool()); - } - - // Keep target for NumPredictedFrames time to perform runtime corrections with until a new target is received - bClearTarget = Target.TickCount >= NumPredictedFrames; - } } - return bClearTarget; + else if (LocalFrame > 0) + { + UE_LOG(LogPhysics, Warning, TEXT("FPhysicsReplication::ApplyRigidBodyState target frame (%d) out of rewind data bounds (%d,%d)"), LocalFrame, + RewindData->GetEarliestFrame_Internal(), RewindData->CurrentFrame()); + } + + return true; } FName FPhysicsReplicationAsyncVR::GetFNameForStatId() const { const static FLazyName StaticName("FPhysicsReplicationAsyncCallback"); return StaticName; -} - -#pragma endregion // FPhysicsReplicationAsync \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshActor.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshActor.cpp index b1a36b3..6f30f9b 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshActor.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshActor.cpp @@ -37,18 +37,7 @@ void UOptionalRepSkeletalMeshComponent::GetLifetimeReplicatedProps(TArray< class { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UOptionalRepSkeletalMeshComponent, bReplicateMovement, PushModelParams); -} - -void UOptionalRepSkeletalMeshComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UOptionalRepSkeletalMeshComponent, bReplicateMovement, this); -#endif + DOREPLIFETIME(UOptionalRepSkeletalMeshComponent, bReplicateMovement); } void UOptionalRepSkeletalMeshComponent::GetWeldedBodies(TArray& OutWeldedBodies, TArray& OutLabels, bool bIncludingAutoWeld) @@ -163,20 +152,13 @@ void AGrippableSkeletalMeshActor::GetLifetimeReplicatedProps(TArray< class FLife { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableSkeletalMeshActor, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableSkeletalMeshActor, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableSkeletalMeshActor, bAllowIgnoringAttachOnOwner, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableSkeletalMeshActor, ClientAuthReplicationData, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableSkeletalMeshActor, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableSkeletalMeshActor, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableSkeletalMeshActor, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(AGrippableSkeletalMeshActor, GripLogicScripts, COND_Custom); + DOREPLIFETIME(AGrippableSkeletalMeshActor, bReplicateGripScripts); + DOREPLIFETIME(AGrippableSkeletalMeshActor, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(AGrippableSkeletalMeshActor, bAllowIgnoringAttachOnOwner); + DOREPLIFETIME(AGrippableSkeletalMeshActor, ClientAuthReplicationData); + DOREPLIFETIME_CONDITION(AGrippableSkeletalMeshActor, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(AGrippableSkeletalMeshActor, GameplayTags, COND_Custom); DISABLE_REPLICATED_PRIVATE_PROPERTY(AActor, AttachmentReplication); @@ -949,80 +931,4 @@ void AGrippableSkeletalMeshActor::GetSubobjectsWithStableNamesForNetworking(TArr } } } -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void AGrippableSkeletalMeshActor::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableSkeletalMeshActor, bReplicateGripScripts, this); -#endif -} - -TArray>& AGrippableSkeletalMeshActor::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableSkeletalMeshActor, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void AGrippableSkeletalMeshActor::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableSkeletalMeshActor, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void AGrippableSkeletalMeshActor::SetAllowIgnoringAttachOnOwner(bool bNewAllowIgnoringAttachOnOwner) -{ - bAllowIgnoringAttachOnOwner = bNewAllowIgnoringAttachOnOwner; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableSkeletalMeshActor, bAllowIgnoringAttachOnOwner, this); -#endif -} - -FVRClientAuthReplicationData& AGrippableSkeletalMeshActor::GetClientAuthReplicationData(FVRClientAuthReplicationData& ClientAuthData) -{ -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableSkeletalMeshActor, ClientAuthReplicationData, this); -#endif - return ClientAuthReplicationData; -} - -FBPInterfaceProperties& AGrippableSkeletalMeshActor::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableSkeletalMeshActor, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& AGrippableSkeletalMeshActor::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableSkeletalMeshActor, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshComponent.cpp index 4059705..c9781fa 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSkeletalMeshComponent.cpp @@ -8,9 +8,6 @@ #include "GripScripts/VRGripScriptBase.h" #include "PhysicsEngine/PhysicsAsset.h" // Tmp until epic bug fixes skeletal welding #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif //============================================================================= UGrippableSkeletalMeshComponent::UGrippableSkeletalMeshComponent(const FObjectInitializer& ObjectInitializer) @@ -47,19 +44,12 @@ void UGrippableSkeletalMeshComponent::GetLifetimeReplicatedProps(TArray< class F { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(UGrippableSkeletalMeshComponent, GripLogicScripts, COND_Custom); + DOREPLIFETIME(UGrippableSkeletalMeshComponent, bReplicateGripScripts); + DOREPLIFETIME(UGrippableSkeletalMeshComponent, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(UGrippableSkeletalMeshComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UGrippableSkeletalMeshComponent, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(UGrippableSkeletalMeshComponent, GameplayTags, COND_Custom); } void UGrippableSkeletalMeshComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -399,72 +389,4 @@ FBodyInstance* UGrippableSkeletalMeshComponent::GetBodyInstance(FName BoneName, } return BodyInst; -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void UGrippableSkeletalMeshComponent::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, bReplicateGripScripts, this); -#endif -} - -TArray>& UGrippableSkeletalMeshComponent::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void UGrippableSkeletalMeshComponent::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void UGrippableSkeletalMeshComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, bReplicateMovement, this); -#endif -} - -FBPInterfaceProperties& UGrippableSkeletalMeshComponent::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& UGrippableSkeletalMeshComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSphereComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSphereComponent.cpp index 6fca280..3e22391 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSphereComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableSphereComponent.cpp @@ -8,11 +8,6 @@ #include "GripScripts/VRGripScriptBase.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - - //============================================================================= UGrippableSphereComponent::UGrippableSphereComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -47,19 +42,12 @@ void UGrippableSphereComponent::GetLifetimeReplicatedProps(TArray< class FLifeti { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSphereComponent, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSphereComponent, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSphereComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSphereComponent, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSphereComponent, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSphereComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(UGrippableSphereComponent, GripLogicScripts, COND_Custom); + DOREPLIFETIME(UGrippableSphereComponent, bReplicateGripScripts) + DOREPLIFETIME(UGrippableSphereComponent, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(UGrippableSphereComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UGrippableSphereComponent, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(UGrippableSphereComponent, GameplayTags, COND_Custom); } void UGrippableSphereComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -331,73 +319,4 @@ void UGrippableSphereComponent::OnComponentDestroyed(bool bDestroyingHierarchy) } GripLogicScripts.Empty(); -} - - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void UGrippableSphereComponent::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSphereComponent, bReplicateGripScripts, this); -#endif -} - -TArray>& UGrippableSphereComponent::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSphereComponent, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void UGrippableSphereComponent::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSphereComponent, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void UGrippableSphereComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSphereComponent, bReplicateMovement, this); -#endif -} - -FBPInterfaceProperties& UGrippableSphereComponent::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSphereComponent, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& UGrippableSphereComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSphereComponent, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshActor.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshActor.cpp index 74dec5c..7feb271 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshActor.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshActor.cpp @@ -110,20 +110,13 @@ void AGrippableStaticMeshActor::GetLifetimeReplicatedProps(TArray< class FLifeti { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableStaticMeshActor, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableStaticMeshActor, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableStaticMeshActor, bAllowIgnoringAttachOnOwner, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableStaticMeshActor, ClientAuthReplicationData, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableStaticMeshActor, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableStaticMeshActor, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(AGrippableStaticMeshActor, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(AGrippableStaticMeshActor, GripLogicScripts, COND_Custom); + DOREPLIFETIME(AGrippableStaticMeshActor, bReplicateGripScripts); + DOREPLIFETIME(AGrippableStaticMeshActor, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(AGrippableStaticMeshActor, bAllowIgnoringAttachOnOwner); + DOREPLIFETIME(AGrippableStaticMeshActor, ClientAuthReplicationData); + DOREPLIFETIME_CONDITION(AGrippableStaticMeshActor, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(AGrippableStaticMeshActor, GameplayTags, COND_Custom); DISABLE_REPLICATED_PRIVATE_PROPERTY(AActor, AttachmentReplication); @@ -895,80 +888,4 @@ void AGrippableStaticMeshActor::GetSubobjectsWithStableNamesForNetworking(TArray } } } -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void AGrippableStaticMeshActor::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableStaticMeshActor, bReplicateGripScripts, this); -#endif -} - -TArray>& AGrippableStaticMeshActor::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableStaticMeshActor, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void AGrippableStaticMeshActor::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableStaticMeshActor, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void AGrippableStaticMeshActor::SetAllowIgnoringAttachOnOwner(bool bNewAllowIgnoringAttachOnOwner) -{ - bAllowIgnoringAttachOnOwner = bNewAllowIgnoringAttachOnOwner; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableStaticMeshActor, bAllowIgnoringAttachOnOwner, this); -#endif -} - -FVRClientAuthReplicationData& AGrippableStaticMeshActor::GetClientAuthReplicationData(FVRClientAuthReplicationData& ClientAuthData) -{ -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableStaticMeshActor, ClientAuthReplicationData, this); -#endif - return ClientAuthReplicationData; -} - -FBPInterfaceProperties& AGrippableStaticMeshActor::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableStaticMeshActor, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& AGrippableStaticMeshActor::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(AGrippableStaticMeshActor, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshComponent.cpp index 1f6b0bc..77ca8fe 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/GrippableStaticMeshComponent.cpp @@ -7,9 +7,6 @@ #include "VRExpansionFunctionLibrary.h" #include "GripScripts/VRGripScriptBase.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif //============================================================================= UGrippableStaticMeshComponent::UGrippableStaticMeshComponent(const FObjectInitializer& ObjectInitializer) @@ -46,19 +43,12 @@ void UGrippableStaticMeshComponent::GetLifetimeReplicatedProps(TArray< class FLi { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, bReplicateGripScripts, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, bRepGripSettingsAndGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, GripLogicScripts, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, VRGripInterfaceSettings, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(UGrippableStaticMeshComponent, GripLogicScripts, COND_Custom); + DOREPLIFETIME(UGrippableStaticMeshComponent, bReplicateGripScripts); + DOREPLIFETIME(UGrippableStaticMeshComponent, bRepGripSettingsAndGameplayTags); + DOREPLIFETIME(UGrippableStaticMeshComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UGrippableStaticMeshComponent, VRGripInterfaceSettings, COND_Custom); + DOREPLIFETIME_CONDITION(UGrippableStaticMeshComponent, GameplayTags, COND_Custom); } void UGrippableStaticMeshComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -324,72 +314,4 @@ void UGrippableStaticMeshComponent::OnComponentDestroyed(bool bDestroyingHierarc } GripLogicScripts.Empty(); -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void UGrippableStaticMeshComponent::SetReplicateGripScripts(bool bNewReplicateGripScripts) -{ - bReplicateGripScripts = bNewReplicateGripScripts; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, bReplicateGripScripts, this); -#endif -} - -TArray>& UGrippableStaticMeshComponent::GetGripLogicScripts() -{ -#if WITH_PUSH_MODEL - if (bReplicateGripScripts) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, GripLogicScripts, this); - } -#endif - - return GripLogicScripts; -} - -void UGrippableStaticMeshComponent::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags) -{ - bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, bRepGripSettingsAndGameplayTags, this); -#endif -} - -void UGrippableStaticMeshComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, bReplicateMovement, this); -#endif -} - -FBPInterfaceProperties& UGrippableStaticMeshComponent::GetVRGripInterfaceSettings(bool bMarkDirty) -{ -#if WITH_PUSH_MODEL - if (bMarkDirty && bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, VRGripInterfaceSettings, this); - } -#endif - - return VRGripInterfaceSettings; -} - -FGameplayTagContainer& UGrippableStaticMeshComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGripSettingsAndGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// \ No newline at end of file +} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/HandSocketComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/HandSocketComponent.cpp index 97d6e18..dfbdd58 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/HandSocketComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Grippables/HandSocketComponent.cpp @@ -3,16 +3,11 @@ #include "Grippables/HandSocketComponent.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(HandSocketComponent) -#include "CoreMinimal.h" -#include "UObject/UObjectIterator.h" #include "Engine/CollisionProfile.h" -#include "BoneContainer.h" #include "Animation/AnimSequence.h" #include "Animation/AnimInstanceProxy.h" #include "Animation/PoseSnapshot.h" #include "Animation/AnimData/AnimDataModel.h" -#include "Engine/SkinnedAssetCommon.h" -#include "Engine/SkinnedAsset.h" //#include "VRExpansionFunctionLibrary.h" #include "Components/SkeletalMeshComponent.h" #include "Components/PoseableMeshComponent.h" @@ -22,10 +17,6 @@ #include "Net/UnrealNetwork.h" #include "Serialization/CustomVersion.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - DEFINE_LOG_CATEGORY(LogVRHandSocketComponent); const FGuid FVRHandSocketCustomVersion::GUID(0x5A018B7F, 0x48A7AFDE, 0xAFBEB580, 0xAD575412); @@ -885,17 +876,10 @@ void UHandSocketComponent::OnComponentDestroyed(bool bDestroyingHierarchy) void UHandSocketComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > & OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UHandSocketComponent, bRepGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UHandSocketComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UHandSocketComponent, GameplayTags, PushModelParamsWithCondition); + + DOREPLIFETIME(UHandSocketComponent, bRepGameplayTags); + DOREPLIFETIME(UHandSocketComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UHandSocketComponent, GameplayTags, COND_Custom); } void UHandSocketComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -979,47 +963,4 @@ UHandSocketComponent* UHandSocketComponent::GetHandSocketComponentFromObject(UOb } return nullptr; -} - -///////////////////////////////////////////////// -//- Push networking getter / setter functions -///////////////////////////////////////////////// - -void UHandSocketComponent::SetRepGameplayTags(bool bNewRepGameplayTags) -{ - bRepGameplayTags = bNewRepGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UHandSocketComponent, bRepGameplayTags, this); -#endif -} - -void UHandSocketComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UHandSocketComponent, bReplicateMovement, this); -#endif -} - -FGameplayTagContainer& UHandSocketComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UHandSocketComponent, GameplayTags, this); - } -#endif - - return GameplayTags; -} - -///////////////////////////////////////////////// -//- End Push networking getter / setter functions -///////////////////////////////////////////////// - -void UHandSocketAnimInstance::NativeInitializeAnimation() -{ - Super::NativeInitializeAnimation(); - - OwningSocket = Cast(GetOwningComponent()->GetAttachParent()); } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRButtonComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRButtonComponent.cpp index e9da277..8219fb2 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRButtonComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRButtonComponent.cpp @@ -9,10 +9,6 @@ #include "GameFramework/Character.h" #include "GameFramework/PlayerController.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - //============================================================================= UVRButtonComponent::UVRButtonComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -52,17 +48,10 @@ void UVRButtonComponent::GetLifetimeReplicatedProps(TArray< class FLifetimePrope { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRButtonComponent, InitialRelativeTransform, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRButtonComponent, bReplicateMovement, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRButtonComponent, StateChangeAuthorityType, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_InitialOnly, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRButtonComponent, bButtonState, PushModelParamsWithCondition); + DOREPLIFETIME(UVRButtonComponent, InitialRelativeTransform); + DOREPLIFETIME(UVRButtonComponent, bReplicateMovement); + DOREPLIFETIME(UVRButtonComponent, StateChangeAuthorityType); + DOREPLIFETIME_CONDITION(UVRButtonComponent, bButtonState, COND_InitialOnly); } void UVRButtonComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -433,28 +422,4 @@ FVector UVRButtonComponent::SetAxisValue(float SetValue) } return vec; -} - -void UVRButtonComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRButtonComponent, bReplicateMovement, this); -#endif -} - -void UVRButtonComponent::SetStateChangeAuthorityType(EVRStateChangeAuthorityType NewStateChangeAuthorityType) -{ - StateChangeAuthorityType = NewStateChangeAuthorityType; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRButtonComponent, StateChangeAuthorityType, this); -#endif -} - -void UVRButtonComponent::SetButtonState(bool bNewButtonState) -{ - bButtonState = bNewButtonState; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRButtonComponent, bButtonState, this); -#endif } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRDialComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRDialComponent.cpp index 7930efc..7020371 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRDialComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRDialComponent.cpp @@ -7,10 +7,6 @@ #include "GripMotionControllerComponent.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - //============================================================================= UVRDialComponent::UVRDialComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -67,19 +63,12 @@ void UVRDialComponent::GetLifetimeReplicatedProps(TArray< class FLifetimePropert { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRDialComponent, InitialRelativeTransform, PushModelParams); + DOREPLIFETIME(UVRDialComponent, InitialRelativeTransform); //DOREPLIFETIME_CONDITION(UVRDialComponent, bIsLerping, COND_InitialOnly); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRDialComponent, bRepGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRDialComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRDialComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME(UVRDialComponent, bRepGameplayTags); + DOREPLIFETIME(UVRDialComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UVRDialComponent, GameplayTags, COND_Custom); } void UVRDialComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -619,11 +608,6 @@ void UVRDialComponent::ResetInitialDialLocation() { // Get our initial relative transform to our parent (or not if un-parented). InitialRelativeTransform = this->GetRelativeTransform(); - -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRDialComponent, InitialRelativeTransform, this); -#endif - CurRotBackEnd = 0.0f; CalculateDialProgress(); } @@ -634,33 +618,4 @@ void UVRDialComponent::CalculateDialProgress() LastGripRot = UVRInteractibleFunctionLibrary::GetDeltaAngleFromTransforms(DialRotationAxis, InitialRelativeTransform, CurRelativeTransform); CurRotBackEnd = LastGripRot; AddDialAngle(0.0f, false, true); -} - - -void UVRDialComponent::SetRepGameplayTags(bool bNewRepGameplayTags) -{ - bRepGameplayTags = bNewRepGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRDialComponent, bRepGameplayTags, this); -#endif -} - -void UVRDialComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRDialComponent, bReplicateMovement, this); -#endif -} - -FGameplayTagContainer& UVRDialComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UVRDialComponent, GameplayTags, this); - } -#endif - - return GameplayTags; } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRLeverComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRLeverComponent.cpp index 44ca29f..f6a63a0 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRLeverComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRLeverComponent.cpp @@ -7,10 +7,6 @@ #include "VRExpansionFunctionLibrary.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - //============================================================================= UVRLeverComponent::UVRLeverComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -89,19 +85,12 @@ void UVRLeverComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProper { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; + DOREPLIFETIME(UVRLeverComponent, InitialRelativeTransform); + //DOREPLIFETIME_CONDITION(UVRLeverComponent, bIsLerping, COND_InitialOnly); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRLeverComponent, InitialRelativeTransform, PushModelParams); - //DOREPLIFETIME_CONDITION(UVRDialComponent, bIsLerping, COND_InitialOnly); - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRLeverComponent, bRepGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRLeverComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRLeverComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME(UVRLeverComponent, bRepGameplayTags); + DOREPLIFETIME(UVRLeverComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UVRLeverComponent, GameplayTags, COND_Custom); } void UVRLeverComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -666,11 +655,6 @@ void UVRLeverComponent::ResetInitialLeverLocation(bool bAllowThrowingEvents) { // Get our initial relative transform to our parent (or not if un-parented). InitialRelativeTransform = this->GetRelativeTransform(); - -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRLeverComponent, InitialRelativeTransform, this); -#endif - CalculateCurrentAngle(InitialRelativeTransform); ProccessCurrentState(bIsLerping, bAllowThrowingEvents, bAllowThrowingEvents); } @@ -832,32 +816,4 @@ float UVRLeverComponent::CalcAngle(EVRInteractibleLeverAxis AxisToCalc, FVector bIsInFirstTick = false; return ReturnAxis; -} - -void UVRLeverComponent::SetRepGameplayTags(bool bNewRepGameplayTags) -{ - bRepGameplayTags = bNewRepGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRLeverComponent, bRepGameplayTags, this); -#endif -} - -void UVRLeverComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRLeverComponent, bReplicateMovement, this); -#endif -} - -FGameplayTagContainer& UVRLeverComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UVRLeverComponent, GameplayTags, this); - } -#endif - - return GameplayTags; } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRMountComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRMountComponent.cpp index 115e95a..63ad99b 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRMountComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRMountComponent.cpp @@ -9,10 +9,6 @@ //#include "PhysicsEngine/ConstraintInstance.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - //============================================================================= UVRMountComponent::UVRMountComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -62,16 +58,9 @@ void UVRMountComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProper { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRMountComponent, bRepGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRMountComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRMountComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME(UVRMountComponent, bRepGameplayTags); + DOREPLIFETIME(UVRMountComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UVRMountComponent, GameplayTags, COND_Custom); } void UVRMountComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -588,42 +577,8 @@ void UVRMountComponent::SetHeld_Implementation(UGripMotionControllerComponent * return FBPInteractionSettings(); }*/ -void UVRMountComponent::ResetInitialMountLocation() -{ - // Get our initial relative transform to our parent (or not if un-parented). - InitialRelativeTransform = this->GetRelativeTransform(); -} - bool UVRMountComponent::GetGripScripts_Implementation(TArray & ArrayReference) { return false; -} - -void UVRMountComponent::SetRepGameplayTags(bool bNewRepGameplayTags) -{ - bRepGameplayTags = bNewRepGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRMountComponent, bRepGameplayTags, this); -#endif -} - -void UVRMountComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRMountComponent, bReplicateMovement, this); -#endif -} - -FGameplayTagContainer& UVRMountComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UVRMountComponent, GameplayTags, this); - } -#endif - - return GameplayTags; } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRSliderComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRSliderComponent.cpp index 9113d33..559904d 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRSliderComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Interactibles/VRSliderComponent.cpp @@ -8,10 +8,6 @@ #include "GripMotionControllerComponent.h" #include "Net/UnrealNetwork.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - //============================================================================= UVRSliderComponent::UVRSliderComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -88,20 +84,13 @@ void UVRSliderComponent::GetLifetimeReplicatedProps(TArray< class FLifetimePrope { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; + DOREPLIFETIME(UVRSliderComponent, InitialRelativeTransform); + DOREPLIFETIME(UVRSliderComponent, SplineComponentToFollow); + //DOREPLIFETIME_CONDITION(UVRSliderComponent, bIsLerping, COND_InitialOnly); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRSliderComponent, InitialRelativeTransform, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRSliderComponent, SplineComponentToFollow, PushModelParams); - //DOREPLIFETIME_CONDITION(UVRDialComponent, bIsLerping, COND_InitialOnly); - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRSliderComponent, bRepGameplayTags, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(UVRSliderComponent, bReplicateMovement, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UVRSliderComponent, GameplayTags, PushModelParamsWithCondition); + DOREPLIFETIME(UVRSliderComponent, bRepGameplayTags); + DOREPLIFETIME(UVRSliderComponent, bReplicateMovement); + DOREPLIFETIME_CONDITION(UVRSliderComponent, GameplayTags, COND_Custom); } void UVRSliderComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -908,10 +897,6 @@ void UVRSliderComponent::SetSplineComponentToFollow(USplineComponent * SplineToF { SplineComponentToFollow = SplineToFollow; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRSliderComponent, SplineComponentToFollow, this); -#endif - if (SplineToFollow != nullptr) ResetToParentSplineLocation(); else @@ -922,11 +907,6 @@ void UVRSliderComponent::ResetInitialSliderLocation() { // Get our initial relative transform to our parent (or not if un-parented). InitialRelativeTransform = this->GetRelativeTransform(); - -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRSliderComponent, InitialRelativeTransform, this); -#endif - ResetToParentSplineLocation(); if (SplineComponentToFollow == nullptr) @@ -1010,32 +990,4 @@ float UVRSliderComponent::CalculateSliderProgress() } return CurrentSliderProgress; -} - -void UVRSliderComponent::SetRepGameplayTags(bool bNewRepGameplayTags) -{ - bRepGameplayTags = bNewRepGameplayTags; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRSliderComponent, bRepGameplayTags, this); -#endif -} - -void UVRSliderComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UVRSliderComponent, bReplicateMovement, this); -#endif -} - -FGameplayTagContainer& UVRSliderComponent::GetGameplayTags() -{ -#if WITH_PUSH_MODEL - if (bRepGameplayTags) - { - MARK_PROPERTY_DIRTY_FROM_NAME(UVRSliderComponent, GameplayTags, this); - } -#endif - - return GameplayTags; } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/CollisionIgnoreSubsystem.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/CollisionIgnoreSubsystem.cpp index 0308f80..c41b3d5 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/CollisionIgnoreSubsystem.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/CollisionIgnoreSubsystem.cpp @@ -4,7 +4,6 @@ #include UE_INLINE_GENERATED_CPP_BY_NAME(CollisionIgnoreSubsystem) #include "Components/SkeletalMeshComponent.h" -#include "Engine/World.h" #include "Runtime/Engine/Classes/Kismet/GameplayStatics.h" #include "VRGlobalSettings.h" @@ -93,16 +92,6 @@ void UCollisionIgnoreSubsystem::ConstructInput() } } -void UCollisionIgnoreSubsystem::Deinitialize() -{ - Super::Deinitialize(); - - if (UpdateHandle.IsValid()) - { - GetWorld()->GetTimerManager().ClearTimer(UpdateHandle); - } -} - void UCollisionIgnoreSubsystem::UpdateTimer(bool bChangesWereMade) { diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/OptionalRepSkeletalMeshActor.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/OptionalRepSkeletalMeshActor.cpp index 480b36f..2fb79cf 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/OptionalRepSkeletalMeshActor.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/OptionalRepSkeletalMeshActor.cpp @@ -30,10 +30,7 @@ void UNoRepSphereComponent::GetLifetimeReplicatedProps(TArray< class FLifetimePr { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UNoRepSphereComponent, bReplicateMovement, PushModelParams); + DOREPLIFETIME(UNoRepSphereComponent, bReplicateMovement); RESET_REPLIFETIME_CONDITION_PRIVATE_PROPERTY(USceneComponent, AttachParent, COND_InitialOnly); RESET_REPLIFETIME_CONDITION_PRIVATE_PROPERTY(USceneComponent, AttachSocketName, COND_InitialOnly); @@ -44,14 +41,6 @@ void UNoRepSphereComponent::GetLifetimeReplicatedProps(TArray< class FLifetimePr //DISABLE_REPLICATED_PRIVATE_PROPERTY(AActor, AttachmentReplication); } -void UNoRepSphereComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UNoRepSphereComponent, bReplicateMovement, this); -#endif -} - void UNoRepSphereComponent::PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) { Super::PreReplication(ChangedPropertyTracker); @@ -106,15 +95,6 @@ void UInversePhysicsSkeletalMeshComponent::PreReplication(IRepChangedPropertyTra DOREPLIFETIME_ACTIVE_OVERRIDE_FAST(USceneComponent, RelativeScale3D, bReplicateMovement); } - -void UInversePhysicsSkeletalMeshComponent::SetReplicateMovement(bool bNewReplicateMovement) -{ - bReplicateMovement = bNewReplicateMovement; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UInversePhysicsSkeletalMeshComponent, bReplicateMovement, this); -#endif -} - void UInversePhysicsSkeletalMeshComponent::EndPhysicsTickComponentVR(FSkeletalMeshComponentEndPhysicsTickFunctionVR& ThisTickFunction) { //IMPORTANT! @@ -652,10 +632,7 @@ void UInversePhysicsSkeletalMeshComponent::GetLifetimeReplicatedProps(TArray< cl { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UInversePhysicsSkeletalMeshComponent, bReplicateMovement, PushModelParams); + DOREPLIFETIME(UInversePhysicsSkeletalMeshComponent, bReplicateMovement); } AOptionalRepGrippableSkeletalMeshActor::AOptionalRepGrippableSkeletalMeshActor(const FObjectInitializer& ObjectInitializer) : @@ -669,11 +646,8 @@ void AOptionalRepGrippableSkeletalMeshActor::GetLifetimeReplicatedProps(TArray< { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_InitialOnly, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AOptionalRepGrippableSkeletalMeshActor, bIgnoreAttachmentReplication, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(AOptionalRepGrippableSkeletalMeshActor, bIgnorePhysicsReplication, PushModelParamsWithCondition); + DOREPLIFETIME(AOptionalRepGrippableSkeletalMeshActor, bIgnoreAttachmentReplication); + DOREPLIFETIME(AOptionalRepGrippableSkeletalMeshActor, bIgnorePhysicsReplication); if (bIgnoreAttachmentReplication) { diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VRAIPerceptionOverrides.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VRAIPerceptionOverrides.cpp index 8dcd672..a874925 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VRAIPerceptionOverrides.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VRAIPerceptionOverrides.cpp @@ -3,11 +3,8 @@ #include "Misc/VRAIPerceptionOverrides.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(VRAIPerceptionOverrides) -#include "CoreMinimal.h" -#include "Engine/Engine.h" -#include "Engine/World.h" -//#include "EngineDefines.h" -//#include "EngineGlobals.h" +#include "EngineDefines.h" +#include "EngineGlobals.h" #include "CollisionQueryParams.h" //#include "Engine/Engine.h" #include "AISystem.h" @@ -48,12 +45,12 @@ DECLARE_CYCLE_STAT(TEXT("Perception Sense: Sight, Process pending result"), STAT -constexpr int32 DefaultMaxTracesPerTick = 6; -constexpr int32 DefaultMaxAsyncTracesPerTick = 10; -constexpr int32 DefaultMinQueriesPerTimeSliceCheck = 40; -constexpr float DefaultPendingQueriesBudgetReductionRatio = 0.5f; -constexpr bool bDefaultUseAsynchronousTraceForDefaultSightQueries = false; -constexpr float DefaultStimulusStrength = 1.f; +static const int32 DefaultMaxTracesPerTick = 6; +static const int32 DefaultMaxAsyncTracesPerTick = 10; +static const int32 DefaultMinQueriesPerTimeSliceCheck = 40; +static const float DefaultPendingQueriesBudgetReductionRatio = 0.5f; +static const bool bDefaultUseAsynchronousTraceForDefaultSightQueries = false; +static const float DefaultStimulusStrength = 1.f; enum class EForEachResult : uint8 { @@ -114,7 +111,7 @@ FORCEINLINE_DEBUGGABLE bool CheckIsTargetInSightPie(const FPerceptionListener& L const FAISightTargetVR::FTargetId FAISightTargetVR::InvalidTargetId = FAISystem::InvalidUnsignedID; FAISightTargetVR::FAISightTargetVR(AActor* InTarget, FGenericTeamId InTeamId) - : Target(InTarget), SightTargetInterface(nullptr), TeamId(InTeamId) + : Target(InTarget), SightTargetInterface(NULL), TeamId(InTeamId) { if (InTarget) { @@ -142,10 +139,8 @@ UAISense_Sight_VR::FDigestedSightProperties::FDigestedSightProperties(const UAIS } UAISense_Sight_VR::FDigestedSightProperties::FDigestedSightProperties() - : PeripheralVisionAngleCos(0.f), SightRadiusSq(-1.f), AutoSuccessRangeSqFromLastSeenLocation(FAISystem::InvalidRange), LoseSightRadiusSq(-1.f), PointOfViewBackwardOffset(0.0f), NearClippingRadiusSq(0.0f) -{ - AffiliationFlags = FAISenseAffiliationFilter::DetectAllFlags(); -} + : PeripheralVisionAngleCos(0.f), SightRadiusSq(-1.f), AutoSuccessRangeSqFromLastSeenLocation(FAISystem::InvalidRange), LoseSightRadiusSq(-1.f), PointOfViewBackwardOffset(0.0f), NearClippingRadiusSq(0.0f), AffiliationFlags(-1) +{} //----------------------------------------------------------------------// @@ -343,7 +338,7 @@ float UAISense_Sight_VR::Update() #if AISENSE_SIGHT_TIMESLICING_DEBUG UE::AISense_SightVR::FTimingSlicingInfo SlicingInfo; #endif // AISENSE_SIGHT_TIMESLICING_DEBUG - constexpr int32 InitialInvalidItemsSize = 16; + static const int32 InitialInvalidItemsSize = 16; enum class EOperationType : uint8 { Remove, @@ -493,7 +488,7 @@ float UAISense_Sight_VR::Update() }); // Do all the removes first and save the out of range swaps because we will insert them at the right location to prevent sorting TArray SightQueriesOutOfRangeToInsert; - for (const FQueryOperation& Operation : QueryOperations) + for (FQueryOperation& Operation : QueryOperations) { switch (Operation.OpType) { @@ -525,12 +520,12 @@ float UAISense_Sight_VR::Update() if (Operation.bInRange) { // In range queries are always sorted at the beginning of the update - SightQueriesInRange.RemoveAtSwap(Operation.Index, 1, EAllowShrinking::No); + SightQueriesInRange.RemoveAtSwap(Operation.Index, 1, /*bAllowShrinking*/false); } else { // Preserve the list ordered - SightQueriesOutOfRange.RemoveAt(Operation.Index, 1, EAllowShrinking::No); + SightQueriesOutOfRange.RemoveAt(Operation.Index, 1, /*bAllowShrinking*/false); if (Operation.Index < NextOutOfRangeIndex) { NextOutOfRangeIndex--; @@ -552,7 +547,7 @@ float UAISense_Sight_VR::Update() for (const auto& TargetId : InvalidTargets) { // remove affected queries - RemoveAllQueriesToTarget_Internal(TargetId); + RemoveAllQueriesToTarget(TargetId); // remove target itself ObservedTargets.Remove(TargetId); } @@ -756,7 +751,7 @@ void UAISense_Sight_VR::OnPendingTraceQueryProcessed(const FTraceHandle& TraceHa void UAISense_Sight_VR::OnPendingQueryProcessed(const int32 SightQueryIndex, const bool bIsVisible, const float StimulusStrength, const FVector& SeenLocation, const TOptional& UserData, const TOptional InTargetActor) { FAISightQueryVR SightQuery = SightQueriesPending[SightQueryIndex]; - SightQueriesPending.RemoveAtSwap(SightQueryIndex, 1, EAllowShrinking::No); + SightQueriesPending.RemoveAtSwap(SightQueryIndex, 1, false); AIPerception::FListenerMap& ListenersMap = *GetListeners(); FPerceptionListener* Listener = ListenersMap.Find(SightQuery.ObserverId); @@ -860,7 +855,7 @@ void UAISense_Sight_VR::UnregisterSource(AActor& SourceActor) Listener.RegisterStimulus(TargetActor, FAIStimulus(*this, 0.f, SightQuery->LastSeenLocation, Listener.CachedLocation, FAIStimulus::SensingFailed)); } - SightQueries.RemoveAtSwap(QueryIndex, 1, EAllowShrinking::No); + SightQueries.RemoveAtSwap(QueryIndex, 1, /*bAllowShrinking=*/false); return EReverseForEachResult::Modified; } @@ -1020,7 +1015,7 @@ void UAISense_Sight_VR::OnListenerUpdateImpl(const FPerceptionListener& UpdatedL // see if this listener is a Target as well const FAISightTargetVR::FTargetId AsTargetId = UpdatedListener.GetBodyActorUniqueID(); FAISightTargetVR* AsTarget = ObservedTargets.Find(AsTargetId); - if (AsTarget != nullptr) + if (AsTarget != NULL) { if (AsTarget->Target.IsValid()) { @@ -1131,11 +1126,13 @@ void UAISense_Sight_VR::RemoveAllQueriesByListener(const FPerceptionListener& Li { OnRemoveFunc(SightQuery); } - SightQueries.RemoveAtSwap(QueryIndex, 1, EAllowShrinking::No); + SightQueries.RemoveAtSwap(QueryIndex, 1, /*bAllowShrinking=*/false); return EReverseForEachResult::Modified; } + + return EReverseForEachResult::UnTouched; }; ReverseForEach(SightQueriesInRange, RemoveQuery); @@ -1151,12 +1148,6 @@ void UAISense_Sight_VR::RemoveAllQueriesToTarget(const FAISightTargetVR::FTarget { SCOPE_CYCLE_COUNTER(STAT_AI_Sense_Sight_RemoveToTarget); UE_MT_SCOPED_WRITE_ACCESS(QueriesListAccessDetector); - RemoveAllQueriesToTarget_Internal(TargetId, OnRemoveFunc); -} - -void UAISense_Sight_VR::RemoveAllQueriesToTarget_Internal(const FAISightTargetVR::FTargetId& TargetId, const TFunction& OnRemoveFunc/*= nullptr */) -{ - SCOPE_CYCLE_COUNTER(STAT_AI_Sense_Sight_RemoveToTarget); auto RemoveQuery = [&TargetId, &OnRemoveFunc](TArray& SightQueries, const int32 QueryIndex)->EReverseForEachResult { @@ -1168,7 +1159,7 @@ void UAISense_Sight_VR::RemoveAllQueriesToTarget_Internal(const FAISightTargetVR { OnRemoveFunc(SightQuery); } - SightQueries.RemoveAtSwap(QueryIndex, 1, EAllowShrinking::No); + SightQueries.RemoveAtSwap(QueryIndex, 1, /*bAllowShrinking=*/false); return EReverseForEachResult::Modified; } diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VREPhysicalAnimationComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VREPhysicalAnimationComponent.cpp index f109a22..24b97a8 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VREPhysicalAnimationComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Misc/VREPhysicalAnimationComponent.cpp @@ -8,11 +8,9 @@ #include "ReferenceSkeleton.h" #include "DrawDebugHelpers.h" -#if UE_ENABLE_DEBUG_DRAWING +#if ENABLE_DRAW_DEBUG #include "Chaos/ImplicitObject.h" #include "Chaos/TriangleMeshImplicitObject.h" -#include "Chaos/ShapeInstance.h" -#include "Chaos/DebugDrawQueue.h" #endif #include "Physics/PhysicsInterfaceCore.h" @@ -233,8 +231,8 @@ void UVREPhysicalAnimationComponent::UpdateWeldedBoneDriver(float DeltaTime) if (FPhysicsInterface::IsValid(ActorHandle) /*&& FPhysicsInterface::IsRigidBody(ActorHandle)*/) { -#if UE_ENABLE_DEBUG_DRAWING - if (false)//bDebugDrawCollision) +#if ENABLE_DRAW_DEBUG + if (bDebugDrawCollision) { Chaos::FDebugDrawQueue::GetInstance().SetConsumerActive(this, true); // Need to deactivate this later as well Chaos::FDebugDrawQueue::GetInstance().SetMaxCost(20000); @@ -253,8 +251,8 @@ void UVREPhysicalAnimationComponent::UpdateWeldedBoneDriver(float DeltaTime) FTransform GlobalPoseInv = GlobalPose.Inverse(); -#if UE_ENABLE_DEBUG_DRAWING - if (false)//bDebugDrawCollision) +#if ENABLE_DRAW_DEBUG + if (bDebugDrawCollision) { Chaos::FDebugDrawQueue::GetInstance().SetRegionOfInterest(GlobalPose.GetLocation(), 100.0f); } @@ -307,33 +305,33 @@ void UVREPhysicalAnimationComponent::UpdateWeldedBoneDriver(float DeltaTime) } } -#if UE_ENABLE_DEBUG_DRAWING - if (false)//bDebugDrawCollision) +#if ENABLE_DRAW_DEBUG + if (bDebugDrawCollision) { - /*const Chaos::FImplicitObject& ShapeImplicit = Shape.GetGeometry(); - Chaos::EImplicitObjectType Type = ShapeImplicit.GetType(); + const Chaos::FImplicitObject* ShapeImplicit = Shape.Shape->GetGeometry().Get(); + Chaos::EImplicitObjectType Type = ShapeImplicit->GetType(); FTransform shapeTransform = FPhysicsInterface::GetLocalTransform(Shape); FTransform FinalTransform = shapeTransform * GlobalPose; Chaos::FRigidTransform3 RigTransform(FinalTransform); - Chaos::DebugDraw::DrawShape(RigTransform, &ShapeImplicit, Shape.Shape, FColor::White);*/ + Chaos::DebugDraw::DrawShape(RigTransform, ShapeImplicit, Chaos::FShapeOrShapesArray(), FColor::White); } #endif } }); -#if UE_ENABLE_DEBUG_DRAWING - if (false)//bDebugDrawCollision) +#if ENABLE_DRAW_DEBUG + if (bDebugDrawCollision) { // Get the latest commands - /*TArray DrawCommands; + TArray DrawCommands; Chaos::FDebugDrawQueue::GetInstance().ExtractAllElements(DrawCommands); if (DrawCommands.Num()) { DebugDrawMesh(DrawCommands); } Chaos::FDebugDrawQueue::GetInstance().SetConsumerActive(this, false); // Need to deactivate this later as well - Chaos::FDebugDrawQueue::GetInstance().SetEnabled(false);*/ + Chaos::FDebugDrawQueue::GetInstance().SetEnabled(false); } #endif } @@ -343,8 +341,7 @@ void UVREPhysicalAnimationComponent::UpdateWeldedBoneDriver(float DeltaTime) } } -#if UE_ENABLE_DEBUG_DRAWING -/* +#if ENABLE_DRAW_DEBUG void UVREPhysicalAnimationComponent::DebugDrawMesh(const TArray& DrawCommands) { UWorld* World = this->GetWorld(); @@ -385,5 +382,5 @@ void UVREPhysicalAnimationComponent::DebugDrawMesh(const TArrayGetBegunPlay()) + if (!World || !World->bBegunPlay) return; // Reference to the Render Target resource @@ -490,24 +485,14 @@ void ARenderTargetReplicationProxy::SendNextDataBlob() } } -void ARenderTargetReplicationProxy::EndPlay(const EEndPlayReason::Type EndPlayReason) -{ - if (SendTimer_Handle.IsValid()) - GetWorld()->GetTimerManager().ClearTimer(SendTimer_Handle); - - Super::EndPlay(EndPlayReason); -} - //============================================================================= void ARenderTargetReplicationProxy::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty >& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_InitialOnly, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - DOREPLIFETIME_WITH_PARAMS_FAST(ARenderTargetReplicationProxy, OwningManager, PushModelParamsWithCondition); - DOREPLIFETIME_WITH_PARAMS_FAST(ARenderTargetReplicationProxy, OwnersID, PushModelParamsWithCondition); + DOREPLIFETIME(ARenderTargetReplicationProxy, OwningManager); + DOREPLIFETIME(ARenderTargetReplicationProxy, OwnersID); } void ARenderTargetReplicationProxy::ReceiveTextureBlob_Implementation(const TArray& TextureBlob, int32 LocationInData, int32 BlobNumber) diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Mover/VRMoverComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Mover/VRMoverComponent.cpp deleted file mode 100644 index e6bb8ba..0000000 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/Mover/VRMoverComponent.cpp +++ /dev/null @@ -1,207 +0,0 @@ - -#include "Mover/VRMoverComponent.h" -#include UE_INLINE_GENERATED_CPP_BY_NAME(VRMoverComponent) - -#include "VRBPDatatypes.h" -#include "DefaultMovementSet\LayeredMoves\BasicLayeredMoves.h" -#include "Engine/BlueprintGeneratedClass.h" -#include "Curves\CurveFloat.h" // Delete after tests, only needed for cloning -#include "ReplicatedVRCameraComponent.h" - -DEFINE_LOG_CATEGORY(LogVRMoverComponent); - - -static const FName Name_CharacterMotionComponent(TEXT("MoverComponent")); - -/* - - Layered move to inject VR movement into the mover component - -*/ - - -FLayeredMove_VRMovement::FLayeredMove_VRMovement() - : Velocity(FVector::ZeroVector) - , MagnitudeOverTime(nullptr) - , SettingsFlags(0) -{ - // This should never end - DurationMs = -1.0f; -} - -bool FLayeredMove_VRMovement::IsFinished(float CurrentSimTimeMs) const -{ - // We never end the VR velocity injection - return false; -} - -bool FLayeredMove_VRMovement::GenerateMove(const FMoverTickStartData& SimState, const FMoverTimeStep& TimeStep, const UMoverComponent* MoverComp, UMoverBlackboard* SimBlackboard, FProposedMove& OutProposedMove) -{ - const FMoverDefaultSyncState* SyncState = SimState.SyncState.SyncStateCollection.FindDataByType(); - check(SyncState); - - const float DeltaSeconds = TimeStep.StepMs * 0.001f; - - // Convert starting velocity based on starting orientation, if settings call for it - if (SettingsFlags & (uint8)ELayeredMove_ConstantVelocitySettingsFlags::VelocityStartRelative && - StartSimTimeMs == TimeStep.BaseSimTimeMs) - { - SettingsFlags &= ~(uint8)ELayeredMove_ConstantVelocitySettingsFlags::VelocityStartRelative; - Velocity = SyncState->GetOrientation_WorldSpace().RotateVector(Velocity); - } - - FVector VelocityThisFrame = Velocity; - - // Put velocity into worldspace - if (SettingsFlags & (uint8)ELayeredMove_ConstantVelocitySettingsFlags::VelocityAlwaysRelative) - { - VelocityThisFrame = SyncState->GetOrientation_WorldSpace().RotateVector(Velocity); - } - - if (MagnitudeOverTime && DurationMs > 0) - { - const float TimeValue = DurationMs > 0.f ? FMath::Clamp((TimeStep.BaseSimTimeMs - StartSimTimeMs) / DurationMs, 0.f, 1.f) : TimeStep.BaseSimTimeMs; - const float TimeFactor = MagnitudeOverTime->GetFloatValue(TimeValue); - VelocityThisFrame *= TimeFactor; - } - - OutProposedMove.LinearVelocity = VelocityThisFrame; - - return true; -} - -FLayeredMoveBase* FLayeredMove_VRMovement::Clone() const -{ - FLayeredMove_VRMovement* CopyPtr = new FLayeredMove_VRMovement(*this); - return CopyPtr; -} - -void FLayeredMove_VRMovement::NetSerialize(FArchive& Ar) -{ - Super::NetSerialize(Ar); - - SerializePackedVector<10, 16>(Velocity, Ar); - Ar << SettingsFlags; - Ar << MagnitudeOverTime; -} - -UScriptStruct* FLayeredMove_VRMovement::GetScriptStruct() const -{ - return FLayeredMove_VRMovement::StaticStruct(); -} - -FString FLayeredMove_VRMovement::ToSimpleString() const -{ - return FString::Printf(TEXT("LinearVelocity")); -} - -void FLayeredMove_VRMovement::AddReferencedObjects(class FReferenceCollector& Collector) -{ - Super::AddReferencedObjects(Collector); -} - - -/* - - VR HMD Sync State to store the HMD velocities - Which should be pulled from input somehow -*/ - -FMoverDataStructBase* FVRMoverHMDSyncState::Clone() const -{ - // TODO: ensure that this memory allocation jives with deletion method - FVRMoverHMDSyncState* CopyPtr = new FVRMoverHMDSyncState(*this); - return CopyPtr; -} - -bool FVRMoverHMDSyncState::NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) -{ - Super::NetSerialize(Ar, Map, bOutSuccess); - - SerializeFixedVector<2, 8>(MoveDirectionIntent, Ar); - bOutSuccess = true; - return true; -} - - - -AVRMoverBasePawn::AVRMoverBasePawn(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) -{ - - CharacterMotionComponent = CreateDefaultSubobject(Name_CharacterMotionComponent); - ensure(CharacterMotionComponent); - - // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. - PrimaryActorTick.bCanEverTick = true; - - SetReplicatingMovement(false); // disable Actor-level movement replication, since our Mover component will handle it - - // Let the code know if blueprints have implemented input - auto IsImplementedInBlueprint = [](const UFunction* Func) -> bool - { - return Func && ensure(Func->GetOuter()) - && Func->GetOuter()->IsA(UBlueprintGeneratedClass::StaticClass()); - }; - - static FName ProduceInputBPFuncName = FName(TEXT("OnProduceInputInBlueprint")); - UFunction* ProduceInputFunction = GetClass()->FindFunctionByName(ProduceInputBPFuncName); - bHasProduceInputinBpFunc = IsImplementedInBlueprint(ProduceInputFunction); -} - -void AVRMoverBasePawn::BeginPlay() -{ - Super::BeginPlay(); - - // In constructor for the data instead of begin play? Might even be able to queue the layered move there too - if (IsValid(CharacterMotionComponent)) - { - // Add the sync data for our layered HMD movement injection - CharacterMotionComponent->PersistentSyncStateDataTypes.Add(FMoverDataPersistence(FVRMoverHMDSyncState::StaticStruct(), true)); - - // Needs to be handled off of possession instead? - if (HasLocalNetOwner()) - { - // Add the persistant HMDlayered move addition - TSharedPtr VRMoveLayer = MakeShared(); - CharacterMotionComponent->QueueLayeredMove(VRMoveLayer); - } - } -} - - -UPrimitiveComponent* AVRMoverBasePawn::GetMovementBase() const -{ - return CharacterMotionComponent ? CharacterMotionComponent->GetMovementBase() : nullptr; -} - - -void AVRMoverBasePawn::ProduceInput_Implementation(int32 SimTimeMs, FMoverInputCmdContext& InputCmdResult) -{ - OnProduceInput((float)SimTimeMs, InputCmdResult); - - if (bHasProduceInputinBpFunc) - { - InputCmdResult = OnProduceInputInBlueprint((float)SimTimeMs, InputCmdResult); - } -} - - -void AVRMoverBasePawn::OnProduceInput(float DeltaMs, FMoverInputCmdContext& OutInputCmd) -{ - - // Generate user commands. Called right before the Character movement simulation will tick (for a locally controlled pawn) - // This isn't meant to be the best way of doing a camera system. It is just meant to show a couple of ways it may be done - // and to make sure we can keep distinct the movement, rotation, and view angles. - // Styles 1-3 are really meant to be used with a gamepad. - // - // Its worth calling out: the code that happens here is happening *outside* of the Character movement simulation. All we are doing - // is generating the input being fed into that simulation. That said, this means that A) the code below does not run on the server - // (and non controlling clients) and B) the code is not rerun during reconcile/resimulates. Use this information guide any - // decisions about where something should go (such as aim assist, lock on targeting systems, etc): it is hard to give absolute - // answers and will depend on the game and its specific needs. In general, at this time, I'd recommend aim assist and lock on - // targeting systems to happen /outside/ of the system, i.e, here. But I can think of scenarios where that may not be ideal too. - - //FCharacterDefaultInputs& CharacterInputs = OutInputCmd.InputCollection.FindOrAddMutableDataByType(); - -} diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ParentRelativeAttachmentComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ParentRelativeAttachmentComponent.cpp index 741ed2f..6dc37e9 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ParentRelativeAttachmentComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ParentRelativeAttachmentComponent.cpp @@ -3,7 +3,6 @@ #include "ParentRelativeAttachmentComponent.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(ParentRelativeAttachmentComponent) -#include "Engine/Engine.h" #include "VRBaseCharacter.h" #include "VRCharacter.h" #include "IXRTrackingSystem.h" diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ReplicatedVRCameraComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ReplicatedVRCameraComponent.cpp index c592ee2..a55c454 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ReplicatedVRCameraComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/ReplicatedVRCameraComponent.cpp @@ -3,9 +3,6 @@ #include "ReplicatedVRCameraComponent.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(ReplicatedVRCameraComponent) -#include "CoreMinimal.h" -#include "Engine/Engine.h" -#include "Engine/World.h" #include "Net/UnrealNetwork.h" #include "VRBaseCharacter.h" #include "VRCharacter.h" @@ -14,9 +11,6 @@ #include "IXRCamera.h" #include "Rendering/MotionVectorSimulation.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif UReplicatedVRCameraComponent::UReplicatedVRCameraComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -47,6 +41,7 @@ UReplicatedVRCameraComponent::UReplicatedVRCameraComponent(const FObjectInitiali MaximumTrackedBounds = 1028; bSetPositionDuringTick = false; + bSmoothReplicatedMotion = false; bLerpingPosition = false; bReppedOnce = false; @@ -75,27 +70,28 @@ void UReplicatedVRCameraComponent::GetLifetimeReplicatedProps(TArray< class FLif DISABLE_REPLICATED_PRIVATE_PROPERTY(USceneComponent, RelativeRotation); DISABLE_REPLICATED_PRIVATE_PROPERTY(USceneComponent, RelativeScale3D); - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_SkipOwner, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - // Skipping the owner with this as the owner will use the location directly - DOREPLIFETIME_WITH_PARAMS_FAST(UReplicatedVRCameraComponent, ReplicatedCameraTransform, PushModelParamsWithCondition); - - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(UReplicatedVRCameraComponent, NetUpdateRate, PushModelParams); - //DOREPLIFETIME(UReplicatedVRCameraComponent, bSmoothReplicatedMotion); // This doesn't need to be replicated + DOREPLIFETIME_CONDITION(UReplicatedVRCameraComponent, ReplicatedCameraTransform, COND_SkipOwner); + DOREPLIFETIME(UReplicatedVRCameraComponent, NetUpdateRate); + DOREPLIFETIME(UReplicatedVRCameraComponent, bSmoothReplicatedMotion); //DOREPLIFETIME(UReplicatedVRCameraComponent, bReplicateTransform); } +// Just skipping this, it generates warnings for attached meshes when using this method of denying transform replication +/*void UReplicatedVRCameraComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) +{ + Super::PreReplication(ChangedPropertyTracker); + + // Don't ever replicate these, they are getting replaced by my custom send anyway + DOREPLIFETIME_ACTIVE_OVERRIDE(USceneComponent, RelativeLocation, false); + DOREPLIFETIME_ACTIVE_OVERRIDE(USceneComponent, RelativeRotation, false); + DOREPLIFETIME_ACTIVE_OVERRIDE(USceneComponent, RelativeScale3D, false); +}*/ + void UReplicatedVRCameraComponent::Server_SendCameraTransform_Implementation(FBPVRComponentPosRep NewTransform) { // Store new transform and trigger OnRep_Function ReplicatedCameraTransform = NewTransform; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UReplicatedVRCameraComponent, ReplicatedCameraTransform, this); -#endif // Don't call on rep on the server if the server controls this controller if (!bHasAuthority) @@ -407,10 +403,6 @@ void UReplicatedVRCameraComponent::TickComponent(float DeltaTime, enum ELevelTic ReplicatedCameraTransform.Rotation = RelativeRot; } -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UReplicatedVRCameraComponent, ReplicatedCameraTransform, this); -#endif - if (GetNetMode() == NM_Client) { AVRBaseCharacter* OwningChar = Cast(GetOwner()); @@ -514,11 +506,6 @@ void UReplicatedVRCameraComponent::HandleXRCamera() } } -FTransform UReplicatedVRCameraComponent::GetHMDTrackingTransform() -{ - return FTransform(ReplicatedCameraTransform.Rotation, ReplicatedCameraTransform.Position); -} - void UReplicatedVRCameraComponent::OnRep_ReplicatedCameraTransform() { if (GetNetMode() < ENetMode::NM_Client && HasTrackingParameters()) @@ -583,19 +570,4 @@ void UReplicatedVRCameraComponent::OnRep_ReplicatedCameraTransform() } else SetRelativeLocationAndRotation(CameraPosition, ReplicatedCameraTransform.Rotation); -} - -void UReplicatedVRCameraComponent::SetNetUpdateRate(float NewNetUpdateRate) -{ - NetUpdateRate = NewNetUpdateRate; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(UReplicatedVRCameraComponent, NetUpdateRate, this); -#endif -} - -bool UReplicatedVRCameraComponent::IsLocallyControlled() const -{ - // I like epics new authority check more than my own - const AActor* MyOwner = GetOwner(); - return MyOwner->HasLocalNetOwner(); } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRAIController.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRAIController.cpp index dc6fc4c..0d770db 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRAIController.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRAIController.cpp @@ -4,8 +4,6 @@ #include UE_INLINE_GENERATED_CPP_BY_NAME(VRAIController) //#include "VRBPDatatypes.h" -#include "CoreMinimal.h" -#include "Engine/World.h" #include "VRBaseCharacter.h" #include "Components/CapsuleComponent.h" #include "NetworkingDistanceConstants.h" // Needed for the LinOfSightTo function override to work diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBPDatatypes.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBPDatatypes.cpp index 30b9c3d..ad63a88 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBPDatatypes.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBPDatatypes.cpp @@ -3,9 +3,6 @@ #include "VRBPDatatypes.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(VRBPDatatypes) -#include "CoreMinimal.h" -#include "VRGlobalSettings.h" -#include "Components\PrimitiveComponent.h" #include "HAL/IConsoleManager.h" #include "Chaos/ChaosEngineInterface.h" @@ -221,72 +218,4 @@ FTransform FBPEuroLowPassFilterTrans::RunFilterSmoothing(const FTransform& InRaw NewTrans.NormalizeRotation(); // Filter passed value return NewTrans; -} - -bool FBPAdvancedPhysicsHandleSettings::FillTo(FBPActorPhysicsHandleInformation* HandleInfo, bool bModifyWithScalers) const -{ - if (!HandleInfo) - return false; - - float DampingMod = 0.0f; - float StiffnessMod = 0.0f; - float ADampingMod = 0.0f; - float AStiffnessMod = 0.0f; - const UVRGlobalSettings& VRSettings = *GetDefault(); - - if (VRSettings.bUseChaosTranslationScalers) - { - StiffnessMod = VRSettings.LinearDriveStiffnessScale; - DampingMod = VRSettings.LinearDriveDampingScale; - AStiffnessMod = VRSettings.AngularDriveStiffnessScale; - ADampingMod = VRSettings.AngularDriveDampingScale; - } - else - { - auto CVarLinearDriveStiffnessScale = IConsoleManager::Get().FindConsoleVariable(TEXT("p.Chaos.JointConstraint.LinearDriveStiffnessScale")); - auto CVarLinearDriveDampingScale = IConsoleManager::Get().FindConsoleVariable(TEXT("p.Chaos.JointConstraint.LinaearDriveDampingScale")); - auto CVarAngularDriveStiffnessScale = IConsoleManager::Get().FindConsoleVariable(TEXT("p.Chaos.JointConstraint.AngularDriveStiffnessScale")); - auto CVarAngularDriveDampingScale = IConsoleManager::Get().FindConsoleVariable(TEXT("p.Chaos.JointConstraint.AngularDriveDampingScale")); - - StiffnessMod = CVarLinearDriveStiffnessScale->GetFloat(); - DampingMod = CVarLinearDriveDampingScale->GetFloat(); - AStiffnessMod = CVarAngularDriveStiffnessScale->GetFloat(); - ADampingMod = CVarAngularDriveDampingScale->GetFloat(); - } - - XAxisSettings.FillTo(HandleInfo->LinConstraint.XDrive, DampingMod, StiffnessMod); - YAxisSettings.FillTo(HandleInfo->LinConstraint.YDrive, DampingMod, StiffnessMod); - ZAxisSettings.FillTo(HandleInfo->LinConstraint.ZDrive, DampingMod, StiffnessMod); - - if ((SlerpSettings.bEnablePositionDrive || SlerpSettings.bEnableVelocityDrive)) - { - HandleInfo->AngConstraint.AngularDriveMode = EAngularDriveMode::SLERP; - SlerpSettings.FillTo(HandleInfo->AngConstraint.SlerpDrive, ADampingMod, AStiffnessMod); - } - else - { - HandleInfo->AngConstraint.AngularDriveMode = EAngularDriveMode::TwistAndSwing; - TwistSettings.FillTo(HandleInfo->AngConstraint.TwistDrive, ADampingMod, AStiffnessMod); - SwingSettings.FillTo(HandleInfo->AngConstraint.SwingDrive, ADampingMod, AStiffnessMod); - } - - return true; -} - -AActor* FBPActorGripInformation::GetGrippedActor() const -{ - return Cast(GrippedObject); -} - -UPrimitiveComponent* FBPActorGripInformation::GetGrippedComponent() const -{ - return Cast(GrippedObject); -} - -bool FBPActorGripInformation::operator==(const UPrimitiveComponent* Other) const -{ - if (Other && GrippedObject && GrippedObject == (const UObject*)Other) - return true; - - return false; } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacter.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacter.cpp index 43efdf8..bbf298b 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacter.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacter.cpp @@ -14,13 +14,8 @@ #include "VRPathFollowingComponent.h" #include "Net/UnrealNetwork.h" #include "XRMotionControllerBase.h" -#include "NavFilters/NavigationQueryFilter.h" //#include "Runtime/Engine/Private/EnginePrivate.h" -#if WITH_PUSH_MODEL -#include "Net/Core/PushModel/PushModel.h" -#endif - DEFINE_LOG_CATEGORY(LogBaseVRCharacter); FName AVRBaseCharacter::LeftMotionControllerComponentName(TEXT("Left Grip Motion Controller")); @@ -240,24 +235,13 @@ void AVRBaseCharacter::PostInitializeComponents() void AVRBaseCharacter::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > & OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - - // For std properties - FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AVRBaseCharacter, SeatInformation, PushModelParams); - DOREPLIFETIME_WITH_PARAMS_FAST(AVRBaseCharacter, VRReplicateCapsuleHeight, PushModelParams); - - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsWithCondition{ COND_SimulatedOnly, REPNOTIFY_OnChanged, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AVRBaseCharacter, ReplicatedCapsuleHeight, PushModelParamsWithCondition); + DOREPLIFETIME_CONDITION(AVRBaseCharacter, SeatInformation, COND_None); + DOREPLIFETIME_CONDITION(AVRBaseCharacter, VRReplicateCapsuleHeight, COND_None); + DOREPLIFETIME_CONDITION(AVRBaseCharacter, ReplicatedCapsuleHeight, COND_SimulatedOnly); DISABLE_REPLICATED_PRIVATE_PROPERTY(AActor, ReplicatedMovement); - // For properties with special conditions - FDoRepLifetimeParams PushModelParamsReplicatedMovement{ COND_SimulatedOrPhysics, REPNOTIFY_Always, /*bIsPushBased=*/true }; - - DOREPLIFETIME_WITH_PARAMS_FAST(AVRBaseCharacter, ReplicatedMovementVR, PushModelParamsReplicatedMovement); + DOREPLIFETIME_CONDITION_NOTIFY(AVRBaseCharacter, ReplicatedMovementVR, COND_SimulatedOrPhysics, REPNOTIFY_Always); } void AVRBaseCharacter::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) @@ -299,10 +283,6 @@ void AVRBaseCharacter::Server_ReZeroSeating_Implementation(FTransform_NetQuantiz SeatInformation.StoredTargetTransform.AddToTranslation(FVector(0, 0, -newLocation.Z)); } -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AVRBaseCharacter, SeatInformation, this); -#endif - OnRep_SeatedCharInfo(); } @@ -477,10 +457,6 @@ void AVRBaseCharacter::GatherCurrentMovement() ReplicatedMovementVR.PausedTrackingLoc = PausedTrackingLoc; ReplicatedMovementVR.PausedTrackingRot = PausedTrackingRot; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AVRBaseCharacter, ReplicatedMovementVR, this); -#endif - } @@ -808,7 +784,7 @@ bool AVRBaseCharacter::SetSeatedMode(USceneComponent * SeatParent, bool bSetSeat // I think we can remove the initial value alltogether eventually right? if (!bRetainRoomscale && VRReplicatedCamera) { - InitialRelCameraTransform = VRReplicatedCamera->GetHMDTrackingTransform(); + InitialRelCameraTransform = FTransform(VRReplicatedCamera->ReplicatedCameraTransform.Rotation, VRReplicatedCamera->ReplicatedCameraTransform.Position, VRReplicatedCamera->GetComponentScale()); } SeatInformation.SeatParent = SeatParent; @@ -829,10 +805,6 @@ bool AVRBaseCharacter::SetSeatedMode(USceneComponent * SeatParent, bool bSetSeat SeatInformation.StoredTargetTransform.AddToTranslation(FVector(0, 0, -newLocation.Z)); } -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AVRBaseCharacter, SeatInformation, this); -#endif - //SetReplicateMovement(false);/ / No longer doing this, allowing it to replicate down to simulated clients now instead } else @@ -843,9 +815,6 @@ bool AVRBaseCharacter::SetSeatedMode(USceneComponent * SeatParent, bool bSetSeat //SetReplicateMovement(true); // No longer doing this, allowing it to replicate down to simulated clients now instead SeatInformation.bSitting = false; } -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AVRBaseCharacter, SeatInformation, this); -#endif OnRep_SeatedCharInfo(); // Call this on server side because it won't call itself NotifyOfTeleport(); // Teleport the controllers @@ -1236,11 +1205,3 @@ void AVRBaseCharacter::StopNavigationMovement() pathComp->AbortMove(*this, FPathFollowingResultFlags::MovementStop | FPathFollowingResultFlags::ForcedScript); } } - -void AVRBaseCharacter::SetVRReplicateCapsuleHeight(bool bNewVRReplicateCapsuleHeight) -{ - VRReplicateCapsuleHeight = bNewVRReplicateCapsuleHeight; -#if WITH_PUSH_MODEL - MARK_PROPERTY_DIRTY_FROM_NAME(AVRBaseCharacter, VRReplicateCapsuleHeight, this); -#endif -} \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacterMovementComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacterMovementComponent.cpp index ea4e5d6..da831b6 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacterMovementComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRBaseCharacterMovementComponent.cpp @@ -19,7 +19,6 @@ #include "Navigation/PathFollowingComponent.h" #include "VRPlayerController.h" #include "GameFramework/PhysicsVolume.h" -#include "Animation\AnimInstance.h" DEFINE_LOG_CATEGORY(LogVRBaseCharacterMovement); @@ -1894,9 +1893,6 @@ void UVRBaseCharacterMovementComponent::MoveAutonomous( const bool bWasPlayingRootMotion = CharacterOwner->IsPlayingRootMotion(); - // Scope these, they nest with Outer references so it should work fine, this keeps the update rotation and move autonomous from double updating the char - //const FScopedPreventAttachedComponentMove PreventMeshMove(BaseVRCharacterOwner ? BaseVRCharacterOwner->NetSmoother : nullptr); - PerformMovement(DeltaTime); // Check if data is valid as PerformMovement can mark character for pending kill @@ -1914,31 +1910,12 @@ void UVRBaseCharacterMovementComponent::MoveAutonomous( } // TODO: SaveBaseLocation() in case tick moves us? - - USkeletalMeshComponent* OwnerMesh = CharacterOwner->GetMesh(); - check(OwnerMesh != nullptr) - static const auto CVarEnableQueuedAnimEventsOnServer = IConsoleManager::Get().FindConsoleVariable(TEXT("a.EnableQueuedAnimEventsOnServer")); - if (CVarEnableQueuedAnimEventsOnServer->GetInt()) + if (!CVarEnableQueuedAnimEventsOnServer->GetInt() || CharacterOwner->GetMesh()->ShouldOnlyTickMontages(DeltaTime)) { - if (const UAnimInstance* AnimInstance = OwnerMesh->GetAnimInstance()) - { - if (OwnerMesh->VisibilityBasedAnimTickOption <= EVisibilityBasedAnimTickOption::AlwaysTickPose && AnimInstance->NeedsUpdate()) - { - // If we are doing a full graph update on the server but its doing a parallel update, - // trigger events right away since these are notifies queued from the montage update and we could be receiving multiple ServerMoves per frame. - OwnerMesh->ConditionallyDispatchQueuedAnimEvents(); - OwnerMesh->AllowQueuedAnimEventsNextDispatch(); - } - } - } - else - { - // Revert back to old behavior if wanted/needed. - if (OwnerMesh->ShouldOnlyTickMontages(DeltaTime)) - { - OwnerMesh->ConditionallyDispatchQueuedAnimEvents(); - } + // If we're not doing a full anim graph update on the server, + // trigger events right away, as we could be receiving multiple ServerMoves per frame. + CharacterOwner->GetMesh()->ConditionallyDispatchQueuedAnimEvents(); } } @@ -2258,10 +2235,9 @@ void UVRBaseCharacterMovementComponent::UpdateFromCompressedFlags(uint8 Flags) FVector UVRBaseCharacterMovementComponent::RoundDirectMovement(FVector InMovement) const { // Match FVector_NetQuantize100 (2 decimal place of precision). - UE::Net::QuantizeVector(100, InMovement); - //InMovement.X = FMath::RoundToFloat(InMovement.X * 100.f) / 100.f; - //InMovement.Y = FMath::RoundToFloat(InMovement.Y * 100.f) / 100.f; - //InMovement.Z = FMath::RoundToFloat(InMovement.Z * 100.f) / 100.f; + InMovement.X = FMath::RoundToFloat(InMovement.X * 100.f) / 100.f; + InMovement.Y = FMath::RoundToFloat(InMovement.Y * 100.f) / 100.f; + InMovement.Z = FMath::RoundToFloat(InMovement.Z * 100.f) / 100.f; return InMovement; } @@ -2408,5 +2384,5 @@ bool UVRBaseCharacterMovementComponent::SetCharacterToNewGravity(FVector NewGrav return true; } - //return false; + return false; } \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacter.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacter.cpp index a81130a..91bfa26 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacter.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacter.cpp @@ -14,7 +14,6 @@ #include "GameFramework/Controller.h" #include "Runtime/Launch/Resources/Version.h" #include "VRPathFollowingComponent.h" -#include "NavFilters/NavigationQueryFilter.h" //#include "Runtime/Engine/Private/EnginePrivate.h" DEFINE_LOG_CATEGORY(LogVRCharacter); diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacterMovementComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacterMovementComponent.cpp index 504ad79..490f506 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacterMovementComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRCharacterMovementComponent.cpp @@ -457,7 +457,7 @@ void FSavedMove_VRCharacter::PrepMoveFor(ACharacter* Character) if (AVRBaseCharacter * BaseChar = Cast(CharMove->GetCharacterOwner())) { - if (BaseChar->GetVRReplicateCapsuleHeight() && this->CapsuleHeight > 0.0f && !FMath::IsNearlyEqual(this->CapsuleHeight, CharMove->VRRootCapsule->GetUnscaledCapsuleHalfHeight())) + if (BaseChar->VRReplicateCapsuleHeight && this->CapsuleHeight > 0.0f && !FMath::IsNearlyEqual(this->CapsuleHeight, CharMove->VRRootCapsule->GetUnscaledCapsuleHalfHeight())) { BaseChar->SetCharacterHalfHeightVR(CapsuleHeight, false); //CharMove->VRRootCapsule->SetCapsuleHalfHeight(this->LFDiff.Z, false); @@ -566,10 +566,6 @@ void UVRCharacterMovementComponent::ServerMove_PerformMovement(const FCharacterN DeltaTime = ServerData->GetServerMoveDeltaTime(ClientTimeStamp, CharacterOwner->GetActorTimeDilation(*MyWorld)); } - // They added a scope here, im not using it as im doing the full capsule above - // Scope these, they nest with Outer references so it should work fine, this keeps the update rotation and move autonomous from double updating the char - //const FScopedPreventAttachedComponentMove PreventMeshMove(BaseVRCharacterOwner ? BaseVRCharacterOwner->NetSmoother : nullptr); - if (DeltaTime > 0.f) { ServerData->CurrentClientTimeStamp = ClientTimeStamp; @@ -619,7 +615,7 @@ void UVRCharacterMovementComponent::ServerMove_PerformMovement(const FCharacterN if (BaseVRCharacterOwner) { - if (BaseVRCharacterOwner->GetVRReplicateCapsuleHeight() && MoveDataVR->CapsuleHeight > 0.0f && !FMath::IsNearlyEqual(MoveDataVR->CapsuleHeight, VRRootCapsule->GetUnscaledCapsuleHalfHeight())) + if (BaseVRCharacterOwner->VRReplicateCapsuleHeight && MoveDataVR->CapsuleHeight > 0.0f && !FMath::IsNearlyEqual(MoveDataVR->CapsuleHeight, VRRootCapsule->GetUnscaledCapsuleHalfHeight())) { BaseVRCharacterOwner->SetCharacterHalfHeightVR(MoveDataVR->CapsuleHeight, false); // BaseChar->ReplicatedCapsuleHeight.CapsuleHeight = LFDiff.Z; @@ -900,9 +896,6 @@ void UVRCharacterMovementComponent::PhysWalking(float deltaTime, int32 Iteration bool bTriedLedgeMove = false; float remainingTime = deltaTime; - const EMovementMode StartingMovementMode = MovementMode; - const uint8 StartingCustomMovementMode = CustomMovementMode; - // Rewind the players position by the new capsule location RewindVRRelativeMovement(); @@ -944,9 +937,9 @@ void UVRCharacterMovementComponent::PhysWalking(float deltaTime, int32 Iteration devCodeVR(ensureMsgf(!Velocity.ContainsNaN(), TEXT("PhysWalking: Velocity contains NaN after Root Motion application (%s)\n%s"), *GetPathNameSafe(this), *Velocity.ToString())); - if (MovementMode != StartingMovementMode || CustomMovementMode != StartingCustomMovementMode) + if (IsFalling()) { - // Root motion could have taken us out of our current mode + // Root motion could have put us into Falling. // No movement has taken place this movement tick so we pass on full time/past iteration count StartNewPhysics(remainingTime + timeTick, Iterations - 1); return; @@ -987,15 +980,9 @@ void UVRCharacterMovementComponent::PhysWalking(float deltaTime, int32 Iteration // try to move forward MoveAlongFloor(MoveVelocity, timeTick, &StepDownResult); - if (IsSwimming()) //just entered water + if (IsFalling()) { - StartSwimming(OldLocation, OldVelocity, timeTick, remainingTime, Iterations); - return; - } - else if (MovementMode != StartingMovementMode || CustomMovementMode != StartingCustomMovementMode) - { - // pawn ended up in a different mode, probably due to the step-up-and-over flow - // let's refund the estimated unused time (if any) and keep moving in the new mode + // pawn decided to jump up const float DesiredDist = Delta.Size(); if (DesiredDist > UE_KINDA_SMALL_NUMBER) { @@ -1006,6 +993,12 @@ void UVRCharacterMovementComponent::PhysWalking(float deltaTime, int32 Iteration StartNewPhysics(remainingTime, Iterations); return; } + else if (IsSwimming()) //just entered water + { + RestorePreAdditiveVRMotionVelocity(); + StartSwimmingVR(OldCapsuleLocation, OldVelocity, timeTick, remainingTime, Iterations); + return; + } } // Update floor. @@ -1303,7 +1296,8 @@ void UVRCharacterMovementComponent::ReplicateMoveToServer(float DeltaTime, const // Remove pending move from move list. It would have to be the last move on the list. if (ClientData->SavedMoves.Num() > 0 && ClientData->SavedMoves.Last() == ClientData->PendingMove) { - ClientData->SavedMoves.Pop(EAllowShrinking::No); + const bool bAllowShrinking = false; + ClientData->SavedMoves.Pop(bAllowShrinking); } ClientData->FreeMove(ClientData->PendingMove); ClientData->PendingMove = nullptr; @@ -2299,17 +2293,6 @@ void UVRCharacterMovementComponent::UpdateBasedMovement(float DeltaSeconds) } else { - // Set MovementBase's root actor as ignored when moving the character primitive component, - // only perform if bDeferUpdateBasedMovement is true since this means the MovementBase is simulating physics - const bool bIgnoreBaseActor = bDeferUpdateBasedMovement && bBasedMovementIgnorePhysicsBase; - AActor* MovementBaseRootActor = nullptr; - if (bIgnoreBaseActor) - { - MovementBaseRootActor = MovementBase->GetAttachmentRootActor(); - UpdatedPrimitive->IgnoreActorWhenMoving(MovementBaseRootActor, true); - MoveComponentFlags |= MOVECOMP_CheckBlockingRootActorInIgnoreList; // Hit actors during MoveUpdatedComponent will have their root actor compared with the ignored actors array - } - // hack - transforms between local and world space introducing slight error FIXMESTEVE - discuss with engine team: just skip the transforms if no rotation? FVector BaseMoveDelta = NewBaseLocation - OldBaseLocation; if (!bRotationChanged && (BaseMoveDelta.X == 0.f) && (BaseMoveDelta.Y == 0.f)) @@ -2321,18 +2304,10 @@ void UVRCharacterMovementComponent::UpdateBasedMovement(float DeltaSeconds) FHitResult MoveOnBaseHit(1.f); const FVector OldLocation = UpdatedComponent->GetComponentLocation(); MoveUpdatedComponent(DeltaPosition, FinalQuat, true, &MoveOnBaseHit); - if ((UpdatedComponent->GetComponentLocation() - (OldLocation + DeltaPosition)).IsNearlyZero() == false) { OnUnableToFollowBaseMove(DeltaPosition, OldLocation, MoveOnBaseHit); } - - // Reset base actor ignore state - if (bIgnoreBaseActor) - { - MoveComponentFlags &= ~MOVECOMP_CheckBlockingRootActorInIgnoreList; - UpdatedPrimitive->IgnoreActorWhenMoving(MovementBaseRootActor, false); - } } if (MovementBase->IsSimulatingPhysics() && CharacterOwner->GetMesh()) @@ -2340,27 +2315,6 @@ void UVRCharacterMovementComponent::UpdateBasedMovement(float DeltaSeconds) CharacterOwner->GetMesh()->ApplyDeltaToAllPhysicsTransforms(DeltaPosition, DeltaQuat); } } - - - // Check if falling above current base - if (IsFalling() && bStayBasedInAir) - { - FVector PawnLocation = UpdatedComponent->GetComponentLocation(); - if (VRRootCapsule) - PawnLocation = VRRootCapsule->OffsetComponentToWorld.GetLocation(); - - FFindFloorResult OutFloorResult; - ComputeFloorDist(PawnLocation, StayBasedInAirHeight, StayBasedInAirHeight, OutFloorResult, CharacterOwner->GetCapsuleComponent()->GetScaledCapsuleRadius(), NULL); - - UPrimitiveComponent* HitComponent = OutFloorResult.HitResult.Component.Get(); - if (!HitComponent || HitComponent->GetAttachmentRoot() != MovementBase->GetAttachmentRoot()) - { - // New or no base under the character - ApplyImpartedMovementBaseVelocity(); - SetBase(NULL); - return; - } - } } FVector UVRCharacterMovementComponent::GetImpartedMovementBaseVelocity() const @@ -3165,9 +3119,6 @@ void UVRCharacterMovementComponent::PhysNavWalking(float deltaTime, int32 Iterat return; } - const EMovementMode StartingMovementMode = MovementMode; - const uint8 StartingCustomMovementMode = CustomMovementMode; - // Rewind the players position by the new capsule location RewindVRRelativeMovement(); @@ -3189,12 +3140,12 @@ void UVRCharacterMovementComponent::PhysNavWalking(float deltaTime, int32 Iterat ApplyRootMotionToVelocity(deltaTime); ApplyVRMotionToVelocity(deltaTime); - if (MovementMode != StartingMovementMode || CustomMovementMode != StartingCustomMovementMode) + /*if (IsFalling()) { - // Root motion could have taken us out of our current mode + // Root motion could have put us into Falling StartNewPhysics(deltaTime, Iterations); return; - } + }*/ Iterations++; @@ -4436,14 +4387,6 @@ void UVRCharacterMovementComponent::ServerMoveHandleClientErrorVR(float ClientTi bCanTrustClientOnLanding = false; } - // They have it private.... - // Check for lift-off, going from walking to falling. - // Note that if bStayBasedInAir is enabled we can't rely on the walking to falling transition, instead run logic on the first tick after clearing the MovementBase - //const bool bCanLiftOffFromBase = bStayBasedInAir - // ? !MovementBase && LastServerMovementBase.Get() // If we keep the base while in air, consider lift-off if base gets set to null and we had a base last tick - // : bLastServerIsWalking; // If walking last tick, we were can consider lift-off logic - //if (bServerIsFalling && bCanLiftOffFromBase && !bTeleportedSinceLastUpdate) - if (bServerIsFalling && bLastServerIsWalking && !bTeleportedSinceLastUpdate) { float ClientForwardFactor = 1.f; @@ -4743,9 +4686,6 @@ bool UVRCharacterMovementComponent::ClientUpdatePositionAfterServerUpdate() CharacterOwner->bClientUpdating = true; bForceNextFloorCheck = true; - // Scope these, they nest with Outer references so it should work fine, this keeps the update rotation and move autonomous from double updating the char - //const FScopedPreventAttachedComponentMove PreventMeshMove(BaseVRCharacterOwner ? BaseVRCharacterOwner->NetSmoother : nullptr); - // Store out our custom properties to restore after replaying const FVRMoveActionArray Orig_MoveActions = MoveActionArray; const FVector Orig_CustomInput = CustomVRInputVector; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRGestureComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRGestureComponent.cpp index 00be260..b04799e 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRGestureComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRGestureComponent.cpp @@ -2,8 +2,6 @@ #include UE_INLINE_GENERATED_CPP_BY_NAME(VRGestureComponent) #include "VRBaseCharacter.h" -#include "Engine/Engine.h" -#include "Engine/World.h" #include "Components/SplineMeshComponent.h" #include "Components/SplineComponent.h" #include "Components/LineBatchComponent.h" diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPathFollowingComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPathFollowingComponent.cpp index ffdc6df..25593ae 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPathFollowingComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPathFollowingComponent.cpp @@ -3,8 +3,6 @@ #include "VRPathFollowingComponent.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(VRPathFollowingComponent) -#include "CoreMinimal.h" -#include "Engine/World.h" //#include "Runtime/Engine/Private/EnginePrivate.h" //#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13 @@ -256,16 +254,8 @@ void UVRPathFollowingComponent::UpdatePathSegment() { const FVector AgentLocation = DestinationAgent ? DestinationAgent->GetNavAgentLocation() : DestinationActor->GetActorLocation(); // note that the condition below requires GoalLocation to be in world space. - FVector GoalLocation = FQuatRotationTranslationMatrix(DestinationActor->GetActorQuat(), AgentLocation).TransformPosition(MoveOffset); + const FVector GoalLocation = FQuatRotationTranslationMatrix(DestinationActor->GetActorQuat(), AgentLocation).TransformPosition(MoveOffset); - if (bMoveToGoalClampedToNavigation && NavigationFilter) - { - FVector HitLocation; - if (MyNavData->Raycast(CurrentLocation, GoalLocation, HitLocation, NavigationFilter)) - { - GoalLocation = HitLocation; - } - } CurrentDestination.Set(NULL, GoalLocation); //UE_VLOG(this, LogPathFollowing, Log, TEXT("Moving directly to move goal rather than following last path segment")); @@ -371,27 +361,6 @@ bool UVRPathFollowingComponent::HasReachedCurrentTarget(const FVector& CurrentLo return false; } - // If the next segment is a link with a custom reach condition, we need to call the HasReachedLinkStart on the link interface. - if (bMoveSegmentIsUsingCustomLinkReachCondition) - { - if (const INavLinkCustomInterface* MoveSegmentCustomLink = Cast(MoveSegmentCustomLinkOb.Get())) - { - if (ensureMsgf(Path.IsValid(), TEXT("%hs: Path should be valid when we get here. Owner [%s]."), __FUNCTION__, *GetNameSafe(GetOwner()))) - { - const FNavPathPoint& LinkStart = Path->GetPathPoints()[MoveSegmentEndIndex]; - if (Path->GetPathPoints().IsValidIndex(MoveSegmentEndIndex + 1)) - { - const FNavPathPoint& LinkEnd = Path->GetPathPoints()[MoveSegmentEndIndex + 1]; - return MoveSegmentCustomLink->HasReachedLinkStart(this, CurrentLocation, LinkStart, LinkEnd); - } - else - { - UE_LOG(LogPathFollowing, Error, TEXT("%hs: NavLink has a start, but no end. Custom reach condition won't be called. NavLinkID [%llu] - LinkStartPos [%s] - Owner [%s]"), __FUNCTION__, LinkStart.CustomNavLinkId.GetId(), *LinkStart.Location.ToString(), *GetNameSafe(GetOwner())); - } - } - } - } - const FVector CurrentTarget = GetCurrentTargetLocation(); const FVector CurrentDirection = GetCurrentDirection(); diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPlayerController.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPlayerController.cpp index 94614cb..39eebe0 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPlayerController.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRPlayerController.cpp @@ -27,6 +27,24 @@ void AVRPlayerController::SpawnPlayerCameraManager() PlayerCameraManager->bUseClientSideCameraUpdates = false; } +// #TODO 4.20: This was removed +/*void AVRPlayerController::InitNavigationControl(UPathFollowingComponent*& PathFollowingComp) +{ + PathFollowingComp = FindComponentByClass(); + if (PathFollowingComp == NULL) + { + PathFollowingComp = NewObject(this); + PathFollowingComp->RegisterComponentWithWorld(GetWorld()); + PathFollowingComp->Initialize(); + } +}*/ + +/*IPathFollowingAgentInterface* AVRPlayerController::GetPathFollowingAgent() const +{ + // Moved spawning the path following component into the path finding logic instead + return FNavigationSystem::FindPathFollowingAgentForActor(*this); +}*/ + void AVRPlayerController::PlayerTick(float DeltaTime) { diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRRootComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRRootComponent.cpp index 2da97a2..f50a237 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRRootComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRRootComponent.cpp @@ -6,8 +6,6 @@ //#include "Runtime/Engine/Private/EnginePrivate.h" //#include "WorldCollision.h" #include "PhysicsPublic.h" -#include "Engine/World.h" -#include "Engine/Engine.h" #include "Engine/ScopedMovementUpdate.h" #include "SceneManagement.h" #include "PrimitiveSceneProxy.h" @@ -15,9 +13,7 @@ #include "IHeadMountedDisplay.h" #include "IXRTrackingSystem.h" #include "VRCharacter.h" -#include "Engine/OverlapResult.h" #include "Algo/Copy.h" -#include "AI/Navigation/NavigationRelevantData.h" #include "Components/PrimitiveComponent.h" @@ -314,7 +310,6 @@ UVRRootComponent::UVRRootComponent(const FObjectInitializer& ObjectInitializer) SetCanEverAffectNavigation(false); bDynamicObstacle = true; - LineThickness = 1.25f; //bOffsetByHMD = false; } @@ -338,7 +333,6 @@ public: , bSimulating(false) //, OffsetComponentToWorld(InComponent->OffsetComponentToWorld) , LocalToWorld(InComponent->OffsetComponentToWorld.ToMatrixWithScale()) - , LineThickness(InComponent->GetLineThickness()) { bWillEverBeLit = false; } @@ -363,14 +357,14 @@ public: // If in editor views, lets offset the capsule upwards so that it views correctly if (bSimulating) { - DrawWireCapsule(PDI, LocalToWorld.GetOrigin() - FVector(0.f, 0.f, CapsuleHalfHeight), LocalToWorld.GetUnitAxis(EAxis::X), LocalToWorld.GetUnitAxis(EAxis::Y), LocalToWorld.GetUnitAxis(EAxis::Z), DrawCapsuleColor, CapsuleRadius, CapsuleHalfHeight, CapsuleSides, SDPG_World, LineThickness); + DrawWireCapsule(PDI, LocalToWorld.GetOrigin() - FVector(0.f, 0.f, CapsuleHalfHeight), LocalToWorld.GetUnitAxis(EAxis::X), LocalToWorld.GetUnitAxis(EAxis::Y), LocalToWorld.GetUnitAxis(EAxis::Z), DrawCapsuleColor, CapsuleRadius, CapsuleHalfHeight, CapsuleSides, SDPG_World); } else if (UseEditorCompositing(View)) { - DrawWireCapsule(PDI, LocalToWorld.GetOrigin() /*+ FVector(0.f, 0.f, CapsuleHalfHeight)*/, LocalToWorld.GetUnitAxis(EAxis::X), LocalToWorld.GetUnitAxis(EAxis::Y), LocalToWorld.GetUnitAxis(EAxis::Z), DrawCapsuleColor, CapsuleRadius, CapsuleHalfHeight, CapsuleSides, SDPG_World, LineThickness); + DrawWireCapsule(PDI, LocalToWorld.GetOrigin() /*+ FVector(0.f, 0.f, CapsuleHalfHeight)*/, LocalToWorld.GetUnitAxis(EAxis::X), LocalToWorld.GetUnitAxis(EAxis::Y), LocalToWorld.GetUnitAxis(EAxis::Z), DrawCapsuleColor, CapsuleRadius, CapsuleHalfHeight, CapsuleSides, SDPG_World, 1.25f); } else - DrawWireCapsule(PDI, LocalToWorld.GetOrigin(), LocalToWorld.GetUnitAxis(EAxis::X), LocalToWorld.GetUnitAxis(EAxis::Y), LocalToWorld.GetUnitAxis(EAxis::Z), DrawCapsuleColor, CapsuleRadius, CapsuleHalfHeight, CapsuleSides, SDPG_World, LineThickness); + DrawWireCapsule(PDI, LocalToWorld.GetOrigin(), LocalToWorld.GetUnitAxis(EAxis::X), LocalToWorld.GetUnitAxis(EAxis::Y), LocalToWorld.GetUnitAxis(EAxis::Z), DrawCapsuleColor, CapsuleRadius, CapsuleHalfHeight, CapsuleSides, SDPG_World, 1.25f); } } } @@ -411,7 +405,6 @@ private: bool bSimulating = false; //FTransform OffsetComponentToWorld; FMatrix LocalToWorld; - const float LineThickness; }; FPrimitiveSceneProxy* UVRRootComponent::CreateSceneProxy() @@ -554,10 +547,9 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, if (bRetainRoomscale) { // Pre-Process this for network sends - UE::Net::QuantizeVector(100, curCameraLoc); - //curCameraLoc.X = FMath::RoundToFloat(curCameraLoc.X * 100.f) / 100.f; - //curCameraLoc.Y = FMath::RoundToFloat(curCameraLoc.Y * 100.f) / 100.f; - //curCameraLoc.Z = FMath::RoundToFloat(curCameraLoc.Z * 100.f) / 100.f; + curCameraLoc.X = FMath::RoundToFloat(curCameraLoc.X * 100.f) / 100.f; + curCameraLoc.Y = FMath::RoundToFloat(curCameraLoc.Y * 100.f) / 100.f; + curCameraLoc.Z = FMath::RoundToFloat(curCameraLoc.Z * 100.f) / 100.f; } @@ -630,10 +622,9 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, lastCameraRot = curCameraRot; //DifferenceFromLastFrame = (NextTransform.GetLocation() - LastPosition);// .GetSafeNormal2D(); - UE::Net::QuantizeVector(100, DifferenceFromLastFrame); - //DifferenceFromLastFrame.X = FMath::RoundToFloat(DifferenceFromLastFrame.X * 100.f) / 100.f; - //DifferenceFromLastFrame.Y = FMath::RoundToFloat(DifferenceFromLastFrame.Y * 100.f) / 100.f; - //DifferenceFromLastFrame.Z = FMath::RoundToFloat(DifferenceFromLastFrame.Z * 100.f) / 100.f; + DifferenceFromLastFrame.X = FMath::RoundToFloat(DifferenceFromLastFrame.X * 100.f) / 100.f; + DifferenceFromLastFrame.Y = FMath::RoundToFloat(DifferenceFromLastFrame.Y * 100.f) / 100.f; + DifferenceFromLastFrame.Z = FMath::RoundToFloat(DifferenceFromLastFrame.Z * 100.f) / 100.f; //DifferenceFromLastFrame.Z = 0.0f; // Reset Z to zero, its not used anyway and this lets me reuse the Z component for capsule half height } else @@ -657,13 +648,9 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, { // I'm limiting it to a -100 - 100 unit range in case people somehow skip tracking so far that this multiplication // Would overflow the max/min values of a float. It shouldn't ever be harmful as that is a loooot of travel in one tick - DifferenceFromLastFrame.X = FMath::Clamp(DifferenceFromLastFrame.X, -100.0f, 100.0f); - DifferenceFromLastFrame.Y = FMath::Clamp(DifferenceFromLastFrame.Y, -100.0f, 100.0f); - DifferenceFromLastFrame.Z = FMath::Clamp(DifferenceFromLastFrame.Z, -100.0f, 100.0f); - UE::Net::QuantizeVector(10000, DifferenceFromLastFrame); - //DifferenceFromLastFrame.X = FMath::RoundToFloat(FMath::Clamp(DifferenceFromLastFrame.X, -100.0f, 100.0f) * 10000.f) / 10000.f; - //DifferenceFromLastFrame.Y = FMath::RoundToFloat(FMath::Clamp(DifferenceFromLastFrame.Y, -100.0f, 100.0f) * 10000.f) / 10000.f; - //DifferenceFromLastFrame.Z = FMath::RoundToFloat(FMath::Clamp(DifferenceFromLastFrame.Z, -100.0f, 100.0f) * 10000.f) / 10000.f; + DifferenceFromLastFrame.X = FMath::RoundToFloat(FMath::Clamp(DifferenceFromLastFrame.X, -100.0f, 100.0f) * 10000.f) / 10000.f; + DifferenceFromLastFrame.Y = FMath::RoundToFloat(FMath::Clamp(DifferenceFromLastFrame.Y, -100.0f, 100.0f) * 10000.f) / 10000.f; + DifferenceFromLastFrame.Z = FMath::RoundToFloat(FMath::Clamp(DifferenceFromLastFrame.Z, -100.0f, 100.0f) * 10000.f) / 10000.f; //DifferenceFromLastFrame.Z = 0.0f; // Reset Z to zero, its not used anyway and this lets me reuse the Z component for capsule half height } } @@ -1073,7 +1060,7 @@ bool UVRRootComponent::MoveComponentImpl(const FVector& Delta, const FQuat& NewR if (TestHit.bBlockingHit) { - if (!ShouldIgnoreHitResult(MyWorld, bAllowSimulatingCollision, TestHit, Delta, Actor, MoveFlags) && !ShouldComponentIgnoreHitResult(TestHit, MoveFlags)) + if (!ShouldIgnoreHitResult(MyWorld, bAllowSimulatingCollision, TestHit, Delta, Actor, MoveFlags)) { if (TestHit.bStartPenetrating) { @@ -1149,7 +1136,8 @@ bool UVRRootComponent::MoveComponentImpl(const FVector& Delta, const FQuat& NewR // Remove any pending overlaps after this point, we are not going as far as we swept. if (FirstNonInitialOverlapIdx != INDEX_NONE) { - PendingOverlaps.SetNum(FirstNonInitialOverlapIdx, EAllowShrinking::No); + const bool bAllowShrinking = false; + PendingOverlaps.SetNum(FirstNonInitialOverlapIdx, bAllowShrinking); } } } @@ -1388,13 +1376,14 @@ bool UVRRootComponent::UpdateOverlapsImpl(const TOverlapArrayView* NewPendingOve for (int32 CompIdx = 0; CompIdx < OldOverlappingComponentPtrs.Num() && NewOverlappingComponentPtrs.Num() > 0; ++CompIdx) { // RemoveAtSwap is ok, since it is not necessary to maintain order + const bool bAllowShrinking = false; const FOverlapInfo* SearchItem = OldOverlappingComponentPtrs[CompIdx]; const int32 NewElementIdx = IndexOfOverlapFast(NewOverlappingComponentPtrs, SearchItem); if (NewElementIdx != INDEX_NONE) { - NewOverlappingComponentPtrs.RemoveAtSwap(NewElementIdx, 1, EAllowShrinking::No); - OldOverlappingComponentPtrs.RemoveAtSwap(CompIdx, 1, EAllowShrinking::No); + NewOverlappingComponentPtrs.RemoveAtSwap(NewElementIdx, 1, bAllowShrinking); + OldOverlappingComponentPtrs.RemoveAtSwap(CompIdx, 1, bAllowShrinking); --CompIdx; } } @@ -1424,7 +1413,7 @@ bool UVRRootComponent::UpdateOverlapsImpl(const TOverlapArrayView* NewPendingOve const int32 StaleElementIndex = IndexOfOverlapFast(OverlappingComponents, OtherOverlap); if (StaleElementIndex != INDEX_NONE) { - OverlappingComponents.RemoveAtSwap(StaleElementIndex, 1, bAllowShrinking ? EAllowShrinking::Yes : EAllowShrinking::No); + OverlappingComponents.RemoveAtSwap(StaleElementIndex, 1, bAllowShrinking); } } } @@ -1526,7 +1515,7 @@ bool UVRRootComponent::IsLocallyControlled() const { if (GetNetMode() < ENetMode::NM_Client) { - if (owningVRChar->GetVRReplicateCapsuleHeight()) + if (owningVRChar->VRReplicateCapsuleHeight) { owningVRChar->ReplicatedCapsuleHeight.CapsuleHeight = CapsuleHalfHeight; } @@ -1660,7 +1649,7 @@ bool UVRRootComponent::ConvertSweptOverlapsToCurrentOverlapsVR( // Not handled yet. We could do it by checking every body explicitly and track each body index in the overlap test, but this seems like a rare need. return false; } - else if (Cast(OtherPrimitive) /* || Cast(this)*/) + else if (Cast(OtherPrimitive) || Cast(this)) { // SkeletalMeshComponent does not support this operation, and would return false in the test when an actual query could return true. return false; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRStereoWidgetComponent.cpp b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRStereoWidgetComponent.cpp index 6f03c91..874702a 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRStereoWidgetComponent.cpp +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Private/VRStereoWidgetComponent.cpp @@ -17,7 +17,6 @@ #include "IStereoLayers.h" #include "IHeadMountedDisplay.h" #include "PrimitiveViewRelevance.h" -#include "StereoLayerAdditionalFlagsManager.h" #include "PrimitiveSceneProxy.h" #include "UObject/ConstructorHelpers.h" #include "EngineGlobals.h" @@ -385,9 +384,9 @@ UVRStereoWidgetComponent::UVRStereoWidgetComponent(const FObjectInitializer& Obj //, StereoLayerType(SLT_TrackerLocked) //, StereoLayerShape(SLSH_QuadLayer) , Priority(0) - , LayerId(IStereoLayers::FLayerDesc::INVALID_LAYER_ID) , bIsDirty(true) , bTextureNeedsUpdate(false) + , LayerId(IStereoLayers::FLayerDesc::INVALID_LAYER_ID) , LastTransform(FTransform::Identity) , bLastVisible(false) { @@ -412,16 +411,6 @@ UVRStereoWidgetComponent::~UVRStereoWidgetComponent() { } - -void UVRStereoWidgetComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) -{ - if (EndPlayReason == EEndPlayReason::EndPlayInEditor || EndPlayReason == EEndPlayReason::Quit) - { - //FStereoLayerAdditionalFlagsManager::Destroy(); - } -} - - void UVRStereoWidgetComponent::BeginDestroy() { IStereoLayers* StereoLayers; @@ -726,13 +715,6 @@ void UVRStereoWidgetComponent::TickComponent(float DeltaTime, enum ELevelTick Ti LayerDsec.Flags |= (bSupportsDepth) ? IStereoLayers::LAYER_FLAG_SUPPORT_DEPTH : 0; LayerDsec.Flags |= (!bCurrVisible) ? IStereoLayers::LAYER_FLAG_HIDDEN : 0; - // Would love to implement but they aren't exporting the symbols - /*TSharedPtr FlagsManager = FStereoLayerAdditionalFlagsManager::Get(); - for (FName& Flag : AdditionalFlags) - { - LayerDsec.Flags |= FlagsManager->GetFlagValue(Flag); - }*/ - // Fix this later when WorldLocked is no longer wrong. switch (Space) { @@ -1111,7 +1093,7 @@ public: bShadowMapped = false; } - virtual void OnTransformChanged(FRHICommandListBase& RHICmdList) override + virtual void OnTransformChanged() override { Origin = GetLocalToWorld().GetOrigin(); } diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripMotionControllerComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripMotionControllerComponent.h index 3fec2f2..a6fb882 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripMotionControllerComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripMotionControllerComponent.h @@ -316,10 +316,6 @@ public: ~UGripMotionControllerComponent(); - // TMP until physics velocity bug is fixed #TODO: Remove - void CalculateGripVelocity(FBPActorGripInformation &GripToFill, UPrimitiveComponent* ComponentToSample, float DeltaTime); - - // Custom version of the component sweep function to remove that aggravating warning epic is throwing about skeletal mesh components. void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void InitializeComponent() override; @@ -498,17 +494,10 @@ public: UPROPERTY(BlueprintReadOnly, Replicated, Category = "GripMotionController", ReplicatedUsing = OnRep_GrippedObjects) TArray GrippedObjects; - // If modifying members in gripped objects directly or a specific grip you need to call this function if you are using Push Networking - void DIRTY_GRIPPED_OBJECTS(); - // When possible I suggest that you use GetAllGrips/GetGrippedObjects instead of directly referencing this UPROPERTY(BlueprintReadOnly, Replicated, Category = "GripMotionController", ReplicatedUsing = OnRep_LocallyGrippedObjects) TArray LocallyGrippedObjects; - // If modifying members in locally gripped objects directly or a specific grip you need to call this function if you are using Push Networking - void DIRTY_LOCALLY_GRIPPED_OBJECTS(); - - // Local Grip TransactionalBuffer to store server sided grips that need to be emplaced into the local buffer UPROPERTY(BlueprintReadOnly, Replicated, Category = "GripMotionController", ReplicatedUsing = OnRep_LocalTransaction) TArray LocalTransactionBuffer; @@ -777,8 +766,37 @@ public: return true; } - // Check the local transaction buffer - void CheckTransactionBuffer(); + inline void CheckTransactionBuffer() + { + if (LocalTransactionBuffer.Num()) + { + for (int i = LocalTransactionBuffer.Num() - 1; i >= 0; --i) + { + if (LocalTransactionBuffer[i].ValueCache.bWasInitiallyRepped && LocalTransactionBuffer[i].GripID != LocalTransactionBuffer[i].ValueCache.CachedGripID) + { + // There appears to be a bug with TArray replication where if you replace an index with another value of that + // Index, it doesn't fully re-init the object, this is a workaround to re-zero non replicated variables + // when that happens. + LocalTransactionBuffer[i].ClearNonReppingItems(); + } + + if (!LocalTransactionBuffer[i].ValueCache.bWasInitiallyRepped && LocalTransactionBuffer[i].GrippedObject->IsValidLowLevelFast()) + { + LocalTransactionBuffer[i].ValueCache.bWasInitiallyRepped = true; + LocalTransactionBuffer[i].ValueCache.CachedGripID = LocalTransactionBuffer[i].GripID; + + int32 Index = LocallyGrippedObjects.Add(LocalTransactionBuffer[i]); + + if (Index != INDEX_NONE) + { + NotifyGrip(LocallyGrippedObjects[Index]); + } + + Server_NotifyHandledTransaction(LocalTransactionBuffer[i].GripID); + } + } + } + } UFUNCTION() virtual void OnRep_LocalTransaction(TArray OriginalArrayState) // Original array state is useless without full serialize, it just hold last delta @@ -830,29 +848,18 @@ public: // Run the smoothing step void RunNetworkedSmoothing(float DeltaTime); -protected: - // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every tick). // On dedicated servers the update rate should be at or lower than the server tick rate for smoothing to work UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "GripMotionController|Networking", meta = (ClampMin = "0", UIMin = "0")) float ControllerNetUpdateRate; - -public: - void SetControllerNetUpdateRate(float NewControllerNetUpdateRate); - inline float GetControllerNetUpdateRate() { return ControllerNetUpdateRate; }; // Used in Tick() to accumulate before sending updates, didn't want to use a timer in this case, also used for remotes to lerp position float ControllerNetUpdateCount; - protected: // Whether to smooth (lerp) between ticks for the replicated motion, DOES NOTHING if update rate is larger than FPS! UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "GripMotionController|Networking") bool bSmoothReplicatedMotion; - public: - void SetSmoothReplicatedMotion(bool NewSmoothReplicatedMotion); - inline bool GetSmoothReplicatedMotion() { return bSmoothReplicatedMotion; }; - // If true then we will use exponential smoothing with buffered correction UPROPERTY(EditAnywhere, Category = "GripMotionController|Networking|Smoothing", meta = (editcondition = "bSmoothReplicatedMotion")) bool bUseExponentialSmoothing = true; @@ -869,16 +876,10 @@ public: UPROPERTY(EditAnywhere, Category = "GripMotionController|Networking|Smoothing", meta = (editcondition = "bUseExponentialSmoothing")) float NetworkNoSmoothUpdateDistance = 100.f; - protected: - // Whether to replicate even if no tracking (FPS or test characters) UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "GripMotionController|Networking") bool bReplicateWithoutTracking; - public: - void SetReplicateWithoutTracking(bool NewReplicateWithoutTracking); - inline bool GetReplicateWithoutTracking() { return bReplicateWithoutTracking; }; - // I'm sending it unreliable because it is being resent pretty often UFUNCTION(Unreliable, Server, WithValidation) void Server_SendControllerTransform(FBPVRComponentPosRep NewTransform); diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripScripts/GS_Melee.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripScripts/GS_Melee.h index 8691b53..151e1fe 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripScripts/GS_Melee.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/GripScripts/GS_Melee.h @@ -181,8 +181,11 @@ public: virtual void OnLodgeHitCallback(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit); UFUNCTION(BlueprintCallable, Category = "Weapon Settings") - void SetIsLodged(bool IsLodged, UPrimitiveComponent* LodgeComponent); - + void SetIsLodged(bool IsLodged, UPrimitiveComponent * LodgeComponent) + { + bIsLodged = IsLodged; + LodgedComponent = LodgeComponent; + } bool bIsLodged; TWeakObjectPtr LodgedComponent; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableActor.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableActor.h index 75df06f..f293628 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableActor.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableActor.h @@ -38,22 +38,14 @@ public: virtual void GatherCurrentMovement() override; -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; // If true then the grip script array will be considered for replication, if false then it will not // This is an optimization for when you have a lot of grip scripts in use, you can toggle this off in cases // where the object will never have a replicating script - UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") + UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override; virtual void GetSubobjectsWithStableNamesForNetworking(TArray& ObjList) override; @@ -86,16 +78,8 @@ public: // Client Auth Throwing Data and functions // ------------------------------------------------ -protected: - // Replication settings for client auth throwing - // Must call MarkClientAuthReplicationDirty if setting the properties of it live UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Replication") FVRClientAuthReplicationData ClientAuthReplicationData; -public: - - // If changing this in c++ it is using a getter to make sure it is dirtied - FVRClientAuthReplicationData& GetClientAuthReplicationData(FVRClientAuthReplicationData& ClientAuthData); - // Add this to client side physics replication (until coming to rest or timeout period is hit) UFUNCTION(BlueprintCallable, Category = "Networking") @@ -138,28 +122,17 @@ public: TagContainer = GameplayTags; } - protected: - /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") - FGameplayTagContainer GameplayTags; - - public: - FGameplayTagContainer& GetGameplayTags(); + FGameplayTagContainer GameplayTags; // End Gameplay Tag Interface virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; - protected: - // Skips the attachment replication if we are locally owned and our grip settings say that we are a client authed grip. UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Replication") bool bAllowIgnoringAttachOnOwner; - public: - - void SetAllowIgnoringAttachOnOwner(bool bNewAllowIgnoringAttachOnOwner); - inline bool GetAllowIgnoringAttachOnOwner() { return bAllowIgnoringAttachOnOwner; }; // Should we skip attachment replication (vr settings say we are a client auth grip and our owner is locally controlled) /*inline*/ bool ShouldWeSkipAttachmentReplication(bool bConsiderHeld = true) const; @@ -188,21 +161,11 @@ public: // On Destroy clean up our objects virtual void BeginDestroy() override; - protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bRepGripSettingsAndGameplayTags; - public: - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; - public: - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableBoxComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableBoxComponent.h index 1b7b3b6..f1a94e5 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableBoxComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableBoxComponent.h @@ -31,7 +31,6 @@ public: virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; @@ -40,13 +39,6 @@ protected: // where the object will never have a replicating script UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override; @@ -84,14 +76,10 @@ public: TagContainer = GameplayTags; } -protected: /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; -public: - FGameplayTagContainer& GetGameplayTags(); - // End Gameplay Tag Interface virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; @@ -106,7 +94,6 @@ public: // This one is for components to clean up virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override; -protected: // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bRepGripSettingsAndGameplayTags; @@ -119,16 +106,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; -public: - - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); - - void SetReplicateMovement(bool bNewReplicateMovement); - inline bool GetReplicateMovement() { return bReplicateMovement; }; // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableCapsuleComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableCapsuleComponent.h index b6b9969..573e324 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableCapsuleComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableCapsuleComponent.h @@ -31,7 +31,6 @@ public: virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; @@ -41,14 +40,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); - bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override; // Sets the Deny Gripping variable on the FBPInterfaceSettings struct @@ -84,12 +75,9 @@ public: TagContainer = GameplayTags; } -protected: /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; -public: - FGameplayTagContainer& GetGameplayTags(); // End Gameplay Tag Interface @@ -104,8 +92,6 @@ public: // This one is for components to clean up virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override; -protected: - // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bRepGripSettingsAndGameplayTags; @@ -119,17 +105,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; -public: - - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); - - void SetReplicateMovement(bool bNewReplicateMovement); - inline bool GetReplicateMovement() { return bReplicateMovement; }; - // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity virtual bool DenyGripping_Implementation(UGripMotionControllerComponent * GripInitiator = nullptr) override; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippablePhysicsReplication.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippablePhysicsReplication.h index cfb8db2..ba33b19 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippablePhysicsReplication.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippablePhysicsReplication.h @@ -10,9 +10,9 @@ #include "PhysicsReplicationInterface.h" #include "Physics/PhysicsInterfaceDeclares.h" #include "PhysicsProxy/SingleParticlePhysicsProxyFwd.h" +#include "Chaos/Particles.h" #include "Chaos/PhysicsObject.h" #include "Chaos/SimCallbackObject.h" -#include "Physics/NetworkPhysicsSettingsComponent.h" #include "GrippablePhysicsReplication.generated.h" @@ -33,18 +33,13 @@ //struct FAsyncPhysicsRepCallbackDataVR; //class FPhysicsReplicationAsyncCallbackVR; -#pragma region FPhysicsReplicationAsync - class FPhysicsReplicationAsyncVR : public Chaos::TSimCallbackObject< FPhysicsReplicationAsyncInput, Chaos::FSimCallbackNoOutput, - Chaos::ESimCallbackOptions::Presimulate | Chaos::ESimCallbackOptions::PhysicsObjectUnregister> + Chaos::ESimCallbackOptions::Presimulate> { virtual FName GetFNameForStatId() const override; - virtual void OnPostInitialize_Internal() override; virtual void OnPreSimulate_Internal() override; - virtual void OnPhysicsObjectUnregistered_Internal(Chaos::FConstPhysicsObjectHandle PhysicsObject) override; - virtual void ApplyTargetStatesAsync(const float DeltaSeconds, const FPhysicsRepErrorCorrectionData& ErrorCorrection, const TArray& TargetStates); // Replication functions @@ -53,25 +48,14 @@ class FPhysicsReplicationAsyncVR : public Chaos::TSimCallbackObject< virtual bool PredictiveInterpolation(Chaos::FPBDRigidParticleHandle* Handle, FReplicatedPhysicsTargetAsync& Target, const float DeltaSeconds); virtual bool ResimulationReplication(Chaos::FPBDRigidParticleHandle* Handle, FReplicatedPhysicsTargetAsync& Target, const float DeltaSeconds); -public: - virtual void RegisterSettings(Chaos::FConstPhysicsObjectHandle PhysicsObject, FNetworkPhysicsSettingsAsync InSettings); - private: float LatencyOneWay; FRigidBodyErrorCorrection ErrorCorrectionDefault; - FNetworkPhysicsSettingsAsync SettingsCurrent; - FNetworkPhysicsSettingsAsync SettingsDefault; - TMap ObjectToTarget; - TMap ObjectToSettings; - TArray ParticlesInResimIslands; + TMap ObjectToTarget; private: - void UpdateAsyncTarget(const FPhysicsRepAsyncInputData& Input, Chaos::FPBDRigidsSolver* RigidsSolver); + void UpdateAsyncTarget(const FPhysicsRepAsyncInputData& Input); void UpdateRewindDataTarget(const FPhysicsRepAsyncInputData& Input); - void CacheResimInteractions(); - // Sets SettingsCurrent to either the objects custom settings or to the default settings - void FetchObjectSettings(Chaos::FConstPhysicsObjectHandle PhysicsObject); - static void ExtrapolateTarget(FReplicatedPhysicsTargetAsync& Target, const int32 ExtrapolateFrames, const float DeltaSeconds); public: void Setup(FRigidBodyErrorCorrection ErrorCorrection) @@ -80,7 +64,7 @@ public: } }; -#pragma endregion // FPhysicsReplicationAsync + class FPhysicsReplicationVR : public FPhysicsReplication { @@ -97,11 +81,9 @@ public: virtual bool ApplyRigidBodyState(float DeltaSeconds, FBodyInstance* BI, FReplicatedPhysicsTarget& PhysicsTarget, const FRigidBodyErrorCorrection& ErrorCorrection, const float PingSecondsOneWay, int32 LocalFrame, int32 NumPredictedFrames) override; virtual bool ApplyRigidBodyState(float DeltaSeconds, FBodyInstance* BI, FReplicatedPhysicsTarget& PhysicsTarget, const FRigidBodyErrorCorrection& ErrorCorrection, const float PingSecondsOneWay, bool* bDidHardSnap = nullptr) override; - void SetReplicatedTargetVR(Chaos::FConstPhysicsObjectHandle PhysicsObject, const FRigidBodyState& ReplicatedTarget, int32 ServerFrame, EPhysicsReplicationMode ReplicationMode = EPhysicsReplicationMode::Default); - + virtual void SetReplicatedTarget(UPrimitiveComponent* Component, FName BoneName, const FRigidBodyState& ReplicatedTarget, int32 ServerFrame) override; + void SetReplicatedTargetVR(Chaos::FPhysicsObject* PhysicsObject, const FRigidBodyState& ReplicatedTarget, int32 ServerFrame, EPhysicsReplicationMode ReplicationMode); - virtual void RemoveReplicatedTarget(UPrimitiveComponent* Component) override; - TArray ReplicatedTargetsQueueVR; FPhysicsReplicationAsyncVR* PhysicsReplicationAsyncVR; FPhysicsReplicationAsyncInput* AsyncInputVR; //async data being written into before we push into callback @@ -109,7 +91,6 @@ public: void PrepareAsyncData_ExternalVR(const FRigidBodyErrorCorrection& ErrorCorrection); //prepare async data for writing. Call on external thread (i.e. game thread) }; - class IPhysicsReplicationFactoryVR : public IPhysicsReplicationFactory { public: diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshActor.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshActor.h index 85e87a6..3b0063a 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshActor.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshActor.h @@ -30,13 +30,11 @@ class VREXPANSIONPLUGIN_API UOptionalRepSkeletalMeshComponent : public USkeletal public: UOptionalRepSkeletalMeshComponent(const FObjectInitializer& ObjectInitializer); -protected: +public: + // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Component Replication") bool bReplicateMovement; -public: - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override; @@ -66,7 +64,6 @@ public: virtual void GatherCurrentMovement() override; -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; @@ -75,13 +72,6 @@ protected: // where the object will never have a replicating script UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch* Bunch, FReplicationFlags* RepFlags) override; virtual void GetSubobjectsWithStableNamesForNetworking(TArray& ObjList) override; @@ -114,12 +104,8 @@ public: // Client Auth Throwing Data and functions // ------------------------------------------------ -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Replication") FVRClientAuthReplicationData ClientAuthReplicationData; -public: - // If changing this in c++ it is using a getter to make sure it is dirtied - FVRClientAuthReplicationData& GetClientAuthReplicationData(FVRClientAuthReplicationData& ClientAuthData); // Add this to client side physics replication (until coming to rest or timeout period is hit) UFUNCTION(BlueprintCallable, Category = "Networking") @@ -162,29 +148,18 @@ public: TagContainer = GameplayTags; } -protected: - /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") - FGameplayTagContainer GameplayTags; - -public: - FGameplayTagContainer& GetGameplayTags(); + FGameplayTagContainer GameplayTags; // End Gameplay Tag Interface virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override; -protected: // Skips the attachment replication if we are locally owned and our grip settings say that we are a client authed grip. UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Replication") bool bAllowIgnoringAttachOnOwner; -public: - - void SetAllowIgnoringAttachOnOwner(bool bNewAllowIgnoringAttachOnOwner); - inline bool GetAllowIgnoringAttachOnOwner() { return bAllowIgnoringAttachOnOwner; }; - // Should we skip attachment replication (vr settings say we are a client auth grip and our owner is locally controlled) /*inline*/ bool ShouldWeSkipAttachmentReplication(bool bConsiderHeld = true) const; @@ -212,22 +187,12 @@ public: // On Destroy clean up our objects virtual void BeginDestroy() override; -protected: - UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bRepGripSettingsAndGameplayTags; UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; -public: - - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); - // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity virtual bool DenyGripping_Implementation(UGripMotionControllerComponent * GripInitiator = nullptr) override; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshComponent.h index 2aec546..19e861d 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSkeletalMeshComponent.h @@ -35,7 +35,6 @@ public: virtual void GetWeldedBodies(TArray& OutWeldedBodies, TArray& OutLabels, bool bIncludingAutoWeld) override; virtual FBodyInstance* GetBodyInstance(FName BoneName = NAME_None, bool bGetWelded = true, int32 Index = INDEX_NONE) const override; -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; @@ -44,12 +43,6 @@ protected: // where the object will never have a replicating script UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override; @@ -88,15 +81,10 @@ public: TagContainer = GameplayTags; } -protected: - /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; -public: - FGameplayTagContainer& GetGameplayTags(); - // End Gameplay Tag Interface virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; @@ -110,7 +98,6 @@ public: // This one is for components to clean up virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override; -protected: // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bRepGripSettingsAndGameplayTags; @@ -123,16 +110,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; -public: - - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); - - void SetReplicateMovement(bool bNewReplicateMovement); - inline bool GetReplicateMovement() { return bReplicateMovement; }; // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSphereComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSphereComponent.h index ec5058b..81fd861 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSphereComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableSphereComponent.h @@ -31,7 +31,6 @@ public: virtual void BeginPlay() override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; @@ -40,13 +39,6 @@ protected: // where the object will never have a replicating script UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override; @@ -85,12 +77,9 @@ public: TagContainer = GameplayTags; } -protected: /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; -public: - FGameplayTagContainer& GetGameplayTags(); // End Gameplay Tag Interface @@ -105,7 +94,6 @@ public: // This one is for components to clean up virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override; -protected: // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bRepGripSettingsAndGameplayTags; @@ -118,16 +106,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; -public: - - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); - - void SetReplicateMovement(bool bNewReplicateMovement); - inline bool GetReplicateMovement() { return bReplicateMovement; }; // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshActor.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshActor.h index 986c521..4a14b3f 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshActor.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshActor.h @@ -60,8 +60,6 @@ public: virtual void GatherCurrentMovement() override; -protected: - UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; @@ -71,14 +69,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); - bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override; virtual void GetSubobjectsWithStableNamesForNetworking(TArray& ObjList) override; @@ -111,15 +101,9 @@ public: // Client Auth Throwing Data and functions // ------------------------------------------------ -protected: - UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Replication") FVRClientAuthReplicationData ClientAuthReplicationData; -public: - // If changing this in c++ it is using a getter to make sure it is dirtied - FVRClientAuthReplicationData& GetClientAuthReplicationData(FVRClientAuthReplicationData& ClientAuthData); - // Add this to client side physics replication (until coming to rest or timeout period is hit) UFUNCTION(BlueprintCallable, Category = "Networking") bool AddToClientReplicationBucket(); @@ -163,27 +147,18 @@ public: TagContainer = GameplayTags; } -protected: - /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; -public: - FGameplayTagContainer& GetGameplayTags(); // End Gameplay Tag Interface virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; -protected: // Skips the attachment replication if we are locally owned and our grip settings say that we are a client authed grip. UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Replication") bool bAllowIgnoringAttachOnOwner; -public: - void SetAllowIgnoringAttachOnOwner(bool bNewAllowIgnoringAttachOnOwner); - inline bool GetAllowIgnoringAttachOnOwner() { return bAllowIgnoringAttachOnOwner; }; - // Should we skip attachment replication (vr settings say we are a client auth grip and our owner is locally controlled) /*inline*/ bool ShouldWeSkipAttachmentReplication(bool bConsiderHeld = true) const; @@ -211,22 +186,12 @@ public: // On Destroy clean up our objects virtual void BeginDestroy() override; -protected: - UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bRepGripSettingsAndGameplayTags; UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; -public: - - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); - // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity virtual bool DenyGripping_Implementation(UGripMotionControllerComponent * GripInitiator = nullptr) override; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshComponent.h index 900433e..a16ea6d 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshComponent.h @@ -35,8 +35,6 @@ public: // Gameplay tag interface // ------------------------------------------------ -protected: - /** Overridden to return requirements tags */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface") TArray> GripLogicScripts; @@ -47,13 +45,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bReplicateGripScripts; -public: - void SetReplicateGripScripts(bool NewReplicateGripScripts); - inline bool GetReplicateGripScripts() { return bReplicateGripScripts; }; - - // Get the grip script array, will automatically dirty it if they are replicated as it is assumed if you are directly accessing it you are altering it - TArray>& GetGripLogicScripts(); - bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override; // Sets the Deny Gripping variable on the FBPInterfaceSettings struct @@ -85,15 +76,10 @@ public: TagContainer = GameplayTags; } -protected: - /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; -public: - FGameplayTagContainer& GetGameplayTags(); - // End Gameplay Tag Interface virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; @@ -107,7 +93,6 @@ public: // This one is for components to clean up virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override; -protected: // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bRepGripSettingsAndGameplayTags; @@ -121,16 +106,6 @@ protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") FBPInterfaceProperties VRGripInterfaceSettings; -public: - void SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags); - inline bool GetRepGripSettingsAndGameplayTags() { return bRepGripSettingsAndGameplayTags; }; - - // Get VRGripInterfaceSettings, set MarkDirty if you intend to (or may) modify the values inside of it - FBPInterfaceProperties& GetVRGripInterfaceSettings(bool bMarkDirty); - - void SetReplicateMovement(bool bNewReplicateMovement); - inline bool GetReplicateMovement() { return bReplicateMovement; }; - // Set up as deny instead of allow so that default allows for gripping // The GripInitiator is not guaranteed to be valid, check it for validity virtual bool DenyGripping_Implementation(UGripMotionControllerComponent * GripInitiator = nullptr) override; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/HandSocketComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/HandSocketComponent.h index 6073e9c..e539d08 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/HandSocketComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/HandSocketComponent.h @@ -7,9 +7,7 @@ #include "GameplayTagAssetInterface.h" #include "Components/SceneComponent.h" #include "Animation/AnimInstance.h" -#include "Animation/BoneReference.h" #include "Misc/Guid.h" - #include "HandSocketComponent.generated.h" class USkeletalMeshComponent; @@ -411,8 +409,6 @@ public: TagContainer = GameplayTags; } - protected: - /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; @@ -427,14 +423,6 @@ public: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bReplicateMovement; - public: - FGameplayTagContainer& GetGameplayTags(); - - void SetRepGameplayTags(bool NewRepGameplayTags); - inline bool GetRepGameplayTags() { return bRepGameplayTags; }; - void SetReplicateMovement(bool NewReplicateMovement); - inline bool GetReplicateMovement() { return bReplicateMovement; }; - /** mesh component to indicate hand placement */ #if WITH_EDITORONLY_DATA @@ -480,5 +468,10 @@ public: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, transient, Category = "Socket Data") TObjectPtr OwningSocket; - virtual void NativeInitializeAnimation() override; + virtual void NativeInitializeAnimation() override + { + Super::NativeInitializeAnimation(); + + OwningSocket = Cast(GetOwningComponent()->GetAttachParent()); + } }; \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRButtonComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRButtonComponent.h index e462761..5b06704 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRButtonComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRButtonComponent.h @@ -111,7 +111,6 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRButtonComponent") bool bIsEnabled; -protected: // Current state of the button, writable to set initial value UPROPERTY(EditAnywhere,BlueprintReadWrite, Replicated, Category = "VRButtonComponent") bool bButtonState; @@ -119,11 +118,6 @@ protected: // Who is allowed to change the button state UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "VRButtonComponent|Replication") EVRStateChangeAuthorityType StateChangeAuthorityType; -public: - bool GetButtonState() { return bButtonState; } - void SetButtonState(bool bNewButtonState); - EVRStateChangeAuthorityType GetStateChangeAuthorityType() { return StateChangeAuthorityType; } - void SetStateChangeAuthorityType(EVRStateChangeAuthorityType NewStateChangeAuthorityType); // Speed that the button de-presses when no longer interacted with UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRButtonComponent") @@ -161,26 +155,18 @@ public: virtual FVector GetTargetRelativeLocation(); - protected: // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bReplicateMovement; - public: - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; // Resetting the initial transform here so that it comes in prior to BeginPlay and save loading. virtual void OnRegister() override; - protected: // Now replicating this so that it works correctly over the network UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_InitialRelativeTransform, Category = "VRButtonComponent") FTransform_NetQuantize InitialRelativeTransform; - public: - // Gets the initial relative transform, if you want to set it you should be using ResetInitialButtonLocation - FTransform GetInitialRelativeTransform() { return InitialRelativeTransform; } UFUNCTION() virtual void OnRep_InitialRelativeTransform() diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRDialComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRDialComponent.h index a5e4d7f..8c510bb 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRDialComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRDialComponent.h @@ -120,13 +120,9 @@ public: // Resetting the initial transform here so that it comes in prior to BeginPlay and save loading. virtual void OnRegister() override; -protected: // Now replicating this so that it works correctly over the network UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_InitialRelativeTransform, Category = "VRDialComponent") - FTransform_NetQuantize InitialRelativeTransform; -public: - // Gets the initial relative transform, if you want to set it you should be using ResetInitialButtonLocation - FTransform GetInitialRelativeTransform() { return InitialRelativeTransform; } + FTransform_NetQuantize InitialRelativeTransform; UFUNCTION() virtual void OnRep_InitialRelativeTransform() @@ -165,12 +161,15 @@ public: TagContainer = GameplayTags; } -protected: /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; + // End Gameplay Tag Interface + virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; + + // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bRepGameplayTags; @@ -178,14 +177,7 @@ protected: // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bReplicateMovement; -public: - FGameplayTagContainer& GetGameplayTags(); - bool GetRepGameplayTags() { return bRepGameplayTags; } - void SetRepGameplayTags(bool bNewRepGameplayTags); - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); - virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void BeginPlay() override; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRLeverComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRLeverComponent.h index 991dd6e..54e457b 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRLeverComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRLeverComponent.h @@ -193,13 +193,9 @@ public: // Resetting the initial transform here so that it comes in prior to BeginPlay and save loading. virtual void OnRegister() override; -protected: // Now replicating this so that it works correctly over the network UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_InitialRelativeTransform, Category = "VRLeverComponent") FTransform_NetQuantize InitialRelativeTransform; -public: - // Gets the initial relative transform, if you want to set it you should be using ResetInitialButtonLocation - FTransform GetInitialRelativeTransform() { return InitialRelativeTransform; } UFUNCTION() virtual void OnRep_InitialRelativeTransform() @@ -238,12 +234,15 @@ public: TagContainer = GameplayTags; } -protected: /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; + // End Gameplay Tag Interface + virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; + + // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bRepGameplayTags; @@ -251,14 +250,7 @@ protected: // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bReplicateMovement; -public: - FGameplayTagContainer& GetGameplayTags(); - bool GetRepGameplayTags() { return bRepGameplayTags; } - void SetRepGameplayTags(bool bNewRepGameplayTags); - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); - virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void BeginPlay() override; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRMountComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRMountComponent.h index 97d2a78..5655040 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRMountComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRMountComponent.h @@ -94,12 +94,15 @@ public: TagContainer = GameplayTags; } -protected: /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; + // End Gameplay Tag Interface + virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; + + // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bRepGameplayTags; @@ -107,14 +110,7 @@ protected: // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bReplicateMovement; -public: - FGameplayTagContainer& GetGameplayTags(); - bool GetRepGameplayTags() { return bRepGameplayTags; } - void SetRepGameplayTags(bool bNewRepGameplayTags); - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); - virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void BeginPlay() override; @@ -150,7 +146,11 @@ public: // Should be called after the Mount is moved post begin play UFUNCTION(BlueprintCallable, Category = "VRMountComponent") - void ResetInitialMountLocation(); + void ResetInitialMountLocation() + { + // Get our initial relative transform to our parent (or not if un-parented). + InitialRelativeTransform = this->GetRelativeTransform(); + } virtual void OnUnregister() override;; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRSliderComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRSliderComponent.h index 61d5c0b..a28bba9 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRSliderComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Interactibles/VRSliderComponent.h @@ -147,13 +147,9 @@ public: UFUNCTION(BlueprintCallable, Category = "GripSettings") void SetGripPriority(int NewGripPriority); -protected: // Set this to assign a spline component to the slider UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Replicated/*Using = OnRep_SplineComponentToFollow*/, Category = "VRSliderComponent") TObjectPtr SplineComponentToFollow; -public: - // Gets the initial relative transform, if you want to set it you should be using ResetInitialButtonLocation - TObjectPtr GetSplineComponentToFollow() { return SplineComponentToFollow; } /*UFUNCTION() virtual void OnRep_SplineComponentToFollow() @@ -202,13 +198,9 @@ public: // Resetting the initial transform here so that it comes in prior to BeginPlay and save loading. virtual void OnRegister() override; -protected: // Now replicating this so that it works correctly over the network UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_InitialRelativeTransform, Category = "VRSliderComponent") FTransform_NetQuantize InitialRelativeTransform; -public: - // Gets the initial relative transform, if you want to set it you should be using ResetInitialButtonLocation - FTransform GetInitialRelativeTransform() { return InitialRelativeTransform; } UFUNCTION() virtual void OnRep_InitialRelativeTransform() @@ -269,13 +261,15 @@ public: TagContainer = GameplayTags; } -protected: - /** Tags that are set on this object */ UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags") FGameplayTagContainer GameplayTags; + // End Gameplay Tag Interface + virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; + + // Requires bReplicates to be true for the component UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface") bool bRepGameplayTags; @@ -283,14 +277,7 @@ protected: // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication") bool bReplicateMovement; -public: - FGameplayTagContainer& GetGameplayTags(); - bool GetRepGameplayTags() { return bRepGameplayTags; } - void SetRepGameplayTags(bool bNewRepGameplayTags); - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); - virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void BeginPlay() override; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/CollisionIgnoreSubsystem.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/CollisionIgnoreSubsystem.h index d9d9c60..8ffce65 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/CollisionIgnoreSubsystem.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/CollisionIgnoreSubsystem.h @@ -216,7 +216,15 @@ public: Super::Initialize(Collection); } - virtual void Deinitialize() override; + virtual void Deinitialize() override + { + Super::Deinitialize(); + + if (UpdateHandle.IsValid()) + { + GetWorld()->GetTimerManager().ClearTimer(UpdateHandle); + } + } UPROPERTY() TMap CollisionTrackedPairs; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/OptionalRepSkeletalMeshActor.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/OptionalRepSkeletalMeshActor.h index 6204dfb..0067180 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/OptionalRepSkeletalMeshActor.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/OptionalRepSkeletalMeshActor.h @@ -20,12 +20,8 @@ class VREXPANSIONPLUGIN_API UNoRepSphereComponent : public USphereComponent public: UNoRepSphereComponent(const FObjectInitializer& ObjectInitializer); -protected: UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Component Replication") bool bReplicateMovement; -public: - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override; }; @@ -67,14 +63,11 @@ class VREXPANSIONPLUGIN_API UInversePhysicsSkeletalMeshComponent : public USkele public: UInversePhysicsSkeletalMeshComponent(const FObjectInitializer& ObjectInitializer); -protected: +public: + // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "Component Replication") bool bReplicateMovement; -public: - bool GetReplicateMovement() { return bReplicateMovement; } - void SetReplicateMovement(bool bNewReplicateMovement); - // This is all overrides to fix the skeletal mesh inverse simulation bug // WILL BE REMOVED LATER when the engine is fixed diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRAIPerceptionOverrides.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRAIPerceptionOverrides.h index 1006aef..7b23c6c 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRAIPerceptionOverrides.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRAIPerceptionOverrides.h @@ -377,8 +377,6 @@ protected: void RemoveAllQueriesByListener(const FPerceptionListener& Listener, const TFunction& OnRemoveFunc = nullptr); void RemoveAllQueriesToTarget(const FAISightTargetVR::FTargetId& TargetId, const TFunction& OnRemoveFunc = nullptr); - /** RemoveAllQueriesToTarget version that need to already have a write access on QueriesListAccessDetector*/ - void RemoveAllQueriesToTarget_Internal(const FAISightTargetVR::FTargetId& TargetId, const TFunction& OnRemoveFunc = nullptr); /** returns information whether new LoS queries have been added */ bool RegisterTarget(AActor& TargetActor, const TFunction& OnAddedFunc = nullptr); diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VREPhysicalAnimationComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VREPhysicalAnimationComponent.h index 0600c4b..2254c44 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VREPhysicalAnimationComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VREPhysicalAnimationComponent.h @@ -5,8 +5,8 @@ //#include "UObject/ObjectMacros.h" #include "Components/ActorComponent.h" #include "EngineDefines.h" -#if UE_ENABLE_DEBUG_DRAWING -//#include "Chaos/DebugDrawQueue.h" +#if ENABLE_DRAW_DEBUG +#include "Chaos/DebugDrawQueue.h" #endif #include "VREPhysicalAnimationComponent.generated.h" @@ -89,11 +89,11 @@ public: /** If true then we will debug draw the mesh collision post shape alterations */ - //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeldedBoneDriver) - //bool bDebugDrawCollision = false; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeldedBoneDriver) + bool bDebugDrawCollision = false; -#if UE_ENABLE_DEBUG_DRAWING - //void DebugDrawMesh(const TArray& DrawCommands); +#if ENABLE_DRAW_DEBUG + void DebugDrawMesh(const TArray& DrawCommands); #endif FTransform GetWorldSpaceRefBoneTransform(FReferenceSkeleton& RefSkel, int32 BoneIndex, int32 ParentBoneIndex); diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRLogComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRLogComponent.h index c3e04c3..b57100a 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRLogComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRLogComponent.h @@ -3,7 +3,6 @@ #pragma once #include "CoreMinimal.h" -#include "Components/ActorComponent.h" #include "Engine/Canvas.h" #include "Engine/TextureRenderTarget2D.h" #include "Engine/Console.h" diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRRenderTargetManager.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRRenderTargetManager.h index 696817e..27ff397 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRRenderTargetManager.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Misc/VRRenderTargetManager.h @@ -1,8 +1,5 @@ #pragma once #include "TimerManager.h" -#include "GameFramework/Actor.h" -#include "Components/ActorComponent.h" -#include "Containers/Queue.h" #include "VRRenderTargetManager.generated.h" class UVRRenderTargetManager; @@ -11,8 +8,6 @@ class UCanvas; class UTexture2D; class UMaterial; class APlayerController; -class FRenderCommandFence; -enum EPixelFormat : uint8; // #TODO: Dirty rects so don't have to send entire texture? @@ -188,7 +183,7 @@ public: UPROPERTY(Replicated) uint32 OwnersID; - + UFUNCTION() void OnRep_Manager(); @@ -219,7 +214,14 @@ public: UPROPERTY() int32 MaxBytesPerSecondRate; - virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; + virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override + { + if(SendTimer_Handle.IsValid()) + GetWorld()->GetTimerManager().ClearTimer(SendTimer_Handle); + + Super::EndPlay(EndPlayReason); + } + UFUNCTION(Reliable, Server, WithValidation) void SendLocalDrawOperations(const TArray& LocalRenderOperationStoreList); diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Mover/VRMoverComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Mover/VRMoverComponent.h deleted file mode 100644 index 687b613..0000000 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/Mover/VRMoverComponent.h +++ /dev/null @@ -1,154 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once -#include "CoreMinimal.h" -#include "MoverComponent.h" -#include "MoverTypes.h" -#include "GameFramework/Pawn.h" -#include "LayeredMove.h" -#include "VRMoverComponent.generated.h" - -class UCurveVector; -class UCurveFloat; - -DECLARE_LOG_CATEGORY_EXTERN(LogVRMoverComponent, Log, All); - -/** Linear Velocity: A method of inducing a straight-line velocity on an actor over time */ -USTRUCT(BlueprintType) -struct VREXPANSIONPLUGIN_API FLayeredMove_VRMovement : public FLayeredMoveBase -{ - GENERATED_USTRUCT_BODY() - - FLayeredMove_VRMovement(); - - virtual ~FLayeredMove_VRMovement() {} - - // Units per second, could be worldspace vs relative depending on Flags - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Mover) - FVector Velocity; - - // Optional curve float for controlling the magnitude of the velocity applied to the actor over the duration of the move - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Mover) - TObjectPtr MagnitudeOverTime; - - // @see ELayeredMove_ConstantVelocitySettingsFlags - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Mover) - uint8 SettingsFlags; - - // Never finish this movement - virtual bool IsFinished(float CurrentSimTimeMs) const; - - // Generate a movement - virtual bool GenerateMove(const FMoverTickStartData& StartState, const FMoverTimeStep& TimeStep, const UMoverComponent* MoverComp, UMoverBlackboard* SimBlackboard, FProposedMove& OutProposedMove) override; - - virtual FLayeredMoveBase* Clone() const override; - - virtual void NetSerialize(FArchive& Ar) override; - - virtual UScriptStruct* GetScriptStruct() const override; - - virtual FString ToSimpleString() const override; - - virtual void AddReferencedObjects(class FReferenceCollector& Collector) override; -}; - -template<> -struct TStructOpsTypeTraits< FLayeredMove_VRMovement > : public TStructOpsTypeTraitsBase2< FLayeredMove_VRMovement > -{ - enum - { - //WithNetSerializer = true, - WithCopy = true - }; -}; - -// Data block containing basic sync state information -USTRUCT(BlueprintType) -struct VREXPANSIONPLUGIN_API FVRMoverHMDSyncState : public FMoverDataStructBase -{ - GENERATED_USTRUCT_BODY() - -public: - // Movement intent direction relative to MovementBase if set, world space otherwise. Magnitude of range (0-1) - UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Mover) - FVector MoveDirectionIntent; - -public: - - FVRMoverHMDSyncState() - { - // In constructor list when the actual var is made - MoveDirectionIntent = FVector::ZeroVector; - } - - virtual ~FVRMoverHMDSyncState() {} - - // @return newly allocated copy of this FMoverDefaultSyncState. Must be overridden by child classes - virtual FMoverDataStructBase* Clone() const override; - - virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override; - - virtual UScriptStruct* GetScriptStruct() const override { return StaticStruct(); } - - // Need implemented (if needed) - virtual bool ShouldReconcile(const FMoverDataStructBase& AuthorityState) const override - { - return false; - } - - // Needs implemented (should we even do this?) - virtual void Interpolate(const FMoverDataStructBase& From, const FMoverDataStructBase& To, float Pct) override - { - return; - } - - -}; - -template<> -struct TStructOpsTypeTraits< FVRMoverHMDSyncState > : public TStructOpsTypeTraitsBase2< FVRMoverHMDSyncState > -{ - enum - { - WithNetSerializer = true, - WithCopy = true - }; -}; - - - -UCLASS() -class VREXPANSIONPLUGIN_API AVRMoverBasePawn : public APawn, public IMoverInputProducerInterface -{ - GENERATED_BODY() - -public: - // Sets default values for this pawn's properties - AVRMoverBasePawn(const FObjectInitializer& ObjectInitializer); - - /** Accessor for the actor's movement component */ - UFUNCTION(BlueprintPure, Category = Mover) - UMoverComponent* GetMoverComponent() const { return CharacterMotionComponent; } - - virtual void BeginPlay() override; - -protected: - - virtual UPrimitiveComponent* GetMovementBase() const override; - - // Entry point for input production. Do not override. To extend in derived character types, override OnProduceInput for native types or implement "Produce Input" blueprint event - virtual void ProduceInput_Implementation(int32 SimTimeMs, FMoverInputCmdContext& InputCmdResult) override; - - // Override this function in native class to author input for the next simulation frame. Consider also calling Super method. - virtual void OnProduceInput(float DeltaMs, FMoverInputCmdContext& InputCmdResult); - - // Implement this event in Blueprints to author input for the next simulation frame. Consider also calling Parent event. - UFUNCTION(BlueprintImplementableEvent, DisplayName = "On Produce Input", meta = (ScriptName = "OnProduceInput")) - FMoverInputCmdContext OnProduceInputInBlueprint(float DeltaMs, FMoverInputCmdContext InputCmd); - -protected: - UPROPERTY(Category = Movement, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) - TObjectPtr CharacterMotionComponent; - - uint8 bHasProduceInputinBpFunc : 1; -}; \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/ReplicatedVRCameraComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/ReplicatedVRCameraComponent.h index 74e657d..3b060c8 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/ReplicatedVRCameraComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/ReplicatedVRCameraComponent.h @@ -106,11 +106,6 @@ public: UPROPERTY(EditDefaultsOnly, ReplicatedUsing = OnRep_ReplicatedCameraTransform, Category = "ReplicatedCamera|Networking") FBPVRComponentPosRep ReplicatedCameraTransform; - // Returns the actual tracked transform of the HMD, as with RetainRoomscale = False we do not set the camera to it - // Can also just use the HMD function library but this is a fast way if you already have a camera reference - UFUNCTION(BlueprintPure, Category = "ReplicatedCamera|Tracking") - FTransform GetHMDTrackingTransform(); - FVector LastUpdatesRelativePosition = FVector::ZeroVector; FRotator LastUpdatesRelativeRotation = FRotator::ZeroRotator; @@ -120,10 +115,9 @@ public: // Run the smoothing step void RunNetworkedSmoothing(float DeltaTime); - // Whether to smooth (lerp) between ticks for the replicated motion, DOES NOTHING if update rate is larger than FPS! - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ReplicatedCamera|Networking") - bool bSmoothReplicatedMotion = true; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "ReplicatedCamera|Networking") + bool bSmoothReplicatedMotion; // If true then we will use exponential smoothing with buffered correction UPROPERTY(EditAnywhere, Category = "ReplicatedCamera|Networking|Smoothing", meta = (editcondition = "bSmoothReplicatedMotion")) @@ -144,19 +138,14 @@ public: UFUNCTION() virtual void OnRep_ReplicatedCameraTransform(); -protected: // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every tick). // On dedicated servers the update rate should be at or lower than the server tick rate for smoothing to work UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "ReplicatedCamera|Networking") float NetUpdateRate; -public: // Used in Tick() to accumulate before sending updates, didn't want to use a timer in this case. float NetUpdateCount; - float GetNetUpdateRate() { return NetUpdateRate; } - void SetNetUpdateRate(float NewNetUpdateRate); - // I'm sending it unreliable because it is being resent pretty often UFUNCTION(Unreliable, Server, WithValidation) void Server_SendCameraTransform(FBPVRComponentPosRep NewTransform); @@ -166,7 +155,14 @@ public: VRBaseCharTransformRPC_Pointer OverrideSendTransform; // Need this as I can't think of another way for an actor component to make sure it isn't on the server - bool IsLocallyControlled() const; + inline bool IsLocallyControlled() const + { + // I like epics new authority check more than my own + const AActor* MyOwner = GetOwner(); + return MyOwner->HasLocalNetOwner(); + //const APawn* MyPawn = Cast(MyOwner); + //return MyPawn ? MyPawn->IsLocallyControlled() : false;// (MyOwner->Role == ENetRole::ROLE_Authority); + } //bool IsServer(); }; \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBPDatatypes.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBPDatatypes.h index 5196519..3f12e5a 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBPDatatypes.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBPDatatypes.h @@ -14,7 +14,6 @@ class UGripMotionControllerComponent; class UVRGripScriptBase; -class UPrimitiveComponent; // Custom movement modes for the characters UENUM(BlueprintType) @@ -1468,13 +1467,6 @@ public: float LerpSpeed; FTransform OnGripTransform; - ///////////////////// - // TMP: Velocity calculation addition for 5.4 #TODO: Remove this when the bug is fixed - FVector LinVel = FVector::ZeroVector; - FVector RotVel = FVector::ZeroVector; - FTransform LastVelWorldTrans; // Identity by default - /////////////////////// - UPROPERTY(BlueprintReadWrite, NotReplicated, Category = "Settings") bool bIsLerping; @@ -1558,9 +1550,15 @@ public: } - AActor* GetGrippedActor() const; + FORCEINLINE AActor * GetGrippedActor() const + { + return Cast(GrippedObject); + } - UPrimitiveComponent* GetGrippedComponent() const; + FORCEINLINE UPrimitiveComponent * GetGrippedComponent() const + { + return Cast(GrippedObject); + } //Check if a grip is the same as another, the only things I check for are the actor / component //This is here for the Find() function from TArray @@ -1582,7 +1580,13 @@ public: return false; } - bool operator==(const UPrimitiveComponent* Other) const; + FORCEINLINE bool operator==(const UPrimitiveComponent * Other) const + { + if (Other && GrippedObject && GrippedObject == (const UObject*)Other) + return true; + + return false; + } FORCEINLINE bool operator==(const UObject * Other) const { @@ -1864,11 +1868,11 @@ public: bEnableVelocityDrive = ConstraintDrive.bEnableVelocityDrive; } - void FillTo(FConstraintDrive& ConstraintDrive, float DampingScaler = 1.0f, float StiffnessScaler = 1.0f) const + void FillTo(FConstraintDrive& ConstraintDrive) const { - ConstraintDrive.Damping = Damping * DampingScaler; - ConstraintDrive.Stiffness = Stiffness * StiffnessScaler; - ConstraintDrive.MaxForce = (float)FMath::Clamp((double)ConstraintDrive.Stiffness * (double)MaxForceCoefficient, 0, (double)MAX_FLT); + ConstraintDrive.Damping = Damping; + ConstraintDrive.Stiffness = Stiffness; + ConstraintDrive.MaxForce = MaxForceCoefficient * Stiffness; ConstraintDrive.bEnablePositionDrive = bEnablePositionDrive; ConstraintDrive.bEnableVelocityDrive = bEnableVelocityDrive; } @@ -1925,5 +1929,27 @@ public: return true; } - bool FillTo(FBPActorPhysicsHandleInformation* HandleInfo, bool bModifyWithScalers = true) const; + bool FillTo(FBPActorPhysicsHandleInformation* HandleInfo) const + { + if (!HandleInfo) + return false; + + XAxisSettings.FillTo(HandleInfo->LinConstraint.XDrive); + YAxisSettings.FillTo(HandleInfo->LinConstraint.YDrive); + ZAxisSettings.FillTo(HandleInfo->LinConstraint.ZDrive); + + if ((SlerpSettings.bEnablePositionDrive || SlerpSettings.bEnableVelocityDrive)) + { + HandleInfo->AngConstraint.AngularDriveMode = EAngularDriveMode::SLERP; + SlerpSettings.FillTo(HandleInfo->AngConstraint.SlerpDrive); + } + else + { + HandleInfo->AngConstraint.AngularDriveMode = EAngularDriveMode::TwistAndSwing; + TwistSettings.FillTo(HandleInfo->AngConstraint.TwistDrive); + SwingSettings.FillTo(HandleInfo->AngConstraint.SwingDrive); + } + + return true; + } }; \ No newline at end of file diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBaseCharacter.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBaseCharacter.h index 7764226..51d1850 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBaseCharacter.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRBaseCharacter.h @@ -13,7 +13,6 @@ class AVRPlayerController; class UGripMotionControllerComponent; class UParentRelativeAttachmentComponent; class AController; -class UNavigationQueryFilter; DECLARE_LOG_CATEGORY_EXTERN(LogBaseVRCharacter, Log, All); @@ -281,7 +280,7 @@ public: // If true then we will retain roomscale tracking in relative space of the character. // If false than the movement component will offset to the hmd tracking and the tracking will be nulled out UPROPERTY(Category = VRBaseCharacter, EditAnywhere, BlueprintReadOnly) - bool bRetainRoomscale = false; + bool bRetainRoomscale = true; //virtual void CacheInitialMeshOffset(FVector MeshRelativeLocation, FRotator MeshRelativeRotation) override; virtual void PostInitializeComponents() override; @@ -331,14 +330,9 @@ public: virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override; -protected: // If true will replicate the capsule height on to clients, allows for dynamic capsule height changes in multiplayer UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRBaseCharacter") bool VRReplicateCapsuleHeight; -public: - bool GetVRReplicateCapsuleHeight() { return VRReplicateCapsuleHeight; } - void SetVRReplicateCapsuleHeight(bool bNewVRReplicateCapsuleHeight); - // OnlyReplicated to simulated clients UPROPERTY(Replicated, ReplicatedUsing = OnRep_CapsuleHeight) diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRGestureComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRGestureComponent.h index 0634221..f253cfc 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRGestureComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRGestureComponent.h @@ -6,7 +6,6 @@ //#include "Engine/Engine.h" #include "VRBPDatatypes.h" #include "Engine/DataAsset.h" -#include "Components\SceneComponent.h" //#include "Engine/EngineTypes.h" //#include "Engine/EngineBaseTypes.h" @@ -319,7 +318,7 @@ public: return FVector::DistSquared(Seq1, Seq2); } - virtual void BeginDestroy() override; + void BeginDestroy() override; // Recalculates a gestures size and re-scales it to the given database UFUNCTION(BlueprintCallable, Category = "VRGestures") diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRRootComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRRootComponent.h index 08ac90f..fd18e20 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRRootComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRRootComponent.h @@ -230,9 +230,6 @@ public: return bInsideVolume; } - // Expose this - inline float GetLineThickness() const {return LineThickness;} - public: // Begin UObject interface #if WITH_EDITOR diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRStereoWidgetComponent.h b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRStereoWidgetComponent.h index 9fddf36..92f871f 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRStereoWidgetComponent.h +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/Public/VRStereoWidgetComponent.h @@ -117,7 +117,6 @@ public: TObjectPtr Shape; void BeginDestroy() override; - virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; void OnUnregister() override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void DrawWidgetToRenderTarget(float DeltaTime) override; @@ -177,10 +176,6 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer") uint32 bQuadPreserveTextureRatio : 1; - /** Additional flags not included in IStereoLayers::ELayerFlags */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "StereoLayer", Meta = (GetOptions = "EditorFlagCollector.GetFlagNames")) - TArray AdditionalFlags; - protected: /** Texture displayed on the stereo layer (is stereocopic textures are supported on the platfrom and more than one texture is provided, this will be the right eye) **/ //UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "StereoLayer") @@ -225,9 +220,6 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer") int32 Priority; - /** IStereoLayer id, 0 is unassigned **/ - uint32 LayerId; - bool bShouldCreateProxy; private: @@ -238,6 +230,9 @@ private: /** Texture needs to be marked for update **/ bool bTextureNeedsUpdate; + /** IStereoLayer id, 0 is unassigned **/ + uint32 LayerId; + /** Last transform is cached to determine if the new frames transform has changed **/ FTransform LastTransform; diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/VRExpansionPlugin.Build.cs b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/VRExpansionPlugin.Build.cs index f065a80..c4976b7 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/VRExpansionPlugin.Build.cs +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/Source/VRExpansionPlugin/VRExpansionPlugin.Build.cs @@ -59,15 +59,23 @@ public class VRExpansionPlugin : ModuleRules "NetCore", "CoreUObject", "Engine", + // "InputCore", "PhysicsCore", + //"FLEX", remove comment if building in the NVIDIA flex branch - NOTE when put in place FLEX only listed win32 and win64 at compatible platforms "HeadMountedDisplay", + // "RHI", + //"RenderCore", + //"ShaderCore", + //"NetworkReplayStreaming", + //"AIModule", "UMG", "NavigationSystem", "AIModule", "AnimGraphRuntime", "XRBase", - "GameplayTags", - "Mover" + "GameplayTags" + //"Renderer", + //"UtilityShaders" }); //if(Target.bUseChaos) @@ -106,6 +114,20 @@ public class VRExpansionPlugin : ModuleRules } ); + // Don't load APEX on incompatible platforms + /* if ( + Target.Platform != UnrealTargetPlatform.IOS && + Target.Platform != UnrealTargetPlatform.TVOS && + Target.Platform != UnrealTargetPlatform.Android && + Target.Platform != UnrealTargetPlatform.HTML5) + { + PublicDependencyModuleNames.AddRange( + new string[] + { + "APEX" + }); + }*/ + // Allow gameplay debugger on editor builds if (Target.bBuildDeveloperTools || (Target.Configuration != UnrealTargetConfiguration.Shipping && Target.Configuration != UnrealTargetConfiguration.Test)) { diff --git a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/VRExpansionPlugin.uplugin b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/VRExpansionPlugin.uplugin index cb68065..2e4de32 100644 --- a/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/VRExpansionPlugin.uplugin +++ b/VIRTUOS_ExpansionPluginTests/Plugins/VRExpansionPlugin/VRExpansionPlugin/VRExpansionPlugin.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 5.4, - "VersionName": "5.4", + "Version": 5.3, + "VersionName": "5.3", "FriendlyName": "VRExpansionPlugin", "Description": "Adds several new VR features & components to UE4", "Category": "VRExpansion", @@ -33,7 +33,7 @@ "LoadingPhase": "PostEngineInit" } ], - "Plugins": [ + "Plugins": [ { "Name": "ChaosVehiclesPlugin", "Enabled": true @@ -41,10 +41,6 @@ { "Name": "XRBase", "Enabled": true - }, - { - "Name": "Mover", - "Enabled": true } - ] + ] } \ No newline at end of file