Files
UnrealEngineUWP/Engine/Source/Runtime/NavigationSystem/Public/NavModifierComponent.h
Mieszko Zielinski a1708e0630 Made NavModifierComponent work properly even if its owner's root component was marked as nav-irrelevant #UE4
While at it had to mess around with RegastNavMeshGenerator's initialization - the old way in some cases resulted in overriding once configured properties or needless dtNavMesh instance recreation.
In the process I've removed the Generator->Init() call from ARecastNavMesh::ConditionalConstructGenerator since now we call Init as part of generator's construction.

#jira UE-74448
#review-6533131 Yoan.StAmant
#rb Yoan.StAmant

[CL 6604191 by Mieszko Zielinski in Dev-Framework branch]
2019-05-22 06:50:15 -04:00

55 lines
1.8 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Templates/SubclassOf.h"
#include "NavAreas/NavArea.h"
#include "NavRelevantComponent.h"
#include "NavModifierComponent.generated.h"
struct FNavigationRelevantData;
UCLASS(ClassGroup = (Navigation), meta = (BlueprintSpawnableComponent), hidecategories = (Activation), config = Engine, defaultconfig)
class NAVIGATIONSYSTEM_API UNavModifierComponent : public UNavRelevantComponent
{
GENERATED_UCLASS_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Navigation)
TSubclassOf<UNavArea> AreaClass;
/** box extent used ONLY when owning actor doesn't have collision component */
UPROPERTY(EditAnywhere, Category = Navigation)
FVector FailsafeExtent;
/** Setting to 'true' will result in expanding lower bounding box of the nav
* modifier by agent's height, before applying to navmesh */
UPROPERTY(config, EditAnywhere, Category = Navigation)
uint8 bIncludeAgentHeight : 1;
virtual void CalcAndCacheBounds() const override;
virtual void GetNavigationData(FNavigationRelevantData& Data) const override;
UFUNCTION(BlueprintCallable, Category = "AI|Navigation")
void SetAreaClass(TSubclassOf<UNavArea> NewAreaClass);
protected:
void OnTransformUpdated(USceneComponent* RootComponent, EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport);
struct FRotatedBox
{
FBox Box;
FQuat Quat;
FRotatedBox() {}
FRotatedBox(const FBox& InBox, const FQuat& InQuat) : Box(InBox), Quat(InQuat) {}
};
mutable TArray<FRotatedBox> ComponentBounds;
mutable FDelegateHandle TransformUpdateHandle;
/** cached in CalcAndCacheBounds and tested in GetNavigationData to see if
* cached data is still valid */
mutable FTransform CachedTransform;
};