Updated to latest VRE Version

Saving Character Position works now
This commit is contained in:
Simeon "Waldo" Wallrath 2024-02-13 10:41:05 +01:00
parent 76ea5a33f8
commit 0cc9b4c0b2
29 changed files with 362 additions and 93 deletions

View file

@ -17,7 +17,9 @@
"SupportedTargetPlatforms": [ "SupportedTargetPlatforms": [
"Win64", "Win64",
"Linux", "Linux",
"Android" "Android",
"Mac",
"IOS"
], ],
"Modules": [ "Modules": [
{ {

View file

@ -95,7 +95,7 @@ TWeakObjectPtr<UAnimSequence> FHandSocketComponentDetails::SaveAnimationAsset(co
// if object with same name exists, warn user // if object with same name exists, warn user
if (Object) if (Object)
{ {
EAppReturnType::Type ReturnValue = FMessageDialog::Open(EAppMsgType::YesNo, NSLOCTEXT("UnrealEd", "Error_AssetExist", "Asset with same name exists. Do you wish to overwrite it?")); EAppReturnType::Type ReturnValue = FMessageDialog::Open(EAppMsgType::YesNo, LOCTEXT("Error_AssetExist", "Asset with same name exists. Do you wish to overwrite it?"));
if (ReturnValue == EAppReturnType::No) if (ReturnValue == EAppReturnType::No)
{ {
return FinalAnimation; // failed return FinalAnimation; // failed
@ -554,12 +554,12 @@ void FHandSocketComponentDetails::CustomizeDetails(IDetailLayoutBuilder& DetailB
ShowVisualizationProperty->SetOnPropertyValueChanged(OnShowVisChangedDelegate); ShowVisualizationProperty->SetOnPropertyValueChanged(OnShowVisChangedDelegate);
DetailBuilder.EditCategory("Hand Animation") DetailBuilder.EditCategory("Hand Animation")
.AddCustomRow(NSLOCTEXT("HandSocketDetails", "UpdateHandSocket", "Save Current Pose")) .AddCustomRow(LOCTEXT("UpdateHandSocketRow", "Save Current Pose"))
.NameContent() .NameContent()
[ [
SNew(STextBlock) SNew(STextBlock)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Text(NSLOCTEXT("HandSocketDetails", "UpdateHandSocket", "Save Current Pose")) .Text(LOCTEXT("UpdateHandSocketText", "Save Current Pose"))
] ]
.ValueContent() .ValueContent()
.MaxDesiredWidth(125.f) .MaxDesiredWidth(125.f)
@ -573,7 +573,7 @@ void FHandSocketComponentDetails::CustomizeDetails(IDetailLayoutBuilder& DetailB
[ [
SNew(STextBlock) SNew(STextBlock)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Text(NSLOCTEXT("HandSocketDetails", "UpdateHandSocket", "Save")) .Text(LOCTEXT("UpdateHandSocketButton", "Save"))
] ]
]; ];
} }

View file

@ -54,12 +54,12 @@ void FVRGlobalSettingsDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuil
//LockedLocationProperty->SetOnPropertyValueChanged(OnLockedStateChangedDelegate); //LockedLocationProperty->SetOnPropertyValueChanged(OnLockedStateChangedDelegate);
DetailBuilder.EditCategory("Utilities") DetailBuilder.EditCategory("Utilities")
.AddCustomRow(NSLOCTEXT("VRGlobalSettingsDetails", "Tools", "Fix Invalid 5.2 Animation Assets")) .AddCustomRow(LOCTEXT("FixInvalidAnimationAssets", "Fix Invalid 5.2 Animation Assets"))
.NameContent() .NameContent()
[ [
SNew(STextBlock) SNew(STextBlock)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Text(NSLOCTEXT("VRGlobalSettingsDetails", "Tools", "Fix Invalid 5.2 Animation Assets")) .Text(LOCTEXT("FixInvalidAnimationAssets", "Fix Invalid 5.2 Animation Assets"))
] ]
.ValueContent() .ValueContent()
.MaxDesiredWidth(125.f) .MaxDesiredWidth(125.f)
@ -73,7 +73,7 @@ void FVRGlobalSettingsDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuil
[ [
SNew(STextBlock) SNew(STextBlock)
.Font(IDetailLayoutBuilder::GetDetailFont()) .Font(IDetailLayoutBuilder::GetDetailFont())
.Text(NSLOCTEXT("VRGlobalSettingsDetails", "Tools", "Fix Animation Assets")) .Text(LOCTEXT("FixInvalidAnimationAssetsButton", "Fix Animation Assets"))
] ]
]; ];
} }

View file

@ -189,7 +189,17 @@ void FSavedMove_VRBaseCharacter::PostUpdate(ACharacter* C, EPostUpdateMode PostU
ConditionalValues.CustomVRInputVector = moveComp->CustomVRInputVector; ConditionalValues.CustomVRInputVector = moveComp->CustomVRInputVector;
ConditionalValues.MoveActionArray = moveComp->MoveActionArray; ConditionalValues.MoveActionArray = moveComp->MoveActionArray;
moveComp->MoveActionArray.Clear(); moveComp->MoveActionArray.Clear();
if (!moveComp->bUseClientControlRotation)
{
if (const USceneComponent* UpdatedComponent = moveComp->UpdatedComponent)
{
SavedControlRotation = UpdatedComponent->GetComponentRotation().Clamp();
} }
}
}
//} //}
/*if (ConditionalValues.MoveAction.MoveAction != EVRMoveAction::VRMOVEACTION_None) /*if (ConditionalValues.MoveAction.MoveAction != EVRMoveAction::VRMOVEACTION_None)
{ {
@ -355,8 +365,21 @@ bool FVRCharacterNetworkMoveData::Serialize(UCharacterMovementComponent& Charact
ACharacter* CharacterOwner = CharacterMovement.GetCharacterOwner(); ACharacter* CharacterOwner = CharacterMovement.GetCharacterOwner();
bool bRepRollAndPitch = false;
if (AVRBaseCharacter* BaseChar = Cast<AVRBaseCharacter>(CharacterOwner))
{
if (!BaseChar->VRMovementReference->bUseClientControlRotation)
{
bRepRollAndPitch = (Roll != 0 || Pitch != 0);
}
}
else
{
bool bCanRepRollAndPitch = (CharacterOwner && (CharacterOwner->bUseControllerRotationRoll || CharacterOwner->bUseControllerRotationPitch)); bool bCanRepRollAndPitch = (CharacterOwner && (CharacterOwner->bUseControllerRotationRoll || CharacterOwner->bUseControllerRotationPitch));
bool bRepRollAndPitch = bCanRepRollAndPitch && (Roll != 0 || Pitch != 0); bRepRollAndPitch = bCanRepRollAndPitch && (Roll != 0 || Pitch != 0);
}
Ar.SerializeBits(&bRepRollAndPitch, 1); Ar.SerializeBits(&bRepRollAndPitch, 1);
if (bRepRollAndPitch) if (bRepRollAndPitch)

View file

@ -10,6 +10,7 @@
#include "Net/UnrealNetwork.h" #include "Net/UnrealNetwork.h"
#include "PrimitiveSceneInfo.h" #include "PrimitiveSceneInfo.h"
#include "Engine/World.h" #include "Engine/World.h"
#include "PrimitiveSceneProxy.h"
#include "GameFramework/WorldSettings.h" #include "GameFramework/WorldSettings.h"
#include "IXRSystemAssets.h" #include "IXRSystemAssets.h"
#include "Components/StaticMeshComponent.h" #include "Components/StaticMeshComponent.h"
@ -4645,7 +4646,7 @@ void UGripMotionControllerComponent::UpdateTracking(float DeltaTime)
float WorldToMeters = GetWorld() ? GetWorld()->GetWorldSettings()->WorldToMeters : 100.0f; float WorldToMeters = GetWorld() ? GetWorld()->GetWorldSettings()->WorldToMeters : 100.0f;
ETrackingStatus LastTrackingStatus = CurrentTrackingStatus; ETrackingStatus LastTrackingStatus = CurrentTrackingStatus;
const bool bNewTrackedState = PollControllerState_GameThread(Position, Orientation, bProvidedLinearVelocity, LinearVelocity, bProvidedAngularVelocity, AngularVelocityAsAxisAndLength, bProvidedLinearAcceleration, LinearAcceleration, WorldToMeters); const bool bNewTrackedState = GripPollControllerState_GameThread(Position, Orientation, bProvidedLinearVelocity, LinearVelocity, bProvidedAngularVelocity, AngularVelocityAsAxisAndLength, bProvidedLinearAcceleration, LinearAcceleration, WorldToMeters);
// if controller tracking just kicked in or we haven't started rendering in the (possibly present) // if controller tracking just kicked in or we haven't started rendering in the (possibly present)
// visualization component. // visualization component.
@ -7410,7 +7411,7 @@ void UGripMotionControllerComponent::FGripViewExtension::PreRenderViewFamily_Ren
FVector Position = MotionControllerComponent->LateUpdateParams.GripRenderThreadRelativeTransform.GetTranslation(); FVector Position = MotionControllerComponent->LateUpdateParams.GripRenderThreadRelativeTransform.GetTranslation();
FRotator Orientation = MotionControllerComponent->LateUpdateParams.GripRenderThreadRelativeTransform.GetRotation().Rotator(); FRotator Orientation = MotionControllerComponent->LateUpdateParams.GripRenderThreadRelativeTransform.GetRotation().Rotator();
if (!MotionControllerComponent->PollControllerState_RenderThread(Position, Orientation, WorldToMetersScale)) if (!MotionControllerComponent->GripPollControllerState_RenderThread(Position, Orientation, WorldToMetersScale))
{ {
return; return;
} }

View file

@ -67,6 +67,7 @@ UHandSocketComponent::UHandSocketComponent(const FObjectInitializer& ObjectIniti
HandRelativePlacement = FTransform::Identity; HandRelativePlacement = FTransform::Identity;
bAlwaysInRange = false; bAlwaysInRange = false;
bDisabled = false; bDisabled = false;
bLockInPlace = false;
bMatchRotation = false; bMatchRotation = false;
OverrideDistance = 0.0f; OverrideDistance = 0.0f;
SlotPrefix = FName("VRGripP"); SlotPrefix = FName("VRGripP");
@ -443,13 +444,38 @@ FTransform UHandSocketComponent::GetHandSocketTransform(UGripMotionControllerCom
ReturnTrans = ReturnTrans * AttParent->GetComponentTransform(); ReturnTrans = ReturnTrans * AttParent->GetComponentTransform();
} }
return ReturnTrans; return ReturnTrans;
} }
} }
} }
if (bLockInPlace)
{
FTransform ReturnTrans = this->GetRelativeTransform();
if (USceneComponent* AttParent = this->GetAttachParent())
{
if (this->GetAttachSocketName() != NAME_None)
{
ReturnTrans = ReturnTrans * AttParent->GetSocketTransform(GetAttachSocketName(), RTS_Component);
}
ReturnTrans = ReturnTrans * AttParent->GetComponentTransform();
}
else
{
ReturnTrans = this->GetComponentTransform(); // Fallback
}
return ReturnTrans;
}
else
{
return this->GetComponentTransform(); return this->GetComponentTransform();
} }
}
FTransform UHandSocketComponent::GetMeshRelativeTransform(bool bIsRightHand, bool bUseParentScale, bool bUseMirrorScale) FTransform UHandSocketComponent::GetMeshRelativeTransform(bool bIsRightHand, bool bUseParentScale, bool bUseMirrorScale)
{ {
@ -552,11 +578,19 @@ FTransform UHandSocketComponent::GetBoneTransformAtTime(UAnimSequence* MyAnimSeq
void UHandSocketComponent::OnRegister() void UHandSocketComponent::OnRegister()
{ {
UWorld* MyWorld = GetWorld();
if (!MyWorld)
return;
TEnumAsByte<EWorldType::Type> MyWorldType = MyWorld->WorldType;
#if WITH_EDITORONLY_DATA #if WITH_EDITORONLY_DATA
AActor* MyOwner = GetOwner(); AActor* MyOwner = GetOwner();
if (bShowVisualizationMesh && (MyOwner != nullptr) && !IsRunningCommandlet()) if (bShowVisualizationMesh && (MyOwner != nullptr) && !IsRunningCommandlet())
{ {
if (HandVisualizerComponent == nullptr && bShowVisualizationMesh) if (HandVisualizerComponent == nullptr && bShowVisualizationMesh && (MyWorldType == EWorldType::EditorPreview || MyWorldType == EWorldType::Editor))
{ {
HandVisualizerComponent = NewObject<UPoseableMeshComponent>(MyOwner, NAME_None, RF_Transactional | RF_TextExportTransient); HandVisualizerComponent = NewObject<UPoseableMeshComponent>(MyOwner, NAME_None, RF_Transactional | RF_TextExportTransient);
HandVisualizerComponent->SetupAttachment(this); HandVisualizerComponent->SetupAttachment(this);
@ -570,9 +604,11 @@ void UHandSocketComponent::OnRegister()
HandVisualizerComponent->RegisterComponentWithWorld(GetWorld()); HandVisualizerComponent->RegisterComponentWithWorld(GetWorld());
//HandVisualizerComponent->SetUsingAbsoluteScale(true); //HandVisualizerComponent->SetUsingAbsoluteScale(true);
} }
else if (!bShowVisualizationMesh && HandVisualizerComponent) else if (/*!bShowVisualizationMesh && */HandVisualizerComponent)
{ {
HideVisualizationMesh(); HandVisualizerComponent->SetVisibility(false);
HandVisualizerComponent->DestroyComponent();
HandVisualizerComponent = nullptr;
} }
if (HandVisualizerComponent) if (HandVisualizerComponent)
@ -595,6 +631,16 @@ void UHandSocketComponent::OnRegister()
#endif // WITH_EDITORONLY_DATA #endif // WITH_EDITORONLY_DATA
if (bLockInPlace && (MyWorldType != EWorldType::EditorPreview && MyWorldType != EWorldType::Editor))
{
// Store current starting relative transform
//LockedRelativeTransform = GetRelativeTransform();
// Kill off child updates
SetUsingAbsoluteLocation(true);
SetUsingAbsoluteRotation(true);
}
Super::OnRegister(); Super::OnRegister();
} }

View file

@ -7,6 +7,7 @@
//#include "VRGripInterface.h" //#include "VRGripInterface.h"
#include "GripMotionControllerComponent.h" #include "GripMotionControllerComponent.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "GameFramework/PlayerController.h"
//============================================================================= //=============================================================================
UVRButtonComponent::UVRButtonComponent(const FObjectInitializer& ObjectInitializer) UVRButtonComponent::UVRButtonComponent(const FObjectInitializer& ObjectInitializer)
@ -182,9 +183,17 @@ bool UVRButtonComponent::IsValidOverlap_Implementation(UPrimitiveComponent * Ove
// Should return faster checking for owning character // Should return faster checking for owning character
AActor * OverlapOwner = OverlapComponent->GetOwner(); AActor * OverlapOwner = OverlapComponent->GetOwner();
if (OverlapOwner && OverlapOwner->IsA(ACharacter::StaticClass()))
if (IsValid(OverlapOwner))
{
if (OverlapOwner->IsA(ACharacter::StaticClass()))
return true; return true;
const AActor* OverlapNetOwner = OverlapOwner->GetNetOwner();
if (IsValid(OverlapNetOwner) && (OverlapNetOwner->IsA(APlayerController::StaticClass()) || OverlapNetOwner->IsA(ACharacter::StaticClass())))
return true;
}
// Because epic motion controllers are not owned by characters have to check here too in case someone implements it like that // Because epic motion controllers are not owned by characters have to check here too in case someone implements it like that
// Now since our grip controllers are a subclass to the std ones we only need to check for the base one instead of both. // Now since our grip controllers are a subclass to the std ones we only need to check for the base one instead of both.
USceneComponent * OurAttachParent = OverlapComponent->GetAttachParent(); USceneComponent * OurAttachParent = OverlapComponent->GetAttachParent();

View file

@ -779,6 +779,50 @@ float UVRSliderComponent::GetDistanceAlongSplineAtSplineInputKey(float InKey) co
return 0.0f; return 0.0f;
} }
FVector UVRSliderComponent::GetPerAxisSliderProgress()
{
// If we are following a spline per axis makes no sense, return overall progress on all axis's
if (SplineComponentToFollow != nullptr)
{
return FVector(CurrentSliderProgress);
}
// Get our relative space location
FTransform ParentTransform = UVRInteractibleFunctionLibrary::Interactible_GetCurrentParentTransform(this);
FTransform CurrentRelativeTransform = InitialRelativeTransform * ParentTransform;
FVector CalculatedLocation = CurrentRelativeTransform.InverseTransformPosition(this->GetComponentLocation());
CalculatedLocation = bSlideDistanceIsInParentSpace ? CalculatedLocation * InitialRelativeTransform.GetScale3D() : CalculatedLocation;
// Should need the clamp normally, but if someone is manually setting locations it could go out of bounds
FVector Progress;
if (bUseLegacyLogic)
{
if(MinSlideDistance.X != 0.0f || MaxSlideDistance.X != 0.0)
Progress.X = FMath::Clamp(FMath::Abs(-MinSlideDistance.X - CalculatedLocation.X) / FMath::Abs(-MinSlideDistance.X - MaxSlideDistance.X), 0.0f, 1.0f);
if (MinSlideDistance.Y != 0.0f || MaxSlideDistance.Y != 0.0)
Progress.Y = FMath::Clamp(FMath::Abs(-MinSlideDistance.Y - CalculatedLocation.Y) / FMath::Abs(-MinSlideDistance.Y - MaxSlideDistance.Y), 0.0f, 1.0f);
if (MinSlideDistance.Z != 0.0f || MaxSlideDistance.Z != 0.0)
Progress.Z = FMath::Clamp(FMath::Abs(-MinSlideDistance.Z - CalculatedLocation.Z) / FMath::Abs(-MinSlideDistance.Z - MaxSlideDistance.Z), 0.0f, 1.0f);
}
else
{
FVector MinABS = MinSlideDistance.GetAbs();
FVector MaxABS = MaxSlideDistance.GetAbs();
if (MinSlideDistance.X != 0.0f || MaxSlideDistance.X != 0.0)
Progress.X = FMath::Clamp(FMath::Abs(-MinABS.X - CalculatedLocation.X) / FMath::Abs(-MinABS.X - MaxABS.X), 0.0f, 1.0f);
if (MinSlideDistance.Y != 0.0f || MaxSlideDistance.Y != 0.0)
Progress.Y = FMath::Clamp(FMath::Abs(-MinABS.Y - CalculatedLocation.Y) / FMath::Abs(-MinABS.Y - MaxABS.Y), 0.0f, 1.0f);
if (MinSlideDistance.Z != 0.0f || MaxSlideDistance.Z != 0.0)
Progress.Z = FMath::Clamp(FMath::Abs(-MinABS.Z - CalculatedLocation.Z) / FMath::Abs(-MinABS.Z - MaxABS.Z), 0.0f, 1.0f);
}
// Don't setup snap point calculations for this function for now
return Progress;
}
float UVRSliderComponent::GetCurrentSliderProgress(FVector CurLocation, bool bUseKeyInstead, float CurKey) float UVRSliderComponent::GetCurrentSliderProgress(FVector CurLocation, bool bUseKeyInstead, float CurKey)
{ {
if (SplineComponentToFollow != nullptr) if (SplineComponentToFollow != nullptr)

View file

@ -406,14 +406,15 @@ void UCollisionIgnoreSubsystem::SetComponentCollisionIgnoreState(bool bIterateCh
return; return;
} }
if (Prim1->Mobility == EComponentMobility::Static || Prim2->Mobility == EComponentMobility::Static) // Appears to work now with the chaos collision ignore setup
/*if (Prim1->Mobility == EComponentMobility::Static || Prim2->Mobility == EComponentMobility::Static)
{ {
UE_LOG(VRE_CollisionIgnoreLog, Error, TEXT("Set Objects Ignore Collision called with at least one static mobility object (cannot ignore collision with it)!!")); UE_LOG(VRE_CollisionIgnoreLog, Error, TEXT("Set Objects Ignore Collision called with at least one static mobility object (cannot ignore collision with it)!!"));
if (bIgnoreCollision) if (bIgnoreCollision)
{ {
return; return;
} }
} }*/
USkeletalMeshComponent* SkeleMesh = nullptr; USkeletalMeshComponent* SkeleMesh = nullptr;
USkeletalMeshComponent* SkeleMesh2 = nullptr; USkeletalMeshComponent* SkeleMesh2 = nullptr;

View file

@ -295,6 +295,9 @@ void UVREPhysicalAnimationComponent::UpdateWeldedBoneDriver(float DeltaTime)
FTransform GlobalTransform = WeldedData->RelativeTransform * Trans; FTransform GlobalTransform = WeldedData->RelativeTransform * Trans;
FTransform RelativeTM = GlobalTransform * GlobalPoseInv; FTransform RelativeTM = GlobalTransform * GlobalPoseInv;
// Fix chaos ensure
RelativeTM.RemoveScaling();
if (!WeldedData->LastLocal.Equals(RelativeTM)) if (!WeldedData->LastLocal.Equals(RelativeTM))
{ {
FPhysicsInterface::SetLocalTransform(Shape, RelativeTM); FPhysicsInterface::SetLocalTransform(Shape, RelativeTM);

View file

@ -3,6 +3,8 @@
#include "Misc/VRLogComponent.h" #include "Misc/VRLogComponent.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(VRLogComponent) #include UE_INLINE_GENERATED_CPP_BY_NAME(VRLogComponent)
#include "GlobalRenderResources.h"
//#include "Engine/Engine.h" //#include "Engine/Engine.h"
/* Top of File */ /* Top of File */
@ -88,9 +90,8 @@ bool UVRLogComponent::DrawConsoleToRenderTarget2D(EBPVRConsoleDrawType DrawType,
// Create the FCanvas which does the actual rendering. // Create the FCanvas which does the actual rendering.
//const ERHIFeatureLevel::Type FeatureLevel = World != nullptr ? World->FeatureLevel : GMaxRHIFeatureLevel; //const ERHIFeatureLevel::Type FeatureLevel = World != nullptr ? World->FeatureLevel : GMaxRHIFeatureLevel;
FCanvas * RenderCanvas = new FCanvas( FCanvas * RenderCanvas = new FCanvas(
Texture->GameThread_GetRenderTargetResource(), (FRenderTarget*)Texture->GameThread_GetRenderTargetResource(),
nullptr, nullptr,
World, World,
World->GetFeatureLevel(), World->GetFeatureLevel(),

View file

@ -7,6 +7,9 @@
#include "GameFramework/PlayerState.h" #include "GameFramework/PlayerState.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "Engine/TextureRenderTarget2D.h" #include "Engine/TextureRenderTarget2D.h"
#include "Engine/Texture2D.h"
#include "TextureResource.h"
#include "CanvasTypes.h"
#include "Kismet/KismetMathLibrary.h" #include "Kismet/KismetMathLibrary.h"
#include "Kismet/KismetRenderingLibrary.h" #include "Kismet/KismetRenderingLibrary.h"
#include "Engine/CanvasRenderTarget2D.h" #include "Engine/CanvasRenderTarget2D.h"
@ -1466,6 +1469,7 @@ void RLE_Funcs::RLEWriteRunFlag(uint32 count, uint8** loc, TArray<DataType>& Dat
Data.Empty(256); Data.Empty(256);
} }
template <typename DataType> template <typename DataType>
bool RLE_Funcs::RLEEncodeBuffer(DataType* BufferToEncode, uint32 EncodeLength, TArray<uint8>* EncodedLine) bool RLE_Funcs::RLEEncodeBuffer(DataType* BufferToEncode, uint32 EncodeLength, TArray<uint8>* EncodedLine)
{ {
@ -1633,15 +1637,17 @@ bool RLE_Funcs::RLEEncodeBuffer(DataType* BufferToEncode, uint32 EncodeLength, T
return true; return true;
// Skipping non compressed for now, the overhead is so low that it isn't worth supporting since the last revision // Skipping non compressed for now, the overhead is so low that it isn't worth supporting since the last revision
/*
if (Wrote > OrigNum * incr) if (Wrote > OrigNum * incr)
{ {
EncodedLine->Empty(OrigNum * incr); EncodedLine->Empty(OrigNum * incr);
EncodedLine->AddUninitialized(OrigNum * incr); EncodedLine->AddUninitialized(OrigNum * incr);
FMemory::Memcpy(EncodedLine->GetData(), BufferToEncode/*LineToEncode->GetData()*/, OrigNum * incr); FMemory::Memcpy(EncodedLine->GetData(), BufferToEncode, OrigNum * incr);
return false; // Return that there was no compression, so the decoder can receive it later return false; // Return that there was no compression, so the decoder can receive it later
} }
else else
return true; return true;
*/
} }
template<int32 ScaleFactor, int32 MaxBitsPerComponent> template<int32 ScaleFactor, int32 MaxBitsPerComponent>

View file

@ -146,7 +146,7 @@ bool UReplicatedVRCameraComponent::HasTrackingParameters()
void UReplicatedVRCameraComponent::ApplyTrackingParameters(FVector &OriginalPosition, bool bSkipLocZero) void UReplicatedVRCameraComponent::ApplyTrackingParameters(FVector &OriginalPosition, bool bSkipLocZero)
{ {
// I'm keeping the original values here as it lets me send them out for seated mode // I'm keeping the original values here as it lets me send them out for seated mode
if (!bSkipLocZero /*&& ((AttachChar && !AttachChar->bRetainRoomscale))*/) if (!bSkipLocZero && (AttachChar && !AttachChar->bRetainRoomscale))
{ {
OriginalPosition.X = 0; OriginalPosition.X = 0;
OriginalPosition.Y = 0; OriginalPosition.Y = 0;

View file

@ -3,6 +3,7 @@
#include "VRBPDatatypes.h" #include "VRBPDatatypes.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(VRBPDatatypes) #include UE_INLINE_GENERATED_CPP_BY_NAME(VRBPDatatypes)
#include "HAL/IConsoleManager.h"
#include "Chaos/ChaosEngineInterface.h" #include "Chaos/ChaosEngineInterface.h"
namespace VRDataTypeCVARs namespace VRDataTypeCVARs

View file

@ -1000,6 +1000,14 @@ bool UVRBaseCharacterMovementComponent::DoMASnapTurn(FVRMoveActionContainer& Mov
bool bRotateAroundCapsule = MoveAction.MoveActionFlags & 0x08; bool bRotateAroundCapsule = MoveAction.MoveActionFlags & 0x08;
// Clamp to 2 decimal precision
/*TargetRot = TargetRot.Clamp();
TargetRot.Pitch = (TargetRot.Pitch * 100.f) / 100.f;
TargetRot.Yaw = (TargetRot.Yaw * 100.f) / 100.f;
TargetRot.Roll = (TargetRot.Roll * 100.f) / 100.f;
TargetRot.Normalize();*/
bIsBlendingOrientation = true;
if (this->BaseVRCharacterOwner && this->BaseVRCharacterOwner->IsLocallyControlled()) if (this->BaseVRCharacterOwner && this->BaseVRCharacterOwner->IsLocallyControlled())
{ {
if (this->bUseClientControlRotation) if (this->bUseClientControlRotation)
@ -1076,6 +1084,15 @@ bool UVRBaseCharacterMovementComponent::DoMASetRotation(FVRMoveActionContainer&
FTransform OriginalRelativeTrans = BaseVRCharacterOwner->GetRootComponent()->GetRelativeTransform(); FTransform OriginalRelativeTrans = BaseVRCharacterOwner->GetRootComponent()->GetRelativeTransform();
FRotator TargetRot(0.f, MoveAction.MoveActionRot.Yaw, 0.f); FRotator TargetRot(0.f, MoveAction.MoveActionRot.Yaw, 0.f);
// Clamp to 2 decimal precision
/*TargetRot = TargetRot.Clamp();
TargetRot.Pitch = (TargetRot.Pitch * 100.f) / 100.f;
TargetRot.Yaw = (TargetRot.Yaw * 100.f) / 100.f;
TargetRot.Roll = (TargetRot.Roll * 100.f) / 100.f;
TargetRot.Normalize();*/
bIsBlendingOrientation = true;
if (this->BaseVRCharacterOwner && this->BaseVRCharacterOwner->IsLocallyControlled()) if (this->BaseVRCharacterOwner && this->BaseVRCharacterOwner->IsLocallyControlled())
{ {
if (this->bUseClientControlRotation) if (this->bUseClientControlRotation)
@ -1602,7 +1619,11 @@ void UVRBaseCharacterMovementComponent::OnClientCorrectionReceived(class FNetwor
if (BaseVRCharacterOwner) if (BaseVRCharacterOwner)
{ {
BaseVRCharacterOwner->OnCharacterNetworkCorrected_Bind.Broadcast(); BaseVRCharacterOwner->OnCharacterNetworkCorrected_Bind.Broadcast();
if(IsValid(BaseVRCharacterOwner->LeftMotionController))
BaseVRCharacterOwner->LeftMotionController->TeleportMoveGrips(false, false); BaseVRCharacterOwner->LeftMotionController->TeleportMoveGrips(false, false);
if (IsValid(BaseVRCharacterOwner->RightMotionController))
BaseVRCharacterOwner->RightMotionController->TeleportMoveGrips(false, false); BaseVRCharacterOwner->RightMotionController->TeleportMoveGrips(false, false);
//BaseVRCharacterOwner->NotifyOfTeleport(false); //BaseVRCharacterOwner->NotifyOfTeleport(false);
} }
@ -2227,14 +2248,32 @@ void UVRBaseCharacterMovementComponent::AutoTraceAndSetCharacterToNewGravity(FHi
if (TargetFloor.Component.IsValid()) if (TargetFloor.Component.IsValid())
{ {
// Should we really be tracing complex? (true should maybe be false?) // Should we really be tracing complex? (true should maybe be false?)
FCollisionQueryParams QueryParams(SCENE_QUERY_STAT(AutoTraceFloorNormal), /*true*/false); FCollisionQueryParams QueryParams(SCENE_QUERY_STAT(AutoTraceFloorNormal), /*true*/false, CharacterOwner);
FCollisionResponseParams ResponseParam;
InitCollisionParams(QueryParams, ResponseParam);
const ECollisionChannel CollisionChannel = UpdatedComponent->GetCollisionObjectType();
FVector TraceStart = BaseVRCharacterOwner->GetVRLocation_Inline(); FVector TraceStart = BaseVRCharacterOwner->GetVRLocation_Inline();
FVector Offset = (-UpdatedComponent->GetComponentQuat().GetUpVector()) * (BaseVRCharacterOwner->VRRootReference->GetScaledCapsuleHalfHeight() + 10.0f); FVector Offset = (-UpdatedComponent->GetComponentQuat().GetUpVector()) * (BaseVRCharacterOwner->VRRootReference->GetScaledCapsuleHalfHeight() + 10.0f);
FHitResult OutHit; FHitResult OutHit;
const bool bDidHit = TargetFloor.Component->LineTraceComponent(OutHit, TraceStart, TraceStart + Offset, QueryParams); //const bool bDidHit = TargetFloor.Component->LineTraceComponent(OutHit, TraceStart, TraceStart + Offset, QueryParams);
bool bDidHit = GetWorld()->LineTraceSingleByChannel(OutHit, TraceStart, TraceStart + Offset, CollisionChannel, QueryParams, ResponseParam);
if (!bDidHit)
{
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Yellow, TEXT("Didn't hit!"));
}
else
{
if (!IsWalkable(OutHit))
{
bDidHit = false;
}
}
//DrawDebugLine(GetWorld(), TraceStart, TraceStart + Offset, FColor::Red, true);
//DrawDebugCapsule(GetWorld(), BaseVRCharacterOwner->GetVRLocation(), BaseVRCharacterOwner->VRRootReference->GetScaledCapsuleHalfHeight(), 5.0f, BaseVRCharacterOwner->VRRootReference->GetComponentQuat(), FColor::Green, true);
if (bDidHit) if (bDidHit)
{ {
FVector NewGravityDir = -OutHit.Normal; FVector NewGravityDir = -OutHit.Normal;
@ -2250,17 +2289,18 @@ void UVRBaseCharacterMovementComponent::AutoTraceAndSetCharacterToNewGravity(FHi
if (bBlendGravityFloorChanges) if (bBlendGravityFloorChanges)
{ {
// Blend the angle over time // Blend the angle over time
const float Alpha = FMath::Clamp(DeltaTime * FloorOrientationChangeBlendRate, 0.f, 1.f); //const float Alpha = FMath::Clamp(DeltaTime * FloorOrientationChangeBlendRate, 0.f, 1.f);
NewGravityDir = FMath::Lerp(GetGravityDirection(), NewGravityDir, Alpha); //NewGravityDir = FMath::Lerp(GetGravityDirection(), NewGravityDir, Alpha);
//bIsBlendingOrientation = true;
} }
} }
SetCharacterToNewGravity(NewGravityDir, true); SetCharacterToNewGravity(NewGravityDir, true, DeltaTime);
} }
} }
} }
bool UVRBaseCharacterMovementComponent::SetCharacterToNewGravity(FVector NewGravityDirection, bool bOrientToNewGravity) bool UVRBaseCharacterMovementComponent::SetCharacterToNewGravity(FVector NewGravityDirection, bool bOrientToNewGravity, float DeltaTime)
{ {
// Ensure its normalized // Ensure its normalized
NewGravityDirection.Normalize(); NewGravityDirection.Normalize();
@ -2268,41 +2308,70 @@ bool UVRBaseCharacterMovementComponent::SetCharacterToNewGravity(FVector NewGrav
if (NewGravityDirection.Equals(GetGravityDirection())) if (NewGravityDirection.Equals(GetGravityDirection()))
return false; return false;
SetGravityDirection(NewGravityDirection); //SetGravityDirection(NewGravityDirection);
if (bOrientToNewGravity && IsValid(BaseVRCharacterOwner)) if (bOrientToNewGravity && IsValid(BaseVRCharacterOwner))
{ {
FQuat CurrentRotQ = UpdatedComponent->GetComponentQuat(); FQuat CurrentRotQ = UpdatedComponent->GetComponentQuat();
FQuat DeltaRot = FQuat::FindBetweenNormals(-CurrentRotQ.GetUpVector(), NewGravityDirection); FQuat DeltaRot = FQuat::FindBetweenNormals(-CurrentRotQ.GetUpVector(), NewGravityDirection);
FRotator NewRot = (DeltaRot * CurrentRotQ)/*.GetNormalized()*/.Rotator();
if (bBlendGravityFloorChanges)
{
// Blend the angle over time
const float Alpha = FMath::Clamp(DeltaTime * FloorOrientationChangeBlendRate, 0.f, 1.f);
DeltaRot = FQuat::Slerp(FQuat::Identity, DeltaRot, Alpha);
//NewGravityDir = FMath::Lerp(GetGravityDirection(), NewGravityDir, Alpha);
bIsBlendingOrientation = true;
}
FQuat NewRot = (DeltaRot * CurrentRotQ);
NewRot.Normalize();
NewGravityDirection = -NewRot.GetUpVector();
AController* OwningController = BaseVRCharacterOwner->GetController(); AController* OwningController = BaseVRCharacterOwner->GetController();
FVector NewLocation; float PivotZ = BaseVRCharacterOwner->bRetainRoomscale ? 0.0f : -BaseVRCharacterOwner->VRRootReference->GetUnscaledCapsuleHalfHeight();
FRotator NewRotation; FQuat NewRotation = NewRot;
FVector OrigLocation = BaseVRCharacterOwner->GetActorLocation();
FVector PivotPoint = BaseVRCharacterOwner->GetActorTransform().InverseTransformPosition(BaseVRCharacterOwner->GetVRLocation_Inline());
//(bRotateAroundCapsule ? GetVRLocation_Inline() : BaseVRCharacterOwner->GetProjectedVRLocation());
// Clamp to 2 decimal precision
/*NewRotation = NewRotation.Clamp();
//NewRotation.Pitch = (NewRotation.Pitch * 100.f) / 100.f;
//NewRotation.Yaw = (NewRotation.Yaw * 100.f) / 100.f;
//NewRotation.Roll = (NewRotation.Roll * 100.f) / 100.f;*/
//NewRotation.Normalize();
// Offset to the floor FTransform BaseTransform = BaseVRCharacterOwner->VRRootReference->GetComponentTransform();
//PivotPoint.Z = -BaseVRCharacterOwner->VRRootReference->GetUnscaledCapsuleHalfHeight(); FVector PivotPoint = BaseTransform.TransformPosition(FVector(0.0f, 0.0f, PivotZ));
PivotPoint.Z = 0.0f;
// Need to seperate out each element for the control rotation //DrawDebugSphere(GetWorld(), BaseVRCharacterOwner->GetVRLocation(), 10.0f, 12.0f, FColor::White, true);
FRotator OrigRotation = BaseVRCharacterOwner->bUseControllerRotationYaw && OwningController ? OwningController->GetControlRotation() : BaseVRCharacterOwner->GetActorRotation(); //DrawDebugSphere(GetWorld(), PivotPoint, 10.0f, 12.0f, FColor::Orange, true);
NewRotation = NewRot; FVector BasePoint = PivotPoint; // Get our pivot point
const FTransform PivotToWorld = FTransform(FQuat::Identity, BasePoint);
const FTransform WorldToPivot = FTransform(FQuat::Identity, -BasePoint);
NewLocation = OrigLocation + OrigRotation.RotateVector(PivotPoint); // Rebase the world transform to the pivot point, add the rotation, remove the pivot point rebase
//NewRotation = NewRot; FTransform NewTransform = BaseTransform * WorldToPivot * FTransform(DeltaRot, FVector::ZeroVector, FVector(1.0f)) * PivotToWorld;
NewLocation -= NewRotation.RotateVector(PivotPoint);
if (BaseVRCharacterOwner->bUseControllerRotationYaw && OwningController) //FVector NewLoc = BaseVRCharacterOwner->VRRootReference->OffsetComponentToWorld.InverseTransformPosition(PivotPoint);
OwningController->SetControlRotation(NewRotation); //GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("NewLoc %s"), *NewLoc.ToString()));
//DrawDebugLine(GetWorld(), OrigLocation, OrigLocation + ((-NewGravityDirection) * 40.0f), FColor::Red, true);
// Also setting actor rot because the control rot transfers to it anyway eventually // Also setting actor rot because the control rot transfers to it anyway eventually
MoveUpdatedComponent(NewLocation - OrigLocation, NewRotation, /*bSweep*/ false); MoveUpdatedComponent(NewTransform.GetLocation()/*NewLocation*/ - BaseTransform.GetLocation(), NewRotation, /*bSweep*/ false);
//BaseVRCharacterOwner->SetActorLocationAndRotation(NewLocation, NewRotation);
if (BaseVRCharacterOwner->bUseControllerRotationYaw && OwningController)
OwningController->SetControlRotation(NewRotation.Rotator());
SetGravityDirection(NewGravityDirection);
return true;
}
else
{
SetGravityDirection(NewGravityDirection);
return true; return true;
} }

View file

@ -29,6 +29,7 @@
#include "Engine/DemoNetDriver.h" #include "Engine/DemoNetDriver.h"
#include "Engine/NetworkObjectList.h" #include "Engine/NetworkObjectList.h"
#include "UObject/Package.h"
#include "VRRootComponent.h" #include "VRRootComponent.h"
#include "WorldCollision.h" #include "WorldCollision.h"
@ -84,6 +85,14 @@ namespace CharacterMovementComponentStatics
TEXT("Error threshold value before correcting a clients rotation.\n") TEXT("Error threshold value before correcting a clients rotation.\n")
TEXT("Rotation is replicated at 2 decimal precision, so values less than 0.01 won't matter."), TEXT("Rotation is replicated at 2 decimal precision, so values less than 0.01 won't matter."),
ECVF_Default); ECVF_Default);
static float fRotationChangingCorrectionThreshold = 0.3f;
FAutoConsoleVariableRef CVarRotationChangingCorrectionThreshold(
TEXT("vre.RotationChangingCorrectionThreshold"),
fRotationChangingCorrectionThreshold,
TEXT("Error threshold value before correcting a clients rotation when actively changing rotation.\n")
TEXT("Rotation is replicated at 2 decimal precision, so values less than 0.01 won't matter."),
ECVF_Default);
} }
void UVRCharacterMovementComponent::StoreSetTrackingPaused(bool bNewTrackingPaused) void UVRCharacterMovementComponent::StoreSetTrackingPaused(bool bNewTrackingPaused)
@ -649,7 +658,8 @@ void UVRCharacterMovementComponent::ServerMove_PerformMovement(const FCharacterN
// Validate move only after old and first dual portion, after all moves are completed. // Validate move only after old and first dual portion, after all moves are completed.
if (MoveData.NetworkMoveType == FCharacterNetworkMoveData::ENetworkMoveType::NewMove) if (MoveData.NetworkMoveType == FCharacterNetworkMoveData::ENetworkMoveType::NewMove)
{ {
ServerMoveHandleClientErrorVR(ClientTimeStamp, DeltaTime, ClientAccel, MoveData.Location, ClientControlRotation.Yaw, MoveData.MovementBase, MoveData.MovementBaseBoneName, MoveData.MovementMode); ServerMoveHandleClientErrorVR(ClientTimeStamp, DeltaTime, ClientAccel, MoveData.Location, ClientControlRotation, MoveData.MovementBase, MoveData.MovementBaseBoneName, MoveData.MovementMode);
//ServerMoveHandleClientErrorVR(ClientTimeStamp, DeltaTime, ClientAccel, MoveData.Location, ClientControlRotation.Yaw, MoveData.MovementBase, MoveData.MovementBaseBoneName, MoveData.MovementMode);
//ServerMoveHandleClientError(ClientTimeStamp, DeltaTime, ClientAccel, MoveData.Location, MoveData.MovementBase, MoveData.MovementBaseBoneName, MoveData.MovementMode); //ServerMoveHandleClientError(ClientTimeStamp, DeltaTime, ClientAccel, MoveData.Location, MoveData.MovementBase, MoveData.MovementBaseBoneName, MoveData.MovementMode);
} }
} }
@ -1922,7 +1932,7 @@ bool UVRCharacterMovementComponent::StepUp(const FVector& GravDir, const FVector
{ {
// Auto Align to the new floor normal // Auto Align to the new floor normal
// Set gravity direction to the new floor normal, don't blend the change, snap to it on a step up // Set gravity direction to the new floor normal, don't blend the change, snap to it on a step up
AutoTraceAndSetCharacterToNewGravity(StepDownResult.FloorResult.HitResult, 0.0f); AutoTraceAndSetCharacterToNewGravity(StepDownResult.FloorResult.HitResult);
} }
} }
} }
@ -2163,7 +2173,7 @@ bool UVRCharacterMovementComponent::VRClimbStepUp(const FVector& GravDir, const
{ {
// Auto Align to the new floor normal // Auto Align to the new floor normal
// Set gravity direction to the new floor normal, don't blend the change, snap to it on a step down // Set gravity direction to the new floor normal, don't blend the change, snap to it on a step down
AutoTraceAndSetCharacterToNewGravity(StepDownResult.FloorResult.HitResult, 0.0f); AutoTraceAndSetCharacterToNewGravity(StepDownResult.FloorResult.HitResult);
} }
} }
} }
@ -4159,7 +4169,7 @@ void UVRCharacterMovementComponent::ClientAdjustPositionVR_Implementation
// Auto Align to the new floor normal // Auto Align to the new floor normal
// Set gravity direction to the new floor normal, snap to new rotation on correction // Set gravity direction to the new floor normal, snap to new rotation on correction
// #TODO: Might need to entirely remove this and let the correction set everything? // #TODO: Might need to entirely remove this and let the correction set everything?
AutoTraceAndSetCharacterToNewGravity(CurrentFloor.HitResult, 0.0f); AutoTraceAndSetCharacterToNewGravity(CurrentFloor.HitResult);
}*/ }*/
} }
} }
@ -4180,13 +4190,40 @@ void UVRCharacterMovementComponent::ClientAdjustPositionVR_Implementation
ClientData->bUpdatePosition = true; ClientData->bUpdatePosition = true;
} }
bool UVRCharacterMovementComponent::ServerCheckClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& ClientWorldLocation, float ClientYaw, const FVector& RelativeClientLocation, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode) bool UVRCharacterMovementComponent::ServerCheckClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& ClientWorldLocation, FRotator ClientRot, const FVector& RelativeClientLocation, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode)
{ {
// Check location difference against global setting // Check location difference against global setting
if (!bIgnoreClientMovementErrorChecksAndCorrection) if (!bIgnoreClientMovementErrorChecksAndCorrection)
{ {
//const FVector LocDiff = UpdatedComponent->GetComponentLocation() - ClientWorldLocation; //const FVector LocDiff = UpdatedComponent->GetComponentLocation() - ClientWorldLocation;
// If we are rolling back client rotation
//if (!bUseClientControlRotation && !FMath::IsNearlyEqual(FRotator::ClampAxis(ClientYaw), FRotator::ClampAxis(UpdatedComponent->GetComponentRotation().Yaw), CharacterMovementComponentStatics::fRotationCorrectionThreshold))
if (!bUseClientControlRotation)
{
// If we are using default gravity direction just match to the yaw only for now (less precision errors)
if (GetGravityDirection().Equals(DefaultGravityDirection))
{
if (!FMath::IsNearlyEqual(FRotator::ClampAxis(ClientRot.Yaw), FRotator::ClampAxis(UpdatedComponent->GetComponentRotation().Yaw), CharacterMovementComponentStatics::fRotationCorrectionThreshold))
{
return true;
}
}
else
{
float CorrectionValue = bIsBlendingOrientation ? CharacterMovementComponentStatics::fRotationChangingCorrectionThreshold : CharacterMovementComponentStatics::fRotationCorrectionThreshold;
bIsBlendingOrientation = false;
if (FQuat::ErrorAutoNormalize(UpdatedComponent->GetComponentQuat(), ClientRot.Quaternion()) > CorrectionValue)
{
return true;
}
}
}
#if ROOT_MOTION_DEBUG #if ROOT_MOTION_DEBUG
if (RootMotionSourceDebug::CVarDebugRootMotionSources.GetValueOnAnyThread() == 1) if (RootMotionSourceDebug::CVarDebugRootMotionSources.GetValueOnAnyThread() == 1)
{ {
@ -4225,16 +4262,10 @@ bool UVRCharacterMovementComponent::ServerCheckClientErrorVR(float ClientTimeSta
#endif // !UE_BUILD_SHIPPING #endif // !UE_BUILD_SHIPPING
} }
// If we are rolling back client rotation
if (!bUseClientControlRotation && !FMath::IsNearlyEqual(FRotator::ClampAxis(ClientYaw), FRotator::ClampAxis(UpdatedComponent->GetComponentRotation().Yaw), CharacterMovementComponentStatics::fRotationCorrectionThreshold))
{
return true;
}
return false; return false;
} }
void UVRCharacterMovementComponent::ServerMoveHandleClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& RelativeClientLoc, float ClientYaw, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode) void UVRCharacterMovementComponent::ServerMoveHandleClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& RelativeClientLoc, FRotator ClientRot, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode)
{ {
if (!ShouldUsePackedMovementRPCs()) if (!ShouldUsePackedMovementRPCs())
{ {
@ -4455,7 +4486,7 @@ void UVRCharacterMovementComponent::ServerMoveHandleClientErrorVR(float ClientTi
// Compute the client error from the server's position // Compute the client error from the server's position
// If client has accumulated a noticeable positional error, correct them. // If client has accumulated a noticeable positional error, correct them.
bNetworkLargeClientCorrection = ServerData->bForceClientUpdate; bNetworkLargeClientCorrection = ServerData->bForceClientUpdate;
if (!bInClientAuthoritativeMovementMode && (ServerData->bForceClientUpdate || (!bFallingWithinAcceptableError && ServerCheckClientErrorVR(ClientTimeStamp, DeltaTime, Accel, ClientLoc, ClientYaw, RelativeClientLoc, ClientMovementBase, ClientBaseBoneName, ClientMovementMode)))) if (!bInClientAuthoritativeMovementMode && (ServerData->bForceClientUpdate || (!bFallingWithinAcceptableError && ServerCheckClientErrorVR(ClientTimeStamp, DeltaTime, Accel, ClientLoc, ClientRot, RelativeClientLoc, ClientMovementBase, ClientBaseBoneName, ClientMovementMode))))
{ {
//UPrimitiveComponent* MovementBase = CharacterOwner->GetMovementBase(); //UPrimitiveComponent* MovementBase = CharacterOwner->GetMovementBase();
ServerData->PendingAdjustment.NewVel = Velocity; ServerData->PendingAdjustment.NewVel = Velocity;

View file

@ -108,9 +108,6 @@ FTransform UVRGlobalSettings::AdjustTransformByGivenControllerProfile(UPARAM(ref
{ {
// Use currently loaded transform // Use currently loaded transform
return SocketTransform * (((bIsRightHand && ControllerProfile.bUseSeperateHandOffsetTransforms) ? ControllerProfile.SocketOffsetTransformRightHand : ControllerProfile.SocketOffsetTransform)); return SocketTransform * (((bIsRightHand && ControllerProfile.bUseSeperateHandOffsetTransforms) ? ControllerProfile.SocketOffsetTransformRightHand : ControllerProfile.SocketOffsetTransform));
// Couldn't find it, return base transform
return SocketTransform;
} }
TArray<FBPVRControllerProfile> UVRGlobalSettings::GetControllerProfiles() TArray<FBPVRControllerProfile> UVRGlobalSettings::GetControllerProfiles()

View file

@ -7,6 +7,8 @@
//#include "WorldCollision.h" //#include "WorldCollision.h"
#include "PhysicsPublic.h" #include "PhysicsPublic.h"
#include "Engine/ScopedMovementUpdate.h" #include "Engine/ScopedMovementUpdate.h"
#include "SceneManagement.h"
#include "PrimitiveSceneProxy.h"
//#include "DrawDebugHelpers.h" //#include "DrawDebugHelpers.h"
#include "IHeadMountedDisplay.h" #include "IHeadMountedDisplay.h"
#include "IXRTrackingSystem.h" #include "IXRTrackingSystem.h"

View file

@ -12,6 +12,7 @@
#include "TextureResource.h" #include "TextureResource.h"
#include "Engine/Texture.h" #include "Engine/Texture.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "SceneManagement.h"
#include "Materials/Material.h" #include "Materials/Material.h"
#include "IStereoLayers.h" #include "IStereoLayers.h"
#include "IHeadMountedDisplay.h" #include "IHeadMountedDisplay.h"

View file

@ -4,6 +4,8 @@
#include UE_INLINE_GENERATED_CPP_BY_NAME(VRTrackedParentInterface) #include UE_INLINE_GENERATED_CPP_BY_NAME(VRTrackedParentInterface)
#include "UObject/Interface.h" #include "UObject/Interface.h"
#include "Components/PrimitiveComponent.h"
#include "Components/SceneComponent.h"
#include "VRBPDatatypes.h" #include "VRBPDatatypes.h"
UVRTrackedParentInterface::UVRTrackedParentInterface(const class FObjectInitializer& ObjectInitializer) UVRTrackedParentInterface::UVRTrackedParentInterface(const class FObjectInitializer& ObjectInitializer)

View file

@ -115,6 +115,7 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data")
FName SlotPrefix; FName SlotPrefix;
// If true the hand meshes relative transform will be de-coupled from the hand socket // If true the hand meshes relative transform will be de-coupled from the hand socket
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Hand Socket Data") UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Hand Socket Data")
bool bDecoupleMeshPlacement; bool bDecoupleMeshPlacement;
@ -147,21 +148,30 @@ public:
bool bOnlyFlipRotation; bool bOnlyFlipRotation;
// If true then this hand socket will always be considered "in range" and checked against others for lowest distance // If true then this hand socket will always be considered "in range" and checked against others for lowest distance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data|Searching")
bool bAlwaysInRange; bool bAlwaysInRange;
// If true and there are multiple hand socket components in range with this setting // If true and there are multiple hand socket components in range with this setting
// Then the default behavior will compare closest rotation on them all to pick one // Then the default behavior will compare closest rotation on them all to pick one
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data|Searching")
bool bMatchRotation; bool bMatchRotation;
// If true then the hand socket will not be considered for search operations // If true then the hand socket will not be considered for search operations
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data|Control")
bool bDisabled; bool bDisabled;
/***
/* If true then the hand socket will be locked in place during gameplay and not moved with the actor (saving performance)
/* Generally you want this unless you are moving a hand socket manually during play for custom grip offsetting logic
/* If you need the relative location of the hand socket for game logic, get the LockedRelativeTransform variable if bLockInPlace is enabled.
/* Defaulted off currently for bug testing
***/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Hand Socket Data|Control")
bool bLockInPlace;
// Snap distance to use if you want to override the defaults. // Snap distance to use if you want to override the defaults.
// Will be ignored if == 0.0f or bAlwaysInRange is true // Will be ignored if == 0.0f or bAlwaysInRange is true
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data|Searching")
float OverrideDistance; float OverrideDistance;
// If true we are expected to have a list of custom deltas for bones to overlay onto our base pose // If true we are expected to have a list of custom deltas for bones to overlay onto our base pose
@ -178,20 +188,20 @@ public:
TObjectPtr<UAnimSequence> HandTargetAnimation; TObjectPtr<UAnimSequence> HandTargetAnimation;
// Scale to apply when mirroring the hand, adjust to visualize your off hand correctly // Scale to apply when mirroring the hand, adjust to visualize your off hand correctly
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data|Mirroring")
FVector MirroredScale; FVector MirroredScale;
#if WITH_EDITORONLY_DATA #if WITH_EDITORONLY_DATA
// If true we will attempt to only show editing widgets for bones matching the _l or _r postfixes // If true we will attempt to only show editing widgets for bones matching the _l or _r postfixes
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation|Misc")
bool bFilterBonesByPostfix; bool bFilterBonesByPostfix;
// The postfix to filter by // The postfix to filter by
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation|Misc")
FString FilterPostfix; FString FilterPostfix;
// An array of bones to skip when looking to edit deltas, can help clean up the interaction if you have extra bones in the heirarchy // An array of bones to skip when looking to edit deltas, can help clean up the interaction if you have extra bones in the heirarchy
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation|Misc")
TArray<FName> BonesToSkip; TArray<FName> BonesToSkip;
FTransform GetBoneTransformAtTime(UAnimSequence* MyAnimSequence, /*float AnimTime,*/ int BoneIdx, FName BoneName, bool bUseRawDataOnly); FTransform GetBoneTransformAtTime(UAnimSequence* MyAnimSequence, /*float AnimTime,*/ int BoneIdx, FName BoneName, bool bUseRawDataOnly);

View file

@ -224,7 +224,6 @@ public:
*/ */
float GetDistanceAlongSplineAtSplineInputKey(float InKey) const; float GetDistanceAlongSplineAtSplineInputKey(float InKey) const;
// Calculates the current slider progress // Calculates the current slider progress
UFUNCTION(BlueprintCallable, Category = "VRSliderComponent") UFUNCTION(BlueprintCallable, Category = "VRSliderComponent")
float CalculateSliderProgress(); float CalculateSliderProgress();
@ -245,6 +244,11 @@ public:
void GetLerpedKey(float &ClosestKey, float DeltaTime); void GetLerpedKey(float &ClosestKey, float DeltaTime);
float GetCurrentSliderProgress(FVector CurLocation, bool bUseKeyInstead = false, float CurKey = 0.f); float GetCurrentSliderProgress(FVector CurLocation, bool bUseKeyInstead = false, float CurKey = 0.f);
// Returns the slider progress as it is currently per axis (not the total progress, just the amount per axis that has a min/max)
UFUNCTION(BlueprintCallable, Category = "VRSliderComponent")
FVector GetPerAxisSliderProgress();
FVector ClampSlideVector(FVector ValueToClamp); FVector ClampSlideVector(FVector ValueToClamp);
// ------------------------------------------------ // ------------------------------------------------

View file

@ -117,11 +117,11 @@ public:
FORCEINLINE bool operator==(const FCollisionPrimPair& Other) const FORCEINLINE bool operator==(const FCollisionPrimPair& Other) const
{ {
/*if (!Prim1.IsValid() || !Prim2.IsValid()) if (!IsValid(Prim1) || !IsValid(Prim2))
return false; return false;
if (!Other.Prim1.IsValid() || !Other.Prim2.IsValid()) if (!IsValid(Other.Prim1) || !IsValid(Other.Prim2))
return false;*/ return false;
return( return(
(Prim1.Get() == Other.Prim1.Get() || Prim1.Get() == Other.Prim2.Get()) && (Prim1.Get() == Other.Prim1.Get() || Prim1.Get() == Other.Prim2.Get()) &&

View file

@ -3,8 +3,12 @@
#pragma once #pragma once
#include "Engine/GameViewportClient.h" #include "Engine/GameViewportClient.h"
//#include "Engine/Engine.h" //#include "Engine/Engine.h"
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "InputKeyEventArgs.h"
#include "Engine/World.h"
#include "Engine/GameInstance.h"
#include "VRGameViewportClient.generated.h" #include "VRGameViewportClient.generated.h"

View file

@ -79,11 +79,17 @@ public:
float FloorOrientationChangeBlendRate = 25.0f; float FloorOrientationChangeBlendRate = 25.0f;
// Sets the value of bAutoOrientToFloorNormal in a manner that cleans up when removed // Sets the value of bAutoOrientToFloorNormal in a manner that cleans up when removed
UFUNCTION(BlueprintCallable, Category = "BaseVRCharacterMovementComponent|VRLocations") UFUNCTION(BlueprintCallable, Category = "BaseVRCharacterMovementComponent|Wall Walking")
void SetAutoOrientToFloorNormal(bool bAutoOrient, bool bRevertGravityWhenDisabled = true); void SetAutoOrientToFloorNormal(bool bAutoOrient, bool bRevertGravityWhenDisabled = true);
void AutoTraceAndSetCharacterToNewGravity(FHitResult & TargetFloor, float DeltaTime); // Store if our current movement was blending rotation
bool SetCharacterToNewGravity(FVector NewGravityDirection, bool bOrientToNewGravity = true); bool bIsBlendingOrientation = false;
void AutoTraceAndSetCharacterToNewGravity(FHitResult & TargetFloor, float DeltaTime = 1.0f);
// Directly set new gravity (does not replicate, move action is preferrable)
UFUNCTION(BlueprintCallable, Category = "BaseVRCharacterMovementComponent|Wall Walking")
bool SetCharacterToNewGravity(FVector NewGravityDirection, bool bOrientToNewGravity = true, float Deltatime = 1.0f);
// Adding seated transition // Adding seated transition
void OnMovementModeChanged(EMovementMode PreviousMovementMode, uint8 PreviousCustomMode) override; void OnMovementModeChanged(EMovementMode PreviousMovementMode, uint8 PreviousCustomMode) override;

View file

@ -134,13 +134,13 @@ public:
* RelativeClientLocation will be a relative location if MovementBaseUtility::UseRelativePosition(ClientMovementBase) is true, or a world location if false. * RelativeClientLocation will be a relative location if MovementBaseUtility::UseRelativePosition(ClientMovementBase) is true, or a world location if false.
* @see ServerCheckClientError() * @see ServerCheckClientError()
*/ */
virtual void ServerMoveHandleClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& RelativeClientLocation, float ClientYaw, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode); virtual void ServerMoveHandleClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& RelativeClientLocation, FRotator ClientRot, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode);
/** /**
* Check for Server-Client disagreement in position or other movement state important enough to trigger a client correction. * Check for Server-Client disagreement in position or other movement state important enough to trigger a client correction.
* @see ServerMoveHandleClientError() * @see ServerMoveHandleClientError()
*/ */
virtual bool ServerCheckClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& ClientWorldLocation, float ClientYaw, const FVector& RelativeClientLocation, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode); virtual bool ServerCheckClientErrorVR(float ClientTimeStamp, float DeltaTime, const FVector& Accel, const FVector& ClientWorldLocation, FRotator ClientRot, const FVector& RelativeClientLocation, UPrimitiveComponent* ClientMovementBase, FName ClientBaseBoneName, uint8 ClientMovementMode);
/** Replicate position correction to client, associated with a timestamped servermove. Client will replay subsequent moves after applying adjustment. */ /** Replicate position correction to client, associated with a timestamped servermove. Client will replay subsequent moves after applying adjustment. */
virtual void ClientAdjustPositionVR_Implementation(float TimeStamp, FVector NewLoc, /*uint16 NewYaw,*/ FVector NewVel, UPrimitiveComponent* NewBase, FName NewBaseBoneName, bool bHasBase, bool bBaseRelativePosition, uint8 ServerMovementMode, TOptional<FRotator> OptionalRotation = TOptional<FRotator>(), TOptional<FVector> OptionalGravityDirection = TOptional<FVector>()); virtual void ClientAdjustPositionVR_Implementation(float TimeStamp, FVector NewLoc, /*uint16 NewYaw,*/ FVector NewVel, UPrimitiveComponent* NewBase, FName NewBaseBoneName, bool bHasBase, bool bBaseRelativePosition, uint8 ServerMovementMode, TOptional<FRotator> OptionalRotation = TOptional<FRotator>(), TOptional<FVector> OptionalGravityDirection = TOptional<FVector>());

View file

@ -17,7 +17,9 @@
"SupportedTargetPlatforms": [ "SupportedTargetPlatforms": [
"Win64", "Win64",
"Linux", "Linux",
"Android" "Android",
"Mac",
"IOS"
], ],
"Modules": [ "Modules": [
{ {

View file

@ -26,7 +26,9 @@
"SupportedTargetPlatforms": [ "SupportedTargetPlatforms": [
"Win64", "Win64",
"Linux", "Linux",
"Android" "Android",
"Mac",
"IOS"
] ]
}, },
{ {
@ -39,7 +41,9 @@
"SupportedTargetPlatforms": [ "SupportedTargetPlatforms": [
"Win64", "Win64",
"Linux", "Linux",
"Android" "Android",
"Mac",
"IOS"
] ]
}, },
{ {