[WIP] Add physics calculations for vehicles. Not actually used anywhere yet.

Yes, I am rounding it up. This should be easy to change. The main reason
for having a minimum speed is that I wasn't sure how all possible vehicle
situations would work. What if you drive a heavy vehicle onto broken
terrain and become unable to drive it away from the terrain again? Having
realistic physics here might make the game very unfun. This was not a
problem with the old system since it didn't consider friction or terrain,
so you couldn't become stuck in the same way. I'll add a TODO to see if I
can remove the rounding up (or at least use a lower value) once the whole
vehicle physics rework is done, before I make a proper pull request. Due to
the way the other vehicle systems work (gas usage, traps under wheels,
movement system) it'll be easier to have 1 tile/turn as a minimum until
everything else is completed.


On Mon, Dec 29, 2014 at 8:32 PM, Coolthulhu <notifications@github.com>
wrote:

> In src/veh_physics.cpp
> <https://github.com/CleverRaven/Cataclysm-DDA/pull/10666#discussion-diff-22324914>
> :
>
> > +        if (  !((v_dir > 0.0) ^ (velocity_end < 0.0)) ) { /* XAND */
> > +            /* Don't go directly from forward to reverse */
> > +            kinetic_end = 0.0;
> > +            velocity_end = 0.0;
> > +        }
> > +        /* Update some other values as well now that we know speed etc */
> > +        velocity_average = (velocity_start + velocity_end) / 2;
> > +        engine_watt_average = newton_average * velocity_average;
> > +        distance_traveled = fabs(velocity_average * t); /* No negatives */
> > +        /* More closely match t to actual time taken, for use in next iteration */
> > +        t = t * TILE_SIZE_M / distance_traveled;
> > +        if( fabs(velocity_end) < 0.1 )
> > +            velocity_end = 0.0;
> > +        if( distance_traveled < 0.001 || t >= TURN_TIME_S || t <= 0.001 || velocity_end == 0.0 ) {
> > +            time_taken = TURN_TIME_S;
> > +            break; /* For gameplay purposes you can always travel 1 tile in a turn */
>
> I'm not sure if I get it, but I hope I just don't.
> 1 tile in a turn is (about?) 10 mph. Are you rounding up speed below 10
> mph to 10 mph?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/CleverRaven/Cataclysm-DDA/pull/10666/files#r22324914>.
>



-- 

 - Vidar