Getting a crash when trying to replace an actor in the editor. Crash happens in UStaticMeshComponent::CopyInstanceVertexColorsIfCompatible after being called from UEditorEngine::ReplaceActors
FStaticMeshLODResources& SourceLODModel = SourceComponent->GetStaticMesh()->RenderData->LODResources[CurrentLOD];
FStaticMeshComponentLODInfo& SourceLODInfo = SourceComponent->LODData[CurrentLOD]; // CRASHES HERE
FStaticMeshLODResources& TargetLODModel = GetStaticMesh()->RenderData->LODResources[CurrentLOD];
FStaticMeshComponentLODInfo& TargetLODInfo = LODData[CurrentLOD];
if ( SourceLODInfo.OverrideVertexColors != NULL )
{
// Copy vertex colors from source to target.
FColorVertexBuffer* SourceColorBuffer = SourceLODInfo.OverrideVertexColors;
TArray< FColor > CopiedColors;
for ( uint32 ColorVertexIndex = 0; ColorVertexIndex < SourceColorBuffer->GetNumVertices(); ColorVertexIndex++ )
{
CopiedColors.Add( SourceColorBuffer->VertexColor( ColorVertexIndex ) );
}
FColorVertexBuffer* TargetColorBuffer = &TargetLODModel.ColorVertexBuffer;
if ( TargetLODInfo.OverrideVertexColors != NULL )
{
TargetLODInfo.BeginReleaseOverrideVertexColors();
FlushRenderingCommands();
}
else
{
TargetLODInfo.OverrideVertexColors = new FColorVertexBuffer;
TargetLODInfo.OverrideVertexColors->InitFromColorArray( CopiedColors );
}
BeginInitResource( TargetLODInfo.OverrideVertexColors );
}
It appears to be an index out of range error. The test case here is replacing a StaticMeshActor with a blueprint containing the same static mesh + some other stuff, not sure if that’s related but its a consistent crash.