Integrate physics library via WASM
- Dominant language
- Kotlin
- Stars
- 4
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Now that we support WASM on all the targets, we should try to make an integration here.
Maybe here a ECS would help. Since WASM calls are slow, we should consider making one single call or a few calls per frame.
So we could use a memory buffer doing the requested operations, and uploadingthe changes per frame, or using the WASM memory as a way to back up the objects (when supported for example in the JVM and JS).
Since I don't have experience with ECS. Let's invoke @jobe-m and @Quillraven
Do you folks think this is doable with Fleks?
With this interface: https://github.com/korlibs/korge/blob/cc9f37efe745c776957c0a69989f3733300fa1f5/korge-core/src/common/korlibs/wasm/WASMLib.kt#L9-L56
The idea would be to:
```kotlin
// Once
val xyAddress = wasm.malloc(elementCount * 4 * 2)
// ...
// Per frame
wasm.writeBuffer(xyAddress , xyBuffer) // Copy ECS data into WASM memory
wasm.invokeFunction("doSimulation")
wasm.readBuffer(xyAddress , xyBuffer) // Read-back ECS data into WASM memory
```
So one write, one call and one read per frame, which might be fast enough.
But not sure if that's doable or how ECS works?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the referenced korge-core/src/common/korlibs/wasm/WASMLib.kt lines 9-56, then investigate how Fleks ECS data could be exchanged with WASM. There are no tests or implementation files named in the issue; done would require a concrete, agreed integration approach or prototype covering the per-frame buffer, call, and read-back flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, wasm
- Domain
- game-dev, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100