Skip to content
Snippets Groups Projects
Commit 651c3fe0 authored by Konstantin Kühlem's avatar Konstantin Kühlem
Browse files

style: Enforce coding style at various places

parent 5f141bb1
Branches
No related tags found
No related merge requests found
[CoreRedirects]
+PropertyRedirects=(OldName="/Script/CharacterPlugin.VHMovement.IKOffsetRigthFoot",NewName="/Script/CharacterPlugin.VHMovement.IKOffsetRightFoot")
\ No newline at end of file
......@@ -60,7 +60,7 @@ void UVHMovement::BeginPlay()
UCapsuleComponent* capsuleComp = AVirtualHumanPtr->GetCapsuleComponent();
IKTraceDistance = capsuleComp->GetScaledCapsuleHalfHeight();
IKOffsetRigthFoot = 0.0f;
IKOffsetRightFoot = 0.0f;
IKOffsetLeftFoot = 0.0f;
IKInterpSpeed = 10.0f;
IKMaxOffset = 55.0f;
......@@ -83,7 +83,7 @@ void UVHMovement::BeginPlay()
UVHMovement* childMovement = child.Key->FindComponentByClass<UVHMovement>();
childMovement->WaypointGroup = GetWaypointGroup();
childMovement->bLoop = IsLoop();
childMovement->parentVH = Cast<AVirtualHuman>(AVirtualHumanPawn);
childMovement->ParentVH = Cast<AVirtualHuman>(AVirtualHumanPawn);
childMovement->GroupFormation = GroupFormation;
childMovement->WaypointOrder = WaypointOrder;
childMovement->bChild = true;
......@@ -169,7 +169,8 @@ void UVHMovement::TickComponent(float DeltaTime, ELevelTick TickType, FActorComp
// the Socket is at the front of the foot
// the bone we rotate around is at the back of the foot
const BoneNames& bones = AVirtualHumanPtr->GetBoneNames();
FVector footVector = AVirtualHumanPtr->GetBodyMesh()->GetBoneLocation(bones.foot_r) - AVirtualHumanPtr->GetBodyMesh()->GetSocketLocation(RightFootSocket);
FVector footVector = AVirtualHumanPtr->GetBodyMesh()->GetBoneLocation(bones.foot_r) - AVirtualHumanPtr->
GetBodyMesh()->GetSocketLocation(RightFootSocket);
float footLength = footVector.Size(); // the length of the shoe
float rotationErrorHeightAdjustment = tanf(footRotationAngleRAD) * footLength;
rotationErrorHeightAdjustment = FMath::Clamp(rotationErrorHeightAdjustment, 0.0f, footLength); // safety clamp
......@@ -178,14 +179,16 @@ void UVHMovement::TickComponent(float DeltaTime, ELevelTick TickType, FActorComp
if (bWalkingUp)
{
IKFootRotationAngle = FMath::FInterpTo(IKFootRotationAngle, -FMath::RadiansToDegrees(footRotationAngleRAD), DeltaTime, IKInterpSpeed);
IKFootRotationAngle = FMath::FInterpTo(IKFootRotationAngle, -FMath::RadiansToDegrees(footRotationAngleRAD),
DeltaTime, IKInterpSpeed);
IKOffsetRight -= rotationErrorHeightAdjustment;
IKOffsetLeft -= rotationErrorHeightAdjustment;
}
else
{
IKFootRotationAngle = FMath::FInterpTo(IKFootRotationAngle, FMath::RadiansToDegrees(footRotationAngleRAD), DeltaTime, IKInterpSpeed);
IKFootRotationAngle = FMath::FInterpTo(IKFootRotationAngle, FMath::RadiansToDegrees(footRotationAngleRAD),
DeltaTime, IKInterpSpeed);
IKOffsetRight += rotationErrorHeightAdjustment;
IKOffsetLeft += rotationErrorHeightAdjustment;
}
......@@ -205,7 +208,7 @@ void UVHMovement::TickComponent(float DeltaTime, ELevelTick TickType, FActorComp
IKHipOffset = FMath::FInterpTo(IKHipOffset, hipOffset, DeltaTime, IKInterpSpeed);
IKOffsetRight = FMath::Clamp(IKOffsetRight, 0.0f, IKMaxOffset);
IKOffsetRigthFoot = FMath::FInterpTo(IKOffsetRigthFoot, IKOffsetRight, DeltaTime, IKInterpSpeed);
IKOffsetRightFoot = FMath::FInterpTo(IKOffsetRightFoot, IKOffsetRight, DeltaTime, IKInterpSpeed);
IKOffsetLeft = FMath::Clamp(IKOffsetLeft, 0.0f, IKMaxOffset);
......@@ -215,7 +218,7 @@ void UVHMovement::TickComponent(float DeltaTime, ELevelTick TickType, FActorComp
// write variables to Animation Instance
if (AnimationInstance)
{
AnimationInstance->IKOffsetRight = -IKOffsetRigthFoot;
AnimationInstance->IKOffsetRight = -IKOffsetRightFoot;
AnimationInstance->IKOffsetLeft = IKOffsetLeftFoot;
AnimationInstance->IKHipOffset = IKHipOffset;
AnimationInstance->IKFootRotation = IKFootRotationAngle;
......@@ -224,7 +227,8 @@ void UVHMovement::TickComponent(float DeltaTime, ELevelTick TickType, FActorComp
void UVHMovement::MoveToWaypoint()
{
if (!AVirtualHumanPawn) {
if (!AVirtualHumanPawn)
{
VH_ERROR("[UVHMovement::MoveToWaypoint()] Owner is not derived from APawn\n");
return;
}
......@@ -234,13 +238,15 @@ void UVHMovement::MoveToWaypoint()
//this might not be initialized on BeginPlay
VirtualHumanAIController = Cast<AVirtualHumanAIController>(AVirtualHumanPawn->GetController());
}
if (!VirtualHumanAIController) {
if (!VirtualHumanAIController)
{
VH_ERROR("[UVHMovement::MoveToWaypoint()] Virtual Human does not implement AIController\n");
return;
}
// if we are at the last waypoint and it defines destroying agent, do so
if (Waypoints.Num() != 0 && CurrentWaypointIterator == Waypoints.Num() && Waypoints[CurrentWaypointIterator - 1]->GetLastWaypointCommand() == EOnWaypointReach::Destroy)
if (Waypoints.Num() != 0 && CurrentWaypointIterator == Waypoints.Num() && Waypoints[CurrentWaypointIterator - 1]->
GetLastWaypointCommand() == EOnWaypointReach::Destroy)
{
VirtualHumanAIController->DestroyAgent();
}
......@@ -248,32 +254,37 @@ void UVHMovement::MoveToWaypoint()
if (CurrentWaypointIterator < Waypoints.Num())
{
ACurrentWaypoint = Waypoints[CurrentWaypointIterator];
if (!ACurrentWaypoint) {
CurrentWaypoint = Waypoints[CurrentWaypointIterator];
if (!CurrentWaypoint)
{
VH_ERROR("Waypoint with Index %i is not valid\n", CurrentWaypointIterator);
return;
}
UNavigationSystemV1* navSys = UNavigationSystemV1::GetCurrent(GetWorld());
if (!navSys) {
if (!navSys)
{
VH_ERROR("Navigation System is not valid\n");
return;
}
auto path = navSys->FindPathToActorSynchronously(GetWorld(), AVirtualHumanPawn->GetActorLocation(), ACurrentWaypoint);
auto path = navSys->FindPathToActorSynchronously(GetWorld(), AVirtualHumanPawn->GetActorLocation(),
CurrentWaypoint);
FAIMoveRequest request = FAIMoveRequest();
request.SetGoalActor(ACurrentWaypoint);
request.SetGoalActor(CurrentWaypoint);
request.SetUsePathfinding(true);
request.SetAllowPartialPath(true);
Cast<UCharacterMovementComponent>(AVirtualHumanPawn->GetMovementComponent())->MaxWalkSpeed = ACurrentWaypoint->GetWalkingSpeed();
Cast<UCharacterMovementComponent>(AVirtualHumanPawn->GetMovementComponent())->MaxWalkSpeed = CurrentWaypoint->
GetWalkingSpeed();
CurrentRequestID = VirtualHumanAIController->RequestMove(request, path->GetPath());
for (TPair<AVirtualHuman*, float>& child : ChildVH)
{
if (!child.Key) {
if (!child.Key)
{
VH_ERROR("Virtual Human does not have a valid child\n");
return;
}
......@@ -303,12 +314,14 @@ void UVHMovement::MoveToWaypoint()
*/
void UVHMovement::MoveToWaypoint(FVector TargetLocation, float Speed)
{
if (!AVirtualHumanPawn) {
if (!AVirtualHumanPawn)
{
VH_ERROR("Parent Pawn is not Virtual Human\n");
return;
}
if (!VirtualHumanAIController) {
if (!VirtualHumanAIController)
{
VH_ERROR("Virtual Human does not implement AIController\n");
return;
}
......@@ -319,7 +332,8 @@ void UVHMovement::MoveToWaypoint(FVector TargetLocation, float Speed)
void UVHMovement::ChildMoveToWaypoint()
{
if (!AVirtualHumanPawn) {
if (!AVirtualHumanPawn)
{
VH_ERROR("Parent Pawn is not Virtual Human\n");
return;
}
......@@ -329,7 +343,8 @@ void UVHMovement::ChildMoveToWaypoint()
//this might not be initialized on BeginPlay
VirtualHumanAIController = Cast<AVirtualHumanAIController>(AVirtualHumanPawn->GetController());
}
if (!VirtualHumanAIController) {
if (!VirtualHumanAIController)
{
VH_ERROR("Virtual Human does not implement AIController\n");
return;
}
......@@ -337,24 +352,27 @@ void UVHMovement::ChildMoveToWaypoint()
if (CurrentWaypointIterator < Waypoints.Num())
{
ACurrentWaypoint = Waypoints[CurrentWaypointIterator]; //ICurrentWaypoint is only incremented by the parent
if (!ACurrentWaypoint) {
CurrentWaypoint = Waypoints[CurrentWaypointIterator]; //ICurrentWaypoint is only incremented by the parent
if (!CurrentWaypoint)
{
VH_ERROR("Waypoint with Index %i is not valid\n", CurrentWaypointIterator);
return;
}
UNavigationSystemV1* navSys = UNavigationSystemV1::GetCurrent(GetWorld());
if (!navSys) {
if (!navSys)
{
VH_ERROR("Navigation System is not valid\n");
return;
}
TArray<FVector> intermediatePoints = ChildPoints.FindRef(ACurrentWaypoint);
if (IntermediatePointIterator < intermediatePoints.Num()) {
TArray<FVector> intermediatePoints = ChildPoints.FindRef(CurrentWaypoint);
auto path = navSys->FindPathToLocationSynchronously(GetWorld(), AVirtualHumanPawn->GetActorLocation(), intermediatePoints[IntermediatePointIterator]);
if (IntermediatePointIterator < intermediatePoints.Num())
{
auto path = navSys->FindPathToLocationSynchronously(GetWorld(), AVirtualHumanPawn->GetActorLocation(),
intermediatePoints[IntermediatePointIterator]);
FAIMoveRequest request = FAIMoveRequest();
request.SetUsePathfinding(true);
......@@ -364,56 +382,57 @@ void UVHMovement::ChildMoveToWaypoint()
// first point is either speed up point or we are on the inside line and there exists only one point
if (IntermediatePointIterator == 0)
{
if (intermediatePoints.Num() > 1) //then we walk towards the speed up point
{
// calculate the speed towards the lastPointOfCurrentPath (therefore + 1)
speed = CalculateChildSpeed(ACurrentWaypoint, intermediatePoints[IntermediatePointIterator + 1]);
speed = FMath::Clamp(speed, 0.0f, FMath::Min(ACurrentWaypoint->GetWalkingSpeed() * 1.5f, MAX_WALKING_SPEED));
speed = CalculateChildSpeed(CurrentWaypoint, intermediatePoints[IntermediatePointIterator + 1]);
speed = FMath::Clamp(speed, 0.0f,
FMath::Min(CurrentWaypoint->GetWalkingSpeed() * 1.5f, MAX_WALKING_SPEED));
Cast<UCharacterMovementComponent>(AVirtualHumanPawn->GetMovementComponent())->MaxWalkSpeed = speed;
}
else // we are on the inside and need to slow down
{
speed = CalculateChildSpeed(ACurrentWaypoint, intermediatePoints[IntermediatePointIterator]); // calculate the speed towards the inner point
speed = FMath::Clamp(speed, 0.0f, FMath::Min(ACurrentWaypoint->GetWalkingSpeed() * 1.5f, MAX_WALKING_SPEED));
speed = CalculateChildSpeed(CurrentWaypoint, intermediatePoints[IntermediatePointIterator]);
// calculate the speed towards the inner point
speed = FMath::Clamp(speed, 0.0f,
FMath::Min(CurrentWaypoint->GetWalkingSpeed() * 1.5f, MAX_WALKING_SPEED));
Cast<UCharacterMovementComponent>(AVirtualHumanPawn->GetMovementComponent())->MaxWalkSpeed = speed;
}
}
if(IntermediatePointIterator == 1) // we are at the speedUpPoint and therefore need to increase our speed to be at the firstPointOfNextPath when parent reaches the waypoint
if (IntermediatePointIterator == 1)
// we are at the speedUpPoint and therefore need to increase our speed to be at the firstPointOfNextPath when parent reaches the waypoint
{
speed = CalculateChildSpeed(ACurrentWaypoint, intermediatePoints);
speed = FMath::Clamp(speed, 0.0f, FMath::Min(ACurrentWaypoint->GetWalkingSpeed() * 1.3f, MAX_WALKING_SPEED));
speed = CalculateChildSpeed(CurrentWaypoint, intermediatePoints);
speed = FMath::Clamp(speed, 0.0f,
FMath::Min(CurrentWaypoint->GetWalkingSpeed() * 1.3f, MAX_WALKING_SPEED));
Cast<UCharacterMovementComponent>(AVirtualHumanPawn->GetMovementComponent())->MaxWalkSpeed = speed;
}
CurrentRequestID = VirtualHumanAIController->RequestMove(request, path->GetPath());
IntermediatePointIterator++;
}
if (IntermediatePointIterator == intermediatePoints.Num()) {
if (IntermediatePointIterator == intermediatePoints.Num())
{
// so AIControlle does not call childMoveToWaypoint again
// will be set to true by parent if he has reached the current waypoint
bChildMovement = false;
}
}
}
TArray<AWaypoint*> UVHMovement::ShuffleArray(TArray<AWaypoint*> myArray)
TArray<AWaypoint*> UVHMovement::ShuffleArray(TArray<AWaypoint*> Array) const
{
if (myArray.Num() > 0)
{
int32 LastIndex = myArray.Num() - 1;
const int32 LastIndex = Array.Num() - 1;
for (int32 i = 0; i <= LastIndex; ++i)
{
int32 Index = MovementRandomStream.RandRange(0, LastIndex - 1);
const int32 Index = MovementRandomStream.RandRange(0, LastIndex - 1);
if (i != Index)
{
myArray.Swap(Index, i);
}
Array.Swap(Index, i);
}
}
return myArray;
return Array;
}
/*
......@@ -432,7 +451,8 @@ void UVHMovement::WaypointMovement()
StoreAllWaypoints();
if (Waypoints.Num() < 1) {
if (Waypoints.Num() < 1)
{
VH_ERROR("No Waypoints for WaypointGroup %i\n", WaypointGroup);
return;
}
......@@ -530,9 +550,8 @@ void UVHMovement::WaypointMovement()
// if we are the child, we set the Waypoints for the parent and for other childs
if (bChild)
{
UVHMovement* parentMovement = parentVH->FindComponentByClass<UVHMovement>();
if (!parentVH)
UVHMovement* parentMovement = ParentVH->FindComponentByClass<UVHMovement>();
if (!ParentVH)
{
VH_ERROR("child has no valid parent\n");
return;
......@@ -553,7 +572,6 @@ void UVHMovement::WaypointMovement()
i++;
}
}
}
......@@ -617,11 +635,13 @@ void UVHMovement::CreateChildPoints()
// around 2nd to last -1
for (int i = 1; i < Waypoints.Num() - 1; i++)
{
ChildPoints.Add(Waypoints[i],(CreateIntermediatePoints(Waypoints[i - 1], Waypoints[i], Waypoints[i + 1])));
ChildPoints.Add(Waypoints[i],
(CreateIntermediatePoints(Waypoints[i - 1], Waypoints[i], Waypoints[i + 1])));
}
// around last waypoint
ChildPoints.Add(Waypoints.Last(), CreateIntermediatePoints(Waypoints.Last(1), Waypoints.Last(), Waypoints[0]));
ChildPoints.Add(Waypoints.Last(),
CreateIntermediatePoints(Waypoints.Last(1), Waypoints.Last(), Waypoints[0]));
// around first waypoint from last waypoint
if (IsLoop())
......@@ -646,7 +666,6 @@ void UVHMovement::CreateChildPoints()
// we just need an aditional starting point that the child moves to in the time the parent walks to the first waypoint
if (Waypoints.Num() > 1)
{
first = Waypoints[0];
next = Waypoints[1];
direction = first->GetActorLocation() - next->GetActorLocation();
......@@ -654,7 +673,7 @@ void UVHMovement::CreateChildPoints()
else
{
first = Waypoints[0];
direction = parentVH->GetActorLocation() - first->GetActorLocation();
direction = ParentVH->GetActorLocation() - first->GetActorLocation();
}
direction.Normalize();
......@@ -670,7 +689,8 @@ void UVHMovement::CreateChildPoints()
CurrentWaypointIterator++;
}
MoveToWaypoint(startingPosition, childSpeed); //after this is done VirtualHumanAIController will automatically call MoveToWaypoint()
MoveToWaypoint(startingPosition, childSpeed);
//after this is done VirtualHumanAIController will automatically call MoveToWaypoint()
if (bDrawDebugSpheres)
{
......@@ -687,7 +707,7 @@ TArray<FVector> UVHMovement::CreateIntermediatePoints(AWaypoint* lastWP, AWaypo
if (lastWP == NULL) // special case when walking from starting position to first waypoint
{
last = parentVH->GetActorLocation();
last = ParentVH->GetActorLocation();
}
else
{
......@@ -724,7 +744,9 @@ TArray<FVector> UVHMovement::CreateIntermediatePoints(AWaypoint* lastWP, AWaypo
// create speedUpPoint if we are on the outside path:
// we make a right turn and offset is to the left or we make a left turn and offset is to the right
if ((angleInMoveDir > 0 && lastWP != NULL && OffsetFromWaypoint > 0) || (angleInMoveDir < 0 && lastWP != NULL && OffsetFromWaypoint < 0)) {
if ((angleInMoveDir > 0 && lastWP != NULL && OffsetFromWaypoint > 0) || (angleInMoveDir < 0 && lastWP != NULL &&
OffsetFromWaypoint < 0))
{
//calculate a point towards the end of the path to the next waypoint at which the child begins to walk faster (if he has the outside path)
FVector speedUpPoint = LastPointOfCurrentPath - 0.40 * (current - last);
......@@ -745,20 +767,22 @@ TArray<FVector> UVHMovement::CreateIntermediatePoints(AWaypoint* lastWP, AWaypo
// if the angle is very big we want the child to just turn around instead of walking a curve
// this requires a side change (if the child walks to the left of the parent, in walking direction, it will now be on the right side)
if (angleInMoveDir > 140) {
if (angleInMoveDir > 140)
{
OffsetFromWaypoint = -1 * OffsetFromWaypoint; // side change
angleInMoveDir -= 180; // for the remaining angle we still calculate intermediate points
}
if (angleInMoveDir < -140) {
if (angleInMoveDir < -140)
{
OffsetFromWaypoint = -1 * OffsetFromWaypoint;
angleInMoveDir += 180;
}
// create intermediate points if we are on the outside path:
// we make a right turn and offset is to the left or we make a left turn and offset is to the right
if ( (angleInMoveDir > 0 && lastWP != NULL && OffsetFromWaypoint > 0) || (angleInMoveDir < 0 && lastWP != NULL && OffsetFromWaypoint < 0)) {
if ((angleInMoveDir > 0 && lastWP != NULL && OffsetFromWaypoint > 0) || (angleInMoveDir < 0 && lastWP != NULL &&
OffsetFromWaypoint < 0))
{
// intermediate point (especially usefull if angles between waypoints is very big)
// could be neglected for perfromace reasons
FVector intermediatePointOffset = childLocationOffset.RotateAngleAxis(angleInMoveDir / 2, FVector(0, 0, 1));
......@@ -785,13 +809,13 @@ TArray<FVector> UVHMovement::CreateIntermediatePoints(AWaypoint* lastWP, AWaypo
float UVHMovement::CalculateChildSpeed(AWaypoint* nextWaypoint, TArray<FVector> points)
{
if (points.Num() < 2) {
if (points.Num() < 2)
{
VH_ERROR("Not enough points to calculate child speed, so we set it to zero.\n");
return 0.f;
}
UNavigationPath* parentPath = UNavigationSystemV1::FindPathToLocationSynchronously(
GetWorld(), parentVH->GetActorLocation(), nextWaypoint->GetActorLocation());
GetWorld(), ParentVH->GetActorLocation(), nextWaypoint->GetActorLocation());
UNavigationPath* childPath = UNavigationSystemV1::FindPathToLocationSynchronously(
GetWorld(), AVirtualHumanPawn->GetActorLocation(), points[1]);
......@@ -820,7 +844,7 @@ float UVHMovement::CalculateChildSpeed(AWaypoint* nextWaypoint, TArray<FVector>
float UVHMovement::CalculateChildSpeed(AWaypoint* nextWaypoint, FVector childPoint)
{
UNavigationPath* parentPath = UNavigationSystemV1::FindPathToLocationSynchronously(
GetWorld(), parentVH->GetActorLocation(), nextWaypoint->GetActorLocation());
GetWorld(), ParentVH->GetActorLocation(), nextWaypoint->GetActorLocation());
UNavigationPath* childPath = UNavigationSystemV1::FindPathToLocationSynchronously(
GetWorld(), AVirtualHumanPawn->GetActorLocation(), childPoint);
......@@ -858,8 +882,8 @@ FHitResult UVHMovement::IKFootTrace(FName Socket, float TraceDistance)
FCollisionQueryParams TraceParams;
TraceParams.bTraceComplex = true;
TraceParams.AddIgnoredActor(AVirtualHumanPtr);
bool hitFound = GetWorld()->LineTraceSingleByChannel(Hit, LineTraceStart, LineTraceEnd, ECC_Visibility, TraceParams);
bool hitFound = GetWorld()->
LineTraceSingleByChannel(Hit, LineTraceStart, LineTraceEnd, ECC_Visibility, TraceParams);
// DrawDebugLine(GetWorld(), LineTraceStart, LineTraceEnd, FColor::Cyan, false, 0.1f);
return Hit;
}
......@@ -10,31 +10,24 @@ AWaypoint::AWaypoint()
WalkingSpeed = 100.0f;
WaypointGroup = 0;
WaypointOrder = 0;
}
int AWaypoint::GetWaypointOrder()
int AWaypoint::GetWaypointOrder() const
{
return WaypointOrder;
}
float AWaypoint::GetWalkingSpeed()
float AWaypoint::GetWalkingSpeed() const
{
return WalkingSpeed;
}
int AWaypoint::GetWaypointGroup()
int AWaypoint::GetWaypointGroup() const
{
return WaypointGroup;
}
int AWaypoint::GetLastWaypointCommand()
int AWaypoint::GetLastWaypointCommand() const
{
return OnReachLastWaypoint;
}
......@@ -5,10 +5,8 @@
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "VHAnimInstance.h"
#include "VHFaceAnimation.generated.h"
struct FFrameData
{
float Timestamp;
......@@ -66,7 +64,7 @@ public:
bool LoadAnimationFile(FString Filename);
// this method can be used to calibrate the neutral face from any animation file (even another one then which should be played)
// the data nearest to the time given will be substracted from any frame of the animation.
// the data nearest to the time given will be subtracted from any frame of the animation.
// this will be overwritten if bUseFaceCalibrationFrame is true
UFUNCTION(BlueprintCallable)
bool Calibrate(FString Filename, float CalibrationTime);
......@@ -77,7 +75,6 @@ public:
UFUNCTION(BlueprintCallable, meta = (DeprecatedFunction, DeprecationMessage = "Function has been deprecated, if needed reimplement it."))
UAnimSequence* SaveAsAnimSequence(FString AnimName);
UPROPERTY(BlueprintReadWrite, EditAnywhere)
bool bUseHeadRotation = true;
......@@ -91,7 +88,6 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float ConstantDelay = 0.0f;
// set to true then, whatever data is in the frame nearest to TimeForCalibration will be substracted from every frame
// this can be used to calibrate to a neutral face
UPROPERTY(BlueprintReadWrite, EditAnywhere)
......@@ -111,8 +107,6 @@ public:
protected:
virtual bool InternalLoadFile(FString FileName);
void ApplyFrameData(int FrameNr);
......@@ -126,14 +120,12 @@ protected:
float GetFacialExpressionMorphTargetValue(const FName& MorphName);
FAnimationData AnimationData;
FFrameData CalibrationFrame;
TMap<FString, FAnimationData> CachedAnimationData;
bool bCurrentlyPlaying = false;
float CurrentPlayTime = 0.0f;
float FadeFraction = 0.0f;
......
......@@ -32,7 +32,6 @@ protected:
UPROPERTY(EditAnywhere)
float NodAmplitude = 3.0; //degrees
private:
UVHAnimInstance* AnimInstance = nullptr;
FRandomStream RandomStream;
......
......@@ -4,19 +4,14 @@
#include "CoreMinimal.h"
#include "AITypes.h"
#include "VirtualHuman.h"
#include "Waypoint.h"
#include "Components/ActorComponent.h"
#include "Components/SplineComponent.h"
#include "VHMovement.generated.h"
class AVirtualHumanAIController;
UENUM()
enum EWaypointOrdering
{
......@@ -32,7 +27,6 @@ enum EGroupFormations
InLine UMETA(DisplayName = "InLine"),
};
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class CHARACTERPLUGIN_API UVHMovement : public UActorComponent
{
......@@ -42,37 +36,39 @@ public:
// Sets default values for this component's properties
UVHMovement();
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override;
void MoveToWaypoint(FVector TargetLocation, float Speed);
void MoveToWaypoint();
void ChildMoveToWaypoint();
AWaypoint* GetCurrentWaypoint()
AWaypoint* GetCurrentWaypoint() const
{
return ACurrentWaypoint;
return CurrentWaypoint;
}
bool IsLoop()
bool IsLoop() const
{
return bLoop;
}
int GetWaypointGroup()
int GetWaypointGroup() const
{
return WaypointGroup;
}
bool IsChild()
bool IsChild() const
{
return bChild;
}
bool ShouldChildMove() {
bool ShouldChildMove() const
{
return bChildMovement;
}
bool IsLineMovement()
bool IsLineMovement() const
{
return bLineMovement;
}
......@@ -93,7 +89,7 @@ public:
float IKInterpSpeed;
UPROPERTY(BlueprintReadOnly, Category = IKFoot)
float IKOffsetRigthFoot;
float IKOffsetRightFoot;
UPROPERTY(BlueprintReadOnly, Category = IKFoot)
float IKOffsetLeftFoot;
......@@ -112,6 +108,7 @@ public:
UPROPERTY(BlueprintReadWrite, Category = IKFoot)
FName LeftFootSocket;
UPROPERTY(BlueprintReadWrite, Category = IKFoot)
float IKFootRotationAngle;
......@@ -122,9 +119,8 @@ protected:
virtual void BeginPlay() override;
private:
TArray<AWaypoint*> ShuffleArray(TArray<AWaypoint*> myArray);
float OffsetFromWaypoint;
TArray<AWaypoint*> Waypoints;
UPROPERTY() TArray<AWaypoint*> Waypoints;
TMap<AWaypoint*, TArray<FVector>> ChildPoints;
const float MAX_WALKING_SPEED = 350.0f;
......@@ -133,22 +129,24 @@ private:
bool bChildMovement;
bool bLineMovement;
APawn* AVirtualHumanPawn;
AVirtualHuman* parentVH;
AVirtualHuman* AVirtualHumanPtr;
AVirtualHumanAIController* VirtualHumanAIController;
UPROPERTY() APawn* AVirtualHumanPawn;
UPROPERTY() AVirtualHuman* ParentVH;
UPROPERTY() AVirtualHuman* AVirtualHumanPtr;
UPROPERTY() AVirtualHumanAIController* VirtualHumanAIController;
AWaypoint* ACurrentWaypoint;
UPROPERTY() AWaypoint* CurrentWaypoint;
UNavigationPath* NavigationPath;
UPROPERTY() UNavigationPath* NavigationPath;
float IKTraceDistance;
bool bWalkingUp;
FVector HitLocation;
UVHAnimInstance* AnimationInstance;
UPROPERTY() UVHAnimInstance* AnimationInstance;
FRandomStream MovementRandomStream;
TArray<AWaypoint*> ShuffleArray(TArray<AWaypoint*> Array) const;
FHitResult IKFootTrace(FName Socket, float TraceDistance);
void CreateChildPoints();
......@@ -184,5 +182,4 @@ private:
UFUNCTION(BlueprintCallable)
void WaypointMovement();
};
......@@ -4,7 +4,6 @@
#include "CoreMinimal.h"
#include "Engine/StaticMeshActor.h"
#include "GameFramework/Character.h"
#include "Waypoint.generated.h"
UENUM()
......@@ -14,19 +13,16 @@ enum EOnWaypointReach
Destroy UMETA(DisplayName = "Destroy Agent"),
};
/**
*
*/
UCLASS()
class CHARACTERPLUGIN_API AWaypoint : public AStaticMeshActor
{
GENERATED_BODY()
public:
AWaypoint();
int GetWaypointOrder();
float GetWalkingSpeed();
int GetWaypointGroup();
int GetLastWaypointCommand();
int GetWaypointOrder() const;
float GetWalkingSpeed() const;
int GetWaypointGroup() const;
int GetLastWaypointCommand() const;
private:
......@@ -49,6 +45,4 @@ private:
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
TEnumAsByte<EOnWaypointReach> OnReachLastWaypoint = EOnWaypointReach::Destroy;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment