EMI: Compare the camera-space Z coordinates of actors instead of their Euclidean distance to the camera.
EMI: Get the sort order from the closest sector even if the current position is not contained within any sector.

This fixes Guybrush occasionally being visible through the buildings and foliage on Lucre island when walking at the edge of the walkable sectors. This happened because for positions at the edge of the walkable sector the method Sector::isPointInSector may not always return true.
EMI: Do not reset sort order when the set changes.

The original game doesn't reset the sort order. This fixes, for example, the voodoo anklet being visible through walls after leaving the jail set.
EMI: Only return a sector sort order if the nearest point on a sector is closer than 0.01 units.
EMI: Set sector sort order to 0 if the current sector does not specify a sort order.
EMI: Decrease the iterator position when a material is erased from the material list.
EMI: Increase MAX_SHADOWS from 5 to 8.
EMI: Reset color when drawing shadow planes.
GRIM/EMI: Fix word wrapping in the case when there are no spaces in the text.

This always caused a buffer overflow before.
Merge pull request #1026 from Akz-/emi-sortorder-fix

EMI: Sort order fixes
EMI: Refactor to use a matrix for the camera.
EMI: Implement Lua functions for getting camera rotation.
EMI: Free costumes once all chores have finished.
EMI: Return the first costume that has a model component in Actor::getCurrentCostume.
EMI: Do not reset the costume when a new wear chore is started. Fixes #878
EMI: Remove special treatment of wear chores which is no longer necessary.
EMI: Make Lua_V2::findCostume only return true if a costume is found.
EMI: Return playing chores of all costumes from GetActorChores.
EMI: Go through all costumes in IsActorChoring.
EMI: Push dumbshadow.cos to the back of the costume stack like any other costume.

The order of the costumes no longer matters. This also fixes a fairly common crash when saving the game.