Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into Ragdoll_Inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Pearson authored Nov 16, 2017
2 parents 98debc7 + 23049c9 commit 4e41e63
Show file tree
Hide file tree
Showing 18 changed files with 231 additions and 23 deletions.
26 changes: 26 additions & 0 deletions Docs/DevelopmentLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

Kept up to date with notes from latest meetings

## 3. Meeting with Tilo 09/11/17, 2pm Tilo's Office

Not present:
* David

Notes by Nick

General Notes:
* IK driving physics will be difficult but is worth us persuing
* Asked for a windows machine to be made availible for development use
* Requested ports to be opened (they may be only opened on certain rows)
* Need a proper prototype test map
* Need to ensure we are integrating our work regularly
* Tilo wants us to consider the idea of a custom controller, also to think about our third key technology

__Group meeting after:__

New Tasks:
* Set up a system so we can have constraints along the arms so that the arms can support the body in ragdoll
* Research combining physics with IK - what works by default in unreal
* Writing a custom IK solver
* Using a sphere trace around the player to maintain a list of possible IK targets
* Sort function that can take a large list of input points and choose IK targets for left and right hands from the list based

Plan to meet again on Monday

## 2. Meeting 06/11/17, 1pm MVB

Not present:
Expand Down
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
4 changes: 2 additions & 2 deletions ParkourGame/Content/ThirdPersonCPP/Maps/entryMap.umap
Git LFS file not shown
Git LFS file not shown
4 changes: 2 additions & 2 deletions ParkourGame/Content/ThirdPersonCPP/Maps/testLevel.umap
Git LFS file not shown
Git LFS file not shown
4 changes: 2 additions & 2 deletions ParkourGame/Content/ThirdPersonCPP/Maps/transitionMap.umap
Git LFS file not shown
Git LFS file not shown
9 changes: 6 additions & 3 deletions ParkourGame/ParkourGame.uproject
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"FileVersion": 3,
"EngineAssociation": "4.17",
"EngineAssociation": "4.18",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "ParkourGame",
"Type": "Runtime",
"LoadingPhase": "Default"
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
],
"TargetPlatforms": [
"LinuxNoEditor",
"MacNoEditor",
"WindowsNoEditor"
]
}
}
6 changes: 6 additions & 0 deletions ParkourGame/Source/ParkourGame/ParkourGameCharacter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

#include "ParkourGameCharacter.h"

#include "Private/Physics/ConstraintManager.h"

// Engine
#include "HeadMountedDisplayFunctionLibrary.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
Expand Down Expand Up @@ -45,6 +49,8 @@ AParkourGameCharacter::AParkourGameCharacter()

// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named MyCharacter (to avoid direct content references in C++)

ConstraintManager = CreateDefaultSubobject<UConstraintManager>(TEXT("ConstraintManager"));
}

//////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions ParkourGame/Source/ParkourGame/ParkourGameCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class AParkourGameCharacter : public ACharacter
/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UConstraintManager* ConstraintManager;
public:
AParkourGameCharacter();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#include "ConstraintManager.h"

#include "PhysicsEngine/PhysicsConstraintActor.h"
#include "PhysicsEngine/PhysicsConstraintComponent.h"


// Sets default values for this component's properties
UConstraintManager::UConstraintManager()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = false;
}


// Called when the game starts
void UConstraintManager::BeginPlay()
{
Super::BeginPlay();


}

FGuid UConstraintManager::CreateConstraint(const FName& Bone, UPrimitiveComponent* OtherComp, const FName& OtherBone /*= NAME_None*/)
{
UWorld* WorldPtr = GetWorld();

if (!OtherComp || Bone == NAME_None || !WorldPtr)
return FGuid();

// Create constraint comp
USkeletalMeshComponent* SkelMeshComp = GetSkeletalMeshComp();
UPhysicsConstraintComponent* NewConstraintComp = NewObject<UPhysicsConstraintComponent>(OtherComp->GetOwner());

if (!ensure(NewConstraintComp) || !ensure(SkelMeshComp))
return FGuid();

// Setup the constraint actor
FConstraintInstance ConstraintInstance;
NewConstraintComp->ConstraintInstance = ConstraintInstance;

NewConstraintComp->SetWorldLocation(OtherComp->GetOwner()->GetActorLocation());
NewConstraintComp->AttachToComponent (OtherComp, FAttachmentTransformRules::KeepWorldTransform, OtherBone);
NewConstraintComp->SetConstrainedComponents(OtherComp, OtherBone, SkelMeshComp, Bone);

// @TODO : Bind to constraint broken event and handle that case

// Add to our list of managed constraints
FManagedPhysicsConstraint& NewConstraint = m_ActiveConstraints[m_ActiveConstraints.AddDefaulted()];

NewConstraint.ConstraintID.NewGuid();
NewConstraint.ConstraintComp = NewConstraintComp;
NewConstraint.TargetBone = Bone;
NewConstraint.OtherComp = OtherComp;
NewConstraint.OtherBone = OtherBone;

return NewConstraint.ConstraintID;
}

void UConstraintManager::DestroyConstraint(const FGuid& Constraint)
{
int32 RemoveIndex = m_ActiveConstraints.FindLastByPredicate([&](const FManagedPhysicsConstraint& QueryConstraint) {
return QueryConstraint.ConstraintID == Constraint;
});

if (RemoveIndex == INDEX_NONE)
return;

UPhysicsConstraintComponent* ConstraintCompPtr = m_ActiveConstraints[RemoveIndex].ConstraintComp.Get();

if (ConstraintCompPtr)
{
// @TODO Unbind from constrain broken event
ConstraintCompPtr->BreakConstraint();
ConstraintCompPtr->DestroyComponent();
}

m_ActiveConstraints.RemoveAtSwap(RemoveIndex);
}

void UConstraintManager::GetConstraintByTargetBone(const FName& Bone, TArray<FGuid>& outConstraints) const
{
GetConstraintsByPredicate([&](const FManagedPhysicsConstraint& Constraint) {
return Constraint.TargetBone == Bone;
}, outConstraints);
}

USkeletalMeshComponent* UConstraintManager::GetSkeletalMeshComp()
{
USkeletalMeshComponent* CompPtr = m_SkeletalMeshComp.Get();

if (CompPtr) return CompPtr;

return Cast<USkeletalMeshComponent>(GetOwner()->GetComponentByClass(USkeletalMeshComponent::StaticClass()));
}
67 changes: 67 additions & 0 deletions ParkourGame/Source/ParkourGame/Private/Physics/ConstraintManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "ConstraintManager.generated.h"


// @TODO: have a lookup table of constraint profile data we can reference for different situations

//typedef FGuid FConstraintID;

class UPhysicsConstraintComponent;

struct FManagedPhysicsConstraint
{
public:
FGuid ConstraintID;

TWeakObjectPtr<UPhysicsConstraintComponent> ConstraintComp;

FName TargetBone = NAME_None;

TWeakObjectPtr<USceneComponent> OtherComp;
FName OtherBone = NAME_None;
};


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class UConstraintManager : public UActorComponent
{
GENERATED_BODY()

public:
// Sets default values for this component's properties
UConstraintManager();

// Called when the game starts
virtual void BeginPlay() override;

public:

UFUNCTION(BlueprintCallable, Category = "ConstraintManager", meta = (AutoCreateRefTerm="Bone,OtherBone"))
FGuid CreateConstraint(const FName& Bone, UPrimitiveComponent* OtherComp, const FName& OtherBone = NAME_None);

UFUNCTION(BlueprintCallable, Category = "ConstraintManager")
void DestroyConstraint(const FGuid& Constraint);

template<typename Func>
void GetConstraintsByPredicate(Func Predicate, TArray<FGuid>& outConstraints) const
{
for (const FManagedPhysicsConstraint& Constraint : m_ActiveConstraints)
{
if (Predicate(Constraint))
outConstraints.Add(Constraint.ConstraintID);
}
}

UFUNCTION(BlueprintCallable, Category = "ConstraintManager", meta = (AutoCreateRefTerm="Bone"))
void GetConstraintByTargetBone(const FName& Bone, TArray<FGuid>& outConstraints) const;

private:

USkeletalMeshComponent* GetSkeletalMeshComp();

TWeakObjectPtr<USkeletalMeshComponent> m_SkeletalMeshComp;
TArray<FManagedPhysicsConstraint> m_ActiveConstraints;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "ParkourGameLogging.h"

DEFINE_LOG_CATEGORY(ParkourGame);
4 changes: 2 additions & 2 deletions ParkourGame/Source/ParkourGame/Public/Utils/GameVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "GameVersion.generated.h"

#define GAME_VERSION_MAJOR 0
#define GAME_VERSION_MINOR 1
#define GAME_VERSION_PATCH 0
#define GAME_VERSION_MINOR 2
#define GAME_VERSION_PATCH 1

USTRUCT(BlueprintType)
struct FGameVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "CoreMinimal.h"

DECLARE_LOG_CATEGORY_EXTERN(ParkourGame, Log, All);

0 comments on commit 4e41e63

Please sign in to comment.