Skip to content

Commit 26f393d

Browse files
rvandoosselaerstephengold
authored andcommitted
Clean up the test case and add some more context. #1340
1 parent 2e1a8dc commit 26f393d

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

jme3-examples/src/main/java/jme3test/light/pbr/TestIssue1340.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package jme3test.light.pbr;
22

3+
import com.jme3.anim.SkinningControl;
34
import com.jme3.app.SimpleApplication;
45
import com.jme3.asset.plugins.UrlLocator;
56
import com.jme3.environment.EnvironmentCamera;
@@ -9,15 +10,20 @@
910
import com.jme3.light.LightProbe;
1011
import com.jme3.math.ColorRGBA;
1112
import com.jme3.math.Vector3f;
13+
import com.jme3.scene.Node;
1214
import com.jme3.scene.Spatial;
1315
import com.jme3.system.AppSettings;
1416

1517
/**
16-
* @author: rvandoosselaer
18+
* This test case validates a shader compilation fix with a model using a PBR material in combination with a
19+
* SkinningControl. When you run this application and you don't see a RenderException, the test is successful.
20+
* For a detailed explanation consult the github issue: https://github.com/jMonkeyEngine/jmonkeyengine/issues/1340
21+
* -rvandoosselaer
1722
*/
1823
public class TestIssue1340 extends SimpleApplication {
1924

20-
int frame;
25+
private Spatial model;
26+
private int frame;
2127

2228
public static void main(String[] args) {
2329
TestIssue1340 testIssue1340 = new TestIssue1340();
@@ -40,8 +46,11 @@ public void simpleInitApp() {
4046

4147
assetManager.registerLocator("https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/RiggedFigure/", UrlLocator.class);
4248

43-
Spatial model = assetManager.loadModel("/glTF-Embedded/RiggedFigure.gltf");
44-
rootNode.attachChild(model);
49+
model = assetManager.loadModel("/glTF-Embedded/RiggedFigure.gltf");
50+
SkinningControl skinningControl = getSkinningControl(model);
51+
if (skinningControl == null || !skinningControl.isHardwareSkinningPreferred()) {
52+
throw new IllegalArgumentException("This test case requires a model with a SkinningControl and with Hardware skinning preferred!");
53+
}
4554

4655
viewPort.setBackgroundColor(ColorRGBA.LightGray);
4756
}
@@ -53,9 +62,31 @@ public void simpleUpdate(float tpf) {
5362
LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
5463
@Override
5564
public void done(LightProbe result) {
56-
enqueue(() -> rootNode.addLight(result));
65+
enqueue(() -> {
66+
rootNode.attachChild(model);
67+
rootNode.addLight(result);
68+
});
5769
}
5870
});
5971
}
6072
}
73+
74+
private SkinningControl getSkinningControl(Spatial model) {
75+
SkinningControl control = model.getControl(SkinningControl.class);
76+
if (control != null) {
77+
return control;
78+
}
79+
80+
if (model instanceof Node) {
81+
for (Spatial child : ((Node) model).getChildren()) {
82+
SkinningControl skinningControl = getSkinningControl(child);
83+
if (skinningControl != null) {
84+
return skinningControl;
85+
}
86+
}
87+
}
88+
89+
return null;
90+
}
91+
6192
}

0 commit comments

Comments
 (0)