Skip to content

Commit efb97a8

Browse files
committed
preserve backward compatibility
1 parent f3307e9 commit efb97a8

File tree

1 file changed

+75
-6
lines changed

1 file changed

+75
-6
lines changed

jme3-core/src/main/java/com/jme3/audio/Listener.java

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ public class Listener {
4747
private float volume = 1f;
4848
private AudioRenderer renderer;
4949

50-
private final Vector3f left = new Vector3f();
51-
private final Vector3f up = new Vector3f();
52-
private final Vector3f direction = new Vector3f();
5350

5451
/**
5552
* Constructs a new {@code Listener} with default parameters.
@@ -110,6 +107,17 @@ public Vector3f getLocation() {
110107
return location;
111108
}
112109

110+
/**
111+
* Gets the current location of the listener in world space.
112+
*
113+
* @param store The vector to store the result in.
114+
* @return The listener's location as a {@link Vector3f}.
115+
*/
116+
public Vector3f getLocation(Vector3f store) {
117+
if (store == null) store = new Vector3f();
118+
return store.set(location);
119+
}
120+
113121
/**
114122
* Gets the current rotation of the listener in world space.
115123
*
@@ -119,6 +127,17 @@ public Quaternion getRotation() {
119127
return rotation;
120128
}
121129

130+
/**
131+
* Gets the current rotation of the listener in world space.
132+
*
133+
* @param store The quaternion to store the result in.
134+
* @return The listener's rotation as a {@link Quaternion}.
135+
*/
136+
public Quaternion getRotation(Quaternion store) {
137+
if (store == null) store = new Quaternion();
138+
return store.set(rotation);
139+
}
140+
122141
/**
123142
* Gets the current velocity of the listener.
124143
* This is used for Doppler effect calculations.
@@ -129,31 +148,81 @@ public Vector3f getVelocity() {
129148
return velocity;
130149
}
131150

151+
/**
152+
* Gets the current velocity of the listener.
153+
*
154+
* @param store The vector to store the result in.
155+
* @return The listener's velocity as a {@link Vector3f}.
156+
*/
157+
public Vector3f getVelocity(Vector3f store) {
158+
if (store == null) store = new Vector3f();
159+
return store.set(velocity);
160+
}
161+
132162
/**
133163
* Gets the left direction vector of the listener.
164+
* This vector is derived from the listener's rotation.
134165
*
135166
* @return The listener's left direction as a {@link Vector3f}.
136167
*/
137168
public Vector3f getLeft() {
138-
return rotation.getRotationColumn(0, left);
169+
return rotation.getRotationColumn(0);
170+
}
171+
172+
173+
/**
174+
* Gets the left direction vector of the listener. This vector is derived from the listener's rotation.
175+
*
176+
* @param store The vector to store the result in.
177+
* @return The listener's left direction as a {@link Vector3f}.
178+
*/
179+
public Vector3f getLeft(Vector3f store) {
180+
if (store == null) store = new Vector3f();
181+
return rotation.getRotationColumn(0, store);
139182
}
140183

141184
/**
142185
* Gets the up direction vector of the listener.
186+
* This vector is derived from the listener's rotation.
143187
*
144188
* @return The listener's up direction as a {@link Vector3f}.
145189
*/
146190
public Vector3f getUp() {
147-
return rotation.getRotationColumn(1, up);
191+
return rotation.getRotationColumn(1);
192+
}
193+
194+
/**
195+
* Gets the up direction vector of the listener.
196+
* This vector is derived from the listener's rotation.
197+
*
198+
* @param store The vector to store the result in.
199+
* @return The listener's up direction as a {@link Vector3f}.
200+
*/
201+
public Vector3f getUp(Vector3f store) {
202+
if (store == null) store = new Vector3f();
203+
return rotation.getRotationColumn(1, store);
148204
}
149205

150206
/**
151207
* Gets the forward direction vector of the listener.
208+
* This vector is derived from the listener's rotation.
152209
*
153210
* @return The listener's forward direction.
154211
*/
155212
public Vector3f getDirection() {
156-
return rotation.getRotationColumn(2, direction);
213+
return rotation.getRotationColumn(2);
214+
}
215+
216+
/**
217+
* Gets the forward direction vector of the listener.
218+
* This vector is derived from the listener's rotation.
219+
*
220+
* @param store The vector to store the result in.
221+
* @return The listener's forward direction.
222+
*/
223+
public Vector3f getDirection(Vector3f store) {
224+
if (store == null) store = new Vector3f();
225+
return rotation.getRotationColumn(2, store);
157226
}
158227

159228
/**

0 commit comments

Comments
 (0)