Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix] More correct way to fix camera glitching
In commit 0aab576 we have attempts to fix camera glitching when one of effectors finishes working. The root of glitches is effector's deletion in CCameraManager::ProcessCameraEffector. Cycle in CCameraManager::UpdateCamEffectors uses reverse iterator and doesn't expect that entry in the list would be removed. Due to specific behavior of reverse iterator it really points to the next element relative to element which it dereferenced to. So, when ProcessCameraEffector deletes currently dereferenced element, iterator automatically starts point to element before deleted one. But the UpdateCamEffectors doesn't know about it, and cycle changes iterator on next iteration. So, processing of one camera effect would be skipped in this moment. Changes in 0aab576 don't seems to be the best solution, because 1) vector is less suitable for situations where we are often want to add or remove random elements 2) Deletion of current effector in ProcessCameraEffector seems to be not safe. For example, we could have CCameraManager's childs with overridden ProcessCameraEffector method. They could be deadly surprised if pointer to current effector would start pointing to non-existent element. So, this commit: 1) Reverts changes from 0aab576 2) Removes effector's deletion from CCameraManager::ProcessCameraEffector; now the method returns false if it should be deleted, or true otherwise 3) Adds code for removing 'old' effectors to UpdateCamEffectors method.
- Loading branch information