Updated the information that traffic lights sent to vehicles
This commit is contained in:
parent
e228aa0fff
commit
90c624bc8c
|
@ -1,5 +1,8 @@
|
||||||
## Latest
|
## Latest
|
||||||
|
|
||||||
|
* Fixed bug at `Vehicle.get_traffic_light_state()` and `Vehicle.is_at_traffic_light()` causing vehicles to temporarily not lose the information of a traffic light if they moved away from it before it turned green.
|
||||||
|
* Fixed bug causing the `Vehicle.get_traffic_light_state()` function not notify about the green to yellow and yellow to red light state changes.
|
||||||
|
* Fixed bug causing the `Vehicle.is_at_traffic_light()` function to return *false* if the traffic light was green.
|
||||||
* Fixed bug causing the scene lights to return an incorrect location at large maps.
|
* Fixed bug causing the scene lights to return an incorrect location at large maps.
|
||||||
* Fixed bug causing the `world.ground_projection()` function to return an incorrect location at large maps.
|
* Fixed bug causing the `world.ground_projection()` function to return an incorrect location at large maps.
|
||||||
* Added failure state to vehicles, which can be retrieved by using `Vehicle.get_failure_state()`. Only Rollover failure state is currently supported.
|
* Added failure state to vehicles, which can be retrieved by using `Vehicle.get_failure_state()`. Only Rollover failure state is currently supported.
|
||||||
|
|
|
@ -78,11 +78,8 @@ void ATrafficLightBase::NotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
|
||||||
if (Controller != nullptr)
|
if (Controller != nullptr)
|
||||||
{
|
{
|
||||||
Controller->SetTrafficLightState(GetTrafficLightState());
|
Controller->SetTrafficLightState(GetTrafficLightState());
|
||||||
if (GetTrafficLightState() != ETrafficLightState::Green)
|
Vehicles.Add(Controller);
|
||||||
{
|
Controller->SetTrafficLight(this);
|
||||||
Vehicles.Add(Controller);
|
|
||||||
Controller->SetTrafficLight(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,8 @@ void UTrafficLightComponent::GenerateTrafficLightBox(const FTransform BoxTransfo
|
||||||
const FVector BoxSize)
|
const FVector BoxSize)
|
||||||
{
|
{
|
||||||
UBoxComponent* BoxComponent = GenerateTriggerBox(BoxTransform, BoxSize);
|
UBoxComponent* BoxComponent = GenerateTriggerBox(BoxTransform, BoxSize);
|
||||||
BoxComponent->OnComponentBeginOverlap.AddDynamic(this, &UTrafficLightComponent::OnOverlapTriggerBox);
|
BoxComponent->OnComponentBeginOverlap.AddDynamic(this, &UTrafficLightComponent::OnBeginOverlapTriggerBox);
|
||||||
|
BoxComponent->OnComponentEndOverlap.AddDynamic(this, &UTrafficLightComponent::OnEndOverlapTriggerBox);
|
||||||
AddEffectTriggerVolume(BoxComponent);
|
AddEffectTriggerVolume(BoxComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,16 +117,8 @@ void UTrafficLightComponent::SetLightState(ETrafficLightState NewState)
|
||||||
if (Controller != nullptr)
|
if (Controller != nullptr)
|
||||||
{
|
{
|
||||||
Controller->SetTrafficLightState(LightState);
|
Controller->SetTrafficLightState(LightState);
|
||||||
if (LightState == ETrafficLightState::Green)
|
|
||||||
{
|
|
||||||
Controller->SetTrafficLight(nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LightState == ETrafficLightState::Green)
|
|
||||||
{
|
|
||||||
Vehicles.Empty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ETrafficLightState UTrafficLightComponent::GetLightState() const
|
ETrafficLightState UTrafficLightComponent::GetLightState() const
|
||||||
|
@ -161,7 +154,7 @@ const UTrafficLightController* UTrafficLightComponent::GetController() const
|
||||||
return TrafficLightController;
|
return TrafficLightController;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UTrafficLightComponent::OnOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
|
void UTrafficLightComponent::OnBeginOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
|
||||||
AActor *OtherActor,
|
AActor *OtherActor,
|
||||||
UPrimitiveComponent *OtherComp,
|
UPrimitiveComponent *OtherComp,
|
||||||
int32 OtherBodyIndex,
|
int32 OtherBodyIndex,
|
||||||
|
@ -176,12 +169,27 @@ void UTrafficLightComponent::OnOverlapTriggerBox(UPrimitiveComponent *Overlapped
|
||||||
if (VehicleController)
|
if (VehicleController)
|
||||||
{
|
{
|
||||||
VehicleController->SetTrafficLightState(LightState);
|
VehicleController->SetTrafficLightState(LightState);
|
||||||
if (LightState != ETrafficLightState::Green)
|
Vehicles.Add(VehicleController);
|
||||||
{
|
VehicleController->SetTrafficLight(Cast<ATrafficLightBase>(GetOwner()));
|
||||||
Vehicles.Add(VehicleController);
|
}
|
||||||
VehicleController->SetTrafficLight(
|
}
|
||||||
Cast<ATrafficLightBase>(GetOwner()));
|
}
|
||||||
}
|
|
||||||
|
void UTrafficLightComponent::OnEndOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
|
||||||
|
AActor *OtherActor,
|
||||||
|
UPrimitiveComponent *OtherComp,
|
||||||
|
int32 OtherBodyIndex)
|
||||||
|
{
|
||||||
|
ACarlaWheeledVehicle * Vehicle = Cast<ACarlaWheeledVehicle>(OtherActor);
|
||||||
|
if (Vehicle)
|
||||||
|
{
|
||||||
|
AWheeledVehicleAIController* VehicleController =
|
||||||
|
Cast<AWheeledVehicleAIController>(Vehicle->GetController());
|
||||||
|
if (VehicleController)
|
||||||
|
{
|
||||||
|
VehicleController->SetTrafficLightState(ETrafficLightState::Green);
|
||||||
|
VehicleController->SetTrafficLight(nullptr);
|
||||||
|
Vehicles.Remove(VehicleController);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,13 +55,21 @@ public:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void OnOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
|
void OnBeginOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
|
||||||
AActor *OtherActor,
|
AActor *OtherActor,
|
||||||
UPrimitiveComponent *OtherComp,
|
UPrimitiveComponent *OtherComp,
|
||||||
int32 OtherBodyIndex,
|
int32 OtherBodyIndex,
|
||||||
bool bFromSweep,
|
bool bFromSweep,
|
||||||
const FHitResult &SweepResult);
|
const FHitResult &SweepResult);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void OnEndOverlapTriggerBox(UPrimitiveComponent *OverlappedComp,
|
||||||
|
AActor *OtherActor,
|
||||||
|
UPrimitiveComponent *OtherComp,
|
||||||
|
int32 OtherBodyIndex);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend ATrafficLightManager;
|
friend ATrafficLightManager;
|
||||||
|
|
Loading…
Reference in New Issue