14 ms·
Rapier is a set of 2D and 3D physics engines written in Rust
- calebpeterson 3y agoReally good JS interoperability too: https://www.rapier.rs/docs/user_guides/javascript/getting_started_js https://www.rapier.rs/docs/user_guides/javascript/getting_st...
- Sateeshm 3y agoAnd Threlte (ThreeJS in Svelte) has great rapier integration https://threlte.xyz/docs/reference/rapier/getting-started https://threlte.xyz/docs/reference/rapier/getting-started
- GenericCanadian 3y agoI wrote a guide on the Bevy plugin for Rust which you can read here: https://taintedcoders.com/bevy/rapier/ https://taintedcoders.com/bevy/rapier/ An interesting alternative in the Bevy space is Bevy XPBD which I also wrote about: https://taintedcoders.com/bevy/xpbd/ https://taintedcoders.com/bevy/xpbd/
- 01HNNWZ0MV43FF 3y agoXPBD has caught my fascination. I've done a couple trial implementations and put AABB-only XPBD in my latest game jam. The only thing I haven't gotten to work is rotation. Everything else, the complexity just melts away. Linear algebra? Nope. Just Vec3. Matrix? Solver? You hit your head, it's 1998, just iterate over all the constraints and satisfy them. Collision margins? Skill issue. Broadphase? GJK? Don't over-think it. Throw a modern CPU at it, do the collect_pairs optimization, then realize you were actually malloc-bound and fix that, and it can handle 100 or so objects without blinking. Don't need Bullet. The velocity fix-up step also threw me off, but having prototyped it for AABBs, I suspect I can translate it back to generic shapes. I skipped it at first and all my collisions were slightly elastic.
- manuel2258 3y agoI'm currently using xpbd to work on a physics driven 2d fighting game, and as of right now, I'm really enjoying it! Until now there was only one problem where some collisions would vanish for one frame. But stuff like that can be easily worked around and even better reported and fixed.
- chrisjj 3y agoI am the only one feeling queasy at a system that treats slow-moving as non-moving? > ) Sleeping is a technique that reduces the cost of simulating objects that are not moving to improve performance. We can tweak it by adding a SleepingThreshold resource: fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugins(PhysicsPlugins::default()) // These are the default values .insert_resource(SleepingThreshold { linear: 0.1, angular: 0.2
- porphyra 3y agoDimforge is really doing god's work. I would be so excited if nalgebra + Rust can replace Eigen + C++ for robotics stuff like localization and mapping.
- accurrent 3y agoYes! Ive been working mostly in rust recently for robotics projects. The amount of time our industry wastes on C++isms is ridiculous where rust just works. Unfortunately theres an old guard that refuses to let up and invest in rust. Tbh there is a huge industry aroumd C++ robotics code so I can see why.
- iExploder 3y agoCompanies barely have enough time and money to keep developing their already existing 10+ yrs old tested and "working" codebases as is, how would anyone switch to a whole new language at this point?
- abricq 3y agoMaybe not converting legacy code, but starting new projects in Rust ! At my robotics company (where I lost so many hours compiling overly-templated code in C++), I was able to convince my boss to start a new small product in Rust (was an internal simulation tool) and it convinced him to let me work on another new product a few month later, also in Rust, on a much bigger scale. He had only ever worked in C++ before, and I guess he doesn't mind to loose hours compiling and fixing memory leaks. But regardless, it worked and now I can work (a bit) in Rust.
- robertlagrant 3y agoThat's great - I mostly work in Python now and I came from the Java world. My first paid Python project was from that time - a little data munging script I was allowed to write in Python.
- accurrent 3y ago
- alex_suzuki 3y agoAnyone know how this compares to something like Box2D? (apart from also supporting 3D)
- excsn 3y agoMight be interested in https://www.youtube.com/watch?v=wgUiZ7E19eM https://www.youtube.com/watch?v=wgUiZ7E19eM
- alex_suzuki 3y agoThanks, that was informative – albeit a bit focused on performance.
- shdh 3y agoHow does it compare to Jolt?
- infogulch 3y agoI got sucked down a Geometric Algebra rabbit hole a few months ago, which seems like a remarkably concise and intuitive way to work in a very wide variety of geometries, including 2D, 3D, 4D+, non-euclidean etc. I've wondered if GA would make a good foundation for a physics engine... There are a few small rust libraries that look interesting [1][2], but none with a lot of traction. Has anyone looked into this? [1]: https://crates.io/keywords/geometric-algebra https://crates.io/keywords/geometric-algebra [2]: https://github.com/Lichtso/geometric_algebra https://github.com/Lichtso/geometric_algebra If you dare, a good place to jump in might be Freya Holmér's Why can't you multiply vectors? - https://www.youtube.com/watch?v=htYh-Tq7ZBI https://www.youtube.com/watch?v=htYh-Tq7ZBI - Then https://bivector.net/index.html https://bivector.net/index.html
- xixixao 3y agoFun fact: I used GA in Excalidraw, and it's still powering some of the interactions! https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/galines.ts https://github.com/excalidraw/excalidraw/blob/master/package...
- falcor84 3y agoWhy "still"? Have you intentionally decided to move away from GA? If so, why?
- xixixao 3y agoBecause it was a while ago and I wouldn’t be surprised if someone ripped it out. It’s a bit of an overkill for what it’s used for / the fact that it is not used widely in the app.
- chrisjj 3y agoInteresting. What advantage did this gain?
- msvan 3y agoThis one has some more traction: https://github.com/fu5ha/ultraviolet https://github.com/fu5ha/ultraviolet
- hansonpeter 3y ago[dead]
- evrimoztamur 3y agoI built a game using Rapier! Using its deterministic mode, I built an online multiplayer game whereby players take turn slamming bugs against the other team and capture the hill. It doesn't have a single-player mode yet (writing an AI for it is a bit more challenging than the chess-like I made) but check it out at https://evrimzone.itch.io/crittershowdown https://evrimzone.itch.io/crittershowdown and the physics/game logic source code at https://github.com/evrimoztamur/crittershowdown/blob/e4d9a1928146197f271b526a38bf8224a9dbf1c3/shared/src/logic/game.rs#L146 https://github.com/evrimoztamur/crittershowdown/blob/e4d9a19.... I plan to write a post about how I wired it together and what I learned, but overall very solid library and well-thought of Rust-y API that enabled me to do everything I needed it to.
- abricq 3y agoLooks real fun. Was it easy to deploy it on your website ? did you compile in web-assembly ? Or are you hosting all the logic onto a local server ?
- evrimoztamur 3y agoFor the deployment, I am running the server applications for both Maginet (https://evrimzone.itch.io/maginet https://evrimzone.itch.io/maginet) and Critter Showdown on the same $5 server, under a different subdomain. These subdomains are reverse-proxied by nginx behind Let's Encrypt certificates. Game servers host lobby and game logic, and are compiled to native Rust binaries. The client-side is compiled to WebAssembly (I don't use an engine, so it's all wasm-bindgen) and the Steam version (of Maginet) is just a thin Electron wrapper around the same thing that runs in the browser. In both games, the client and server share all the game related logic, with the server orchestrating synchronization of states, and client wrapping it all with the I/O. Was it easy? In the end, sure, it's a very simple system. However, a lot of gotchas including HTTP headers (connecting itch.io to my personal domain, or making sure that when the game updates the clients pick up the new binary). I wrote about the client/server part of Maginet and its technical aspects over at https://evrim.zone/blog/projects/maginet/development_overview https://evrim.zone/blog/projects/maginet/development_overvie.... However, I did not write much about the deployment. Both Critter Showdown and Maginet are essentially the same framework, I built the former in two weeks for a jam based on the stripped-down Maginet shell. If you follow the instructions on GitHub, you should be able to download and run both of them quite easily. Build client, build and run server, then head out to localhost:port to play! PS: Maginet runs the shared game logic on the server side, but Critter Showdown (with Rapier2D physics) does not. Maginet has a stricter move validation logic (legal vs illegal turns for your mages) that Critter Showdown doesn't (force impulse vectors for your bugs). Turns are passed in Critter Showdown only when both players' turns are received, and it works pretty seamlessly.
- sillysaurusx 3y agoI’ll never be able to read "rapier" and not think of https://youtu.be/K_rZ27Jdc00?si=rqibtrXl-Wpa49gr https://youtu.be/K_rZ27Jdc00?si=rqibtrXl-Wpa49gr
- anasrin 3y agoUsing rapier along side three js, overall I really like it. But lack of documentation on wasm make me jump back and forth on rust version
- amne 3y agoWhat is the main feature? I hope it's not "Rust".
- timeon 3y agoThat is important feature if you want to use it within Rust code-base.
- lukan 3y agoQuite fast, because of a parallel algorithm. Many benchmarks said so, too. But I cannot directly compare, how it works out for real, as I did not finish yet migrating my engine from Box2D (also in wasm) to rapier and just did some small experiments with rapier otherwise.
- dncornholio 3y agoSo maybe you could have listed all the reasons you opted to switch to Rapier? Or was it the benchmark results?
- lukan 3y ago"Or was it the benchmark results?" Yes. More power means more options in the game. But I did not decided to switch yet, I need to see how it performs. But for this I have to implement a basic version.
- gs17 3y agoIt's effectively the only physics engine for Rust, so that's an important feature.
- rollulus 3y agoFrom building a rigid body physics engine decades ago I remember that stacking was a very hard problem. The best solution at the time to avoid objects sinking into the ground was to create a directed acyclic graph, starting with the ground and pushing bodies outward. It required multiple iterations to converge and felt very hacky. Does anyone know if this problem has been solved nowadays? I couldn’t find any mention of stacking in this project.
- QuadmasterXLII 3y agoThe author of Box2D just put out a fantastic blog post on exactly that subject: https://box2d.org/posts/2024/02/solver2d/ https://box2d.org/posts/2024/02/solver2d/ The author's video linked at the bottom of the post shows how each solver handles various hard stacking problems https://youtu.be/sKHf_o_UCzI https://youtu.be/sKHf_o_UCzI
- TinkersW 3y agoStacking works fine today.. you don't need a acyclic graph, just run the solver for enough iterations and it will converge, multiple iterations is to be expected given the number of contacts and friction constraints involved. If you track the max residual you can run until it reaches ~0. The only kinda busted aspect is that collision & solver only runs at some limited update rate, so if you start with penetration it needs to resolve that, which is kinda "fake" since real world objects don't penetrate like that, so this can add extra motion and make the stack less stable, but there are various methods to work around this, all the popular physics engine have some solution or another.
- hnben 3y agoHow good is it suited for neuro evolution? i.e.: * Can it do multiple concurrent headless simulations on GPU? * Can it handle many Mobs/NPCs interacting with each other? (1.000? 1.000.000?) * Is there a limit on the frame rate?
- lukan 3y agoAre you sure, you are in the right thread? Nothing runs on GPU here, no NPCs, no game engine. This is a physic engine.
- lostdog 3y agoNVidia has a physics engine that runs on the GPU. It is really useful if you're training neural nets, which also run in parallel on the GPU. That's probably what the other poster was thinking about when they asked.
- lukan 3y agoI know about PhysX (have not tried it out, though) but it is news to me, that its hardware part is also really useful for training neural nets? More so than the ordinary GPU?
- lostdog 3y agoI'm referring to the Isaac simulator. Here's an example of using parallel training to learn walking policies very quickly: https://syncedreview.com/2021/10/01/deepmind-podracer-tpu-based-rl-frameworks-deliver-exceptional-performance-at-low-cost-115/ https://syncedreview.com/2021/10/01/deepmind-podracer-tpu-ba...
- iercan 3y agoI tried to build a small web demo with Rapier too https://github.com/iErcann/NotRoblox https://github.com/iErcann/NotRoblox (no rust) What I like : - Good documentation compared to AmmoJS (you need to read pybullet) - Recent - You can run it server side (Node) & client side (Browser), here I'm running it server side but it's possible to do both and implement client side prediction + reconciliation - Small bundle (AmmoJS was like 2 MB?)
- gs17 3y ago> What I like : - Good documentation compared to AmmoJS (you need to read pybullet) On the Rust side, the Rapier docs are out of date AFAIK. Fortunately I'm stuck on the previous version so it's not so bad.
- bambax 3y agoOn the same topic I really like Matthias Müller's lectures and simple and readable JS code "Ten Minute Physics" https://matthias-research.github.io/pages/tenMinutePhysics/index.html https://matthias-research.github.io/pages/tenMinutePhysics/i...
- xpe 3y agoRelated to 3D but different from physics engines: for those interested in BREP (boundary representation) CAD kernels, you might be interested in the open source Rust project called Fornjot.
- digdugdirk 3y agoThank you! I clicked the link on this one hoping it'd be CAD applicable. Just FYI for any random geniuses who happen to read this post - if you can create a modern open-source GPU accelerated CAD kernel (GPU computation, not graphics), mechanical engineers the world over will build shrines in your honour. #HeresHoping
- LoganDark 3y agoThese guys (Dimforge) used to have a physics engine called nphysics that supported soft bodies and multibodies. It's now been deprecated in favor of Rapier, which doesn't support those or half the other things that nphysics did. As a result, nphysics is so old that it can't be used with the modern ecosystem, but Rapier is so new that it's far less capable. This has happened before as well, they used to have a fluid simulation library called Salva that supported two-way coupling with nphysics, and ran on all GPUs/CPUs, but that's deprecated in favor of Sparkl which doesn't, and also only supports CUDA. As a result, Salva is about as old as nphysics, but Sparkl is so new that it's also far less capable, and it also has no cross-platform support. Seemingly intentionally! (Rewrite to make this code less cross-platform.) Hopefully one day the constant rewrites will stop and they'll settle on something that actually supports everything it should. Until then though, I don't see the dimforge ecosystem working out for me if they keep losing features each rewrite. After all, how do I know that Rapier isn't going to get deprecated in favor of something even newer that doesn't support half the features Rapier does? Sure, give them a break. It's new! It doesn't support all the features that the more mature nphysics does. And that's exactly why the more mature nphysics is completely deprecated and unmaintained in favor of... oh, wait. These would be unrealistic concerns only if dimforge didn't already have a track record. :( I get that one day Rapier might be up to feature parity with what nphysics already had five years ago, but that's a completely arbitrary five-year setback for developers who want to build on these features that are currently missing.
- WanderPanda 3y agoHow does it compare to MuJoCo?
- prashp 3y agoThe demos don't work on Firefox 123.0 for me
- mtoner23 3y agoRust keeps proving the stereotype true lol. 50 game engines written in rust but only 5 games made in rust.
- gs17 3y agoI wish there were 50 physics engines. Rapier doesn't exactly meet my needs but there's no good alternative.
- cyber_kinetist 3y agoI remember one recent game I've enjoyed was written in Rust: (the) Gnorp Apologue (https://gnorp.dev/ https://gnorp.dev/). So maybe feasible with smaller-scale 2D games that can be written without too much "engine" code (in this case the game used SDL for most of the stuff)
- sebular 3y agoI made a simple web game using Rapier that takes advantage of the deterministic physics to prevent cheating by running physics and computing win/loss states on the server (though I stupidly haven’t implemented the high score board yet). It’s an homage to the old Taito electric arcade game “Ice Cold Beer” https://beerbubble.xyz https://beerbubble.xyz
- ixxie 3y agoIf you are into Svelte we have a nice API for you: https://threlte.xyz/docs/reference/rapier/getting-started https://threlte.xyz/docs/reference/rapier/getting-started
- catapart 3y agoOh awesome! I was just putting together some utilities for a barebones, no-bundler, vanilla javascript game library, and was wondering what kind of physics engine would work for demonstrating it. This looks perfect! I love that you already have the compatibility libraries available. Actually, now that I take a look at the webpage, I really love everything this company is doing. Very interested in working with these libraries!
- coolvision 3y agoI tried to make a robot simulator with rapier, with a mixed sucess: https://grgv.xyz/blog/simulator4/ https://grgv.xyz/blog/simulator4/ The performance is great but realism of joints and motors is lacking, and not suitable realistic simulation.