Skip to content

Commit

Permalink
Fix bug causing undirected transactions to appear directed and slight…
Browse files Browse the repository at this point in the history
… refactor of LineBatcher (#2239)
  • Loading branch information
Quasar985 authored Nov 26, 2024
1 parent e58eebf commit fae2f1a
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private int bufferConnectionInfo(final int pos, final IntBuffer dataBuffer, fina
final int highVertex = access.getConnectionHighVertex(pos);
final int flags = (access.isConnectionDimmed(pos) ? 2 : 0) | (access.isConnectionSelected(pos) ? 1 : 0);
final int lineStyle = access.getConnectionLineStyle(pos).ordinal();
final ConnectionDirection connectionDirection = access.getConnectionDirection(pos);
final ConnectionDirection connectionDirection = determineConnectionDirection(pos, access);

dataBuffer.put(representativeTransactionId);
dataBuffer.put(lowVertex * LINE_INFO_BITS_AVOID + ((connectionDirection == ConnectionDirection.LOW_TO_HIGH || connectionDirection == ConnectionDirection.BIDIRECTED) ? LINE_INFO_ARROW : 0));
Expand All @@ -229,16 +229,7 @@ private int updateConnectionInfo(final int pos, final IntBuffer dataBuffer, fina
final int highVertex = access.getConnectionHighVertex(pos);
final int flags = (access.isConnectionDimmed(pos) ? 2 : 0) | (access.isConnectionSelected(pos) ? 1 : 0);
final int lineStyle = access.getConnectionLineStyle(pos).ordinal();
final ConnectionDirection connectionDirection;
if (access.isConnectionDirected(pos)) {
if (access.getConnectionDirection(pos) != ConnectionDirection.UNDIRECTED) { // covers the case where the transaction was initially undirected
connectionDirection = access.getConnectionDirection(pos);
} else {
connectionDirection = ConnectionDirection.LOW_TO_HIGH;
}
} else {
connectionDirection = ConnectionDirection.UNDIRECTED; // undirected transactions shouldn't have an arrow
}
final ConnectionDirection connectionDirection = determineConnectionDirection(pos, access);

dataBuffer.put(representativeTransactionId);
dataBuffer.put(lowVertex * LINE_INFO_BITS_AVOID + ((connectionDirection == ConnectionDirection.LOW_TO_HIGH || connectionDirection == ConnectionDirection.BIDIRECTED) ? LINE_INFO_ARROW : 0));
Expand All @@ -252,6 +243,18 @@ private int updateConnectionInfo(final int pos, final IntBuffer dataBuffer, fina
return -1;
}

private ConnectionDirection determineConnectionDirection(final int pos, final VisualAccess access) {
if (access.isConnectionDirected(pos)) {
if (access.getConnectionDirection(pos) != ConnectionDirection.UNDIRECTED) { // covers the case where the transaction was initially undirected
return access.getConnectionDirection(pos);
} else {
return ConnectionDirection.LOW_TO_HIGH;
}
} else {
return ConnectionDirection.UNDIRECTED; // undirected transactions shouldn't have an arrow
}
}

private int bufferColorInfo(final int pos, final FloatBuffer colorBuffer, final VisualAccess access) {
if (connectionPosToBufferPos.containsKey(pos)) {
final ConstellationColor color = access.getConnectionColor(pos);
Expand All @@ -270,14 +273,14 @@ private int bufferColorInfo(final int pos, final FloatBuffer colorBuffer, final

public GLRenderableUpdateTask updateInfo(final VisualAccess access, final VisualChange change) {
return SceneBatcher.updateIntBufferTask(change, access, this::updateConnectionInfo, gl -> batch.connectIntBuffer(gl, connectionInfoTarget),
gl -> batch.disconnectBuffer(gl, connectionInfoTarget),
new boolean[]{true, true, true, false, true, true, true, true});
gl -> batch.disconnectBuffer(gl, connectionInfoTarget),
new boolean[]{true, true, true, false, true, true, true, true});
}

public GLRenderableUpdateTask updateColors(final VisualAccess access, final VisualChange change) {
return SceneBatcher.updateFloatBufferTask(change, access, this::bufferColorInfo, gl -> batch.connectFloatBuffer(gl, colorTarget),
gl -> batch.disconnectBuffer(gl, colorTarget),
COLOR_BUFFER_WIDTH * 2);
gl -> batch.disconnectBuffer(gl, colorTarget),
COLOR_BUFFER_WIDTH * 2);
}

public GLRenderableUpdateTask updateOpacity(final VisualAccess access) {
Expand Down

0 comments on commit fae2f1a

Please sign in to comment.