File tree Expand file tree Collapse file tree
jme3-core/src/main/java/com/jme3/scene Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -242,6 +242,26 @@ public void updateLogicalState(float tpf) {
242242 }
243243 }
244244
245+ private void findGlobalLights (Spatial sp , LightList list ) {
246+ LightList lights = sp .getLocalLightList ();
247+ for (Light l : lights ) {
248+ if (l .isGlobal ()) {
249+ list .add (l );
250+ }
251+ }
252+
253+ if (sp instanceof Node ){
254+ Node n = (Node ) sp ;
255+ List <Spatial > children = n .getChildren ();
256+ for (int i = 0 ; i < children .size (); i ++) {
257+ Spatial child = children .get (i );
258+ if ((child .refreshFlags & RF_GLOBAL_LIGHTS )!= 0 ) {
259+ findGlobalLights (child , list );
260+ }
261+ }
262+ }
263+ }
264+
245265 @ Override
246266 public void updateGeometricState () {
247267 if (refreshFlags == 0 ) {
@@ -254,18 +274,11 @@ public void updateGeometricState() {
254274
255275 boolean updateGlobalLights = (refreshFlags & RF_GLOBAL_LIGHTS ) != 0 ;
256276 if (updateGlobalLights ){
257- refreshFlags &= ~RF_GLOBAL_LIGHTS ;
258277 // if root node, we collect the global lights
259278 if (getParent () == null ){
260- depthFirstTraversal (sx ->{
261- LightList childLights = sx .getLocalLightList ();
262- for (Light l : childLights ) {
263- if (l .isGlobal ()) {
264- worldLights .add (l );
265- }
266- }
267- });
279+ findGlobalLights (this , worldLights );
268280 }
281+ refreshFlags &= ~RF_GLOBAL_LIGHTS ;
269282 }
270283
271284 if ((refreshFlags & RF_TRANSFORM ) != 0 ) {
Original file line number Diff line number Diff line change @@ -299,6 +299,9 @@ protected void setLightListRefresh() {
299299 // to update lights.
300300 Spatial p = parent ;
301301 boolean hasGlobalLights = hasGlobalLights ();
302+ if (hasGlobalLights ){
303+ refreshFlags |= RF_GLOBAL_LIGHTS ;
304+ }
302305 while (p != null ) {
303306 if ((p .refreshFlags & RF_CHILD_LIGHTLIST ) != 0 ) {
304307 // The parent already has this flag,
@@ -967,6 +970,9 @@ public void updateGeometricState() {
967970 if ((refreshFlags & RF_MATPARAM_OVERRIDE ) != 0 ) {
968971 updateMatParamOverrides ();
969972 }
973+ if ((refreshFlags & RF_GLOBAL_LIGHTS ) != 0 ) {
974+ refreshFlags &= ~RF_GLOBAL_LIGHTS ;
975+ }
970976 assert refreshFlags == 0 : "Illegal refresh flags state: " + refreshFlags + " for spatial " + getName ();
971977 }
972978
You can’t perform that action at this time.
0 commit comments