From dd9fc9f51c580f5892c712dcd323e075e93eaeca Mon Sep 17 00:00:00 2001
From: David Gilbert <david.gilbert@rwth-aachen.de>
Date: Tue, 18 Aug 2020 16:30:40 +0200
Subject: [PATCH] Fixed a crash that happened when trying to clear an
 EditorLine's points array.

---
 .../Private/GPUInstancedLineComponent.cpp                   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp b/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp
index f6bc55a..bb26e02 100644
--- a/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp
+++ b/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp
@@ -329,7 +329,7 @@ void UGPUInstancedLineComponent::PostEditChangeChainProperty(FPropertyChangedCha
 						const int32 NumberOfPointsToRemove = FMath::Max(NumberOfPoints - 2, 0);
 						for(int32 PointToRemove = 0; PointToRemove < NumberOfPointsToRemove; PointToRemove++)
 						{
-							RemovePoint(EditorLines[EditorLineIndex].RespectiveLineId, 2 + PointToRemove);
+							RemovePoint(EditorLines[EditorLineIndex].RespectiveLineId, 2); // just repeatedly delete point 2
 						}
 
 						TArray<FVector> Pts = { FVector(0, 0, 0), FVector(0, 0, 0) };
@@ -1273,7 +1273,7 @@ bool UGPUInstancedLineComponent::RemoveAllEditorLines()
 
 bool UGPUInstancedLineComponent::RemovePoint(int32 LineId, int32 PointId)
 {
-	TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::RemoveLine"))
+	TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::RemovePoint"))
 
 	GPULineArray& Line = LineMap[LineId];
 	const GPULineIndices& Indices = Line[PointId];
@@ -1341,7 +1341,7 @@ bool UGPUInstancedLineComponent::RemovePoint(int32 LineId, int32 PointId)
 // todo
 bool UGPUInstancedLineComponent::RemovePoints(int32 LineId, int32 StartingPointId, int32 NumberOfPoints)
 {
-	TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::RemoveLine"))
+	TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("UGPUInstancedLineComponent::RemovePoints"))
 
 	
 	
-- 
GitLab