for( int b = 0; b < insertions; b++ )
float pointA = *vIndex-1;
float pointC = *vIndex;
// calculate new point, inserted at vIndex
terrain.insert( vIndex, (pointA + pointC) / 2 );
Your pointer manipulation here is wrong. Unary * has a much higher precedence than -. This means that it gets the location pointed at first, then subtracts 1. So PointA = PointC-1, basically. That's why when you add them and divide by two, you'll get PointC-0.5.
What you want to do is replace *vIndex-1 with *(vIndex-1) so that the subtract is performed first.
Thanks, that explains that part. But now I'm getting complaints:
d:\Development\test\Main.cpp(42): error C2784: 'reverse_iterator<_RanIt>::difference_type std::operator -(const
std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument
for 'const std::reverse_iterator<_RanIt> &' from 'std::list<_Ty>::iterator'
It seems that my list doesn't like me using pointers in that way. Vectors would be fine with it, but I can't use them because of the iterator being invalidated when you make an insertion - for the first loop it's not a problem because I only need to insert once, but for the later loops I will be inserting multiple values.
I suppose I could get around this by doing multiple increments and decrements of the iterator to get it to the positions I want, but that comes across as a bit of a kludge and I'd rather avoid hacking my code around in that way.