Start to add path following debug

This commit is contained in:
Arnaud Jamin
2023-10-20 09:02:11 -04:00
parent 804f7c6ba5
commit 812f4fa91f
8 changed files with 137 additions and 40 deletions
+36 -35
View File
@@ -2,47 +2,48 @@ using UnrealBuildTool;
public class CogAI : ModuleRules
{
public CogAI(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
}
);
PrivateIncludePaths.AddRange(
new string[] {
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
public CogAI(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
}
);
PrivateIncludePaths.AddRange(
new string[] {
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CogCommon",
"CogImgui",
"CogDebug",
"CogWindow",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"AIModule",
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
}
);
}
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
}
);
}
}
@@ -2,6 +2,8 @@
#define LOCTEXT_NAMESPACE "FCogAIModule"
DEFINE_LOG_CATEGORY(LogCogAI);
//--------------------------------------------------------------------------------------------------------------------------
void FCogAIModule::StartupModule()
{
@@ -7,6 +7,8 @@
#include "BehaviorTree/Tasks/BTTask_BlueprintBase.h"
#include "BehaviorTree/Tasks/BTTask_Wait.h"
#include "BrainComponent.h"
#include "CogAIModule.h"
#include "CogDebugDraw.h"
#include "CogImguiHelper.h"
#include "CogWindowWidgets.h"
#include "GameFramework/Pawn.h"
@@ -26,12 +28,100 @@ UCogAIWindow_BehaviorTree::UCogAIWindow_BehaviorTree()
bHasMenu = true;
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAIWindow_BehaviorTree::GameTick(float DeltaTime)
{
Super::GameTick(DeltaTime);
#if ENABLE_COG
const AActor* Selection = GetSelection();
if (Selection == nullptr)
{
return;
}
const APawn* Pawn = Cast<APawn>(Selection);
if (Pawn == nullptr)
{
return;
}
const AAIController* AIController = Cast<AAIController>(Pawn->Controller);
if (AIController == nullptr)
{
return;
}
const UPathFollowingComponent* PathFollowing = AIController->GetPathFollowingComponent();
if (PathFollowing == nullptr)
{
return;
}
const FNavigationPath* CurrentPath = PathFollowing->GetPath().Get();
if (CurrentPath == nullptr)
{
return;
}
FVector LastLocation;
for (int32 i = 0; i < CurrentPath->GetPathPoints().Num(); i++)
{
const FVector& Location = CurrentPath->GetPathPoints()[i].Location;
if (i > 0)
{
FCogDebugDraw::Arrow(LogCogAI, this, LastLocation, Location, FColor::White, false, 0);
FCogDebugDraw::Point(LogCogAI, this, LastLocation, 10.0f, FColor::White, false, 0);
FCogDebugDraw::Point(LogCogAI, this, Location, 10.0f, FColor::White, false, 0);
}
LastLocation = Location;
}
//TArray<FString> Tokens;
//TArray<EPathFollowingDebugTokens::Type> Flags;
//PathFollowing->GetDebugStringTokens(Tokens, Flags);
//for (int32 Idx = 0; Idx < Tokens.Num(); Idx++)
//{
// switch (Flags[Idx])
// {
// case EPathFollowingDebugTokens::Description:
// DataPack.PathFollowingInfo += Tokens[Idx];
// break;
// case EPathFollowingDebugTokens::ParamName:
// DataPack.PathFollowingInfo += TEXT(", {yellow}");
// DataPack.PathFollowingInfo += Tokens[Idx];
// DataPack.PathFollowingInfo += TEXT(":");
// break;
// case EPathFollowingDebugTokens::PassedValue:
// DataPack.PathFollowingInfo += TEXT("{yellow}");
// DataPack.PathFollowingInfo += Tokens[Idx];
// break;
// case EPathFollowingDebugTokens::FailedValue:
// DataPack.PathFollowingInfo += TEXT("{orange}");
// DataPack.PathFollowingInfo += Tokens[Idx];
// break;
// default:
// break;
// }
//}
#endif //ENABLE_COG
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAIWindow_BehaviorTree::RenderContent()
{
Super::RenderContent();
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("Options"))
@@ -104,7 +104,6 @@ void UCogAIWindow_Blackboard::RenderContent()
});
}
if (ImGui::BeginTable("Blackboard", 3, ImGuiTableFlags_SizingFixedFit
| ImGuiTableFlags_Resizable
| ImGuiTableFlags_NoBordersInBodyUntilResize
@@ -3,6 +3,8 @@
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
COGAI_API DECLARE_LOG_CATEGORY_EXTERN(LogCogAI, Warning, All);
class COGAI_API FCogAIModule : public IModuleInterface
{
public:
@@ -18,7 +18,9 @@ public:
protected:
void RenderHelp();
virtual void GameTick(float DeltaTime) override;
virtual void RenderHelp() override;
virtual void RenderContent() override;
+3 -1
View File
@@ -4,13 +4,13 @@
#include "CogSampleDefines.h"
#if ENABLE_COG
#include "CogAIModule.h"
#include "CogDebugLog.h"
#endif //ENABLE_COG
DEFINE_LOG_CATEGORY(LogCogAlways);
DEFINE_LOG_CATEGORY(LogCogAbility);
DEFINE_LOG_CATEGORY(LogCogAI);
DEFINE_LOG_CATEGORY(LogCogBaseAimRotation);
DEFINE_LOG_CATEGORY(LogCogCollision);
DEFINE_LOG_CATEGORY(LogCogControlRotation);
@@ -26,6 +26,7 @@ namespace CogSampleLog
void RegisterAllLogCategories()
{
#if ENABLE_COG
FCogDebugLog::AddLogCategory(LogCogAlways, "Always", "Debug Category that is always active", false);
FCogDebugLog::AddLogCategory(LogCogAbility, "Ability", "Log and debug draw of gameplay abilities");
@@ -41,6 +42,7 @@ namespace CogSampleLog
FCogDebugLog::AddLogCategory(LogCogSkeleton, "Skeleton", "Debug Draw a Character Skeleton");
FCogDebugLog::AddLogCategory(LogCogTargetAcquisition, "Target Acquisition", "Debug Draw the target acquisition debug draw");
FCogDebugLog::AddLogCategory(LogGameplayEffects, "Gameplay Effects", "Unreal Gameplay Effect Log");
#endif //ENABLE_COG
}
}
@@ -5,7 +5,6 @@
DECLARE_LOG_CATEGORY_EXTERN(LogCogAlways, VeryVerbose, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCogAbility, Warning, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCogAI, Warning, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCogBaseAimRotation, Warning, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCogCollision, Warning, All);
DECLARE_LOG_CATEGORY_EXTERN(LogCogControlRotation, Warning, All);