From e440deb962775eabf8e9aca3fce1c476a37f0d55 Mon Sep 17 00:00:00 2001
From: David Gilbert <david.gilbert@rwth-aachen.de>
Date: Mon, 7 Sep 2020 16:22:40 +0200
Subject: [PATCH] - Added a quick hack to prevent the component from moving.
 Moving theoretically doesn't affect rendering etc, but it does offset the
 individual point property gizmos for editor lines. That's incredibly
 annoying.

---
 .../Private/GPUInstancedLineComponent.cpp            | 12 ++++++++++++
 .../Public/GPUInstancedLineComponent.h               |  5 ++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp b/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp
index e3398a0..4b2acaa 100644
--- a/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp
+++ b/Source/InstancedMeshLineRendering/Private/GPUInstancedLineComponent.cpp
@@ -9,6 +9,9 @@
 
 UGPUInstancedLineComponent::UGPUInstancedLineComponent(const FObjectInitializer& ObjectInitializer)
 {
+	SetWorldTransform(FTransform::Identity);
+	SetUsingAbsoluteLocation(true);
+	
 	SetCastShadow(false);
 	SetCollisionEnabled(ECollisionEnabled::NoCollision);
 	SetGenerateOverlapEvents(false);
@@ -32,6 +35,9 @@ UGPUInstancedLineComponent::UGPUInstancedLineComponent(const FObjectInitializer&
 	TextureWidth = 2048;
 	TextureHeight = 2048;
 
+	SetMobility(EComponentMobility::Static);
+
+
 	//DynamicLineMaterial = nullptr;
 	//PositionTexture = nullptr;
 }
@@ -419,6 +425,12 @@ void UGPUInstancedLineComponent::PostEditChangeProperty(FPropertyChangedEvent& P
 	
 	Super::PostEditChangeProperty(PropertyChangedEvent);
 }
+
+// This is hacky - reset the transform to 0,0,0 every time the component is moved to not mess up the editor gizmos
+void UGPUInstancedLineComponent::OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport)
+{
+	SetWorldTransform(FTransform::Identity);
+}
 #endif
 
 // Doesn't do anything yet, just as a testing function to see execution order on Unreal startup.
diff --git a/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h b/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h
index 9c87a46..d3e9bda 100644
--- a/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h
+++ b/Source/InstancedMeshLineRendering/Public/GPUInstancedLineComponent.h
@@ -75,7 +75,7 @@ struct FEditorLineData
 };
 
 
-UCLASS(Blueprintable, BlueprintType, meta = (BlueprintSpawnableComponent), HideCategories=("Instances"))
+UCLASS(Blueprintable, BlueprintType, meta = (BlueprintSpawnableComponent), HideCategories=("Instances", "Object", "LOD", "Physics", "Activation", "Materials", "Cooking", "Sockets", "Collision", "Mobile", "HLOD"))
 class INSTANCEDMESHLINERENDERING_API UGPUInstancedLineComponent : public UInstancedStaticMeshComponent
 {
 	GENERATED_BODY()
@@ -125,6 +125,9 @@ protected:
 #if WITH_EDITOR
 	virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override;
 	virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; // need this for the widget as for some godforsaken reason the Chain event doesn't fire...
+	// This is ABSURDLY hacky
+	virtual void OnUpdateTransform(EUpdateTransformFlags UpdateTransformFlags, ETeleportType Teleport = ETeleportType::None) override;
+
 #endif
 
 	virtual void PostLoad() override;
-- 
GitLab