From 5b59d9ad14ddd68951b335a7b1cf4d8204b7bf15 Mon Sep 17 00:00:00 2001 From: Axel Date: Wed, 20 Jan 2021 17:54:43 +0100 Subject: [PATCH] Removed double check for carsim mode. --- .../Carla/Source/Carla/Server/CarlaServer.cpp | 6 +---- .../Carla/Vehicle/CarlaWheeledVehicle.cpp | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp index 5de6e6164..871ad6763 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp @@ -920,11 +920,7 @@ void FCarlaServer::FPimpl::BindActions() auto* CarlaVehicle = Cast(ActorView.GetActor()); // The physics in the vehicles works in a different way so to disable them. if (CarlaVehicle != nullptr){ - // Ignore the call for carsim - if (!CarlaVehicle->GetCarlaMovementComponent()) - { - CarlaVehicle->SetSimulatePhysics(bEnabled); - } + CarlaVehicle->SetSimulatePhysics(bEnabled); } // The physics in the walkers also works in a different way so to disable them, // we need to do it in the UCharacterMovementComponent. diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/CarlaWheeledVehicle.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/CarlaWheeledVehicle.cpp index d7367be64..f231f523a 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/CarlaWheeledVehicle.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/CarlaWheeledVehicle.cpp @@ -454,6 +454,11 @@ void ACarlaWheeledVehicle::SetCarlaMovementComponent(UBaseCarlaMovementComponent } void ACarlaWheeledVehicle::SetSimulatePhysics(bool enabled) { + if(!GetCarlaMovementComponent()) + { + return; + } + UWheeledVehicleMovementComponent4W *Vehicle4W = Cast( GetVehicleMovement()); check(Vehicle4W != nullptr); @@ -462,19 +467,16 @@ void ACarlaWheeledVehicle::SetSimulatePhysics(bool enabled) { return; SetActorEnableCollision(true); - if(!GetCarlaMovementComponent()) - { - auto RootComponent = Cast(GetRootComponent()); - RootComponent->SetSimulatePhysics(enabled); - RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); + auto RootComponent = Cast(GetRootComponent()); + RootComponent->SetSimulatePhysics(enabled); + RootComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); - GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite(); - if(enabled) - Vehicle4W->RecreatePhysicsState(); - else - Vehicle4W->DestroyPhysicsState(); - GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite(); - } + GetWorld()->GetPhysicsScene()->GetPxScene()->lockWrite(); + if(enabled) + Vehicle4W->RecreatePhysicsState(); + else + Vehicle4W->DestroyPhysicsState(); + GetWorld()->GetPhysicsScene()->GetPxScene()->unlockWrite(); bPhysicsEnabled = enabled; }