X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicle.cpp;h=cb776f413daacb20f82889076aeab17e451cc842;hb=c52c0e591be55cb2c7251689c69c642e3cb3601c;hp=2ad716600f50a293ae07c1fa47be0e47fdd4268c;hpb=dd05e8ed55a9072daaf18e4c63c3b66e386ba7f4;p=r2c2.git diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index 2ad7166..cb776f4 100644 --- a/source/libr2c2/vehicle.cpp +++ b/source/libr2c2/vehicle.cpp @@ -33,6 +33,8 @@ Vehicle::Vehicle(Layout &l, const VehicleType &t): for(unsigned j=0; jaxles.size(); ++j) i->axles[j] = &axles[i->type->first_axle+j]; + update_rods(); + layout.add(*this); } @@ -173,7 +175,8 @@ void Vehicle::update_position(int sign) { OrientedPoint p = placement.get_point(); position = p.position; - position.z += layout.get_catalogue().get_rail_elevation(); + // TODO Move the z adjustment to VehiclePlacement + position.z += placement.get_position(VehiclePlacement::FRONT_AXLE)->get_type().get_appearance().get_rail_elevation(); rotation = p.rotation; tilt = p.tilt; @@ -245,7 +248,7 @@ void Vehicle::propagate_backward() void Vehicle::check_sensor(const TrackOffsetIter &t, unsigned &sensor, bool release) { - unsigned s = t->get_sensor_id(); + unsigned s = t->get_sensor_address(); if(s!=sensor) { unsigned old = sensor; @@ -353,6 +356,14 @@ int Vehicle::get_link_slot(const Object &other) const return -1; } +bool Vehicle::collide_ray(const Ray &ray, float *d) const +{ + if(is_placed()) + return Object::collide_ray(ray, d); + else + return false; +} + Vehicle::Axle::Axle(const VehicleType::Axle &t): type(&t)