Updated pluigin so that it correctly gets your hand and tracking offset

This commit is contained in:
olav
2025-04-17 13:58:55 +02:00
parent a35f8e2cef
commit 936f2cb020
14 changed files with 177 additions and 55 deletions
@@ -107,7 +107,7 @@ TWeakObjectPtr<UAnimSequence> FHandSocketComponentDetails::SaveAnimationAsset(co
if (!BaseAnimation)
{
LocalPoses = HandSocketComponent->VisualizationMesh->GetSkeleton()->GetRefLocalPoses();
LocalPoses = HandSocketComponent->VisualizationMesh->GetRefSkeleton().GetRefBonePose();
}
// If not, create new one now.
@@ -251,7 +251,7 @@ TWeakObjectPtr<UAnimSequence> FHandSocketComponentDetails::SaveAnimationAsset(co
int32 BoneIndex = BoneTreeIndex;//AnimSkeleton->GetMeshBoneIndexFromSkeletonBoneIndex(SkeletalMesh, BoneTreeIndex);
//int32 ParentIndex = SkeletalMesh->RefSkeleton.GetParentIndex(BoneIndex);
FTransform LocalTransform = LocalPoses[BoneIndex];
//FTransform LocalTransform = RefSkeleton.GetRefBonePose()[BoneIndex];
FName BoneName = AnimSkeleton->GetReferenceSkeleton().GetBoneName(BoneIndex);
@@ -393,13 +393,22 @@ void UGripMotionControllerComponent::GetCurrentProfileTransform(bool bBindToNoti
FTransform NewControllerProfileTransform = FTransform::Identity;
if (HandType == EControllerHand::Left || HandType == EControllerHand::AnyHand || !VRSettings->bUseSeperateHandTransforms)
if (UEnum::GetDisplayValueAsText(HandType).ToString().Contains("Left")/*HandType == EControllerHand::Left*/ || HandType == EControllerHand::AnyHand || !VRSettings->bUseSeperateHandTransforms)
{
NewControllerProfileTransform = VRSettings->CurrentControllerProfileTransform;
FString message = FString::Printf(TEXT("Loaded left offsets! tracker source is %s "), *UEnum::GetDisplayValueAsText(HandType).ToString());
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, *message);
}
else if (HandType == EControllerHand::Right)
else if (UEnum::GetDisplayValueAsText(HandType).ToString().Contains("Right"))//HandType == EControllerHand::Right)
{
NewControllerProfileTransform = VRSettings->CurrentControllerProfileTransformRight;
FString message = FString::Printf(TEXT("Loaded right offsets! tracker source is %s "), *UEnum::GetDisplayValueAsText(HandType).ToString());
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, *message);
}
if (bBindToNoticationDelegate && !NewControllerProfileEvent_Handle.IsValid())
@@ -7214,10 +7223,10 @@ void UGripMotionControllerComponent::ApplyTrackingParameters(FVector& OriginalPo
if (GEngine->XRSystem->GetCurrentPose(IXRTrackingSystem::HMDDeviceId, curRot, curLoc))
{
if (IsValid(AttachChar) && AttachChar->VRReplicatedCamera)
/*if (IsValid(AttachChar) && AttachChar->VRReplicatedCamera)
{
AttachChar->VRReplicatedCamera->ApplyTrackingParameters(curLoc, true);
}
}*/
//curLoc.Z = 0;
LastLocationForLateUpdate = curLoc;
@@ -7234,7 +7243,7 @@ void UGripMotionControllerComponent::ApplyTrackingParameters(FVector& OriginalPo
if (IsValid(AttachChar) && AttachChar->VRReplicatedCamera)
{
// Sample camera location instead
LastLocationForLateUpdate = AttachChar->VRReplicatedCamera->GetRelativeLocation();
LastLocationForLateUpdate = AttachChar->VRReplicatedCamera->ReplicatedCameraTransform.Position; //GetRelativeLocation();
if (!AttachChar->bRetainRoomscale && IsLocallyControlled())
{
@@ -8334,12 +8343,12 @@ void UGripMotionControllerComponent::GetHandType(EControllerHand& Hand)
{
// Check if the palm motion source extension is being used
// I assume eventually epic will handle this case
if (MotionSource.Compare(FName(TEXT("RightPalm"))) == 0)
if (MotionSource.Compare(FName(TEXT("RightPalm"))) == 0 || MotionSource.Compare(FName(TEXT("RightWrist"))) == 0 || MotionSource.ToString().Contains("Right"))
{
Hand = EControllerHand::Right;
}
// Could skip this and default to left now but would rather check
else if (MotionSource.Compare(FName(TEXT("LeftPalm"))) == 0)
else if (MotionSource.Compare(FName(TEXT("LeftPalm"))) == 0 || MotionSource.Compare(FName(TEXT("LeftWrist"))) == 0 || MotionSource.ToString().Contains("Left"))
{
Hand = EControllerHand::Left;
}
@@ -237,7 +237,7 @@ bool UHandSocketComponent::GetAnimationSequenceAsPoseSnapShot(UAnimSequence* InA
if (TrackIndex != INDEX_NONE && (!bSkipRootBone || TrackIndex != 0))
{
double TrackLocation = 0.0f;
double TrackLocation = 0.0f;
InAnimationSequence->GetBoneTransform(LocalTransform, FSkeletonPoseBoneIndex(TrackMap[TrackIndex].BoneTreeIndex), TrackLocation, false);
}
else
@@ -345,7 +345,7 @@ bool UHandSocketComponent::GetBlendedPoseSnapShot(FPoseSnapshot& PoseSnapShot, U
if (TrackIndex != INDEX_NONE && (!bSkipRootBone || TrackIndex != 0))
{
double TrackLocation = 0.0f;
double TrackLocation = HandTargetAnimation->GetPlayLength() * HandAnimationProgress;
HandTargetAnimation->GetBoneTransform(LocalTransform, FSkeletonPoseBoneIndex(TrackMap[TrackIndex].BoneTreeIndex), TrackLocation, false);
}
else
@@ -397,7 +397,8 @@ bool UHandSocketComponent::GetBlendedPoseSnapShot(FPoseSnapshot& PoseSnapShot, U
PoseSnapShot.LocalTransforms.Empty();
TargetMesh->GetBoneNames(PoseSnapShot.BoneNames);
PoseSnapShot.LocalTransforms = TargetMesh->GetSkinnedAsset()->GetSkeleton()->GetRefLocalPoses();
//PoseSnapShot.LocalTransforms = TargetMesh->GetSkinnedAsset()->GetSkeleton()->GetRefLocalPoses();
PoseSnapShot.LocalTransforms = TargetMesh->GetSkinnedAsset()->GetRefSkeleton().GetRefBonePose();
FQuat DeltaQuat = FQuat::Identity;
FName TargetBoneName = NAME_None;
@@ -692,7 +693,7 @@ void UHandSocketComponent::OnRegister()
{
if (HandPreviewMaterial)
{
HandVisualizerComponent->SetMaterial(0, (UMaterialInterface*)HandPreviewMaterial);
HandVisualizerComponent->SetMaterial(0, HandPreviewMaterial);
}
HandVisualizerComponent->SetSkinnedAssetAndUpdate(VisualizationMesh);
}
@@ -782,9 +783,11 @@ void UHandSocketComponent::PoseVisualizationToAnimation(bool bForceRefresh)
if (!HandTargetAnimation)
{
// Store local poses for posing
LocalPoses = HandVisualizerComponent->GetSkinnedAsset()->GetSkeleton()->GetRefLocalPoses();
LocalPoses = HandVisualizerComponent->GetSkinnedAsset()->GetRefSkeleton().GetRefBonePose();
}
// Check out of the skin cache, the poses don't update otherwise when enabled
int32 NumLODs = HandVisualizerComponent->GetNumLODs();
HandVisualizerComponent->SkinCacheUsage.Empty(NumLODs);
@@ -841,6 +844,7 @@ void UHandSocketComponent::PoseVisualizationToAnimation(bool bForceRefresh)
else
{
BoneTrans = LocalPoses[i];
//BoneTrans = HandVisualizerComponent->GetSkinnedAsset()->GetRefSkeleton().GetRefBonePose()[i];
}
BoneTrans = BoneTrans * ParentTrans;// *HandVisualizerComponent->GetComponentTransform();
@@ -851,7 +855,6 @@ void UHandSocketComponent::PoseVisualizationToAnimation(bool bForceRefresh)
BoneTrans.ConcatenateRotation(DeltaQuat);
BoneTrans.NormalizeRotation();
HandVisualizerComponent->SetBoneTransformByName(BonesNames[i], BoneTrans, EBoneSpaces::ComponentSpace);
}
if (HandVisualizerComponent && (!bTickedPose || bForceRefresh))
@@ -272,24 +272,34 @@ void UVRDialComponent::OnGripRelease_Implementation(UGripMotionControllerCompone
float AngleOffsetCheck = FMath::Abs(FRotator::ClampAxis(CurRotBackEnd) - FRotator::ClampAxis(LastSnapAngle));
float TargetSnap = FMath::RoundToFloat(FMath::GridSnap(CurRotBackEnd, SnapAngleIncrement));
if (FMath::Abs(FRotator::ClampAxis(CurRotBackEnd) - TargetSnap) <= FMath::Min(SnapAngleIncrement, SnapAngleThreshold))
if (FMath::Abs(/*FRotator::ClampAxis(*/CurRotBackEnd/*)*/ - TargetSnap) <= FMath::Min(SnapAngleIncrement, SnapAngleThreshold))
{
if (AngleOffsetCheck >= SnapAngleThreshold)//FMath::Min(SnapAngleIncrement, SnapAngleThreshold))
{
this->SetRelativeRotation((FTransform(UVRInteractibleFunctionLibrary::SetAxisValueRot(DialRotationAxis, FMath::GridSnap(CurRotBackEnd, SnapAngleIncrement), FRotator::ZeroRotator)) * InitialRelativeTransform).Rotator());
CurRotBackEnd = FMath::GridSnap(CurRotBackEnd, SnapAngleIncrement);
if (bUseRollover)
{
CurrentDialAngle = FMath::RoundToFloat(CurRotBackEnd);
}
else
{
CurrentDialAngle = FRotator::ClampAxis(FMath::RoundToFloat(CurRotBackEnd));
}
}
else
{
// Reset to the snap angle so that it requires full motion to break out of it
CurRotBackEnd = CurrentDialAngle;
}
}
if (bUseRollover)
{
CurrentDialAngle = FMath::RoundToFloat(CurRotBackEnd);
}
else
{
CurrentDialAngle = FRotator::ClampAxis(FMath::RoundToFloat(CurRotBackEnd));
// Reset to the snap angle so that it requires full motion to break out of it
CurRotBackEnd = CurrentDialAngle;
}
if (!FMath::IsNearlyEqual(LastSnapAngle, CurrentDialAngle))
{
ReceiveDialHitSnapAngle(CurrentDialAngle);
@@ -582,7 +592,7 @@ void UVRDialComponent::AddDialAngle(float DialAngleDelta, bool bCallEvents, bool
float AngleOffsetCheck = FMath::Abs(FRotator::ClampAxis(CurRotBackEnd) - FRotator::ClampAxis(LastSnapAngle));
float TargetSnap = FMath::RoundToFloat(FMath::GridSnap(CurRotBackEnd, SnapAngleIncrement));
if (FMath::Abs(FRotator::ClampAxis(CurRotBackEnd) - TargetSnap) <= FMath::Min(SnapAngleIncrement, SnapAngleThreshold))
if (FMath::Abs(/*FRotator::ClampAxis(*/CurRotBackEnd/*)*/ - TargetSnap) <= FMath::Min(SnapAngleIncrement, SnapAngleThreshold))
{
if (AngleOffsetCheck >= SnapAngleThreshold)//FMath::Min(SnapAngleIncrement, SnapAngleThreshold))
{
@@ -161,17 +161,14 @@ void UCollisionIgnoreSubsystem::CheckActiveFilters()
{
bool bMadeChanges = false;
for (TPair<FCollisionPrimPair, FCollisionIgnorePairArray>& KeyPair : CollisionTrackedPairs)
for (TMap<FCollisionPrimPair, FCollisionIgnorePairArray>::TIterator ItRemove = CollisionTrackedPairs.CreateIterator(); ItRemove; ++ItRemove)
{
// First check for invalid primitives
if (!IsValid(KeyPair.Key.Prim1) || !IsValid(KeyPair.Key.Prim2))
// First check for invalid primitives and an empty pair array
if (!IsValid(ItRemove->Key.Prim1) || !IsValid(ItRemove->Key.Prim2) || ItRemove->Value.PairArray.Num() < 1)
{
// If we don't have a map element for this pair, then add it now
if (!RemovedPairs.Contains(KeyPair.Key))
{
RemovedPairs.Add(KeyPair.Key, KeyPair.Value);
bMadeChanges = true;
}
ItRemove->Value.PairArray.Empty();
ItRemove.RemoveCurrent();
bMadeChanges = true;
continue; // skip remaining checks as we have invalid primitives anyway
}
@@ -267,16 +264,6 @@ void UCollisionIgnoreSubsystem::CheckActiveFilters()
});
}
#endif
// If there are no pairs left
if (KeyPair.Value.PairArray.Num() < 1)
{
// Try and remove it, chaos should be cleaning up the ignore setups
if (!RemovedPairs.Contains(KeyPair.Key))
{
RemovedPairs.Add(KeyPair.Key, KeyPair.Value);
}
}
}
/*#if WITH_CHAOS
@@ -295,13 +282,18 @@ void UCollisionIgnoreSubsystem::CheckActiveFilters()
}
#endif*/
for (const TPair<FCollisionPrimPair, FCollisionIgnorePairArray>& KeyPair : RemovedPairs)
/*for (const TPair<FCollisionPrimPair, FCollisionIgnorePairArray>& KeyPair : RemovedPairs)
{
if (CollisionTrackedPairs.Contains(KeyPair.Key))
{
CollisionTrackedPairs[KeyPair.Key].PairArray.Empty();
CollisionTrackedPairs.Remove(KeyPair.Key);
}
}*/
if (bMadeChanges)
{
CollisionTrackedPairs.Compact();
}
UpdateTimer(bMadeChanges);
@@ -283,6 +283,21 @@ UPrimitiveComponent* FBPActorGripInformation::GetGrippedComponent() const
return Cast<UPrimitiveComponent>(GrippedObject);
}
UPrimitiveComponent* FBPActorGripInformation::GetGripPrimitiveComponent() const
{
UPrimitiveComponent* RootComp = nullptr;
if (GripTargetType == EGripTargetType::ActorGrip)
{
RootComp = Cast<UPrimitiveComponent>(GetGrippedActor()->GetRootComponent());
}
else
RootComp = GetGrippedComponent();
return RootComp;
}
bool FBPActorGripInformation::operator==(const UPrimitiveComponent* Other) const
{
if (Other && GrippedObject && GrippedObject == (const UObject*)Other)
@@ -586,6 +586,11 @@ bool UVRExpansionFunctionLibrary::IsActiveGrip(const FBPActorGripInformation& Gr
return Grip.IsActive();
}
UPrimitiveComponent* UVRExpansionFunctionLibrary::GetGripPrimitiveTarget(const FBPActorGripInformation& Grip)
{
return Grip.GetGripPrimitiveComponent();
}
FTransform_NetQuantize UVRExpansionFunctionLibrary::MakeTransform_NetQuantize(FVector Translation, FRotator Rotation, FVector Scale)
{
return FTransform_NetQuantize(Rotation, Translation, Scale);
@@ -468,7 +468,7 @@ void UVRRootComponent::UpdateCharacterCapsuleOffset()
{
if (owningVRChar && !owningVRChar->bRetainRoomscale && owningVRChar->NetSmoother)
{
if (!FMath::IsNearlyEqual(LastCapsuleHalfHeight, CapsuleHalfHeight))
if (bCenterCapsuleOnHMD || !FMath::IsNearlyEqual(LastCapsuleHalfHeight, CapsuleHalfHeight))
{
owningVRChar->NetSmoother->SetRelativeLocation(GetTargetHeightOffset(), false, nullptr, ETeleportType::TeleportPhysics);
@@ -506,6 +506,8 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType,
if (IsLocallyControlled())
{
bool bHadBadTracking = false;
if (owningVRChar && owningVRChar->bTrackingPaused)
{
curCameraLoc = owningVRChar->PausedTrackingLoc;
@@ -524,6 +526,7 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType,
{
curCameraLoc = lastCameraLoc;
curCameraRot = lastCameraRot;
bHadBadTracking = true;
}
else
{
@@ -562,7 +565,7 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType,
// Can adjust the relative tolerances to remove jitter and some update processing
if (!bRetainRoomscale || (!curCameraLoc.Equals(lastCameraLoc, 0.01f) || !curCameraRot.Equals(lastCameraRot, 0.01f)))
if (!bHadBadTracking && (!bRetainRoomscale || (!curCameraLoc.Equals(lastCameraLoc, 0.01f) || !curCameraRot.Equals(lastCameraRot, 0.01f))))
{
// Also calculate vector of movement for the movement component
FVector LastPosition = OffsetComponentToWorld.GetLocation();
@@ -591,9 +594,23 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType,
Params.bFindInitialOverlaps = true;
bool bBlockingHit = false;
if (bUseWalkingCollisionOverride && bRetainRoomscale)
if (bUseWalkingCollisionOverride /* && bRetainRoomscale*/)
{
FVector TargetWorldLocation = OffsetComponentToWorld.GetLocation();
FVector TargetWorldLocation = FVector::ZeroVector;
if (bRetainRoomscale)
{
TargetWorldLocation = OffsetComponentToWorld.GetLocation();
}
else // Not Retained Roomscale
{
FVector NewLocation = StoredCameraRotOffset.RotateVector(FVector(VRCapsuleOffset.X, VRCapsuleOffset.Y, 0.0f)) + curCameraLoc;
FVector PlanerLocation = NewLocation - lastCameraLoc;
PlanerLocation.Z = 0.0f;
DifferenceFromLastFrame = GetComponentTransform().TransformVector(PlanerLocation);
TargetWorldLocation = LastPosition + DifferenceFromLastFrame;
}
bool bAllowWalkingCollision = false;
if (CharMove != nullptr)
{
@@ -638,7 +655,6 @@ void UVRRootComponent::TickComponent(float DeltaTime, enum ELevelTick TickType,
}
else
{
// Run this first so we get full fidelity on the relative space calculation
FVector NewLocation = StoredCameraRotOffset.RotateVector(FVector(VRCapsuleOffset.X, VRCapsuleOffset.Y, 0.0f)) + curCameraLoc;
FVector PlanerLocation = NewLocation - lastCameraLoc;
@@ -1545,7 +1561,7 @@ bool UVRRootComponent::IsLocallyControlled() const
GenerateOffsetToWorld();
}*/
if (!owningVRChar->bRetainRoomscale && !IsLocallyControlled())
if (!owningVRChar->bRetainRoomscale && !IsLocallyControlled() && !IsNetMode(NM_DedicatedServer))
{
// Don't smooth this change in mesh position
FNetworkPredictionData_Client_Character* ClientData = owningVRChar->GetCharacterMovement()->GetPredictionData_Client_Character();
@@ -189,6 +189,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation")
TObjectPtr<UAnimSequence> HandTargetAnimation;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Animation")
float HandAnimationProgress = 0.0f;
// Scale to apply when mirroring the hand, adjust to visualize your off hand correctly
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Socket Data|Mirroring")
FVector MirroredScale;
@@ -465,7 +468,7 @@ public:
#if WITH_EDITORONLY_DATA
// Material to apply to the hand
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hand Visualization")
TObjectPtr<UMaterial> HandPreviewMaterial;
TObjectPtr<UMaterialInterface> HandPreviewMaterial;
#endif
};
@@ -13,6 +13,40 @@
#include "VRWheeledVehicle.generated.h"
// This only exists to expose the blueprint properties of the transmission values
USTRUCT(BlueprintType, Category = "VRWheeledVehicle")
struct VREXPANSIONPLUGIN_API FBPVehicleTransmissionConfig : public FVehicleTransmissionConfig
{
GENERATED_BODY()
public:
void SetFrom(FVehicleTransmissionConfig & Config)
{
bUseAutomaticGears = Config.bUseAutomaticGears;
bUseAutoReverse = Config.bUseAutoReverse;
FinalRatio = Config.FinalRatio;
ForwardGearRatios = Config.ForwardGearRatios;
ReverseGearRatios = Config.ReverseGearRatios;
ChangeUpRPM = Config.ChangeUpRPM;
ChangeDownRPM = Config.ChangeDownRPM;
GearChangeTime = Config.GearChangeTime;
TransmissionEfficiency = Config.TransmissionEfficiency;
}
void SetTo(FVehicleTransmissionConfig& Config)
{
Config.bUseAutomaticGears = bUseAutomaticGears;
Config.bUseAutoReverse = bUseAutoReverse;
Config.FinalRatio = FinalRatio;
Config.ForwardGearRatios = ForwardGearRatios;
Config.ReverseGearRatios = ReverseGearRatios;
Config.ChangeUpRPM = ChangeUpRPM;
Config.ChangeDownRPM = ChangeDownRPM;
Config.GearChangeTime = GearChangeTime;
Config.TransmissionEfficiency = TransmissionEfficiency;
}
};
/**
* This override of the base wheeled vehicle allows for dual pawn usage in engine.
*/
@@ -24,6 +58,29 @@ class VREXPANSIONPLUGIN_API AVRWheeledVehicle : public AWheeledVehiclePawn
public:
UFUNCTION(BlueprintPure, Category = "Pawn")
float GetFinalGearRatio()
{
float CurrentGearRatio = 0.0f;
if (UChaosWheeledVehicleMovementComponent* MoveComp = Cast<UChaosWheeledVehicleMovementComponent>(this->GetMovementComponent()))
{
CurrentGearRatio = MoveComp->TransmissionSetup.FinalRatio;
}
return CurrentGearRatio;
}
UFUNCTION(BlueprintCallable, Category = "Pawn")
void SetFinalGearRatio(float NewFinalGearRatio)
{
if (UChaosWheeledVehicleMovementComponent* MoveComp = Cast<UChaosWheeledVehicleMovementComponent>(this->GetMovementComponent()))
{
MoveComp->TransmissionSetup.FinalRatio = NewFinalGearRatio;
}
}
// Calls the movement components override controller function
UFUNCTION(BlueprintCallable, Category = "Pawn")
virtual bool SetBindToInput(AController * CController, bool bBindToInput)
{
@@ -137,8 +137,7 @@ public:
FQuat GetCalculatedRotation(FRotator InverseRot, float DeltaTime)
{
FRotator FinalRot = FRotator::ZeroRotator;
if (FPlatformMath::Abs(FRotator::ClampAxis(InverseRot.Yaw) - LastRot) < YawTolerance) // This is never true with the default value of 0.0f
if (FPlatformMath::Abs(FMath::FindDeltaAngleDegrees(InverseRot.Yaw, LastRot)) < YawTolerance) // This is never true with the default value of 0.0f
{
if (!bWasSetOnce)
{
@@ -1562,6 +1562,8 @@ public:
UPrimitiveComponent* GetGrippedComponent() const;
UPrimitiveComponent* GetGripPrimitiveComponent() const;
//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
FORCEINLINE bool operator==(const FBPActorGripInformation &Other) const
@@ -200,6 +200,10 @@ public:
UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions")
static bool IsActiveGrip(const FBPActorGripInformation& Grip);
/* Returns the target primitive component if the grip has one (it should always), otherwise it will return invalid */
UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions")
static UPrimitiveComponent* GetGripPrimitiveTarget(const FBPActorGripInformation& Grip);
/** Make a transform net quantize from location, rotation and scale */
UFUNCTION(BlueprintPure, meta = (Scale = "1,1,1", Keywords = "construct build", NativeMakeFunc), Category = "VRExpansionLibrary|TransformNetQuantize")
static FTransform_NetQuantize MakeTransform_NetQuantize(FVector Location, FRotator Rotation, FVector Scale);
@@ -57,7 +57,14 @@ public:
inline FVector GetTargetHeightOffset()
{
//return FVector::ZeroVector;
return FVector(0.f, 0.f, (-this->GetUnscaledCapsuleHalfHeight()) - VRCapsuleOffset.Z);
if (bCenterCapsuleOnHMD)
{
return FVector(0.f, 0.f, (-VRCapsuleOffset.Z) - curCameraLoc.Z);
}
else
{
return FVector(0.f, 0.f, (-this->GetUnscaledCapsuleHalfHeight()) - VRCapsuleOffset.Z);
}
}
/**
@@ -266,7 +273,7 @@ void inline UVRRootComponent::GenerateOffsetToWorld(bool bUpdateBounds, bool bGe
if(owningVRChar && !owningVRChar->bRetainRoomscale)
{
OffsetComponentToWorld = FTransform(CamRotOffset.Quaternion(), FVector(0.0f, 0.0f, bCenterCapsuleOnHMD ? curCameraLoc.Z : 0.0f), FVector(1.0f)) * GetComponentTransform();
OffsetComponentToWorld = FTransform(CamRotOffset.Quaternion(), FVector(0.0f, 0.0f, 0.0f), FVector(1.0f)) * GetComponentTransform();
}
else
{