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

Fixed two bugs, one of the introduced by cleanup.

parent 91ffe586
No related branches found
No related tags found
No related merge requests found
...@@ -104,7 +104,7 @@ int32 UGPUInstancedLineComponent::AddNewSegmentInstance(const FLinearColor& Colo ...@@ -104,7 +104,7 @@ int32 UGPUInstancedLineComponent::AddNewSegmentInstance(const FLinearColor& Colo
return InstanceId; return InstanceId;
} }
void UGPUInstancedLineComponent::UpdateTexture(const FIntPoint& StartIndex, int32 NumberOfPoints, uint8* SrcData) void UGPUInstancedLineComponent::UpdateTexture(const FIntPoint& StartIndex, int32 NumberOfPoints, uint8* SrcData, bool bMarkRenderStateDirty)
{ {
int32 NumRegions = 0; int32 NumRegions = 0;
FUpdateTextureRegion2D* Regions = CalculateTextureRegions(StartIndex, NumberOfPoints, NumRegions); FUpdateTextureRegion2D* Regions = CalculateTextureRegions(StartIndex, NumberOfPoints, NumRegions);
...@@ -117,6 +117,10 @@ void UGPUInstancedLineComponent::UpdateTexture(const FIntPoint& StartIndex, int3 ...@@ -117,6 +117,10 @@ void UGPUInstancedLineComponent::UpdateTexture(const FIntPoint& StartIndex, int3
delete InTextureData; delete InTextureData;
delete InRegions; delete InRegions;
}); });
// Probably not a good place to call this
if(bMarkRenderStateDirty)
MarkRenderStateDirty();
} }
void UGPUInstancedLineComponent::Init() void UGPUInstancedLineComponent::Init()
...@@ -650,7 +654,7 @@ int32 UGPUInstancedLineComponent::AddLine(const TArray<FVector>& Line, FLinearCo ...@@ -650,7 +654,7 @@ int32 UGPUInstancedLineComponent::AddLine(const TArray<FVector>& Line, FLinearCo
return LineId; return LineId;
} }
int32 UGPUInstancedLineComponent::AddLine(TArray<FVector4>& Line, FLinearColor Color, float Width) int32 UGPUInstancedLineComponent::AddLine(TArray<FVector4>& Line, FLinearColor Color, float Width, bool bMarkRenderStateDirty)
{ {
if (Line.Num() < 2) if (Line.Num() < 2)
{ {
...@@ -689,7 +693,7 @@ int32 UGPUInstancedLineComponent::AddLine(TArray<FVector4>& Line, FLinearColor C ...@@ -689,7 +693,7 @@ int32 UGPUInstancedLineComponent::AddLine(TArray<FVector4>& Line, FLinearColor C
// Store the points in a linear array here // Store the points in a linear array here
LinearLineData.Append(*TextureData); LinearLineData.Append(*TextureData);
UpdateTexture(InitialTextureMarker, Line.Num(), (uint8*)TextureData->GetData()); UpdateTexture(InitialTextureMarker, TextureData->Num(), (uint8*)TextureData->GetData(), bMarkRenderStateDirty);
return LineId; return LineId;
...@@ -951,7 +955,7 @@ bool UGPUInstancedLineComponent::AddPoints(int32 LineId, const TArray<FVector>& ...@@ -951,7 +955,7 @@ bool UGPUInstancedLineComponent::AddPoints(int32 LineId, const TArray<FVector>&
UpdateTexture(InitialTextureMarker, Points.Num(), (uint8*)TextureData->GetData()); UpdateTexture(InitialTextureMarker, Points.Num(), (uint8*)TextureData->GetData());
MarkRenderStateDirty(); //MarkRenderStateDirty(); called in UpdateTexture already
return true; return true;
} }
...@@ -1248,7 +1252,7 @@ bool UGPUInstancedLineComponent::UpdatePoints(int32 LineId, int32 StartingPointI ...@@ -1248,7 +1252,7 @@ bool UGPUInstancedLineComponent::UpdatePoints(int32 LineId, int32 StartingPointI
{ {
(*TextureData)[0].W = 0; (*TextureData)[0].W = 0;
} }
if (StartingPointId + Points.Num() == Line.IndexArray.Num()) if (StartingPointId + TextureData->Num() == Line.IndexArray.Num())
{ {
TextureData->Last().W = -1; TextureData->Last().W = -1;
} }
...@@ -1389,7 +1393,7 @@ bool UGPUInstancedLineComponent::RemovePoint(int32 LineId, int32 PointId) ...@@ -1389,7 +1393,7 @@ bool UGPUInstancedLineComponent::RemovePoint(int32 LineId, int32 PointId)
Line.IndexArray[i].TextureIndex -= 1; Line.IndexArray[i].TextureIndex -= 1;
SetCustomDataValue(Line.IndexArray[i].InstanceIndex, 4, Line.IndexArray[i].TextureIndex, false); SetCustomDataValue(Line.IndexArray[i].InstanceIndex, 4, Line.IndexArray[i].TextureIndex, false);
} }
MarkRenderStateDirty(); //MarkRenderStateDirty();
RemoveInstance(RemovedInstanceId); RemoveInstance(RemovedInstanceId);
} }
......
...@@ -148,7 +148,7 @@ public: ...@@ -148,7 +148,7 @@ public:
int32 AddNewSegmentInstance(const FLinearColor& Color, float Width, int32 Index); int32 AddNewSegmentInstance(const FLinearColor& Color, float Width, int32 Index);
void UpdateTexture(const FIntPoint& StartIndex, int32 NumberOfPoints, uint8* SrcData); void UpdateTexture(const FIntPoint& StartIndex, int32 NumberOfPoints, uint8* SrcData, bool bMarkRenderStateDirty = true);
/** /**
* Reserves internal memory for a given amount of Lines and Segments per Line. * Reserves internal memory for a given amount of Lines and Segments per Line.
...@@ -204,7 +204,7 @@ public: ...@@ -204,7 +204,7 @@ public:
int32 AddLine(const TArray<FVector>& Line, FLinearColor Color, float Width = 1.0); int32 AddLine(const TArray<FVector>& Line, FLinearColor Color, float Width = 1.0);
int32 AddLine(TArray<FVector4>& Line, FLinearColor Color, float Width = 1.0); int32 AddLine(TArray<FVector4>& Line, FLinearColor Color, float Width = 1.0, bool bMarkRenderStateDirty = true);
/** /**
* Adds a line and returns the respective ID of the line, which can be used to identify it for updating, modifying and removing. * Adds a line and returns the respective ID of the line, which can be used to identify it for updating, modifying and removing.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment