Clamp shine parameter in range of 0..1

This commit is contained in:
Sampo Niskanen 2013-01-06 18:10:17 +02:00
parent 31f620d1bd
commit e4cda1c751

View File

@ -1,6 +1,7 @@
package net.sf.openrocket.appearance; package net.sf.openrocket.appearance;
import net.sf.openrocket.util.Color; import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.MathUtil;
/** /**
* A component appearance. * A component appearance.
@ -9,21 +10,21 @@ import net.sf.openrocket.util.Color;
* @author Bill Kuker <bkuker@billkuker.com> * @author Bill Kuker <bkuker@billkuker.com>
*/ */
public class Appearance { public class Appearance {
public static final Appearance MISSING = new Appearance(new Color(0,0,0), 100, null); public static final Appearance MISSING = new Appearance(new Color(0, 0, 0), 100, null);
private final Color paint; private final Color paint;
private final double shine; private final double shine;
private final Decal texture; private final Decal texture;
Appearance(final Color paint, final double shine, final Decal texture){ Appearance(final Color paint, final double shine, final Decal texture) {
this.paint = paint; this.paint = paint;
this.shine = shine; this.shine = MathUtil.clamp(shine, 0, 1);
this.texture = texture; this.texture = texture;
} }
Appearance(final Color paint, final double shine){ Appearance(final Color paint, final double shine) {
this.paint = paint; this.paint = paint;
this.shine = shine; this.shine = MathUtil.clamp(shine, 0, 1);
this.texture = null; this.texture = null;
} }