Skip to content

Grayscale Issue temporary patch #1571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e5899ff
AnimEvent: grammatical correction to the javadoc
stephengold Apr 22, 2021
81d5ca6
GLRenderer: avoid NPE reported by Pavl_G (#1527)
stephengold Apr 25, 2021
70eb9d8
jme3-core: corrections to comments ("bellow" -> "below")
stephengold Apr 26, 2021
e3f6ac4
AppProfiler: Fixed typo in comment (#1535)
theHacker Apr 29, 2021
146f4b9
fix issue #1533 (failed assertion in TestAnimMigration) (#1534)
stephengold May 1, 2021
4ec83aa
TransformTrack: add null checks to getTranslations() and getRotations…
stephengold May 1, 2021
b70be12
TestBareBonesApp: add missing apostrophe to a comment
stephengold May 4, 2021
f15f3ed
Refactors the context restart code. (#1526)
Markil3 May 5, 2021
1e84bb3
LwjglContext: correction to comment ("relevent" -> "relevant")
stephengold May 5, 2021
2788165
Joint: resolve 2 javadoc warnings
stephengold May 7, 2021
bc973a5
LodGenerator.java: improve the javadoc (#1540)
ITGame-designer337 May 8, 2021
db23bd6
AnimEvent: solve bug where onStop() kills prior event on the same lay…
stephengold May 8, 2021
5dc1f01
correct the dependencies of jme3-jbullet (#1541)
stephengold May 8, 2021
fef5fc4
AnimEvent: enhance logging
stephengold May 4, 2021
0a9e3f7
TestDirectionalLightShadow: don't dup mappings of ShadowTestUIManager
stephengold May 11, 2021
65d8ff7
TestDirectionalLightShadow: don't dup 2 mappings in ShadowTestUIManager
stephengold May 11, 2021
88effd4
TestGltfUnlit: simplify
stephengold May 12, 2021
b8e5c25
solve issue #1542 (crash in TestAppStates) (#1545)
stephengold May 12, 2021
8989a75
solve issue #1543 (crash in TestManyLocators) (#1546)
stephengold May 12, 2021
51d0388
solve issue #1544 (diagnostic messages from TestMusicPlayer) (#1547)
stephengold May 12, 2021
01fbd16
test case and solution for issue #1548 (MorphControl doesn't override…
stephengold May 12, 2021
55d549a
Matrix4f: improve the javadoc (#1550)
stephengold May 12, 2021
9c40d2f
BloomUI: correct a "System.out" hint message
stephengold May 12, 2021
4cd537a
LightScatteringUI: correct a "System.out" hint message
stephengold May 12, 2021
bdf15ba
SSAOUI: correct a "System.out" hint message
stephengold May 13, 2021
7b82356
TestDepthFuncChange: correct 2 typographical error in comments
stephengold May 13, 2021
338f95d
TestTexture3D: correct 2 typographical errors in comments
stephengold May 13, 2021
ba3741d
WaterUI: correct a "System.out" hint message
stephengold May 14, 2021
70e1749
resolve issue #1551 (OpenGLExceptions in jme3-examples) (#1556)
stephengold May 15, 2021
6644cca
MorphControl: serialize target list & add minor cleanups (#1553)
Ali-RS May 16, 2021
fb5529f
TestAttachDriver: don't remove the SliderJoint more than once (#1560)
stephengold May 18, 2021
a13946a
fix issue 1559 (TestSoftwareMouse misbehaves with LWJGL v3)
stephengold May 18, 2021
7978802
TestJaime: longer "JumpForward" animation to cut risk of incomplete jump
stephengold May 19, 2021
4b697fe
AnimEvent: add details to the log output for onStop()
stephengold May 19, 2021
469fd72
solve issue #1562 (NPE in TestMusicPlayer)
stephengold May 19, 2021
1107105
jme3-examples: comments ("jme3-testdata")
stephengold May 19, 2021
a186509
TextureUtil: correct 2 typos
stephengold May 20, 2021
c0bb575
TestFancyCar: delete useless code and commented-out code
stephengold May 25, 2021
cb5173b
Test and solution for issue #1564 (setting Material parameter of type…
theMinka May 27, 2021
91863ac
Adjusted calculations for colorToGrey.frag to account for similar col…
Jun 10, 2021
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
32 changes: 32 additions & 0 deletions jme3-core/src/main/java/com/jme3/anim/AnimComposer.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,37 @@ public void setGlobalSpeed(float globalSpeed) {
this.globalSpeed = globalSpeed;
}

/**
* Access the manager of the named layer.
*
* @param layerName the name of the layer to access
* @return the current manager (typically an AnimEvent) or null for none
*/
public Object getLayerManager(String layerName) {
Layer layer = layers.get(layerName);
if (layer == null) {
throw new IllegalArgumentException("Unknown layer " + layerName);
}

return layer.manager;
}

/**
* Assign a manager to the named layer.
*
* @param layerName the name of the layer to modify
* @param manager the desired manager (typically an AnimEvent) or null for
* none
*/
public void setLayerManager(String layerName, Object manager) {
Layer layer = layers.get(layerName);
if (layer == null) {
throw new IllegalArgumentException("Unknown layer " + layerName);
}

layer.manager = manager;
}

/**
* Create a shallow clone for the JME cloner.
*
Expand Down Expand Up @@ -539,6 +570,7 @@ private static class Layer implements JmeCloneable {
private Action currentAction;
private AnimationMask mask;
private double time;
private Object manager;

public Layer(AnimComposer ac) {
this.ac = ac;
Expand Down
3 changes: 2 additions & 1 deletion jme3-core/src/main/java/com/jme3/anim/Joint.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private void updateAttachNode() {
* have already been computed, otherwise this method will return undefined
* results.
*
* @param outTransform
* @param outTransform storage for the result (modified)
*/
void getOffsetTransform(Matrix4f outTransform) {
jointModelTransform.getOffsetTransform(outTransform, inverseModelBindMatrix);
Expand Down Expand Up @@ -358,6 +358,7 @@ public List<Joint> getChildren() {
* @param jointIndex this bone's index in its armature (&ge;0)
* @param targets a list of geometries animated by this bone's skeleton (not
* null, unaffected)
* @return the attachments node (not null)
*/
Node getAttachmentsNode(int jointIndex, SafeArrayList<Geometry> targets) {
targetGeometry = null;
Expand Down
115 changes: 100 additions & 15 deletions jme3-core/src/main/java/com/jme3/anim/MorphControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@
*/
package com.jme3.anim;

import com.jme3.export.Savable;
import com.jme3.material.*;
import com.jme3.export.*;
import com.jme3.material.MatParam;
import com.jme3.material.MatParamOverride;
import com.jme3.material.Material;
import com.jme3.renderer.*;
import com.jme3.scene.*;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.mesh.MorphTarget;
import com.jme3.shader.VarType;
import com.jme3.util.BufferUtils;
import com.jme3.util.SafeArrayList;

import com.jme3.util.clone.Cloner;
import java.io.IOException;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -50,6 +54,9 @@
* All stock shaders only support morphing these 3 buffers, but note that MorphTargets can have any type of buffers.
* If you want to use other types of buffers you will need a custom MorphControl and a custom shader.
*
* Note that if morphed children are attached to or detached from the sub graph after the MorphControl is added to
* spatial, you must detach and attach the control again for the changes to get reflected.
*
* @author Rémy Bouquet
*/
public class MorphControl extends AbstractControl implements Savable {
Expand All @@ -59,11 +66,14 @@ public class MorphControl extends AbstractControl implements Savable {
private static final int MAX_MORPH_BUFFERS = 14;
private final static float MIN_WEIGHT = 0.005f;

final private SafeArrayList<Geometry> targets = new SafeArrayList<>(Geometry.class);
final private TargetLocator targetLocator = new TargetLocator();
private static final String TAG_APPROXIMATE = "approximateTangents";
private static final String TAG_TARGETS = "targets";

private SafeArrayList<Geometry> targets = new SafeArrayList<>(Geometry.class);
private TargetLocator targetLocator = new TargetLocator();

private boolean approximateTangents = true;
final private MatParamOverride nullNumberOfBones = new MatParamOverride(VarType.Int, "NumberOfBones", null);
private MatParamOverride nullNumberOfBones = new MatParamOverride(VarType.Int, "NumberOfBones", null);

private float[] tmpPosArray;
private float[] tmpNormArray;
Expand All @@ -72,22 +82,31 @@ public class MorphControl extends AbstractControl implements Savable {
private static final VertexBuffer.Type bufferTypes[] = VertexBuffer.Type.values();

@Override
protected void controlUpdate(float tpf) {
if (!enabled) {
return;
public void setSpatial(Spatial spatial) {
super.setSpatial(spatial);

// Remove matparam override from the old targets
for (Geometry target : targets.getArray()) {
target.removeMatParamOverride(nullNumberOfBones);
}

// gathering geometries in the sub graph.
// This must be done in the update phase as the gathering might add a matparam override
// This must not be done in the render phase as the gathering might add a matparam override
// which then will throw an IllegalStateException if done in the render phase.
targets.clear();
this.spatial.depthFirstTraversal(targetLocator);
if (spatial != null) {
spatial.depthFirstTraversal(targetLocator);
}
}

@Override
protected void controlUpdate(float tpf) {

}

@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
if (!enabled) {
return;
}
for (Geometry geom : targets) {
for (Geometry geom : targets.getArray()) {
Mesh mesh = geom.getMesh();
if (!geom.isDirtyMorph()) {
continue;
Expand Down Expand Up @@ -373,6 +392,72 @@ public boolean isApproximateTangents() {
return approximateTangents;
}

/**
* Callback from {@link com.jme3.util.clone.Cloner} to convert this
* shallow-cloned Control into a deep-cloned one, using the specified Cloner
* and original to resolve copied fields.
*
* @param cloner the Cloner that's cloning this Control (not null, modified)
* @param original the instance from which this Control was shallow-cloned
* (not null, unaffected)
*/
@Override
public void cloneFields(Cloner cloner, Object original) {
super.cloneFields(cloner, original);

targets = cloner.clone(targets);
targetLocator = new TargetLocator();
nullNumberOfBones = cloner.clone(nullNumberOfBones);
tmpPosArray = null;
tmpNormArray = null;
tmpTanArray = null;
}

/**
* Create a shallow clone for the JME cloner.
*
* @return a new instance
*/
@Override
public MorphControl jmeClone() {
try {
MorphControl clone = (MorphControl) super.clone();
return clone;
} catch (CloneNotSupportedException exception) {
throw new RuntimeException(exception);
}
}

/**
* De-serialize this Control from the specified importer, for example when
* loading from a J3O file.
*
* @param importer (not null)
* @throws IOException from the importer
*/
@Override
public void read(JmeImporter importer) throws IOException {
super.read(importer);
InputCapsule capsule = importer.getCapsule(this);
approximateTangents = capsule.readBoolean(TAG_APPROXIMATE, true);
targets.addAll(capsule.readSavableArrayList(TAG_TARGETS, null));
}

/**
* Serialize this Control to the specified exporter, for example when saving
* to a J3O file.
*
* @param exporter (not null)
* @throws IOException from the exporter
*/
@Override
public void write(JmeExporter exporter) throws IOException {
super.write(exporter);
OutputCapsule capsule = exporter.getCapsule(this);
capsule.write(approximateTangents, TAG_APPROXIMATE, true);
capsule.writeSavableArrayList(new ArrayList(targets), TAG_TARGETS, null);
}

private class TargetLocator extends SceneGraphVisitorAdapter {
@Override
public void visit(Geometry geom) {
Expand Down
8 changes: 4 additions & 4 deletions jme3-core/src/main/java/com/jme3/anim/TransformTrack.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public TransformTrack(HasLocalTransform target, float[] times, Vector3f[] transl
/**
* return the array of rotations of this track
*
* @return an array
* @return an array, or null if no rotations
*/
public Quaternion[] getRotations() {
return rotations.toObjectArray();
return rotations == null ? null : rotations.toObjectArray();
}

/**
Expand All @@ -110,10 +110,10 @@ public float[] getTimes() {
/**
* returns the array of translations of this track
*
* @return an array
* @return an array, or null if no translations
*/
public Vector3f[] getTranslations() {
return translations.toObjectArray();
return translations == null ? null : translations.toObjectArray();
}


Expand Down
29 changes: 21 additions & 8 deletions jme3-core/src/main/java/com/jme3/cinematic/events/AnimEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import java.util.logging.Logger;

/**
* An CinematicEvent that plays a canned animation action in an
* A CinematicEvent that plays a canned animation action in an
* {@link com.jme3.anim.AnimComposer}.
*
* Inspired by Nehon's {@link AnimationEvent}.
Expand Down Expand Up @@ -121,18 +121,23 @@ public void initEvent(Application app, Cinematic cinematic) {
*/
@Override
public void onPause() {
logger.log(Level.SEVERE, "");
logger.log(Level.INFO, "layer={0} action={1}",
new Object[]{layerName, actionName});

Action eventAction = composer.action(actionName);
eventAction.setSpeed(0f);
Object layerManager = composer.getLayerManager(layerName);
if (layerManager == this) {
Action eventAction = composer.action(actionName);
eventAction.setSpeed(0f);
}
}

/**
* Callback when the event is started.
*/
@Override
public void onPlay() {
logger.log(Level.INFO, "");
logger.log(Level.INFO, "layer={0} action={1}",
new Object[]{layerName, actionName});

Action currentAction = composer.getCurrentAction(layerName);
Action eventAction = composer.action(actionName);
Expand All @@ -149,15 +154,22 @@ public void onPlay() {
composer.setTime(layerName, 0.0);
}
eventAction.setSpeed(speed);
composer.setLayerManager(layerName, this);
}

/**
* Callback when the event is stopped.
*/
@Override
public void onStop() {
logger.log(Level.INFO, "");
composer.removeCurrentAction(layerName);
logger.log(Level.INFO, "layer={0} action={1}",
new Object[]{layerName, actionName});

Object layerManager = composer.getLayerManager(layerName);
if (layerManager == this) {
composer.removeCurrentAction(layerName);
composer.setLayerManager(layerName, null);
}
}

/**
Expand Down Expand Up @@ -212,7 +224,8 @@ public void setSpeed(float speed) {
*/
@Override
public void setTime(float time) {
logger.log(Level.INFO, "time = {0}", time);
logger.log(Level.INFO, "layer={0} action={1} time={2}",
new Object[]{layerName, actionName, time});
super.setTime(time);

Action currentAction = composer.getCurrentAction(layerName);
Expand Down
2 changes: 1 addition & 1 deletion jme3-core/src/main/java/com/jme3/light/SpotLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void computeAngleParameters() {
packedAngleCos = (int) (innerCos * 1000);

//due to approximations, very close angles can give the same cos
//here we make sure outer cos is bellow inner cos.
//here we make sure outer cos is below inner cos.
if (((int) packedAngleCos) == ((int) (outerAngleCos * 1000))) {
outerAngleCos -= 0.001f;
}
Expand Down
Loading