Skip to content

Commit

Permalink
Geometry: add the copyLocation() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Aug 9, 2023
1 parent 272c020 commit 6903ae1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/src/main/java/com/github/stephengold/vsport/Geometry.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import org.joml.Matrix3fc;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.joml.Vector3fc;

/**
Expand Down Expand Up @@ -88,6 +89,18 @@ protected Geometry() {
// *************************************************************************
// new methods exposed

/**
* Return a copy of the location of the mesh origin.
*
* @param storeResult storage for the result (modified if not null)
* @return a location vector in world coordinates (either
* {@code storeResult} or a new vector null)
*/
public Vector3f copyLocation(Vector3f storeResult) {
Vector3f result = uniformValues.copyLocation(storeResult);
return result;
}

/**
* Return a copy of the mesh-to-world coordinate rotation.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ class NonGlobalUniformValues {
// *************************************************************************
// new methods exposed

/**
* Return a copy of the location of the mesh origin.
*
* @param storeResult storage for the result (modified if not null)
* @return a location vector in world coordinates (either
* {@code storeResult} or a new vector, not null)
*/
Vector3f copyLocation(Vector3f storeResult) {
if (storeResult == null) {
return new Vector3f(location);
} else {
return storeResult.set(location);
}
}

/**
* Return a copy of the mesh-to-world coordinate rotation.
*
Expand Down

0 comments on commit 6903ae1

Please sign in to comment.