From d1c8521d08a3166224b08eec197f755218dfa45b Mon Sep 17 00:00:00 2001 From: Wyatt Gillette Date: Fri, 20 Jun 2025 12:50:17 +0200 Subject: [PATCH 1/2] Update VertexBuffer.java --- .../src/main/java/com/jme3/scene/VertexBuffer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java b/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java index 8c0a388bb7..2e889998d1 100644 --- a/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java +++ b/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java @@ -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 @@ -57,7 +57,7 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable { /** * Type of buffer. Specifies the actual attribute it defines. */ - public static enum Type { + public enum Type { /** * Position of the vertex (3 floats) */ @@ -233,7 +233,7 @@ public static enum Type { * is used. This can determine if a vertex buffer is placed in VRAM * or held in video memory, but no guarantees are made- it's only a hint. */ - public static enum Usage { + public enum Usage { /** * Mesh data is sent once and very rarely updated. */ @@ -261,7 +261,7 @@ public static enum Usage { * For the {@link Format#Half} type, {@link ByteBuffer}s should * be used. */ - public static enum Format { + public enum Format { /** * Half precision floating point. 2 bytes, signed. */ @@ -1130,6 +1130,7 @@ public void write(JmeExporter ex) throws IOException { oc.write(offset, "offset", 0); oc.write(stride, "stride", 0); oc.write(instanceSpan, "instanceSpan", 0); + oc.write(name, "name", null); String dataName = "data" + format.name(); Buffer roData = getDataReadOnly(); @@ -1166,6 +1167,8 @@ public void read(JmeImporter im) throws IOException { offset = ic.readInt("offset", 0); stride = ic.readInt("stride", 0); instanceSpan = ic.readInt("instanceSpan", 0); + name = ic.readString("name", null); + componentsLength = components * format.getComponentSize(); String dataName = "data" + format.name(); From 0f8a309888c0ca1f15d9a408554814c4ebba1aed Mon Sep 17 00:00:00 2001 From: Wyatt Gillette Date: Fri, 20 Jun 2025 16:17:29 +0200 Subject: [PATCH 2/2] Update VertexBuffer: modify getName() method + javadoc --- .../main/java/com/jme3/scene/VertexBuffer.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java b/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java index 2e889998d1..ddb34f43ee 100644 --- a/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java +++ b/jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java @@ -1168,7 +1168,7 @@ public void read(JmeImporter im) throws IOException { stride = ic.readInt("stride", 0); instanceSpan = ic.readInt("instanceSpan", 0); name = ic.readString("name", null); - + componentsLength = components * format.getComponentSize(); String dataName = "data" + format.name(); @@ -1194,14 +1194,28 @@ public void read(JmeImporter im) throws IOException { } } + /** + * Returns the name of this `VertexBuffer`. If no name has been explicitly + * set, a default name is generated based on its class name and buffer type + * (e.g., "VertexBuffer(Position)"). + * + * @return The name of the `VertexBuffer`. + */ public String getName() { if (name == null) { - name = getClass().getSimpleName() + "(" + getBufferType().name() + ")"; + return String.format("%s(%s)", getClass().getSimpleName(), getBufferType().name()); } return name; } + /** + * Sets a custom name for this `VertexBuffer`. + * + * @param name The new name for the `VertexBuffer`. Can be null to revert + * to the default generated name. + */ public void setName(String name) { this.name = name; } + }