UE554: PrimitiveOptions.MaterialID has strange behavior (And Completely Broken on Revolve)(Geometry Script)

I fixed the Revolve problem using this function instead of PrimitiveOptions.MaterialID

UDynamicMesh* SetMaterilaId(UDynamicMesh* TargetMesh, const int MaterialID)
{
	FGeometryScriptIndexList TriangleIDList;

	bool bHasTriangleIDGaps = false;
	UGeometryScriptLibrary_MeshQueryFunctions::GetAllTriangleIDs
	(
		TargetMesh, 
		TriangleIDList, 
		bHasTriangleIDGaps
	);	

	bool bDeferChangeNotifications = false; 
	UGeometryScriptDebug* Debug = nullptr;
	
	return UGeometryScriptLibrary_MeshMaterialFunctions::SetMaterialIDOnTriangles
	(
		TargetMesh, 
		TriangleIDList, 
		MaterialID, 
		bDeferChangeNotifications, 
		Debug
	);
}

NOTE: Use this function before RemapMaterialIDs(…);


I also managed to remove the useless material slot zero, just use this function

void FMaterials::Apply(UDynamicMesh* TargetMesh, const TObjectPtr<UDynamicMeshComponent> &DynamicMeshComponent) const
{
	if (MaterialsList.Num()==0) return;
	
	if (!IsValid(DynamicMeshComponent)) return;
	

	TArray<UMaterialInterface*> CompactedMaterialList = MaterialsList;
	CompactedMaterialList.RemoveAt(0);

	UGeometryScriptDebug* Debug = nullptr;	


	int MissingMaterialID = -1;
	TargetMesh = UGeometryScriptLibrary_MeshMaterialFunctions::RemapToNewMaterialIDsByMaterial
	(
		TargetMesh, 
		MaterialsList, 
		CompactedMaterialList, 
		MissingMaterialID, 
		Debug
	);
	
	DynamicMeshComponent->ConfigureMaterialSet(CompactedMaterialList,true);
}

if someone know why the (MaterialID = 0) is not working let me know please.


A wonderfull bug Epic team… two bugs for the price of one… i had a very funny day today… probably i will enjoy it the rest of the week.


I hope this help somone else.
Best Regards!!

1 Like