Fixed raytracing functions

This commit is contained in:
Guillermo 2022-05-23 13:48:27 +02:00 committed by glopezdiest
parent 0f5252ad62
commit e56470659a
2 changed files with 19 additions and 2 deletions

View File

@ -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.

View File

@ -30,7 +30,15 @@ std::vector<crp::LabelledPoint> 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<bool, crp::LabelledPoint> 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));
}