Fix crash when player goes out of road map

This commit is contained in:
nsubiron 2017-05-02 15:17:13 +01:00
parent 1bb3f230de
commit 991b2e46b0
1 changed files with 3 additions and 2 deletions

View File

@ -12,9 +12,10 @@ static uint32 ClampFloatToUInt(const float Value, int32 Min, int32 Max)
const FRoadMapPixelData &URoadMap::GetDataAt(const FVector &WorldLocation) const
{
check(IsValid());
const FVector Location = WorldToMap.TransformPosition(WorldLocation);
uint32 X = ClampFloatToUInt(PixelsPerCentimeter * Location.X, 0, Width);
uint32 Y = ClampFloatToUInt(PixelsPerCentimeter * Location.Y, 0, Height);
uint32 X = ClampFloatToUInt(PixelsPerCentimeter * Location.X, 0, Width - 1);
uint32 Y = ClampFloatToUInt(PixelsPerCentimeter * Location.Y, 0, Height - 1);
return GetDataAt(X, Y);
}