Fix for clamp() method of ColorRGBA

The clamp method was refactored recently and not working because of a slight oversight.

Fixed clamp method in ColorRGBA. by Perjin · Pull Request #158 · jMonkeyEngine/jmonkeyengine · GitHub

[java]

  • Saturate that color ensuring all channels have a value between 0 and 1
    */
    public void clamp() {
  • FastMath.clamp(r, 0f, 1f);
  • FastMath.clamp(g, 0f, 1f);
  • FastMath.clamp(b, 0f, 1f);
  • FastMath.clamp(a, 0f, 1f);
  • r = FastMath.clamp(r, 0f, 1f);
  • g = FastMath.clamp(g, 0f, 1f);
  • b = FastMath.clamp(b, 0f, 1f);
  • a = FastMath.clamp(a, 0f, 1f);
    }
    /**
    [/java]
2 Likes

^^ Haha this is a nice bug :stuck_out_tongue: Good find.

This method is broken either way but it occurs to me that it should probably be called clampLocal().

I did this…sorry.

@pspeed said: This method is broken either way but it occurs to me that it should probably be called clampLocal().
I think we talked about it when I did this...but can't remember what was the argument against it.

I merged the request

@nehon said: I did this...sorry.

I think we talked about it when I did this…but can’t remember what was the argument against it.

You might be thinking of interpolate. Some of our local, non-local naming is a bit inconsistent.