I have the following code which works as expected:
bool result=false;
for(int i=0;i<n;i++)
{
if(face[i].intersect(*coordinates, org, dir))
{
result = true;
}
}
return result;
But this one has a different behavior (the value pointed to by coordinates
is different)
bool result=false;
for(int i=0;i<n;i++)
{
result = result || faceList[i].intersect(*coordinates, org, dir, triangle);
}
return result;
What's the reason for this? Is the expression after ||
never evaluated if the one before is true? I thought this optimization was allowed only in an if
statement.