Cloning a material with deepClone()?

So, when changing the color of the simple cloned material (after collecting its color object), the original material gets it’s color changed too (of course).

I wonder if a new method deepClone() could clone recognized types? like:

public MatParam deepClone() {
    try {
        MatParam param = (MatParam) super.clone();
        if(param.value instanceof ColorRGBA){ //added code
           param.value = value.clone(); //added code
        } //added code, other types could go here too
        return param;
    } catch (CloneNotSupportedException ex) {
        throw new AssertionError();

or that is not as useful as I am thinking? and may cause memory overload issues?
So instead I should just clone and fix the things I want to be unique (like the color)?

Here is also the same context Cloned materials and parameter changes

Eventually the deepClone() method will use the new Cloner utility which would likely fix this issue. I didn’t convert it in this pass because it seemed unlikely that the current version was causing issues… and I already had to convert a ton of other stuff.

In the mean time, yeah, best just to reset the colors you don’t want shared.

1 Like

cool, thx!!!

nice work! found it :slight_smile: