File tree Expand file tree Collapse file tree
particles-kool/src/commonMain/kotlin/me/dvyy/particles/compute/simulation Expand file tree Collapse file tree Original file line number Diff line number Diff 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) {
You can’t perform that action at this time.
0 commit comments