Skip to content

Commit a0d3712

Browse files
Trying to fix performance issues
1 parent 7ba4719 commit a0d3712

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ captures
2222
/composeApp/natives/
2323
/composeApp/projects.json
2424
/composeApp/testreference.png
25+
/composeApp/editor.log
26+
/composeApp/error2.log

composeApp/src/jvmMain/composeResources/files/shaders/desktop/foverlaytile.glsl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#version 330 core
22

3-
const int MAX_OVERLAYS = 16;
3+
const int MAX_OVERLAYS = 2;
44
const int NEIGHBORS_SIZE = 9;
55
const int OVERLAY_NEIGHBORS_SIZE = MAX_OVERLAYS * NEIGHBORS_SIZE;
66
const ivec2 OVERLAY_NEIGHBORS_DIMENSIONS = ivec2(NEIGHBORS_SIZE, MAX_OVERLAYS);
@@ -52,8 +52,6 @@ int getIndex2d(ivec2 pos, ivec2 dimensions) {
5252
vec4 getPixel(vec2 texCord) {
5353
// 0 - nothing
5454
// 1 - current tile to be drawn
55-
// uint tileValue = texture(uTileMap, texCord).r;
56-
// bool isSet = tileValue == 1u;
5755
vec2 tileMapCoordinates = texCord / uTileUnit;
5856
vec2 tileCoordinates = fract(tileMapCoordinates);// [0..1] within a tile
5957

@@ -111,12 +109,10 @@ vec4 getPixel(vec2 texCord) {
111109
for (int i = 0; i < 9; i++) {
112110
ivec2 offset = offsets[i];
113111
neighborTileStatus[i] = texture(uTileMap, texCord + vec2(offset) * uTileUnit).r == 1u;
114-
// if (neighborTileStatus[i]) debugPixels[i] = vec4(1.0);
115112
}
116113

117114

118115

119-
// float[9][MAX_OVERLAYS] tileIndecies;
120116
float[OVERLAY_NEIGHBORS_SIZE] tileIndecies;
121117

122118

@@ -128,7 +124,6 @@ vec4 getPixel(vec2 texCord) {
128124
}
129125
}
130126

131-
// vec2[9][MAX_OVERLAYS] randomOffsets;
132127
vec2[OVERLAY_NEIGHBORS_SIZE] randomOffsets;
133128

134129
float doubleRandomRange = uRandomRange * 2;

composeApp/src/jvmMain/kotlin/ua/valeriishymchuk/lobmapeditor/services/project/EditorService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,20 @@ class EditorService<T : GameScenario<T>>(
154154
private val saveCount = AtomicInteger()
155155

156156
fun save(forceSave: Boolean = false, blocking: Boolean = false) {
157+
val scenario = scenario.value ?: return
157158
if (savingJob?.isActive == true) return
158159
if (!forceSave) {
159160
if (System.currentTimeMillis() - lastSave < 30000 && System.currentTimeMillis() - lastAction < 5000) return
160161
}
161-
if (scenario.value!!.hashCode() == lastHashCode) return
162+
if (scenario.hashCode() == lastHashCode) return
162163

163164
suspend fun save0() {
164165
lastSave = System.currentTimeMillis()
165-
lastHashCode = scenario.value!!.hashCode()
166+
lastHashCode = scenario.hashCode()
166167
val backupId = saveCount.incrementAndGet() % 10
167168
val backupFile = projectRef.getBackupFile(backupId)
168169
projectRef.mapFile.copyTo(backupFile, overwrite = true)
169-
scenarioIOService.save(scenario.value!!, projectRef.mapFile)
170+
scenarioIOService.save(scenario, projectRef.mapFile)
170171
println("Saved map")
171172
}
172173

composeApp/src/jvmMain/kotlin/ua/valeriishymchuk/lobmapeditor/ui/component/project/tool/ToolConfig.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,10 @@ private fun PlayerToolConfig() {
286286
val toolService by rememberInstance<ToolService>()
287287
val editorService by rememberInstance<EditorService<GameScenario.Preset>>()
288288
val scenario by editorService.scenario.collectAsState()
289+
scenario ?: return
289290
val tool = toolService.playerTool
290291
val currentPlayerReference by tool.currentPlayer.collectAsState()
291-
var playerToMoveOwnership by remember(scenario!!, currentPlayerReference) {
292+
var playerToMoveOwnership by remember(scenario, currentPlayerReference) {
292293
mutableStateOf(Reference<Int, Player>(scenario!!.players.indices.first { currentPlayerReference.key != it }))
293294
}
294295
val currentPlayer = currentPlayerReference.getValueOrNull(scenario!!.players::getOrNull) ?: Unit.let {
@@ -310,8 +311,6 @@ private fun PlayerToolConfig() {
310311

311312

312313
LaunchedEffect(currentPlayerReference) {
313-
// println("Changed currentPlayerReference to ${currentPlayerReference.key}")
314-
// val textValue = ammoTextFieldValue.text.toIntOrNull() ?: return@LaunchedEffect
315314
ammoTextFieldValue = ammoTextFieldValue.copy(text = currentPlayer.ammo.toString())
316315
}
317316

0 commit comments

Comments
 (0)