Skip to content

Commit 7dd8693

Browse files
authored
Merge branch 'jMonkeyEngine:master' into master
2 parents f25ce69 + 951b430 commit 7dd8693

File tree

61 files changed

+2615
-555
lines changed

Some content is hidden

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

61 files changed

+2615
-555
lines changed

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
jobs:
66
format:
77
runs-on: ubuntu-latest
8-
if: github.repository != 'jMonkeyEngine/jmonkeyengine'
8+
if: ${{ false }}
99
steps:
1010
- name: Checkout
1111
uses: actions/checkout@v4

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ appveyor.yml
4848
javadoc_deploy
4949
javadoc_deploy.pub
5050
!.vscode/settings.json
51-
!.vscode/JME_style.xml
51+
!.vscode/JME_style.xml
52+
!.vscode/extensions.json

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"vscjava.vscode-java-pack",
4+
"slevesque.shader"
5+
]
6+
}

.vscode/settings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
22
"java.configuration.updateBuildConfiguration": "automatic",
3+
"java.compile.nullAnalysis.mode": "automatic",
34
"java.refactor.renameFromFileExplorer": "prompt",
45
"java.format.settings.url": "./.vscode/JME_style.xml",
56
"editor.formatOnPaste": true,
6-
"editor.formatOnType": true
7+
"editor.formatOnType": false,
8+
"editor.formatOnSave": true,
9+
"editor.formatOnSaveMode": "modifications" ,
10+
11+
"prettier.tabWidth": 4,
12+
"prettier.printWidth": 110,
13+
"prettier.enable": true,
14+
"prettier.resolveGlobalModules": true
715
}

common.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tasks.withType(JavaCompile) { // compile-time options:
2828
}
2929

3030
ext {
31-
lwjgl3Version = '3.3.2' // used in both the jme3-lwjgl3 and jme3-vr build scripts
31+
lwjgl3Version = '3.3.3' // used in both the jme3-lwjgl3 and jme3-vr build scripts
3232
niftyVersion = '1.4.3' // used in both the jme3-niftygui and jme3-examples build scripts
3333
}
3434

gradle/wrapper/gradle-wrapper.jar

50 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

jme3-core/src/main/java/com/jme3/export/FormatVersion.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@
3939
public final class FormatVersion {
4040

4141
/**
42-
* Version number of the format
42+
* Version number of the format.
43+
* <p>
44+
* Changes for each version:
45+
* <ol>
46+
* <li>Undocumented
47+
* <li>Undocumented
48+
* <li>XML prefixes "jme-" to all key names
49+
* </ol>
4350
*/
44-
public static final int VERSION = 2;
51+
public static final int VERSION = 3;
4552

4653
/**
4754
* Signature of the format: currently, "JME3" as ASCII.

jme3-core/src/main/java/com/jme3/input/FlyByCamera.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2023 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -383,9 +383,24 @@ protected void rotateCamera(float value, Vector3f axis) {
383383
* @param value zoom amount
384384
*/
385385
protected void zoomCamera(float value) {
386-
float newFov = cam.getFov() + value * 0.1F * zoomSpeed;
387-
if (newFov > 0) {
388-
cam.setFov(newFov);
386+
if (cam.isParallelProjection()) {
387+
float zoomFactor = 1.0F + value * 0.01F * zoomSpeed;
388+
if (zoomFactor > 0F) {
389+
float left = zoomFactor * cam.getFrustumLeft();
390+
float right = zoomFactor * cam.getFrustumRight();
391+
float top = zoomFactor * cam.getFrustumTop();
392+
float bottom = zoomFactor * cam.getFrustumBottom();
393+
394+
float near = cam.getFrustumNear();
395+
float far = cam.getFrustumFar();
396+
cam.setFrustum(near, far, left, right, top, bottom);
397+
}
398+
399+
} else { // perspective projection
400+
float newFov = cam.getFov() + value * 0.1F * zoomSpeed;
401+
if (newFov > 0) {
402+
cam.setFov(newFov);
403+
}
389404
}
390405
}
391406

jme3-core/src/main/java/com/jme3/material/Material.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -890,16 +890,37 @@ private boolean isBO(final VarType type) {
890890
return type == VarType.BufferObject;
891891
}
892892

893-
private void updateRenderState(RenderManager renderManager, Renderer renderer, TechniqueDef techniqueDef) {
893+
private void updateRenderState(Geometry geometry, RenderManager renderManager, Renderer renderer, TechniqueDef techniqueDef) {
894894
if (renderManager.getForcedRenderState() != null) {
895-
renderer.applyRenderState(renderManager.getForcedRenderState());
895+
mergedRenderState.copyFrom(renderManager.getForcedRenderState());
896+
} else if (techniqueDef.getRenderState() != null) {
897+
mergedRenderState.copyFrom(RenderState.DEFAULT);
898+
techniqueDef.getRenderState().copyMergedTo(additionalState, mergedRenderState);
896899
} else {
897-
if (techniqueDef.getRenderState() != null) {
898-
renderer.applyRenderState(techniqueDef.getRenderState().copyMergedTo(additionalState, mergedRenderState));
899-
} else {
900-
renderer.applyRenderState(RenderState.DEFAULT.copyMergedTo(additionalState, mergedRenderState));
901-
}
900+
mergedRenderState.copyFrom(RenderState.DEFAULT);
901+
RenderState.DEFAULT.copyMergedTo(additionalState, mergedRenderState);
902902
}
903+
// test if the face cull mode should be flipped before render
904+
if (mergedRenderState.isFaceCullFlippable() && isNormalsBackward(geometry.getWorldScale())) {
905+
mergedRenderState.flipFaceCull();
906+
}
907+
renderer.applyRenderState(mergedRenderState);
908+
}
909+
910+
/**
911+
* Returns true if the geometry world scale indicates that normals will be backward.
912+
* @param scalar geometry world scale
913+
* @return
914+
*/
915+
private boolean isNormalsBackward(Vector3f scalar) {
916+
// count number of negative scalar vector components
917+
int n = 0;
918+
if (scalar.x < 0) n++;
919+
if (scalar.y < 0) n++;
920+
if (scalar.z < 0) n++;
921+
// An odd number of negative components means the normal vectors
922+
// are backward to what they should be.
923+
return n == 1 || n == 3;
903924
}
904925

905926
/**
@@ -1028,7 +1049,7 @@ public void render(Geometry geometry, LightList lights, RenderManager renderMana
10281049
}
10291050

10301051
// Apply render state
1031-
updateRenderState(renderManager, renderer, techniqueDef);
1052+
updateRenderState(geometry, renderManager, renderer, techniqueDef);
10321053

10331054
// Get world overrides
10341055
SafeArrayList<MatParamOverride> overrides = geometry.getWorldMatParamOverrides();

jme3-core/src/main/java/com/jme3/material/RenderState.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,56 @@ public void set(RenderState state) {
16851685
sfactorAlpha = state.sfactorAlpha;
16861686
dfactorAlpha = state.dfactorAlpha;
16871687
}
1688+
1689+
/**
1690+
* Copy all values from the given state to this state.
1691+
* <p>
1692+
* This method is more precise than {@link #set(com.jme3.material.RenderState)}.
1693+
* @param state state to copy from
1694+
*/
1695+
public void copyFrom(RenderState state) {
1696+
this.applyBlendMode = state.applyBlendMode;
1697+
this.applyColorWrite = state.applyColorWrite;
1698+
this.applyCullMode = state.applyCullMode;
1699+
this.applyDepthFunc = state.applyDepthFunc;
1700+
this.applyDepthTest = state.applyDepthTest;
1701+
this.applyDepthWrite = state.applyDepthWrite;
1702+
this.applyLineWidth = state.applyLineWidth;
1703+
this.applyPolyOffset = state.applyPolyOffset;
1704+
this.applyStencilTest = state.applyStencilTest;
1705+
this.applyWireFrame = state.applyWireFrame;
1706+
this.backStencilDepthFailOperation = state.backStencilDepthFailOperation;
1707+
this.backStencilDepthPassOperation = state.backStencilDepthPassOperation;
1708+
this.backStencilFunction = state.backStencilFunction;
1709+
this.backStencilMask = state.backStencilMask;
1710+
this.backStencilReference = state.backStencilReference;
1711+
this.backStencilStencilFailOperation = state.backStencilStencilFailOperation;
1712+
this.blendEquation = state.blendEquation;
1713+
this.blendEquationAlpha = state.blendEquationAlpha;
1714+
this.blendMode = state.blendMode;
1715+
this.cachedHashCode = state.cachedHashCode;
1716+
this.colorWrite = state.colorWrite;
1717+
this.cullMode = state.cullMode;
1718+
this.depthFunc = state.depthFunc;
1719+
this.depthTest = state.depthTest;
1720+
this.depthWrite = state.depthWrite;
1721+
this.dfactorAlpha = state.dfactorAlpha;
1722+
this.dfactorRGB = state.dfactorRGB;
1723+
this.frontStencilDepthFailOperation = state.frontStencilDepthFailOperation;
1724+
this.frontStencilDepthPassOperation = state.frontStencilDepthPassOperation;
1725+
this.frontStencilFunction = state.frontStencilFunction;
1726+
this.frontStencilMask = state.frontStencilMask;
1727+
this.frontStencilReference = state.frontStencilReference;
1728+
this.frontStencilStencilFailOperation = state.frontStencilStencilFailOperation;
1729+
this.lineWidth = state.lineWidth;
1730+
this.offsetEnabled = state.offsetEnabled;
1731+
this.offsetFactor = state.offsetFactor;
1732+
this.offsetUnits = state.offsetUnits;
1733+
this.sfactorAlpha = state.sfactorAlpha;
1734+
this.sfactorRGB = state.sfactorRGB;
1735+
this.stencilTest = state.stencilTest;
1736+
this.wireframe = state.wireframe;
1737+
}
16881738

16891739
@Override
16901740
public String toString() {
@@ -1711,4 +1761,29 @@ public String toString() {
17111761
+ (blendMode.equals(BlendMode.Custom)? "\ncustomBlendFactors=("+sfactorRGB+", "+dfactorRGB+", "+sfactorAlpha+", "+dfactorAlpha+")":"")
17121762
+"\n]";
17131763
}
1764+
1765+
/**
1766+
* Flips the given face cull mode so that {@code Back} becomes
1767+
* {@code Front} and {@code Front} becomes {@code Back}.
1768+
* <p>{@code FrontAndBack} and {@code Off} are unaffected. This is important
1769+
* for flipping the cull mode when normal vectors are found to be backward.
1770+
* @param cull
1771+
* @return flipped cull mode
1772+
*/
1773+
public void flipFaceCull() {
1774+
switch (cullMode) {
1775+
case Back: cullMode = FaceCullMode.Front; break;
1776+
case Front: cullMode = FaceCullMode.Back; break;
1777+
}
1778+
}
1779+
1780+
/**
1781+
* Checks if the face cull mode is "flippable".
1782+
* <p>The cull mode is flippable when it is either {@code Front} or {@code Back}.
1783+
* @return
1784+
*/
1785+
public boolean isFaceCullFlippable() {
1786+
return cullMode == FaceCullMode.Front || cullMode == FaceCullMode.Back;
1787+
}
1788+
17141789
}

jme3-core/src/main/java/com/jme3/material/TechniqueDef.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2023 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -422,11 +422,6 @@ public VarType getDefineIdType(int defineId) {
422422
public void addShaderParamDefine(String paramName, VarType paramType, String defineName) {
423423
int defineId = defineNames.size();
424424

425-
if (defineId >= DefineList.MAX_DEFINES) {
426-
throw new IllegalStateException("Cannot have more than " +
427-
DefineList.MAX_DEFINES + " defines on a technique.");
428-
}
429-
430425
paramToDefineId.put(paramName, defineId);
431426
defineNames.add(defineName);
432427
defineTypes.add(paramType);
@@ -445,11 +440,6 @@ public void addShaderParamDefine(String paramName, VarType paramType, String def
445440
public int addShaderUnmappedDefine(String defineName, VarType defineType) {
446441
int defineId = defineNames.size();
447442

448-
if (defineId >= DefineList.MAX_DEFINES) {
449-
throw new IllegalStateException("Cannot have more than " +
450-
DefineList.MAX_DEFINES + " defines on a technique.");
451-
}
452-
453443
defineNames.add(defineName);
454444
defineTypes.add(defineType);
455445
return defineId;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public Pass() {
108108
public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples, boolean renderDepth) {
109109
Collection<Caps> caps = renderer.getCaps();
110110
if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
111-
renderFrameBuffer = new FrameBuffer(width, height, numSamples);
111+
renderFrameBuffer = new FrameBuffer(width, height, numSamples);
112112
renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
113113
renderFrameBuffer.setDepthTarget(FrameBufferTarget.newTarget(depthBufferFormat));
114114
if (renderDepth) {
@@ -126,7 +126,7 @@ public void init(Renderer renderer, int width, int height, Format textureFormat,
126126
}
127127

128128
renderFrameBuffer.addColorTarget(FrameBufferTarget.newTarget(renderedTexture));
129-
129+
renderFrameBuffer.setName(getClass().getSimpleName());
130130

131131
}
132132

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ private void renderFilterChain(Renderer r, FrameBuffer sceneFb) {
295295
if (msDepth && filter.isRequiresDepthTexture()) {
296296
mat.setInt("NumSamplesDepth", depthTexture.getImage().getMultiSamples());
297297
}
298-
298+
299299
if (filter.isRequiresSceneTexture()) {
300300
mat.setTexture("Texture", tex);
301301
if (tex.getImage().getMultiSamples() > 1) {
@@ -508,6 +508,14 @@ public void reshape(ViewPort vp, int w, int h) {
508508
renderFrameBuffer.addColorTarget(FrameBufferTarget.newTarget(filterTexture));
509509
}
510510

511+
if (renderFrameBufferMS != null) {
512+
renderFrameBufferMS.setName("FilterPostProcessor MS");
513+
}
514+
515+
if (renderFrameBuffer != null) {
516+
renderFrameBuffer.setName("FilterPostProcessor");
517+
}
518+
511519
for (Filter filter : filters.getArray()) {
512520
initFilter(filter, vp);
513521
}

jme3-core/src/main/java/com/jme3/renderer/RenderManager.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -967,19 +967,15 @@ public void renderViewPortQueues(ViewPort vp, boolean flush) {
967967
if (prof != null) {
968968
prof.vpStep(VpStep.RenderBucket, vp, Bucket.Opaque);
969969
}
970-
this.renderer.pushDebugGroup(Bucket.Opaque.name());
971970
rq.renderQueue(Bucket.Opaque, this, cam, flush);
972-
this.renderer.popDebugGroup();
973971

974972
// render the sky, with depth range set to the farthest
975973
if (!rq.isQueueEmpty(Bucket.Sky)) {
976974
if (prof != null) {
977975
prof.vpStep(VpStep.RenderBucket, vp, Bucket.Sky);
978976
}
979977
renderer.setDepthRange(1, 1);
980-
this.renderer.pushDebugGroup(Bucket.Sky.name());
981978
rq.renderQueue(Bucket.Sky, this, cam, flush);
982-
this.renderer.popDebugGroup();
983979
depthRangeChanged = true;
984980
}
985981

@@ -995,9 +991,7 @@ public void renderViewPortQueues(ViewPort vp, boolean flush) {
995991
renderer.setDepthRange(0, 1);
996992
depthRangeChanged = false;
997993
}
998-
this.renderer.pushDebugGroup(Bucket.Transparent.name());
999994
rq.renderQueue(Bucket.Transparent, this, cam, flush);
1000-
this.renderer.popDebugGroup();
1001995
}
1002996

1003997
if (!rq.isQueueEmpty(Bucket.Gui)) {
@@ -1006,9 +1000,7 @@ public void renderViewPortQueues(ViewPort vp, boolean flush) {
10061000
}
10071001
renderer.setDepthRange(0, 0);
10081002
setCamera(cam, true);
1009-
this.renderer.pushDebugGroup(Bucket.Gui.name());
10101003
rq.renderQueue(Bucket.Gui, this, cam, flush);
1011-
this.renderer.popDebugGroup();
10121004
setCamera(cam, false);
10131005
depthRangeChanged = true;
10141006
}

0 commit comments

Comments
 (0)