I’ve tracked the issue down to a check in “PCGGeometryHelpers::RemapMaterials”, for some reason a check is being done to see if the “ToMaterials” array is not empty (on the first line), when this doesn’t seem necessary and in fact causes this issue of materials not working properly when appending to an empty dynamic mesh.
void RemapMaterials(UE::Geometry::FDynamicMesh3& InMesh, const TArray<UMaterialInterface*>& FromMaterials, TArray<TObjectPtr<UMaterialInterface>>& ToMaterials, const UE::Geometry::FMeshIndexMappings* OptionalMappings)
{
if (FromMaterials.IsEmpty() || ToMaterials.IsEmpty() || !InMesh.HasAttributes() || !InMesh.Attributes()->HasMaterialID())
{
return;
}
...
Stepping/looking through the code it seems like it should append the materials to the ToMaterials array, regardless of it being empty or not, so I think this check can just be removed? “On my machine” it seems to work fine like this, and it solves the issue I was having ![]()
void RemapMaterials(UE::Geometry::FDynamicMesh3& InMesh, const TArray<UMaterialInterface*>& FromMaterials, TArray<TObjectPtr<UMaterialInterface>>& ToMaterials, const UE::Geometry::FMeshIndexMappings* OptionalMappings)
{
if (FromMaterials.IsEmpty() || !InMesh.HasAttributes() || !InMesh.Attributes()->HasMaterialID())
{
return;
}
...
Let me know if you’d like to know any more info or anything else! ![]()