Reinstate maximum steering angle (PATCH) - Printable Version +- Forums (https://www.vdrift.net/Forum) +-- Forum: Community (https://www.vdrift.net/Forum/forumdisplay.php?fid=3) +--- Forum: Bugs (https://www.vdrift.net/Forum/forumdisplay.php?fid=7) +--- Thread: Reinstate maximum steering angle (PATCH) (/showthread.php?tid=1139) Reinstate maximum steering angle (PATCH) - fudje - 06-26-2009 This has been missing for the entire "refactor" - and is really annoying (to me at least. Should be to others too). To reproduce, just drive any car on any track. All cars currently steer to 45Â°, which is both useless and unrealistic. Patch to fix is very small. I've tried to keep this to the current coding style (header seem to have a lot of implementation code in them - what's with that? It could be driving up compilation times, btw): Code:```Index: include/cardynamics.h =================================================================== --- include/cardynamics.h    (revision 2505) +++ include/cardynamics.h    (working copy) @@ -196,7 +196,8 @@     std::vector > brake;     std::vector > tire;     std::vector > aerodynamics; -     +    T maxangle; +     //set at load time     std::list > > mass_only_particles;     enum @@ -1416,9 +1417,6 @@     ///set the steering angle to "value", where 1.0 is maximum right lock and -1.0 is maximum left lock.     void SetSteering(const T value)     { -        //TODO: load in max steering angle -        T maxangle = 45.0; -                 T steerangle = value * maxangle; //steering angle in degrees                  //ackermann stuff @@ -1448,13 +1446,18 @@         wheel[FRONT_RIGHT].SetSteerAngle(right_wheel_angle);     }      -    //TODO: load in max steering angle     ///Get the maximum steering angle in degrees     T GetMaxSteeringAngle() const     { -        return 45.0; +        return maxangle;     }      +    ///Set the mavimum steering angle in degrees +    void SetMaxSteeringAngle(const T value){ +      maxangle = value; +    } + +         ///get the worldspace engine position     MATHVECTOR GetEnginePosition()     { Index: src/car.cpp =================================================================== --- src/car.cpp    (revision 2505) +++ src/car.cpp    (working copy) @@ -1068,6 +1068,15 @@         }     } +    //load the max steering angle +    { +        float maxangle = 45.0; +        if (!GetConfigfileParam(error_output, c, "steering.max-angle", maxangle)) +            return false; +         +        dynamics.SetMaxSteeringAngle(maxangle); +    } +     //load the driver     {         float mass;``` Compiled and Tested on Ubuntu Karmic with gcc 4.4.0 - The bits I've added should compile on any C++ compiler ever made though Cheers, fudje Re: Reinstate maximum steering angle (PATCH) - joevenzon - 06-26-2009 fudje Wrote:I've tried to keep this to the current coding style (header seem to have a lot of implementation code in them - what's with that? It could be driving up compilation times, btw) The cardynamics.h file defines a templated CARDYNAMICS class. The only reason I made it a template was so I could easily switch between floats and doubles as the primary "real" type, but this would have been much better served with a typedef instead of a template (woops, poor design on my part). As a result the implementation of the class is in the header since that's the easiest way to do template classes. Of course, there are fairly simple ways to separate out the implementation and header with template functions, and even better I could just refactor to use a typedef, but I haven't bothered yet. If you're interested in doing this let me know and I'll set you up with SVN access (the patch looks good and I'm applying it now). - joevenzon - 06-27-2009 OK, your patch is in R2506. Thanks! - fudje - 06-27-2009 Ah, of course, the templating. I don't really understand C++ templates enough to do anything much about it at this point (though I fear I am going to have to learn) - mostly what I know is they're much more hackish than in, say, Java or C#. You're very welcome to have the patch. Thanks for applying to SVN