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

temp

parent 6d9f16b4
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -71,8 +71,14 @@ FPrimitiveSceneProxy* ULineInstancedStaticMeshComponent::CreateSceneProxy()
}
FMatrix Transform;
PerInstanceRenderData->InstanceBuffer_GameThread->GetInstanceTransform(RenderIndex, Transform);
PerInstanceRenderData->InstanceBuffer_GameThread->SetInstance(RenderIndex, Transform, static_cast<float>(RenderIndex));
PerInstanceRenderData->InstanceBuffer_GameThread->GetInstanceTransform(Index, Transform);
float Id = static_cast<float>(Index) + 0.5f;
PerInstanceRenderData->InstanceBuffer_GameThread->SetInstance(Index, Transform, 0.0f);
UE_LOG(LogTemp, Display, TEXT("%f"), Id);
FFloat16 half = FFloat16(Id);
UE_LOG(LogTemp, Display, TEXT("Half: %f"), half.GetFloat());
}
return Proxy;
......@@ -189,67 +195,67 @@ void ULineInstancedStaticMeshComponent::SetLaserMaterial(UMaterialInstanceDynami
TextureRegion->DestX = 0;
TextureRegion->DestY = 0;
}
void ULineInstancedStaticMeshComponent::UpdateLines(float NewLineWidth)
{
LineWidth = NewLineWidth;
for (int32 i = 0; i < 50 * 50; ++i) // until queue is empty
{
if (FOptiXModule::Get().GetOptiXContextManager()->LaserIntersectionQueue.IsEmpty()) break;
TPair<uint32, TArray<FVector>> QueueItem;
FOptiXModule::Get().GetOptiXContextManager()->LaserIntersectionQueue.Dequeue(QueueItem);
int32 Index = QueueItem.Key;
FVector PrevIntersection(0, 0, 0);
bool bIsDirty = true;
for (int32 Intersection = 0; Intersection < SegmentsPerLine * 2; Intersection += 2)
{
int32 TransformIndex = Index * SegmentsPerLine + Intersection / 2; // should be safe
bIsDirty = true;
FTransform LineTransform;
FVector Start = QueueItem.Value[Intersection];
FVector End = QueueItem.Value[Intersection + 1];
float D = FVector::Distance(Start, End);
float DScaled = D / 100.0;
float Width = LineWidth;
if (D == 0)
{
Width = 0; // Set scale to 0 if it shouldn't be drawn
}
LineTransform.SetScale3D({ Width, Width, DScaled });
LineTransform.SetLocation(Start);
// Rotation - align z to point towards End:
FQuat Rot = FRotationMatrix::MakeFromZ(End - Start).ToQuat();
if (D == 0)
{
Rot = FRotationMatrix::Identity.ToQuat();
}
LineTransform.SetRotation(Rot);
FTransform OldTransform;
GetInstanceTransform(TransformIndex, OldTransform, true);
if (OldTransform.Equals(LineTransform))
{
bIsDirty = false;
}
if (LineTransform.ContainsNaN())
{
UE_LOG(LogTemp, Fatal, TEXT("Line Transform contains NaNs!"));
}
UpdateInstanceTransform(TransformIndex, LineTransform, true, bIsDirty, true);
TransformIndex++;
}
}
}
\ No newline at end of file
//
//void ULineInstancedStaticMeshComponent::UpdateLines(float NewLineWidth)
//{
// LineWidth = NewLineWidth;
//
// for (int32 i = 0; i < 50 * 50; ++i) // until queue is empty
// {
// if (FOptiXModule::Get().GetOptiXContextManager()->LaserIntersectionQueue.IsEmpty()) break;
//
// TPair<uint32, TArray<FVector>> QueueItem;
// FOptiXModule::Get().GetOptiXContextManager()->LaserIntersectionQueue.Dequeue(QueueItem);
// int32 Index = QueueItem.Key;
//
// FVector PrevIntersection(0, 0, 0);
//
// bool bIsDirty = true;
//
// for (int32 Intersection = 0; Intersection < SegmentsPerLine * 2; Intersection += 2)
// {
// int32 TransformIndex = Index * SegmentsPerLine + Intersection / 2; // should be safe
// bIsDirty = true;
// FTransform LineTransform;
// FVector Start = QueueItem.Value[Intersection];
// FVector End = QueueItem.Value[Intersection + 1];
//
// float D = FVector::Distance(Start, End);
// float DScaled = D / 100.0;
// float Width = LineWidth;
// if (D == 0)
// {
// Width = 0; // Set scale to 0 if it shouldn't be drawn
// }
//
// LineTransform.SetScale3D({ Width, Width, DScaled });
// LineTransform.SetLocation(Start);
//
// // Rotation - align z to point towards End:
// FQuat Rot = FRotationMatrix::MakeFromZ(End - Start).ToQuat();
//
// if (D == 0)
// {
// Rot = FRotationMatrix::Identity.ToQuat();
// }
//
// LineTransform.SetRotation(Rot);
//
// FTransform OldTransform;
// GetInstanceTransform(TransformIndex, OldTransform, true);
//
// if (OldTransform.Equals(LineTransform))
// {
// bIsDirty = false;
// }
//
// if (LineTransform.ContainsNaN())
// {
// UE_LOG(LogTemp, Fatal, TEXT("Line Transform contains NaNs!"));
// }
//
// UpdateInstanceTransform(TransformIndex, LineTransform, true, bIsDirty, true);
// TransformIndex++;
// }
// }
//}
\ No newline at end of file
......@@ -30,7 +30,7 @@ public:
void InitLineSegments(TArray<int32> LaserIndices, int32 NumberOfSegmentsPerLine, float LineW = 0.01);
void UpdateLines(float NewLineWidth);
//void UpdateLines(float NewLineWidth);
void UpdateLUT(TArray<FColor> ColorMap);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment