Skip to content
Merged
Changes from 1 commit
Commits
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
30 changes: 14 additions & 16 deletions jme3-core/src/main/java/com/jme3/audio/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@
*/
public class Listener {

private final Vector3f location;
private final Vector3f velocity;
private final Quaternion rotation;
private float volume = 1;
private final Vector3f location = new Vector3f();
private final Vector3f velocity = new Vector3f();
private final Quaternion rotation = new Quaternion();
private float volume = 1f;
private AudioRenderer renderer;

private final Vector3f left = new Vector3f();
private final Vector3f up = new Vector3f();
private final Vector3f direction = new Vector3f();

/**
* Constructs a new {@code Listener} with default parameters.
*/
public Listener() {
location = new Vector3f();
velocity = new Vector3f();
rotation = new Quaternion();
}

/**
Expand All @@ -62,9 +63,9 @@ public Listener() {
* @param source The {@code Listener} to copy the properties from.
*/
public Listener(Listener source) {
this.location = source.location.clone();
this.velocity = source.velocity.clone();
this.rotation = source.rotation.clone();
this.location.set(source.location);
this.velocity.set(source.velocity);
this.rotation.set(source.rotation);
this.volume = source.volume;
this.renderer = source.renderer; // Note: Renderer is also copied
}
Expand Down Expand Up @@ -130,32 +131,29 @@ public Vector3f getVelocity() {

/**
* Gets the left direction vector of the listener.
* This vector is derived from the listener's rotation.
*
* @return The listener's left direction as a {@link Vector3f}.
*/
public Vector3f getLeft() {
return rotation.getRotationColumn(0);
return rotation.getRotationColumn(0, left);
Comment thread
riccardobl marked this conversation as resolved.
Outdated
}

/**
* Gets the up direction vector of the listener.
* This vector is derived from the listener's rotation.
*
* @return The listener's up direction as a {@link Vector3f}.
*/
public Vector3f getUp() {
return rotation.getRotationColumn(1);
return rotation.getRotationColumn(1, up);
}

/**
* Gets the forward direction vector of the listener.
* This vector is derived from the listener's rotation.
*
* @return The listener's forward direction.
*/
public Vector3f getDirection() {
return rotation.getRotationColumn(2);
return rotation.getRotationColumn(2, direction);
}

/**
Expand Down