Skip to content

Instantly share code, notes, and snippets.

@hvent90
Created August 12, 2022 18:30
Show Gist options
  • Save hvent90/03a15ebd36733097b6afd708b3f0fd52 to your computer and use it in GitHub Desktop.
Save hvent90/03a15ebd36733097b6afd708b3f0fd52 to your computer and use it in GitHub Desktop.
misc. massentity/statetree/smartobjects/zonegraph source hacks
diff --git a/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/MassStateTreeExecutionContext.cpp b/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/MassStateTreeExecutionContext.cpp
index 5473fc5776fc..c53f9827eda2 100644
--- a/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/MassStateTreeExecutionContext.cpp
+++ b/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/MassStateTreeExecutionContext.cpp
@@ -1,3 +1,4 @@
+
// Copyright Epic Games, Inc. All Rights Reserved.
#include "MassStateTreeExecutionContext.h"
diff --git a/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/Tasks/MassFindSmartObjectTask.cpp b/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/Tasks/MassFindSmartObjectTask.cpp
index f3398b8d9444..310cce0c8768 100644
--- a/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/Tasks/MassFindSmartObjectTask.cpp
+++ b/Engine/Plugins/AI/MassAI/Source/MassAIBehavior/Private/Tasks/MassFindSmartObjectTask.cpp
@@ -125,24 +125,24 @@ EStateTreeRunStatus FMassFindSmartObjectTask::Tick(FStateTreeExecutionContext& C
{
// Use lanes if possible for faster queries using zone graph annotations
const FMassEntityHandle RequestingEntity = MassContext.GetEntity();
- if (LaneLocation != nullptr)
- {
- MASSBEHAVIOR_CLOG(!LaneLocation->LaneHandle.IsValid(), Error, TEXT("Always expecting a valid lane from the ZoneGraph movement"));
- if (LaneLocation->LaneHandle.IsValid())
- {
- MASSBEHAVIOR_LOG(Log, TEXT("Requesting search candidates from lane %s (%s/%s)"),
- *LaneLocation->LaneHandle.ToString(),
- *LexToString(LaneLocation->DistanceAlongLane),
- *LexToString(LaneLocation->LaneLength));
-
- SearchRequestID = MassSmartObjectHandler.FindCandidatesAsync(RequestingEntity, SOUser.UserTags, ActivityRequirements, { LaneLocation->LaneHandle, LaneLocation->DistanceAlongLane });
- }
- }
- else
- {
+ // if (LaneLocation != nullptr)
+ // {
+ // MASSBEHAVIOR_CLOG(!LaneLocation->LaneHandle.IsValid(), Error, TEXT("Always expecting a valid lane from the ZoneGraph movement"));
+ // if (LaneLocation->LaneHandle.IsValid())
+ // {
+ // MASSBEHAVIOR_LOG(Log, TEXT("Requesting search candidates from lane %s (%s/%s)"),
+ // *LaneLocation->LaneHandle.ToString(),
+ // *LexToString(LaneLocation->DistanceAlongLane),
+ // *LexToString(LaneLocation->LaneLength));
+ //
+ // SearchRequestID = MassSmartObjectHandler.FindCandidatesAsync(RequestingEntity, SOUser.UserTags, ActivityRequirements, { LaneLocation->LaneHandle, LaneLocation->DistanceAlongLane });
+ // }
+ // }
+ // else
+ // {
const FTransformFragment& TransformFragment = Context.GetExternalData(EntityTransformHandle);
SearchRequestID = MassSmartObjectHandler.FindCandidatesAsync(RequestingEntity, SOUser.UserTags, ActivityRequirements, TransformFragment.GetTransform().GetLocation());
- }
+ // }
}
}
else
diff --git a/Engine/Plugins/Runtime/MassGameplay/Source/MassSmartObjects/Private/SmartObjectZoneAnnotations.cpp b/Engine/Plugins/Runtime/MassGameplay/Source/MassSmartObjects/Private/SmartObjectZoneAnnotations.cpp
index 6f3667cb255d..6dc49290f802 100644
--- a/Engine/Plugins/Runtime/MassGameplay/Source/MassSmartObjects/Private/SmartObjectZoneAnnotations.cpp
+++ b/Engine/Plugins/Runtime/MassGameplay/Source/MassSmartObjects/Private/SmartObjectZoneAnnotations.cpp
@@ -138,11 +138,17 @@ TOptional<FSmartObjectLaneLocation> USmartObjectZoneAnnotations::GetSmartObjectL
TOptional<FSmartObjectLaneLocation> SmartObjectLaneLocation;
if (const FSmartObjectAnnotationData* AnnotationData = GetAnnotationData(DataHandle))
{
- const int32 Index = AnnotationData->SmartObjectToLaneLocationIndexLookup.FindChecked(SmartObjectHandle);
- if (AnnotationData->SmartObjectLaneLocations.IsValidIndex(Index))
+ // const int32 Index = AnnotationData->SmartObjectToLaneLocationIndexLookup.Find(SmartObjectHandle);
+ const int32* Index = AnnotationData->SmartObjectToLaneLocationIndexLookup.Find(SmartObjectHandle);
+ if (Index && AnnotationData->SmartObjectLaneLocations.IsValidIndex(*Index))
{
- SmartObjectLaneLocation = AnnotationData->SmartObjectLaneLocations[Index];
+ SmartObjectLaneLocation = AnnotationData->SmartObjectLaneLocations[*Index];
}
+
+ // if (AnnotationData->SmartObjectLaneLocations.IsValidIndex(Index))
+ // {
+ // SmartObjectLaneLocation = AnnotationData->SmartObjectLaneLocations[Index];
+ // }
}
return SmartObjectLaneLocation;
}
diff --git a/Engine/Source/Programs/SymsLibDump/Private/SymsLibDump.cpp b/Engine/Source/Programs/SymsLibDump/Private/SymsLibDump.cpp
index 19472a624c9b..ca49f66bb579 100644
--- a/Engine/Source/Programs/SymsLibDump/Private/SymsLibDump.cpp
+++ b/Engine/Source/Programs/SymsLibDump/Private/SymsLibDump.cpp
@@ -274,7 +274,7 @@ namespace
Symbols[ProcIndex].Size = RangeArray.ranges[0].max - RangeArray.ranges[0].min;
}
- SYMS_String8 Name = syms_linkage_name_from_sid(Arena, Group->dbg_data, Group->dbg, UnitAccel, SymbolID);
+ SYMS_String8 Name = syms_group_symbol_name_from_sid(Arena, Group, UnitAccel, SymbolID);
// If we fail to find a linkage name fallback to name from sid. Some platforms, like Windows wont have a linkage name
if (Name.size == 0)
diff --git a/Engine/Source/Runtime/Engine/Private/LevelTick.cpp b/Engine/Source/Runtime/Engine/Private/LevelTick.cpp
index bf564cc48270..3132c7a46392 100644
--- a/Engine/Source/Runtime/Engine/Private/LevelTick.cpp
+++ b/Engine/Source/Runtime/Engine/Private/LevelTick.cpp
@@ -906,7 +906,8 @@ void UWorld::ClearActorComponentEndOfFrameUpdate(UActorComponent* Component)
}
}
-void UWorld::MarkActorComponentForNeededEndOfFrameUpdate(UActorComponent* Component, bool bForceGameThread)
+void UWorld::
+MarkActorComponentForNeededEndOfFrameUpdate(UActorComponent* Component, bool bForceGameThread)
{
check(!bPostTickComponentUpdate); // can't call this while we are doing the updates
@hvent90
Copy link
Author

hvent90 commented Aug 12, 2022

SmartObject zone annotations weren't being properly generated in World Partition. I got around this by creating my own state tree task to find smart objects based off their world location. Not as performant as the zone annotations method.
https://gist.github.com/hvent90/03a15ebd36733097b6afd708b3f0fd52#file-ue_massentity_hacks-patch-L65-L76

@hvent90
Copy link
Author

hvent90 commented Aug 12, 2022

https://gist.github.com/hvent90/03a15ebd36733097b6afd708b3f0fd52#file-ue_massentity_hacks-patch-L18-L51
This forces the request to be based off of world location rather than lane based. I should make my own task for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment