Use physics for all movement

At the moment, movements are handled in 4 different ways depending on the object type:

  • actors position is set by the physics simulation based on velocity, which depends on game mechanics
  • projectile are similar to actors, but simpler
  • objects position is set by game mechanics, in case of collision then the physics unstuck logic moves actors out of the way or get them stuck (#5856 (closed))
  • a hybrid system is used for doors: their position is set by mechanics but there is some collision detection afterwards. Actors may still get stuck inside the door (#5683 (closed))

Aforementioned bugs were closed because the unstuck logic manages to hide from the player the fact that the objects are pushed through the actors, nevertheless this is backward. Also there is no guarantee that it will work in slightly different setup (faster rotation, different geometry).

My plan is to handle all objects similarly as actors, that is the mechanics set a velocity, and the physics find a correct position. For projectile this is easy as most of the job was already done, this is mostly refactoring, for objects and doors it's a little bit more complex. I'll probably split in 3-4 MR. In the end, it would look like this :

class MWPhysics::Door 
{    
    /* ... */
    void setRotation(osg::Quat rotation);
    /* ... */
};  

class MWPhysics::MovementSolver
{
    /* ... */
    static move(Door& actor.....);
    /* ... */
};

World::rotateDoor(door)
{
   /*...*/
   rotateObject(door, physDoor->getSimulationResult()); // update world according to last physics run result
   update(door); // what's next?
   if (needRotate)
       physDoor->setRotation(rotation); // and one more round
   /*...*/
};

The benefits are:

  • short term: reliable handling of movement without relying on unstuck logic (which I personally consider a stop gap: we shouldn't be stuck in the first place). Also, we can easily handle situation which are now impossible to handle due to lack of collision detection, such as stopping the bar door when it collides with an actor below
  • longer term: potential for cool stuff. Now Morrowind's Laws of Physics are scattered in several not so obvious places (and are also very brittle), meaning that if we want to modify them for mods or other games, it gets hairy. Once this is done, objects behaviour will be defined in a few (I think 4) move() functions in MovementSolver, which is relatively easier to alter. There's still a long way before that, but we can start some baby steps.