public RenderState copyMergedTo(RenderState additionalState, RenderState state) {
        if (additionalState == null) {
            return this;
        }

        if (additionalState.applyWireFrame) {
            state.wireframe = additionalState.wireframe;
        } else {
            state.wireframe = wireframe;
        }

        if (additionalState.applyCullMode) {
            state.cullMode = additionalState.cullMode;
        } else {
            state.cullMode = cullMode;
        }
        if (additionalState.applyDepthWrite) {
            state.depthWrite = additionalState.depthWrite;
        } else {
            state.depthWrite = depthWrite;
        }
        if (additionalState.applyDepthTest) {
            state.depthTest = additionalState.depthTest;
        } else {
            state.depthTest = depthTest;
        }
        if (additionalState.applyDepthFunc) {
            state.depthFunc = additionalState.depthFunc;
        } else {
            state.depthFunc = depthFunc;
        }
        if (additionalState.applyColorWrite) {
            state.colorWrite = additionalState.colorWrite;
        } else {
            state.colorWrite = colorWrite;
        }
        if (additionalState.applyBlendMode) {
            state.blendMode = additionalState.blendMode;
            if (additionalState.blendMode == BlendMode.Custom) {
                state.blendEquation = additionalState.blendEquation;
                state.blendEquationAlpha = additionalState.blendEquationAlpha;
                state.sfactorRGB = additionalState.sfactorRGB;
                state.dfactorRGB = additionalState.dfactorRGB;
                state.sfactorAlpha = additionalState.sfactorAlpha;
                state.dfactorAlpha = additionalState.dfactorAlpha;
            }
        } else {
            state.blendMode = blendMode;
            if (blendMode == BlendMode.Custom) {
                state.blendEquation = blendEquation;
                state.blendEquationAlpha = blendEquationAlpha;
                state.sfactorRGB = sfactorRGB;
                state.dfactorRGB = dfactorRGB;
                state.sfactorAlpha = sfactorAlpha;
                state.dfactorAlpha = dfactorAlpha;
            }
        }

        if (additionalState.applyPolyOffset) {
            state.offsetEnabled = additionalState.offsetEnabled;
            state.offsetFactor = additionalState.offsetFactor;
            state.offsetUnits = additionalState.offsetUnits;
        } else {
            state.offsetEnabled = offsetEnabled;
            state.offsetFactor = offsetFactor;
            state.offsetUnits = offsetUnits;
        }
        if (additionalState.applyStencilTest) {
            state.stencilTest = additionalState.stencilTest;

            state.frontStencilStencilFailOperation = additionalState.frontStencilStencilFailOperation;
            state.frontStencilDepthFailOperation = additionalState.frontStencilDepthFailOperation;
            state.frontStencilDepthPassOperation = additionalState.frontStencilDepthPassOperation;

            state.backStencilStencilFailOperation = additionalState.backStencilStencilFailOperation;
            state.backStencilDepthFailOperation = additionalState.backStencilDepthFailOperation;
            state.backStencilDepthPassOperation = additionalState.backStencilDepthPassOperation;

            state.frontStencilFunction = additionalState.frontStencilFunction;
            state.backStencilFunction = additionalState.backStencilFunction;

            state.frontStencilMask = additionalState.frontStencilMask;
            state.frontStencilReference = additionalState.frontStencilMask;
            state.backStencilMask = additionalState.backStencilMask;
            state.backStencilReference = additionalState.backStencilMask;
        } else {
            state.stencilTest = stencilTest;

            state.frontStencilStencilFailOperation = frontStencilStencilFailOperation;
            state.frontStencilDepthFailOperation = frontStencilDepthFailOperation;
            state.frontStencilDepthPassOperation = frontStencilDepthPassOperation;

            state.backStencilStencilFailOperation = backStencilStencilFailOperation;
            state.backStencilDepthFailOperation = backStencilDepthFailOperation;
            state.backStencilDepthPassOperation = backStencilDepthPassOperation;

            state.frontStencilFunction = frontStencilFunction;
            state.backStencilFunction = backStencilFunction;

            state.frontStencilMask = frontStencilMask;
            state.frontStencilReference = frontStencilMask;
            state.backStencilMask = backStencilMask;
            state.backStencilReference = backStencilMask;
        }
        if (additionalState.applyLineWidth) {
            state.lineWidth = additionalState.lineWidth;
        } else {
            state.lineWidth = lineWidth;
        }
        state.cachedHashCode = -1;
        return state;
    }
Merges <code>this</code> state and <code>additionalState</code> into
the parameter <code>state</code> based on a specific criteria.

<p>The criteria for this merge is the following:<br>
For every given property, such as alpha test or depth write, check
if it was modified from the original in the <code>additionalState</code>
if it was modified, then copy the property from the <code>additionalState</code>
into the parameter <code>state</code>, otherwise, copy the property from <code>this</code>
into the parameter <code>state</code>. If <code>additionalState</code>
is <code>null</code>, then no modifications are made and <code>this</code> is returned,
otherwise, the parameter <code>state</code> is returned with the result
of the merge.

@param additionalState The <code>additionalState</code>, from which data is taken only
if it was modified by the user.
@param state Contains output of the method if <code>additionalState</code>
is not null.
@return <code>state</code> if <code>additionalState</code> is non-null,
otherwise returns <code>this</code>
jme3-core/src/main/java/com/jme3/material/RenderState.java