Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dev-cli): Lua Bindings for C++ Physics Library and Compilation to WASM32 #931

Open
PeterFarber opened this issue Jul 31, 2024 · 1 comment
Labels
cli ao CLI enhancement New feature or request

Comments

@PeterFarber
Copy link
Contributor

Description

I’m proposing a feature that involves integrating a C++ physics library with Lua and compiling the resulting code into WebAssembly (WASM). This integration will enable Lua scripts to utilize the functionalities of the C++ physics library and ensure that the code can run efficiently in a web environment.

This feature aims to enhance the usability of the physics library by integrating it into Lua scripts and expanding its reach to web applications through WASM32. The result will be a shared library for Lua and a WASM module for web deployment.

1. Create Lua Bindings for the C++ Physics Library

  • Objective: Develop Lua bindings for the existing C++ physics library to allow Lua scripts to access and use the library’s functionalities.
  • Tasks:
    • Use a Lua-C++ binding tool such as LuaBridge to create the bindings ( or write them manually ).
    • Expose key functions from the physics library to Lua.
    • Write wrapper functions to handle Lua’s garbage collection and memory management where necessary.

2. Compile the C++ Code and Lua Bindings into a Shared Library

  • Objective: Compile the C++ code and Lua bindings into a shared library (e.g., .so) that can be required by Lua scripts.
  • Tasks:
    • Ensure the shared library exports symbols visible to Lua.
    • Test the shared library by loading it in a Lua environment and verifying that functions can be called as expected.

3. Compile the Lua Files into WASM32

  • Objective: Compile the Lua scripts into WebAssembly 32 Bit (WASM32) format using the dev-cli to ensure compatibility with web environments.
  • Tasks:
    • Use the dev-cli toolchain for compiling Lua files into WASM32.
    • Test the resulting WASM module in a web environment to ensure correct functionality and performance.

Expected Outcome

  • Lua scripts should be able to seamlessly use the C++ physics library functions.
  • A shared library should be created that integrates well with Lua.
  • Lua files should compile successfully into WASM32 and function correctly in web environments.

Additional Information

  • The C++ physics library in question is JoltPhysics.
  • The Lua-C++ binding library to be used is LuaBridge.
  • The dev-cli documentation can be found here.

Benefits

  • Enhances the versatility of the physics library by making it accessible from Lua scripts.
  • Expands usability to web applications through WASM32, providing broader deployment options.
@PeterFarber PeterFarber added enhancement New feature or request cli ao CLI labels Jul 31, 2024
@ppedziwiatr
Copy link
Collaborator

How about adding lua binding for the EVM secp256k1 elliptic curves? :)
I've started to develop it here https://github.com/warp-contracts/ao-redstone-oracle/tree/main/secp256k1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli ao CLI enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants