Skip to content
Snippets Groups Projects
Commit d61f7bc5 authored by Peter Gschladt's avatar Peter Gschladt
Browse files

Merge branch 'fix/nanite' into 'dev/5.5'

fix: Converted all static meshes to nanite

See merge request !118
parents 9d2086b7 003b0afa
No related branches found
No related tags found
1 merge request!118fix: Converted all static meshes to nanite
Showing
with 53 additions and 3 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -189,6 +189,9 @@ void UCollisionHandlingMovement::SetCapsuleColliderToUserSize() const
}
CapsuleColliderComponent->SetWorldRotation(FRotator::ZeroRotator);
// Counteract Pawn Scaling
CapsuleColliderComponent->SetWorldScale3D(FVector::One());
}
void UCollisionHandlingMovement::CheckAndRevertCollisionSinceLastTick()
......
......@@ -42,7 +42,7 @@ void UTurnComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent)
// no snap turning for desktop mode
if (!URWTHVRUtilities::IsDesktopMode())
{
EI->BindAction(XRTurn, ETriggerEvent::Started, this, &UTurnComponent::OnBeginSnapTurn);
EI->BindAction(XRTurn, ETriggerEvent::Triggered, this, &UTurnComponent::OnBeginSnapTurn);
}
else
{
......
......@@ -41,8 +41,26 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob
LeftHand = CreateDefaultSubobject<UReplicatedMotionControllerComponent>(TEXT("Left Hand MCC"));
LeftHand->SetupAttachment(RootComponent);
UniformScale = GetActorScale3D().X;
GetRootComponent()->TransformUpdated.AddLambda(
[this](USceneComponent*, EUpdateTransformFlags, ETeleportType)
{
FVector CurrentScale = this->GetActorScale3D();
if (CurrentScale.X != UniformScale || CurrentScale.Y != UniformScale || CurrentScale.Z != UniformScale)
{
UE_LOGFMT(Toolkit, Warning,
"ARWTHVRPawn: Do not adjust the scale of the pawn directly. This will not work in VR. Use "
"ARWTHVRPawn::SetScale(float) instead.");
}
});
}
void ARWTHVRPawn::BeginPlay()
{
Super::BeginPlay();
InitialWorldToMeters = GetWorldSettings()->WorldToMeters;
}
void ARWTHVRPawn::BeginPlay() { Super::BeginPlay(); }
void ARWTHVRPawn::Tick(float DeltaSeconds)
{
......@@ -56,6 +74,22 @@ void ARWTHVRPawn::Tick(float DeltaSeconds)
EvaluateLivelink();
}
/*
* Scales the Pawn while also adjusting the WorldToMeters ratio to adjust for pupillary distance.
* Only supports uniform scaling.
*/
void ARWTHVRPawn::SetScale(float NewScale)
{
FVector OldScale = GetActorScale();
UniformScale = NewScale;
FVector NewScaleVector = FVector(UniformScale, UniformScale, UniformScale);
GetWorldSettings()->WorldToMeters = InitialWorldToMeters * UniformScale;
SetActorRelativeScale3D(NewScaleVector);
OnScaleChanged.Broadcast(OldScale, NewScale);
}
float ARWTHVRPawn::GetScale() { return UniformScale; }
/*
* The alternative would be to do this only on the server on possess and check for player state/type,
* as connections now send their playertype over.
......
......@@ -14,6 +14,8 @@ class UCameraComponent;
class UMotionControllerComponent;
struct FLiveLinkTransformStaticData;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnScaleChangedDelegate, FVector, OldScale, float, NewUniformScale);
/**
* Pawn implementation with additional VR functionality, can be used in the Cave, with an HMD and on desktop.
*/
......@@ -31,6 +33,15 @@ public:
virtual void NotifyControllerChanged() override;
UFUNCTION(BlueprintCallable)
void SetScale(float NewScale);
UFUNCTION(BlueprintCallable)
float GetScale();
UPROPERTY(BlueprintAssignable)
FOnScaleChangedDelegate OnScaleChanged;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Pawn|Input")
TArray<UInputMappingContext*> InputMappingContexts;
......@@ -111,4 +122,6 @@ protected:
private:
UInputComponent* ActivePlayerInputComponent;
float InitialWorldToMeters;
float UniformScale;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment