2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-05-29 17:06:50 -04:00
|
|
|
#include "EnvironmentQuery/EnvQuery.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "UObject/UnrealType.h"
|
|
|
|
|
#include "DataProviders/AIDataProvider.h"
|
|
|
|
|
#include "DataProviders/AIDataProvider_QueryParams.h"
|
2014-05-29 17:06:50 -04:00
|
|
|
#include "EnvironmentQuery/EnvQueryGenerator.h"
|
|
|
|
|
#include "EnvironmentQuery/EnvQueryTest.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "EnvironmentQuery/EnvQueryOption.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-10-06 15:59:09 -04:00
|
|
|
namespace FEQSParamsExporter
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
bool HasNamedValue(const FName& ParamName, const TArray<FAIDynamicParam>& NamedValues)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
for (int32 ValueIndex = 0; ValueIndex < NamedValues.Num(); ValueIndex++)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
if (NamedValues[ValueIndex].ParamName == ParamName)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
2015-10-06 15:59:09 -04:00
|
|
|
|
|
|
|
|
return false;
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-10-06 15:59:09 -04:00
|
|
|
void AddNamedValue(UObject& QueryOwner, const FName& ParamName, const EAIParamType ParamType, float Value, TArray<FAIDynamicParam>& NamedValues, TArray<FName>& RequiredParams)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
check(ParamName.IsNone() == false);
|
|
|
|
|
|
|
|
|
|
if (HasNamedValue(ParamName, NamedValues) == false)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
FAIDynamicParam& NewValue = NamedValues[NamedValues.Add(FAIDynamicParam())];
|
2014-03-14 14:13:41 -04:00
|
|
|
NewValue.ParamName = ParamName;
|
|
|
|
|
NewValue.ParamType = ParamType;
|
|
|
|
|
NewValue.Value = Value;
|
2015-10-06 15:59:09 -04:00
|
|
|
NewValue.ConfigureBBKey(QueryOwner);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RequiredParams.AddUnique(ParamName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define GET_STRUCT_NAME_CHECKED(StructName) \
|
|
|
|
|
((void)sizeof(StructName), TEXT(#StructName))
|
|
|
|
|
|
2015-10-06 15:59:09 -04:00
|
|
|
void AddNamedValuesFromObject(UObject& QueryOwner, const UEnvQueryNode& QueryNode, TArray<FAIDynamicParam>& NamedValues, TArray<FName>& RequiredParams)
|
2014-06-13 12:46:13 -04:00
|
|
|
{
|
2019-12-13 11:07:03 -05:00
|
|
|
for (FProperty* TestProperty = QueryNode.GetClass()->PropertyLink; TestProperty; TestProperty = TestProperty->PropertyLinkNext)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2021-05-27 13:40:37 -04:00
|
|
|
FArrayProperty* TestArray = CastField<FArrayProperty>(TestProperty);
|
|
|
|
|
if (TestArray)
|
|
|
|
|
{
|
|
|
|
|
FObjectPropertyBase* ArrayInnerProperty = CastField<FObjectPropertyBase>(TestArray->Inner);
|
|
|
|
|
if (ArrayInnerProperty == nullptr)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ArrayInnerProperty->PropertyClass == nullptr || ArrayInnerProperty->PropertyClass->IsChildOf<UEnvQueryNode>() == false)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FScriptArrayHelper ArrayHelper(TestArray, TestArray->ContainerPtrToValuePtr<void>(&QueryNode));
|
|
|
|
|
|
|
|
|
|
for (int32 SubNodeIndex = 0; SubNodeIndex < ArrayHelper.Num(); ++SubNodeIndex)
|
|
|
|
|
{
|
|
|
|
|
const UEnvQueryNode** SubNode = reinterpret_cast<const UEnvQueryNode**>(ArrayHelper.GetRawPtr(SubNodeIndex));
|
|
|
|
|
if (SubNode && *SubNode)
|
|
|
|
|
{
|
|
|
|
|
AddNamedValuesFromObject(QueryOwner, **SubNode, NamedValues, RequiredParams);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-13 11:07:03 -05:00
|
|
|
FStructProperty* TestStruct = CastField<FStructProperty>(TestProperty);
|
2015-10-06 15:59:09 -04:00
|
|
|
if (TestStruct == NULL)
|
2015-03-09 07:19:19 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
continue;
|
2015-03-09 07:19:19 -04:00
|
|
|
}
|
2015-10-06 15:59:09 -04:00
|
|
|
|
|
|
|
|
const FString TypeDesc = TestStruct->GetCPPType(NULL, CPPF_None);
|
|
|
|
|
if (TypeDesc.Contains(GET_STRUCT_NAME_CHECKED(FAIDataProviderIntValue)))
|
2015-03-09 07:19:19 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
const FAIDataProviderIntValue* PropertyValue = TestStruct->ContainerPtrToValuePtr<FAIDataProviderIntValue>(&QueryNode);
|
|
|
|
|
const UAIDataProvider_QueryParams* QueryParamProvider = PropertyValue ? Cast<const UAIDataProvider_QueryParams>(PropertyValue->DataBinding) : nullptr;
|
|
|
|
|
if (QueryParamProvider && !QueryParamProvider->ParamName.IsNone())
|
|
|
|
|
{
|
|
|
|
|
AddNamedValue(QueryOwner, QueryParamProvider->ParamName, EAIParamType::Int, *((float*)&PropertyValue->DefaultValue), NamedValues, RequiredParams);
|
|
|
|
|
}
|
2015-03-09 07:19:19 -04:00
|
|
|
}
|
2015-10-06 15:59:09 -04:00
|
|
|
else if (TypeDesc.Contains(GET_STRUCT_NAME_CHECKED(FAIDataProviderFloatValue)))
|
2015-03-09 07:19:19 -04:00
|
|
|
{
|
2015-10-06 15:59:09 -04:00
|
|
|
const FAIDataProviderFloatValue* PropertyValue = TestStruct->ContainerPtrToValuePtr<FAIDataProviderFloatValue>(&QueryNode);
|
|
|
|
|
const UAIDataProvider_QueryParams* QueryParamProvider = PropertyValue ? Cast<const UAIDataProvider_QueryParams>(PropertyValue->DataBinding) : nullptr;
|
|
|
|
|
if (QueryParamProvider && !QueryParamProvider->ParamName.IsNone())
|
|
|
|
|
{
|
|
|
|
|
AddNamedValue(QueryOwner, QueryParamProvider->ParamName, EAIParamType::Float, PropertyValue->DefaultValue, NamedValues, RequiredParams);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (TypeDesc.Contains(GET_STRUCT_NAME_CHECKED(FAIDataProviderBoolValue)))
|
|
|
|
|
{
|
|
|
|
|
const FAIDataProviderBoolValue* PropertyValue = TestStruct->ContainerPtrToValuePtr<FAIDataProviderBoolValue>(&QueryNode);
|
|
|
|
|
const UAIDataProvider_QueryParams* QueryParamProvider = PropertyValue ? Cast<const UAIDataProvider_QueryParams>(PropertyValue->DataBinding) : nullptr;
|
|
|
|
|
if (QueryParamProvider && !QueryParamProvider->ParamName.IsNone())
|
|
|
|
|
{
|
|
|
|
|
AddNamedValue(QueryOwner, QueryParamProvider->ParamName, EAIParamType::Bool, PropertyValue->DefaultValue ? 1.0f : -1.0f, NamedValues, RequiredParams);
|
|
|
|
|
}
|
2015-03-09 07:19:19 -04:00
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef GET_STRUCT_NAME_CHECKED
|
2015-10-06 15:59:09 -04:00
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-10-06 15:59:09 -04:00
|
|
|
UEnvQuery::UEnvQuery(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UEnvQuery::CollectQueryParams(UObject& QueryOwner, TArray<FAIDynamicParam>& NamedValues) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
TArray<FName> RequiredParams;
|
|
|
|
|
|
|
|
|
|
// collect all params
|
2014-06-13 12:46:13 -04:00
|
|
|
for (int32 OptionIndex = 0; OptionIndex < Options.Num(); OptionIndex++)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-06-13 12:46:13 -04:00
|
|
|
const UEnvQueryOption* Option = Options[OptionIndex];
|
2015-10-06 15:59:09 -04:00
|
|
|
if (Option->Generator == nullptr)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FEQSParamsExporter::AddNamedValuesFromObject(QueryOwner, *(Option->Generator), NamedValues, RequiredParams);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-06-13 12:46:13 -04:00
|
|
|
for (int32 TestIndex = 0; TestIndex < Option->Tests.Num(); TestIndex++)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-06-13 12:46:13 -04:00
|
|
|
const UEnvQueryTest* TestOb = Option->Tests[TestIndex];
|
2015-10-06 15:59:09 -04:00
|
|
|
if (TestOb)
|
|
|
|
|
{
|
|
|
|
|
FEQSParamsExporter::AddNamedValuesFromObject(QueryOwner, *TestOb, NamedValues, RequiredParams);
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// remove unnecessary params
|
2014-06-13 12:46:13 -04:00
|
|
|
for (int32 ValueIndex = NamedValues.Num() - 1; ValueIndex >= 0; ValueIndex--)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-06-13 12:46:13 -04:00
|
|
|
if (!RequiredParams.Contains(NamedValues[ValueIndex].ParamName))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-06-13 12:46:13 -04:00
|
|
|
NamedValues.RemoveAt(ValueIndex);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
Copying //UE4/Dev-Frame to //UE4/Main
#lockdown Nick.Penwarden
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2775736 on 2015/11/20 by Richard.Hinckley
Fix for Paper2D issue with repeated imports in one edutor session. Paper2D import process now creates a new importer at the end. This prevents the sprite sheet import process from leaving frame data around, causing subsequent imports (including imports of different sprite sheets) to include this data inappropriately.
#codereview michael.noland
Change 2776352 on 2015/11/20 by Zak.Middleton
#ue4 - Avoid useless DetachFromParent() for the same pending AttachParent during registration. Added missing UpdateOverlaps() when detaching from object simulating physics.
#rb Marc.Audy, Ori.Cohen
#codereview James.Golding
Change 2776401 on 2015/11/20 by Mieszko.Zielinski
Implemented a way to do batched points projection to navmesh, where every point can declare a custom projection box #UE4
The biggest advantage here is that projection box is independent from projected point - no more manual offsetting of projected point to achieve "100uu up and 500uu down"-like functionality
#jira UE-23705
#rb Lukasz.Furman
Change 2777450 on 2015/11/23 by Martin.Wilson
Bake additive data into animations during cooking to avoid doing additive calculations and extra pose extraction and blending at runtime
#rb Thomas.Sarkanen
Change 2777698 on 2015/11/23 by Mieszko.Zielinski
Gameplay debugging tools fixes #UE4
Fixes:
- made newly added logs respect Log Visualizer's filters
- added handling of invalid data when trying to draw EGameplayDebuggerShapeElement::Cylinder in AGameplayDebuggingHUDComponent::DrawPerception. This is a patch, root cause to be found.
- fixed Log Visualizer resetting it's data while trying to serialize invalid objects. This is a patch, root cause to be addressed.
In addition
- while at it removed bunch of 'auto' and 'class' keywords from the files I've touched
#rb Lukasz.Furman
Change 2777762 on 2015/11/23 by Mieszko.Zielinski
Removed BlackboardComponent's functionality deprecated since 4.7 #UE4
#rb Lukasz.Furman
Change 2777839 on 2015/11/23 by Zak.Middleton
#ue4 - Wrap all vector library calls to math functions through our FMath versions, so they benefit from fixes or improvements therein. Added Exp2() function.
#rb Laurent.Delayen
Change 2777840 on 2015/11/23 by Zak.Middleton
#ue4 - Fix up uses of library math functions to go through our FMath namespace.
#rb Laurent.Delayen
Change 2778287 on 2015/11/23 by Stan.Melax
deprecation of FCollisionQueryParams(bool)
See 2774707 description for the whole story
#OR-9936
#codereview marc.audy
Changes to kite will have to be in a separate check-in
I couldn't submit to all files from the framework branch addition fixes have their files are shelved in cl 2778299
Change 2778507 on 2015/11/23 by Marc.Audy
Eliminate spurious cook warnings for known missing packages
#rb Michael.Noland
Change 2778546 on 2015/11/23 by Aaron.McLeran
Moving occlusion feature settings from audio component to sound attenuation settings struct.
- Sound attenuation setting struct is used for all sounds that do 3d spatialization so it make sense for the occlusion feature settings to be there.
- Kept old low-pass frequency filter setting values on audio component (where HighFrequencyAttenuation used to be)
#rb Zak.Middleton
Change 2778664 on 2015/11/23 by Zak.Middleton
#ue4 - Clarify some comparison functions (IsZero, IsNearlyZero, Equals) in FRotator to explain that they compare as orientations, not other interpretations such as rotational speed, winding, etc.
#rb Aaron.Mcleran
#codereview Frank.Gigliotti
Change 2779335 on 2015/11/24 by Mieszko.Zielinski
Another VisualLog patch to avoid crashing due to a core bug that remains to be investigated #UE4
Again, the core bug here is related visual log trying to serialize invalid objects on a regular basis.
#rb Lukasz.Furman
Change 2779338 on 2015/11/24 by Benn.Gallagher
Fixed crash in Persona when focus is taken from a different window
#jira UE-22516
#rb Ben.Cosh
Change 2779375 on 2015/11/24 by Benn.Gallagher
Fix for deadlock in destructibles. Aquiring actor buffer without releasing causes an infinite wait on next aquire.
#rb Ori.Cohen
Change 2779753 on 2015/11/24 by Zak.Middleton
#ue4 - FMath::Atan2() no longer calls atan2f() because of some compiler or library bugs causing it to randomly return NaN for valid input. It now uses a high-precision minimax approximation instead, measured to be 2x faster than the stock C version.
#rb Brian.Karis
Change 2779853 on 2015/11/24 by Marc.Audy
2015-12-02 16:42:06 -05:00
|
|
|
|
|
|
|
|
void UEnvQuery::PostInitProperties()
|
|
|
|
|
{
|
|
|
|
|
Super::PostInitProperties();
|
|
|
|
|
QueryName = GetFName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UEnvQuery::PostLoad()
|
|
|
|
|
{
|
|
|
|
|
Super::PostLoad();
|
|
|
|
|
|
|
|
|
|
if (QueryName == NAME_None || QueryName.IsValid() == false)
|
|
|
|
|
{
|
|
|
|
|
QueryName = GetFName();
|
|
|
|
|
}
|
2016-03-15 14:49:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if WITH_EDITOR
|
2021-05-12 18:10:03 -04:00
|
|
|
void UEnvQuery::PostRename(UObject* OldOuter, const FName OldName)
|
|
|
|
|
{
|
|
|
|
|
Super::PostRename(OldOuter, OldName);
|
|
|
|
|
|
|
|
|
|
QueryName = GetFName();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-15 14:49:07 -04:00
|
|
|
void UEnvQuery::PostDuplicate(bool bDuplicateForPIE)
|
|
|
|
|
{
|
|
|
|
|
if (bDuplicateForPIE == false)
|
|
|
|
|
{
|
|
|
|
|
QueryName = GetFName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Super::PostDuplicate(bDuplicateForPIE);
|
|
|
|
|
}
|
|
|
|
|
#endif // WITH_EDITOR
|