Skip to content

Commit 09c40f6

Browse files
authored
Merge branch 'jMonkeyEngine:master' into master
2 parents 917a240 + 9d52503 commit 09c40f6

File tree

58 files changed

+442
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+442
-245
lines changed

README.md

+1-1

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ if (skipPrebuildLibraries != "true" && buildNativeProjects != "true") {
274274
//}
275275

276276
wrapper {
277-
gradleVersion = '6.9.1'
277+
gradleVersion = '6.9.2'
278278
}
279279

280280

jme3-android/src/main/java/com/jme3/app/jmeSurfaceView/JmeSurfaceView.java

+260-220
Large diffs are not rendered by default.

jme3-android/src/main/java/com/jme3/app/jmeSurfaceView/OnExceptionThrown.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333

3434
/**
3535
* An interface designed to listen for exceptions and fire an event when an exception is thrown.
36-
* @see JmeSurfaceView#setOnExceptionThrown(OnExceptionThrown)
3736
*
3837
* @author pavl_g.
38+
* @see JmeSurfaceView#setOnExceptionThrown(OnExceptionThrown)
3939
*/
4040
public interface OnExceptionThrown {
4141
/**
4242
* Listens for a thrown exception or a thrown error.
43+
*
4344
* @param e the exception or the error that is throwable.
4445
*/
4546
void onExceptionThrown(Throwable e);

jme3-android/src/main/java/com/jme3/app/jmeSurfaceView/OnLayoutDrawn.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
public interface OnLayoutDrawn {
4444
/**
4545
* Dispatched when the layout is drawn on the screen.
46+
*
4647
* @param legacyApplication the application instance.
47-
* @param layout the current layout.
48+
* @param layout the current layout.
4849
*/
4950
void onLayoutDrawn(LegacyApplication legacyApplication, View layout);
5051
}

jme3-android/src/main/java/com/jme3/app/jmeSurfaceView/OnRendererCompleted.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@
3636

3737
/**
3838
* An interface used for invoking an event when the user delay finishes, on the first update of the game.
39-
* @see JmeSurfaceView#setOnRendererCompleted(OnRendererCompleted)
4039
*
4140
* @author pavl_g.
41+
* @see JmeSurfaceView#setOnRendererCompleted(OnRendererCompleted)
4242
*/
4343
public interface OnRendererCompleted {
4444
/**
4545
* Invoked when the user delay finishes, on the first update of the game, the event is dispatched on the
4646
* enclosing Activity context thread.
47-
* @see JmeSurfaceView#update()
47+
*
4848
* @param application the current jme game instance.
4949
* @param appSettings the current window settings of the running jme game.
50+
* @see JmeSurfaceView#update()
5051
*/
5152
void onRenderCompletion(LegacyApplication application, AppSettings appSettings);
5253
}

jme3-android/src/main/java/com/jme3/app/jmeSurfaceView/OnRendererStarted.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@
3838
* An interface used for invoking an event when the application is started explicitly from {@link JmeSurfaceView#startRenderer(int)}.
3939
* NB : This listener must be utilized before using {@link JmeSurfaceView#startRenderer(int)}, ie : it would be ignored if you try to use {@link JmeSurfaceView#setOnRendererStarted(OnRendererStarted)} after
4040
* {@link JmeSurfaceView#startRenderer(int)}.
41-
* @see JmeSurfaceView#setOnRendererStarted(OnRendererStarted)
4241
*
4342
* @author pavl_g.
43+
* @see JmeSurfaceView#setOnRendererStarted(OnRendererStarted)
4444
*/
4545
public interface OnRendererStarted {
4646
/**
4747
* Invoked when the game application is started by the {@link LegacyApplication#start()}, the event is dispatched on the
4848
* holder Activity context thread.
49-
* @see JmeSurfaceView#startRenderer(int)
49+
*
5050
* @param application the game instance.
51-
* @param layout the enclosing layout.
51+
* @param layout the enclosing layout.
52+
* @see JmeSurfaceView#startRenderer(int)
5253
*/
5354
void onRenderStart(LegacyApplication application, View layout);
5455
}

jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2022 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -453,7 +453,7 @@ public void reshape(ViewPort vp, int w, int h) {
453453
//this has no effect at first init but is useful when resizing the canvas with multi views
454454
cam.setViewPort(left, right, bottom, top);
455455
//resizing the camera to fit the new viewport and saving original dimensions
456-
cam.resize(w, h, false);
456+
cam.resize(w, h, true);
457457
left = cam.getViewPortLeft();
458458
right = cam.getViewPortRight();
459459
top = cam.getViewPortTop();

jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2022 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -84,7 +84,7 @@ public class FrameBuffer extends NativeObject {
8484
private RenderBuffer depthBuf = null;
8585
private int colorBufIndex = 0;
8686
private boolean srgb;
87-
private Boolean mipsGenerationHint = null;
87+
private Boolean mipMapsGenerationHint = null;
8888

8989
/**
9090
* <code>RenderBuffer</code> represents either a texture or a
@@ -850,10 +850,10 @@ public boolean isSrgb() {
850850
* @param v true to enable, null to use the default value for the renderer (default to null)
851851
*/
852852
public void setMipMapsGenerationHint(Boolean v) {
853-
mipsGenerationHint = v;
853+
mipMapsGenerationHint = v;
854854
}
855855

856856
public Boolean getMipMapsGenerationHint() {
857-
return mipsGenerationHint;
857+
return mipMapsGenerationHint;
858858
}
859859
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
* Copyright (c) 2009-2022 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
package jme3test.post;
33+
34+
import com.jme3.app.SimpleApplication;
35+
import com.jme3.light.DirectionalLight;
36+
import com.jme3.material.Material;
37+
import com.jme3.math.ColorRGBA;
38+
import com.jme3.math.Vector3f;
39+
import com.jme3.post.FilterPostProcessor;
40+
import com.jme3.post.filters.CartoonEdgeFilter;
41+
import com.jme3.scene.Geometry;
42+
import com.jme3.scene.Node;
43+
import com.jme3.scene.Spatial;
44+
import com.jme3.system.AppSettings;
45+
import com.jme3.texture.Texture;
46+
47+
/**
48+
* Test case for JME issue #1798: filtered scenes are squeezed by resizable
49+
* windows.
50+
* <p>
51+
* If successful, a cartoon monkey head will be shown, and resizing the window
52+
* (using the system's window manager) will not change its shape.
53+
* <p>
54+
* If unsuccessful, then making the window taller will make the head taller, and
55+
* making the window wider will make the head wider.
56+
* <p>
57+
* Based on the TestCartoonEdge application.
58+
*/
59+
public class TestIssue1798 extends SimpleApplication {
60+
// *************************************************************************
61+
// fields
62+
63+
private FilterPostProcessor fpp;
64+
// *************************************************************************
65+
// new methods exposed
66+
67+
public static void main(String[] args) {
68+
AppSettings s = new AppSettings(true);
69+
s.setResizable(true);
70+
TestIssue1798 app = new TestIssue1798();
71+
app.setSettings(s);
72+
app.start();
73+
}
74+
// *************************************************************************
75+
// SimpleApplication methods
76+
77+
/**
78+
* Initialize this application.
79+
*/
80+
@Override
81+
public void simpleInitApp() {
82+
viewPort.setBackgroundColor(ColorRGBA.Gray);
83+
flyCam.setDragToRotate(true);
84+
setupLighting();
85+
setupModel();
86+
setupFilters();
87+
}
88+
// *************************************************************************
89+
// private methods
90+
91+
private void makeToonish(Spatial spatial) {
92+
if (spatial instanceof Node) {
93+
Node n = (Node) spatial;
94+
for (Spatial child : n.getChildren()) {
95+
makeToonish(child);
96+
}
97+
} else if (spatial instanceof Geometry) {
98+
Geometry g = (Geometry) spatial;
99+
Material m = g.getMaterial();
100+
if (m.getMaterialDef().getMaterialParam("UseMaterialColors") != null) {
101+
Texture t = assetManager.loadTexture("Textures/ColorRamp/toon.png");
102+
m.setTexture("ColorRamp", t);
103+
m.setBoolean("UseMaterialColors", true);
104+
m.setColor("Specular", ColorRGBA.Black);
105+
m.setColor("Diffuse", ColorRGBA.White);
106+
m.setBoolean("VertexLighting", true);
107+
}
108+
}
109+
}
110+
111+
private void setupFilters() {
112+
fpp = new FilterPostProcessor(assetManager);
113+
int numSamples = getContext().getSettings().getSamples();
114+
if (numSamples > 0) {
115+
fpp.setNumSamples(numSamples);
116+
}
117+
CartoonEdgeFilter toon = new CartoonEdgeFilter();
118+
toon.setEdgeColor(ColorRGBA.Yellow);
119+
fpp.addFilter(toon);
120+
viewPort.addProcessor(fpp);
121+
}
122+
123+
private void setupLighting() {
124+
DirectionalLight dl = new DirectionalLight();
125+
dl.setDirection(new Vector3f(-1, -1, 1).normalizeLocal());
126+
dl.setColor(new ColorRGBA(2, 2, 2, 1));
127+
rootNode.addLight(dl);
128+
}
129+
130+
private void setupModel() {
131+
Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
132+
makeToonish(model);
133+
rootNode.attachChild(model);
134+
}
135+
}

jme3-jbullet/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ sourceSets {
22
main {
33
java {
44
srcDir 'src/main/java'
5-
srcDir '../jme3-bullet/src/common/java'
65
}
76
}
87
test {

jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ private void updateSizes() {
374374
// framebuffer size (resolution) may differ from window size (e.g. HiDPI)
375375

376376
glfwGetWindowSize(window, width, height);
377-
int windowWidth = width[0];
378-
int windowHeight = height[0];
377+
int windowWidth = width[0] < 1 ? 1 : width[0];
378+
int windowHeight = height[0] < 1 ? 1 : height[0];
379379
if (settings.getWindowWidth() != windowWidth
380380
|| settings.getWindowHeight() != windowHeight) {
381381
settings.setWindowSize(windowWidth, windowHeight);

jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2022 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -89,14 +89,14 @@ public class GltfLoader implements AssetLoader {
8989
private Vector3fArrayPopulator vector3fArrayPopulator = new Vector3fArrayPopulator();
9090
private QuaternionArrayPopulator quaternionArrayPopulator = new QuaternionArrayPopulator();
9191
private Matrix4fArrayPopulator matrix4fArrayPopulator = new Matrix4fArrayPopulator();
92-
private static Map<String, MaterialAdapter> defaultMaterialAdapters = new HashMap<>();
92+
private Map<String, MaterialAdapter> defaultMaterialAdapters = new HashMap<>();
9393
private CustomContentManager customContentManager = new CustomContentManager();
9494
private boolean useNormalsFlag = false;
9595

9696
Map<SkinData, List<Spatial>> skinnedSpatials = new HashMap<>();
9797
IntMap<SkinBuffers> skinBuffers = new IntMap<>();
9898

99-
static {
99+
public GltfLoader() {
100100
defaultMaterialAdapters.put("pbrMetallicRoughness", new PBRMetalRoughMaterialAdapter());
101101
}
102102

jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/TrackData.java

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2020 jMonkeyEngine
2+
* Copyright (c) 2009-2022 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -90,7 +90,14 @@ public void update() {
9090
KeyFrame kf = keyFrames.get(j);
9191
if (Float.floatToIntBits(kf.time) != Float.floatToIntBits(time)) {
9292
if (time > kf.time) {
93-
continue;
93+
if (j < keyFrames.size() - 1) {
94+
// Keep searching for the insertion point.
95+
continue;
96+
}
97+
kf = new KeyFrame();
98+
kf.time = time;
99+
// Add kf after the last keyframe in the list.
100+
keyFrames.add(kf);
94101
} else {
95102
kf = new KeyFrame();
96103
kf.time = time;
@@ -165,19 +172,31 @@ public void update() {
165172
}
166173
}
167174

168-
checkTimesConsistantcy();
175+
checkTimesConsistency();
169176

170177
length = times[times.length - 1];
171178
}
172179

173-
public void checkTimesConsistantcy() {
180+
/**
181+
* Verify that the
182+
* {@link #times}, {@link #translations}, {@link #rotations}, and
183+
* {@link #scales} vectors all have the same length, if present.
184+
*
185+
* @throws AssetLoadException if the lengths differ
186+
*/
187+
public void checkTimesConsistency() {
174188
if ((translations != null && times.length != translations.length)
175189
|| (rotations != null && times.length != rotations.length)
176190
|| (scales != null && times.length != scales.length)) {
177191
throw new AssetLoadException("Inconsistent animation sampling ");
178192
}
179193
}
180194

195+
@Deprecated
196+
public void checkTimesConsistantcy() {
197+
checkTimesConsistency();
198+
}
199+
181200
private void populateTransform(Type type, int index, List<KeyFrame> keyFrames, KeyFrame currentKeyFrame, TransformIndices transformIndices) {
182201
Object transform = getTransform(type, currentKeyFrame);
183202
if (transform != null) {

0 commit comments

Comments
 (0)