Browse Source

Fix mistakes in assignment of adjacent module IDs. Swap message buffers at the end of each Engine step.

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
9943d7b13a
2 changed files with 10 additions and 5 deletions
  1. +5
    -5
      src/app/RackWidget.cpp
  2. +5
    -0
      src/engine/Engine.cpp

+ 5
- 5
src/app/RackWidget.cpp View File

@@ -329,19 +329,19 @@ static void RackWidget_updateAdjacent(RackWidget *that) {


if (m == m2) if (m == m2)
continue; continue;
math::Vec p2 = m->box.pos.div(RACK_GRID_SIZE).round();
math::Vec p2 = m2->box.pos.div(RACK_GRID_SIZE).round();


// Check if m is to the right of m2
// Check if m is to the left of m2
if (pRight.isEqual(p2)) { if (pRight.isEqual(p2)) {
m->module->leftModuleId = m2->module->id;
m2->module->rightModuleId = m->module->id;
m->module->rightModuleId = m2->module->id;
m2->module->leftModuleId = m->module->id;
found = true; found = true;
break; break;
} }
} }


if (!found) { if (!found) {
m->module->leftModuleId = -1;
m->module->rightModuleId = -1;
} }
} }
} }


+ 5
- 0
src/engine/Engine.cpp View File

@@ -267,6 +267,11 @@ static void Engine_step(Engine *that) {
for (Cable *cable : that->internal->cables) { for (Cable *cable : that->internal->cables) {
cable->step(); cable->step();
} }
// Swap messages of all modules
for (Module *module : that->internal->modules) {
std::swap(module->leftProducerMessage, module->leftConsumerMessage);
std::swap(module->rightProducerMessage, module->rightConsumerMessage);
}
} }


static void Engine_updateAdjacent(Engine *that, Module *m) { static void Engine_updateAdjacent(Engine *that, Module *m) {


Loading…
Cancel
Save