diff --git a/CHANGELOG.md b/CHANGELOG.md index d20670329..465e2ca36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Latest + * 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. * Fixed bug causing the TM to block the simulation when another client teleported a vehicle with no physics. * Fixed bug causing the TM to block the simulation when travelling through a short roads that looped on themselves. diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Util/RayTracer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Util/RayTracer.cpp index 64bdd0880..7b6e9c0fb 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Util/RayTracer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Util/RayTracer.cpp @@ -30,7 +30,15 @@ std::vector URayTracer::CastRay( UPrimitiveComponent* Component = Hit.GetComponent(); crp::CityObjectLabel ComponentTag = ATagger::GetTagOfTaggedComponent(*Component); - result.emplace_back(crp::LabelledPoint(Hit.Location, ComponentTag)); + + FVector UELocation = Hit.Location; + ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(World); + ALargeMapManager* LargeMap = GameMode->GetLMManager(); + if (LargeMap) + { + UELocation = LargeMap->LocalToGlobalLocation(UELocation); + } + result.emplace_back(crp::LabelledPoint(UELocation, ComponentTag)); } return result; } @@ -52,7 +60,15 @@ std::pair URayTracer::ProjectPoint( UPrimitiveComponent* Component = Hit.GetComponent(); crp::CityObjectLabel ComponentTag = ATagger::GetTagOfTaggedComponent(*Component); - return std::make_pair(bDidHit, crp::LabelledPoint(Hit.Location, ComponentTag)); + + FVector UELocation = Hit.Location; + ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(World); + ALargeMapManager* LargeMap = GameMode->GetLMManager(); + if (LargeMap) + { + UELocation = LargeMap->LocalToGlobalLocation(UELocation); + } + return std::make_pair(bDidHit, crp::LabelledPoint(UELocation, ComponentTag)); } return std::make_pair(bDidHit, crp::LabelledPoint(FVector(0.0f,0.0f,0.0f), crp::CityObjectLabel::None)); }