Skip to content

Commit 4650463

Browse files
authored
Update ArmatureInterJointsWire.java
1 parent 367ea2d commit 4650463

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

jme3-core/src/main/java/com/jme3/scene/debug/custom/ArmatureInterJointsWire.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
package com.jme3.scene.debug.custom;
2-
31
/*
4-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2025 jMonkeyEngine
53
* All rights reserved.
64
*
75
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +29,7 @@
3129
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3230
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3331
*/
34-
32+
package com.jme3.scene.debug.custom;
3533

3634
import com.jme3.math.Vector3f;
3735
import com.jme3.scene.Mesh;
@@ -46,20 +44,38 @@
4644
* @author Marcin Roguski (Kaelthas)
4745
*/
4846
public class ArmatureInterJointsWire extends Mesh {
49-
private final Vector3f tmp = new Vector3f();
5047

48+
/**
49+
* A temporary {@link Vector3f} used for calculations to avoid object allocation.
50+
*/
51+
private final Vector3f tempVec = new Vector3f();
52+
53+
/**
54+
* For serialization only. Do not use.
55+
*/
56+
protected ArmatureInterJointsWire() {
57+
}
5158

59+
/**
60+
* Creates a new {@code ArmatureInterJointsWire} mesh.
61+
* The mesh will be set up to draw lines from the {@code start} vector to each of the {@code ends} vectors.
62+
*
63+
* @param start The starting point of the lines (e.g., the bone tail's position). Not null.
64+
* @param ends An array of ending points for the lines (e.g., the children's head positions). Not null.
65+
*/
5266
public ArmatureInterJointsWire(Vector3f start, Vector3f[] ends) {
5367
setMode(Mode.Lines);
5468
updateGeometry(start, ends);
5569
}
5670

5771
/**
58-
* For serialization only. Do not use.
72+
* Updates the geometry of this mesh based on the provided start and end points.
73+
* This method re-generates the position, texture coordinate, normal, and index buffers
74+
* for the mesh.
75+
*
76+
* @param start The new starting point for the lines. Not null.
77+
* @param ends An array of new ending points for the lines. Not null.
5978
*/
60-
protected ArmatureInterJointsWire() {
61-
}
62-
6379
protected void updateGeometry(Vector3f start, Vector3f[] ends) {
6480
float[] pos = new float[ends.length * 3 + 3];
6581
pos[0] = start.x;
@@ -78,7 +94,7 @@ protected void updateGeometry(Vector3f start, Vector3f[] ends) {
7894
texCoord[0] = 0;
7995
texCoord[1] = 0;
8096
for (int i = 0; i < ends.length * 2; i++) {
81-
texCoord[i + 2] = tmp.set(start).subtractLocal(ends[i / 2]).length();
97+
texCoord[i + 2] = tempVec.set(start).subtractLocal(ends[i / 2]).length();
8298
}
8399
setBuffer(Type.TexCoord, 2, texCoord);
84100

0 commit comments

Comments
 (0)