diff --git a/Content/Laser/LaserMaterial.uasset b/Content/Laser/LaserMaterial.uasset index 1a4c98e6df2cc1938a2253970c9cb50d76676a44..8121da9f89ca61ef86b71803a362b1c6342e5b26 100644 Binary files a/Content/Laser/LaserMaterial.uasset and b/Content/Laser/LaserMaterial.uasset differ diff --git a/Source/OptiX/Private/LineInstancedStaticMeshComponent.cpp b/Source/OptiX/Private/LineInstancedStaticMeshComponent.cpp index 12b0ff14029c133a8f81f6ca3d5f37e30614b174..f33e21d6f460b34dc039cf8dc043c47169d1d390 100644 --- a/Source/OptiX/Private/LineInstancedStaticMeshComponent.cpp +++ b/Source/OptiX/Private/LineInstancedStaticMeshComponent.cpp @@ -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 diff --git a/Source/OptiX/Public/LineInstancedStaticMeshComponent.h b/Source/OptiX/Public/LineInstancedStaticMeshComponent.h index 72fe7f3a2253f3f1c056dfd236e77848597816b6..9e53e5cdec6ae5cc31855ddb3218b225183e4d00 100644 --- a/Source/OptiX/Public/LineInstancedStaticMeshComponent.h +++ b/Source/OptiX/Public/LineInstancedStaticMeshComponent.h @@ -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);