CARLA
Loading...
Searching...
No Matches
CarlaNavModifierBox.cpp
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
8
9#include <util/ue-header-guard-begin.h>
10#include "Components/BoxComponent.h"
11#include "NavAreas/NavArea.h"
12#include "NavModifierComponent.h"
13#include <util/ue-header-guard-end.h>
14
15ACarlaNavModifierBox::ACarlaNavModifierBox(const FObjectInitializer &ObjectInitializer)
16 : Super(ObjectInitializer)
17{
18 PrimaryActorTick.bCanEverTick = false;
19 SetCanBeDamaged(false);
20
21 Box = CreateDefaultSubobject<UBoxComponent>(TEXT("Box"));
22 SetRootComponent(Box);
23 // UNavModifierComponent only reads bounds from components that have
24 // collision enabled and can affect navigation, but a component is only
25 // exported as navmesh GEOMETRY when it blocks Pawn or Vehicle
26 // (UPrimitiveComponent::IsNavigationRelevant) -- so query-only collision
27 // that ignores every channel gives us modifier bounds without rasterizing
28 // the box itself.
29 Box->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
30 Box->SetCollisionResponseToAllChannels(ECR_Ignore);
31 Box->SetGenerateOverlapEvents(false);
32 Box->SetCanEverAffectNavigation(true);
33 Box->SetMobility(EComponentMobility::Static);
34
35 NavModifier = CreateDefaultSubobject<UNavModifierComponent>(TEXT("NavModifier"));
36}
37
38void ACarlaNavModifierBox::Configure(TSubclassOf<UNavArea> InAreaClass, const FVector &BoxExtent)
39{
40 Box->SetBoxExtent(BoxExtent);
41 NavModifier->SetAreaClass(InAreaClass);
42}
void Configure(TSubclassOf< UNavArea > AreaClass, const FVector &BoxExtent)
Set the stamped area and the box half-extent (called by the builder before the actor package is saved...
TObjectPtr< UNavModifierComponent > NavModifier
ACarlaNavModifierBox(const FObjectInitializer &ObjectInitializer)
TObjectPtr< UBoxComponent > Box