Skip to content

Commit

Permalink
codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-sts committed May 19, 2024
1 parent b0b9d90 commit 3402c81
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,17 @@ class SceneCanvas : OpenGLCanvas() {
}

fun handleClick(screenPoint: Vector2i, mouseButton: MouseButton) {
// Coordinates in the frame coordinate system.
val frameCoordinates = determineFrameCoordinates(screenPoint)
val frameIndexCoordinates = frameCoordinates.toIntVector()
val frameIndex = frameIndexCoordinates.y * columnsNumber + frameIndexCoordinates.x
// Frame local coordinate including spacing area.
var frameLocalCoordinate = Vector2f(frameCoordinates.x % 1, frameCoordinates.y % 1)
// Frame local coordinate excluding spacing area.
frameLocalCoordinate = frameToShaderVector(frameLocalCoordinate, framesSize)
frameLocalCoordinate.x /= framesRatio
// Frame local coordinates (within a frame) including spacing area.
var frameLocalCoordinates = Vector2f(frameCoordinates.x % 1, frameCoordinates.y % 1)
// Frame local coordinates excluding spacing area.
frameLocalCoordinates = frameToShaderVector(frameLocalCoordinates, framesSize)
frameLocalCoordinates.x /= framesRatio
val framePixelCoordinate =
Vector2f(frameLocalCoordinate.x * framesSize.x, frameLocalCoordinate.y * framesSize.y).toIntVector()
Vector2f(frameLocalCoordinates.x * framesSize.x, frameLocalCoordinates.y * framesSize.y).toIntVector()

if (mouseButton == landmarkInteractionMouseButton) {
if (isFirstAssociatingFrameChosen) {
Expand Down
12 changes: 3 additions & 9 deletions src/main/kotlin/solve/rendering/engine/core/batch/RenderBatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@ open class RenderBatch(
textures.clear()
}

override fun compareTo(other: RenderBatch): Int {
return if (zIndex < other.zIndex) {
-1
} else if (zIndex > other.zIndex) {
1
} else {
0
}
}
override fun compareTo(other: RenderBatch): Int = batchComparator.compare(this, other)

fun bind() {
glBindVertexArray(vaoID)
Expand Down Expand Up @@ -199,5 +191,7 @@ open class RenderBatch(

companion object {
private const val MaxTexturesNumber = 7

private val batchComparator = Comparator.comparingInt<RenderBatch> { it.zIndex }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,36 @@ abstract class LandmarkLayerRenderer(
this._visibleLayers = newVisibleLayers
_visibleLayersSelectionIndices = newVisibleLayersSelectionIndices
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is LandmarkLayerRenderer) return false

if (getScene != other.getScene) return false
if (framesRatio != other.framesRatio) return false
if (_visibleLayers != other._visibleLayers) return false
if (_previousVisibleLayers != other._previousVisibleLayers) return false
if (visibleLayersToLandmarksMap != other.visibleLayersToLandmarksMap) return false
if (_visibleLayersLandmarks != other._visibleLayersLandmarks) return false
if (_visibleLayersSelectionIndices != other._visibleLayersSelectionIndices) return false
if (_hiddenVisibleLayersInCurrentFrame != other._hiddenVisibleLayersInCurrentFrame) return false
if (_newVisibleLayersInCurrentFrame != other._newVisibleLayersInCurrentFrame) return false
if (layers != other.layers) return false

return true
}

override fun hashCode(): Int {
var result = getScene.hashCode()
result = 31 * result + framesRatio.hashCode()
result = 31 * result + _visibleLayers.hashCode()
result = 31 * result + _previousVisibleLayers.hashCode()
result = 31 * result + visibleLayersToLandmarksMap.hashCode()
result = 31 * result + _visibleLayersLandmarks.hashCode()
result = 31 * result + _visibleLayersSelectionIndices.hashCode()
result = 31 * result + _hiddenVisibleLayersInCurrentFrame.hashCode()
result = 31 * result + _newVisibleLayersInCurrentFrame.hashCode()
result = 31 * result + layers.hashCode()
return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ abstract class Renderer(protected val window: Window) : Comparable<Renderer> {
rebufferBatches()
}

batches.sort()
batches.sorted().forEach { batch ->
batch.bind()
glDrawElements(batch.primitiveType.openGLPrimitive, batch.getVerticesNumber(), GL_UNSIGNED_INT, 0)
Expand Down

0 comments on commit 3402c81

Please sign in to comment.