Skip to content

Commit

Permalink
legacy parameter for bidirectional cell connections
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Sep 14, 2024
1 parent a015c32 commit aad96aa
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
11 changes: 6 additions & 5 deletions source/EngineGpuKernels/CellFunctionProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ __inline__ __device__ void CellFunctionProcessor::resetFetchedActivities(Simulat
auto otherExecutionOrderNumber = cell->connections[i].cell->executionOrderNumber;
auto otherInputExecutionOrderNumber = cell->connections[i].cell->inputExecutionOrderNumber;
auto otherOutputBlocked = cell->connections[i].cell->outputBlocked;
bool flowToCell =
cell->inputExecutionOrderNumber == otherExecutionOrderNumber && !otherOutputBlocked
&& cell->executionOrderNumber > otherInputExecutionOrderNumber;
bool flowToCell = !(cudaSimulationParameters.features.legacyModes && cudaSimulationParameters.legacyCellDirectionalConnection)
? cell->inputExecutionOrderNumber == otherExecutionOrderNumber && !otherOutputBlocked
&& cell->executionOrderNumber > otherInputExecutionOrderNumber
: false;
if (otherInputExecutionOrderNumber == cell->executionOrderNumber && !flowToCell) {
if (maxOtherExecutionOrderNumber == -1) {
maxOtherExecutionOrderNumber = otherExecutionOrderNumber;
Expand Down Expand Up @@ -134,8 +135,8 @@ __inline__ __device__ Activity CellFunctionProcessor::calcInputActivity(Cell* ce
if (connectedCell->outputBlocked || connectedCell->livingState != LivingState_Ready ) {
continue;
}
if (connectedCell->inputExecutionOrderNumber == cell->executionOrderNumber && connectedCell->executionOrderNumber > cell->executionOrderNumber
&& !cell->outputBlocked) {
if (!(cudaSimulationParameters.features.legacyModes && cudaSimulationParameters.legacyCellDirectionalConnection) && connectedCell->inputExecutionOrderNumber == cell->executionOrderNumber
&& connectedCell->executionOrderNumber > cell->executionOrderNumber && !cell->outputBlocked) {
continue;
}
if (connectedCell->executionOrderNumber == cell->inputExecutionOrderNumber) {
Expand Down
2 changes: 1 addition & 1 deletion source/EngineGpuKernels/MuscleProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ __device__ __inline__ void MuscleProcessor::movement(SimulationData& data, Simul
cell->vel += direction;
cell->cellFunctionData.muscle.lastMovementX = direction.x;
cell->cellFunctionData.muscle.lastMovementY = direction.y;
if (!cudaSimulationParameters.features.legacyModes || !cudaSimulationParameters.legacyCellFunctionMuscleNoActivityReset) {
if (!(cudaSimulationParameters.features.legacyModes && cudaSimulationParameters.legacyCellFunctionMuscleNoActivityReset)) {
activity.channels[0] = 0;
activity.origin = ActivityOrigin_Unknown;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void LegacyAuxiliaryDataParserService::activateParametersAndFeaturesForLegacyFil
if (programVersion.empty()) {
parameters.features.legacyModes = true;
parameters.legacyCellFunctionMuscleNoActivityReset = true;
parameters.legacyCellDirectionalConnection = true;
}

//*******************
Expand Down
1 change: 1 addition & 0 deletions source/EngineInterface/SimulationParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,6 @@ bool SimulationParameters::operator==(SimulationParameters const& other) const
&& legacyCellFunctionMuscleMovementAngleFromSensor == other.legacyCellFunctionMuscleMovementAngleFromSensor
&& muscleMovementVisualization == other.muscleMovementVisualization
&& legacyCellFunctionMuscleNoActivityReset == other.legacyCellFunctionMuscleNoActivityReset
&& legacyCellDirectionalConnection == other.legacyCellDirectionalConnection
;
}
1 change: 1 addition & 0 deletions source/EngineInterface/SimulationParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ struct SimulationParameters

bool legacyCellFunctionMuscleMovementAngleFromSensor = false;
bool legacyCellFunctionMuscleNoActivityReset = false;
bool legacyCellDirectionalConnection = false;

bool operator==(SimulationParameters const& other) const;
bool operator!=(SimulationParameters const& other) const { return !operator==(other); }
Expand Down
7 changes: 7 additions & 0 deletions source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,13 @@ void _SimulationParametersWindow::processBase()
.tooltip("If activated, the activity in channel #0 is not set to 0 in muscle cells which are in movement mode. Thus the output of this type "
"of muscles can be reused for other muscle cells."),
parameters.legacyCellFunctionMuscleNoActivityReset);
AlienImGui::Checkbox(
AlienImGui::CheckboxParameters()
.name("Allow bidirectional connections")
.textWidth(RightColumnWidth)
.defaultValue(origParameters.legacyCellDirectionalConnection)
.tooltip("If activated, two connected cells can receive each other's input if the 'input execution number' matches."),
parameters.legacyCellDirectionalConnection);
AlienImGui::EndTreeNode();
}
}
Expand Down

0 comments on commit aad96aa

Please sign in to comment.