Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The Rapier Physics Engine (dimforge.com)
164 points by alex_hirner on Aug 27, 2020 | hide | past | favorite | 83 comments


Why do the readmes for physics engines rarely specify how they solve contact constraints? This is one of the most difficult parts of writing a physics engine. It might be less important if you're just interested in visuals and making it "look OK" in a videogame, but it has an impact on the dynamics, so especially if you're interested in robotics or accurate simulation of real-world physics, this is really important to specify.


I would add that the way the contact constraints are solved decides what kind of artifacts you will be getting and you need to understand that to be able to understand precision of your simulation.

Even for a videogame this would be important. You may want to know if it is possible for fast moving objects to pass each other or not. You might then want to limit the velocity of objects (a cheap trick to solve the issue, but very effective), or you might want to choose an engine specifically for this (for example if you make a billiards game or a shooter).


Cross Platform determinism and great serialization capabilities makes this a networked physics programmer's dream!

I kinda wish this was in cpp, so that I could integrate it with Godot and have it be considered for upstreaming.

Edit:

Wait, no ray cast? I'm confused why that wouldn't be implemented. That's a very simple operation, is it not?

No continuous collision detection is not so great either, but is okay if the performance is good enough to tick at a high rate.


There is another Rust crate[0] from the same author that does ray casting. Also, nothing prevents this from being used in Godot[1].

[0]: https://github.com/dimforge/ncollide

[1]: https://github.com/godot-rust/godot-rust


Yeah, ray-casting and CCD are missing currently, mostly because I didn't have the time to implement them yet (though I did implement them on ncollide/nphysics (https://nphysics.org) so it is mostly a matter of adapting/rewriting them to fit in Rapier.)


I'm making a game in Godot and Rust, so I appreciate this physics engine. You can make Godot modules in Rust, so it could be an add-in (even in the Godot Asset library?) using a Godot Module.

The Rust library to bind to Godot can be found here: https://github.com/godot-rust/godot-rust


A few months back I tried - and failed - to write a basic 2d physics engine for my JS canvas library. Before then, I tried to use existing JS physics engines with the library ... but none of them integrated nicely; the closest I got to making something useful was with Matter.js (see Codepen demo[1]).

Rapier has a WASM version, and JS bindings. I'm already looking forward to see if I can get the engine working with my code. Is there a JS-focussed community around Rapier where I can ask questions if I get stuck?

[1] - https://codepen.io/kaliedarik/pen/zYvbwBy


Author of Rapier here. The best way to get help would be to join our discord server [1]. There is a channel dedicated to rapier.js. So far most of us are Rust devs but we want to grow our JS community progressively.

You can also ask questions/post issues on the rapier.js repository [2]. You will also find a WIP user-guide on the rapier website: [3].

Right now the JS bindings are not complete, so a couple of months of work is still needed to expose all the capabilities of Rapier through JS.

[1]: https://discord.gg/vt9DJSW

[2]: https://github.com/dimforge/rapier.js

[3]: https://www.rapier.rs/docs/user_guides/javascript/getting_st...


Many thanks! I've joined the discord and will have a go at setting up a Rapier-driven demo in a canvas element this weekend.


They have a discord, the link is on their github: https://github.com/dimforge/rapier


I've used Matter.js in a project with custom canvas renderer and it performed great. The only issue that I've had to patch up was tunnelling at high speeds. But this is a common problem with many engines.


- cross platform bit level determinism

- fully serializable state

Wow! Sounds like a boon for Javascript game engines like Bevy. I wonder if they'll support PlayCanvas as well.


Bevy is a a Rust game engine https://bevyengine.org/, although potentially it could be used with js when targeting WASM.


The benchmarks are pretty interesting. Why is it that nphysics has such apparent inconsistency in its frame times?


The main source of inconsistency for nphysics performances is its broad-phase algorithm. It is a tree-based approach which is admittedly not written very efficiently and has very unstable performances when most objects moves.


> Cross-platform determinism: if the enhanced-determinism feature of Rapier is enabled, it will behave in a bit-level cross-platform deterministic way in all platforms that comply with the IEEE 754-2008 floating point standard.

Impressive! I've understood this to be a hard problem. Unity has promised this for years but still hasn't delivered, last time I looked.

Is there anywhere we could read more about the tradeoffs and challenges involved?

Also, how widely has this been tested?

Perhaps most importantly: how can I extend this determinism to my own code?


Do these type of physics engine use Newtonian F=MA at their hearts or do they rely on Lagrangian mechanics?

My instinct tells me the first as it seems more straightforward, but then I realized I just have no idea.

Anyone knowledgeable care to enlighten?


The former, because in order to formulate a physics engine in Lagrangian mechanics you need analytic differentiation (or you can just precalculate the partial derivatives with your own hands, but then it will be precisely the same as coding it in F=ma.)


Yes, it uses a Newtonian formulation. Another physics engine (nphysics) I wrote before rapier, had a Lagrangian formulation of joints (using reduced-coordinates). This is something I intend to add to Rapier too at some points.


On a side note, does anyone know what happened to Bullet3D? It seemed like this was a really good candidate for driving game physics a few years ago, but it's been rebranded as "PyBullet", the wiki's no longer available, and it seems to have pivoted towards simulation. Also it seems like Bullet3 never got a proper release.

Is this a dead project?


It is still going strong and being actively developed : https://github.com/bulletphysics/bullet3 & https://pybullet.org/wordpress/


I think one of its main author was hired by Google AI when they (Google) realized that getting a big fat neural network to model the inverse problem of a physics engine (should call it a mechanics engine, really) had lots of very practical applications.

In other news, bullet is alive and kicking. e.g. It's integration into blender lets you do amazing thing, especially wrt modeling natural environments fast.


They mention wasm bindings. Are there c bindings as well?


No C bindings so far. This is something I would like to consider doing at some point. Though when exactly it is done will depends on the demand since I have limited resources.


I would try this out tomorrow if it had a C FFI. I've been working more with Rust, but I have a lot of existing work in other languages, and a C FFI would make it so much easier to consider this as an alternative.


Bookmarking this comment section in case I ever need a prime example of bikeshedding.


It’s really out of hand. HN seemingly can’t help itself bikeshedding the naming of things, but you’d hope people would check to see all the other similar comments before posting their own not-so-unique take as a top-level comment...

Easy, albeit predictable, fodder for n-gate, if they can be bothered.


You spoke to soon, it's all buried now. The system works?


Regarding inane comments about the name, take a look at this:

https://en.wikipedia.org/wiki/Windows_Mobile#Pocket_PC_2000

Pocket PC 2000, originally codenamed "Rapier", was released on April 19, 2000, and was based on the Windows CE 3.0 kernel.


[flagged]


Please don't troll HN. We ban accounts for that.

https://news.ycombinator.com/newsguidelines.html


Do you not like swords?


Why?


They more than likely mean Rapier, the sword.

But honestly, I agree. Why would you _choose_ a name that sounds like this?


The only people who are upset about naming something after a sword are those who want to be upset. If someone desires to be upset and you make them upset, is that not a service?


[flagged]


> I think 'rapier' is not a good name, for (I hope) obvious reasons.

Fine I'll bite, why's it not a good name? I immediately thought of the type of sword and the thrusting action it implies - which feels apt in the context of physics engines... no?


This explains my initial impression of the name: Funnier, fluffier, fruitier, rapier.


Did you not think 'sword'? Why was your first impression a non-existent word rather than the real one that already exists?


Every word sounds like some other words. Most adults make peace with this situation. But this reminds me of the crisis that ocurred a few years ago in the Washington, DC city government when a councilmember used the word “niggardly” in a meeting and other semi-literate councilmembers had strokes and heart attacks. This actually became an issue that was talked about for months.


I'm not a native speaker, and searching on urban dictionary I could not find anything. What's the problem with the name?


I'm a native English speaker and I didn't get what their problem with it was either. I've never heard anyone voice such an objection to using the word outside of this thread. Bizarre reasoning imo.


Because it sounds like rape


The problem with this kind of slippery-slope way into self-censorhip, is that similarities are (n) an almost infinite possibility in most languages. more so having in mind you're going from french to english.

Same way of thinking got GitHub to try and replace master, for something else like mercurial's main. Having master in the context nothing to do with slavery.

I get someone might be sensible to some words, but I don't see why someone else should keep a list of possible -not good- works declared and updated by the mob mafia of twitter and social media.


Come on man. Are you really going to call your product Poup and say "b-but it's french for Doll". It's not a political thing it's just the way the word rings in current English is bad. Jokes have been being made about "rapier wit" etc. for 50 years.


No offense intended to you at all, but "the way the word rings in current English" seems super subjective. Personally, the notion of "rape" never even occurred to me when I heard this name.

Incidentally, unlike "rapier", words like "raptor" and "rapture" are directly related to the word "rape". These words can be clearly traced back to ancient Greek (meaning something like 'to seize violently'), and perhaps beyond.

Just my $0.02. :-)


I don't think most people associate oil crops with physics engines.


Wow. Until this comment I couldn't see it. Isn't "rapier" (the sword) pronounced differently though?


Don’t tell him about rapeseed.


Well he might know it better as canola oil, which is the "rebranding" it received for precisely the same reason. So I'm not certain that's the intended point.


> canola oil, which is the "rebranding" it received for precisely the same reason

Do you have a source? Wikipedia lists a different reason, see: https://en.wikipedia.org/wiki/Canola_oil:

> The change in name serves to distinguish it from natural rapeseed oil, which has much higher erucic acid content.


(1) A seed was rebranded as an oil?

(2) Not really; the nomenclature and its history is more interesting than that.

(3) The seed is still called rapeseed.

(4) Why was that not the intended point?


1) the corresponding oil - which (unlike the seed) is actually commonly used/referenced thing in English - was

2) it played a role [https://www.chicagotribune.com/news/ct-xpm-1989-10-12-890122...]

3) the sword is still called rapier

4) because it doesn't serve as a logical foil for aforementioned reasons. If anything it just shows a nice analogous response.


Oh give over that article says nothing about it being named Canola because of the word rapeseed containing the word rape. The earlier assumption about the naming of Canola oil is just incorrect.


Well logically it makes sense, branding things with "rape," which is not a commonly known name is not . And there are other articles that support it:

https://www.theguardian.com/world/2015/apr/22/canada-tisdale....

There obviously could have been myriad reasons. Also, Aldi ran into a similar issue with rape:

https://www.telegraph.co.uk/news/2016/03/25/aldi-forced-to-c...


Some other words we could stop using for the same reason:

Rope, rap, rapper, crepe, paper, wrapper, rapid...


None of these are good examples. It's not the spelling. It's the pronunciation to native English speakers. "Rapey".

There's no point getting on a high horse about people being adults, etc. Marketing and advertising empirically work, and not because people are stupid. A lot of time and money is spent thinking up good names and trying to avoid names with embarassing connotations.

If a bunch of native English speakers are telling you that the name sounds bad to native English speakers, then it's worth at least considering rather than dismissing.

EDIT> Reminds me of Rational Rose .petal files.


As a native English speaker I can attest that we sure as shit don't pronounce it "Rapey".


Consider the argument: "Tastier" doesn't bring to mind any associations with "Tasty" because we don't pronounce "Tastier" as "Tasty". Bad argument, right?

Also, why am I wasting time responding? But it is fascinating the extents to which people seem to almost purposefully misunderstand each other online. I sometimes like to explore the space I guess.


Isn't rapier a french word, and pronounced as such?


French, yes. Pronounced according to academie rules, no.


Ok just to clear things up for the repliers, what I should’ve said was that the first part of this word being rape is unfortunate, but not a big deal. It’s fine as a name, but not what I would go with. Like how Uranus is a fine name, but not what I would name it if I was the official namer of planets.


> Uranus

Ignoring that it's usually pronounced Uran-us rather than Ur-anus, really? I spend a lot of time around physicists and astrophysicists and I think you can probably guess how much of an issue this is (or for any adults)


Maybe to people who made "rapey" part of their vocabulary because of internet "humor".


Rapier is like the actual name of some people: https://en.wikipedia.org/wiki/Rapier_(disambiguation)#People


That's true, but not that relevant. There are people with all kinds of last names, e.g.: https://www.boredpanda.com/people-with-dirty-last-names-prob... .


I think only in the same way that 'soccer' is not a good name for football, as a reference to domestic violence


[flagged]


I'm baffled by people put off by the name.

Is 'rapier' not a word used in US English? It's a type of sword. It's nothing to do with 'rape' if that's what you're thinking. It's neither spelt nor pronounced anything like 'rape'. I can't see any possible confusion or connection at all but several people are making it in this thread.


I'm also confused. Perhaps it's more commonly used in EU/Australian/New Zealand English? But even then I don't think so - that type of sword is called that in US made video games too.


On the one hand, I find myself surprised that a sizeable number of people seem to reach that association.

On the other hand, as a native English speaker, I understand the word to be pronounced such that it isn't much of a stretch to put it between "rapey" and "rapiest". While neither of those is, I think, particularly well established as a word in "proper" English, they are understood and used in less formal contexts (if jocularly).

I don't know where all of this leaves us.


I wonder whether the division falls along the lines of people who have vs. have not played D&D.


There's more to the world then US. English is the common tech language that almost everyone on HN is capable reading but not always fluent or mothertongue. I don't think "rapier" is a common word for non-native speakers.


If they at all play fantasy games (video or otherwise) or read fantasy or historical novels then they've run across this word.


It's not commonly used. I'd imagine most people know it but for those that don't I could understand the confusion and concern.

I know the word and its meaning and my initial reaction was negative because I thought "this has very little metaphorical value for a physics engine." You think of kinesis, movement, reactions. "Box" makes sense because it's a physical constraint with coming and interesting physics effects across its physics. Rapier is - to me - just an inanimate object.

But imagine you don't know the word. It could be jarring. And unlike words evoked by a sibling reply (paper, rap, etc) it's not nearly as commonly known or used.


I think your use of 'jarring' is appropriate. There's nothing that's actually wrong with the word--it's type of sword, we're all fine. On the other hand, that may not be worth the risk, compared to other words in a similar vein: scimitar or falchion or something.

Either way, this is a super cool project. You have to love it when someone puts their mind to it and produces something of this quality as open-source. I'm especially interested to see if this might kickstart some of the Rust efforts around GPGPU, which is currently so-so, since a cross-platform solution there seems like it would definitely be a benefit for this kind of project.


>>>I know the word and its meaning and my initial reaction was negative because I thought "this has very little metaphorical value for a physics engine." You think of kinesis, movement, reactions.... Rapier is - to me - just an inanimate object.

I looked at is as implying lightweight, nimble, and functional efficiency for small-scale uses, much like its namesake. I would assign much different metaphorical implications to something named "Zweihander" (Germanic two-handed sword) or an even more esoteric French polearm name such as "Bec de corbin" (a name probably only known to hoplophiles).

https://www.youtube.com/watch?v=9qJBGlChcXU?t=546

https://myarmoury.com/othr_aa_bec.html


Sorry but it's even more insulting to expect someone to cater to a person's ignorance


I'm certainly not asking anyone to change it just showing why for some people it might be off-putting.


Let me see if I understand. A french author should be careful about using this french word on its project because, if someone in the US mispronounce it, it sounds like something that's reprehensible?

I hope I'm not misrepresenting your argument, but the way I understood it sounds very US-centered.


Again I'm neither admonishing nor prescribing anything.

This sort of thing happens sometimes (see: Ford Pinto)


Better tell the British to rename their Rapier Missile System https://en.wikipedia.org/wiki/Rapier_(missile) beause their love for the French language means using a word that sounds vaguely similar to a bad English word.


Different market. Guys, this is just marketing which empirically works. It's hilarious to listen to a bunch of developers who are probably not that good at marketing opine about how this name is just great.

I mean to be empirical one could focus-test. But a controlled focus-test is probably out of reach for a lone developer on a hobby project.


Rapier is not (only) a French word. Sure it has French origins, but I'm sure you will find it in any English language dictionary too, English is made up of loan words.

(On a side note, Firefox's spellchecker marks uncapitalized "english" as incorrect, but not uncapitalized "french". Weird.)


Uncapitalized "french" is common in "french fries" and is also a verb meaning to remove meat from the end of a bone.

I think English is almost always capitalized even when it means spin on a billiard ball.

(I'm not sure about capitalization of "french" in the context of kissing, but I _think_ it's usually capitalized there.)


Most people know that a rapier is a type of sword. No need to insult a whole nationality over it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: