Skip to content
Snippets Groups Projects
Commit 39f01207 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

- Fixed startup crash in packaged build: Apparently UpdateTextureRegions...

- Fixed startup crash in packaged build: Apparently UpdateTextureRegions requires a padded array in packaged, while PIE can deal with an array that's too short...
parent 54205187
No related branches found
No related tags found
No related merge requests found
...@@ -62,9 +62,11 @@ void UGPUInstancedLineComponent::UpdateWholeTexture() ...@@ -62,9 +62,11 @@ void UGPUInstancedLineComponent::UpdateWholeTexture()
0, 0,
0, FMath::Min(LinearLineData.Num(), TextureWidth), FMath::CeilToInt(static_cast<float>(LinearLineData.Num()) / static_cast<float>(TextureWidth))); 0, FMath::Min(LinearLineData.Num(), TextureWidth), FMath::CeilToInt(static_cast<float>(LinearLineData.Num()) / static_cast<float>(TextureWidth)));
// Copy for now
TArray<FVector4>* TextureData = new TArray<FVector4>(LinearLineData); TArray<FVector4>* TextureData = new TArray<FVector4>(LinearLineData);
// Needed for packaging - works without this in the editor but crashes when packaging.
TextureData->SetNumUninitialized(TextureWidth * TextureHeight, false);
PositionTexture->UpdateTextureRegions(0, 1, Region, TextureWidth * sizeof(FVector4), sizeof(FVector4), (uint8*)TextureData->GetData(), PositionTexture->UpdateTextureRegions(0, 1, Region, TextureWidth * sizeof(FVector4), sizeof(FVector4), (uint8*)TextureData->GetData(),
[](auto InTextureData, auto InRegions) [](auto InTextureData, auto InRegions)
{ {
...@@ -554,19 +556,19 @@ void UGPUInstancedLineComponent::InitializeLinesInBulk(int32 NumberOfLines, int3 ...@@ -554,19 +556,19 @@ void UGPUInstancedLineComponent::InitializeLinesInBulk(int32 NumberOfLines, int3
SetCustomDataValue(InstanceId, 2, Color.B, false); SetCustomDataValue(InstanceId, 2, Color.B, false);
SetCustomDataValue(InstanceId, 3, Width, false); SetCustomDataValue(InstanceId, 3, Width, false);
SetCustomDataValue(InstanceId, 4, static_cast<float>(CurrentTextureIndex), false); // Segment Start SetCustomDataValue(InstanceId, 4, static_cast<float>(CurrentTextureIndex), false); // Segment Start
NewLineArray.Add(TPair<int32, int32>{InstanceId, LinearLineData.Num() + PointIndex}); NewLineArray.Add(TPair<int32, int32>{InstanceId, LineIndex * (NumberOfSegmentsPerLine + 1) + PointIndex});
CurrentTextureIndex++; CurrentTextureIndex++;
MoveTextureMarker(); MoveTextureMarker();
} }
NewLineArray.Add(TPair<int32, int32>{-1, LinearLineData.Num() + NumberOfSegmentsPerLine}); NewLineArray.Add(TPair<int32, int32>{-1, LineIndex * (NumberOfSegmentsPerLine + 1) + NumberOfSegmentsPerLine});
MoveTextureMarker(); MoveTextureMarker();
CurrentTextureIndex++; CurrentTextureIndex++;
NextFreeId++; NextFreeId++;
} }
MarkRenderStateDirty();
UpdateWholeTexture(); UpdateWholeTexture();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment