Skip to content

Commit 888e597

Browse files
committed
fix: Lower boundary force further to prevent sticking, decrease extra distance added
1 parent 1176878 commit 888e597

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • particles-kool/src/commonMain/kotlin/me/dvyy/particles/compute/simulation

particles-kool/src/commonMain/kotlin/me/dvyy/particles/compute/simulation/FieldsShader.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,15 @@ class FieldsShader(
167167
// Wall repulsion
168168
//TODO make configurable, since lennardJones might not be provided
169169
fun lJ(dist: KslExpression<KslFloat1>) = (functions["lennardJones"] as KslFunctionFloat1)
170-
.invoke(dist, 1f.const, 3f.const, 0.002f.const)
171-
nextForce.x += lJ(position.x - 0f.const + 1f.const)
172-
nextForce.x -= lJ(boxMax.x - position.x + 1f.const)
173-
nextForce.y += lJ(position.y - 0f.const + 1f.const)
174-
nextForce.y -= lJ(boxMax.y - position.y + 1f.const)
170+
.invoke(dist, 1f.const, 5f.const, 0.0001f.const)
171+
val extraDist = 0.1f.const // Add a small amount of distance so the force is always nonzero
172+
nextForce.x += lJ(position.x + extraDist)
173+
nextForce.x -= lJ(boxMax.x - position.x + extraDist)
174+
nextForce.y += lJ(position.y + extraDist)
175+
nextForce.y -= lJ(boxMax.y - position.y + extraDist)
175176
`if`(boxMax.z ne 0f.const) {
176-
nextForce.z += lJ(position.z - 0f.const + 1f.const)
177-
nextForce.z -= lJ(boxMax.z - position.z + 1f.const)
177+
nextForce.z += lJ(position.z + extraDist)
178+
nextForce.z -= lJ(boxMax.z - position.z + extraDist)
178179
}
179180
// Cap force
180181
`if`(length(nextForce) gt params.maxForce.ksl) {

0 commit comments

Comments
 (0)