Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
be87dee
com.jme3.anim.tween.action.BlendSpace: basic javadoc
pavly-gerges May 27, 2023
4a5100d
class-entry-javadoc: documentation of different cases of blending-wei…
pavly-gerges May 28, 2023
c90cd78
class-entry-javadoc: inlined value domain with the value at 'Blending…
pavly-gerges May 28, 2023
7c5e36c
BlendSpace#getWeight(): extra clarification of the transformations word
pavly-gerges May 28, 2023
8ca8d9d
class-entry-javadoc: added reference for more
pavly-gerges May 28, 2023
d4570dc
class-entry-javadoc: added zero and negative case scenarios
pavly-gerges May 28, 2023
433bf5d
class-entry-javadoc: restricts blend weight values to [0, 1]
pavly-gerges May 29, 2023
a8602f8
BlendSpace: better documentation formatting
pavly-gerges May 29, 2023
bbd041c
class-entry-javadoc: more clarifications on the 'blending' definition
pavly-gerges May 29, 2023
a3603f2
class-entry-javadoc: removed irrelevant IllegalArgumentException docu…
pavly-gerges May 29, 2023
dd1dbac
Strict blend weight range
pavly-gerges May 29, 2023
bffb6a9
BlendSpace#getWeight(): sentence typos
pavly-gerges May 29, 2023
6c8a00f
BlendSpace#setBlendAction(...): javadoc mark the argument as not-null
pavly-gerges May 30, 2023
95f815b
BlendSpace#getWeight(): moved the blend weight range to the return ta…
pavly-gerges May 31, 2023
637275f
BlendSpace#getWeight(): explicitly saying "negative values and values…
pavly-gerges May 31, 2023
bf37824
BlendSpace.java: updated copyright to 2024
pavly-gerges Jan 22, 2024
9bc1eda
Class-JavaDoc: better explanation of the interface purpose
pavly-gerges Jan 24, 2024
ab466ac
Class-JavaDoc: denoted that extrapolations are disabled in a blending…
pavly-gerges Jan 24, 2024
7a18af3
Update BlendSpace.java
pavly-gerges Jan 24, 2024
5e70e87
JmeSurfaceView: corrected the dispatching algorithm of SystemListener…
pavly-gerges Feb 2, 2025
6735cb7
OGLESContext#deinitInThread(): releasing the weak references of the A…
pavly-gerges Feb 2, 2025
d9a90fa
JmeSurfaceView: removed unused imports
pavly-gerges Feb 2, 2025
02c3b53
Update Jme3 Copyright to 2025
pavly-gerges Feb 2, 2025
86b6d59
JmeSurfaceView.java: documentation enhances
pavly-gerges Feb 3, 2025
1b91c0d
BlendSpace.java: updated Jme3 Copyright to 2025
pavly-gerges Feb 5, 2025
b3b2e01
Fix Fog in Lighting.frag
yaRnMcDonuts Feb 6, 2025
f0553ca
Update author in MaterialFog.glsllib
yaRnMcDonuts Feb 8, 2025
8df8441
Remove author name in confusing location
yaRnMcDonuts Feb 8, 2025
139b7d2
Fix missing wViewDir variable
yaRnMcDonuts Feb 10, 2025
841cd7f
add geometryNormal debug mode
yaRnMcDonuts Feb 10, 2025
3ddc195
minor formatting edits
yaRnMcDonuts Feb 10, 2025
9a1c11c
Set non null values as defaults for vars in PBRSurface
yaRnMcDonuts Feb 10, 2025
772f2ea
Merge pull request #2 from yaRnMcDonuts/yaRnMcDonuts-patch-2
yaRnMcDonuts Feb 10, 2025
b03dec8
BlendSpace: re-enforcements at the class-entry docs
pavly-gerges Feb 16, 2025
adf1147
BlendSpace.java: decomposed notes at the class-entry from the blend w…
pavly-gerges Feb 16, 2025
b174045
Merge pull request #2359 from Electrostat-Lab/fix-jmesurfaceview-mem-…
yaRnMcDonuts Feb 17, 2025
b2f9e68
Merge pull request #2367 from yaRnMcDonuts/master
yaRnMcDonuts Feb 17, 2025
becdf50
Merge pull request #2364 from jMonkeyEngine/yaRnMcDonuts-patch-6
yaRnMcDonuts Feb 17, 2025
7783a4d
Merge pull request #2022 from Electrostat-Lab/blendspace-javadocs
yaRnMcDonuts Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2023 jMonkeyEngine
* Copyright (c) 2009-2025 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -247,10 +247,19 @@ protected void deinitInThread() {
}

listener.destroy();

// releases the view holder from the Android Input Resources
// releasing the view enables the context instance to be
// reclaimed by the GC.
// if not released; it leads to a weak reference leak
// disabling the destruction of the Context View Holder.
androidInput.setView(null);

// nullifying the references
// signals their memory to be reclaimed
listener = null;
renderer = null;
timer = null;
androidInput = null;

// do android specific cleaning here
logger.fine("Display destroyed.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2022 jMonkeyEngine
* Copyright (c) 2009-2025 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -239,11 +239,7 @@ public void startRenderer(int delayMillis) {
}

private void removeGLSurfaceView() {
((Activity) getContext()).runOnUiThread(() -> {
if (glSurfaceView != null) {
JmeSurfaceView.this.removeView(glSurfaceView);
}
});
((Activity) getContext()).runOnUiThread(() -> JmeSurfaceView.this.removeView(glSurfaceView));
}

@Override
Expand All @@ -265,19 +261,34 @@ public void handleError(String errorMsg, Throwable throwable) {
public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) {
switch (event) {
case ON_DESTROY:
/*destroy only if the policy flag is enabled*/
if (destructionPolicy == DestructionPolicy.DESTROY_WHEN_FINISH) {
legacyApplication.stop(!isGLThreadPaused());
}
// activity is off the foreground stack
// activity is being destructed completely as a result of Activity#finish()
// this is a killable automata state!
jmeSurfaceViewLogger.log(Level.INFO, "Hosting Activity has been destructed.");
break;
case ON_PAUSE:
loseFocus();
// activity is still on the foreground stack but not
// on the topmost level or before transition to stopped/hidden or destroyed state
// as a result of dispatch to Activity#finish()
// activity is no longer visible and is out of foreground
if (((Activity) getContext()).isFinishing()) {
if (destructionPolicy == DestructionPolicy.DESTROY_WHEN_FINISH) {
legacyApplication.stop(!isGLThreadPaused());
} else if (destructionPolicy == DestructionPolicy.KEEP_WHEN_FINISH) {
jmeSurfaceViewLogger.log(Level.INFO, "Context stops, but game is still running.");
}
} else {
loseFocus();
}
break;
case ON_RESUME:
// activity is back to the topmost of the
// foreground stack
gainFocus();
break;
case ON_STOP:
jmeSurfaceViewLogger.log(Level.INFO, "Context stops, but game is still running");
// activity is out off the foreground stack or being destructed by a finishing dispatch
// this is a killable automata state!
break;
}
}
Expand Down Expand Up @@ -404,13 +415,13 @@ public void loseFocus() {

@Override
public void destroy() {
/*skip the destroy block if the invoking instance is null*/
if (legacyApplication == null) {
return;
if (glSurfaceView != null) {
removeGLSurfaceView();
}
if (legacyApplication != null) {
legacyApplication.destroy();
}
removeGLSurfaceView();
legacyApplication.destroy();
/*help the Dalvik Garbage collector to destruct the pointers, by making them nullptr*/
/*help the Dalvik Garbage collector to destruct the objects, by releasing their references*/
/*context instances*/
legacyApplication = null;
appSettings = null;
Expand All @@ -430,10 +441,10 @@ public void destroy() {
onRendererCompleted = null;
onExceptionThrown = null;
onLayoutDrawn = null;
/*nullifying the static memory (pushing zero to registers to prepare for a clean use)*/
GameState.setLegacyApplication(null);
GameState.setFirstUpdatePassed(false);
jmeSurfaceViewLogger.log(Level.INFO, "Context and Game have been destructed");
JmeAndroidSystem.setView(null);
jmeSurfaceViewLogger.log(Level.INFO, "Context and Game have been destructed.");
}

@Override
Expand Down Expand Up @@ -516,11 +527,13 @@ public void bindAppStateToActivityLifeCycle(final boolean condition) {
/*register this Ui Component as an observer to the context of jmeSurfaceView only if this context is a LifeCycleOwner*/
if (getContext() instanceof LifecycleOwner) {
((LifecycleOwner) getContext()).getLifecycle().addObserver(JmeSurfaceView.this);
jmeSurfaceViewLogger.log(Level.INFO, "Command binding SurfaceView to the Activity Lifecycle.");
}
} else {
/*un-register this Ui Component as an observer to the context of jmeSurfaceView only if this context is a LifeCycleOwner*/
if (getContext() instanceof LifecycleOwner) {
((LifecycleOwner) getContext()).getLifecycle().removeObserver(JmeSurfaceView.this);
jmeSurfaceViewLogger.log(Level.INFO, "Command removing SurfaceView from the Activity Lifecycle.");
}
}
}
Expand Down Expand Up @@ -917,7 +930,7 @@ public void setShowErrorDialog(boolean showErrorDialog) {
}

/**
* Determines whether the app context would be destructed
* Determines whether the app context would be destructed as a result of dispatching {@link Activity#finish()}
* with the holder activity context in case of {@link DestructionPolicy#DESTROY_WHEN_FINISH} or be
* spared for a second use in case of {@link DestructionPolicy#KEEP_WHEN_FINISH}.
* Default value is : {@link DestructionPolicy#DESTROY_WHEN_FINISH}.
Expand All @@ -926,12 +939,14 @@ public void setShowErrorDialog(boolean showErrorDialog) {
*/
public enum DestructionPolicy {
/**
* Finishes the game context with the activity context (ignores the static memory {@link GameState#legacyApplication}).
* Finishes the game context with the activity context (ignores the static memory {@link GameState#legacyApplication})
* as a result of dispatching {@link Activity#finish()}.
*/
DESTROY_WHEN_FINISH,
/**
* Spares the game context inside a static memory {@link GameState#legacyApplication}
* when the activity context is destroyed, but the app stills in the background.
* when the activity context is destroyed dispatching {@link Activity#finish()}, but the {@link android.app.Application}
* stills in the background.
*/
KEEP_WHEN_FINISH
}
Expand Down
85 changes: 85 additions & 0 deletions jme3-core/src/main/java/com/jme3/anim/tween/action/BlendSpace.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,95 @@
/*
* Copyright (c) 2009-2025 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 com.jme3.anim.tween.action;

/**
* A provider interface which provides a value {@link BlendSpace#getWeight()} to control the blending between 2 successive actions in a {@link BlendAction}.
* The blending weight is a read-only value, and it can be manipulated using the arbitrary value {@link BlendSpace#setValue(float)} during the application runtime.
*
* <p>
* Notes about the blending action and its relations with the blending weight:
* <ul>
* <li> Blending is the action of mixing between 2 successive animation {@link BlendableAction}s by interpolating their transforms and
* then applying the result on the assigned {@link HasLocalTransform} object, the {@link BlendSpace} provides this blending action with a blend weight value. </li>
* <li> The blend weight is the value for the interpolation for the target transforms. </li>
* <li> The blend weight value must be in this interval [0, 1]. </li>
* </ul>
* </p>
*
* <p>
* Different blending weight case scenarios managed by {@link BlendAction} internally:
* <ul>
* <li> In case of (0 < Blending weight < 1), the blending is executed each update among 2 actions, the first action will use
* a blend value of 1 and the second action will use the blend space weight as a value for the interpolation. </li>
* <li> In case of (Blending weight = 0), the blending hasn't started yet, only the first action will be interpolated at (weight = 1). </li>
* <li> In case of (Blending weight = 1), the blending is finished and only the second action will continue to run at (weight = 1). </li>
* </ul>
* </p>
*
* <p>
* Notes about the blending weight value:
* <ul>
* <li> Negative values and values greater than 1 aren't allowed (i.e., extrapolations aren't allowed). </li>
* <li> For more details, see {@link BlendAction#doInterpolate(double)} and {@link BlendAction#collectTransform(HasLocalTransform, Transform, float, BlendableAction)}. </li>
* </ul>
* </p>
*
* Created by Nehon.
* @see LinearBlendSpace an example of blendspace implementation
*/
public interface BlendSpace {

/**
* Adjusts the target blend action instance that will utilize the blend weight value provided by this blend-space implementation.
*
* @param action the blend action instance that will utilize this blend-space (not null).
*/
public void setBlendAction(BlendAction action);

/**
* Provides the blend weight value to the assigned {@link BlendAction} instance,
* this value will be used for interpolating a collection of actions' transformations (i.e., keyframes).
*
* @return the blending weight value in the range from 0 to 1,
* negative values and values above 1 aren't allowed.
* @see LinearBlendSpace#getWeight()
*/
public float getWeight();

/**
* An arbitrary value used for adjusting the blending weight value.
*
* @param value the value in floats.
* @see LinearBlendSpace#setValue(float)
*/
public void setValue(float value);
}
34 changes: 4 additions & 30 deletions jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,9 @@
#import "Common/ShaderLib/Lighting.glsllib"
#endif

// fog - jayfella
#ifdef USE_FOG
#import "Common/ShaderLib/MaterialFog.glsllib"
varying float fog_distance;
uniform vec4 m_FogColor;

#ifdef FOG_LINEAR
uniform vec2 m_LinearFog;
#endif

#ifdef FOG_EXP
uniform float m_ExpFog;
#endif

#ifdef FOG_EXPSQ
uniform float m_ExpSqFog;
#endif

#endif // end fog
#import "Common/ShaderLib/MaterialFog.glsllib"
#endif

varying vec2 texCoord;
#ifdef SEPARATE_TEXCOORD
Expand Down Expand Up @@ -231,21 +215,11 @@ void main(){
SpecularSum2.rgb * specularColor.rgb * vec3(light.y);
#endif


// add fog after the lighting because shadows will cause the fog to darken
// which just results in the geometry looking like it's changed color
#ifdef USE_FOG
#ifdef FOG_LINEAR
gl_FragColor = getFogLinear(gl_FragColor, m_FogColor, m_LinearFog.x, m_LinearFog.y, fog_distance);
#endif
#ifdef FOG_EXP
gl_FragColor = getFogExp(gl_FragColor, m_FogColor, m_ExpFog, fog_distance);
#endif
#ifdef FOG_EXPSQ
gl_FragColor = getFogExpSquare(gl_FragColor, m_FogColor, m_ExpSqFog, fog_distance);
#endif
#endif // end fog

gl_FragColor = MaterialFog_calculateFogColor(vec4(gl_FragColor));
#endif

gl_FragColor.a = alpha;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//author @jayfella
#ifndef __MATERIAL_FOG_UTIL__
#define __MATERIAL_FOG_UTIL__


vec4 getFogLinear(in vec4 diffuseColor, in vec4 fogColor, in float start, in float end, in float distance) {

float fogFactor = (end - distance) / (end - start);
Expand Down Expand Up @@ -39,8 +39,7 @@

#ifdef FOG_EXPSQ
uniform float m_ExpSqFog;
#endif

#endif

vec4 MaterialFog_calculateFogColor(in vec4 fragColor){
#ifdef FOG_LINEAR
Expand All @@ -54,7 +53,7 @@
#endif

return fragColor;
}
}

#endif
#endif
Loading
Loading