From 693c3438638a1cbbd3c5b66e4b8a5630fdd1532d Mon Sep 17 00:00:00 2001 From: Pedro Henrique Date: Sun, 18 Dec 2016 17:28:42 -0300 Subject: [PATCH] Fix getSurfacePoints method in model implementations --- src/tracer/model/Sphere.java | 2 +- src/tracer/model/Triangle.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tracer/model/Sphere.java b/src/tracer/model/Sphere.java index 41ca236..c3fa3f2 100644 --- a/src/tracer/model/Sphere.java +++ b/src/tracer/model/Sphere.java @@ -117,7 +117,7 @@ public Vector3 getCenter() { public Vector3[] getSurfacePoints(int count) { Vector3[] surfacePoints = new Vector3[count]; for (int i = 0; i < count; i++) { - surfacePoints[i] = this.surfacePoints[TTRand.range(0, count)]; + surfacePoints[i] = this.surfacePoints[TTRand.range(0, this.surfacePoints.length - 1)]; } return surfacePoints; } diff --git a/src/tracer/model/Triangle.java b/src/tracer/model/Triangle.java index b72133e..b1d5828 100644 --- a/src/tracer/model/Triangle.java +++ b/src/tracer/model/Triangle.java @@ -130,7 +130,7 @@ public Vector3 getCenter() { public Vector3[] getSurfacePoints(int count) { Vector3[] surfacePoints = new Vector3[count]; for (int i = 0; i < count; i++) { - surfacePoints[i] = surfacePoints[TTRand.range(0, count)]; + surfacePoints[i] = this.surfacePoints[TTRand.range(0, this.surfacePoints.length - 1)]; } return surfacePoints; }