I've solved the problem I was having with my vector. It took a lot of searching, but my suspicions were confirmed, iterators on vectors are usually killed by a push_back to the same vector. This is because the vector often has to resize the amount of memory its allocating on a push_back which causes the iterator to reset. The solution was to reserve enough space for the vector beforehand so that the push didn't trigger a resize. Its working very well now and I have clouds of dust being thrown up be the vehicles. I'll use the same method to have spray shooting up when the vehicle enters water. I just need to fix the code to determine terrain type now.
|