Why can't Lights be disabled without removing them from the rootNode?

I can see there was a setEnabled/isEnabled pair in Light.java but it has been commented out. Indeed, there is even a “protected boolean enabled = true;” field but it is never written to neither in Light.java nor in its descendants as PointLight or DirectionalLight.

Is the only way of disabling a light to remove it from the rootNode ?

Is there any shader’y reason for not providing such functionality ?

Anyway, I have used a setUserData(“enabled”) on my LightNode to keep state of my lights being enabled or not.

Why not just remove them to turn them off?

Yes right now that’s what I’m doing.

I admit my point wasn’t made very clearly: I have two distinct predicates to decide whether a light should be affecting the scene or not:

1- If it is within a given range of the camera for this particular light (the sun has a range of Double.NEGATIVE_INFINITY while a firecamp might have a range of 100, say)
2- If game logic decides this light is on or not (flashlight and what not).

The first point I address with addLight/removeLight, while the second one I would have liked to toggle a simple boolean (setEnabled).

This is just about separating gaming from rendering and I like to write code that doesn’t mix with bits it doesn’t absolutely have to mix with.

@gsimard said: This is just about separating gaming from rendering and I like to write code that doesn't mix with bits it doesn't absolutely have to mix with.

Then your “lights” are game objects and your Lights are rendering. If you are serious about the separation then these are two different things and the latter merely reflects the former.

So when your “game object light” is near then you add a real Light object to your scene. When the “game object light” is not near then you remove it. The “game object light” exists whether the scene is being rendered or not.

Now if I happened to make a patch that would make the Light’s “enabled” boolean and its getter/setter work with the renderer, would there be anything against it ?

@gsimard said: Now if I happened to make a patch that would make the Light's "enabled" boolean and its getter/setter work with the renderer, would there be anything against it ?

Probably. I think it might be a pretty invasive change.

My guess is that there are some things that check “do we have a light?” and that check is easy right now. I lights can be disabled then suddenly it has to search to see.

Plus, it strongly hints at using rendering objects as game objects… and as you hinted, separation is good.