X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=antikythera;a=blobdiff_plain;f=src%2Fmachine.cc;fp=src%2Fmachine.cc;h=d6bb33800a03283f6df68190911cb843701d9159;hp=81aa6f6cfd4a0aa7c9337a215848379179a23599;hb=80bcc959131067cc774b85cc1f63e81d8b5a012a;hpb=566e3392b43649dc7015ea7b0954a0efd6727c10 diff --git a/src/machine.cc b/src/machine.cc index 81aa6f6..d6bb338 100644 --- a/src/machine.cc +++ b/src/machine.cc @@ -105,11 +105,14 @@ void Machine::calc_meshing() // fix the initial angles so that teeth mesh as best as possible // should work in one pass as long as the gear train is not impossible for(int i=0; iinit_angle = 0; + float rnd = gears[i]->angle + gears[i]->get_angular_pitch() / 2.0; + float snap = rnd - fmod(rnd, gears[i]->get_angular_pitch()); + gears[i]->set_angle(snap); + gears[i]->set_angular_offset(0); } for(int i=0; iinit_angle += correction * gears[j]->get_angular_pitch(); + float prev_offs = gears[j]->get_angular_offset(); + gears[j]->set_angular_offset(prev_offs + correction * gears[j]->get_angular_pitch()); } } } - - /* - for(int i=0; iinit_angle); - } - */ } void Machine::update_gear(int idx, float angle)