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
240e4625
Commit
240e4625
authored
3 years ago
by
Ehret
Browse files
Options
Downloads
Patches
Plain Diff
minor improvements
parent
d45251bb
No related branches found
No related tags found
2 merge requests
!28
Improve Walking implementation
,
!13
Draft: Improve walking implementation
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp
+7
-9
7 additions, 9 deletions
Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp
Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h
+0
-2
0 additions, 2 deletions
Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h
with
7 additions
and
11 deletions
Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp
+
7
−
9
View file @
240e4625
...
...
@@ -5,6 +5,8 @@
UVRPawnMovement
::
UVRPawnMovement
(
const
FObjectInitializer
&
ObjectInitializer
)
:
Super
(
ObjectInitializer
)
{
// the capsule is used to store the players size and position, e.g., for other interactions and as starting point
// for the capsule trace (which however not use the capsule component directly)
CapsuleColliderComponent
=
CreateDefaultSubobject
<
UCapsuleComponent
>
(
TEXT
(
"CapsuleCollider"
));
CapsuleColliderComponent
->
SetCollisionEnabled
(
ECollisionEnabled
::
QueryAndPhysics
);
CapsuleColliderComponent
->
SetCollisionResponseToAllChannels
(
ECollisionResponse
::
ECR_Overlap
);
...
...
@@ -131,18 +133,19 @@ void UVRPawnMovement::CheckForPhysWalkingCollision()
if
(
LastCapsulePosition
.
IsNearlyZero
())
{
//probably not yet set, so do nothing than setting it
LastCapsulePosition
=
Get
CapsuleLocation
FromHead
();
LastCapsulePosition
=
Capsule
ColliderComponent
->
GetComponent
Location
();
return
;
}
const
FVector
CapsuleLocation
=
Get
CapsuleLocation
FromHead
();
const
FVector
CapsuleLocation
=
Capsule
ColliderComponent
->
GetComponent
Location
();
const
FHitResult
HitResult
=
CreateCapsuleTrace
(
LastCapsulePosition
,
CapsuleLocation
);
//if this was not possible move the entire pawn away to avoid the head collision
if
(
HitResult
.
bBlockingHit
)
{
const
FVector
MoveOutVector
=
HitResult
.
Location
-
CapsuleLocation
;
UpdatedComponent
->
AddWorldOffset
(
MoveOutVector
);
//move it out twice as far, to avoid getting stuck situations
UpdatedComponent
->
AddWorldOffset
(
2
*
MoveOutVector
);
}
else
{
...
...
@@ -158,7 +161,7 @@ FVector UVRPawnMovement::GetCollisionSafeVirtualSteeringVec(FVector InputVector,
{
const
float
SafetyFactor
=
3.0f
;
//so we detect collision a bit earlier
const
FVector
CapsuleLocation
=
Get
CapsuleLocation
FromHead
();
const
FVector
CapsuleLocation
=
Capsule
ColliderComponent
->
GetComponent
Location
();
FVector
ProbePosition
=
SafetyFactor
*
InputVector
.
GetSafeNormal
()
*
GetMaxSpeed
()
*
DeltaTime
+
CapsuleLocation
;
const
FHitResult
TraceResult
=
CreateCapsuleTrace
(
CapsuleLocation
,
ProbePosition
);
if
(
!
TraceResult
.
bBlockingHit
)
...
...
@@ -244,11 +247,6 @@ void UVRPawnMovement::ShiftVertically(float Distance, float VerticalAcceleration
}
}
FVector
UVRPawnMovement
::
GetCapsuleLocationFromHead
()
{
return
HeadComponent
->
GetComponentLocation
()
-
FVector
(
0
,
0
,
CapsuleColliderComponent
->
GetScaledCapsuleHalfHeight
());
}
FHitResult
UVRPawnMovement
::
CreateCapsuleTrace
(
const
FVector
Start
,
FVector
End
,
bool
DrawDebug
)
const
{
const
EDrawDebugTrace
::
Type
DrawType
=
DrawDebug
?
EDrawDebugTrace
::
Type
::
ForDuration
:
EDrawDebugTrace
::
Type
::
None
;
...
...
This diff is collapsed.
Click to expand it.
Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h
+
0
−
2
View file @
240e4625
...
...
@@ -71,8 +71,6 @@ private:
void
MoveByGravityOrStepUp
(
float
DeltaSeconds
);
void
ShiftVertically
(
float
Distance
,
float
VerticalAcceleration
,
float
DeltaSeconds
);
FVector
GetCapsuleLocationFromHead
();
UPROPERTY
(
VisibleAnywhere
)
UCapsuleComponent
*
CapsuleColliderComponent
=
nullptr
;
UPROPERTY
()
USceneComponent
*
HeadComponent
=
nullptr
;
...
...
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