Skip to content

Commit

Permalink
update frames renderer loading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-sts committed Mar 10, 2024
1 parent 19420fb commit 77ec591
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import solve.rendering.engine.utils.toIntVector
import solve.scene.controller.SceneController
import solve.scene.model.VisualizationFrame
import solve.utils.ceilToInt
import java.util.Collections.synchronizedList
import java.util.concurrent.CopyOnWriteArrayList
import kotlin.math.abs
import kotlin.math.min

Expand Down Expand Up @@ -58,7 +58,7 @@ class FramesRenderer(

private var cameraLastGridCellPosition = getScreenCenterGridCellPosition()

private val bufferFramesToUpload = synchronizedList<LoadedBufferFrameData>(mutableListOf())
private val bufferFramesToUpload = CopyOnWriteArrayList<LoadedBufferFrameData>(mutableListOf())
private val framesLoadingCoroutineScope = CoroutineScope(Dispatchers.Default)

private var needToReinitializeBuffers = false
Expand Down Expand Up @@ -166,9 +166,7 @@ class FramesRenderer(

private fun uploadLoadedFramesToBuffers() {
bufferFramesToUpload.forEach { frame ->
synchronized(bufferFramesToUpload) {
bufferFramesToUpload.remove(frame)
}
bufferFramesToUpload.remove(frame)
bufferFramesArrayTexture?.uploadTexture(frame.textureData, frame.bufferIndex)
Texture2D.freeData(frame.textureData)
}
Expand Down Expand Up @@ -293,9 +291,7 @@ class FramesRenderer(
return@launch
}

synchronized(bufferFramesToUpload) {
bufferFramesToUpload.add(LoadedBufferFrameData(textureData, index))
}
bufferFramesToUpload.add(LoadedBufferFrameData(textureData, index))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/solve/scene/SceneFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import tornadofx.find
* Transforms common application data models into scene data and applies it.
*/
object SceneFacade {
val lastVisualizationKeepSettingsProperty = SimpleObjectProperty(false)
val lastVisualizationKeepSettingsProperty = SimpleObjectProperty(true)
private var lastVisualizationKeepSettings: Boolean
get() = lastVisualizationKeepSettingsProperty.value
private set(value) {
Expand Down

0 comments on commit 77ec591

Please sign in to comment.