X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicle.cpp;h=b7355c6a6e2fab2bd73caaeafafd4881ce989b2d;hb=d3a7a9e9ad694d52ccca8b6038501772fdc1dfd5;hp=2c31ba19f189467ad07233dc0ff600e87fe6643e;hpb=f8a7788cee0261babfc4c804a58515aad6dfbc3d;p=r2c2.git diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index 2c31ba1..b7355c6 100644 --- a/source/libr2c2/vehicle.cpp +++ b/source/libr2c2/vehicle.cpp @@ -29,7 +29,7 @@ Vehicle::Vehicle(Layout &l, const VehicleType &t): front_sensor(0), back_sensor(0) { - axles.assign(type.get_axles().begin(), type.get_axles().end()); + axles.assign(type.get_fixed_axles().begin(), type.get_fixed_axles().end()); bogies.assign(type.get_bogies().begin(), type.get_bogies().end()); rods.assign(type.get_rods().begin(), type.get_rods().end()); @@ -125,6 +125,13 @@ void Vehicle::advance(float d) propagate_position(); } +const Vehicle::Axle &Vehicle::get_fixed_axle(unsigned i) const +{ + if(i>=axles.size()) + throw InvalidParameterValue("Axle index out of range"); + return axles[i]; +} + const Vehicle::Bogie &Vehicle::get_bogie(unsigned i) const { if(i>=bogies.size()) @@ -132,13 +139,6 @@ const Vehicle::Bogie &Vehicle::get_bogie(unsigned i) const return bogies[i]; } -const Vehicle::Axle &Vehicle::get_axle(unsigned i) const -{ - if(i>=axles.size()) - throw InvalidParameterValue("Axle index out of range"); - return axles[i]; -} - const Vehicle::Axle &Vehicle::get_bogie_axle(unsigned i, unsigned j) const { if(i>=bogies.size()) @@ -290,7 +290,7 @@ void Vehicle::update_rods() i->position = i->type->pivot_point; else if(i->type->pivot==VehicleType::Rod::AXLE) { - const Axle &axle = get_axle(i->type->pivot_index); + const Axle &axle = get_fixed_axle(i->type->pivot_index); float c = cos(axle.angle); float s = sin(axle.angle); const Vector &pp = i->type->pivot_point;