Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RWTH VR Toolkit
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Unreal-Development
Plugins
RWTH VR Toolkit
Commits
fc4eda4e
Commit
fc4eda4e
authored
4 months ago
by
Kris Tabea Helwig
Browse files
Options
Downloads
Patches
Plain Diff
feat(pawn): Adds VR scaling functionality
parent
1536d61c
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!118
fix: Converted all static meshes to nanite
,
!115
Feature/scaling
,
!114
Feature/scaling
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp
+46
-13
46 additions, 13 deletions
Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp
Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h
+4
-0
4 additions, 0 deletions
Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h
with
50 additions
and
13 deletions
Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp
+
46
−
13
View file @
fc4eda4e
...
@@ -41,8 +41,30 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob
...
@@ -41,8 +41,30 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob
LeftHand
=
CreateDefaultSubobject
<
UReplicatedMotionControllerComponent
>
(
TEXT
(
"Left Hand MCC"
));
LeftHand
=
CreateDefaultSubobject
<
UReplicatedMotionControllerComponent
>
(
TEXT
(
"Left Hand MCC"
));
LeftHand
->
SetupAttachment
(
RootComponent
);
LeftHand
->
SetupAttachment
(
RootComponent
);
GetRootComponent
()
->
TransformUpdated
.
AddLambda
([
this
](
USceneComponent
*
,
EUpdateTransformFlags
,
ETeleportType
)
{
FVector
CurrentScale
=
this
->
GetActorScale3D
();
if
(
CurrentScale
.
X
==
CurrentScale
.
Y
&&
CurrentScale
.
Y
==
CurrentScale
.
Z
)
{
float
expectedScale
=
GetWorldSettings
()
->
WorldToMeters
/
InitialWorldToMeters
;
float
ErrorPrecision
=
1E-05
;
if
(
FMath
::
IsNearlyEqual
(
CurrentScale
.
X
,
expectedScale
,
ErrorPrecision
))
{
return
;
}
}
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
)
void
ARWTHVRPawn
::
Tick
(
float
DeltaSeconds
)
{
{
...
@@ -56,6 +78,17 @@ void ARWTHVRPawn::Tick(float DeltaSeconds)
...
@@ -56,6 +78,17 @@ void ARWTHVRPawn::Tick(float DeltaSeconds)
EvaluateLivelink
();
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
NewScaleVector
=
FVector
(
NewScale
,
NewScale
,
NewScale
);
GetWorldSettings
()
->
WorldToMeters
=
InitialWorldToMeters
*
NewScale
;
SetActorScale3D
(
NewScaleVector
);
}
/*
/*
* The alternative would be to do this only on the server on possess and check for player state/type,
* 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.
* as connections now send their playertype over.
...
...
This diff is collapsed.
Click to expand it.
Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h
+
4
−
0
View file @
fc4eda4e
...
@@ -31,6 +31,9 @@ public:
...
@@ -31,6 +31,9 @@ public:
virtual
void
NotifyControllerChanged
()
override
;
virtual
void
NotifyControllerChanged
()
override
;
UFUNCTION
(
BlueprintCallable
)
void
SetScale
(
float
NewScale
);
UPROPERTY
(
EditAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn|Input"
)
UPROPERTY
(
EditAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn|Input"
)
TArray
<
UInputMappingContext
*>
InputMappingContexts
;
TArray
<
UInputMappingContext
*>
InputMappingContexts
;
...
@@ -111,4 +114,5 @@ protected:
...
@@ -111,4 +114,5 @@ protected:
private:
private:
UInputComponent
*
ActivePlayerInputComponent
;
UInputComponent
*
ActivePlayerInputComponent
;
float
InitialWorldToMeters
;
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment