Hi everybody!
When I run my program I get this error (a runtime error):
"list iterator not dereferencable"
Here is the part from my code that doing the problem. The line with the comment sign ( // )
at the start is the cause of the error.
As you can see, box.points is not an empty list and there is no divide by 0.
Thanks
box.add(Vector(5,-5,0));
box.add(Vector(8,6,0));
box.add(Vector(-4,5,0));
box.add(Vector(-5,-7,0));
for(list<Vector>::iterator i = box.points.begin(); i!= box.points.end(); ++i)
{
float mRay = (lightpos.y - i->y) / (lightpos.x - i->x);
for(list<Vector>::iterator j = box.points.begin(), nextDot = box.points.begin(); j!= box.points.end(); ++j)
{
if(nextDot!=box.points.end())
{
//nextDot++;
}
if(j==box.points.end()) nextDot = box.points.begin();
float mBox = (nextDot->y - j->y) / (nextDot->x - j->x);
if(mRay!=mBox) lightrays.push_back(Ray(lightpos, Vector(i->x,i->y,i->z)));
}
}