Skip to content

Commit

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

/**
Expand Down Expand Up @@ -100,6 +101,7 @@ protected CustomEllipsoid() {
*/
public CustomEllipsoid(float radius) {
super(radius, radius, radius);
Validate.positive(radius, "radius");

this.unscaledHe = new Vector3f(radius, radius, radius);
this.inertiaFactor = 0.2f;
Expand All @@ -122,6 +124,10 @@ public CustomEllipsoid(float xHalfExtent, float yHalfExtent,
float zHalfExtent, float inertiaFactor) {
super(xHalfExtent, yHalfExtent, zHalfExtent);

Validate.positive(xHalfExtent, "X half extent");
Validate.positive(yHalfExtent, "Y half extent");
Validate.positive(zHalfExtent, "Z half extent");

this.unscaledHe = new Vector3f(xHalfExtent, yHalfExtent, zHalfExtent);
this.inertiaFactor = inertiaFactor;
setScale(scale);
Expand All @@ -137,6 +143,7 @@ public CustomEllipsoid(float xHalfExtent, float yHalfExtent,
*/
public CustomEllipsoid(Vector3f halfExtents, float inertiaFactor) {
super(halfExtents);
Validate.positive(halfExtents, "half extents");

this.unscaledHe = halfExtents.clone();
this.inertiaFactor = inertiaFactor;
Expand Down

0 comments on commit 2701f4a

Please sign in to comment.