package eu.jonahbauer.raytracing.scene;

import eu.jonahbauer.raytracing.math.Vec3;
import eu.jonahbauer.raytracing.render.material.Material;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public record HitResult(
        double t,
        @NotNull Vec3 position,
        @NotNull Vec3 normal,
        @NotNull Material material,
        boolean frontFace
) implements Comparable<HitResult> {
    public HitResult {
        Objects.requireNonNull(position, "position");
        normal = normal.unit();
    }

    @Override
    public int compareTo(@NotNull HitResult o) {
        return Double.compare(t, o.t);
    }
}
