Skip to content

Commit

Permalink
CustomEllipsoid: add the getHalfExtents() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Mar 2, 2024
1 parent 2701f4a commit e900e38
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import java.util.logging.Logger;
import jme3utilities.Validate;
import jme3utilities.math.MyMath;
import jme3utilities.math.MyVector3f;

/**
* A collision shape for an axis-aligned ellipsoid.
Expand Down Expand Up @@ -150,6 +151,29 @@ public CustomEllipsoid(Vector3f halfExtents, float inertiaFactor) {
setScale(scale);
}
// *************************************************************************
// new methods exposed

/**
* Copy the half extents of the ellipsoid.
*
* @param storeResult storage for the result (modified if not null)
* @return the unscaled half extent for each local axis (either storeResult
* or a new vector, not null, all components >0)
*/
public Vector3f getHalfExtents(Vector3f storeResult) {
assert MyVector3f.isAllPositive(unscaledHe) : unscaledHe;

Vector3f result;
if (storeResult == null) {
result = unscaledHe.clone();
} else {
result = storeResult.set(unscaledHe);
}

return result;

}
// *************************************************************************
// CustomConvexShape methods

/**
Expand Down

0 comments on commit e900e38

Please sign in to comment.