Simplify hit search as now the list is ordered.

This commit is contained in:
Godzil
2020-02-20 01:40:50 +00:00
parent aa078f4d46
commit be6b472472

View File

@@ -55,21 +55,12 @@ void Intersect::add(Intersection i)
Intersection Intersect::hit()
{
int i;
double minHit = DBL_MAX;
uint32_t curHit = -1;
for(i = 0; i < this->num; i++)
{
if ((this->list[i]->t >= 0) && (this->list[i]->t < minHit))
{
curHit = i;
minHit = this->list[i]->t;
}
if (this->list[i]->t >= 0)
return *this->list[i];
}
if (curHit == -1)
{
return Intersection(0, nullptr);
}
return *this->list[curHit];
}