MeshVertex has been converted by component transform before being converted by instance transform.
It is ( Vertex * ComponentTransform ) * InstanceTransform.

I thought it has to be converted by (Vertex * InstanceTransform * ComponentTransform).

I found one quick solution.


// code placeholder
 void FMeshMergeHelpers::ExpandInstances(const UInstancedStaticMeshComponent* InInstancedStaticMeshComponent, FMeshDescription& InOutRawMesh, TArray<FSectionInfo>& InOutSections)
     FMeshDescription CombinedRawMesh;
     bool bFirstMesh = true;
     for(const FInstancedStaticMeshInstanceData& InstanceData : InInstancedStaticMeshComponent->PerInstanceSMData)
         FMeshDescription InstanceRawMesh = InOutRawMesh;
 #if 0
         FMeshMergeHelpers::TransformRawMeshVertexData(FTransform(InstanceData.Transform), InstanceRawMesh);
         const FTransform ComponentTransform = InInstancedStaticMeshComponent->GetComponentTransform();
         const FTransform InstanceTransform = ComponentTransform.Inverse() * FTransform(InstanceData.Transform) * ComponentTransform;
         FMeshMergeHelpers::TransformRawMeshVertexData(InstanceTransform, InstanceRawMesh);


Steps to Reproduce
  1. Put ISMs containing scaled instances and non-zero transform in the level. (see screenshot.)
  2. Enable HLOD in worldsetting pane
  3. Generate Proxy meshes in HLOD outliner
  4. Set Forced LoD level 0 in the HLOD outliner pane to display the meshes place a  wrong location.


[Image Removed]

Have Comments or More Details?

There's no existing public thread on this issue, so head over toAnswerHub just mention UE-79140 in the post.

Login to Vote

ComponentTools - HLOD
Affects Versions4.23
Target Fix4.24
Fix Commit8211754
Main Commit8211754
Release Commit9552237
CreatedAug 20, 2019
ResolvedAug 23, 2019
UpdatedOct 28, 2019