Skip to content

Commit

Permalink
precise check for crossing connections in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Jan 4, 2025
1 parent a636bb3 commit 8a6e408
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions source/EngineGpuKernels/ConstructorProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ __inline__ __device__ Cell* ConstructorProcessor::continueConstruction(
Math::rotateQuarterClockwise(n);

// assemble surrounding cell candidates
Cell* otherCellCandidates[MAX_CELL_BONDS * 2];
Cell* otherCellCandidates[MAX_CELL_BONDS * 4];
int numOtherCellCandidates = 0;
data.cellMap.getMatchingCells(
otherCellCandidates,
MAX_CELL_BONDS * 2,
MAX_CELL_BONDS * 4,
numOtherCellCandidates,
newCellPos,
cudaSimulationParameters.cellFunctionConstructorConnectingCellMaxDistance[hostCell->color],
Expand Down Expand Up @@ -466,7 +466,22 @@ __inline__ __device__ Cell* ConstructorProcessor::continueConstruction(
for (int i = 0; i < numOtherCellCandidates; ++i) {
Cell* otherCell = otherCellCandidates[i];
if (otherCell->tryLock()) {
if (!CellConnectionProcessor::wouldResultInOverlappingConnection(otherCell, newCellPos)) {
bool crossingLinks = false;
for (int j = 0; j < numOtherCellCandidates; ++j) {
if (i == j) {
continue;
}
auto otherCell2 = otherCellCandidates[j];
for (int k = 0; k < otherCell2->numConnections; ++k) {
if (otherCell2->connections[k].cell == otherCell) {
continue;
}
if (Math::crossing(newCellPos, otherCell->pos, otherCell2->pos, otherCell2->connections[k].cell->pos)) {
crossingLinks = true;
}
}
}
if (!crossingLinks) {
auto delta = data.cellMap.getCorrectedDirection(newCellPos - otherCell->pos);
if (CellConnectionProcessor::hasAngleSpace(data, otherCell, Math::angleOfVector(delta), constructionData.genomeHeader.angleAlignment)) {
otherCells[numOtherCells++] = otherCell;
Expand Down

0 comments on commit 8a6e408

Please sign in to comment.