Compare commits

...

18 Commits

Author SHA1 Message Date
Toni Helenius
1e7e12ee69 Fix for resizing the window (issue 1191) (#1308)
* Listen for framebuffer size callbacks and set the resolution from that

* Also check the window size on the framebuffer size callback
2020-03-24 04:48:25 -04:00
Stephen Gold
f0e09b2a9e main.yml: add Gradle-wrapper validation to several jobs 2020-03-24 04:47:32 -04:00
Toni Helenius
1198908555 Lwjgl3 restart input handle (#1268)
* Reinit inputs on context restart

* Added test issue from issue #1013

* Verify that the inputs are already initialized
2020-03-24 04:44:01 -04:00
Stephen Gold
fecd018fae BufferUtils: resolve issue #1288 (rewrite isDirect()) (#1299) 2020-03-24 04:42:02 -04:00
Stephen Gold
b102eabb56 Fixes issue #1286 2020-03-24 04:37:53 -04:00
Riccardo Balbo
836455826b Fix openal-soft dead link 2020-03-24 04:36:39 -04:00
Riccardo Balbo
3c93e50d99 Update link for stb_image.h 2020-03-24 04:36:08 -04:00
Ali-RS
78779ffe0a Removed extra PostShadow Technique from PBRLighting.j3md (#1273) 2020-03-24 04:33:19 -04:00
Toni Helenius
9002d088e7 Issue 801 (#1269)
* Test case for issue #801

* Reset the context with the initial values
2020-03-24 04:33:03 -04:00
Ryan McDonough
753c3cc173 PreShadow & PostShadow Support for PBRLighting.j3md (#1265)
* Update PBRLighting.j3md

* Create PreShadowPBR.frag

* Create PostShadowPBR.frag
2020-03-24 04:31:37 -04:00
MeFisto94
55a36abe9d Fixes #1261 - Clone the Terrain Picker, so that loading a terrain from file still works (after cloning, the picker would have the wrong terrain quad instance) 2020-03-24 04:29:34 -04:00
MeFisto94
17fbedd5fe Fixes Bullet-Native Artifacts not containing natives when not building from cpp source and not using the build target. 2020-03-24 04:26:30 -04:00
Riccardo Balbo
2e30b24438 Fix #1236 non-lvalue cannot be out parameter 2020-03-24 04:21:52 -04:00
Stephen Gold
bd1b6d284c com.jme3.scene.shape.Line: protect the no-argument constructor (#1234) 2019-12-21 08:48:51 -05:00
Stephen Gold
8a04afd7a1 AnimControl: correct javadoc for the no-arg constructor (#1233) 2019-12-21 08:48:43 -05:00
Stephen Gold
f9d2e03362 Mesh: avoid NPE in getMorphTargets() when there are no targets (#1231) 2019-12-21 08:48:25 -05:00
Paul Speed
8905b3d8f8 Refactored how versions are auto-built to provide more normal versions
when building locally.
Normal auto-detected versions will be based on the base version parsed
from the most recent tag on the branch with a -SNAPSHOT appended.  If
the current commit is the tagged commit then it is used directly to
preserve backwards compatibility... but really that should be a CI
only option for most use-cases.
A new includeBranchInVersion option was added to allow the old behavior
of including the branch name in a munged version string for those
wanting to keep their experimental branch builds separate from their
normal master/version-branch builds.
2019-12-21 08:43:59 -05:00
Riccardo Balbo
a2169999e5 Remove "v" from version tag to maintain consistency with old releases 2019-12-21 05:02:37 -05:00
22 changed files with 877 additions and 409 deletions

View File

@ -69,7 +69,8 @@ jobs:
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build - name: Build
run: | run: |
# Build # Build
@ -96,10 +97,11 @@ jobs:
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build - name: Build
run: | run: |
gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \ ./gradlew -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \
:jme3-android-native:assemble \ :jme3-android-native:assemble \
:jme3-bullet-native-android:assemble :jme3-bullet-native-android:assemble
@ -138,7 +140,8 @@ jobs:
with: with:
java-version: ${{ matrix.jdk }} java-version: ${{ matrix.jdk }}
architecture: x64 architecture: x64
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build Natives - name: Build Natives
shell: bash shell: bash
env: env:
@ -233,7 +236,8 @@ jobs:
with: with:
name: linuxarm-natives name: linuxarm-natives
path: build/native path: build/native
- name: Validate the Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build Engine - name: Build Engine
shell: bash shell: bash
run: | run: |

View File

@ -158,29 +158,29 @@ task configureAndroidNDK {
gradle.rootProject.ext.set("usePrebuildNatives", buildNativeProjects!="true"); gradle.rootProject.ext.set("usePrebuildNatives", buildNativeProjects!="true");
if(skipPrebuildLibraries!="true"&&buildNativeProjects!="true"){ if (skipPrebuildLibraries != "true" && buildNativeProjects != "true") {
String rootPath = rootProject.projectDir.absolutePath String rootPath = rootProject.projectDir.absolutePath
Properties nativesSnasphotProp = new Properties() Properties nativesSnasphotProp = new Properties()
File nativesSnasphotPropF=new File("${rootPath}/natives-snapshot.properties"); File nativesSnasphotPropF = new File("${rootPath}/natives-snapshot.properties");
if(nativesSnasphotPropF.exists()){ if (nativesSnasphotPropF.exists()) {
nativesSnasphotPropF.withInputStream { nativesSnasphotProp.load(it) } nativesSnasphotPropF.withInputStream { nativesSnasphotProp.load(it) }
String nativesSnasphot=nativesSnasphotProp.getProperty("natives.snapshot"); String nativesSnasphot = nativesSnasphotProp.getProperty("natives.snapshot");
String nativesUrl=PREBUILD_NATIVES_URL.replace('${natives.snapshot}',nativesSnasphot) String nativesUrl = PREBUILD_NATIVES_URL.replace('${natives.snapshot}', nativesSnasphot)
println "Use natives snapshot: "+nativesUrl println "Use natives snapshot: " + nativesUrl
String nativesZipFile="${rootPath}" + File.separator + "build"+ File.separator +nativesSnasphot+"-natives.zip" String nativesZipFile = "${rootPath}" + File.separator + "build" + File.separator + nativesSnasphot + "-natives.zip"
String nativesPath="${rootPath}" + File.separator + "build"+ File.separator +"native" String nativesPath = "${rootPath}" + File.separator + "build" + File.separator + "native"
task getNativesZipFile { task getNativesZipFile {
outputs.file nativesZipFile outputs.file nativesZipFile
doFirst { doFirst {
File target = file(nativesZipFile); File target = file(nativesZipFile);
println("Download natives from "+nativesUrl+" to "+nativesZipFile); println("Download natives from " + nativesUrl + " to " + nativesZipFile);
target.getParentFile().mkdirs(); target.getParentFile().mkdirs();
ant.get(src: nativesUrl, dest: target); ant.get(src: nativesUrl, dest: target);
} }
@ -192,28 +192,26 @@ if(skipPrebuildLibraries!="true"&&buildNativeProjects!="true"){
dependsOn getNativesZipFile dependsOn getNativesZipFile
doFirst { doFirst {
for(File src : zipTree(nativesZipFile)){ for (File src : zipTree(nativesZipFile)) {
String srcRel=src.getAbsolutePath().substring((int)(nativesZipFile.length()+1)); String srcRel = src.getAbsolutePath().substring((int) (nativesZipFile.length() + 1));
srcRel=srcRel.substring(srcRel.indexOf( File.separator)+1); srcRel = srcRel.substring(srcRel.indexOf(File.separator) + 1);
File dest=new File(nativesPath+File.separator+srcRel); File dest = new File(nativesPath + File.separator + srcRel);
boolean doCopy = !(dest.exists() && dest.lastModified() > src.lastModified()) boolean doCopy = !(dest.exists() && dest.lastModified() > src.lastModified())
if (doCopy) { if (doCopy) {
println("Copy "+src+" "+dest); println("Copy " + src + " " + dest);
dest.getParentFile().mkdirs(); dest.getParentFile().mkdirs();
Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
} }
} }
} }
} }
build.dependsOn extractPrebuiltNatives
assemble.dependsOn extractPrebuiltNatives
} }
} }
//class IncrementalReverseTask extends DefaultTask { //class IncrementalReverseTask extends DefaultTask {
// @InputDirectory // @InputDirectory
// def File inputDir // def File inputDir

View File

@ -8,6 +8,10 @@ jmeVersionName =
# If true, the version name will contain the commit hash # If true, the version name will contain the commit hash
useCommitHashAsVersionName = false useCommitHashAsVersionName = false
# Set to true if a non-master branch name should be included in the automatically
# generated version.
includeBranchInVersion = false
# specify if JavaDoc should be built # specify if JavaDoc should be built
buildJavaDoc = true buildJavaDoc = true

View File

@ -1,5 +1,5 @@
String tremorZipFile = "TremorAndroid.zip" String tremorZipFile = "TremorAndroid.zip"
String stbiUrl = 'https://raw.githubusercontent.com/nothings/stb/master/stb_image.h' String stbiUrl = 'https://raw.githubusercontent.com/jMonkeyEngine/stb/0224a44a10564a214595797b4c88323f79a5f934/stb_image.h'
// Working directories for the ndk build. // Working directories for the ndk build.
String decodeBuildDir = "${buildDir}" + File.separator + 'decode' String decodeBuildDir = "${buildDir}" + File.separator + 'decode'

View File

@ -1,11 +1,11 @@
// OpenAL Soft r1.16 // OpenAL Soft r1.16
String openALSoftUrl = 'http://repo.or.cz/w/openal-soft.git/snapshot/e5016f814a265ed592a88acea95cf912c4bfdf12.zip' String openALSoftUrl = 'https://github.com/jMonkeyEngine/openal-soft/archive/e5016f814a265ed592a88acea95cf912c4bfdf12.zip'
String openALSoftZipFile = 'OpenALSoft.zip' String openALSoftZipFile = 'OpenALSoft.zip'
// OpenAL Soft directory the download is extracted into // OpenAL Soft directory the download is extracted into
// Typically, the downloaded OpenAL Soft zip file will extract to a directory // Typically, the downloaded OpenAL Soft zip file will extract to a directory
// called "openal-soft" // called "openal-soft"
String openALSoftFolder = 'openal-soft-e5016f8' String openALSoftFolder = 'openal-soft-e5016f814a265ed592a88acea95cf912c4bfdf12'
//Working directories for the ndk build. //Working directories for the ndk build.
String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft' String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft'

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009-2018 jMonkeyEngine * Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -102,7 +102,9 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
} }
/** /**
* Serialization only. Do not use. * Instantiate an animation control with no skeleton, suitable only for
* animations that don't contain any bone tracks. Also used for
* serialization.
*/ */
public AnimControl() { public AnimControl() {
} }
@ -144,6 +146,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Retrieve an animation from the list of animations. * Retrieve an animation from the list of animations.
*
* @param name The name of the animation to retrieve. * @param name The name of the animation to retrieve.
* @return The animation corresponding to the given name, or null, if no * @return The animation corresponding to the given name, or null, if no
* such named animation exists. * such named animation exists.
@ -155,6 +158,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Adds an animation to be available for playing to this * Adds an animation to be available for playing to this
* <code>AnimControl</code>. * <code>AnimControl</code>.
*
* @param anim The animation to add. * @param anim The animation to add.
*/ */
public void addAnim(Animation anim) { public void addAnim(Animation anim) {
@ -163,6 +167,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Remove an animation so that it is no longer available for playing. * Remove an animation so that it is no longer available for playing.
*
* @param anim The animation to remove. * @param anim The animation to remove.
*/ */
public void removeAnim(Animation anim) { public void removeAnim(Animation anim) {
@ -231,6 +236,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Adds a new listener to receive animation related events. * Adds a new listener to receive animation related events.
*
* @param listener The listener to add. * @param listener The listener to add.
*/ */
public void addListener(AnimEventListener listener) { public void addListener(AnimEventListener listener) {
@ -244,6 +250,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Removes the given listener from listening to events. * Removes the given listener from listening to events.
*
* @param listener * @param listener
* @see AnimControl#addListener(com.jme3.animation.AnimEventListener) * @see AnimControl#addListener(com.jme3.animation.AnimEventListener)
*/ */
@ -308,6 +315,7 @@ public final class AnimControl extends AbstractControl implements Cloneable, Jme
/** /**
* Returns the length of the given named animation. * Returns the length of the given named animation.
*
* @param name The name of the animation * @param name The name of the animation
* @return The length of time, in seconds, of the named animation. * @return The length of time, in seconds, of the named animation.
*/ */

View File

@ -32,7 +32,6 @@
package com.jme3.renderer; package com.jme3.renderer;
import com.jme3.material.RenderState; import com.jme3.material.RenderState;
import com.jme3.material.RenderState.BlendFunc;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer;
@ -49,96 +48,96 @@ public class RenderContext {
/** /**
* @see RenderState#setFaceCullMode(com.jme3.material.RenderState.FaceCullMode) * @see RenderState#setFaceCullMode(com.jme3.material.RenderState.FaceCullMode)
*/ */
public RenderState.FaceCullMode cullMode = RenderState.FaceCullMode.Off; public RenderState.FaceCullMode cullMode;
/** /**
* @see RenderState#setDepthTest(boolean) * @see RenderState#setDepthTest(boolean)
*/ */
public boolean depthTestEnabled = false; public boolean depthTestEnabled;
/** /**
* @see RenderState#setDepthWrite(boolean) * @see RenderState#setDepthWrite(boolean)
*/ */
public boolean depthWriteEnabled = true; public boolean depthWriteEnabled;
/** /**
* @see RenderState#setColorWrite(boolean) * @see RenderState#setColorWrite(boolean)
*/ */
public boolean colorWriteEnabled = true; public boolean colorWriteEnabled;
/** /**
* @see Renderer#setClipRect(int, int, int, int) * @see Renderer#setClipRect(int, int, int, int)
*/ */
public boolean clipRectEnabled = false; public boolean clipRectEnabled;
/** /**
* @see RenderState#setPolyOffset(float, float) * @see RenderState#setPolyOffset(float, float)
*/ */
public boolean polyOffsetEnabled = false; public boolean polyOffsetEnabled;
/** /**
* @see RenderState#setPolyOffset(float, float) * @see RenderState#setPolyOffset(float, float)
*/ */
public float polyOffsetFactor = 0; public float polyOffsetFactor;
/** /**
* @see RenderState#setPolyOffset(float, float) * @see RenderState#setPolyOffset(float, float)
*/ */
public float polyOffsetUnits = 0; public float polyOffsetUnits;
/** /**
* @see Mesh#setPointSize(float) * @see Mesh#setPointSize(float)
*/ */
public float pointSize = 1; public float pointSize;
/** /**
* @see RenderState#setLineWidth(float) * @see RenderState#setLineWidth(float)
*/ */
public float lineWidth = 1; public float lineWidth;
/** /**
* @see RenderState#setBlendMode(com.jme3.material.RenderState.BlendMode) * @see RenderState#setBlendMode(com.jme3.material.RenderState.BlendMode)
*/ */
public RenderState.BlendMode blendMode = RenderState.BlendMode.Off; public RenderState.BlendMode blendMode;
/** /**
* @see RenderState#setBlendEquation(com.jme3.material.RenderState.BlendEquation) * @see RenderState#setBlendEquation(com.jme3.material.RenderState.BlendEquation)
*/ */
public RenderState.BlendEquation blendEquation = RenderState.BlendEquation.Add; public RenderState.BlendEquation blendEquation;
/** /**
* @see RenderState#setBlendEquationAlpha(com.jme3.material.RenderState.BlendEquationAlpha) * @see RenderState#setBlendEquationAlpha(com.jme3.material.RenderState.BlendEquationAlpha)
*/ */
public RenderState.BlendEquationAlpha blendEquationAlpha = RenderState.BlendEquationAlpha.InheritColor; public RenderState.BlendEquationAlpha blendEquationAlpha;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc sfactorRGB = RenderState.BlendFunc.One; public RenderState.BlendFunc sfactorRGB;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc dfactorRGB = RenderState.BlendFunc.One; public RenderState.BlendFunc dfactorRGB;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc sfactorAlpha = RenderState.BlendFunc.One; public RenderState.BlendFunc sfactorAlpha;
/** /**
* @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc, * @see RenderState#setCustomBlendFactors(com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc,
* com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc) * com.jme3.material.RenderState.BlendFunc, com.jme3.material.RenderState.BlendFunc)
*/ */
public RenderState.BlendFunc dfactorAlpha = RenderState.BlendFunc.One; public RenderState.BlendFunc dfactorAlpha;
/** /**
* @see RenderState#setWireframe(boolean) * @see RenderState#setWireframe(boolean)
*/ */
public boolean wireframe = false; public boolean wireframe;
/** /**
* @see Renderer#setShader(com.jme3.shader.Shader) * @see Renderer#setShader(com.jme3.shader.Shader)
@ -153,7 +152,7 @@ public class RenderContext {
/** /**
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
*/ */
public int boundFBO = 0; public int boundFBO;
/** /**
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
@ -165,7 +164,7 @@ public class RenderContext {
* *
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
*/ */
public int boundRB = 0; public int boundRB;
/** /**
* Currently bound draw buffer * Currently bound draw buffer
@ -178,7 +177,7 @@ public class RenderContext {
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
* @see FrameBuffer#setTargetIndex(int) * @see FrameBuffer#setTargetIndex(int)
*/ */
public int boundDrawBuf = -1; public int boundDrawBuf;
/** /**
* Currently bound read buffer * Currently bound read buffer
@ -187,7 +186,7 @@ public class RenderContext {
* @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer) * @see Renderer#setFrameBuffer(com.jme3.texture.FrameBuffer)
* @see FrameBuffer#setTargetIndex(int) * @see FrameBuffer#setTargetIndex(int)
*/ */
public int boundReadBuf = -1; public int boundReadBuf;
/** /**
* Currently bound element array vertex buffer. * Currently bound element array vertex buffer.
@ -213,89 +212,93 @@ public class RenderContext {
*/ */
public int boundPixelPackPBO; public int boundPixelPackPBO;
public int numTexturesSet = 0; public int numTexturesSet;
/** /**
* Current bound texture IDs for each texture unit. * Current bound texture IDs for each texture unit.
* *
* @see Renderer#setTexture(int, com.jme3.texture.Texture) * @see Renderer#setTexture(int, com.jme3.texture.Texture)
*/ */
public Image[] boundTextures = new Image[16]; public final Image[] boundTextures = new Image[16];
/** /**
* IDList for texture units * IDList for texture units
* *
* @see Renderer#setTexture(int, com.jme3.texture.Texture) * @see Renderer#setTexture(int, com.jme3.texture.Texture)
*/ */
public IDList textureIndexList = new IDList(); public final IDList textureIndexList = new IDList();
/** /**
* Currently bound texture unit * Currently bound texture unit
* *
* @see Renderer#setTexture(int, com.jme3.texture.Texture) * @see Renderer#setTexture(int, com.jme3.texture.Texture)
*/ */
public int boundTextureUnit = 0; public int boundTextureUnit;
/** /**
* Stencil Buffer state * Stencil Buffer state
*/ */
public boolean stencilTest = false; public boolean stencilTest;
public RenderState.StencilOperation frontStencilStencilFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation frontStencilStencilFailOperation;
public RenderState.StencilOperation frontStencilDepthFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation frontStencilDepthFailOperation;
public RenderState.StencilOperation frontStencilDepthPassOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation frontStencilDepthPassOperation;
public RenderState.StencilOperation backStencilStencilFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilStencilFailOperation;
public RenderState.StencilOperation backStencilDepthFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilDepthFailOperation;
public RenderState.StencilOperation backStencilDepthPassOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilDepthPassOperation;
public RenderState.TestFunction frontStencilFunction = RenderState.TestFunction.Always; public RenderState.TestFunction frontStencilFunction;
public RenderState.TestFunction backStencilFunction = RenderState.TestFunction.Always; public RenderState.TestFunction backStencilFunction;
/** /**
* Vertex attribs currently bound and enabled. If a slot is null, then * Vertex attribs currently bound and enabled. If a slot is null, then
* it is disabled. * it is disabled.
*/ */
public VertexBuffer[] boundAttribs = new VertexBuffer[16]; public final VertexBuffer[] boundAttribs = new VertexBuffer[16];
/** /**
* IDList for vertex attributes * IDList for vertex attributes
*/ */
public IDList attribIndexList = new IDList(); public final IDList attribIndexList = new IDList();
/** /**
* depth test function * depth test function
*/ */
public RenderState.TestFunction depthFunc = RenderState.TestFunction.Less; public RenderState.TestFunction depthFunc;
/** /**
* alpha test function * alpha test function
*/ */
public RenderState.TestFunction alphaFunc = RenderState.TestFunction.Greater; public RenderState.TestFunction alphaFunc;
public int initialDrawBuf; public int initialDrawBuf;
public int initialReadBuf; public int initialReadBuf;
public ColorRGBA clearColor = new ColorRGBA(0,0,0,0); public ColorRGBA clearColor = new ColorRGBA(0, 0, 0, 0);
/** public RenderContext() {
* Reset the RenderContext to default GL state init();
*/ }
public void reset(){
private void init() {
cullMode = RenderState.FaceCullMode.Off; cullMode = RenderState.FaceCullMode.Off;
depthTestEnabled = false; depthTestEnabled = false;
depthWriteEnabled = false; depthWriteEnabled = true;
colorWriteEnabled = false; colorWriteEnabled = true;
clipRectEnabled = false; clipRectEnabled = false;
polyOffsetEnabled = false; polyOffsetEnabled = false;
polyOffsetFactor = 0; polyOffsetFactor = 0;
polyOffsetUnits = 0; polyOffsetUnits = 0;
pointSize = 1; pointSize = 1;
lineWidth = 1;
blendMode = RenderState.BlendMode.Off; blendMode = RenderState.BlendMode.Off;
blendEquation = RenderState.BlendEquation.Add; blendEquation = RenderState.BlendEquation.Add;
blendEquationAlpha = RenderState.BlendEquationAlpha.InheritColor; blendEquationAlpha = RenderState.BlendEquationAlpha.InheritColor;
sfactorRGB = BlendFunc.One; sfactorRGB = RenderState.BlendFunc.One;
dfactorRGB = BlendFunc.One; dfactorRGB = RenderState.BlendFunc.One;
sfactorAlpha = BlendFunc.One; sfactorAlpha = RenderState.BlendFunc.One;
dfactorAlpha = BlendFunc.One; dfactorAlpha = RenderState.BlendFunc.One;
wireframe = false; wireframe = false;
boundShaderProgram = 0; boundShaderProgram = 0;
boundShader = null; boundShader = null;
boundFBO = 0; boundFBO = 0;
@ -308,17 +311,9 @@ public class RenderContext {
boundArrayVBO = 0; boundArrayVBO = 0;
boundPixelPackPBO = 0; boundPixelPackPBO = 0;
numTexturesSet = 0; numTexturesSet = 0;
for (int i = 0; i < boundTextures.length; i++)
boundTextures[i] = null;
textureIndexList.reset();
boundTextureUnit = 0; boundTextureUnit = 0;
for (int i = 0; i < boundAttribs.length; i++)
boundAttribs[i] = null;
attribIndexList.reset();
stencilTest = false; stencilTest = false;
frontStencilStencilFailOperation = RenderState.StencilOperation.Keep; frontStencilStencilFailOperation = RenderState.StencilOperation.Keep;
frontStencilDepthFailOperation = RenderState.StencilOperation.Keep; frontStencilDepthFailOperation = RenderState.StencilOperation.Keep;
frontStencilDepthPassOperation = RenderState.StencilOperation.Keep; frontStencilDepthPassOperation = RenderState.StencilOperation.Keep;
@ -328,8 +323,29 @@ public class RenderContext {
frontStencilFunction = RenderState.TestFunction.Always; frontStencilFunction = RenderState.TestFunction.Always;
backStencilFunction = RenderState.TestFunction.Always; backStencilFunction = RenderState.TestFunction.Always;
depthFunc = RenderState.TestFunction.LessOrEqual; depthFunc = RenderState.TestFunction.Less;
alphaFunc = RenderState.TestFunction.Greater; alphaFunc = RenderState.TestFunction.Greater;
clearColor.set(0,0,0,0); cullMode = RenderState.FaceCullMode.Off;
clearColor.set(0, 0, 0, 0);
}
/**
* Reset the RenderContext to default GL state
*/
public void reset(){
init();
for (int i = 0; i < boundTextures.length; i++) {
boundTextures[i] = null;
}
textureIndexList.reset();
for (int i = 0; i < boundAttribs.length; i++) {
boundAttribs[i] = null;
}
attribIndexList.reset();
} }
} }

View File

@ -1527,7 +1527,11 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
} }
public MorphTarget[] getMorphTargets() { public MorphTarget[] getMorphTargets() {
return morphTargets.getArray(); if (morphTargets == null) {
return new MorphTarget[0];
} else {
return morphTargets.getArray();
}
} }
/** /**

View File

@ -55,7 +55,7 @@ public class Line extends Mesh {
/** /**
* No-argument constructor needed by SavableClassUtil. * No-argument constructor needed by SavableClassUtil.
*/ */
public Line() { // TODO protected protected Line() {
} }
public Line(Vector3f start, Vector3f end) { public Line(Vector3f start, Vector3f end) {
@ -69,7 +69,6 @@ public class Line extends Mesh {
setBuffer(Type.Position, 3, new float[]{start.x, start.y, start.z, setBuffer(Type.Position, 3, new float[]{start.x, start.y, start.z,
end.x, end.y, end.z,}); end.x, end.y, end.z,});
setBuffer(Type.TexCoord, 2, new float[]{0, 0, setBuffer(Type.TexCoord, 2, new float[]{0, 0,
1, 1}); 1, 1});

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009-2019 jMonkeyEngine * Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -171,7 +171,7 @@ public abstract class JmeSystemDelegate {
return is64 ? Platform.Windows64 : Platform.Windows32; return is64 ? Platform.Windows64 : Platform.Windows32;
} else if (os.contains("linux") || os.contains("freebsd") } else if (os.contains("linux") || os.contains("freebsd")
|| os.contains("sunos") || os.contains("unix")) { || os.contains("sunos") || os.contains("unix")) {
if (arch.startsWith("arm")) { if (arch.startsWith("arm") || arch.startsWith("aarch")) {
return is64 ? Platform.Linux_ARM64 : Platform.Linux_ARM32; return is64 ? Platform.Linux_ARM64 : Platform.Linux_ARM32;
} else { } else {
return is64 ? Platform.Linux64 : Platform.Linux32; return is64 ? Platform.Linux64 : Platform.Linux32;

View File

@ -1277,36 +1277,14 @@ public final class BufferUtils {
allocator.destroyDirectBuffer(toBeDestroyed); allocator.destroyDirectBuffer(toBeDestroyed);
} }
/* /**
* FIXME when java 1.5 supprt is dropped - replace calls to this method with * Test whether the specified buffer is direct.
* Buffer.isDirect
*
* Buffer.isDirect() is only java 6. Java 5 only have this method on Buffer
* subclasses : FloatBuffer, IntBuffer, ShortBuffer,
* ByteBuffer,DoubleBuffer, LongBuffer. CharBuffer has been excluded as we
* don't use it.
* *
* @param buf the buffer to test (not null, unaffected)
* @return true if direct, otherwise false
*/ */
private static boolean isDirect(Buffer buf) { private static boolean isDirect(Buffer buf) {
if (buf instanceof FloatBuffer) { return buf.isDirect();
return ((FloatBuffer) buf).isDirect();
}
if (buf instanceof IntBuffer) {
return ((IntBuffer) buf).isDirect();
}
if (buf instanceof ShortBuffer) {
return ((ShortBuffer) buf).isDirect();
}
if (buf instanceof ByteBuffer) {
return ((ByteBuffer) buf).isDirect();
}
if (buf instanceof DoubleBuffer) {
return ((DoubleBuffer) buf).isDirect();
}
if (buf instanceof LongBuffer) {
return ((LongBuffer) buf).isDirect();
}
throw new UnsupportedOperationException(" BufferUtils.isDirect was called on " + buf.getClass().getName());
} }
private static class BufferInfo extends PhantomReference<Buffer> { private static class BufferInfo extends PhantomReference<Buffer> {

View File

@ -168,7 +168,7 @@ MaterialDef PBR Lighting {
Technique PreShadow { Technique PreShadow {
VertexShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert VertexShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert
FragmentShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag FragmentShader GLSL300 GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadowPBR.frag
WorldParameters { WorldParameters {
WorldViewProjectionMatrix WorldViewProjectionMatrix
@ -196,44 +196,9 @@ MaterialDef PBR Lighting {
} }
Technique PostShadow{ Technique PostShadow {
VertexShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.vert VertexShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert
FragmentShader GLSL310 GLSL300 GLSL150: Common/MatDefs/Shadow/PostShadow.frag FragmentShader GLSL310 GLSL300 GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadowPBR.frag
WorldParameters {
WorldViewProjectionMatrix
WorldMatrix
ViewProjectionMatrix
ViewMatrix
}
Defines {
HARDWARE_SHADOWS : HardwareShadows
FILTER_MODE : FilterMode
PCFEDGE : PCFEdge
DISCARD_ALPHA : AlphaDiscardThreshold
SHADOWMAP_SIZE : ShadowMapSize
SHADOWMAP_SIZE : ShadowMapSize
FADE : FadeInfo
PSSM : Splits
POINTLIGHT : LightViewProjectionMatrix5
NUM_BONES : NumberOfBones
INSTANCING : UseInstancing
BACKFACE_SHADOWS: BackfaceShadows
NUM_MORPH_TARGETS: NumberOfMorphTargets
NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers
}
ForcedRenderState {
Blend Modulate
DepthWrite Off
PolyOffset -0.1 0
}
}
Technique PostShadow{
VertexShader GLSL100: Common/MatDefs/Shadow/PostShadow.vert
FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag
WorldParameters { WorldParameters {
WorldViewProjectionMatrix WorldViewProjectionMatrix

View File

@ -0,0 +1,89 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/Shadows.glsllib"
#if defined(PSSM) || defined(FADE)
varying float shadowPosition;
#endif
varying vec4 projCoord0;
varying vec4 projCoord1;
varying vec4 projCoord2;
varying vec4 projCoord3;
#ifndef BACKFACE_SHADOWS
varying float nDotL;
#endif
#ifdef POINTLIGHT
varying vec4 projCoord4;
varying vec4 projCoord5;
uniform vec3 m_LightPos;
varying vec4 worldPos;
#else
#ifndef PSSM
varying float lightDot;
#endif
#endif
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
uniform sampler2D m_ColorMap;
#else
uniform sampler2D m_BaseColorMap;
#endif
uniform float m_AlphaDiscardThreshold;
varying vec2 texCoord;
#endif
#ifdef FADE
uniform vec2 m_FadeInfo;
#endif
void main(){
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
float alpha = texture2D(m_ColorMap,texCoord).a;
#else
float alpha = texture2D(m_BaseColorMap,texCoord).a;
#endif
if(alpha<=m_AlphaDiscardThreshold){
discard;
}
#endif
#ifndef BACKFACE_SHADOWS
if(nDotL > 0.0){
discard;
}
#endif
float shadow = 1.0;
#ifdef POINTLIGHT
shadow = getPointLightShadows(worldPos, m_LightPos,
m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3,m_ShadowMap4,m_ShadowMap5,
projCoord0, projCoord1, projCoord2, projCoord3, projCoord4, projCoord5);
#else
#ifdef PSSM
shadow = getDirectionalLightShadows(m_Splits, shadowPosition,
m_ShadowMap0,m_ShadowMap1,m_ShadowMap2,m_ShadowMap3,
projCoord0, projCoord1, projCoord2, projCoord3);
#else
//spotlight
if(lightDot < 0.0){
gl_FragColor = vec4(1.0);
return;
}
shadow = getSpotLightShadows(m_ShadowMap0,projCoord0);
#endif
#endif
#ifdef FADE
shadow = max(0.0, mix(shadow, 1.0, max(0.0, (shadowPosition - m_FadeInfo.x) * m_FadeInfo.y)));
#endif
shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);
gl_FragColor = vec4(shadow, shadow, shadow, 1.0);
}

View File

@ -0,0 +1,28 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"
varying vec2 texCoord;
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
uniform sampler2D m_ColorMap;
#else
uniform sampler2D m_BaseColorMap;
#endif
uniform float m_AlphaDiscardThreshold;
#endif
void main(){
#ifdef DISCARD_ALPHA
#ifdef COLOR_MAP
if (texture2D(m_ColorMap, texCoord).a <= m_AlphaDiscardThreshold){
discard;
}
#else
if (texture2D(m_BaseColorMap, texCoord).a <= m_AlphaDiscardThreshold){
discard;
}
#endif
#endif
gl_FragColor = vec4(1.0);
}

View File

@ -173,10 +173,13 @@ Note that it only handles morphing position, normals and tangents.
void Morph_Compute(inout vec4 pos){ void Morph_Compute(inout vec4 pos){
#if (NUM_TARGETS_BUFFERS == 2) #if (NUM_TARGETS_BUFFERS == 2)
Morph_Compute_Pos_Norm(pos,vec3(0.0)); vec3 dummy_norm = vec3(0.0);
Morph_Compute_Pos_Norm(pos, dummy_norm);
return; return;
#elif (NUM_TARGETS_BUFFERS == 3) #elif (NUM_TARGETS_BUFFERS == 3)
Morph_Compute_Pos_Norm_Tan(pos, vec3(0.0), vec3(0.0)); vec3 dummy_norm = vec3(0.0);
vec3 dummy_tan = vec3(0.0);
Morph_Compute_Pos_Norm_Tan(pos, dummy_norm, dummy_tan);
return; return;
#endif #endif
Morph_Compute_Pos(pos); Morph_Compute_Pos(pos);
@ -187,7 +190,9 @@ Note that it only handles morphing position, normals and tangents.
Morph_Compute_Pos(pos); Morph_Compute_Pos(pos);
return; return;
#elif (NUM_TARGETS_BUFFERS == 3) #elif (NUM_TARGETS_BUFFERS == 3)
Morph_Compute_Pos_Norm_Tan(pos, vec3(0.0), vec3(0.0)); vec3 dummy_norm = vec3(0.0);
vec3 dummy_tan = vec3(0.0);
Morph_Compute_Pos_Norm_Tan(pos, dummy_norm, dummy_tan);
return; return;
#elif (NUM_TARGETS_BUFFERS == 2) #elif (NUM_TARGETS_BUFFERS == 2)
Morph_Compute_Pos_Norm(pos, norm); Morph_Compute_Pos_Norm(pos, norm);

View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package jme3test.niftygui;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.LayerBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.builder.ScreenBuilder;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
public class TestIssue1013 extends SimpleApplication implements ScreenController {
public static void main(String[] args) {
new TestIssue1013().start();
}
private NiftyJmeDisplay niftyDisplay;
@Override
public void simpleInitApp() {
// this box here always renders
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("/com/jme3/app/Monkey.png"));
geom.setMaterial(mat);
rootNode.attachChild(geom);
niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
Nifty nifty = niftyDisplay.getNifty();
nifty.loadStyleFile("nifty-default-styles.xml");
nifty.loadControlFile("nifty-default-controls.xml");
ScreenController ctrl = this;
new ScreenBuilder("start") {
{
controller(ctrl);
layer(new LayerBuilder() {
{
childLayoutVertical();
panel(new PanelBuilder() {
{
childLayoutCenter();
width("100%");
height("50%");
backgroundColor("#ff0000");
}
});
control(new ButtonBuilder("RestartButton", "Restart Context") {
{
alignCenter();
valignCenter();
height("32px");
width("480px");
interactOnClick("restartContext()");
}
});
}
});
}
}.build(nifty);
guiViewPort.addProcessor(niftyDisplay);
nifty.gotoScreen("start");
flyCam.setDragToRotate(true);
}
@Override
public void bind(Nifty nifty, Screen screen) {
}
@Override
public void onStartScreen() {
}
@Override
public void onEndScreen() {
}
public void restartContext() {
// even without changing settings, stuff breaks!
restart();
// ...and re-adding the processor doesn't help at all
guiViewPort.addProcessor(niftyDisplay);
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package jme3test.renderer;
import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
public class TestIssue801 extends SimpleApplication {
public static void main(String[] args) {
AppSettings initialSettings = new AppSettings(true);
initialSettings.setBitsPerPixel(24);
TestIssue801 app = new TestIssue801();
app.setSettings(initialSettings);
app.start();
}
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(new ColorRGBA(0.3f, 0.3f, 0.3f, 1f));
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
inputManager.addMapping("changeBpp", new KeyTrigger(KeyInput.KEY_P));
ActionListener listener = new ActionListener() {
@Override
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("changeBpp") && keyPressed) {
goWindowed();
}
}
};
inputManager.addListener(listener, "changeBpp");
}
void goWindowed() {
AppSettings newSettings = new AppSettings(false);
newSettings.copyFrom(settings);
newSettings.setBitsPerPixel(16);
setSettings(newSettings);
restart();
}
}

View File

@ -83,11 +83,33 @@ public class GlfwKeyInput implements KeyInput {
@Override @Override
public void initialize() { public void initialize() {
if (!context.isRenderable()) {
return;
}
initCallbacks();
initialized = true;
logger.fine("Keyboard created.");
}
/**
* Re-initializes the key input context window specific callbacks
*/
public void resetContext() {
if (!context.isRenderable()) { if (!context.isRenderable()) {
return; return;
} }
closeCallbacks();
initCallbacks();
}
private void closeCallbacks() {
keyCallback.close();
charCallback.close();
}
private void initCallbacks() {
glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() { glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() {
@Override @Override
public void invoke(final long window, final int key, final int scancode, final int action, final int mods) { public void invoke(final long window, final int key, final int scancode, final int action, final int mods) {
@ -122,9 +144,6 @@ public class GlfwKeyInput implements KeyInput {
keyInputEvents.add(released); keyInputEvents.add(released);
} }
}); });
initialized = true;
logger.fine("Keyboard created.");
} }
public int getKeyCount() { public int getKeyCount() {
@ -149,8 +168,7 @@ public class GlfwKeyInput implements KeyInput {
return; return;
} }
keyCallback.close(); closeCallbacks();
charCallback.close();
logger.fine("Keyboard destroyed."); logger.fine("Keyboard destroyed.");
} }

View File

@ -176,7 +176,30 @@ public class GlfwMouseInput implements MouseInput {
@Override @Override
public void initialize() { public void initialize() {
initCallbacks();
if (listener != null) {
sendFirstMouseEvent();
}
setCursorVisible(cursorVisible);
logger.fine("Mouse created.");
initialized = true;
}
/**
* Re-initializes the mouse input context window specific callbacks
*/
public void resetContext() {
if (!context.isRenderable()) {
return;
}
closeCallbacks();
initCallbacks();
}
private void initCallbacks() {
final long window = context.getWindowHandle(); final long window = context.getWindowHandle();
try (MemoryStack stack = MemoryStack.stackPush()) { try (MemoryStack stack = MemoryStack.stackPush()) {
@ -219,14 +242,6 @@ public class GlfwMouseInput implements MouseInput {
currentWidth = width; currentWidth = width;
} }
}); });
if(listener != null) {
sendFirstMouseEvent();
}
setCursorVisible(cursorVisible);
logger.fine("Mouse created.");
initialized = true;
} }
private void initCurrentMousePosition(long window) { private void initCurrentMousePosition(long window) {
@ -295,9 +310,7 @@ public class GlfwMouseInput implements MouseInput {
return; return;
} }
cursorPosCallback.close(); closeCallbacks();
scrollCallback.close();
mouseButtonCallback.close();
currentCursor = null; currentCursor = null;
currentCursorDelays = null; currentCursorDelays = null;
@ -313,6 +326,12 @@ public class GlfwMouseInput implements MouseInput {
logger.fine("Mouse destroyed."); logger.fine("Mouse destroyed.");
} }
private void closeCallbacks() {
cursorPosCallback.close();
scrollCallback.close();
mouseButtonCallback.close();
}
@Override @Override
public void setCursorVisible(boolean visible) { public void setCursorVisible(boolean visible) {
cursorVisible = visible; cursorVisible = visible;

View File

@ -47,6 +47,7 @@ import com.jme3.util.BufferUtils;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -121,6 +122,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
private GLFWErrorCallback errorCallback; private GLFWErrorCallback errorCallback;
private GLFWWindowSizeCallback windowSizeCallback; private GLFWWindowSizeCallback windowSizeCallback;
private GLFWFramebufferSizeCallback framebufferSizeCallback;
private GLFWWindowFocusCallback windowFocusCallback; private GLFWWindowFocusCallback windowFocusCallback;
private Thread mainThread; private Thread mainThread;
@ -250,16 +252,8 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
throw new RuntimeException("Failed to create the GLFW window"); throw new RuntimeException("Failed to create the GLFW window");
} }
// Add a resize callback which delegates to the listener
glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() {
@Override
public void invoke(final long window, final int width, final int height) {
settings.setResolution(width, height);
listener.reshape(width, height);
}
});
glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() { glfwSetWindowFocusCallback(window, windowFocusCallback = new GLFWWindowFocusCallback() {
@Override @Override
public void invoke(final long window, final boolean focus) { public void invoke(final long window, final boolean focus) {
if (wasActive != focus) { if (wasActive != focus) {
@ -294,7 +288,46 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
setWindowIcon(settings); setWindowIcon(settings);
showWindow(); showWindow();
// Windows resize callback
glfwSetWindowSizeCallback(window, windowSizeCallback = new GLFWWindowSizeCallback() {
@Override
public void invoke(final long window, final int width, final int height) {
// This is the window size, never to passed to any pixel based stuff!
// https://www.glfw.org/docs/latest/window_guide.html#window_size
onWindowSizeChanged(width, height);
}
});
// Add a framebuffer resize callback which delegates to the listener
glfwSetFramebufferSizeCallback(window, framebufferSizeCallback = new GLFWFramebufferSizeCallback() {
@Override
public void invoke(final long window, final int width, final int height) {
// The window size might be also changed, but the window size callback might not trigger
// Maybe a bug in graphics drivers or LWJGL 3...? So make sure we emulate the original JME behavior here
IntBuffer windowWidth = BufferUtils.createIntBuffer(1);
IntBuffer windowHeight = BufferUtils.createIntBuffer(1);
glfwGetWindowSize(window, windowWidth, windowHeight);
onWindowSizeChanged(windowWidth.get(), windowHeight.get());
// https://www.glfw.org/docs/latest/window_guide.html#window_fbsize
listener.reshape(width, height);
}
});
allowSwapBuffers = settings.isSwapBuffers(); allowSwapBuffers = settings.isSwapBuffers();
// Create OpenCL
if (settings.isOpenCLSupport()) {
initOpenCL(window);
}
}
private void onWindowSizeChanged(final int width, final int height) {
settings.setResolution(width, height);
} }
protected void showWindow() { protected void showWindow() {
@ -303,6 +336,8 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
/** /**
* Set custom icons to the window of this application. * Set custom icons to the window of this application.
*
* @param settings settings for getting the icons
*/ */
protected void setWindowIcon(final AppSettings settings) { protected void setWindowIcon(final AppSettings settings) {
@ -399,6 +434,11 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
windowSizeCallback = null; windowSizeCallback = null;
} }
if (framebufferSizeCallback != null) {
framebufferSizeCallback.close();
framebufferSizeCallback = null;
}
if (windowFocusCallback != null) { if (windowFocusCallback != null) {
windowFocusCallback.close(); windowFocusCallback.close();
windowFocusCallback = null; windowFocusCallback = null;
@ -409,7 +449,6 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
window = NULL; window = NULL;
} }
glfwTerminate();
} catch (final Exception ex) { } catch (final Exception ex) {
listener.handleError("Failed to destroy context", ex); listener.handleError("Failed to destroy context", ex);
} }
@ -429,6 +468,8 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
/** /**
* Does LWJGL display initialization in the OpenGL thread * Does LWJGL display initialization in the OpenGL thread
*
* @return returns {@code true} if the context initialization was successful
*/ */
protected boolean initInThread() { protected boolean initInThread() {
try { try {
@ -455,13 +496,6 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
created.set(true); created.set(true);
super.internalCreate(); super.internalCreate();
//create OpenCL
//Must be done here because the window handle is needed
if (settings.isOpenCLSupport()) {
initOpenCL(window);
}
} catch (Exception ex) { } catch (Exception ex) {
try { try {
if (window != NULL) { if (window != NULL) {
@ -486,14 +520,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
protected void runLoop() { protected void runLoop() {
// If a restart is required, lets recreate the context. // If a restart is required, lets recreate the context.
if (needRestart.getAndSet(false)) { if (needRestart.getAndSet(false)) {
try { restartContext();
destroyContext();
createContext(settings);
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Failed to set display settings!", ex);
}
LOGGER.fine("Display restarted.");
} }
if (!created.get()) { if (!created.get()) {
@ -549,6 +576,25 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
glfwPollEvents(); glfwPollEvents();
} }
private void restartContext() {
try {
destroyContext();
createContext(settings);
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Failed to set display settings!", ex);
}
// We need to reinit the mouse and keyboard input as they are tied to a window handle
if (keyInput != null && keyInput.isInitialized()) {
keyInput.resetContext();
}
if (mouseInput != null && mouseInput.isInitialized()) {
mouseInput.resetContext();
}
LOGGER.fine("Display restarted.");
}
private void setFrameRateLimit(int frameRateLimit) { private void setFrameRateLimit(int frameRateLimit) {
this.frameRateLimit = frameRateLimit; this.frameRateLimit = frameRateLimit;
frameSleepTime = 1000.0 / this.frameRateLimit; frameSleepTime = 1000.0 / this.frameRateLimit;
@ -562,6 +608,7 @@ public abstract class LwjglWindow extends LwjglContext implements Runnable {
destroyContext(); destroyContext();
super.internalDestroy(); super.internalDestroy();
glfwTerminate();
LOGGER.fine("Display destroyed."); LOGGER.fine("Display destroyed.");
} }

View File

@ -1793,9 +1793,8 @@ public class TerrainQuad extends Node implements Terrain {
// This was not cloned before... I think that's a mistake. // This was not cloned before... I think that's a mistake.
this.affectedAreaBBox = cloner.clone(affectedAreaBBox); this.affectedAreaBBox = cloner.clone(affectedAreaBBox);
// picker is not cloneable and not cloned. This also seems like // Otherwise, picker would be cloned by reference and thus "this" would be wrong
// a mistake if you ever load the same terrain twice. this.picker = new BresenhamTerrainPicker(this);
// this.picker = cloner.clone(picker);
// neighbourFinder is also not cloned. Maybe that's ok. // neighbourFinder is also not cloned. Maybe that's ok.
} }

View File

@ -24,35 +24,107 @@ ext {
task configureVersionInfo { task configureVersionInfo {
try { try {
// Users can configure behavior by setting properties on the command
// line:
//
// jmeVersionName:
// If set this will override all automatic version detection.
//
// useCommitHashAsVersionName:
// If there is no jmeVersionName set and the current commit has no
// specific tag then setting this to 'true' will cause the version to
// be the full commit ID.
//
// includeBranchInVersion:
// Set to true if a non-master branch name should be included in the automatically
// generated version.
def grgit = Grgit.open(project.file('.')) def grgit = Grgit.open(project.file('.'))
def head = grgit.head() def head = grgit.head()
jmeRevision = grgit.log(includes: [head]).size() jmeRevision = grgit.log(includes: [head]).size()
jmeGitHash = head.id jmeGitHash = head.id
jmeShortGitHash = head.abbreviatedId jmeShortGitHash = head.abbreviatedId
jmeBranchName = grgit.branch.current.name jmeBranchName = grgit.branch.current.name
jmeGitTag = grgit.tag.list().find { it.commit == head }
if(jmeVersionName==""){ // This code will find an exact-match tag if the current
if (jmeGitTag != null) { // commit is the same as the tag commit.
jmeGitTag = jmeGitTag.name jmeGitTag = grgit.tag.list().find { it.commit == head }
jmeFullVersion = jmeGitTag def latestTag;
jmeVersionTag = "" if( jmeGitTag ) {
} else { // Just use the name. We keep jmeGitTag separate because there
if(useCommitHashAsVersionName=="true"&&jmeGitHash!=null&&!jmeGitHash.equals("")){ // is some logic that wants to know if this specific commit has
jmeFullVersion = jmeGitHash // a tag versus 'whatever tag we are a child of'... which is what
jmeVersionTag = "" // 'latestTag' will be.
}else{ jmeGitTag = jmeGitTag.name
jmeFullVersion="${jmeVersion}-"; latestTag = jmeGitTag;
if(jmeBranchName!="master")jmeFullVersion+="${jmeBranchName}-"; } else {
jmeFullVersion+="SNAPSHOT" // Use describe to find the most recent tag. Unfortunately,
jmeVersionTag="SNAPSHOT" // in this version of grgit, we don't have the 'always' options
} // so we can't make as many assumptions about the format of the
} // string.
}else{ // If the commit is an exact match then it will return just the
jmeVersionTag="" // tag name... else it will be tagName-commitCount-abbreviatedId
jmeFullVersion=jmeVersionName // We'll use some groovy regex magic to get the tag either way.
def describe = grgit.describe()
def fullDescribe = (describe =~/(.*?)-(\d+)-g$jmeShortGitHash/)
latestTag = fullDescribe ? fullDescribe[0][1] : describe
println "Latest tag:" + latestTag
} }
// We could enhance this with some more regex if we wanted to sanity
// check that it was formatted like our versions.
def tagVersion = (latestTag =~/v?(.*)/)[0][1];
// If the branch is not master then use the tag.
if( jmeBranchName != "master" ) {
jmeVersion = tagVersion
}
// Parse out just the base version part. -SNAPSHOT versions
// shouldn't really include our release suffixes
def baseVersion = (tagVersion =~/(\d+\.\d+.\d+)/)
baseVersion = baseVersion.size() > 0 ? baseVersion[0][0] : tagVersion
if( !jmeVersionName ) {
// If there is a specific tag for the top commit then we always
// use that.
if( jmeGitTag ) {
println "Using GIT tag as version"
jmeFullVersion = tagVersion; // already cleaned up
jmeVersionTag = "" // and no SNAPSHOT suffix for an exact version tag
// Note: this will not automatically add SNAPSHOT if the user has
// local changes that they haven't committed. Technically, only
// real CI builds should be using non-SNAPSHOT versions so we may
// eventually want to change the script to always use -SNAPSHOT with
// a CI option to turn it off.
// We could also check the grgit.status for unstaged modified/removed files.
// def unstaged = grgit.status().unstaged;
// def modCount = unstaged.modified.size() + unstaged.removed.size()
// ...but that seems like a wasteful check considering only official
// version builds should not have a -SNAPSHOT.
} else if( useCommitHashAsVersionName == "true" && jmeGitHash ) {
// The user has opted to use the hash... and we actually have
// a hash.
println "Using commit ID as version"
jmeFullVersion = jmeGitHash;
jmeVersionTag = ""
} else {
println "Auto-detecting version"
jmeVersionTag = "SNAPSHOT"
if( includeBranchInVersion == "true" && jmeBranchName != "master" ) {
jmeFullVersion = baseVersion + "-" + jmeBranchName + "-" + jmeVersionTag;
} else {
jmeFullVersion = baseVersion + "-" + jmeVersionTag;
}
}
} else {
// Just use defaults
println "Using user-defined version"
jmeFullVersion=jmeVersionName
jmeVersionTag = "SNAPSHOT"
}
println("Revision: ${jmeRevision}") println("Revision: ${jmeRevision}")
println("Hash: ${jmeGitHash}") println("Hash: ${jmeGitHash}")
@ -61,7 +133,8 @@ task configureVersionInfo {
println("Build Date: ${jmeBuildDate}") println("Build Date: ${jmeBuildDate}")
println("Build Branch: ${jmeBranchName}") println("Build Branch: ${jmeBranchName}")
println("Use commit hash as version ${useCommitHashAsVersionName}") println("Use commit hash as version ${useCommitHashAsVersionName}")
println("Build Tag: ${jmeVersionTag}") println("Base Version: ${baseVersion}")
println("Build Suffix: ${jmeVersionTag}")
println("Build Version: ${jmeFullVersion}") println("Build Version: ${jmeFullVersion}")
} catch (ex) { } catch (ex) {