Question for UpdateOriginalMaterial call in FMaterialEditor::PostUndo

Hi I have a question regarding FMaterialEditor::PostUndo in MaterialEditor.cpp.

In CL 36818554, UpdateOriginalMaterial is added to DeleteNodes and PostUndo, but then in CL 37019164, UpdateOriginalMaterial is removed from DeleteNodes.

I don’t know about the problem the previous CL is trying to solve, but based on the change history, UpdateOriginalMaterial in PostUndo could be unnecessary?

I’m asking because it slows down our artists workflow a lot that it compiles materials every time when they hit undo/redo, especially working on base Material Functions,

so it would be great if it’s safe to remove UpdateOriginalMaterial in PostUndo.

Thank you!

Hello, I apologize for the delay response.

The engineer who made those changes is out currently and I’m headed out on vacation. When the original engineer is back, he can take a look.

My understanding on why UpdateOriginalMaterial was added in PostUndo was because we were running into crashes when modifying a material function when you had a material open that used that material function. This ensured the material was always up to date as the material function changed. That fixed the crash, but is also a very big cost to pay for every undo operation.

We can investigate how to make this faster.

Thanks,

Jason

Hello,

Thanks for bearing with me.

As Jason correctly stated, UpdateOriginalMaterial() was added to DeleteNodes during a while trying to identify a fix for an elusive bug that was causing materials to become invalid, together with other changes. We noted though that the call introduced a slow “Apply Changes” window every time a node was deleted which was obviously a regression. After some experimentation though we observed that calling UpdateOriginalMaterial() in DeleteNodes() was actually superfluous so we removed to fix the regression.

Sadly by the way the undo operations are implemented in the engine at the moment we cannot remove the call to UpdateOriginalMaterial() from PostUndo() as that would make materials invalid: for instance, if you create a material function and set it up with some inputs, then create a material and call the function, then (keeping both the function and the material open in the editor) you delete some material inputs and click Apply, then undo, you’ll notice that the Material becomes incorrect (the inputs don’t reappear) if UpdateOriginalMaterial() is removed from PostUndo(). Please feel free to experiment with this.

I hope this clarifies your doubts.

Kind Regards,

Massimo

Hi Jason and Massimo,

I appreciate the detailed explanation, I think I understand the problem now!

We will do some experiment on our end.

Thanks a lot!

Eric