Fixed coordinate issues

This commit is contained in:
Axel 2022-11-02 16:56:49 +01:00 committed by bernat
parent 0ac47c8950
commit 010c3e29bf
2 changed files with 6 additions and 10 deletions

View File

@ -488,7 +488,7 @@ void AVegetationManager::FreeTileCache(ULevel* InLevel)
void AVegetationManager::UpdateMaterials(FTileData* Tile) void AVegetationManager::UpdateMaterials(FTileData* Tile)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::UpdateMaterials); TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::UpdateMaterials);
const FTransform GlobalTransform = LargeMap->LocalToGlobalTransform(HeroVehicle->GetActorTransform()); const FTransform GlobalTransform = HeroVehicle->GetActorTransform();
const FLinearColor Position = GlobalTransform.GetLocation(); const FLinearColor Position = GlobalTransform.GetLocation();
Tile->UpdateMaterialCache(Position, DebugMaterials); Tile->UpdateMaterialCache(Position, DebugMaterials);
} }
@ -541,7 +541,7 @@ TArray<FElementsToSpawn> AVegetationManager::GetElementsToSpawn(FTileData* Tile)
void AVegetationManager::SpawnSkeletalFoliages(TArray<FElementsToSpawn>& ElementsToSpawn) void AVegetationManager::SpawnSkeletalFoliages(TArray<FElementsToSpawn>& ElementsToSpawn)
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::SpawnSkeletalFoliages); TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::SpawnSkeletalFoliages);
const FTransform HeroTransform = LargeMap->LocalToGlobalTransform(HeroVehicle->GetActorTransform()); const FTransform HeroTransform = HeroVehicle->GetActorTransform();
const FVector HeroLocation = HeroTransform.GetLocation(); const FVector HeroLocation = HeroTransform.GetLocation();
const float HeroDetectionSizeSquared = HeroVehicle->GetDetectionSize() * HeroVehicle->GetDetectionSize(); const float HeroDetectionSizeSquared = HeroVehicle->GetDetectionSize() * HeroVehicle->GetDetectionSize();
@ -589,7 +589,7 @@ void AVegetationManager::SpawnSkeletalFoliages(TArray<FElementsToSpawn>& Element
void AVegetationManager::ActivePooledActors() void AVegetationManager::ActivePooledActors()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::ActivePooledActors); TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::ActivePooledActors);
const FTransform HeroTransform = LargeMap->LocalToGlobalTransform(HeroVehicle->GetActorTransform()); const FTransform HeroTransform = HeroVehicle->GetActorTransform();
const FVector HeroLocation = HeroTransform.GetLocation(); const FVector HeroLocation = HeroTransform.GetLocation();
const float SquaredActiveActorDistance = ActiveActorDistance * ActiveActorDistance; const float SquaredActiveActorDistance = ActiveActorDistance * ActiveActorDistance;
@ -615,7 +615,7 @@ void AVegetationManager::ActivePooledActors()
void AVegetationManager::DestroySkeletalFoliages() void AVegetationManager::DestroySkeletalFoliages()
{ {
TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::DestroySkeletalFoliages); TRACE_CPUPROFILER_EVENT_SCOPE(AVegetationManager::DestroySkeletalFoliages);
const FTransform HeroTransform = LargeMap->LocalToGlobalTransform(HeroVehicle->GetActorTransform()); const FTransform HeroTransform = HeroVehicle->GetActorTransform();
const FVector HeroLocation = HeroTransform.GetLocation(); const FVector HeroLocation = HeroTransform.GetLocation();
const float HeroDetectionSizeSquared = HeroVehicle->GetDetectionSize() * HeroVehicle->GetDetectionSize(); const float HeroDetectionSizeSquared = HeroVehicle->GetDetectionSize() * HeroVehicle->GetDetectionSize();
@ -799,8 +799,7 @@ TArray<FString> AVegetationManager::GetTilesInUse()
const FBox Box = Procedural->ProceduralComponent->GetBounds(); const FBox Box = Procedural->ProceduralComponent->GetBounds();
if (!Box.IsValid) if (!Box.IsValid)
continue; continue;
const FTransform GlobalTransform = LargeMap->LocalToGlobalTransform(HeroVehicle->GetActorTransform()); if (Box.IsInside(HeroVehicle->GetActorTransform().GetLocation()))
if (Box.IsInside(GlobalTransform.GetLocation()))
Results.Emplace(Element.Key); Results.Emplace(Element.Key);
} }
return Results; return Results;

View File

@ -211,10 +211,7 @@ bool ACarlaWheeledVehicle::IsInVehicleRange(const FVector& Location) const
void ACarlaWheeledVehicle::UpdateDetectionBox() void ACarlaWheeledVehicle::UpdateDetectionBox()
{ {
ALargeMapManager* LargeMap = UCarlaStatics::GetLargeMapManager(GetWorld()); const FTransform GlobalTransform = GetActorTransform();
if (!IsValid(LargeMap))
return;
const FTransform GlobalTransform = LargeMap->LocalToGlobalTransform(GetActorTransform());
const FVector Vec { DetectionSize, DetectionSize, DetectionSize }; const FVector Vec { DetectionSize, DetectionSize, DetectionSize };
FBox Box = FBox(-Vec, Vec); FBox Box = FBox(-Vec, Vec);
const FTransform NonScaledTransform(GlobalTransform.GetRotation(), GlobalTransform.GetLocation(), {1.0f, 1.0f, 1.0f}); const FTransform NonScaledTransform(GlobalTransform.GetRotation(), GlobalTransform.GetLocation(), {1.0f, 1.0f, 1.0f});