//CASE 1: edited light already exists in global lights
if(globalLights.containsKey(key)) {
LightNode oldLightNode = globalLights.get(key);
LightNode freshLightNode = buildLightFromState(light);
getRenderer().updateLight(oldLightNode, freshLightNode);
LOGGER.fine("UPDATING LIGHT: "+key);
//CASE 2: edited light does not exist in global lights
} else {
LOGGER.fine("ADDING LIGHT: "+key);
LightNode freshLight = buildLightFromState(light);
globalLights.put(key, freshLight);
getRenderer().addLight(key, freshLight);
//needs to be added anew.
}
//CASE 3: there are global lights that don't exist in shared map
//hint #1: is the global lights length greater than the shared map?
if(globalLights.size() > sharedLightMap.size()) {
String lightToAdd = findALightToAdd();
if(lightToAdd != null) {
LightNode node = globalLights.get(lightToAdd);
LOGGER.fine("SHARING LIGHT: "+key);
sharedLightMap.put(lightToAdd,buildStateFromLight(node));
}
}