add Range to optimize Shape#hit
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package eu.jonahbauer.raytracing.shape;
|
||||
|
||||
import eu.jonahbauer.raytracing.math.Range;
|
||||
import eu.jonahbauer.raytracing.math.Ray;
|
||||
import eu.jonahbauer.raytracing.math.Vec3;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -18,7 +19,7 @@ class SphereTest {
|
||||
var direction = new Vec3(-1, -1, -1);
|
||||
var ray = new Ray(origin, direction);
|
||||
|
||||
var result = sphere.hit(ray);
|
||||
var result = sphere.hit(ray, Range.NON_NEGATIVE);
|
||||
assertFalse(result.isEmpty());
|
||||
assertEquals(center.plus(new Vec3(1, 1, 1).unit().times(radius)), ray.at(result.get().t()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user