-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #624 from neph1/fix_spatial_update
speculative fix for failed spatial updates in scenecomposer window
- Loading branch information
Showing
3 changed files
with
96 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
jme3-core/src/com/jme3/gde/core/assets/RefreshJmeSpatial.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
package com.jme3.gde.core.assets; | ||
|
||
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; | ||
import org.openide.nodes.Node; | ||
|
||
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial; | ||
|
||
/** | ||
* Work around for refresh not working recursively on JmeSpatial | ||
* @author rickard | ||
*/ | ||
public class RefreshJmeSpatial implements Runnable { | ||
|
||
private final JmeNode rootNode; | ||
private final String spatialName; | ||
|
||
public RefreshJmeSpatial(JmeNode rootNode, String spatialName) { | ||
this.rootNode = rootNode; | ||
this.spatialName = spatialName; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
refreshNamedSpatial(rootNode, spatialName); | ||
} | ||
/** | ||
* Look for the spatial to update using the name of the asset | ||
* @param spatial | ||
* @param name | ||
*/ | ||
private void refreshNamedSpatial(JmeSpatial spatial, String name){ | ||
if(spatial.getName().equals(name)){ | ||
recurseRefresh(spatial); | ||
} else { | ||
for(Node s: spatial.getChildren().getNodes()){ | ||
if(s instanceof JmeSpatial jmeSpatial){ | ||
refreshNamedSpatial(jmeSpatial, name); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
/** | ||
* Refreshes the spatial and all children | ||
* @param spatial | ||
*/ | ||
private void recurseRefresh(JmeSpatial spatial){ | ||
spatial.refresh(false); | ||
for(Node s: spatial.getChildren().getNodes()){ | ||
if(s instanceof JmeSpatial jmeSpatial){ | ||
recurseRefresh(jmeSpatial); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters