Skip to content

Commit c2371eb

Browse files
authored
Merge pull request #38 from K-Meech/bounding-box-fix
Avoid negative array size when drawing bounding boxes
2 parents 96826b5 + 7223cd2 commit c2371eb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/ij3d/shapes/BoundingBox.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,18 @@ private Appearance createAppearance(final Color3f color) {
198198

199199
private Geometry makeLine(final Point3f start, final Point3f end,
200200
final Color3f color, final float tickDistance, final float first,
201-
final float tickSize, final boolean noTicks)
201+
final float tickSize, boolean noTicks)
202202
{
203203
final float lineLength = start.distance(end);
204204
final int nTicks =
205205
(int) Math.floor((lineLength - first) / tickDistance) + 1;
206206

207+
// Avoid negative array size. This occurs when the (lineLength - first)
208+
// is negative.
209+
if (nTicks < 1) {
210+
noTicks = true;
211+
}
212+
207213
final int n = noTicks ? 2 : nTicks * 6 + 2;
208214

209215
final Point3f[] coords = new Point3f[n];

0 commit comments

Comments
 (0)