this post was submitted on 14 May 2025
392 points (99.5% liked)

PC Gaming

10989 readers
888 users here now

For PC gaming news and discussion. PCGamingWiki

Rules:

  1. Be Respectful.
  2. No Spam or Porn.
  3. No Advertising.
  4. No Memes.
  5. No Tech Support.
  6. No questions about buying/building computers.
  7. No game suggestions, friend requests, surveys, or begging.
  8. No Let's Plays, streams, highlight reels/montages, random videos or shorts.
  9. No off-topic posts/comments, within reason.
  10. Use the original source, no clickbait titles, no duplicates. (Submissions should be from the original source if possible, unless from paywalled or non-english sources. If the title is clickbait or lacks context you may lightly edit the title.)

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] sp3ctr4l@lemmy.dbzer0.com 1 points 5 hours ago* (last edited 4 hours ago)

Nothing about Lua would make it difficult to implement a physics engine in it compared to other languages.

Correct, but said implementation will be orders of magnitude slower than implementing at a lower level... meaning you cannot handle lots of objects, you can only handle a few, and only with a few players if this is all networked... otherwise you get massive physics calculation innacuracy, terrible performance spikes, crashes, and if networked, server hangs/stalls, huge desync, etc.

The hardest part would be integrating with Morrowind's systems. If the engine doesn't expose e.g. collision geometry to scripts in an efficient way, then you'll run into some real challenges.

I mean... that is true, that having to emulate collision meshes/hulls would be less efficient than just actually having direct access to them... but that would be the case with any language, and Lua is still much slower at any real time collision mesh/hull emulation than doing the same in a lower level language.

Even without LuaJIT, there's no reason to expect performance so bad you can't implement realtime rigid body physics. Interpreted Lua is fast, but even if it wasn't, a 60 fps performance target for physics is not tough to achieve at all.

You say that, but I've never seen it done well in a way that can scale for many tens or hundreds or thousands of 3D physics calls in a complex single player scenario, or a multiplayer scenario where you now also have to account for networked synchronization.

Not saying its impossible, just saying it... I've never seen anyone pull off an efficient and accurate 3D physics engine in Lua, untill now with this LuaJIT implementation.

If you can show me a high performance 3d physics engine written entirely in just straight up Lua, well please do show me, and share with the class.

My guess would be that it would be constrained to either specific physics scenarios, as in, wouldn't have as full a realistic physics feature set... wouldn't handle well a lot of simultaneous intersctions... but I'm open to being surprised.

...

Like uh, Godot's Jolt physics are written in C++...

...and while this used to basically be an addon, that was better than Godot's default physics engine...

...even Jolt isn't nearly as efficient or accurate as say, Valve's implementation of Havok in Source.

Godot has been catching up with Unity on this physics engine performance front, but Unity still has the performance edge by a bit, and neither are close to Source.

And these are all C++ physics implementations, to the best of my knowledge.