Simplify hit search as now the list is ordered.
This commit is contained in:
@@ -55,21 +55,12 @@ void Intersect::add(Intersection i)
|
|||||||
Intersection Intersect::hit()
|
Intersection Intersect::hit()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double minHit = DBL_MAX;
|
|
||||||
uint32_t curHit = -1;
|
|
||||||
for(i = 0; i < this->num; i++)
|
for(i = 0; i < this->num; i++)
|
||||||
{
|
{
|
||||||
if ((this->list[i]->t >= 0) && (this->list[i]->t < minHit))
|
if (this->list[i]->t >= 0)
|
||||||
{
|
return *this->list[i];
|
||||||
curHit = i;
|
|
||||||
minHit = this->list[i]->t;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curHit == -1)
|
return Intersection(0, nullptr);
|
||||||
{
|
|
||||||
return Intersection(0, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this->list[curHit];
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user