Skip to content

Commit 2fed713

Browse files
LuisPovedaCanoBlyron
authored andcommitted
Changed GetTrafficSignTriggerVolume to return the first trigger volume for OpenDRIVE-based signals.
1 parent 363da3d commit 2fed713

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Util/BoundingBoxCalculator.cpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -665,31 +665,26 @@ FBoundingBox UBoundingBoxCalculator::GetTrafficSignTriggerVolume(const AActor *A
665665
auto TrafficSign = Cast<ATrafficSignBase>(Actor);
666666
if (TrafficSign != nullptr)
667667
{
668-
// first return a merge of the generated trigger boxes, if any
668+
// Return the first generated trigger box (OpenDRIVE-based signals)
669+
// Newer traffic signs may have multiple trigger volumes (EffectBox, CheckBox, etc.)
670+
// but for the Python API we return only the first one to preserve its rotation
669671
auto TriggerVolumes = TrafficSign->GetTriggerVolumes();
670672
if (TriggerVolumes.Num() > 0)
671673
{
672-
// Transform all trigger volumes to local space first (same as bounding boxes)
674+
UBoxComponent* FirstTriggerVolume = TriggerVolumes[0];
673675
FTransform Transform = Actor->GetActorTransform();
674-
TArray<FBoundingBox> TriggerVolumesLocal;
675676

676-
for (UBoxComponent* TriggerVolume : TriggerVolumes)
677-
{
678-
FBoundingBox TVWorld;
679-
TVWorld.Origin = TriggerVolume->GetComponentLocation();
680-
TVWorld.Extent = TriggerVolume->GetScaledBoxExtent();
681-
TVWorld.Rotation = TriggerVolume->GetComponentRotation();
682-
683-
FBoundingBox TVLocal;
684-
TVLocal.Origin = Transform.InverseTransformPosition(TVWorld.Origin);
685-
TVLocal.Extent = TVWorld.Extent; // Extent doesn't change
686-
TVLocal.Rotation = FRotator(0, 0, 0); // In local space, no rotation
687-
TriggerVolumesLocal.Add(TVLocal);
688-
}
689-
690-
FBoundingBox Box = CombineBBs(TriggerVolumesLocal);
691-
Box.Rotation = FRotator(0, 0, 0);
692-
return Box;
677+
FBoundingBox TVWorld;
678+
TVWorld.Origin = FirstTriggerVolume->GetComponentLocation();
679+
TVWorld.Extent = FirstTriggerVolume->GetScaledBoxExtent();
680+
TVWorld.Rotation = FirstTriggerVolume->GetComponentRotation();
681+
682+
FBoundingBox TVLocal;
683+
TVLocal.Origin = Transform.InverseTransformPosition(TVWorld.Origin);
684+
TVLocal.Extent = TVWorld.Extent; // Extent doesn't change
685+
TVLocal.Rotation = Transform.InverseTransformRotation(TVWorld.Rotation.Quaternion()).Rotator();
686+
687+
return TVLocal;
693688
}
694689
// try to return the original bounding box
695690
auto TriggerVolume = TrafficSign->GetTriggerVolume();

0 commit comments

Comments
 (0)