From 31383778d9d578c74d12e6cf2aaaddb582f8c082 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sun, 13 Sep 2015 22:06:32 -0400 Subject: [PATCH] light: ensure directional lights are sorted to be always first --- jme3-core/src/main/java/com/jme3/light/AmbientLight.java | 2 ++ jme3-core/src/main/java/com/jme3/light/DirectionalLight.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/light/AmbientLight.java b/jme3-core/src/main/java/com/jme3/light/AmbientLight.java index 8dd5f9266..58676851c 100644 --- a/jme3-core/src/main/java/com/jme3/light/AmbientLight.java +++ b/jme3-core/src/main/java/com/jme3/light/AmbientLight.java @@ -69,6 +69,8 @@ public class AmbientLight extends Light { @Override public void computeLastDistance(Spatial owner) { + // ambient lights must always be before directional lights. + lastDistance = -2; } @Override diff --git a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java index 87fbf695a..b8e1a1979 100644 --- a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java +++ b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java @@ -80,7 +80,9 @@ public class DirectionalLight extends Light { @Override public void computeLastDistance(Spatial owner) { - lastDistance = 0; // directional lights are always closest to their owner + // directional lights are after ambient lights + // but before all other lights. + lastDistance = -1; } /**