From d2315beda93202349212fd5c2d72d93a7e3990ad Mon Sep 17 00:00:00 2001 From: codex <103840984+codex128@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:10:20 -0400 Subject: [PATCH 01/37] added AlertArmatureMask --- .../java/com/jme3/anim/AlertArmatureMask.java | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java diff --git a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java new file mode 100644 index 0000000000..33912c28e3 --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java @@ -0,0 +1,190 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.jme3.anim; + +import com.jme3.scene.Spatial; +import java.util.Iterator; + +/** + * Extension of {@link ArmatureMask}. + * + *
Provides a feature which checks higher layers for joint use before it + * approves the layer to use a joint. + * + * @author codex + */ +public class AlertArmatureMask extends ArmatureMask { + + private final String layer; + private final AnimComposer anim; + private final SkinningControl skin; + private boolean checkUpperLayers = true; + + /** + * @param layer The layer this mask is targeted for. It is extremely important + * that this match the name of the layer this mask is (or will be) part of. You + * can use {@link makeLayer} to ensure this. + * @param spatial Spatial containing necessary controls ({@link AnimComposer} and {@link SkinningControl}) + */ + public AlertArmatureMask(String layer, Spatial spatial) { + super(); + this.layer = layer; + anim = spatial.getControl(AnimComposer.class); + skin = spatial.getControl(SkinningControl.class); + } + public AlertArmatureMask(String layer, AnimComposer anim, SkinningControl skin) { + super(); + this.layer = layer; + this.anim = anim; + this.skin = skin; + } + + /** + * Creates a copyFor of this {@code AlertArmatureMask} for the given layer. + * @param layer + * @return copyFor of this {@code AlertArmatureMask} for the layer + */ + public AlertArmatureMask copyFor(String layer) { + return new AlertArmatureMask(layer, anim, skin); + } + /** + * Makes a layer for this mask. + */ + public void makeLayer() { + anim.makeLayer(layer, this); + } + + /** + * Adds all joints to this mask. + * @return + */ + public AlertArmatureMask addAll() { + for (Joint j : skin.getArmature().getJointList()) { + super.addBones(skin.getArmature(), j.getName()); + } + return this; + } + /** + * Adds the given joint and all its children to this mask. + * @param joint + * @return + */ + public AlertArmatureMask addFromJoint(String joint) { + super.addFromJoint(skin.getArmature(), joint); + return this; + } + /** + * Adds the given joints to this mask. + * @param joints + * @return + */ + public AlertArmatureMask addJoints(String... joints) { + super.addBones(skin.getArmature(), joints); + return this; + } + + /** + * Makes this mask check if each joint is being used by a higher layer + * before it uses them. + *
Not checking is more efficient, but checking can avoid some + * interpolation issues between layers. Default=true + * @param check + */ + public void setCheckUpperLayers(boolean check) { + checkUpperLayers = check; + } + + /** + * Get the layer this mask is targeted for. + *
It is extremely important that this value match the actual layer + * this is included in, because checking upper layers may not work if + * they are different. + * @return target layer + */ + public String getTargetLayer() { + return layer; + } + /** + * Get the {@link AnimComposer} this mask is for. + * @return + */ + public AnimComposer getAnimComposer() { + return anim; + } + /** + * Get the {@link SkinningControl} this mask is for. + * @return + */ + public SkinningControl getSkinningControl() { + return skin; + } + /** + * Returns true if this mask is checking upper layers for joint use. + * @return + */ + public boolean isCheckUpperLayers() { + return checkUpperLayers; + } + + @Override + public boolean contains(Object target) { + return simpleContains(target) && (!checkUpperLayers || !isAffectedByUpperLayers(target)); + } + private boolean simpleContains(Object target) { + return super.contains(target); + } + private boolean isAffectedByUpperLayers(Object target) { + boolean higher = false; + /** + * ... Since AnimComposer does not provide a Collection that + * has a decending iterator, we will just have to skip over + * a bunch of lower layers before we actually need to do anything. + */ + for (String name : anim.getLayerNames()) { + if (name.equals(layer)) { + higher = true; + continue; + } + if (!higher) { + continue; + } + AnimLayer lyr = anim.getLayer(name); + // if there is no action playing, no joints are used, so we can skip + if (lyr.getCurrentAction() == null) continue; + if (lyr.getMask() instanceof AlertArmatureMask) { + // dodge some needless recursion by calling a simpler method + if (((AlertArmatureMask)lyr.getMask()).simpleContains(target)) { + return true; + } + } + else if (lyr.getMask().contains(target)) { + return true; + } + } + return false; + } + + /** + * Creates an {@code AlertArmatureMask} for all joints. + * @param layer + * @param spatial + * @return + */ + public static AlertArmatureMask all(String layer, Spatial spatial) { + return new AlertArmatureMask(layer, spatial).addAll(); + } + /** + * Creates an {@code AlertArmatureMask} for all joints. + * @param layer + * @param anim + * @param skin + * @return + */ + public static AlertArmatureMask all(String layer, AnimComposer anim, SkinningControl skin) { + return new AlertArmatureMask(layer, anim, skin).addAll(); + } + +} + From 2f1dae883262a0c69918fd1da445e3fa6dfb1211 Mon Sep 17 00:00:00 2001 From: codex <103840984+codex128@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:30:50 -0400 Subject: [PATCH 02/37] fixed docs and added another helper --- .../java/com/jme3/anim/AlertArmatureMask.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java index 33912c28e3..da8d1dcaed 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java +++ b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java @@ -44,7 +44,7 @@ public AlertArmatureMask(String layer, AnimComposer anim, SkinningControl skin) /** * Creates a copyFor of this {@code AlertArmatureMask} for the given layer. * @param layer - * @return copyFor of this {@code AlertArmatureMask} for the layer + * @return copy of this {@code AlertArmatureMask} for the layer */ public AlertArmatureMask copyFor(String layer) { return new AlertArmatureMask(layer, anim, skin); @@ -185,6 +185,21 @@ public static AlertArmatureMask all(String layer, Spatial spatial) { public static AlertArmatureMask all(String layer, AnimComposer anim, SkinningControl skin) { return new AlertArmatureMask(layer, anim, skin).addAll(); } + /** + * Creates an array of masks all sharing the same joint masking as {@code base}. + *
This is useful, for example, when you want to create several layers that all cover + * the entire armature. + * @param base base mask used to create other masks + * @param layers layer names to use + * @return array of new masks + */ + public static AlertArmatureMask[] create(AlertArmatureMask base, String... layers) { + AlertArmatureMask[] masks = new AlertArmatureMask[layers.length]; + for (int i = 0; i < layers.length; i++) { + masks[i] = base.copyFor(layers[i]); + } + return masks; + } } From a750f1cf1a461853a70941bd2897c555543795ff Mon Sep 17 00:00:00 2001 From: codex <103840984+codex128@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:33:45 -0400 Subject: [PATCH 03/37] made it easier to turn off priority checking --- jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java index da8d1dcaed..a9e25607bc 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java +++ b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java @@ -91,9 +91,11 @@ public AlertArmatureMask addJoints(String... joints) { *
Not checking is more efficient, but checking can avoid some * interpolation issues between layers. Default=true * @param check + * @return */ - public void setCheckUpperLayers(boolean check) { + public AlertArmatureMask setCheckUpperLayers(boolean check) { checkUpperLayers = check; + return this; } /** From cd876d403e8039e7831616736fc00847ac661005 Mon Sep 17 00:00:00 2001 From: codex <103840984+codex128@users.noreply.github.com> Date: Mon, 24 Jul 2023 20:09:58 -0400 Subject: [PATCH 04/37] removed copy methods --- .../java/com/jme3/anim/AlertArmatureMask.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java index a9e25607bc..e034b942a5 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java +++ b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java @@ -41,14 +41,6 @@ public AlertArmatureMask(String layer, AnimComposer anim, SkinningControl skin) this.skin = skin; } - /** - * Creates a copyFor of this {@code AlertArmatureMask} for the given layer. - * @param layer - * @return copy of this {@code AlertArmatureMask} for the layer - */ - public AlertArmatureMask copyFor(String layer) { - return new AlertArmatureMask(layer, anim, skin); - } /** * Makes a layer for this mask. */ @@ -187,21 +179,6 @@ public static AlertArmatureMask all(String layer, Spatial spatial) { public static AlertArmatureMask all(String layer, AnimComposer anim, SkinningControl skin) { return new AlertArmatureMask(layer, anim, skin).addAll(); } - /** - * Creates an array of masks all sharing the same joint masking as {@code base}. - *
This is useful, for example, when you want to create several layers that all cover - * the entire armature. - * @param base base mask used to create other masks - * @param layers layer names to use - * @return array of new masks - */ - public static AlertArmatureMask[] create(AlertArmatureMask base, String... layers) { - AlertArmatureMask[] masks = new AlertArmatureMask[layers.length]; - for (int i = 0; i < layers.length; i++) { - masks[i] = base.copyFor(layers[i]); - } - return masks; - } } From 9c9c2d8422bf6e216fed6e10754712651bf5906d Mon Sep 17 00:00:00 2001 From: codex <103840984+codex128@users.noreply.github.com> Date: Fri, 19 Jan 2024 08:06:28 -0500 Subject: [PATCH 05/37] updated license --- .../java/com/jme3/anim/AlertArmatureMask.java | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java index e034b942a5..bc797599e9 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java +++ b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java @@ -1,11 +1,37 @@ /* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + * Copyright (c) 2024 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; import com.jme3.scene.Spatial; -import java.util.Iterator; /** * Extension of {@link ArmatureMask}. @@ -58,6 +84,7 @@ public AlertArmatureMask addAll() { } return this; } + /** * Adds the given joint and all its children to this mask. * @param joint @@ -67,6 +94,7 @@ public AlertArmatureMask addFromJoint(String joint) { super.addFromJoint(skin.getArmature(), joint); return this; } + /** * Adds the given joints to this mask. * @param joints @@ -100,6 +128,7 @@ public AlertArmatureMask setCheckUpperLayers(boolean check) { public String getTargetLayer() { return layer; } + /** * Get the {@link AnimComposer} this mask is for. * @return @@ -107,6 +136,7 @@ public String getTargetLayer() { public AnimComposer getAnimComposer() { return anim; } + /** * Get the {@link SkinningControl} this mask is for. * @return @@ -114,6 +144,7 @@ public AnimComposer getAnimComposer() { public SkinningControl getSkinningControl() { return skin; } + /** * Returns true if this mask is checking upper layers for joint use. * @return @@ -126,16 +157,13 @@ public boolean isCheckUpperLayers() { public boolean contains(Object target) { return simpleContains(target) && (!checkUpperLayers || !isAffectedByUpperLayers(target)); } + private boolean simpleContains(Object target) { return super.contains(target); } + private boolean isAffectedByUpperLayers(Object target) { boolean higher = false; - /** - * ... Since AnimComposer does not provide a Collection that - * has a decending iterator, we will just have to skip over - * a bunch of lower layers before we actually need to do anything. - */ for (String name : anim.getLayerNames()) { if (name.equals(layer)) { higher = true; @@ -169,6 +197,7 @@ else if (lyr.getMask().contains(target)) { public static AlertArmatureMask all(String layer, Spatial spatial) { return new AlertArmatureMask(layer, spatial).addAll(); } + /** * Creates an {@code AlertArmatureMask} for all joints. * @param layer From 83c95e504b8d043e6d0f96f0ccd046d2e3429b1c Mon Sep 17 00:00:00 2001 From: codex <103840984+codex128@users.noreply.github.com> Date: Sat, 20 Jan 2024 16:39:33 -0500 Subject: [PATCH 06/37] updated javadoc --- .../java/com/jme3/anim/AlertArmatureMask.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java index bc797599e9..0af9f13779 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java +++ b/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java @@ -34,10 +34,8 @@ import com.jme3.scene.Spatial; /** - * Extension of {@link ArmatureMask}. - * - *
Provides a feature which checks higher layers for joint use before it - * approves the layer to use a joint. + * Mask that excludes joints from participating in the layer + * if a higher layer is using those joints in an animation. * * @author codex */ @@ -49,7 +47,7 @@ public class AlertArmatureMask extends ArmatureMask { private boolean checkUpperLayers = true; /** - * @param layer The layer this mask is targeted for. It is extremely important + * @param layer The layer this mask is targeted for. It is important * that this match the name of the layer this mask is (or will be) part of. You * can use {@link makeLayer} to ensure this. * @param spatial Spatial containing necessary controls ({@link AnimComposer} and {@link SkinningControl}) @@ -60,6 +58,13 @@ public AlertArmatureMask(String layer, Spatial spatial) { anim = spatial.getControl(AnimComposer.class); skin = spatial.getControl(SkinningControl.class); } + /** + * @param layer The layer this mask is targeted for. It is important + * that this match the name of the layer this mask is (or will be) part of. You + * can use {@link makeLayer} to ensure this. + * @param anim anim composer this mask is assigned to + * @param skin skinning control complimenting the anim composer. + */ public AlertArmatureMask(String layer, AnimComposer anim, SkinningControl skin) { super(); this.layer = layer; @@ -68,7 +73,7 @@ public AlertArmatureMask(String layer, AnimComposer anim, SkinningControl skin) } /** - * Makes a layer for this mask. + * Makes a layer from this mask. */ public void makeLayer() { anim.makeLayer(layer, this); @@ -76,7 +81,7 @@ public void makeLayer() { /** * Adds all joints to this mask. - * @return + * @return this.instance */ public AlertArmatureMask addAll() { for (Joint j : skin.getArmature().getJointList()) { @@ -88,7 +93,7 @@ public AlertArmatureMask addAll() { /** * Adds the given joint and all its children to this mask. * @param joint - * @return + * @return this instance */ public AlertArmatureMask addFromJoint(String joint) { super.addFromJoint(skin.getArmature(), joint); @@ -98,7 +103,7 @@ public AlertArmatureMask addFromJoint(String joint) { /** * Adds the given joints to this mask. * @param joints - * @return + * @return this instance */ public AlertArmatureMask addJoints(String... joints) { super.addBones(skin.getArmature(), joints); @@ -111,7 +116,7 @@ public AlertArmatureMask addJoints(String... joints) { *
Not checking is more efficient, but checking can avoid some
* interpolation issues between layers. Default=true
* @param check
- * @return
+ * @return this instance
*/
public AlertArmatureMask setCheckUpperLayers(boolean check) {
checkUpperLayers = check;
@@ -131,7 +136,7 @@ public String getTargetLayer() {
/**
* Get the {@link AnimComposer} this mask is for.
- * @return
+ * @return anim composer
*/
public AnimComposer getAnimComposer() {
return anim;
@@ -139,7 +144,7 @@ public AnimComposer getAnimComposer() {
/**
* Get the {@link SkinningControl} this mask is for.
- * @return
+ * @return skinning control
*/
public SkinningControl getSkinningControl() {
return skin;
@@ -190,9 +195,9 @@ else if (lyr.getMask().contains(target)) {
/**
* Creates an {@code AlertArmatureMask} for all joints.
- * @param layer
- * @param spatial
- * @return
+ * @param layer layer the returned mask is, or will be, be assigned to
+ * @param spatial spatial containing anim composer and skinning control
+ * @return new mask
*/
public static AlertArmatureMask all(String layer, Spatial spatial) {
return new AlertArmatureMask(layer, spatial).addAll();
@@ -200,10 +205,10 @@ public static AlertArmatureMask all(String layer, Spatial spatial) {
/**
* Creates an {@code AlertArmatureMask} for all joints.
- * @param layer
- * @param anim
- * @param skin
- * @return
+ * @param layer layer the returned mask is, or will be, assigned to
+ * @param anim anim composer
+ * @param skin skinning control
+ * @return new mask
*/
public static AlertArmatureMask all(String layer, AnimComposer anim, SkinningControl skin) {
return new AlertArmatureMask(layer, anim, skin).addAll();
From 90e6cd81feed8aa487998f23199f8f67a3cc51ed Mon Sep 17 00:00:00 2001
From: codex <103840984+codex128@users.noreply.github.com>
Date: Sun, 21 Jan 2024 15:48:49 -0500
Subject: [PATCH 07/37] renamed mask
---
...ask.java => SingleLayerInfluenceMask.java} | 30 +++++++++----------
1 file changed, 15 insertions(+), 15 deletions(-)
rename jme3-core/src/main/java/com/jme3/anim/{AlertArmatureMask.java => SingleLayerInfluenceMask.java} (85%)
diff --git a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java b/jme3-core/src/main/java/com/jme3/anim/SingleLayerInfluenceMask.java
similarity index 85%
rename from jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java
rename to jme3-core/src/main/java/com/jme3/anim/SingleLayerInfluenceMask.java
index 0af9f13779..935cb99abd 100644
--- a/jme3-core/src/main/java/com/jme3/anim/AlertArmatureMask.java
+++ b/jme3-core/src/main/java/com/jme3/anim/SingleLayerInfluenceMask.java
@@ -39,7 +39,7 @@
*
* @author codex
*/
-public class AlertArmatureMask extends ArmatureMask {
+public class SingleLayerInfluenceMask extends ArmatureMask {
private final String layer;
private final AnimComposer anim;
@@ -52,7 +52,7 @@ public class AlertArmatureMask extends ArmatureMask {
* can use {@link makeLayer} to ensure this.
* @param spatial Spatial containing necessary controls ({@link AnimComposer} and {@link SkinningControl})
*/
- public AlertArmatureMask(String layer, Spatial spatial) {
+ public SingleLayerInfluenceMask(String layer, Spatial spatial) {
super();
this.layer = layer;
anim = spatial.getControl(AnimComposer.class);
@@ -65,7 +65,7 @@ public AlertArmatureMask(String layer, Spatial spatial) {
* @param anim anim composer this mask is assigned to
* @param skin skinning control complimenting the anim composer.
*/
- public AlertArmatureMask(String layer, AnimComposer anim, SkinningControl skin) {
+ public SingleLayerInfluenceMask(String layer, AnimComposer anim, SkinningControl skin) {
super();
this.layer = layer;
this.anim = anim;
@@ -83,7 +83,7 @@ public void makeLayer() {
* Adds all joints to this mask.
* @return this.instance
*/
- public AlertArmatureMask addAll() {
+ public SingleLayerInfluenceMask addAll() {
for (Joint j : skin.getArmature().getJointList()) {
super.addBones(skin.getArmature(), j.getName());
}
@@ -95,7 +95,7 @@ public AlertArmatureMask addAll() {
* @param joint
* @return this instance
*/
- public AlertArmatureMask addFromJoint(String joint) {
+ public SingleLayerInfluenceMask addFromJoint(String joint) {
super.addFromJoint(skin.getArmature(), joint);
return this;
}
@@ -105,7 +105,7 @@ public AlertArmatureMask addFromJoint(String joint) {
* @param joints
* @return this instance
*/
- public AlertArmatureMask addJoints(String... joints) {
+ public SingleLayerInfluenceMask addJoints(String... joints) {
super.addBones(skin.getArmature(), joints);
return this;
}
@@ -118,7 +118,7 @@ public AlertArmatureMask addJoints(String... joints) {
* @param check
* @return this instance
*/
- public AlertArmatureMask setCheckUpperLayers(boolean check) {
+ public SingleLayerInfluenceMask setCheckUpperLayers(boolean check) {
checkUpperLayers = check;
return this;
}
@@ -180,9 +180,9 @@ private boolean isAffectedByUpperLayers(Object target) {
AnimLayer lyr = anim.getLayer(name);
// if there is no action playing, no joints are used, so we can skip
if (lyr.getCurrentAction() == null) continue;
- if (lyr.getMask() instanceof AlertArmatureMask) {
+ if (lyr.getMask() instanceof SingleLayerInfluenceMask) {
// dodge some needless recursion by calling a simpler method
- if (((AlertArmatureMask)lyr.getMask()).simpleContains(target)) {
+ if (((SingleLayerInfluenceMask)lyr.getMask()).simpleContains(target)) {
return true;
}
}
@@ -194,24 +194,24 @@ else if (lyr.getMask().contains(target)) {
}
/**
- * Creates an {@code AlertArmatureMask} for all joints.
+ * Creates an {@code SingleLayerInfluenceMask} for all joints.
* @param layer layer the returned mask is, or will be, be assigned to
* @param spatial spatial containing anim composer and skinning control
* @return new mask
*/
- public static AlertArmatureMask all(String layer, Spatial spatial) {
- return new AlertArmatureMask(layer, spatial).addAll();
+ public static SingleLayerInfluenceMask all(String layer, Spatial spatial) {
+ return new SingleLayerInfluenceMask(layer, spatial).addAll();
}
/**
- * Creates an {@code AlertArmatureMask} for all joints.
+ * Creates an {@code SingleLayerInfluenceMask} for all joints.
* @param layer layer the returned mask is, or will be, assigned to
* @param anim anim composer
* @param skin skinning control
* @return new mask
*/
- public static AlertArmatureMask all(String layer, AnimComposer anim, SkinningControl skin) {
- return new AlertArmatureMask(layer, anim, skin).addAll();
+ public static SingleLayerInfluenceMask all(String layer, AnimComposer anim, SkinningControl skin) {
+ return new SingleLayerInfluenceMask(layer, anim, skin).addAll();
}
}
From 0c2d187fda2757bac3722abaf8ee1c01ee7e94fd Mon Sep 17 00:00:00 2001
From: codex <103840984+codex128@users.noreply.github.com>
Date: Mon, 23 Jun 2025 23:07:35 -0400
Subject: [PATCH 08/37] create vulkan context and prototyped vulkan instance
creation in a test class
---
gradle/libs.versions.toml | 1 +
jme3-core/build.gradle | 49 ++
.../jme3/renderer/vulkan/VulkanRenderer.java | 10 +
.../com/jme3/renderer/vulkan/VulkanUtils.java | 113 +++++
.../main/java/com/jme3/system/JmeContext.java | 19 +-
jme3-examples/build.gradle | 4 +-
.../main/java/jme3test/vulkan/VulkanTest.java | 215 +++++++++
jme3-lwjgl3/build.gradle | 1 +
.../com/jme3/input/lwjgl/GlfwKeyInput.java | 7 +-
.../com/jme3/input/lwjgl/GlfwMouseInput.java | 8 +-
.../main/java/com/jme3/system/GlfwWindow.java | 17 +
.../com/jme3/system/{lwjgl => }/Sync.java | 4 +-
.../{lwjgl => }/WindowSizeListener.java | 4 +-
.../com/jme3/system/lwjgl/LwjglWindow.java | 14 +-
.../jme3/system/vulkan/DeviceEvaluator.java | 11 +
.../system/vulkan/LwjglVulkanContext.java | 455 ++++++++++++++++++
16 files changed, 911 insertions(+), 21 deletions(-)
create mode 100644 jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanRenderer.java
create mode 100644 jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanUtils.java
create mode 100644 jme3-examples/src/main/java/jme3test/vulkan/VulkanTest.java
create mode 100644 jme3-lwjgl3/src/main/java/com/jme3/system/GlfwWindow.java
rename jme3-lwjgl3/src/main/java/com/jme3/system/{lwjgl => }/Sync.java (99%)
rename jme3-lwjgl3/src/main/java/com/jme3/system/{lwjgl => }/WindowSizeListener.java (97%)
create mode 100644 jme3-lwjgl3/src/main/java/com/jme3/system/vulkan/DeviceEvaluator.java
create mode 100644 jme3-lwjgl3/src/main/java/com/jme3/system/vulkan/LwjglVulkanContext.java
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 6b56daa8a7..fabebdcc8a 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -34,6 +34,7 @@ lwjgl3-opencl = { module = "org.lwjgl:lwjgl-opencl", version.ref = "lwjgl3"
lwjgl3-opengl = { module = "org.lwjgl:lwjgl-opengl", version.ref = "lwjgl3" }
lwjgl3-openvr = { module = "org.lwjgl:lwjgl-openvr", version.ref = "lwjgl3" }
lwjgl3-ovr = { module = "org.lwjgl:lwjgl-ovr", version.ref = "lwjgl3" }
+lwjgl3-vulkan = { module = "org.lwjgl:lwjgl-vulkan", version.ref = "lwjgl3" }
mokito-core = "org.mockito:mockito-core:3.12.4"
diff --git a/jme3-core/build.gradle b/jme3-core/build.gradle
index 58ac362921..b741fc18cc 100644
--- a/jme3-core/build.gradle
+++ b/jme3-core/build.gradle
@@ -19,6 +19,55 @@ dependencies {
testRuntimeOnly project(':jme3-testdata')
testImplementation project(':jme3-desktop')
testRuntimeOnly project(':jme3-plugins')
+
+ // Use LWJGL3 directly in core. This destroys LWJGL2 and JOGL compatibility.
+ api (libs.lwjgl3.awt) {
+ exclude group: 'org.lwjgl', module: 'lwjgl'
+ }
+ api libs.lwjgl3.base
+ api libs.lwjgl3.glfw
+ api libs.lwjgl3.jawt
+ api libs.lwjgl3.jemalloc
+ api libs.lwjgl3.openal
+ api libs.lwjgl3.opencl
+ api libs.lwjgl3.opengl
+ api libs.lwjgl3.vulkan
+ runtimeOnly(variantOf(libs.lwjgl3.base){ classifier('natives-windows') })
+ runtimeOnly(variantOf(libs.lwjgl3.base){ classifier('natives-windows-x86') })
+ runtimeOnly(variantOf(libs.lwjgl3.base){ classifier('natives-linux') })
+ runtimeOnly(variantOf(libs.lwjgl3.base){ classifier('natives-linux-arm32') })
+ runtimeOnly(variantOf(libs.lwjgl3.base){ classifier('natives-linux-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.base){ classifier('natives-macos') })
+ runtimeOnly(variantOf(libs.lwjgl3.base){ classifier('natives-macos-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.glfw){ classifier('natives-windows') })
+ runtimeOnly(variantOf(libs.lwjgl3.glfw){ classifier('natives-windows-x86') })
+ runtimeOnly(variantOf(libs.lwjgl3.glfw){ classifier('natives-linux') })
+ runtimeOnly(variantOf(libs.lwjgl3.glfw){ classifier('natives-linux-arm32') })
+ runtimeOnly(variantOf(libs.lwjgl3.glfw){ classifier('natives-linux-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.glfw){ classifier('natives-macos') })
+ runtimeOnly(variantOf(libs.lwjgl3.glfw){ classifier('natives-macos-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.jemalloc){ classifier('natives-windows') })
+ runtimeOnly(variantOf(libs.lwjgl3.jemalloc){ classifier('natives-windows-x86') })
+ runtimeOnly(variantOf(libs.lwjgl3.jemalloc){ classifier('natives-linux') })
+ runtimeOnly(variantOf(libs.lwjgl3.jemalloc){ classifier('natives-linux-arm32') })
+ runtimeOnly(variantOf(libs.lwjgl3.jemalloc){ classifier('natives-linux-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.jemalloc){ classifier('natives-macos') })
+ runtimeOnly(variantOf(libs.lwjgl3.jemalloc){ classifier('natives-macos-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.opengl){ classifier('natives-windows') })
+ runtimeOnly(variantOf(libs.lwjgl3.opengl){ classifier('natives-windows-x86') })
+ runtimeOnly(variantOf(libs.lwjgl3.opengl){ classifier('natives-linux') })
+ runtimeOnly(variantOf(libs.lwjgl3.opengl){ classifier('natives-linux-arm32') })
+ runtimeOnly(variantOf(libs.lwjgl3.opengl){ classifier('natives-linux-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.opengl){ classifier('natives-macos') })
+ runtimeOnly(variantOf(libs.lwjgl3.opengl){ classifier('natives-macos-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.openal){ classifier('natives-windows') })
+ runtimeOnly(variantOf(libs.lwjgl3.openal){ classifier('natives-windows-x86') })
+ runtimeOnly(variantOf(libs.lwjgl3.openal){ classifier('natives-linux') })
+ runtimeOnly(variantOf(libs.lwjgl3.openal){ classifier('natives-linux-arm32') })
+ runtimeOnly(variantOf(libs.lwjgl3.openal){ classifier('natives-linux-arm64') })
+ runtimeOnly(variantOf(libs.lwjgl3.openal){ classifier('natives-macos') })
+ runtimeOnly(variantOf(libs.lwjgl3.openal){ classifier('natives-macos-arm64') })
+
}
task updateVersionPropertiesFile {
diff --git a/jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanRenderer.java
new file mode 100644
index 0000000000..a41424268c
--- /dev/null
+++ b/jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanRenderer.java
@@ -0,0 +1,10 @@
+package com.jme3.renderer.vulkan;
+
+import com.jme3.system.NullRenderer;
+
+/**
+ * Temporary placeholder.
+ */
+public class VulkanRenderer extends NullRenderer {
+
+}
diff --git a/jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanUtils.java b/jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanUtils.java
new file mode 100644
index 0000000000..e3992ac3a3
--- /dev/null
+++ b/jme3-core/src/main/java/com/jme3/renderer/vulkan/VulkanUtils.java
@@ -0,0 +1,113 @@
+package com.jme3.renderer.vulkan;
+
+import org.lwjgl.PointerBuffer;
+import org.lwjgl.system.MemoryStack;
+import org.lwjgl.system.MemoryUtil;
+import org.lwjgl.vulkan.VkInstance;
+
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.function.*;
+import java.util.stream.Stream;
+
+import static org.lwjgl.vulkan.VK10.*;
+
+public class VulkanUtils {
+
+ public static void check(int vulkanCode, String message) {
+ if (vulkanCode != VK_SUCCESS) {
+ throw new RuntimeException(message);
+ }
+ }
+
+ public static