Skip to content

Commit

Permalink
Make deprecated 'ambient_light' facet work again in the new light system
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Mar 7, 2022
1 parent 7a093a4 commit ba5159a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
23 changes: 12 additions & 11 deletions msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java
Expand Up @@ -758,17 +758,18 @@ public void initWith(final IScope scope, final IDescription desc) {
setBackgroundColor(Cast.asColor(scope, color.value(scope)));
constantBackground = color.isConst();
}
//
// final IExpression light = facets.getExpr(IKeyword.AMBIENT_LIGHT);
// if (light != null) {
// if (light.getGamlType().equals(Types.COLOR)) {
// setAmbientLightColor(Cast.asColor(scope, light.value(scope)));
// } else {
// final int meanValue = Cast.asInt(scope, light.value(scope));
// setAmbientLightColor(new GamaColor(meanValue, meanValue, meanValue, 255));
// }
// constantAmbientLight = light.isConst();
// }

final IExpression light = facets.getExpr("ambient_light");
if (light != null) {
GamaColor intensity;
if (light.getGamlType().equals(Types.COLOR)) {
intensity = Cast.asColor(scope, light.value(scope));
} else {
final int meanValue = Cast.asInt(scope, light.value(scope));
intensity = new GamaColor(meanValue, meanValue, meanValue, 255);
}
lights.put(ILightDefinition.ambient, new GenericLightDefinition(ILightDefinition.ambient, -1, intensity));
}

final IExpression antialias = facets.getExpr("antialias");
if (antialias != null) { setAntialias(Cast.asBool(scope, antialias.value(scope))); }
Expand Down
Expand Up @@ -35,9 +35,23 @@ public class GenericLightDefinition implements ILightDefinition {
* the id.
*/
public GenericLightDefinition(final String name, final int id, final int intensity) {
this(name, id, new GamaColor(intensity, intensity, intensity, 255));
}

/**
* Instantiates a new generic light definition.
*
* @param name
* the name.
* @param id
* the id.
* @param intensity
* the intensity.
*/
public GenericLightDefinition(final String name, final int id, final GamaColor intensity) {
this.name = name;
this.id = id;
this.intensity = new GamaColor(intensity, intensity, intensity, 255);
this.intensity = intensity;
}

@Override
Expand Down

0 comments on commit ba5159a

Please sign in to comment.