Removed collision from signals defined in the middle of a driving lane.
This commit is contained in:
parent
d9c4de2c54
commit
e7082fae9f
|
@ -259,6 +259,29 @@ void ATrafficLightManager::SpawnTrafficLights()
|
|||
TrafficLight->GetRootComponent(),
|
||||
FAttachmentTransformRules::KeepRelativeTransform);
|
||||
|
||||
auto ClosestWaypointToSignal =
|
||||
GetMap()->GetClosestWaypointOnRoad(CarlaTransform.location);
|
||||
if (ClosestWaypointToSignal)
|
||||
{
|
||||
auto SignalDistanceToRoad =
|
||||
(GetMap()->ComputeTransform(ClosestWaypointToSignal.get()).location - CarlaTransform.location).Length();
|
||||
double LaneWidth = GetMap()->GetLaneWidth(ClosestWaypointToSignal.get());
|
||||
|
||||
if(SignalDistanceToRoad < LaneWidth / 2.0)
|
||||
{
|
||||
UE_LOG(LogCarla, Warning,
|
||||
TEXT("Traffic light %s overlaps a driving lane. Disabling collision..."),
|
||||
*TrafficLightComponent->GetSignId());
|
||||
|
||||
TArray<UPrimitiveComponent*> Primitives;
|
||||
TrafficLight->GetComponents(Primitives);
|
||||
for (auto* Primitive : Primitives)
|
||||
{
|
||||
Primitive->SetCollisionProfileName(TEXT("NoCollision"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RegisterLightComponent(TrafficLightComponent);
|
||||
}
|
||||
}
|
||||
|
@ -299,6 +322,29 @@ void ATrafficLightManager::SpawnSignals()
|
|||
FAttachmentTransformRules::KeepRelativeTransform);
|
||||
SignComponent->InitializeSign(GetMap().get());
|
||||
|
||||
auto ClosestWaypointToSignal =
|
||||
GetMap()->GetClosestWaypointOnRoad(CarlaTransform.location);
|
||||
if (ClosestWaypointToSignal)
|
||||
{
|
||||
auto SignalDistanceToRoad =
|
||||
(GetMap()->ComputeTransform(ClosestWaypointToSignal.get()).location - CarlaTransform.location).Length();
|
||||
double LaneWidth = GetMap()->GetLaneWidth(ClosestWaypointToSignal.get());
|
||||
|
||||
if(SignalDistanceToRoad < LaneWidth / 2.0)
|
||||
{
|
||||
UE_LOG(LogCarla, Warning,
|
||||
TEXT("Traffic light %s overlaps a driving lane. Disabling collision..."),
|
||||
*SignComponent->GetSignId());
|
||||
|
||||
TArray<UPrimitiveComponent*> Primitives;
|
||||
TrafficSign->GetComponents(Primitives);
|
||||
for (auto* Primitive : Primitives)
|
||||
{
|
||||
Primitive->SetCollisionProfileName(TEXT("NoCollision"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TrafficSignComponents.Add(SignComponent->GetSignId(), SignComponent);
|
||||
|
||||
TrafficSigns.Add(TrafficSign);
|
||||
|
|
Loading…
Reference in New Issue